From: Michael Wallner Date: Tue, 20 Oct 2020 15:01:17 +0000 (+0200) Subject: testing X-Git-Tag: 1.1.0-beta1~189 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=340a8c60204067740fe191624cd56307bacea1aa;hp=7883b530881983213dffaa6c71ace9204bedb82a;p=awesomized%2Flibmemcached testing --- diff --git a/.travis.yml b/.travis.yml index 85307b85..abcf4669 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ addons: - libsasl2-dev env: - - CMAKE_BUILD_TYPE=Debug BUILD_TESTING=true ENABLE_SASL=true CFLAGS="-O0 --coverage" CXXFLAGS="-O0 --coverage" + - CMAKE_BUILD_TYPE=Debug BUILD_TESTING=true ENABLE_SASL=true ENABLE_HASH_HSIEH=true CFLAGS="-O0 --coverage" CXXFLAGS="-O0 --coverage" install: - | diff --git a/src/libhashkit/CMakeLists.txt b/src/libhashkit/CMakeLists.txt index ffe4026b..daeec57b 100644 --- a/src/libhashkit/CMakeLists.txt +++ b/src/libhashkit/CMakeLists.txt @@ -7,7 +7,6 @@ endif() add_library(libhashkit SHARED aes.cc algorithm.cc - behavior.cc common.h crc32.cc digest.cc @@ -19,7 +18,6 @@ add_library(libhashkit SHARED hashkit.cc ${HSIEH_CC} jenkins.cc - ketama.cc md5.cc murmur.cc murmur3.cc diff --git a/src/libhashkit/behavior.cc b/src/libhashkit/behavior.cc deleted file mode 100644 index 04d1bba5..00000000 --- a/src/libhashkit/behavior.cc +++ /dev/null @@ -1,38 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * HashKit library - * - * Copyright (C) 2009-2012 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#include "libhashkit/common.h" diff --git a/src/libhashkit/ketama.cc b/src/libhashkit/ketama.cc deleted file mode 100644 index 11e6222b..00000000 --- a/src/libhashkit/ketama.cc +++ /dev/null @@ -1,194 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * HashKit library - * - * Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2009 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#include "libhashkit/common.h" -#include - -#if 0 -static uint32_t ketama_server_hash(const char *key, unsigned int key_length, int alignment) -{ - unsigned char results[16]; - - md5_signature((unsigned char*)key, key_length, results); - return ((uint32_t) (results[3 + alignment * 4] & 0xFF) << 24) - | ((uint32_t) (results[2 + alignment * 4] & 0xFF) << 16) - | ((uint32_t) (results[1 + alignment * 4] & 0xFF) << 8) - | (results[0 + alignment * 4] & 0xFF); -} - -static int continuum_points_cmp(const void *t1, const void *t2) -{ - hashkit_continuum_point_st *ct1= (hashkit_continuum_point_st *)t1; - hashkit_continuum_point_st *ct2= (hashkit_continuum_point_st *)t2; - - if (ct1->value == ct2->value) - return 0; - else if (ct1->value > ct2->value) - return 1; - else - return -1; -} - -int update_continuum(hashkit_st *hashkit) -{ - uint32_t count; - uint32_t continuum_index= 0; - uint32_t value; - uint32_t points_index; - uint32_t points_count= 0; - uint32_t points_per_server; - uint32_t points_per_hash; - uint64_t total_weight= 0; - uint32_t live_servers; - uint8_t *context; - - if (hashkit->active_fn != NULL || hashkit->weight_fn != NULL) - { - live_servers= 0; - - for (count= 0, context= hashkit->list; count < hashkit->list_size; - count++, context+= hashkit->context_size) - { - if (hashkit->active_fn != NULL) - { - if (hashkit->active_fn(context)) - live_servers++; - else - continue; - } - - if (hashkit->weight_fn != NULL) - total_weight+= hashkit->weight_fn(context); - } - } - - if (hashkit->active_fn == NULL) - live_servers= (uint32_t)hashkit->list_size; - - if (live_servers == 0) - return 0; - - if (hashkit->weight_fn == NULL) - { - points_per_server= HASHKIT_POINTS_PER_NODE; - points_per_hash= 1; - } - else - { - points_per_server= HASHKIT_POINTS_PER_NODE_WEIGHTED; - points_per_hash= 4; - } - - if (live_servers > hashkit->continuum_count) - { - hashkit_continuum_point_st *new_continuum; - - new_continuum= realloc(hashkit->continuum, - sizeof(hashkit_continuum_point_st) * - (live_servers + HASHKIT_CONTINUUM_ADDITION) * - points_per_server); - - if (new_continuum == NULL) - return ENOMEM; - - hashkit->continuum= new_continuum; - hashkit->continuum_count= live_servers + HASHKIT_CONTINUUM_ADDITION; - } - - for (count= 0, context= hashkit->list; count < hashkit->list_size; - count++, context+= hashkit->context_size) - { - if (hashkit->active_fn != NULL && hashkit->active_fn(context) == false) - continue; - - if (hashkit->weight_fn != NULL) - { - float pct = (float)hashkit->weight_fn(context) / (float)total_weight; - points_per_server= (uint32_t) ((floorf((float) (pct * HASHKIT_POINTS_PER_NODE_WEIGHTED / 4 * (float)live_servers + 0.0000000001))) * 4); - } - - for (points_index= 0; - points_index < points_per_server / points_per_hash; - points_index++) - { - char sort_host[HASHKIT_CONTINUUM_KEY_SIZE]= ""; - size_t sort_host_length; - - if (hashkit->continuum_key_fn == NULL) - { - sort_host_length= (size_t) snprintf(sort_host, HASHKIT_CONTINUUM_KEY_SIZE, "%u", - points_index); - } - else - { - sort_host_length= hashkit->continuum_key_fn(sort_host, HASHKIT_CONTINUUM_KEY_SIZE, - points_index, context); - } - - if (hashkit->weight_fn == NULL) - { - if (hashkit->continuum_hash_fn == NULL) - value= hashkit_default(sort_host, sort_host_length); - else - value= hashkit->continuum_hash_fn(sort_host, sort_host_length); - - hashkit->continuum[continuum_index].index= count; - hashkit->continuum[continuum_index++].value= value; - } - else - { - unsigned int i; - for (i = 0; i < points_per_hash; i++) - { - value= ketama_server_hash(sort_host, (uint32_t) sort_host_length, (int) i); - hashkit->continuum[continuum_index].index= count; - hashkit->continuum[continuum_index++].value= value; - } - } - } - - points_count+= points_per_server; - } - - hashkit->continuum_points_count= points_count; - qsort(hashkit->continuum, hashkit->continuum_points_count, sizeof(hashkit_continuum_point_st), - continuum_points_cmp); - - return 0; -} -#endif diff --git a/src/libhashkit/murmur3.cc b/src/libhashkit/murmur3.cc index 4446a951..f685a240 100644 --- a/src/libhashkit/murmur3.cc +++ b/src/libhashkit/murmur3.cc @@ -25,15 +25,7 @@ static FORCE_INLINE uint32_t rotl32 ( uint32_t x, int8_t r ) return (x << r) | (x >> (32 - r)); } -static FORCE_INLINE uint64_t rotl64 ( uint64_t x, int8_t r ) -{ - return (x << r) | (x >> (64 - r)); -} - #define ROTL32(x,y) rotl32(x,y) -#define ROTL64(x,y) rotl64(x,y) - -#define BIG_CONSTANT(x) (x##LLU) //----------------------------------------------------------------------------- // Block read - if your platform needs to do endian-swapping or can only @@ -62,19 +54,6 @@ static FORCE_INLINE uint32_t fmix32 ( uint32_t h ) return h; } -//---------- - -static FORCE_INLINE uint64_t fmix64 ( uint64_t k ) -{ - k ^= k >> 33; - k *= BIG_CONSTANT(0xff51afd7ed558ccd); - k ^= k >> 33; - k *= BIG_CONSTANT(0xc4ceb9fe1a85ec53); - k ^= k >> 33; - - return k; -} - //----------------------------------------------------------------------------- void MurmurHash3_x86_32 ( const void * key, int len, @@ -135,218 +114,3 @@ void MurmurHash3_x86_32 ( const void * key, int len, *(uint32_t*)out = h1; } - -//----------------------------------------------------------------------------- - -void MurmurHash3_x86_128 ( const void * key, const int len, - uint32_t seed, void * out ) -{ - const uint8_t * data = (const uint8_t*)key; - const int nblocks = len / 16; - int i; - - uint32_t h1 = seed; - uint32_t h2 = seed; - uint32_t h3 = seed; - uint32_t h4 = seed; - - uint32_t c1 = 0x239b961b; - uint32_t c2 = 0xab0e9789; - uint32_t c3 = 0x38b34ae5; - uint32_t c4 = 0xa1e38b93; - - //---------- - // body - - const uint32_t * blocks = (const uint32_t *)(data + nblocks*16); - - for(i = -nblocks; i; i++) - { - uint32_t k1 = getblock(blocks,i*4+0); - uint32_t k2 = getblock(blocks,i*4+1); - uint32_t k3 = getblock(blocks,i*4+2); - uint32_t k4 = getblock(blocks,i*4+3); - - k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1; - - h1 = ROTL32(h1,19); h1 += h2; h1 = h1*5+0x561ccd1b; - - k2 *= c2; k2 = ROTL32(k2,16); k2 *= c3; h2 ^= k2; - - h2 = ROTL32(h2,17); h2 += h3; h2 = h2*5+0x0bcaa747; - - k3 *= c3; k3 = ROTL32(k3,17); k3 *= c4; h3 ^= k3; - - h3 = ROTL32(h3,15); h3 += h4; h3 = h3*5+0x96cd1c35; - - k4 *= c4; k4 = ROTL32(k4,18); k4 *= c1; h4 ^= k4; - - h4 = ROTL32(h4,13); h4 += h1; h4 = h4*5+0x32ac3b17; - } - - //---------- - // tail - - const uint8_t * tail = (const uint8_t*)(data + nblocks*16); - - uint32_t k1 = 0; - uint32_t k2 = 0; - uint32_t k3 = 0; - uint32_t k4 = 0; - - switch(len & 15) - { - case 15: k4 ^= tail[14] << 16; - /* fall through */ - case 14: k4 ^= tail[13] << 8; - /* fall through */ - case 13: k4 ^= tail[12] << 0; - k4 *= c4; k4 = ROTL32(k4,18); k4 *= c1; h4 ^= k4; - /* fall through */ - case 12: k3 ^= tail[11] << 24; - /* fall through */ - case 11: k3 ^= tail[10] << 16; - /* fall through */ - case 10: k3 ^= tail[ 9] << 8; - /* fall through */ - case 9: k3 ^= tail[ 8] << 0; - k3 *= c3; k3 = ROTL32(k3,17); k3 *= c4; h3 ^= k3; - /* fall through */ - case 8: k2 ^= tail[ 7] << 24; - /* fall through */ - case 7: k2 ^= tail[ 6] << 16; - /* fall through */ - case 6: k2 ^= tail[ 5] << 8; - /* fall through */ - case 5: k2 ^= tail[ 4] << 0; - k2 *= c2; k2 = ROTL32(k2,16); k2 *= c3; h2 ^= k2; - /* fall through */ - case 4: k1 ^= tail[ 3] << 24; - /* fall through */ - case 3: k1 ^= tail[ 2] << 16; - /* fall through */ - case 2: k1 ^= tail[ 1] << 8; - /* fall through */ - case 1: k1 ^= tail[ 0] << 0; - k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1; - }; - - //---------- - // finalization - - h1 ^= len; h2 ^= len; h3 ^= len; h4 ^= len; - - h1 += h2; h1 += h3; h1 += h4; - h2 += h1; h3 += h1; h4 += h1; - - h1 = fmix32(h1); - h2 = fmix32(h2); - h3 = fmix32(h3); - h4 = fmix32(h4); - - h1 += h2; h1 += h3; h1 += h4; - h2 += h1; h3 += h1; h4 += h1; - - ((uint32_t*)out)[0] = h1; - ((uint32_t*)out)[1] = h2; - ((uint32_t*)out)[2] = h3; - ((uint32_t*)out)[3] = h4; -} - -//----------------------------------------------------------------------------- - -void MurmurHash3_x64_128 ( const void * key, const int len, - const uint32_t seed, void * out ) -{ - const uint8_t * data = (const uint8_t*)key; - const int nblocks = len / 16; - int i; - - uint64_t h1 = seed; - uint64_t h2 = seed; - - uint64_t c1 = BIG_CONSTANT(0x87c37b91114253d5); - uint64_t c2 = BIG_CONSTANT(0x4cf5ad432745937f); - - //---------- - // body - - const uint64_t * blocks = (const uint64_t *)(data); - - for(i = 0; i < nblocks; i++) - { - uint64_t k1 = getblock(blocks,i*2+0); - uint64_t k2 = getblock(blocks,i*2+1); - - k1 *= c1; k1 = ROTL64(k1,31); k1 *= c2; h1 ^= k1; - - h1 = ROTL64(h1,27); h1 += h2; h1 = h1*5+0x52dce729; - - k2 *= c2; k2 = ROTL64(k2,33); k2 *= c1; h2 ^= k2; - - h2 = ROTL64(h2,31); h2 += h1; h2 = h2*5+0x38495ab5; - } - - //---------- - // tail - - const uint8_t * tail = (const uint8_t*)(data + nblocks*16); - - uint64_t k1 = 0; - uint64_t k2 = 0; - - switch(len & 15) - { - case 15: k2 ^= (uint64_t)(tail[14]) << 48; - /* fall through */ - case 14: k2 ^= (uint64_t)(tail[13]) << 40; - /* fall through */ - case 13: k2 ^= (uint64_t)(tail[12]) << 32; - /* fall through */ - case 12: k2 ^= (uint64_t)(tail[11]) << 24; - /* fall through */ - case 11: k2 ^= (uint64_t)(tail[10]) << 16; - /* fall through */ - case 10: k2 ^= (uint64_t)(tail[ 9]) << 8; - /* fall through */ - case 9: k2 ^= (uint64_t)(tail[ 8]) << 0; - k2 *= c2; k2 = ROTL64(k2,33); k2 *= c1; h2 ^= k2; - /* fall through */ - case 8: k1 ^= (uint64_t)(tail[ 7]) << 56; - /* fall through */ - case 7: k1 ^= (uint64_t)(tail[ 6]) << 48; - /* fall through */ - case 6: k1 ^= (uint64_t)(tail[ 5]) << 40; - /* fall through */ - case 5: k1 ^= (uint64_t)(tail[ 4]) << 32; - /* fall through */ - case 4: k1 ^= (uint64_t)(tail[ 3]) << 24; - /* fall through */ - case 3: k1 ^= (uint64_t)(tail[ 2]) << 16; - /* fall through */ - case 2: k1 ^= (uint64_t)(tail[ 1]) << 8; - /* fall through */ - case 1: k1 ^= (uint64_t)(tail[ 0]) << 0; - k1 *= c1; k1 = ROTL64(k1,31); k1 *= c2; h1 ^= k1; - }; - - //---------- - // finalization - - h1 ^= len; h2 ^= len; - - h1 += h2; - h2 += h1; - - h1 = fmix64(h1); - h2 = fmix64(h2); - - h1 += h2; - h2 += h1; - - ((uint64_t*)out)[0] = h1; - ((uint64_t*)out)[1] = h2; -} - -//----------------------------------------------------------------------------- - diff --git a/src/libhashkit/murmur3.h b/src/libhashkit/murmur3.h index 4eb4fa64..98768689 100644 --- a/src/libhashkit/murmur3.h +++ b/src/libhashkit/murmur3.h @@ -9,8 +9,4 @@ void MurmurHash3_x86_32 (const void *key, int len, uint32_t seed, void *out); -void MurmurHash3_x86_128(const void *key, int len, uint32_t seed, void *out); - -void MurmurHash3_x64_128(const void *key, int len, uint32_t seed, void *out); - //----------------------------------------------------------------------------- diff --git a/test/fixtures/hashes.hpp b/test/fixtures/hashes.hpp index c3e344f2..2c62c824 100644 --- a/test/fixtures/hashes.hpp +++ b/test/fixtures/hashes.hpp @@ -28,6 +28,7 @@ static const char *input[] = { "when", "yellow", "zip", + "The quick brown fox jumps over the lazy dog", }; static const uint32_t output[][sizeof(input)/sizeof(*input)] = { @@ -38,7 +39,7 @@ static const uint32_t output[][sizeof(input)/sizeof(*input)] = { 384136800U, 214358653U, 2379473940U, 4269788650U, 2864377005U, 2638630052U, 427683330U, 990491717U, 1747111141U, 792127364U, 2599214128U, 2553037199U, - 2509838425U }, + 2509838425U, 1369346549U }, // md5 { 3195025439U, 2556848621U, 3724893440U, 3332385401U, @@ -47,13 +48,13 @@ static const uint32_t output[][sizeof(input)/sizeof(*input)] = { 1451250070U, 2820856945U, 2060845566U, 3646985608U, 2138080750U, 217675895U, 2230934345U, 1234361223U, 3968582726U, 2455685270U, 1293568479U, 199067604U, - 2042482093U }, + 2042482093U, 2642219166U }, // crc { 10542U, 22009U, 14526U, 19510U, 19432U, 10199U, 20634U, 9369U, 11511U, 10362U, 7893U, 31289U, 11313U, 9354U, 7621U, 30628U, 15218U, 25967U, 2695U, 9380U, - 17300U, 28156U, 9192U, 20484U, 16925U }, + 17300U, 28156U, 9192U, 20484U, 16925U, 16719U }, // fnv1_64 { 473199127U, 4148981457U, 3971873300U, 3257986707U, @@ -62,7 +63,7 @@ static const uint32_t output[][sizeof(input)/sizeof(*input)] = { 2345265314U, 3340346032U, 2722964135U, 1173398992U, 2815549194U, 2562818319U, 224996066U, 2680194749U, 3035305390U, 246890365U, 2395624193U, 4145193337U, - 1801941682U }, + 1801941682U, 2112060110U }, // fnv1a_64 { 1488911807U, 2500855813U, 1510099634U, 1390325195U, @@ -71,7 +72,7 @@ static const uint32_t output[][sizeof(input)/sizeof(*input)] = { 561034892U, 4156330026U, 3716417003U, 3475297030U, 1518272172U, 227211583U, 3938128828U, 126112909U, 3043416448U, 3131561933U, 1328739897U, 2455664041U, - 2272238452U }, + 2272238452U, 3890508048U }, // fnv1_32 { 67176023U, 1190179409U, 2043204404U, 3221866419U, @@ -80,7 +81,7 @@ static const uint32_t output[][sizeof(input)/sizeof(*input)] = { 510234242U, 4248244304U, 1362796839U, 103389328U, 1449620010U, 182962511U, 3554262370U, 3206747549U, 1551306158U, 4127558461U, 1889140833U, 2774173721U, - 1180552018U }, + 1180552018U, 3922226286U }, // fnv1a_32 { 280767167U, 2421315013U, 3072375666U, 855001899U, @@ -89,7 +90,7 @@ static const uint32_t output[][sizeof(input)/sizeof(*input)] = { 3654473228U, 260679466U, 1169454059U, 2698319462U, 1062177260U, 235516991U, 2218399068U, 405302637U, 1128467232U, 3579622413U, 2138539289U, 96429129U, - 2877453236U }, + 2877453236U, 76545936U }, // hsieh #ifdef HAVE_HSIEH_HASH @@ -97,9 +98,9 @@ static const uint32_t output[][sizeof(input)/sizeof(*input)] = { 1805464076U, 1895033657U, 409795758U, 979934958U, 3634096985U, 1284445480U, 2265380744U, 707972988U, 353823508U, 1549198350U, 1327930172U, 9304163U, 4220749037U, 2493964934U, 2777873870U, 2057831732U, 1510213931U, 2027828987U, - 3395453351U }, + 3395453351U, 471461527U }, #else - { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, #endif // murmur @@ -110,7 +111,9 @@ static const uint32_t output[][sizeof(input)/sizeof(*input)] = { 2321988328U, 1145154116U, 4038540960U, 2224541613U, 264013145U, 3995512858U, 2400956718U, 2346666219U, 926327338U, 442757446U, 1770805201U, 560483147U, - 3902279934U }, + 3902279934U, 818385189U }, +#else + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, #endif // jenkins @@ -120,7 +123,7 @@ static const uint32_t output[][sizeof(input)/sizeof(*input)] = { 2415988847U, 1494268927U, 1025545760U, 3920481083U, 4153263658U, 3824871822U, 3072759809U, 798622255U, 3065432577U, 1453328165U, 2691550971U, 3408888387U, - 2629893356U }, + 2629893356U, 314054204U }, // murmur3 #ifdef HAVE_MURMUR_HASH @@ -130,10 +133,9 @@ static const uint32_t output[][sizeof(input)/sizeof(*input)] = { 732888124U, 4050076964U, 3298336176U, 1336207361U, 810553576U, 3748182674U, 3860119212U, 3439537197U, 3044240981U, 1464271804U, 3896193724U, 2915115798U, - 1702843840U }, + 1702843840U, 2603515018U }, #else { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, - { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, #endif }; diff --git a/test/tests/hashkit/basic.cpp b/test/tests/hashkit/basic.cpp index 3ba0fb68..369b530f 100644 --- a/test/tests/hashkit/basic.cpp +++ b/test/tests/hashkit/basic.cpp @@ -79,6 +79,14 @@ TEST_CASE("hashkit") { REQUIRE_FALSE(hashkit_compare(&st, hp)); } + SECTION("strerror") { + auto bad_str = string{hashkit_strerror(hp, HASHKIT_MAXIMUM_RETURN)}; + for (int h = HASHKIT_SUCCESS; h < HASHKIT_MAXIMUM_RETURN; ++h) { + auto r = static_cast(h); + REQUIRE(bad_str != hashkit_strerror(hp, r)); + } + } + hashkit_free(&st); hashkit_free(hp); } diff --git a/test/tests/memcached/encoding_key.cpp b/test/tests/memcached/encoding_key.cpp index 7dd091f3..4fc57b0b 100644 --- a/test/tests/memcached/encoding_key.cpp +++ b/test/tests/memcached/encoding_key.cpp @@ -2,8 +2,8 @@ #include "test/lib/MemcachedCluster.hpp" #define TEST_KEY S("test") -#define INITIAL_VAL S("initial") -#define REPLACED_VAL S("replaced") +#define INITIAL_VAL S("initial value, which is longer than AES_BLOCK_SIZE") +#define REPLACED_VAL S("replaced value, thich is longer than AES_BLOCK_SIZE") static inline void check(memcached_st *enc, memcached_st *raw, const char *val, size_t len) { memcached_return_t enc_rc, raw_rc; diff --git a/test/tests/memcached/generate_hash.cpp b/test/tests/memcached/generate_hash.cpp index bbb637c1..aa5358eb 100644 --- a/test/tests/memcached/generate_hash.cpp +++ b/test/tests/memcached/generate_hash.cpp @@ -1,8 +1,8 @@ #include "test/lib/common.hpp" #include "test/fixtures/hashes.hpp" -static constexpr const uint32_t md5_hosts[] = {4U, 1U, 0U, 1U, 4U, 2U, 0U, 3U, 0U, 0U, 3U, 1U, 0U, 0U, 1U, 3U, 0U, 0U, 0U, 3U, 1U, 0U, 4U, 4U, 3U}; -static constexpr const uint32_t crc_hosts[] = {2U, 4U, 1U, 0U, 2U, 4U, 4U, 4U, 1U, 2U, 3U, 4U, 3U, 4U, 1U, 3U, 3U, 2U, 0U, 0U, 0U, 1U, 2U, 4U, 0U}; +static constexpr const uint32_t md5_hosts[] = {4U, 1U, 0U, 1U, 4U, 2U, 0U, 3U, 0U, 0U, 3U, 1U, 0U, 0U, 1U, 3U, 0U, 0U, 0U, 3U, 1U, 0U, 4U, 4U, 3U, 1U}; +static constexpr const uint32_t crc_hosts[] = {2U, 4U, 1U, 0U, 2U, 4U, 4U, 4U, 1U, 2U, 3U, 4U, 3U, 4U, 1U, 3U, 3U, 2U, 0U, 0U, 0U, 1U, 2U, 4U, 0U, 4U}; static constexpr const uint32_t *hosts[] = {nullptr, md5_hosts, crc_hosts}; TEST_CASE("memcached_generate_hash") {