Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Jiri Olsa | 0a4e1ae | 2012-11-10 01:46:41 +0100 | [diff] [blame] | 2 | #ifndef TESTS_H |
| 3 | #define TESTS_H |
| 4 | |
Wang Nan | e8c6d50 | 2015-11-17 08:32:48 +0000 | [diff] [blame] | 5 | #include <stdbool.h> |
| 6 | |
Jiri Olsa | 450ac18 | 2013-06-07 15:37:03 +0200 | [diff] [blame] | 7 | #define TEST_ASSERT_VAL(text, cond) \ |
| 8 | do { \ |
| 9 | if (!(cond)) { \ |
| 10 | pr_debug("FAILED %s:%d %s\n", __FILE__, __LINE__, text); \ |
| 11 | return -1; \ |
| 12 | } \ |
| 13 | } while (0) |
| 14 | |
Arnaldo Carvalho de Melo | 8f19601 | 2015-05-11 16:30:20 -0300 | [diff] [blame] | 15 | #define TEST_ASSERT_EQUAL(text, val, expected) \ |
| 16 | do { \ |
| 17 | if (val != expected) { \ |
| 18 | pr_debug("FAILED %s:%d %s (%d != %d)\n", \ |
| 19 | __FILE__, __LINE__, text, val, expected); \ |
| 20 | return -1; \ |
| 21 | } \ |
| 22 | } while (0) |
| 23 | |
Jiri Olsa | f4c1ea5 | 2012-12-19 11:33:39 -0300 | [diff] [blame] | 24 | enum { |
| 25 | TEST_OK = 0, |
| 26 | TEST_FAIL = -1, |
| 27 | TEST_SKIP = -2, |
| 28 | }; |
| 29 | |
Matt Fleming | 31b6753 | 2015-10-05 15:40:19 +0100 | [diff] [blame] | 30 | struct test { |
| 31 | const char *desc; |
Arnaldo Carvalho de Melo | 81f17c9 | 2017-08-03 15:16:31 -0300 | [diff] [blame] | 32 | int (*func)(struct test *test, int subtest); |
Wang Nan | e8c6d50 | 2015-11-17 08:32:48 +0000 | [diff] [blame] | 33 | struct { |
| 34 | bool skip_if_fail; |
| 35 | int (*get_nr)(void); |
| 36 | const char *(*get_desc)(int subtest); |
| 37 | } subtest; |
Jiri Olsa | 598762c | 2017-06-01 22:54:50 +0200 | [diff] [blame] | 38 | bool (*is_supported)(void); |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 39 | void *priv; |
Matt Fleming | 31b6753 | 2015-10-05 15:40:19 +0100 | [diff] [blame] | 40 | }; |
| 41 | |
Jiri Olsa | d3b59a3 | 2012-11-10 01:46:42 +0100 | [diff] [blame] | 42 | /* Tests */ |
Arnaldo Carvalho de Melo | 81f17c9 | 2017-08-03 15:16:31 -0300 | [diff] [blame] | 43 | int test__vmlinux_matches_kallsyms(struct test *test, int subtest); |
| 44 | int test__openat_syscall_event(struct test *test, int subtest); |
| 45 | int test__openat_syscall_event_on_all_cpus(struct test *test, int subtest); |
| 46 | int test__basic_mmap(struct test *test, int subtest); |
| 47 | int test__PERF_RECORD(struct test *test, int subtest); |
| 48 | int test__perf_evsel__roundtrip_name_test(struct test *test, int subtest); |
| 49 | int test__perf_evsel__tp_sched_test(struct test *test, int subtest); |
| 50 | int test__syscall_openat_tp_fields(struct test *test, int subtest); |
| 51 | int test__pmu(struct test *test, int subtest); |
| 52 | int test__attr(struct test *test, int subtest); |
| 53 | int test__dso_data(struct test *test, int subtest); |
| 54 | int test__dso_data_cache(struct test *test, int subtest); |
| 55 | int test__dso_data_reopen(struct test *test, int subtest); |
| 56 | int test__parse_events(struct test *test, int subtest); |
| 57 | int test__hists_link(struct test *test, int subtest); |
| 58 | int test__python_use(struct test *test, int subtest); |
| 59 | int test__bp_signal(struct test *test, int subtest); |
| 60 | int test__bp_signal_overflow(struct test *test, int subtest); |
Jiri Olsa | 032db28 | 2018-03-12 14:45:48 +0100 | [diff] [blame^] | 61 | int test__bp_accounting(struct test *test, int subtest); |
Arnaldo Carvalho de Melo | 81f17c9 | 2017-08-03 15:16:31 -0300 | [diff] [blame] | 62 | int test__task_exit(struct test *test, int subtest); |
Andi Kleen | 3067eaa | 2017-08-16 15:21:56 -0700 | [diff] [blame] | 63 | int test__mem(struct test *test, int subtest); |
Arnaldo Carvalho de Melo | 81f17c9 | 2017-08-03 15:16:31 -0300 | [diff] [blame] | 64 | int test__sw_clock_freq(struct test *test, int subtest); |
| 65 | int test__code_reading(struct test *test, int subtest); |
| 66 | int test__sample_parsing(struct test *test, int subtest); |
| 67 | int test__keep_tracking(struct test *test, int subtest); |
| 68 | int test__parse_no_sample_id_all(struct test *test, int subtest); |
| 69 | int test__dwarf_unwind(struct test *test, int subtest); |
| 70 | int test__expr(struct test *test, int subtest); |
| 71 | int test__hists_filter(struct test *test, int subtest); |
| 72 | int test__mmap_thread_lookup(struct test *test, int subtest); |
| 73 | int test__thread_mg_share(struct test *test, int subtest); |
| 74 | int test__hists_output(struct test *test, int subtest); |
| 75 | int test__hists_cumulate(struct test *test, int subtest); |
| 76 | int test__switch_tracking(struct test *test, int subtest); |
| 77 | int test__fdarray__filter(struct test *test, int subtest); |
| 78 | int test__fdarray__add(struct test *test, int subtest); |
| 79 | int test__kmod_path__parse(struct test *test, int subtest); |
| 80 | int test__thread_map(struct test *test, int subtest); |
| 81 | int test__llvm(struct test *test, int subtest); |
Wang Nan | e8c6d50 | 2015-11-17 08:32:48 +0000 | [diff] [blame] | 82 | const char *test__llvm_subtest_get_desc(int subtest); |
| 83 | int test__llvm_subtest_get_nr(void); |
Arnaldo Carvalho de Melo | 81f17c9 | 2017-08-03 15:16:31 -0300 | [diff] [blame] | 84 | int test__bpf(struct test *test, int subtest); |
Wang Nan | 77a0cf6 | 2015-11-17 08:32:49 +0000 | [diff] [blame] | 85 | const char *test__bpf_subtest_get_desc(int subtest); |
| 86 | int test__bpf_subtest_get_nr(void); |
Arnaldo Carvalho de Melo | 81f17c9 | 2017-08-03 15:16:31 -0300 | [diff] [blame] | 87 | int test__session_topology(struct test *test, int subtest); |
| 88 | int test__thread_map_synthesize(struct test *test, int subtest); |
| 89 | int test__thread_map_remove(struct test *test, int subtest); |
| 90 | int test__cpu_map_synthesize(struct test *test, int subtest); |
| 91 | int test__synthesize_stat_config(struct test *test, int subtest); |
| 92 | int test__synthesize_stat(struct test *test, int subtest); |
| 93 | int test__synthesize_stat_round(struct test *test, int subtest); |
| 94 | int test__event_update(struct test *test, int subtest); |
| 95 | int test__event_times(struct test *test, int subtest); |
| 96 | int test__backward_ring_buffer(struct test *test, int subtest); |
| 97 | int test__cpu_map_print(struct test *test, int subtest); |
| 98 | int test__sdt_event(struct test *test, int subtest); |
| 99 | int test__is_printable_array(struct test *test, int subtest); |
| 100 | int test__bitmap_print(struct test *test, int subtest); |
| 101 | int test__perf_hooks(struct test *test, int subtest); |
| 102 | int test__clang(struct test *test, int subtest); |
Wang Nan | 00b8669 | 2016-11-26 07:03:34 +0000 | [diff] [blame] | 103 | const char *test__clang_subtest_get_desc(int subtest); |
| 104 | int test__clang_subtest_get_nr(void); |
Arnaldo Carvalho de Melo | 81f17c9 | 2017-08-03 15:16:31 -0300 | [diff] [blame] | 105 | int test__unit_number__scnprint(struct test *test, int subtest); |
Jiri Olsa | d3b59a3 | 2012-11-10 01:46:42 +0100 | [diff] [blame] | 106 | |
Jiri Olsa | 598762c | 2017-06-01 22:54:50 +0200 | [diff] [blame] | 107 | bool test__bp_signal_is_supported(void); |
| 108 | |
Matt Fleming | d8b167f | 2015-10-05 15:40:20 +0100 | [diff] [blame] | 109 | #if defined(__arm__) || defined(__aarch64__) |
Jiri Olsa | 9ff125d | 2014-01-07 13:47:28 +0100 | [diff] [blame] | 110 | #ifdef HAVE_DWARF_UNWIND_SUPPORT |
Jiri Olsa | aa16b81 | 2014-01-07 13:47:22 +0100 | [diff] [blame] | 111 | struct thread; |
| 112 | struct perf_sample; |
| 113 | int test__arch_unwind_sample(struct perf_sample *sample, |
| 114 | struct thread *thread); |
| 115 | #endif |
| 116 | #endif |
Jiri Olsa | 0a4e1ae | 2012-11-10 01:46:41 +0100 | [diff] [blame] | 117 | #endif /* TESTS_H */ |