*/
#include <config.h>
-#include <limits.h>
#include "classifier.h"
#include <errno.h>
#include <limits.h>
+#include "command-line.h"
#include "flow.h"
-#include <limits.h>
#include "packets.h"
#undef NDEBUG
\f
/* 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;
/* 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. */
/* 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;
/* 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;
/* 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;
/* 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;
/* 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;
/* 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;
/* 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;
compare_classifiers(&cls, &tcls);
free(rule);
}
- putchar('.');
- fflush(stdout);
destroy_classifier(&cls);
tcls_destroy(&tcls);
}
}
\f
-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;
}