/*
- * 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.
* hmap.h. */
#include <config.h>
+#undef NDEBUG
#include "hmap.h"
+#include <assert.h>
#include <string.h>
#include "hash.h"
+#include "ovstest.h"
+#include "random.h"
#include "util.h"
-#undef NDEBUG
-#include <assert.h>
-
/* Sample hmap element. */
struct element {
int value;
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;
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");
}
}
}
-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);