test/service: use compiler atomics for lock sync
[dpdk.git] / app / test / test.h
index 7c24432..c3b2a87 100644 (file)
@@ -22,8 +22,6 @@
 # define TEST_TRACE_FAILURE(_file, _line, _func)
 #endif
 
-#define RTE_TEST_TRACE_FAILURE TEST_TRACE_FAILURE
-
 #include <rte_test.h>
 
 #define TEST_ASSERT RTE_TEST_ASSERT
@@ -110,24 +108,28 @@ struct unit_test_case {
        int (*setup)(void);
        void (*teardown)(void);
        int (*testcase)(void);
+       int (*testcase_with_data)(const void *data);
        const char *name;
        unsigned enabled;
+       const void *data;
 };
 
-#define TEST_CASE(fn) { NULL, NULL, fn, #fn, 1 }
+#define TEST_CASE(fn) { NULL, NULL, fn, NULL, #fn, 1, NULL }
 
-#define TEST_CASE_NAMED(name, fn) { NULL, NULL, fn, name, 1 }
+#define TEST_CASE_NAMED(name, fn) { NULL, NULL, fn, NULL, name, 1, NULL }
 
 #define TEST_CASE_ST(setup, teardown, testcase) \
-               { setup, teardown, testcase, #testcase, 1 }
+               { setup, teardown, testcase, NULL, #testcase, 1, NULL }
 
+#define TEST_CASE_WITH_DATA(setup, teardown, testcase, data) \
+               { setup, teardown, NULL, testcase, #testcase, 1, data }
 
-#define TEST_CASE_DISABLED(fn) { NULL, NULL, fn, #fn, 0 }
+#define TEST_CASE_DISABLED(fn) { NULL, NULL, fn, NULL, #fn, 0, NULL }
 
 #define TEST_CASE_ST_DISABLED(setup, teardown, testcase) \
-               { setup, teardown, testcase, #testcase, 0 }
+               { setup, teardown, testcase, NULL, #testcase, 0, NULL }
 
-#define TEST_CASES_END() { NULL, NULL, NULL, NULL, 0 }
+#define TEST_CASES_END() { NULL, NULL, NULL, NULL, NULL, 0, NULL }
 
 static inline void
 debug_hexdump(FILE *file, const char *title, const void *buf, size_t len)
@@ -140,6 +142,13 @@ struct unit_test_suite {
        const char *suite_name;
        int (*setup)(void);
        void (*teardown)(void);
+       unsigned int total;
+       unsigned int executed;
+       unsigned int succeeded;
+       unsigned int skipped;
+       unsigned int failed;
+       unsigned int unsupported;
+       struct unit_test_suite **unit_test_suites;
        struct unit_test_case unit_test_cases[];
 };
 
@@ -154,8 +163,10 @@ extern int last_test_result;
 extern const char *prgname;
 
 int commands_init(void);
+int command_valid(const char *cmd);
 
 int test_mp_secondary(void);
+int test_timer_secondary(void);
 
 int test_set_rxtx_conf(cmdline_fixed_string_t mode);
 int test_set_rxtx_anchor(cmdline_fixed_string_t type);
@@ -177,8 +188,7 @@ void add_test_command(struct test_command *t);
                .command = RTE_STR(cmd), \
                .callback = func, \
        }; \
-       static void __attribute__((constructor, used)) \
-       test_register_##cmd(void) \
+       RTE_INIT(test_register_##cmd) \
        { \
                add_test_command(&test_struct_##cmd); \
        }