--- /dev/null
+AccessModifierOffset: -2
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: false
+#AlignConsecutiveBitFields: false (in v11)
+AlignConsecutiveDeclarations: false
+AlignConsecutiveMacros: true
+AlignEscapedNewlines: DontAlign
+# AlignOperands: AlignAfterOperator (in v11)
+AlignOperands: false
+AlignTrailingComments: true
+AllowAllArgumentsOnNextLine: true
+AllowAllConstructorInitializersOnNextLine: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: Never
+AllowShortCaseLabelsOnASingleLine: true
+#AllowShortEnumsOnASingleLine: true (in v11)
+AllowShortFunctionsOnASingleLine: Inline
+AllowShortIfStatementsOnASingleLine: Never
+AllowShortLambdasOnASingleLine: All
+AllowShortLoopsOnASingleLine: true
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: Yes
+BinPackArguments: true
+BinPackParameters: true
+#BitFieldColonSpacing: None (in v12)
+BraceWrapping:
+ AfterCaseLabel: false
+ AfterClass: false
+ AfterControlStatement: MultiLine
+ AfterEnum: false
+ AfterExternBlock: false
+ AfterFunction: false
+ AfterNamespace: false
+ AfterObjCDeclaration: false
+ AfterStruct: false
+ AfterUnion: false
+ BeforeCatch: false
+ BeforeElse: false
+# BeforeLambdaBody: false (in v11)
+# BeforeWhile: false (in v11)
+ IndentBraces: false
+ SplitEmptyFunction: true
+ SplitEmptyNamespace: true
+ SplitEmptyRecord: true
+BreakBeforeBinaryOperators: NonAssignment
+BreakBeforeBraces: Custom
+BreakBeforeInheritanceComma: true
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializers: BeforeComma
+BreakConstructorInitializersBeforeComma: true
+BreakInheritanceList: BeforeComma
+BreakStringLiterals: true
+ColumnLimit: 100
+#CommentPragmas: '^ ...'
+CompactNamespaces: false
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 0
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: true
+DeriveLineEnding: true
+DerivePointerAlignment: false
+DisableFormat: false
+#ExperimentalAutoDetectBinPacking: false
+FixNamespaceComments: true
+ForEachMacros:
+ - foreach
+ - BOOST_FOREACH
+IncludeBlocks: Preserve
+IncludeCategories:
+ - Regex: '^"lib(hashkit|(memcached(|protocol|util)))(-.*)?/'
+ Priority: 3
+ - Regex: '^(<|")test/)'
+ Priority: 2
+ - Regex: '.*'
+ Priority: 1
+IncludeIsMainSourceRegex: ''
+IndentCaseLabels: false
+IndentGotoLabels: false
+#IndentExternBlock: false (in v11)
+IndentPPDirectives: AfterHash
+IndentWidth: 2
+IndentWrappedFunctionNames: false
+#InsertTrailingCommas: Wrapped (in v11)
+KeepEmptyLinesAtTheStartOfBlocks: false
+Language: Cpp
+MacroBlockBegin: ''
+MacroBlockEnd: ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+#PenaltyBreakAssignment: 2
+#PenaltyBreakBeforeFirstCallParameter: 19
+#PenaltyBreakComment: 300
+#PenaltyBreakFirstLessLess: 120
+#PenaltyBreakString: 1000
+#PenaltyBreakTemplateDeclaration: 10
+#PenaltyExcessCharacter: 1000000
+#PenaltyReturnTypeOnItsOwnLine: 60
+PointerAlignment: Right
+ReflowComments: true
+SortIncludes: false
+SortUsingDeclarations: true
+SpaceAfterCStyleCast: true
+SpaceAfterLogicalNot: false
+SpaceAfterTemplateKeyword: false
+#SpaceAroundPointerQualifiers: Both (in v12)
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeCpp11BracedList: false
+SpaceBeforeCtorInitializerColon: true
+SpaceBeforeInheritanceColon: true
+SpaceBeforeParens: ControlStatements
+SpaceBeforeRangeBasedForLoopColon: true
+SpaceBeforeSquareBrackets: false
+SpaceInEmptyBlock: false
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles: false
+SpacesInConditionalStatement: false
+SpacesInContainerLiterals: false
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard: Latest
+#StatementMacros:
+# -
+TabWidth: 2
+UseCRLF: false
+UseTab: Never
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
--- /dev/null
+#!/bin/bash
+
+PROGRAM_NAME=$(basename $0)
+CWD=$(dirname $0)
+FILES=()
+INPLACE=false
+
+help() {
+ echo $2
+ echo "Usage:"
+ echo " $PROGRAM_NAME [-hi] [--help|--inplace] <file> ..."
+ echo
+ exit $1
+}
+
+while test $# -gt 0; do
+ case $1 in
+ -h|--help) help ;;
+ -i|--inplace) INPLACE=true ;;
+ *)
+ test -f $1 || help 1 "$1 does not exist.\n"
+ FILES+=($1)
+ ;;
+ esac
+
+ shift
+done
+
+test "${#FILES[@]}" -eq 0 && help 1
+
+for FILE in "${FILES[@]}"; do
+ if $INPLACE; then
+ TEMP=$(mktemp $FILE.XXXXXXXX)
+ exec 1>$TEMP
+ fi
+ cat $CWD/../LICENSE.HEADER
+ echo
+ awk < $FILE '
+ BEGIN { hash_seen = 0 }
+ /^#/ { hash_seen = 1 }
+ { if (hash_seen) print }
+ '
+ if $INPLACE; then
+ mv $TEMP $FILE
+ fi
+done
/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
+ *
* Libmemcached library
*
* Copyright (C) 2011-2013 Data Differential, http://datadifferential.com/
#include "libmemcached/common.h"
-/*
- What happens if no servers exist?
-*/
char *memcached_get(memcached_st *ptr, const char *key,
size_t key_length,
size_t *value_length,
/* Request the key */
*error= __mget_by_key_real(ptr, group_key, group_key_length,
- (const char * const *)&key, &key_length,
+ (const char * const *)&key, &key_length,
1, false);
if (ptr)
{
}
}
- if (value_length)
+ if (value_length)
{
*value_length= 0;
}
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
#include "test/lib/common.hpp"
#include "libmemcached/common.h"
#include "libmemcachedutil/common.h"
-static inline memcached_return_t ping_callback(const memcached_st *, const memcached_instance_st *instance, void *) {
+static inline memcached_return_t ping_callback(const memcached_st *,
+ const memcached_instance_st *instance, void *) {
memcached_return_t rc;
- REQUIRE(libmemcached_util_ping(memcached_server_name(instance), memcached_server_port(instance), &rc));
+ REQUIRE(libmemcached_util_ping(memcached_server_name(instance), memcached_server_port(instance),
+ &rc));
REQUIRE(rc == MEMCACHED_SUCCESS);
return MEMCACHED_SUCCESS;
}
-static inline memcached_return_t ping2_callback(const memcached_st *, const memcached_instance_st *instance, void *) {
+static inline memcached_return_t ping2_callback(const memcached_st *,
+ const memcached_instance_st *instance, void *) {
memcached_return_t rc;
- REQUIRE(libmemcached_util_ping2(memcached_server_name(instance), memcached_server_port(instance), "memcached", "memcached", &rc));
+ REQUIRE(libmemcached_util_ping2(memcached_server_name(instance), memcached_server_port(instance),
+ "memcached", "memcached", &rc));
REQUIRE(rc == MEMCACHED_SUCCESS);
return MEMCACHED_SUCCESS;
}
-static inline memcached_return_t callback_counter(const memcached_st *, memcached_result_st *, void *context) {
- auto *counter= reinterpret_cast<size_t *>(context);
+static inline memcached_return_t callback_counter(const memcached_st *, memcached_result_st *,
+ void *context) {
+ auto *counter = reinterpret_cast<size_t *>(context);
*counter = *counter + 1;
return MEMCACHED_SUCCESS;
return MEMCACHED_SUCCESS;
}
-static inline memcached_return_t read_through_trigger(memcached_st *, char *, size_t, memcached_result_st *result) {
+static inline memcached_return_t read_through_trigger(memcached_st *, char *, size_t,
+ memcached_result_st *result) {
return memcached_result_set_value(result, S("updated by read through trigger"));
}
return MEMCACHED_SUCCESS;
}
-static inline memcached_return_t server_sort_callback(const memcached_st *, const memcached_instance_st *server, void *context) {
+static inline memcached_return_t
+server_sort_callback(const memcached_st *, const memcached_instance_st *server, void *context) {
if (context) {
auto bigger = reinterpret_cast<size_t *>(context);
REQUIRE(*bigger <= memcached_server_port(server));
}
return MEMCACHED_SUCCESS;
}
-
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
#pragma once
#include "mem_config.h"
static const char *input[] = {
- "apple",
- "beat",
- "carrot",
- "daikon",
- "eggplant",
- "flower",
- "green",
- "hide",
- "ick",
- "jack",
- "kick",
- "lime",
- "mushrooms",
- "nectarine",
- "orange",
- "peach",
- "quant",
- "ripen",
- "strawberry",
- "tang",
- "up",
- "volumne",
- "when",
- "yellow",
- "zip",
- "The quick brown fox jumps over the lazy dog",
+ "apple", "beat",
+ "carrot", "daikon",
+ "eggplant", "flower",
+ "green", "hide",
+ "ick", "jack",
+ "kick", "lime",
+ "mushrooms", "nectarine",
+ "orange", "peach",
+ "quant", "ripen",
+ "strawberry", "tang",
+ "up", "volumne",
+ "when", "yellow",
+ "zip", "The quick brown fox jumps over the lazy dog",
};
-static const uint32_t output[][sizeof(input)/sizeof(*input)] = {
+static const uint32_t output[][sizeof(input) / sizeof(*input)] = {
// one_at_a_time
- { 2297466611U, 3902465932U, 469785835U, 1937308741U,
- 261917617U, 3785641677U, 1439605128U, 1649152283U,
- 1493851484U, 1246520657U, 2221159044U, 1973511823U,
- 384136800U, 214358653U, 2379473940U, 4269788650U,
- 2864377005U, 2638630052U, 427683330U, 990491717U,
- 1747111141U, 792127364U, 2599214128U, 2553037199U,
- 2509838425U, 1369346549U },
+ {2297466611U, 3902465932U, 469785835U, 1937308741U, 261917617U, 3785641677U, 1439605128U,
+ 1649152283U, 1493851484U, 1246520657U, 2221159044U, 1973511823U, 384136800U, 214358653U,
+ 2379473940U, 4269788650U, 2864377005U, 2638630052U, 427683330U, 990491717U, 1747111141U,
+ 792127364U, 2599214128U, 2553037199U, 2509838425U, 1369346549U},
// md5
- { 3195025439U, 2556848621U, 3724893440U, 3332385401U,
- 245758794U, 2550894432U, 121710495U, 3053817768U,
- 1250994555U, 1862072655U, 2631955953U, 2951528551U,
- 1451250070U, 2820856945U, 2060845566U, 3646985608U,
- 2138080750U, 217675895U, 2230934345U, 1234361223U,
- 3968582726U, 2455685270U, 1293568479U, 199067604U,
- 2042482093U, 2642219166U },
+ {3195025439U, 2556848621U, 3724893440U, 3332385401U, 245758794U, 2550894432U, 121710495U,
+ 3053817768U, 1250994555U, 1862072655U, 2631955953U, 2951528551U, 1451250070U, 2820856945U,
+ 2060845566U, 3646985608U, 2138080750U, 217675895U, 2230934345U, 1234361223U, 3968582726U,
+ 2455685270U, 1293568479U, 199067604U, 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, 16719U },
+ {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, 16719U},
// fnv1_64
- { 473199127U, 4148981457U, 3971873300U, 3257986707U,
- 1722477987U, 2991193800U, 4147007314U, 3633179701U,
- 1805162104U, 3503289120U, 3395702895U, 3325073042U,
- 2345265314U, 3340346032U, 2722964135U, 1173398992U,
- 2815549194U, 2562818319U, 224996066U, 2680194749U,
- 3035305390U, 246890365U, 2395624193U, 4145193337U,
- 1801941682U, 2112060110U },
+ {473199127U, 4148981457U, 3971873300U, 3257986707U, 1722477987U, 2991193800U, 4147007314U,
+ 3633179701U, 1805162104U, 3503289120U, 3395702895U, 3325073042U, 2345265314U, 3340346032U,
+ 2722964135U, 1173398992U, 2815549194U, 2562818319U, 224996066U, 2680194749U, 3035305390U,
+ 246890365U, 2395624193U, 4145193337U, 1801941682U, 2112060110U},
// fnv1a_64
- { 1488911807U, 2500855813U, 1510099634U, 1390325195U,
- 3647689787U, 3241528582U, 1669328060U, 2604311949U,
- 734810122U, 1516407546U, 560948863U, 1767346780U,
- 561034892U, 4156330026U, 3716417003U, 3475297030U,
- 1518272172U, 227211583U, 3938128828U, 126112909U,
- 3043416448U, 3131561933U, 1328739897U, 2455664041U,
- 2272238452U, 3890508048U },
+ {1488911807U, 2500855813U, 1510099634U, 1390325195U, 3647689787U, 3241528582U, 1669328060U,
+ 2604311949U, 734810122U, 1516407546U, 560948863U, 1767346780U, 561034892U, 4156330026U,
+ 3716417003U, 3475297030U, 1518272172U, 227211583U, 3938128828U, 126112909U, 3043416448U,
+ 3131561933U, 1328739897U, 2455664041U, 2272238452U, 3890508048U},
// fnv1_32
- { 67176023U, 1190179409U, 2043204404U, 3221866419U,
- 2567703427U, 3787535528U, 4147287986U, 3500475733U,
- 344481048U, 3865235296U, 2181839183U, 119581266U,
- 510234242U, 4248244304U, 1362796839U, 103389328U,
- 1449620010U, 182962511U, 3554262370U, 3206747549U,
- 1551306158U, 4127558461U, 1889140833U, 2774173721U,
- 1180552018U, 3922226286U },
+ {67176023U, 1190179409U, 2043204404U, 3221866419U, 2567703427U, 3787535528U, 4147287986U,
+ 3500475733U, 344481048U, 3865235296U, 2181839183U, 119581266U, 510234242U, 4248244304U,
+ 1362796839U, 103389328U, 1449620010U, 182962511U, 3554262370U, 3206747549U, 1551306158U,
+ 4127558461U, 1889140833U, 2774173721U, 1180552018U, 3922226286U},
// fnv1a_32
- { 280767167U, 2421315013U, 3072375666U, 855001899U,
- 459261019U, 3521085446U, 18738364U, 1625305005U,
- 2162232970U, 777243802U, 3323728671U, 132336572U,
- 3654473228U, 260679466U, 1169454059U, 2698319462U,
- 1062177260U, 235516991U, 2218399068U, 405302637U,
- 1128467232U, 3579622413U, 2138539289U, 96429129U,
- 2877453236U, 76545936U },
+ {280767167U, 2421315013U, 3072375666U, 855001899U, 459261019U, 3521085446U, 18738364U,
+ 1625305005U, 2162232970U, 777243802U, 3323728671U, 132336572U, 3654473228U, 260679466U,
+ 1169454059U, 2698319462U, 1062177260U, 235516991U, 2218399068U, 405302637U, 1128467232U,
+ 3579622413U, 2138539289U, 96429129U, 2877453236U, 76545936U},
- // hsieh
+// hsieh
#ifdef HAVE_HSIEH_HASH
- { 3738850110U, 3636226060U, 3821074029U, 3489929160U, 3485772682U, 80540287U,
- 1805464076U, 1895033657U, 409795758U, 979934958U, 3634096985U, 1284445480U,
- 2265380744U, 707972988U, 353823508U, 1549198350U, 1327930172U, 9304163U,
- 4220749037U, 2493964934U, 2777873870U, 2057831732U, 1510213931U, 2027828987U,
- 3395453351U, 471461527U },
+ {3738850110U, 3636226060U, 3821074029U, 3489929160U, 3485772682U, 80540287U, 1805464076U,
+ 1895033657U, 409795758U, 979934958U, 3634096985U, 1284445480U, 2265380744U, 707972988U,
+ 353823508U, 1549198350U, 1327930172U, 9304163U, 4220749037U, 2493964934U, 2777873870U,
+ 2057831732U, 1510213931U, 2027828987U, 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, 1},
#endif
- // murmur
+// murmur
#ifdef HAVE_MURMUR_HASH
- { 4142305122U, 734504955U, 3802834688U, 4076891445U,
- 387802650U, 560515427U, 3274673488U, 3150339524U,
- 1527441970U, 2728642900U, 3613992239U, 2938419259U,
- 2321988328U, 1145154116U, 4038540960U, 2224541613U,
- 264013145U, 3995512858U, 2400956718U, 2346666219U,
- 926327338U, 442757446U, 1770805201U, 560483147U,
- 3902279934U, 818385189U },
+ {4142305122U, 734504955U, 3802834688U, 4076891445U, 387802650U, 560515427U, 3274673488U,
+ 3150339524U, 1527441970U, 2728642900U, 3613992239U, 2938419259U, 2321988328U, 1145154116U,
+ 4038540960U, 2224541613U, 264013145U, 3995512858U, 2400956718U, 2346666219U, 926327338U,
+ 442757446U, 1770805201U, 560483147U, 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 },
+ {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
- { 1442444624U, 4253821186U, 1885058256U, 2120131735U,
- 3261968576U, 3515188778U, 4232909173U, 4288625128U,
- 1812047395U, 3689182164U, 2502979932U, 1214050606U,
- 2415988847U, 1494268927U, 1025545760U, 3920481083U,
- 4153263658U, 3824871822U, 3072759809U, 798622255U,
- 3065432577U, 1453328165U, 2691550971U, 3408888387U,
- 2629893356U, 314054204U },
+ {1442444624U, 4253821186U, 1885058256U, 2120131735U, 3261968576U, 3515188778U, 4232909173U,
+ 4288625128U, 1812047395U, 3689182164U, 2502979932U, 1214050606U, 2415988847U, 1494268927U,
+ 1025545760U, 3920481083U, 4153263658U, 3824871822U, 3072759809U, 798622255U, 3065432577U,
+ 1453328165U, 2691550971U, 3408888387U, 2629893356U, 314054204U},
- // murmur3
+// murmur3
#ifdef HAVE_MURMUR_HASH
- { 1120212521U, 1448785489U, 4186307405U, 2686268514U,
- 444808887U, 221750260U, 3074673162U, 1946933257U,
- 2826416675U, 2430719166U, 3200429559U, 297894347U,
- 732888124U, 4050076964U, 3298336176U, 1336207361U,
- 810553576U, 3748182674U, 3860119212U, 3439537197U,
- 3044240981U, 1464271804U, 3896193724U, 2915115798U,
- 1702843840U, 2603515018U },
+ {1120212521U, 1448785489U, 4186307405U, 2686268514U, 444808887U, 221750260U, 3074673162U,
+ 1946933257U, 2826416675U, 2430719166U, 3200429559U, 297894347U, 732888124U, 4050076964U,
+ 3298336176U, 1336207361U, 810553576U, 3748182674U, 3860119212U, 3439537197U, 3044240981U,
+ 1464271804U, 3896193724U, 2915115798U, 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
};
-
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
#pragma once
static struct {
- const char *key;
- unsigned long hash1;
- unsigned long hash2;
- const char *server;
-} ketama_test_cases[99]= {
- { "SVa_]_V41)", 443691461UL, 445379617UL, "10.0.1.7" },
- { "*/Z;?V(.\\8", 1422915503UL, 1428303028UL, "10.0.1.1" },
- { "30C1*Z*S/_", 1473165754UL, 1480075959UL, "10.0.1.2" },
- { "ERR:EC58G>", 2148406511UL, 2168579133UL, "10.0.1.7" },
- { "1I=cTMNTKF", 2882686667UL, 2885206587UL, "10.0.1.5" },
- { "]VG<`I*Z8)", 1103544263UL, 1104827657UL, "10.0.1.5" },
- { "UUTC`-V159", 3716288206UL, 3727224240UL, "10.0.1.5" },
- { "@7RU6C6T+Z", 3862737685UL, 3871917949UL, "10.0.1.5" },
- { "/XLN0@+36;", 1623269830UL, 1627683651UL, "10.0.1.1" },
- { "4(`X;\\V.^c", 373546328UL, 383925769UL, "10.0.1.1" },
- { "726bW=9*a4", 4213440020UL, 4213950705UL, "10.0.1.7" },
- { "\\`)<B)UE,c", 951096736UL, 955226069UL, "10.0.1.1" },
- { "P1[Ma3=K1/", 1989324036UL, 1994028240UL, "10.0.1.8" },
- { "C89I.-V?cT", 1604239957UL, 1606398093UL, "10.0.1.8" },
- { "D[HE+cFXDK", 2117036136UL, 2117124014UL, "10.0.1.3" },
- { "P1L?NAB[)K", 2129972569UL, 2132542634UL, "10.0.1.1" },
- { "cDT0)Z5P6,", 176485284UL, 178675413UL, "10.0.1.5" },
- { "@JW`+[WAO8", 2720940826UL, 2743975456UL, "10.0.1.5" },
- { "\\39DKW^)N_", 3548879868UL, 3550704865UL, "10.0.1.3" },
- { "EM75N0+[X1", 1558531507UL, 1559308507UL, "10.0.1.4" },
- { "`,SS]NBP,b", 1883545960UL, 1884847278UL, "10.0.1.1" },
- { "XX1a9LT+F?", 653487707UL, 656410408UL, "10.0.1.5" },
- { "Zc\\-,F-c6V", 1160802451UL, 1171575728UL, "10.0.1.5" },
- { "1*RTMC7,03", 1602398012UL, 1606398093UL, "10.0.1.8" },
- { "*Xc+V0P>32", 536016577UL, 539988520UL, "10.0.1.7" },
- { "U))Fb-(`,.", 4128682289UL, 4136854163UL, "10.0.1.7" },
- { "R-08RNTaRT", 3718170086UL, 3727224240UL, "10.0.1.5" },
- { "(LHcO203I3", 1007779411UL, 1014643570UL, "10.0.1.5" },
- { "=256P+;Qc8", 3976201210UL, 3976304873UL, "10.0.1.5" },
- { "OI5XZ_BBT(", 2155922164UL, 2168579133UL, "10.0.1.7" },
- { "2TLRL/UL;:", 1086800909UL, 1095659802UL, "10.0.1.7" },
- { "WHD\\O1`ZRW", 3087923411UL, 3095471560UL, "10.0.1.5" },
- { ".=54)_c;=T", 2497691631UL, 2502731301UL, "10.0.1.1" },
- { ";G<W-XWZ@b", 2888169733UL, 2888728739UL, "10.0.1.5" },
- { "(,>E`)FT\\4", 580747448UL, 581063326UL, "10.0.1.2" },
- { "HZAU*;P*N]", 2564670474UL, 2565697267UL, "10.0.1.7" },
- { "NZ@ZE=O84_", 533335275UL, 539988520UL, "10.0.1.7" },
- { "6,cEI`F_P>", 3972869246UL, 3974773167UL, "10.0.1.6" },
- { "c,5AQ/T5)6", 2835605783UL, 2847870057UL, "10.0.1.8" },
- { ".O,>>BT)RX", 3857978174UL, 3871917949UL, "10.0.1.5" },
- { "XY\\X::LX50", 1749241099UL, 1752196488UL, "10.0.1.6" },
- { "+550F^/.01", 3781824099UL, 3783248219UL, "10.0.1.6" },
- { "<.X9E2S5+9", 3232479481UL, 3234387706UL, "10.0.1.7" },
- { "]\\.UH8_0a1", 2419699252UL, 2423002920UL, "10.0.1.4" },
- { "8(6=(T0/Z0", 728266737UL, 729026070UL, "10.0.1.7" },
- { "8*6a;Sc*X+", 4223431086UL, 4230156966UL, "10.0.1.2" },
- { "<QW:;3K6;H", 2731158143UL, 2743975456UL, "10.0.1.5" },
- { "7C@EY@-Y?_", 760770733UL, 761576669UL, "10.0.1.5" },
- { "aPb3E1WD4K", 2500489218UL, 2502731301UL, "10.0.1.1" },
- { "?@12R<=1BH", 1494795329UL, 1502505505UL, "10.0.1.8" },
- { "QR(a+Q=1FU", 3238535074UL, 3238996435UL, "10.0.1.6" },
- { "`C9^FV,960", 2628553463UL, 2628733766UL, "10.0.1.6" },
- { "UNHVP..^8H", 977096483UL, 977319837UL, "10.0.1.4" },
- { ":Y.2W2[(35", 2777083668UL, 2784182515UL, "10.0.1.7" },
- { "M/HV^_HZ4O", 3623390946UL, 3624445007UL, "10.0.1.7" },
- { "ZY16KQ<ICD", 1831153193UL, 1838563516UL, "10.0.1.4" },
- { "bV2,`a.PY9", 1962228869UL, 1962648654UL, "10.0.1.1" },
- { "U;9:-+5N]9", 269504649UL, 277560877UL, "10.0.1.1" },
- { "1S/:aJ[1(;", 578069729UL, 581063326UL, "10.0.1.2" },
- { "Nb-X^]M)I:", 330865696UL, 331009896UL, "10.0.1.6" },
- { "2;M;ES>J5/", 2776949824UL, 2784182515UL, "10.0.1.7" },
- { "[>RZHG97Q9", 71954686UL, 72034069UL, "10.0.1.6" },
- { "J3/G[)9<^Z", 2799896459UL, 2805183696UL, "10.0.1.7" },
- { "N-)88>[O`,", 50404102UL, 51792557UL, "10.0.1.5" },
- { "NP:=FR\\OaA", 3837333776UL, 3837792034UL, "10.0.1.7" },
- { "`@L+W;a,O[", 1512157148UL, 1522285852UL, "10.0.1.6" },
- { "W2`P:-+1T[", 2945171975UL, 2946196424UL, "10.0.1.5" },
- { "-6G7K^YDIN", 3168617340UL, 3170513015UL, "10.0.1.7" },
- { "U>*>9ZI6V5", 668514946UL, 674097631UL, "10.0.1.6" },
- { ".I?^6Ic9RK", 938419020UL, 942832691UL, "10.0.1.6" },
- { "0OZH^9BKM[", 3682518606UL, 3686781297UL, "10.0.1.8" },
- { "5?50UGZ:ML", 868610882UL, 869425986UL, "10.0.1.5" },
- { "?K2NF@3=IU", 381218851UL, 383925769UL, "10.0.1.1" },
- { "YI@G-2X?UB", 3688706179UL, 3693197681UL, "10.0.1.5" },
- { "7cY</BSaL=", 3976870223UL, 3978903843UL, "10.0.1.6" },
- { "A(`KF:[RH8", 3292979676UL, 3294849139UL, "10.0.1.6" },
- { ";=ZT\\W^P+H", 1401102653UL, 1416290674UL, "10.0.1.4" },
- { "b2?WFF56;R", 480494704UL, 486971192UL, "10.0.1.4" },
- { "CTR74,J+N.", 137446045UL, 146633907UL, "10.0.1.8" },
- { "<b;*R+QDST", 1304985302UL, 1308223778UL, "10.0.1.5" },
- { "\\R^7=9UCG`", 126218373UL, 129199837UL, "10.0.1.5" },
- { "1bQS5]WOXB", 1853470245UL, 1855329369UL, "10.0.1.4" },
- { "M(@X^b[L:K", 3019630308UL, 3022260113UL, "10.0.1.1" },
- { "431cBF8,YO", 1679726993UL, 1685224295UL, "10.0.1.7" },
- { "(bEIQJ:E./", 2922607787UL, 2925521819UL, "10.0.1.6" },
- { "WS/3H*)7F;", 419488232UL, 422140585UL, "10.0.1.5" },
- { "ZJF[Ia6Q)+", 3960568056UL, 3962489998UL, "10.0.1.7" },
- { "<]*QCK8U,>", 2590140172UL, 2598117636UL, "10.0.1.7" },
- { "\\[a\\^=V_M0", 689410119UL, 698690782UL, "10.0.1.6" },
- { "7;RM+8J9YC", 1530175299UL, 1531107082UL, "10.0.1.7" },
- { "4*=.SPR[AV", 3928582722UL, 3928853792UL, "10.0.1.1" },
- { "-2F+^88P4U", 3023552752UL, 3025823613UL, "10.0.1.7" },
- { "X;-F`(N?9D", 570465234UL, 572485994UL, "10.0.1.7" },
- { "R=F_D-K2a]", 1287750228UL, 1290935562UL, "10.0.1.7" },
- { "X*+2aaC.EG", 3200948713UL, 3201088518UL, "10.0.1.5" },
- { "[1ZXONX2]a", 4108881567UL, 4109865744UL, "10.0.1.4" },
- { "FL;\\GWacaV", 458449508UL, 467374054UL, "10.0.1.4" },
- { "\\MQ_XNT7L-", 1259349383UL, 1259509450UL, "10.0.1.7" },
- { "VD6D0]ba_\\", 3842502950UL, 3842588691UL, "10.0.1.1" },
+ const char *key;
+ unsigned long hash1;
+ unsigned long hash2;
+ const char *server;
+} ketama_test_cases[99] = {
+ {"SVa_]_V41)", 443691461UL, 445379617UL, "10.0.1.7"},
+ {"*/Z;?V(.\\8", 1422915503UL, 1428303028UL, "10.0.1.1"},
+ {"30C1*Z*S/_", 1473165754UL, 1480075959UL, "10.0.1.2"},
+ {"ERR:EC58G>", 2148406511UL, 2168579133UL, "10.0.1.7"},
+ {"1I=cTMNTKF", 2882686667UL, 2885206587UL, "10.0.1.5"},
+ {"]VG<`I*Z8)", 1103544263UL, 1104827657UL, "10.0.1.5"},
+ {"UUTC`-V159", 3716288206UL, 3727224240UL, "10.0.1.5"},
+ {"@7RU6C6T+Z", 3862737685UL, 3871917949UL, "10.0.1.5"},
+ {"/XLN0@+36;", 1623269830UL, 1627683651UL, "10.0.1.1"},
+ {"4(`X;\\V.^c", 373546328UL, 383925769UL, "10.0.1.1"},
+ {"726bW=9*a4", 4213440020UL, 4213950705UL, "10.0.1.7"},
+ {"\\`)<B)UE,c", 951096736UL, 955226069UL, "10.0.1.1"},
+ {"P1[Ma3=K1/", 1989324036UL, 1994028240UL, "10.0.1.8"},
+ {"C89I.-V?cT", 1604239957UL, 1606398093UL, "10.0.1.8"},
+ {"D[HE+cFXDK", 2117036136UL, 2117124014UL, "10.0.1.3"},
+ {"P1L?NAB[)K", 2129972569UL, 2132542634UL, "10.0.1.1"},
+ {"cDT0)Z5P6,", 176485284UL, 178675413UL, "10.0.1.5"},
+ {"@JW`+[WAO8", 2720940826UL, 2743975456UL, "10.0.1.5"},
+ {"\\39DKW^)N_", 3548879868UL, 3550704865UL, "10.0.1.3"},
+ {"EM75N0+[X1", 1558531507UL, 1559308507UL, "10.0.1.4"},
+ {"`,SS]NBP,b", 1883545960UL, 1884847278UL, "10.0.1.1"},
+ {"XX1a9LT+F?", 653487707UL, 656410408UL, "10.0.1.5"},
+ {"Zc\\-,F-c6V", 1160802451UL, 1171575728UL, "10.0.1.5"},
+ {"1*RTMC7,03", 1602398012UL, 1606398093UL, "10.0.1.8"},
+ {"*Xc+V0P>32", 536016577UL, 539988520UL, "10.0.1.7"},
+ {"U))Fb-(`,.", 4128682289UL, 4136854163UL, "10.0.1.7"},
+ {"R-08RNTaRT", 3718170086UL, 3727224240UL, "10.0.1.5"},
+ {"(LHcO203I3", 1007779411UL, 1014643570UL, "10.0.1.5"},
+ {"=256P+;Qc8", 3976201210UL, 3976304873UL, "10.0.1.5"},
+ {"OI5XZ_BBT(", 2155922164UL, 2168579133UL, "10.0.1.7"},
+ {"2TLRL/UL;:", 1086800909UL, 1095659802UL, "10.0.1.7"},
+ {"WHD\\O1`ZRW", 3087923411UL, 3095471560UL, "10.0.1.5"},
+ {".=54)_c;=T", 2497691631UL, 2502731301UL, "10.0.1.1"},
+ {";G<W-XWZ@b", 2888169733UL, 2888728739UL, "10.0.1.5"},
+ {"(,>E`)FT\\4", 580747448UL, 581063326UL, "10.0.1.2"},
+ {"HZAU*;P*N]", 2564670474UL, 2565697267UL, "10.0.1.7"},
+ {"NZ@ZE=O84_", 533335275UL, 539988520UL, "10.0.1.7"},
+ {"6,cEI`F_P>", 3972869246UL, 3974773167UL, "10.0.1.6"},
+ {"c,5AQ/T5)6", 2835605783UL, 2847870057UL, "10.0.1.8"},
+ {".O,>>BT)RX", 3857978174UL, 3871917949UL, "10.0.1.5"},
+ {"XY\\X::LX50", 1749241099UL, 1752196488UL, "10.0.1.6"},
+ {"+550F^/.01", 3781824099UL, 3783248219UL, "10.0.1.6"},
+ {"<.X9E2S5+9", 3232479481UL, 3234387706UL, "10.0.1.7"},
+ {"]\\.UH8_0a1", 2419699252UL, 2423002920UL, "10.0.1.4"},
+ {"8(6=(T0/Z0", 728266737UL, 729026070UL, "10.0.1.7"},
+ {"8*6a;Sc*X+", 4223431086UL, 4230156966UL, "10.0.1.2"},
+ {"<QW:;3K6;H", 2731158143UL, 2743975456UL, "10.0.1.5"},
+ {"7C@EY@-Y?_", 760770733UL, 761576669UL, "10.0.1.5"},
+ {"aPb3E1WD4K", 2500489218UL, 2502731301UL, "10.0.1.1"},
+ {"?@12R<=1BH", 1494795329UL, 1502505505UL, "10.0.1.8"},
+ {"QR(a+Q=1FU", 3238535074UL, 3238996435UL, "10.0.1.6"},
+ {"`C9^FV,960", 2628553463UL, 2628733766UL, "10.0.1.6"},
+ {"UNHVP..^8H", 977096483UL, 977319837UL, "10.0.1.4"},
+ {":Y.2W2[(35", 2777083668UL, 2784182515UL, "10.0.1.7"},
+ {"M/HV^_HZ4O", 3623390946UL, 3624445007UL, "10.0.1.7"},
+ {"ZY16KQ<ICD", 1831153193UL, 1838563516UL, "10.0.1.4"},
+ {"bV2,`a.PY9", 1962228869UL, 1962648654UL, "10.0.1.1"},
+ {"U;9:-+5N]9", 269504649UL, 277560877UL, "10.0.1.1"},
+ {"1S/:aJ[1(;", 578069729UL, 581063326UL, "10.0.1.2"},
+ {"Nb-X^]M)I:", 330865696UL, 331009896UL, "10.0.1.6"},
+ {"2;M;ES>J5/", 2776949824UL, 2784182515UL, "10.0.1.7"},
+ {"[>RZHG97Q9", 71954686UL, 72034069UL, "10.0.1.6"},
+ {"J3/G[)9<^Z", 2799896459UL, 2805183696UL, "10.0.1.7"},
+ {"N-)88>[O`,", 50404102UL, 51792557UL, "10.0.1.5"},
+ {"NP:=FR\\OaA", 3837333776UL, 3837792034UL, "10.0.1.7"},
+ {"`@L+W;a,O[", 1512157148UL, 1522285852UL, "10.0.1.6"},
+ {"W2`P:-+1T[", 2945171975UL, 2946196424UL, "10.0.1.5"},
+ {"-6G7K^YDIN", 3168617340UL, 3170513015UL, "10.0.1.7"},
+ {"U>*>9ZI6V5", 668514946UL, 674097631UL, "10.0.1.6"},
+ {".I?^6Ic9RK", 938419020UL, 942832691UL, "10.0.1.6"},
+ {"0OZH^9BKM[", 3682518606UL, 3686781297UL, "10.0.1.8"},
+ {"5?50UGZ:ML", 868610882UL, 869425986UL, "10.0.1.5"},
+ {"?K2NF@3=IU", 381218851UL, 383925769UL, "10.0.1.1"},
+ {"YI@G-2X?UB", 3688706179UL, 3693197681UL, "10.0.1.5"},
+ {"7cY</BSaL=", 3976870223UL, 3978903843UL, "10.0.1.6"},
+ {"A(`KF:[RH8", 3292979676UL, 3294849139UL, "10.0.1.6"},
+ {";=ZT\\W^P+H", 1401102653UL, 1416290674UL, "10.0.1.4"},
+ {"b2?WFF56;R", 480494704UL, 486971192UL, "10.0.1.4"},
+ {"CTR74,J+N.", 137446045UL, 146633907UL, "10.0.1.8"},
+ {"<b;*R+QDST", 1304985302UL, 1308223778UL, "10.0.1.5"},
+ {"\\R^7=9UCG`", 126218373UL, 129199837UL, "10.0.1.5"},
+ {"1bQS5]WOXB", 1853470245UL, 1855329369UL, "10.0.1.4"},
+ {"M(@X^b[L:K", 3019630308UL, 3022260113UL, "10.0.1.1"},
+ {"431cBF8,YO", 1679726993UL, 1685224295UL, "10.0.1.7"},
+ {"(bEIQJ:E./", 2922607787UL, 2925521819UL, "10.0.1.6"},
+ {"WS/3H*)7F;", 419488232UL, 422140585UL, "10.0.1.5"},
+ {"ZJF[Ia6Q)+", 3960568056UL, 3962489998UL, "10.0.1.7"},
+ {"<]*QCK8U,>", 2590140172UL, 2598117636UL, "10.0.1.7"},
+ {"\\[a\\^=V_M0", 689410119UL, 698690782UL, "10.0.1.6"},
+ {"7;RM+8J9YC", 1530175299UL, 1531107082UL, "10.0.1.7"},
+ {"4*=.SPR[AV", 3928582722UL, 3928853792UL, "10.0.1.1"},
+ {"-2F+^88P4U", 3023552752UL, 3025823613UL, "10.0.1.7"},
+ {"X;-F`(N?9D", 570465234UL, 572485994UL, "10.0.1.7"},
+ {"R=F_D-K2a]", 1287750228UL, 1290935562UL, "10.0.1.7"},
+ {"X*+2aaC.EG", 3200948713UL, 3201088518UL, "10.0.1.5"},
+ {"[1ZXONX2]a", 4108881567UL, 4109865744UL, "10.0.1.4"},
+ {"FL;\\GWacaV", 458449508UL, 467374054UL, "10.0.1.4"},
+ {"\\MQ_XNT7L-", 1259349383UL, 1259509450UL, "10.0.1.7"},
+ {"VD6D0]ba_\\", 3842502950UL, 3842588691UL, "10.0.1.1"},
};
-
static struct {
const char *key;
unsigned long hash1;
unsigned long hash2;
const char *server;
-} ketama_test_cases_spy[99]= {
- { "SVa_]_V41)", 443691461UL, 445379617UL, "10.0.1.2" },
- { "*/Z;?V(.\\8", 1422915503UL, 1428303028UL, "10.0.1.4" },
- { "30C1*Z*S/_", 1473165754UL, 1480075959UL, "10.0.1.2" },
- { "ERR:EC58G>", 2148406511UL, 2168579133UL, "10.0.1.7" },
- { "1I=cTMNTKF", 2882686667UL, 2885206587UL, "10.0.1.4" },
- { "]VG<`I*Z8)", 1103544263UL, 1104827657UL, "10.0.1.5" },
- { "UUTC`-V159", 3716288206UL, 3727224240UL, "10.0.1.7" },
- { "@7RU6C6T+Z", 3862737685UL, 3871917949UL, "10.0.1.6" },
- { "/XLN0@+36;", 1623269830UL, 1627683651UL, "10.0.1.7" },
- { "4(`X;\\V.^c", 373546328UL, 383925769UL, "10.0.1.6" },
- { "726bW=9*a4", 4213440020UL, 4213950705UL, "10.0.1.3" },
- { "\\`)<B)UE,c", 951096736UL, 955226069UL, "10.0.1.8" },
- { "P1[Ma3=K1/", 1989324036UL, 1994028240UL, "10.0.1.1" },
- { "C89I.-V?cT", 1604239957UL, 1606398093UL, "10.0.1.5" },
- { "D[HE+cFXDK", 2117036136UL, 2117124014UL, "10.0.1.5" },
- { "P1L?NAB[)K", 2129972569UL, 2132542634UL, "10.0.1.7" },
- { "cDT0)Z5P6,", 176485284UL, 178675413UL, "10.0.1.1" },
- { "@JW`+[WAO8", 2720940826UL, 2743975456UL, "10.0.1.2" },
- { "\\39DKW^)N_", 3548879868UL, 3550704865UL, "10.0.1.6" },
- { "EM75N0+[X1", 1558531507UL, 1559308507UL, "10.0.1.5" },
- { "`,SS]NBP,b", 1883545960UL, 1884847278UL, "10.0.1.1" },
- { "XX1a9LT+F?", 653487707UL, 656410408UL, "10.0.1.6" },
- { "Zc\\-,F-c6V", 1160802451UL, 1171575728UL, "10.0.1.6" },
- { "1*RTMC7,03", 1602398012UL, 1606398093UL, "10.0.1.5" },
- { "*Xc+V0P>32", 536016577UL, 539988520UL, "10.0.1.7" },
- { "U))Fb-(`,.", 4128682289UL, 4136854163UL, "10.0.1.7" },
- { "R-08RNTaRT", 3718170086UL, 3727224240UL, "10.0.1.5" },
- { "(LHcO203I3", 1007779411UL, 1014643570UL, "10.0.1.1" },
- { "=256P+;Qc8", 3976201210UL, 3976304873UL, "10.0.1.3" },
- { "OI5XZ_BBT(", 2155922164UL, 2168579133UL, "10.0.1.5" },
- { "2TLRL/UL;:", 1086800909UL, 1095659802UL, "10.0.1.2" },
- { "WHD\\O1`ZRW", 3087923411UL, 3095471560UL, "10.0.1.1" },
- { ".=54)_c;=T", 2497691631UL, 2502731301UL, "10.0.1.6" },
- { ";G<W-XWZ@b", 2888169733UL, 2888728739UL, "10.0.1.7" },
- { "(,>E`)FT\\4", 580747448UL, 581063326UL, "10.0.1.5" },
- { "HZAU*;P*N]", 2564670474UL, 2565697267UL, "10.0.1.1" },
- { "NZ@ZE=O84_", 533335275UL, 539988520UL, "10.0.1.7" },
- { "6,cEI`F_P>", 3972869246UL, 3974773167UL, "10.0.1.3" },
- { "c,5AQ/T5)6", 2835605783UL, 2847870057UL, "10.0.1.7" },
- { ".O,>>BT)RX", 3857978174UL, 3871917949UL, "10.0.1.7" },
- { "XY\\X::LX50", 1749241099UL, 1752196488UL, "10.0.1.7" },
- { "+550F^/.01", 3781824099UL, 3783248219UL, "10.0.1.2" },
- { "<.X9E2S5+9", 3232479481UL, 3234387706UL, "10.0.1.7" },
- { "]\\.UH8_0a1", 2419699252UL, 2423002920UL, "10.0.1.6" },
- { "8(6=(T0/Z0", 728266737UL, 729026070UL, "10.0.1.6" },
- { "8*6a;Sc*X+", 4223431086UL, 4230156966UL, "10.0.1.5" },
- { "<QW:;3K6;H", 2731158143UL, 2743975456UL, "10.0.1.7" },
- { "7C@EY@-Y?_", 760770733UL, 761576669UL, "10.0.1.5" },
- { "aPb3E1WD4K", 2500489218UL, 2502731301UL, "10.0.1.2" },
- { "?@12R<=1BH", 1494795329UL, 1502505505UL, "10.0.1.1" },
- { "QR(a+Q=1FU", 3238535074UL, 3238996435UL, "10.0.1.5" },
- { "`C9^FV,960", 2628553463UL, 2628733766UL, "10.0.1.3" },
- { "UNHVP..^8H", 977096483UL, 977319837UL, "10.0.1.6" },
- { ":Y.2W2[(35", 2777083668UL, 2784182515UL, "10.0.1.6" },
- { "M/HV^_HZ4O", 3623390946UL, 3624445007UL, "10.0.1.4" },
- { "ZY16KQ<ICD", 1831153193UL, 1838563516UL, "10.0.1.7" },
- { "bV2,`a.PY9", 1962228869UL, 1962648654UL, "10.0.1.7" },
- { "U;9:-+5N]9", 269504649UL, 277560877UL, "10.0.1.2" },
- { "1S/:aJ[1(;", 578069729UL, 581063326UL, "10.0.1.5" },
- { "Nb-X^]M)I:", 330865696UL, 331009896UL, "10.0.1.3" },
- { "2;M;ES>J5/", 2776949824UL, 2784182515UL, "10.0.1.6" },
- { "[>RZHG97Q9", 71954686UL, 72034069UL, "10.0.1.4" },
- { "J3/G[)9<^Z", 2799896459UL, 2805183696UL, "10.0.1.6" },
- { "N-)88>[O`,", 50404102UL, 51792557UL, "10.0.1.2" },
- { "NP:=FR\\OaA", 3837333776UL, 3837792034UL, "10.0.1.7" },
- { "`@L+W;a,O[", 1512157148UL, 1522285852UL, "10.0.1.5" },
- { "W2`P:-+1T[", 2945171975UL, 2946196424UL, "10.0.1.7" },
- { "-6G7K^YDIN", 3168617340UL, 3170513015UL, "10.0.1.5" },
- { "U>*>9ZI6V5", 668514946UL, 674097631UL, "10.0.1.5" },
- { ".I?^6Ic9RK", 938419020UL, 942832691UL, "10.0.1.6" },
- { "0OZH^9BKM[", 3682518606UL, 3686781297UL, "10.0.1.2" },
- { "5?50UGZ:ML", 868610882UL, 869425986UL, "10.0.1.6" },
- { "?K2NF@3=IU", 381218851UL, 383925769UL, "10.0.1.6" },
- { "YI@G-2X?UB", 3688706179UL, 3693197681UL, "10.0.1.6" },
- { "7cY</BSaL=", 3976870223UL, 3978903843UL, "10.0.1.7" },
- { "A(`KF:[RH8", 3292979676UL, 3294849139UL, "10.0.1.6" },
- { ";=ZT\\W^P+H", 1401102653UL, 1416290674UL, "10.0.1.6" },
- { "b2?WFF56;R", 480494704UL, 486971192UL, "10.0.1.7" },
- { "CTR74,J+N.", 137446045UL, 146633907UL, "10.0.1.7" },
- { "<b;*R+QDST", 1304985302UL, 1308223778UL, "10.0.1.5" },
- { "\\R^7=9UCG`", 126218373UL, 129199837UL, "10.0.1.6" },
- { "1bQS5]WOXB", 1853470245UL, 1855329369UL, "10.0.1.7" },
- { "M(@X^b[L:K", 3019630308UL, 3022260113UL, "10.0.1.4" },
- { "431cBF8,YO", 1679726993UL, 1685224295UL, "10.0.1.1" },
- { "(bEIQJ:E./", 2922607787UL, 2925521819UL, "10.0.1.7" },
- { "WS/3H*)7F;", 419488232UL, 422140585UL, "10.0.1.3" },
- { "ZJF[Ia6Q)+", 3960568056UL, 3962489998UL, "10.0.1.5" },
- { "<]*QCK8U,>", 2590140172UL, 2598117636UL, "10.0.1.5" },
- { "\\[a\\^=V_M0", 689410119UL, 698690782UL, "10.0.1.7" },
- { "7;RM+8J9YC", 1530175299UL, 1531107082UL, "10.0.1.7" },
- { "4*=.SPR[AV", 3928582722UL, 3928853792UL, "10.0.1.3" },
- { "-2F+^88P4U", 3023552752UL, 3025823613UL, "10.0.1.7" },
- { "X;-F`(N?9D", 570465234UL, 572485994UL, "10.0.1.5" },
- { "R=F_D-K2a]", 1287750228UL, 1290935562UL, "10.0.1.1" },
- { "X*+2aaC.EG", 3200948713UL, 3201088518UL, "10.0.1.3" },
- { "[1ZXONX2]a", 4108881567UL, 4109865744UL, "10.0.1.7" },
- { "FL;\\GWacaV", 458449508UL, 467374054UL, "10.0.1.7" },
- { "\\MQ_XNT7L-", 1259349383UL, 1259509450UL, "10.0.1.5" },
- { "VD6D0]ba_\\", 3842502950UL, 3842588691UL, "10.0.1.7" },
+} ketama_test_cases_spy[99] = {
+ {"SVa_]_V41)", 443691461UL, 445379617UL, "10.0.1.2"},
+ {"*/Z;?V(.\\8", 1422915503UL, 1428303028UL, "10.0.1.4"},
+ {"30C1*Z*S/_", 1473165754UL, 1480075959UL, "10.0.1.2"},
+ {"ERR:EC58G>", 2148406511UL, 2168579133UL, "10.0.1.7"},
+ {"1I=cTMNTKF", 2882686667UL, 2885206587UL, "10.0.1.4"},
+ {"]VG<`I*Z8)", 1103544263UL, 1104827657UL, "10.0.1.5"},
+ {"UUTC`-V159", 3716288206UL, 3727224240UL, "10.0.1.7"},
+ {"@7RU6C6T+Z", 3862737685UL, 3871917949UL, "10.0.1.6"},
+ {"/XLN0@+36;", 1623269830UL, 1627683651UL, "10.0.1.7"},
+ {"4(`X;\\V.^c", 373546328UL, 383925769UL, "10.0.1.6"},
+ {"726bW=9*a4", 4213440020UL, 4213950705UL, "10.0.1.3"},
+ {"\\`)<B)UE,c", 951096736UL, 955226069UL, "10.0.1.8"},
+ {"P1[Ma3=K1/", 1989324036UL, 1994028240UL, "10.0.1.1"},
+ {"C89I.-V?cT", 1604239957UL, 1606398093UL, "10.0.1.5"},
+ {"D[HE+cFXDK", 2117036136UL, 2117124014UL, "10.0.1.5"},
+ {"P1L?NAB[)K", 2129972569UL, 2132542634UL, "10.0.1.7"},
+ {"cDT0)Z5P6,", 176485284UL, 178675413UL, "10.0.1.1"},
+ {"@JW`+[WAO8", 2720940826UL, 2743975456UL, "10.0.1.2"},
+ {"\\39DKW^)N_", 3548879868UL, 3550704865UL, "10.0.1.6"},
+ {"EM75N0+[X1", 1558531507UL, 1559308507UL, "10.0.1.5"},
+ {"`,SS]NBP,b", 1883545960UL, 1884847278UL, "10.0.1.1"},
+ {"XX1a9LT+F?", 653487707UL, 656410408UL, "10.0.1.6"},
+ {"Zc\\-,F-c6V", 1160802451UL, 1171575728UL, "10.0.1.6"},
+ {"1*RTMC7,03", 1602398012UL, 1606398093UL, "10.0.1.5"},
+ {"*Xc+V0P>32", 536016577UL, 539988520UL, "10.0.1.7"},
+ {"U))Fb-(`,.", 4128682289UL, 4136854163UL, "10.0.1.7"},
+ {"R-08RNTaRT", 3718170086UL, 3727224240UL, "10.0.1.5"},
+ {"(LHcO203I3", 1007779411UL, 1014643570UL, "10.0.1.1"},
+ {"=256P+;Qc8", 3976201210UL, 3976304873UL, "10.0.1.3"},
+ {"OI5XZ_BBT(", 2155922164UL, 2168579133UL, "10.0.1.5"},
+ {"2TLRL/UL;:", 1086800909UL, 1095659802UL, "10.0.1.2"},
+ {"WHD\\O1`ZRW", 3087923411UL, 3095471560UL, "10.0.1.1"},
+ {".=54)_c;=T", 2497691631UL, 2502731301UL, "10.0.1.6"},
+ {";G<W-XWZ@b", 2888169733UL, 2888728739UL, "10.0.1.7"},
+ {"(,>E`)FT\\4", 580747448UL, 581063326UL, "10.0.1.5"},
+ {"HZAU*;P*N]", 2564670474UL, 2565697267UL, "10.0.1.1"},
+ {"NZ@ZE=O84_", 533335275UL, 539988520UL, "10.0.1.7"},
+ {"6,cEI`F_P>", 3972869246UL, 3974773167UL, "10.0.1.3"},
+ {"c,5AQ/T5)6", 2835605783UL, 2847870057UL, "10.0.1.7"},
+ {".O,>>BT)RX", 3857978174UL, 3871917949UL, "10.0.1.7"},
+ {"XY\\X::LX50", 1749241099UL, 1752196488UL, "10.0.1.7"},
+ {"+550F^/.01", 3781824099UL, 3783248219UL, "10.0.1.2"},
+ {"<.X9E2S5+9", 3232479481UL, 3234387706UL, "10.0.1.7"},
+ {"]\\.UH8_0a1", 2419699252UL, 2423002920UL, "10.0.1.6"},
+ {"8(6=(T0/Z0", 728266737UL, 729026070UL, "10.0.1.6"},
+ {"8*6a;Sc*X+", 4223431086UL, 4230156966UL, "10.0.1.5"},
+ {"<QW:;3K6;H", 2731158143UL, 2743975456UL, "10.0.1.7"},
+ {"7C@EY@-Y?_", 760770733UL, 761576669UL, "10.0.1.5"},
+ {"aPb3E1WD4K", 2500489218UL, 2502731301UL, "10.0.1.2"},
+ {"?@12R<=1BH", 1494795329UL, 1502505505UL, "10.0.1.1"},
+ {"QR(a+Q=1FU", 3238535074UL, 3238996435UL, "10.0.1.5"},
+ {"`C9^FV,960", 2628553463UL, 2628733766UL, "10.0.1.3"},
+ {"UNHVP..^8H", 977096483UL, 977319837UL, "10.0.1.6"},
+ {":Y.2W2[(35", 2777083668UL, 2784182515UL, "10.0.1.6"},
+ {"M/HV^_HZ4O", 3623390946UL, 3624445007UL, "10.0.1.4"},
+ {"ZY16KQ<ICD", 1831153193UL, 1838563516UL, "10.0.1.7"},
+ {"bV2,`a.PY9", 1962228869UL, 1962648654UL, "10.0.1.7"},
+ {"U;9:-+5N]9", 269504649UL, 277560877UL, "10.0.1.2"},
+ {"1S/:aJ[1(;", 578069729UL, 581063326UL, "10.0.1.5"},
+ {"Nb-X^]M)I:", 330865696UL, 331009896UL, "10.0.1.3"},
+ {"2;M;ES>J5/", 2776949824UL, 2784182515UL, "10.0.1.6"},
+ {"[>RZHG97Q9", 71954686UL, 72034069UL, "10.0.1.4"},
+ {"J3/G[)9<^Z", 2799896459UL, 2805183696UL, "10.0.1.6"},
+ {"N-)88>[O`,", 50404102UL, 51792557UL, "10.0.1.2"},
+ {"NP:=FR\\OaA", 3837333776UL, 3837792034UL, "10.0.1.7"},
+ {"`@L+W;a,O[", 1512157148UL, 1522285852UL, "10.0.1.5"},
+ {"W2`P:-+1T[", 2945171975UL, 2946196424UL, "10.0.1.7"},
+ {"-6G7K^YDIN", 3168617340UL, 3170513015UL, "10.0.1.5"},
+ {"U>*>9ZI6V5", 668514946UL, 674097631UL, "10.0.1.5"},
+ {".I?^6Ic9RK", 938419020UL, 942832691UL, "10.0.1.6"},
+ {"0OZH^9BKM[", 3682518606UL, 3686781297UL, "10.0.1.2"},
+ {"5?50UGZ:ML", 868610882UL, 869425986UL, "10.0.1.6"},
+ {"?K2NF@3=IU", 381218851UL, 383925769UL, "10.0.1.6"},
+ {"YI@G-2X?UB", 3688706179UL, 3693197681UL, "10.0.1.6"},
+ {"7cY</BSaL=", 3976870223UL, 3978903843UL, "10.0.1.7"},
+ {"A(`KF:[RH8", 3292979676UL, 3294849139UL, "10.0.1.6"},
+ {";=ZT\\W^P+H", 1401102653UL, 1416290674UL, "10.0.1.6"},
+ {"b2?WFF56;R", 480494704UL, 486971192UL, "10.0.1.7"},
+ {"CTR74,J+N.", 137446045UL, 146633907UL, "10.0.1.7"},
+ {"<b;*R+QDST", 1304985302UL, 1308223778UL, "10.0.1.5"},
+ {"\\R^7=9UCG`", 126218373UL, 129199837UL, "10.0.1.6"},
+ {"1bQS5]WOXB", 1853470245UL, 1855329369UL, "10.0.1.7"},
+ {"M(@X^b[L:K", 3019630308UL, 3022260113UL, "10.0.1.4"},
+ {"431cBF8,YO", 1679726993UL, 1685224295UL, "10.0.1.1"},
+ {"(bEIQJ:E./", 2922607787UL, 2925521819UL, "10.0.1.7"},
+ {"WS/3H*)7F;", 419488232UL, 422140585UL, "10.0.1.3"},
+ {"ZJF[Ia6Q)+", 3960568056UL, 3962489998UL, "10.0.1.5"},
+ {"<]*QCK8U,>", 2590140172UL, 2598117636UL, "10.0.1.5"},
+ {"\\[a\\^=V_M0", 689410119UL, 698690782UL, "10.0.1.7"},
+ {"7;RM+8J9YC", 1530175299UL, 1531107082UL, "10.0.1.7"},
+ {"4*=.SPR[AV", 3928582722UL, 3928853792UL, "10.0.1.3"},
+ {"-2F+^88P4U", 3023552752UL, 3025823613UL, "10.0.1.7"},
+ {"X;-F`(N?9D", 570465234UL, 572485994UL, "10.0.1.5"},
+ {"R=F_D-K2a]", 1287750228UL, 1290935562UL, "10.0.1.1"},
+ {"X*+2aaC.EG", 3200948713UL, 3201088518UL, "10.0.1.3"},
+ {"[1ZXONX2]a", 4108881567UL, 4109865744UL, "10.0.1.7"},
+ {"FL;\\GWacaV", 458449508UL, 467374054UL, "10.0.1.7"},
+ {"\\MQ_XNT7L-", 1259349383UL, 1259509450UL, "10.0.1.5"},
+ {"VD6D0]ba_\\", 3842502950UL, 3842588691UL, "10.0.1.7"},
};
-
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
#pragma once
#include <cstring>
c_string(const char *s, size_t l) noexcept
: c_str{s}
- , size{l}
- {}
- bool operator ==(const c_string &cs) const noexcept {
- return !strcmp(c_str, cs.c_str);
- }
- bool operator ==(const char *p) const noexcept {
- return !strcmp(c_str, p);
- }
+ , size{l} {}
+ bool operator==(const c_string &cs) const noexcept { return !strcmp(c_str, cs.c_str); }
+ bool operator==(const char *p) const noexcept { return !strcmp(c_str, p); }
};
static c_string null_c_string{nullptr, 0};
test_case(c_string o, c_string r) noexcept
: option{o}
- , result{r}
- {}
+ , result{r} {}
test_case(const char *os, size_t ol, const char *rs, size_t rl) noexcept
: option{os, ol}
- , result{c_string{rs, rl}}
- {}
+ , result{c_string{rs, rl}} {}
test_case(const char *os, size_t ol, memcached_behavior_t b, uint64_t v) noexcept
- : option{os, ol}
- , result{setting_t{b, v}}
- {}
+ : option{os, ol}
+ , result{setting_t{b, v}} {}
test_case(const char *os, size_t ol, memcached_flag_t f, uint64_t v) noexcept
- : option{os, ol}
- , result{setting_t{f, v}}
- {}
+ : option{os, ol}
+ , result{setting_t{f, v}} {}
};
-#define test_count(tca) (sizeof(tca)/sizeof(tca[0]))
+#define test_count(tca) (sizeof(tca) / sizeof(tca[0]))
struct test_group {
using check_func = function<void(memcached_st *, const test_case::result_t &)>;
: name{name_}
, check{move(check_)}
, tests{tests_}
- , ntests{ntests_}
- {}
+ , ntests{ntests_} {}
};
static test_case host_string_tests[] = {
- {S("--server=localhost"), S("localhost")},
- {S("--server=10.0.2.1"), S("10.0.2.1")},
- {S("--server=example.com"), S("example.com")},
- {S("--server=localhost:30"), S("localhost")},
- {S("--server=10.0.2.1:20"), S("10.0.2.1")},
- {S("--server=example.com:1024"), S("example.com")},
- {S("--server=10.0.2.1:30/?40"), S("10.0.2.1")},
- {S("--server=example.com:1024/?30"), S("example.com")},
- {S("--server=10.0.2.1/?20"), S("10.0.2.1")},
- {S("--server=example.com/?10"), S("example.com")},
+ {S("--server=localhost"), S("localhost")},
+ {S("--server=10.0.2.1"), S("10.0.2.1")},
+ {S("--server=example.com"), S("example.com")},
+ {S("--server=localhost:30"), S("localhost")},
+ {S("--server=10.0.2.1:20"), S("10.0.2.1")},
+ {S("--server=example.com:1024"), S("example.com")},
+ {S("--server=10.0.2.1:30/?40"), S("10.0.2.1")},
+ {S("--server=example.com:1024/?30"), S("example.com")},
+ {S("--server=10.0.2.1/?20"), S("10.0.2.1")},
+ {S("--server=example.com/?10"), S("example.com")},
};
static test_group test_host_strings{
- "host strings",
- [](memcached_st *memc, const test_case::result_t &result) {
- auto instance = memcached_server_instance_by_position(memc, 0);
- REQUIRE(instance);
- REQUIRE(get<c_string>(result) == memcached_server_name(instance));
- },
- host_string_tests,
- test_count(host_string_tests)
-};
+ "host strings",
+ [](memcached_st *memc, const test_case::result_t &result) {
+ auto instance = memcached_server_instance_by_position(memc, 0);
+ REQUIRE(instance);
+ REQUIRE(get<c_string>(result) == memcached_server_name(instance));
+ },
+ host_string_tests, test_count(host_string_tests)};
static test_case bad_host_string_tests[] = {
- {{S("-servers=localhost:11221,localhost:11222,localhost:11223,localhost:11224,localhost:11225")}, null_c_string},
+ {{S("-servers=localhost:11221,localhost:11222,localhost:11223,localhost:11224,localhost:"
+ "11225")},
+ null_c_string},
{{S("-- servers=a.example.com:81,localhost:82,b.example.com")}, null_c_string},
{{S("--servers=localhost:+80")}, null_c_string},
// all of the following should not fail IMO
};
static test_group test_bad_host_strings{
- "bad host strings",
- [](memcached_st *memc, const test_case::result_t &) {
- REQUIRE_FALSE(memc);
- },
- bad_host_string_tests,
- test_count(bad_host_string_tests)
-};
+ "bad host strings",
+ [](memcached_st *memc, const test_case::result_t &) { REQUIRE_FALSE(memc); },
+ bad_host_string_tests, test_count(bad_host_string_tests)};
static test_case behavior_tests[] = {
{S("--CONNECT-TIMEOUT=456"), MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT, 456},
{S("--TCP-KEEPIDLE"), MEMCACHED_BEHAVIOR_TCP_KEEPIDLE, 1},
{S("--USE-UDP"), MEMCACHED_BEHAVIOR_USE_UDP, 1},
{S("--VERIFY-KEY"), MEMCACHED_BEHAVIOR_VERIFY_KEY, 1},
- {S("--DISTRIBUTION=consistent"), MEMCACHED_BEHAVIOR_DISTRIBUTION, MEMCACHED_DISTRIBUTION_CONSISTENT},
- {S("--DISTRIBUTION=consistent,CRC"), MEMCACHED_BEHAVIOR_DISTRIBUTION, MEMCACHED_DISTRIBUTION_CONSISTENT},
- {S("--DISTRIBUTION=consistent,MD5"), MEMCACHED_BEHAVIOR_DISTRIBUTION, MEMCACHED_DISTRIBUTION_CONSISTENT},
- {S("--DISTRIBUTION=consistent,JENKINS"), MEMCACHED_BEHAVIOR_KETAMA_HASH, MEMCACHED_HASH_JENKINS},
+ {S("--DISTRIBUTION=consistent"), MEMCACHED_BEHAVIOR_DISTRIBUTION,
+ MEMCACHED_DISTRIBUTION_CONSISTENT},
+ {S("--DISTRIBUTION=consistent,CRC"), MEMCACHED_BEHAVIOR_DISTRIBUTION,
+ MEMCACHED_DISTRIBUTION_CONSISTENT},
+ {S("--DISTRIBUTION=consistent,MD5"), MEMCACHED_BEHAVIOR_DISTRIBUTION,
+ MEMCACHED_DISTRIBUTION_CONSISTENT},
+ {S("--DISTRIBUTION=consistent,JENKINS"), MEMCACHED_BEHAVIOR_KETAMA_HASH,
+ MEMCACHED_HASH_JENKINS},
{S("--DISTRIBUTION=random"), MEMCACHED_BEHAVIOR_DISTRIBUTION, MEMCACHED_DISTRIBUTION_RANDOM},
{S("--DISTRIBUTION=modula"), MEMCACHED_BEHAVIOR_DISTRIBUTION, MEMCACHED_DISTRIBUTION_MODULA},
{S("--HASH=CRC"), MEMCACHED_BEHAVIOR_HASH, MEMCACHED_HASH_CRC},
};
static test_group test_behaviors{
- "behaviors",
- [](memcached_st *memc, const test_case::result_t &result) {
- auto setting = get<test_case::setting_t>(result);
- REQUIRE(memc);
- REQUIRE(setting.second ==
- memcached_behavior_get(memc, get<memcached_behavior_t>(setting.first)));
- },
- behavior_tests,
- test_count(behavior_tests)
-};
+ "behaviors",
+ [](memcached_st *memc, const test_case::result_t &result) {
+ auto setting = get<test_case::setting_t>(result);
+ REQUIRE(memc);
+ REQUIRE(setting.second
+ == memcached_behavior_get(memc, get<memcached_behavior_t>(setting.first)));
+ },
+ behavior_tests, test_count(behavior_tests)};
static test_case flag_tests[] = {
{S("--FETCH-VERSION"), MEMCACHED_FLAG_IS_FETCHING_VERSION, 1},
};
static test_group test_flags{
- "flags",
- [](memcached_st *memc, const test_case::result_t &result) {
- auto setting = get<test_case::setting_t>(result);
- REQUIRE(memc);
- REQUIRE(setting.second == memcached_flag(*memc, get<memcached_flag_t>(setting.first)));
- },
- flag_tests,
- test_count(flag_tests)
-};
+ "flags",
+ [](memcached_st *memc, const test_case::result_t &result) {
+ auto setting = get<test_case::setting_t>(result);
+ REQUIRE(memc);
+ REQUIRE(setting.second == memcached_flag(*memc, get<memcached_flag_t>(setting.first)));
+ },
+ flag_tests, test_count(flag_tests)};
static test_case namespace_tests[] = {
{S("--NAMESPACE=foo"), S("foo")},
{S("--NAMESPACE=\"foo\""), S("foo")},
- {S("--NAMESPACE=\"The quick brown fox jumps over the lazy dog\""), S("The quick brown fox jumps over the lazy dog")},
+ {S("--NAMESPACE=\"The quick brown fox jumps over the lazy dog\""),
+ S("The quick brown fox jumps over the lazy dog")},
};
-static test_group test_namespace{
- "namespace",
- [](memcached_st *memc, const test_case::result_t &result) {
- auto ns = get<c_string>(result);
- REQUIRE(memc);
- REQUIRE(ns == memcached_get_namespace(*memc));
- },
- namespace_tests,
- test_count(namespace_tests)
-};
+static test_group test_namespace{"namespace",
+ [](memcached_st *memc, const test_case::result_t &result) {
+ auto ns = get<c_string>(result);
+ REQUIRE(memc);
+ REQUIRE(ns == memcached_get_namespace(*memc));
+ },
+ namespace_tests, test_count(namespace_tests)};
static test_group tests[] = {
test_host_strings,
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
#pragma once
#include "common.hpp"
class Cluster {
public:
- explicit
- Cluster(Server serv, uint16_t cnt = 0);
+ explicit Cluster(Server serv, uint16_t cnt = 0);
~Cluster();
Cluster(const Cluster &c) = delete;
- Cluster &operator = (const Cluster &c) = delete;
+ Cluster &operator=(const Cluster &c) = delete;
Cluster(Cluster &&c)
- : proto{}
- {
+ : proto{} {
*this = move(c);
};
- Cluster &operator = (Cluster &&c) {
+ Cluster &operator=(Cluster &&c) {
count = exchange(c.count, 0);
proto = exchange(c.proto, Server{});
cluster = exchange(c.cluster, {});
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
#pragma once
#include "common.hpp"
void swap(Connection &conn);
Connection(const Connection &conn);
- Connection &operator = (const Connection &conn);
+ Connection &operator=(const Connection &conn);
- Connection(Connection &&conn) noexcept ;
- Connection &operator = (Connection &&conn) noexcept ;
+ Connection(Connection &&conn) noexcept;
+ Connection &operator=(Connection &&conn) noexcept;
int getError();
int getLastError();
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
#pragma once
#include "common.hpp"
~ForkAndExec();
ForkAndExec(const ForkAndExec &) = delete;
- ForkAndExec &operator = (const ForkAndExec &) = delete;
+ ForkAndExec &operator=(const ForkAndExec &) = delete;
ForkAndExec(ForkAndExec &&) = default;
- ForkAndExec &operator = (ForkAndExec &&) = default;
+ ForkAndExec &operator=(ForkAndExec &&) = default;
- [[nodiscard]]
- int createPipe();
- pid_t operator () ();
+ [[nodiscard]] int createPipe();
+ pid_t operator()();
private:
int ready[2], pipes[2];
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
#pragma once
#include "common.hpp"
#include "Cluster.hpp"
#include "ReturnMatcher.hpp"
-
class MemcachedCluster {
public:
using behavior_t = pair<memcached_behavior_t, uint64_t>;
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
#pragma once
#include "common.hpp"
class Retry {
public:
-
using predicate = function<bool()>;
explicit Retry(predicate pred_, unsigned max_ = 10, chrono::milliseconds sleep_for_ = 100ms);
- bool operator () ();
+ bool operator()();
private:
unsigned max;
chrono::milliseconds sleep_for;
predicate pred;
};
-
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
#pragma once
#include "test/lib/common.hpp"
class ReturnMatcher : public Catch::MatcherBase<memcached_return_t> {
public:
- explicit ReturnMatcher(const memcached_st *memc_, memcached_return_t expected_ = MEMCACHED_SUCCESS)
- : memc{memc_}
- , expected{expected_}
- {}
+ explicit ReturnMatcher(const memcached_st *memc_,
+ memcached_return_t expected_ = MEMCACHED_SUCCESS)
+ : memc{memc_}
+ , expected{expected_} {}
ReturnMatcher(const ReturnMatcher &) = default;
ReturnMatcher(ReturnMatcher &&rm);
- ReturnMatcher &operator = (ReturnMatcher &&rm);
+ ReturnMatcher &operator=(ReturnMatcher &&rm);
bool match(const memcached_return_t &arg) const override;
ReturnMatcher success();
- ReturnMatcher operator () (memcached_return_t expected_);
+ ReturnMatcher operator()(memcached_return_t expected_);
protected:
string describe() const override;
class LoneReturnMatcher {
public:
ReturnMatcher returns;
- explicit LoneReturnMatcher(const memcached_st *memc) : returns{memc}
- {}
+ explicit LoneReturnMatcher(const memcached_st *memc)
+ : returns{memc} {}
};
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
#pragma once
#include "common.hpp"
class Server {
public:
-
friend class Cluster;
using arg_func_t = function<string(string)>;
using arg_pair_t = pair<arg_t, arg_t>;
using argv_t = vector<variant<arg_t, arg_pair_t>>;
- explicit
- Server(string binary_ = "false", argv_t args_ = {});
+ explicit Server(string binary_ = "false", argv_t args_ = {});
~Server();
Server(const Server &s);
- Server &operator = (const Server &s);
+ Server &operator=(const Server &s);
- Server(Server &&s) {
- *this = move(s);
- };
- Server &operator = (Server &&s) {
+ Server(Server &&s) { *this = move(s); };
+ Server &operator=(Server &&s) {
binary = exchange(s.binary, "false");
args = exchange(s.args, {});
pid = exchange(s.pid, 0);
int pipe;
ChildProc(pid_t pid_, int pipe_)
: pid{pid_}
- , pipe{pipe_}
- {
- }
+ , pipe{pipe_} {}
};
optional<ChildProc> start();
bool stop();
bool tryWait();
string &drain();
-
private:
string binary;
argv_t args;
socket_or_port_t socket_or_port = 11211;
string output;
- [[nodiscard]]
- vector<char *> createArgv();
+ [[nodiscard]] vector<char *> createArgv();
optional<string> handleArg(vector<char *> &arr, const string &arg, const arg_func_t &next_arg);
};
-inline ostream &operator << (ostream &out, const socket_or_port_t sop) {
+inline ostream &operator<<(ostream &out, const socket_or_port_t sop) {
if (holds_alternative<string>(sop)) {
out << get<string>(sop);
} else {
return out;
}
-inline ostream &operator << (ostream &out, const Server &server) {
- out << "Server{binary=" << server.getBinary() << ",pid=" << server.getPid() << ",conn=" << server.getSocketOrPort() << "}";
+inline ostream &operator<<(ostream &out, const Server &server) {
+ out << "Server{binary=" << server.getBinary() << ",pid=" << server.getPid()
+ << ",conn=" << server.getSocketOrPort() << "}";
return out;
}
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
#pragma once
#include "test/lib/common.hpp"
explicit Shell(const string &prefix, bool redirect_stderr = true);
bool run(const string &command, string &output);
bool run(const string &command);
+
private:
string prefix;
bool redirect;
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
#pragma once
#include <chrono>
/**
* Useful macros for testing
*/
-#define S(s) (s),strlen(s)
+#define S(s) (s), strlen(s)
#define DECLARE_STREQUAL static auto strequal = equal_to<string>();
#define LOOPED_SECTION(tests) \
for (auto &[name, test] : tests) DYNAMIC_SECTION("test " << name)
-#define REQUIRE_SUCCESS(rc) do { \
- INFO("expected: SUCCESS"); \
+#define REQUIRE_SUCCESS(rc) \
+ do { \
+ INFO("expected: SUCCESS"); \
REQUIRE_THAT(rc, test.returns.success()); \
- } while(0)
-#define REQUIRE_RC(rc, call) do { \
+ } while (0)
+#define REQUIRE_RC(rc, call) \
+ do { \
INFO("expected: " << memcached_strerror(nullptr, rc)); \
- REQUIRE_THAT(call, test.returns(rc)); \
- } while(0)
+ REQUIRE_THAT(call, test.returns(rc)); \
+ } while (0)
const char *getenv_else(const char *var, const char *defval);
-inline memcached_return_t fetch_all_results(memcached_st *memc, unsigned int &keys_returned, memcached_return_t &rc) {
+inline memcached_return_t fetch_all_results(memcached_st *memc, unsigned int &keys_returned,
+ memcached_return_t &rc) {
keys_returned = 0;
memcached_result_st *result = nullptr;
class Tempfile {
public:
explicit Tempfile(const char templ_[] = "memc.test.XXXXXX") {
- *copy(S(templ_)+templ_, fn) = '\0';
+ *copy(S(templ_) + templ_, fn) = '\0';
fd = mkstemp(fn);
}
~Tempfile() {
close(fd);
unlink(fn);
}
- int getFd() const {
- return fd;
- }
- const char *getFn() const {
- return fn;
- }
+ int getFd() const { return fd; }
+ const char *getFn() const { return fn; }
bool put(const char *buf, size_t len) const {
- return static_cast<ssize_t >(len) == write(fd, buf, len);
+ return static_cast<ssize_t>(len) == write(fd, buf, len);
}
+
private:
char fn[80];
int fd;
public:
memcached_st *memc;
- explicit
- MemcachedPtr(memcached_st *memc_) {
- memc = memc_;
- }
+ explicit MemcachedPtr(memcached_st *memc_) { memc = memc_; }
MemcachedPtr()
- : MemcachedPtr(memcached_create(nullptr))
- {}
- ~MemcachedPtr() {
- memcached_free(memc);
- }
- memcached_st *operator * () const {
- return memc;
- }
- auto operator ->() const{
- return memc;
- }
+ : MemcachedPtr(memcached_create(nullptr)) {}
+ ~MemcachedPtr() { memcached_free(memc); }
+ memcached_st *operator*() const { return memc; }
+ auto operator->() const { return memc; }
};
template<class T>
class Malloced {
T *ptr;
+
public:
- explicit
- Malloced(T *ptr_)
- : ptr{ptr_}
- {}
+ explicit Malloced(T *ptr_)
+ : ptr{ptr_} {}
Malloced &operator=(T *ptr_) {
if (ptr)
free(ptr);
return *this;
}
~Malloced() {
- if(ptr)
+ if (ptr)
free(ptr);
}
- auto operator *() {
- return ptr;
- }
- auto operator ->() {
- return ptr;
- }
+ auto operator*() { return ptr; }
+ auto operator->() { return ptr; }
};
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
#pragma once
#include "mem_config.h"
#include <cstdlib>
#if HAVE_SETENV
-# define SET_ENV_EX(n, k, v, overwrite) setenv(k, v, (overwrite))
+# define SET_ENV_EX(n, k, v, overwrite) setenv(k, v, (overwrite))
#else // !HAVE_SETENV
-# define SET_ENV_EX(n, k, v, overwrite) do { \
- static char n ## _env[] = k "=" v; \
- if ((overwrite) || !getenv(k)) { \
- putenv(n ## _env); \
- } \
-} while(false)
+# define SET_ENV_EX(n, k, v, overwrite) \
+ do { \
+ static char n##_env[] = k "=" v; \
+ if ((overwrite) || !getenv(k)) { \
+ putenv(n##_env); \
+ } \
+ } while (false)
#endif
#define SET_ENV(symbolic_name, literal_env_var, literal_env_val) \
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
#pragma once
#include <cstddef>
string random_binary_string(size_t len);
char random_ascii(char min = '!', char max = '~');
string random_ascii_string(size_t len, char min = '!', char max = '~');
-kv_pair random_ascii_pair(size_t minlen = 1<<2, size_t maxlen = 1<<10);
+kv_pair random_ascii_pair(size_t minlen = 1 << 2, size_t maxlen = 1 << 10);
-template<template <typename> class Container>
-auto random_ascii_pairs(size_t count, size_t minlen = 1<<2, size_t maxlen = 1<<10) {
+template<template<typename> class Container>
+auto random_ascii_pairs(size_t count, size_t minlen = 1 << 2, size_t maxlen = 1 << 10) {
Container<kv_pair> v;
v.reserve(count);
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
#define CATCH_CONFIG_RUNNER
#include "lib/catch.hpp"
#include "setup.hpp"
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
#pragma once
int setup(int &argc, char ***argv);