0001
0002 #ifndef TESTS_H
0003 #define TESTS_H
0004
0005 #include <stdbool.h>
0006
0007 #define TEST_ASSERT_VAL(text, cond) \
0008 do { \
0009 if (!(cond)) { \
0010 pr_debug("FAILED %s:%d %s\n", __FILE__, __LINE__, text); \
0011 return -1; \
0012 } \
0013 } while (0)
0014
0015 #define TEST_ASSERT_EQUAL(text, val, expected) \
0016 do { \
0017 if (val != expected) { \
0018 pr_debug("FAILED %s:%d %s (%d != %d)\n", \
0019 __FILE__, __LINE__, text, val, expected); \
0020 return -1; \
0021 } \
0022 } while (0)
0023
0024 enum {
0025 TEST_OK = 0,
0026 TEST_FAIL = -1,
0027 TEST_SKIP = -2,
0028 };
0029
0030 struct test_suite;
0031
0032 typedef int (*test_fnptr)(struct test_suite *, int);
0033
0034 struct test_case {
0035 const char *name;
0036 const char *desc;
0037 const char *skip_reason;
0038 test_fnptr run_case;
0039 };
0040
0041 struct test_suite {
0042 const char *desc;
0043 struct test_case *test_cases;
0044 void *priv;
0045 };
0046
0047 #define DECLARE_SUITE(name) \
0048 extern struct test_suite suite__##name;
0049
0050 #define TEST_CASE(description, _name) \
0051 { \
0052 .name = #_name, \
0053 .desc = description, \
0054 .run_case = test__##_name, \
0055 }
0056
0057 #define TEST_CASE_REASON(description, _name, _reason) \
0058 { \
0059 .name = #_name, \
0060 .desc = description, \
0061 .run_case = test__##_name, \
0062 .skip_reason = _reason, \
0063 }
0064
0065 #define DEFINE_SUITE(description, _name) \
0066 struct test_case tests__##_name[] = { \
0067 TEST_CASE(description, _name), \
0068 { .name = NULL, } \
0069 }; \
0070 struct test_suite suite__##_name = { \
0071 .desc = description, \
0072 .test_cases = tests__##_name, \
0073 }
0074
0075
0076 DECLARE_SUITE(vmlinux_matches_kallsyms);
0077 DECLARE_SUITE(openat_syscall_event);
0078 DECLARE_SUITE(openat_syscall_event_on_all_cpus);
0079 DECLARE_SUITE(basic_mmap);
0080 DECLARE_SUITE(PERF_RECORD);
0081 DECLARE_SUITE(perf_evsel__roundtrip_name_test);
0082 DECLARE_SUITE(perf_evsel__tp_sched_test);
0083 DECLARE_SUITE(syscall_openat_tp_fields);
0084 DECLARE_SUITE(pmu);
0085 DECLARE_SUITE(pmu_events);
0086 DECLARE_SUITE(attr);
0087 DECLARE_SUITE(dso_data);
0088 DECLARE_SUITE(dso_data_cache);
0089 DECLARE_SUITE(dso_data_reopen);
0090 DECLARE_SUITE(parse_events);
0091 DECLARE_SUITE(hists_link);
0092 DECLARE_SUITE(python_use);
0093 DECLARE_SUITE(bp_signal);
0094 DECLARE_SUITE(bp_signal_overflow);
0095 DECLARE_SUITE(bp_accounting);
0096 DECLARE_SUITE(wp);
0097 DECLARE_SUITE(task_exit);
0098 DECLARE_SUITE(mem);
0099 DECLARE_SUITE(sw_clock_freq);
0100 DECLARE_SUITE(code_reading);
0101 DECLARE_SUITE(sample_parsing);
0102 DECLARE_SUITE(keep_tracking);
0103 DECLARE_SUITE(parse_no_sample_id_all);
0104 DECLARE_SUITE(dwarf_unwind);
0105 DECLARE_SUITE(expr);
0106 DECLARE_SUITE(hists_filter);
0107 DECLARE_SUITE(mmap_thread_lookup);
0108 DECLARE_SUITE(thread_maps_share);
0109 DECLARE_SUITE(hists_output);
0110 DECLARE_SUITE(hists_cumulate);
0111 DECLARE_SUITE(switch_tracking);
0112 DECLARE_SUITE(fdarray__filter);
0113 DECLARE_SUITE(fdarray__add);
0114 DECLARE_SUITE(kmod_path__parse);
0115 DECLARE_SUITE(thread_map);
0116 DECLARE_SUITE(llvm);
0117 DECLARE_SUITE(bpf);
0118 DECLARE_SUITE(session_topology);
0119 DECLARE_SUITE(thread_map_synthesize);
0120 DECLARE_SUITE(thread_map_remove);
0121 DECLARE_SUITE(cpu_map_synthesize);
0122 DECLARE_SUITE(synthesize_stat_config);
0123 DECLARE_SUITE(synthesize_stat);
0124 DECLARE_SUITE(synthesize_stat_round);
0125 DECLARE_SUITE(event_update);
0126 DECLARE_SUITE(event_times);
0127 DECLARE_SUITE(backward_ring_buffer);
0128 DECLARE_SUITE(cpu_map_print);
0129 DECLARE_SUITE(cpu_map_merge);
0130 DECLARE_SUITE(sdt_event);
0131 DECLARE_SUITE(is_printable_array);
0132 DECLARE_SUITE(bitmap_print);
0133 DECLARE_SUITE(perf_hooks);
0134 DECLARE_SUITE(clang);
0135 DECLARE_SUITE(unit_number__scnprint);
0136 DECLARE_SUITE(mem2node);
0137 DECLARE_SUITE(maps__merge_in);
0138 DECLARE_SUITE(time_utils);
0139 DECLARE_SUITE(jit_write_elf);
0140 DECLARE_SUITE(api_io);
0141 DECLARE_SUITE(demangle_java);
0142 DECLARE_SUITE(demangle_ocaml);
0143 DECLARE_SUITE(pfm);
0144 DECLARE_SUITE(parse_metric);
0145 DECLARE_SUITE(pe_file_parsing);
0146 DECLARE_SUITE(expand_cgroup_events);
0147 DECLARE_SUITE(perf_time_to_tsc);
0148 DECLARE_SUITE(dlfilter);
0149 DECLARE_SUITE(sigtrap);
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166 #if defined(__powerpc__) || defined(__s390x__) || defined(__arm__) || defined(__aarch64__)
0167 #define BP_SIGNAL_IS_SUPPORTED 0
0168 #else
0169 #define BP_SIGNAL_IS_SUPPORTED 1
0170 #endif
0171
0172 #ifdef HAVE_DWARF_UNWIND_SUPPORT
0173 struct thread;
0174 struct perf_sample;
0175 int test__arch_unwind_sample(struct perf_sample *sample,
0176 struct thread *thread);
0177 #endif
0178
0179 #if defined(__arm__)
0180 DECLARE_SUITE(vectors_page);
0181 #endif
0182
0183 #endif