X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=tests%2Ftest-bitmap.c;h=3dbc8df6f9853b925f047bc4e450a1779971dae5;hb=d5da6c53ca75df14d698c5355afb492057e2b814;hp=3644419d188a14f468e74171dd66cce7872200ba;hpb=c44a2a6df4ebde5ec9752d08ff82fec7f0c5c90c;p=cascardo%2Fovs.git diff --git a/tests/test-bitmap.c b/tests/test-bitmap.c index 3644419d1..3dbc8df6f 100644 --- a/tests/test-bitmap.c +++ b/tests/test-bitmap.c @@ -15,13 +15,12 @@ */ #include +#undef NDEBUG #include "bitmap.h" +#include +#include "command-line.h" #include "ovstest.h" #include "timeval.h" -#include "command-line.h" - -#undef NDEBUG -#include enum { MAX_BITS = 20 * BITMAP_ULONG_BITS }; @@ -82,12 +81,12 @@ test_bitmap_scan(void) bitmap_set1(a, MAX_BITS - 1); assert(bitmap_scan(a, true, 0, MAX_BITS) == MAX_BITS - 1); bitmap_set1(a, MAX_BITS - BITMAP_ULONG_BITS + 1); - assert(bitmap_scan(a, true, 0, MAX_BITS - 1) + assert(bitmap_scan(a, true, 3, MAX_BITS) == MAX_BITS - BITMAP_ULONG_BITS + 1); bitmap_set1(a, BITMAP_ULONG_BITS - 1); - assert(bitmap_scan(a, true, 0, MAX_BITS - 1) == BITMAP_ULONG_BITS - 1); + assert(bitmap_scan(a, true, 7, MAX_BITS - 1) == BITMAP_ULONG_BITS - 1); bitmap_set1(a, 0); - assert(bitmap_scan(a, true, 0, MAX_BITS - 1) == 0); + assert(bitmap_scan(a, true, 0, MAX_BITS - 7) == 0); bitmap_set_multiple(a, 0, MAX_BITS, true); @@ -104,12 +103,12 @@ test_bitmap_scan(void) bitmap_set0(a, MAX_BITS - 1); assert(bitmap_scan(a, false, 0, MAX_BITS) == MAX_BITS - 1); bitmap_set0(a, MAX_BITS - BITMAP_ULONG_BITS + 1); - assert(bitmap_scan(a, false, 0, MAX_BITS - 1) + assert(bitmap_scan(a, false, 3, MAX_BITS) == MAX_BITS - BITMAP_ULONG_BITS + 1); bitmap_set0(a, BITMAP_ULONG_BITS - 1); - assert(bitmap_scan(a, false, 0, MAX_BITS - 1) == BITMAP_ULONG_BITS - 1); + assert(bitmap_scan(a, false, 7, MAX_BITS - 1) == BITMAP_ULONG_BITS - 1); bitmap_set0(a, 0); - assert(bitmap_scan(a, false, 0, MAX_BITS - 1) == 0); + assert(bitmap_scan(a, false, 0, MAX_BITS - 7) == 0); free(a); } @@ -122,7 +121,7 @@ run_test(void (*function)(void)) } static void -run_tests(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) +run_tests(struct ovs_cmdl_context *ctx OVS_UNUSED) { run_test(test_bitmap_equal); run_test(test_bitmap_scan); @@ -130,9 +129,9 @@ run_tests(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) } static void -run_benchmarks(int argc OVS_UNUSED, char *argv[]) +run_benchmarks(struct ovs_cmdl_context *ctx) { - int n_iter = strtol(argv[1], NULL, 10); + int n_iter = strtol(ctx->argv[1], NULL, 10); struct timeval start; xgettimeofday(&start); @@ -149,17 +148,22 @@ run_benchmarks(int argc OVS_UNUSED, char *argv[]) printf("\n"); } -static const struct command commands[] = { - {"check", 0, 0, run_tests}, - {"benchmark", 1, 1, run_benchmarks}, - {NULL, 0, 0, NULL}, +static const struct ovs_cmdl_command commands[] = { + {"check", NULL, 0, 0, run_tests}, + {"benchmark", NULL, 1, 1, run_benchmarks}, + {NULL, NULL, 0, 0, NULL}, }; static void test_bitmap_main(int argc, char *argv[]) { + struct ovs_cmdl_context ctx = { + .argc = argc - 1, + .argv = argv + 1, + }; + set_program_name(argv[0]); - run_command(argc - 1, argv + 1, commands); + ovs_cmdl_run_command(&ctx, commands); } OVSTEST_REGISTER("test-bitmap", test_bitmap_main);