From 3223e977cae4125b24ebb9498e0b67b4d8fac4c3 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 26 May 2010 12:48:32 -0700 Subject: [PATCH] tests: Break monolithic classifier test into subtests. This makes it easier to see which tests are taking up a lot of time, and to see which ones actually fail if any of them do. --- tests/automake.mk | 1 + tests/classifier.at | 16 +++++++++++ tests/library.at | 5 ---- tests/test-classifier.c | 63 ++++++++++++++++++++--------------------- tests/testsuite.at | 1 + 5 files changed, 48 insertions(+), 38 deletions(-) create mode 100644 tests/classifier.at diff --git a/tests/automake.mk b/tests/automake.mk index ebf2a018..51205d9b 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -8,6 +8,7 @@ TESTSUITE_AT = \ tests/testsuite.at \ tests/ovsdb-macros.at \ tests/library.at \ + tests/classifier.at \ tests/check-structs.at \ tests/daemon.at \ tests/vconn.at \ diff --git a/tests/classifier.at b/tests/classifier.at new file mode 100644 index 00000000..f9e6953d --- /dev/null +++ b/tests/classifier.at @@ -0,0 +1,16 @@ +AT_BANNER([flow classifier unit tests]) +m4_foreach( + [testname], + [[empty], + [destroy-null], + [single-rule], + [rule-replacement], + [two-rules-in-one-bucket], + [two-rules-in-one-table], + [two-rules-in-different-tables], + [many-rules-in-one-bucket], + [many-rules-in-one-table], + [many-rules-in-different-tables]], + [AT_SETUP([flow classifier - m4_bpatsubst(testname, [-], [ ])]) + AT_CHECK([test-classifier testname], [0], [], []) + AT_CLEANUP])]) diff --git a/tests/library.at b/tests/library.at index 0e408f04..f9f97f14 100644 --- a/tests/library.at +++ b/tests/library.at @@ -10,11 +10,6 @@ AT_SETUP([test TCP/IP checksumming]) AT_CHECK([test-csum], [0], [ignore]) AT_CLEANUP -AT_SETUP([test flow classifier]) -AT_KEYWORDS([slow]) -AT_CHECK([test-classifier], [0], [ignore]) -AT_CLEANUP - AT_SETUP([test hash functions]) AT_CHECK([test-hash], [0], [ignore]) AT_CLEANUP diff --git a/tests/test-classifier.c b/tests/test-classifier.c index c831559b..a63b7cab 100644 --- a/tests/test-classifier.c +++ b/tests/test-classifier.c @@ -26,12 +26,11 @@ */ #include -#include #include "classifier.h" #include #include +#include "command-line.h" #include "flow.h" -#include #include "packets.h" #undef NDEBUG @@ -487,7 +486,7 @@ shuffle(unsigned int *p, size_t n) /* Tests an empty classifier. */ static void -test_empty(void) +test_empty(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) { struct classifier cls; struct tcls tcls; @@ -503,14 +502,14 @@ test_empty(void) /* Destroys a null classifier. */ static void -test_destroy_null(void) +test_destroy_null(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) { classifier_destroy(NULL); } /* Tests classification with one rule at a time. */ static void -test_single_rule(void) +test_single_rule(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) { unsigned int wc_fields; /* Hilarious. */ @@ -548,7 +547,7 @@ test_single_rule(void) /* Tests replacing one rule by another. */ static void -test_rule_replacement(void) +test_rule_replacement(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) { unsigned int wc_fields; @@ -599,7 +598,7 @@ random_wcf_in_table(int table, int seed) /* Tests classification with two rules at a time that fall into the same * bucket. */ static void -test_two_rules_in_one_bucket(void) +test_two_rules_in_one_bucket(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) { int table, rel_pri, wcf_pat, value_pat; @@ -688,7 +687,7 @@ test_two_rules_in_one_bucket(void) /* Tests classification with two rules at a time that fall into the same * table but different buckets. */ static void -test_two_rules_in_one_table(void) +test_two_rules_in_one_table(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) { int table, rel_pri, wcf_pat; @@ -764,7 +763,8 @@ test_two_rules_in_one_table(void) /* Tests classification with two rules at a time that fall into different * tables. */ static void -test_two_rules_in_different_tables(void) +test_two_rules_in_different_tables(int argc OVS_UNUSED, + char *argv[] OVS_UNUSED) { int table1, table2, rel_pri, wcf_pat; @@ -833,7 +833,7 @@ test_two_rules_in_different_tables(void) /* Tests classification with many rules at a time that fall into the same * bucket but have unique priorities (and various wildcards). */ static void -test_many_rules_in_one_bucket(void) +test_many_rules_in_one_bucket(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) { enum { MAX_RULES = 50 }; int iteration, table; @@ -877,7 +877,7 @@ test_many_rules_in_one_bucket(void) /* Tests classification with many rules at a time that fall into the same * table but random buckets. */ static void -test_many_rules_in_one_table(void) +test_many_rules_in_one_table(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) { enum { MAX_RULES = 50 }; int iteration, table; @@ -920,7 +920,8 @@ test_many_rules_in_one_table(void) /* Tests classification with many rules at a time that fall into random buckets * in random tables. */ static void -test_many_rules_in_different_tables(void) +test_many_rules_in_different_tables(int argc OVS_UNUSED, + char *argv[] OVS_UNUSED) { enum { MAX_RULES = 50 }; int iteration; @@ -965,36 +966,32 @@ test_many_rules_in_different_tables(void) compare_classifiers(&cls, &tcls); free(rule); } - putchar('.'); - fflush(stdout); destroy_classifier(&cls); tcls_destroy(&tcls); } } -static void -run_test(void (*function)(void)) -{ - function(); - putchar('.'); - fflush(stdout); -} +static const struct command commands[] = { + {"empty", 0, 0, test_empty}, + {"destroy-null", 0, 0, test_destroy_null}, + {"single-rule", 0, 0, test_single_rule}, + {"rule-replacement", 0, 0, test_rule_replacement}, + {"two-rules-in-one-bucket", 0, 0, test_two_rules_in_one_bucket}, + {"two-rules-in-one-table", 0, 0, test_two_rules_in_one_table}, + {"two-rules-in-different-tables", 0, 0, + test_two_rules_in_different_tables}, + {"many-rules-in-one-bucket", 0, 0, test_many_rules_in_one_bucket}, + {"many-rules-in-one-table", 0, 0, test_many_rules_in_one_table}, + {"many-rules-in-different-tables", 0, 0, + test_many_rules_in_different_tables}, + {NULL, 0, 0, NULL}, +}; int -main(void) +main(int argc, char *argv[]) { init_values(); - run_test(test_empty); - run_test(test_destroy_null); - run_test(test_single_rule); - run_test(test_rule_replacement); - run_test(test_two_rules_in_one_bucket); - run_test(test_two_rules_in_one_table); - run_test(test_two_rules_in_different_tables); - run_test(test_many_rules_in_one_bucket); - run_test(test_many_rules_in_one_table); - run_test(test_many_rules_in_different_tables); - putchar('\n'); + run_command(argc - 1, argv + 1, commands); return 0; } diff --git a/tests/testsuite.at b/tests/testsuite.at index f4e80caf..5699e3c9 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -38,6 +38,7 @@ m4_define([OVS_WAIT_WHILE], [OVS_WAIT([if $1; then :; else exit 0; fi], [$2])]) m4_include([tests/ovsdb-macros.at]) m4_include([tests/library.at]) +m4_include([tests/classifier.at]) m4_include([tests/check-structs.at]) m4_include([tests/daemon.at]) m4_include([tests/vconn.at]) -- 2.30.2