projects
/
awesomized
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Merge in additional language plus some of the configure language for
[awesomized/libmemcached]
/
tests
/
hashkit_functions.c
diff --git
a/tests/hashkit_functions.c
b/tests/hashkit_functions.c
index 005143a0b2e44f7794b70778211fda92ad992d16..23feb9e50a6f3e46459684fb0a9196d07081359a 100644
(file)
--- a/
tests/hashkit_functions.c
+++ b/
tests/hashkit_functions.c
@@
-6,6
+6,8
@@
* the COPYING file in the parent directory for full text.
*/
* the COPYING file in the parent directory for full text.
*/
+#include "config.h"
+
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
@@
-13,7
+15,7
@@
#include <libhashkit/hashkit.h>
#include <libhashkit/hashkit.h>
-#include
"test.h"
+#include
<libtest/test.h>
#include "hash_results.h"
#include "hash_results.h"
@@
-29,10
+31,11
@@
struct hash_test_st
bool _unused;
};
bool _unused;
};
-static test_return_t init_test(void *not_used
__attribute__((unused))
)
+static test_return_t init_test(void *not_used)
{
hashkit_st hashk;
hashkit_st *hashk_ptr;
{
hashkit_st hashk;
hashkit_st *hashk_ptr;
+ (void)not_used;
hashk_ptr= hashkit_create(&hashk);
test_true(hashk_ptr);
hashk_ptr= hashkit_create(&hashk);
test_true(hashk_ptr);
@@
-44,9
+47,10
@@
static test_return_t init_test(void *not_used __attribute__((unused)))
return TEST_SUCCESS;
}
return TEST_SUCCESS;
}
-static test_return_t allocation_test(void *not_used
__attribute__((unused))
)
+static test_return_t allocation_test(void *not_used)
{
hashkit_st *hashk_ptr;
{
hashkit_st *hashk_ptr;
+ (void)not_used;
hashk_ptr= hashkit_create(NULL);
test_true(hashk_ptr);
hashk_ptr= hashkit_create(NULL);
test_true(hashk_ptr);
@@
-113,10
+117,11
@@
static test_return_t clone_test(hashkit_st *hashk)
return TEST_SUCCESS;
}
return TEST_SUCCESS;
}
-static test_return_t one_at_a_time_run (hashkit_st *hashk
__attribute__((unused))
)
+static test_return_t one_at_a_time_run (hashkit_st *hashk)
{
uint32_t x;
const char **ptr;
{
uint32_t x;
const char **ptr;
+ (void)hashk;
for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
{
for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
{
@@
-129,10
+134,11
@@
static test_return_t one_at_a_time_run (hashkit_st *hashk __attribute__((unused)
return TEST_SUCCESS;
}
return TEST_SUCCESS;
}
-static test_return_t md5_run (hashkit_st *hashk
__attribute__((unused))
)
+static test_return_t md5_run (hashkit_st *hashk)
{
uint32_t x;
const char **ptr;
{
uint32_t x;
const char **ptr;
+ (void)hashk;
for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
{
for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
{
@@
-145,10
+151,11
@@
static test_return_t md5_run (hashkit_st *hashk __attribute__((unused)))
return TEST_SUCCESS;
}
return TEST_SUCCESS;
}
-static test_return_t crc_run (hashkit_st *hashk
__attribute__((unused))
)
+static test_return_t crc_run (hashkit_st *hashk)
{
uint32_t x;
const char **ptr;
{
uint32_t x;
const char **ptr;
+ (void)hashk;
for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
{
for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
{
@@
-161,10
+168,11
@@
static test_return_t crc_run (hashkit_st *hashk __attribute__((unused)))
return TEST_SUCCESS;
}
return TEST_SUCCESS;
}
-static test_return_t fnv1_64_run (hashkit_st *hashk
__attribute__((unused))
)
+static test_return_t fnv1_64_run (hashkit_st *hashk)
{
uint32_t x;
const char **ptr;
{
uint32_t x;
const char **ptr;
+ (void)hashk;
for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
{
for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
{
@@
-177,10
+185,11
@@
static test_return_t fnv1_64_run (hashkit_st *hashk __attribute__((unused)))
return TEST_SUCCESS;
}
return TEST_SUCCESS;
}
-static test_return_t fnv1a_64_run (hashkit_st *hashk
__attribute__((unused))
)
+static test_return_t fnv1a_64_run (hashkit_st *hashk)
{
uint32_t x;
const char **ptr;
{
uint32_t x;
const char **ptr;
+ (void)hashk;
for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
{
for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
{
@@
-193,11
+202,11
@@
static test_return_t fnv1a_64_run (hashkit_st *hashk __attribute__((unused)))
return TEST_SUCCESS;
}
return TEST_SUCCESS;
}
-static test_return_t fnv1_32_run (hashkit_st *hashk
__attribute__((unused))
)
+static test_return_t fnv1_32_run (hashkit_st *hashk)
{
uint32_t x;
const char **ptr;
{
uint32_t x;
const char **ptr;
-
+ (void)hashk;
for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
{
for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
{
@@
-210,10
+219,11
@@
static test_return_t fnv1_32_run (hashkit_st *hashk __attribute__((unused)))
return TEST_SUCCESS;
}
return TEST_SUCCESS;
}
-static test_return_t fnv1a_32_run (hashkit_st *hashk
__attribute__((unused))
)
+static test_return_t fnv1a_32_run (hashkit_st *hashk)
{
uint32_t x;
const char **ptr;
{
uint32_t x;
const char **ptr;
+ (void)hashk;
for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
{
for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
{
@@
-226,10
+236,11
@@
static test_return_t fnv1a_32_run (hashkit_st *hashk __attribute__((unused)))
return TEST_SUCCESS;
}
return TEST_SUCCESS;
}
-static test_return_t hsieh_run (hashkit_st *hashk
__attribute__((unused))
)
+static test_return_t hsieh_run (hashkit_st *hashk)
{
uint32_t x;
const char **ptr;
{
uint32_t x;
const char **ptr;
+ (void)hashk;
for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
{
for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
{
@@
-246,9
+257,12
@@
static test_return_t hsieh_run (hashkit_st *hashk __attribute__((unused)))
return TEST_SUCCESS;
}
return TEST_SUCCESS;
}
-static test_return_t murmur_run (hashkit_st *hashk
__attribute__((unused))
)
+static test_return_t murmur_run (hashkit_st *hashk)
{
{
-#ifdef __sparc
+ (void)hashk;
+
+#ifdef WORDS_BIGENDIAN
+ (void)murmur_values;
return TEST_SKIPPED;
#else
uint32_t x;
return TEST_SKIPPED;
#else
uint32_t x;
@@
-258,7
+272,11
@@
static test_return_t murmur_run (hashkit_st *hashk __attribute__((unused)))
{
uint32_t hash_val;
{
uint32_t hash_val;
+#ifdef HAVE_MURMUR_HASH
hash_val= libhashkit_murmur(*ptr, strlen(*ptr));
hash_val= libhashkit_murmur(*ptr, strlen(*ptr));
+#else
+ hash_val= 1;
+#endif
assert(murmur_values[x] == hash_val);
}
assert(murmur_values[x] == hash_val);
}
@@
-266,11
+284,11
@@
static test_return_t murmur_run (hashkit_st *hashk __attribute__((unused)))
#endif
}
#endif
}
-static test_return_t jenkins_run (hashkit_st *hashk
__attribute__((unused))
)
+static test_return_t jenkins_run (hashkit_st *hashk)
{
uint32_t x;
const char **ptr;
{
uint32_t x;
const char **ptr;
-
+ (void)hashk;
for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
{
for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
{
@@
-307,7
+325,7
@@
static test_return_t hashkit_digest_test(hashkit_st *hashk)
static test_return_t hashkit_set_function_test(hashkit_st *hashk)
{
static test_return_t hashkit_set_function_test(hashkit_st *hashk)
{
- for (hashkit_hash_algorithm_t algo = HASHKIT_HASH_DEFAULT; algo < HASHKIT_HASH_MAX; algo++)
+ for (hashkit_hash_algorithm_t algo = HASHKIT_HASH_DEFAULT; algo < HASHKIT_HASH_MAX; algo++)
{
hashkit_return_t rc;
uint32_t x;
{
hashkit_return_t rc;
uint32_t x;
@@
-317,13
+335,20
@@
static test_return_t hashkit_set_function_test(hashkit_st *hashk)
rc= hashkit_set_function(hashk, algo);
/* Hsieh is disabled most of the time for patent issues */
rc= hashkit_set_function(hashk, algo);
/* Hsieh is disabled most of the time for patent issues */
+#ifndef HAVE_HSIEH_HASH
if (rc == HASHKIT_FAILURE && algo == HASHKIT_HASH_HSIEH)
continue;
if (rc == HASHKIT_FAILURE && algo == HASHKIT_HASH_HSIEH)
continue;
+#endif
- if (rc == HASHKIT_FAILURE && algo == HASHKIT_HASH_CUSTOM)
+#ifndef HAVE_MURMUR_HASH
+ if (rc == HASHKIT_FAILURE && algo == HASHKIT_HASH_MURMUR)
continue;
continue;
+#endif
- test_true(rc == HASHKIT_SUCCESS);
+ if (rc == HASHKIT_INVALID_ARGUMENT && algo == HASHKIT_HASH_CUSTOM)
+ continue;
+
+ test_true_got(rc == HASHKIT_SUCCESS, hashkit_strerror(NULL, rc));
switch (algo)
{
switch (algo)
{
@@
-413,7
+438,7
@@
static test_return_t hashkit_set_custom_function_test(hashkit_st *hashk)
static test_return_t hashkit_set_distribution_function_test(hashkit_st *hashk)
{
static test_return_t hashkit_set_distribution_function_test(hashkit_st *hashk)
{
- for (hashkit_hash_algorithm_t algo = HASHKIT_HASH_DEFAULT; algo < HASHKIT_HASH_MAX; algo++)
+ for (hashkit_hash_algorithm_t algo = HASHKIT_HASH_DEFAULT; algo < HASHKIT_HASH_MAX; algo++)
{
hashkit_return_t rc;
{
hashkit_return_t rc;
@@
-423,7
+448,7
@@
static test_return_t hashkit_set_distribution_function_test(hashkit_st *hashk)
if (rc == HASHKIT_FAILURE && algo == HASHKIT_HASH_HSIEH)
continue;
if (rc == HASHKIT_FAILURE && algo == HASHKIT_HASH_HSIEH)
continue;
- if (rc == HASHKIT_
FAILURE
&& algo == HASHKIT_HASH_CUSTOM)
+ if (rc == HASHKIT_
INVALID_ARGUMENT
&& algo == HASHKIT_HASH_CUSTOM)
continue;
test_true(rc == HASHKIT_SUCCESS);
continue;
test_true(rc == HASHKIT_SUCCESS);
@@
-445,7
+470,7
@@
static test_return_t hashkit_set_custom_distribution_function_test(hashkit_st *h
static test_return_t hashkit_get_function_test(hashkit_st *hashk)
{
static test_return_t hashkit_get_function_test(hashkit_st *hashk)
{
- for (hashkit_hash_algorithm_t algo = HASHKIT_HASH_DEFAULT; algo < HASHKIT_HASH_MAX; algo++)
+ for (hashkit_hash_algorithm_t algo = HASHKIT_HASH_DEFAULT; algo < HASHKIT_HASH_MAX; algo++)
{
hashkit_return_t rc;
{
hashkit_return_t rc;
@@
-467,6
+492,7
@@
static test_return_t hashkit_compare_test(hashkit_st *hashk)
clone= hashkit_clone(NULL, hashk);
test_true(hashkit_compare(clone, hashk));
clone= hashkit_clone(NULL, hashk);
test_true(hashkit_compare(clone, hashk));
+ hashkit_free(clone);
return TEST_SUCCESS;
}
return TEST_SUCCESS;
}