+
+/* The default test enum which should be common to all tests */
+#define OPT_TEST_ENUM \
+ OPT_TEST_HELP = 500, \
+ OPT_TEST_LIST, \
+ OPT_TEST_SINGLE, \
+ OPT_TEST_ITERATION, \
+ OPT_TEST_INDENT, \
+ OPT_TEST_SEED
+
+/* The Default test OPTIONS common to all tests (without a usage string) */
+#define OPT_TEST_OPTIONS \
+ { OPT_HELP_STR, 1, '-', "Valid options are:\n" }, \
+ { "help", OPT_TEST_HELP, '-', "Display this summary" }, \
+ { "list", OPT_TEST_LIST, '-', "Display the list of tests available" }, \
+ { "test", OPT_TEST_SINGLE, 's', "Run a single test by id or name" }, \
+ { "iter", OPT_TEST_ITERATION, 'n', "Run a single iteration of a test" }, \
+ { "indent", OPT_TEST_INDENT,'p', "Number of tabs added to output" }, \
+ { "seed", OPT_TEST_SEED, 'n', "Seed value to randomize tests with" }
+
+/* The Default test OPTIONS common to all tests starting with an additional usage string */
+#define OPT_TEST_OPTIONS_WITH_EXTRA_USAGE(usage) \
+ { OPT_HELP_STR, 1, '-', "Usage: %s [options] " usage }, \
+ OPT_TEST_OPTIONS
+
+/* The Default test OPTIONS common to all tests with an default usage string */
+#define OPT_TEST_OPTIONS_DEFAULT_USAGE \
+ { OPT_HELP_STR, 1, '-', "Usage: %s [options]\n" }, \
+ OPT_TEST_OPTIONS
+
+/*
+ * Optional Cases that need to be ignored by the test app when using opt_next(),
+ * (that are handled internally).
+ */
+#define OPT_TEST_CASES \
+ OPT_TEST_HELP: \
+ case OPT_TEST_LIST: \
+ case OPT_TEST_SINGLE: \
+ case OPT_TEST_ITERATION: \
+ case OPT_TEST_INDENT: \
+ case OPT_TEST_SEED
+
+/*
+ * Tests that use test_get_argument() that dont have any additional options
+ * (i.e- dont use opt_next()) can use this to set the usage string.
+ * It embeds test_get_options() which gives default command line options for
+ * the test system.
+ *
+ * Tests that need to use opt_next() need to specify
+ * (1) test_get_options() containing an options[] (Which should include either
+ * OPT_TEST_OPTIONS_DEFAULT_USAGE OR
+ * OPT_TEST_OPTIONS_WITH_EXTRA_USAGE).
+ * (2) An enum outside the test_get_options() which contains OPT_TEST_ENUM, as
+ * well as the additional options that need to be handled.
+ * (3) case OPT_TEST_CASES: break; inside the opt_next() handling code.
+ */
+#define OPT_TEST_DECLARE_USAGE(usage_str) \
+const OPTIONS *test_get_options(void) \
+{ \
+ enum { OPT_TEST_ENUM }; \
+ static const OPTIONS options[] = { \
+ OPT_TEST_OPTIONS_WITH_EXTRA_USAGE(usage_str), \
+ { NULL } \
+ }; \
+ return options; \
+}
+