X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=tests%2Ftest-hmap.c;h=0c103e9c913a98e397e2592e0a2d4e54ef826dfe;hb=003ce655b7116d18c86a74c50391e54990346931;hp=be6bcf4a784c9ee105adef847f08dde83922c8a3;hpb=4e8e4213a815a30216e855a805a8bcd5b8c5a886;p=sliver-openvswitch.git diff --git a/tests/test-hmap.c b/tests/test-hmap.c index be6bcf4a7..0c103e9c9 100644 --- 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. @@ -21,7 +21,9 @@ #include "hmap.h" #include #include "hash.h" +#include "random.h" #include "util.h" +#include "ovstest.h" #undef NDEBUG #include @@ -108,7 +110,7 @@ static void shuffle(int *p, size_t n) { for (; n > 1; n--, p++) { - int *q = &p[rand() % n]; + int *q = &p[random_range(n)]; int tmp = *p; *p = *q; *q = tmp; @@ -124,7 +126,7 @@ print_hmap(const char *name, struct hmap *hmap) printf("%s:", name); HMAP_FOR_EACH (e, node, hmap) { - printf(" %d(%zu)", e->value, e->node.hash & hmap->mask); + printf(" %d(%"PRIuSIZE")", e->value, e->node.hash & hmap->mask); } printf("\n"); } @@ -284,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"); - return 0; } +OVSTEST_REGISTER("test-hmap", test_hmap_main);