tests.h (f832044c8e8a92ab418bf11d10b18e7ffe024190) | tests.h (78244d2e21146b88faffe2653397f0fa176794f1) |
---|---|
1/* SPDX-License-Identifier: GPL-2.0 */ 2#ifndef TESTS_H 3#define TESTS_H 4 5#include <stdbool.h> 6 7#define TEST_ASSERT_VAL(text, cond) \ 8do { \ --- 17 unchanged lines hidden (view full) --- 26 TEST_FAIL = -1, 27 TEST_SKIP = -2, 28}; 29 30struct test_suite; 31 32typedef int (*test_fnptr)(struct test_suite *, int); 33 | 1/* SPDX-License-Identifier: GPL-2.0 */ 2#ifndef TESTS_H 3#define TESTS_H 4 5#include <stdbool.h> 6 7#define TEST_ASSERT_VAL(text, cond) \ 8do { \ --- 17 unchanged lines hidden (view full) --- 26 TEST_FAIL = -1, 27 TEST_SKIP = -2, 28}; 29 30struct test_suite; 31 32typedef int (*test_fnptr)(struct test_suite *, int); 33 |
34struct test_case { 35 const char *name; 36 const char *desc; 37 test_fnptr run_case; 38}; 39 |
|
34struct test_suite { 35 const char *desc; 36 test_fnptr func; 37 struct { 38 bool skip_if_fail; 39 int (*get_nr)(void); 40 const char *(*get_desc)(int subtest); 41 const char *(*skip_reason)(int subtest); 42 } subtest; | 40struct test_suite { 41 const char *desc; 42 test_fnptr func; 43 struct { 44 bool skip_if_fail; 45 int (*get_nr)(void); 46 const char *(*get_desc)(int subtest); 47 const char *(*skip_reason)(int subtest); 48 } subtest; |
49 struct test_case *test_cases; |
|
43 bool (*is_supported)(void); 44 void *priv; 45}; 46 47#define DECLARE_SUITE(name) \ 48 extern struct test_suite suite__##name; 49 | 50 bool (*is_supported)(void); 51 void *priv; 52}; 53 54#define DECLARE_SUITE(name) \ 55 extern struct test_suite suite__##name; 56 |
50#define DEFINE_SUITE(description, name) \ 51 struct test_suite suite__##name = { \ 52 .desc = description, \ 53 .func = test__##name, \ | 57#define TEST_CASE(description, _name) \ 58 { \ 59 .name = #_name, \ 60 .desc = description, \ 61 .run_case = test__##_name, \ |
54 } 55 | 62 } 63 |
64#define DEFINE_SUITE(description, _name) \ 65 struct test_case tests__##_name[] = { \ 66 TEST_CASE(description, _name), \ 67 { .name = NULL, } \ 68 }; \ 69 struct test_suite suite__##_name = { \ 70 .desc = description, \ 71 .test_cases = tests__##_name, \ 72 } 73 |
|
56/* Tests */ 57DECLARE_SUITE(vmlinux_matches_kallsyms); 58DECLARE_SUITE(openat_syscall_event); 59DECLARE_SUITE(openat_syscall_event_on_all_cpus); 60DECLARE_SUITE(basic_mmap); 61DECLARE_SUITE(PERF_RECORD); 62DECLARE_SUITE(perf_evsel__roundtrip_name_test); 63DECLARE_SUITE(perf_evsel__tp_sched_test); --- 81 unchanged lines hidden --- | 74/* Tests */ 75DECLARE_SUITE(vmlinux_matches_kallsyms); 76DECLARE_SUITE(openat_syscall_event); 77DECLARE_SUITE(openat_syscall_event_on_all_cpus); 78DECLARE_SUITE(basic_mmap); 79DECLARE_SUITE(PERF_RECORD); 80DECLARE_SUITE(perf_evsel__roundtrip_name_test); 81DECLARE_SUITE(perf_evsel__tp_sched_test); --- 81 unchanged lines hidden --- |