git://git.onelab.eu
/
sliver-openvswitch.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of ssh://git.onelab.eu/git/sliver-openvswitch
[sliver-openvswitch.git]
/
tests
/
test-hindex.c
diff --git
a/tests/test-hindex.c
b/tests/test-hindex.c
index
b5fe9f0
..
eb63d9d
100644
(file)
--- a/
tests/test-hindex.c
+++ b/
tests/test-hindex.c
@@
-21,6
+21,7
@@
#include "hindex.h"
#include <string.h>
#include "hash.h"
#include "hindex.h"
#include <string.h>
#include "hash.h"
+#include "random.h"
#include "util.h"
#undef NDEBUG
#include "util.h"
#undef NDEBUG
@@
-108,7
+109,7
@@
static void
shuffle(int *p, size_t n)
{
for (; n > 1; n--, p++) {
shuffle(int *p, size_t n)
{
for (; n > 1; n--, p++) {
- int *q = &p[rand
() % n
];
+ int *q = &p[rand
om_range(n)
];
int tmp = *p;
*p = *q;
*q = tmp;
int tmp = *p;
*p = *q;
*q = tmp;
@@
-136,7
+137,7
@@
print_hindex(const char *name, struct hindex *hindex)
printf("%s:", name);
HINDEX_FOR_EACH (e, node, hindex) {
printf("%s:", name);
HINDEX_FOR_EACH (e, node, hindex) {
- printf(" %d(%
zu
)", e->value, e->node.hash & hindex->mask);
+ printf(" %d(%
"PRIuSIZE"
)", e->value, e->node.hash & hindex->mask);
}
printf("\n");
}
}
printf("\n");
}
@@
-177,6
+178,12
@@
mod2_hash(int value)
return value % 2;
}
return value % 2;
}
+static size_t
+multipart_hash(int value)
+{
+ return (mod4_hash(value) << 16) | (constant_hash(value) & 0xFFFF);
+}
+
/* Tests basic hindex insertion and deletion. */
static void
test_hindex_insert_delete(hash_func *hash)
/* Tests basic hindex insertion and deletion. */
static void
test_hindex_insert_delete(hash_func *hash)
@@
-297,6
+304,7
@@
run_test(void (*function)(hash_func *))
mod4_hash,
mod3_hash,
mod2_hash,
mod4_hash,
mod3_hash,
mod2_hash,
+ multipart_hash,
};
size_t i;
};
size_t i;