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
Prepare for post-2.2.0 (2.2.90).
[sliver-openvswitch.git]
/
tests
/
test-hmap.c
diff --git
a/tests/test-hmap.c
b/tests/test-hmap.c
index
18d8f46
..
0c103e9
100644
(file)
--- a/
tests/test-hmap.c
+++ b/
tests/test-hmap.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (c) 2008, 2009, 2010
Nicira Networks
.
+ * Copyright (c) 2008, 2009, 2010
, 2013, 2014 Nicira, Inc
.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-21,7
+21,9
@@
#include "hmap.h"
#include <string.h>
#include "hash.h"
#include "hmap.h"
#include <string.h>
#include "hash.h"
+#include "random.h"
#include "util.h"
#include "util.h"
+#include "ovstest.h"
#undef NDEBUG
#include <assert.h>
#undef NDEBUG
#include <assert.h>
@@
-56,7
+58,7
@@
check_hmap(struct hmap *hmap, const int values[], size_t n,
hmap_values = xmalloc(sizeof *sort_values * n);
i = 0;
hmap_values = xmalloc(sizeof *sort_values * n);
i = 0;
- HMAP_FOR_EACH (e,
struct element,
node, hmap) {
+ HMAP_FOR_EACH (e, node, hmap) {
assert(i < n);
hmap_values[i++] = e->value;
}
assert(i < n);
hmap_values[i++] = e->value;
}
@@
-77,8
+79,7
@@
check_hmap(struct hmap *hmap, const int values[], size_t n,
for (i = 0; i < n; i++) {
size_t count = 0;
for (i = 0; i < n; i++) {
size_t count = 0;
- HMAP_FOR_EACH_WITH_HASH (e, struct element, node,
- hash(values[i]), hmap) {
+ HMAP_FOR_EACH_WITH_HASH (e, node, hash(values[i]), hmap) {
count += e->value == values[i];
}
assert(count == 1);
count += e->value == values[i];
}
assert(count == 1);
@@
-109,7
+110,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;
@@
-124,8
+125,8
@@
print_hmap(const char *name, struct hmap *hmap)
struct element *e;
printf("%s:", name);
struct element *e;
printf("%s:", name);
- HMAP_FOR_EACH (e,
struct element,
node, hmap) {
- printf(" %d(%
zu
)", e->value, e->node.hash & hmap->mask);
+ HMAP_FOR_EACH (e, node, hmap) {
+ printf(" %d(%
"PRIuSIZE"
)", e->value, e->node.hash & hmap->mask);
}
printf("\n");
}
}
printf("\n");
}
@@
-242,7
+243,7
@@
test_hmap_for_each_safe(hash_func *hash)
i = 0;
n_remaining = n;
i = 0;
n_remaining = n;
- HMAP_FOR_EACH_SAFE (e, next,
struct element,
node, &hmap) {
+ HMAP_FOR_EACH_SAFE (e, next, node, &hmap) {
assert(i < n);
if (pattern & (1ul << e->value)) {
size_t j;
assert(i < n);
if (pattern & (1ul << e->value)) {
size_t j;
@@
-285,13
+286,13
@@
run_test(void (*function)(hash_func *))
}
}
}
}
-int
-
main(void
)
+static void
+
test_hmap_main(int argc OVS_UNUSED, char *argv[] OVS_UNUSED
)
{
run_test(test_hmap_insert_delete);
run_test(test_hmap_for_each_safe);
run_test(test_hmap_reserve_shrink);
printf("\n");
{
run_test(test_hmap_insert_delete);
run_test(test_hmap_for_each_safe);
run_test(test_hmap_reserve_shrink);
printf("\n");
- return 0;
}
}
+OVSTEST_REGISTER("test-hmap", test_hmap_main);