18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef TESTS_H
38c2ecf20Sopenharmony_ci#define TESTS_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <stdbool.h>
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#define TEST_ASSERT_VAL(text, cond)					 \
88c2ecf20Sopenharmony_cido {									 \
98c2ecf20Sopenharmony_ci	if (!(cond)) {							 \
108c2ecf20Sopenharmony_ci		pr_debug("FAILED %s:%d %s\n", __FILE__, __LINE__, text); \
118c2ecf20Sopenharmony_ci		return -1;						 \
128c2ecf20Sopenharmony_ci	}								 \
138c2ecf20Sopenharmony_ci} while (0)
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#define TEST_ASSERT_EQUAL(text, val, expected)				 \
168c2ecf20Sopenharmony_cido {									 \
178c2ecf20Sopenharmony_ci	if (val != expected) {						 \
188c2ecf20Sopenharmony_ci		pr_debug("FAILED %s:%d %s (%d != %d)\n",		 \
198c2ecf20Sopenharmony_ci			 __FILE__, __LINE__, text, val, expected);	 \
208c2ecf20Sopenharmony_ci		return -1;						 \
218c2ecf20Sopenharmony_ci	}								 \
228c2ecf20Sopenharmony_ci} while (0)
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_cienum {
258c2ecf20Sopenharmony_ci	TEST_OK   =  0,
268c2ecf20Sopenharmony_ci	TEST_FAIL = -1,
278c2ecf20Sopenharmony_ci	TEST_SKIP = -2,
288c2ecf20Sopenharmony_ci};
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_cistruct test {
318c2ecf20Sopenharmony_ci	const char *desc;
328c2ecf20Sopenharmony_ci	int (*func)(struct test *test, int subtest);
338c2ecf20Sopenharmony_ci	struct {
348c2ecf20Sopenharmony_ci		bool skip_if_fail;
358c2ecf20Sopenharmony_ci		int (*get_nr)(void);
368c2ecf20Sopenharmony_ci		const char *(*get_desc)(int subtest);
378c2ecf20Sopenharmony_ci		const char *(*skip_reason)(int subtest);
388c2ecf20Sopenharmony_ci	} subtest;
398c2ecf20Sopenharmony_ci	bool (*is_supported)(void);
408c2ecf20Sopenharmony_ci	void *priv;
418c2ecf20Sopenharmony_ci};
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci/* Tests */
448c2ecf20Sopenharmony_ciint test__vmlinux_matches_kallsyms(struct test *test, int subtest);
458c2ecf20Sopenharmony_ciint test__openat_syscall_event(struct test *test, int subtest);
468c2ecf20Sopenharmony_ciint test__openat_syscall_event_on_all_cpus(struct test *test, int subtest);
478c2ecf20Sopenharmony_ciint test__basic_mmap(struct test *test, int subtest);
488c2ecf20Sopenharmony_ciint test__PERF_RECORD(struct test *test, int subtest);
498c2ecf20Sopenharmony_ciint test__perf_evsel__roundtrip_name_test(struct test *test, int subtest);
508c2ecf20Sopenharmony_ciint test__perf_evsel__tp_sched_test(struct test *test, int subtest);
518c2ecf20Sopenharmony_ciint test__syscall_openat_tp_fields(struct test *test, int subtest);
528c2ecf20Sopenharmony_ciint test__pmu(struct test *test, int subtest);
538c2ecf20Sopenharmony_ciint test__pmu_events(struct test *test, int subtest);
548c2ecf20Sopenharmony_ciconst char *test__pmu_events_subtest_get_desc(int subtest);
558c2ecf20Sopenharmony_ciconst char *test__pmu_events_subtest_skip_reason(int subtest);
568c2ecf20Sopenharmony_ciint test__pmu_events_subtest_get_nr(void);
578c2ecf20Sopenharmony_ciint test__attr(struct test *test, int subtest);
588c2ecf20Sopenharmony_ciint test__dso_data(struct test *test, int subtest);
598c2ecf20Sopenharmony_ciint test__dso_data_cache(struct test *test, int subtest);
608c2ecf20Sopenharmony_ciint test__dso_data_reopen(struct test *test, int subtest);
618c2ecf20Sopenharmony_ciint test__parse_events(struct test *test, int subtest);
628c2ecf20Sopenharmony_ciint test__hists_link(struct test *test, int subtest);
638c2ecf20Sopenharmony_ciint test__python_use(struct test *test, int subtest);
648c2ecf20Sopenharmony_ciint test__bp_signal(struct test *test, int subtest);
658c2ecf20Sopenharmony_ciint test__bp_signal_overflow(struct test *test, int subtest);
668c2ecf20Sopenharmony_ciint test__bp_accounting(struct test *test, int subtest);
678c2ecf20Sopenharmony_ciint test__wp(struct test *test, int subtest);
688c2ecf20Sopenharmony_ciconst char *test__wp_subtest_get_desc(int subtest);
698c2ecf20Sopenharmony_ciint test__wp_subtest_get_nr(void);
708c2ecf20Sopenharmony_ciint test__task_exit(struct test *test, int subtest);
718c2ecf20Sopenharmony_ciint test__mem(struct test *test, int subtest);
728c2ecf20Sopenharmony_ciint test__sw_clock_freq(struct test *test, int subtest);
738c2ecf20Sopenharmony_ciint test__code_reading(struct test *test, int subtest);
748c2ecf20Sopenharmony_ciint test__sample_parsing(struct test *test, int subtest);
758c2ecf20Sopenharmony_ciint test__keep_tracking(struct test *test, int subtest);
768c2ecf20Sopenharmony_ciint test__parse_no_sample_id_all(struct test *test, int subtest);
778c2ecf20Sopenharmony_ciint test__dwarf_unwind(struct test *test, int subtest);
788c2ecf20Sopenharmony_ciint test__expr(struct test *test, int subtest);
798c2ecf20Sopenharmony_ciint test__hists_filter(struct test *test, int subtest);
808c2ecf20Sopenharmony_ciint test__mmap_thread_lookup(struct test *test, int subtest);
818c2ecf20Sopenharmony_ciint test__thread_maps_share(struct test *test, int subtest);
828c2ecf20Sopenharmony_ciint test__hists_output(struct test *test, int subtest);
838c2ecf20Sopenharmony_ciint test__hists_cumulate(struct test *test, int subtest);
848c2ecf20Sopenharmony_ciint test__switch_tracking(struct test *test, int subtest);
858c2ecf20Sopenharmony_ciint test__fdarray__filter(struct test *test, int subtest);
868c2ecf20Sopenharmony_ciint test__fdarray__add(struct test *test, int subtest);
878c2ecf20Sopenharmony_ciint test__kmod_path__parse(struct test *test, int subtest);
888c2ecf20Sopenharmony_ciint test__thread_map(struct test *test, int subtest);
898c2ecf20Sopenharmony_ciint test__llvm(struct test *test, int subtest);
908c2ecf20Sopenharmony_ciconst char *test__llvm_subtest_get_desc(int subtest);
918c2ecf20Sopenharmony_ciint test__llvm_subtest_get_nr(void);
928c2ecf20Sopenharmony_ciint test__bpf(struct test *test, int subtest);
938c2ecf20Sopenharmony_ciconst char *test__bpf_subtest_get_desc(int subtest);
948c2ecf20Sopenharmony_ciint test__bpf_subtest_get_nr(void);
958c2ecf20Sopenharmony_ciint test__session_topology(struct test *test, int subtest);
968c2ecf20Sopenharmony_ciint test__thread_map_synthesize(struct test *test, int subtest);
978c2ecf20Sopenharmony_ciint test__thread_map_remove(struct test *test, int subtest);
988c2ecf20Sopenharmony_ciint test__cpu_map_synthesize(struct test *test, int subtest);
998c2ecf20Sopenharmony_ciint test__synthesize_stat_config(struct test *test, int subtest);
1008c2ecf20Sopenharmony_ciint test__synthesize_stat(struct test *test, int subtest);
1018c2ecf20Sopenharmony_ciint test__synthesize_stat_round(struct test *test, int subtest);
1028c2ecf20Sopenharmony_ciint test__event_update(struct test *test, int subtest);
1038c2ecf20Sopenharmony_ciint test__event_times(struct test *test, int subtest);
1048c2ecf20Sopenharmony_ciint test__backward_ring_buffer(struct test *test, int subtest);
1058c2ecf20Sopenharmony_ciint test__cpu_map_print(struct test *test, int subtest);
1068c2ecf20Sopenharmony_ciint test__cpu_map_merge(struct test *test, int subtest);
1078c2ecf20Sopenharmony_ciint test__sdt_event(struct test *test, int subtest);
1088c2ecf20Sopenharmony_ciint test__is_printable_array(struct test *test, int subtest);
1098c2ecf20Sopenharmony_ciint test__bitmap_print(struct test *test, int subtest);
1108c2ecf20Sopenharmony_ciint test__perf_hooks(struct test *test, int subtest);
1118c2ecf20Sopenharmony_ciint test__clang(struct test *test, int subtest);
1128c2ecf20Sopenharmony_ciconst char *test__clang_subtest_get_desc(int subtest);
1138c2ecf20Sopenharmony_ciint test__clang_subtest_get_nr(void);
1148c2ecf20Sopenharmony_ciint test__unit_number__scnprint(struct test *test, int subtest);
1158c2ecf20Sopenharmony_ciint test__mem2node(struct test *t, int subtest);
1168c2ecf20Sopenharmony_ciint test__maps__merge_in(struct test *t, int subtest);
1178c2ecf20Sopenharmony_ciint test__time_utils(struct test *t, int subtest);
1188c2ecf20Sopenharmony_ciint test__jit_write_elf(struct test *test, int subtest);
1198c2ecf20Sopenharmony_ciint test__api_io(struct test *test, int subtest);
1208c2ecf20Sopenharmony_ciint test__demangle_java(struct test *test, int subtest);
1218c2ecf20Sopenharmony_ciint test__pfm(struct test *test, int subtest);
1228c2ecf20Sopenharmony_ciconst char *test__pfm_subtest_get_desc(int subtest);
1238c2ecf20Sopenharmony_ciint test__pfm_subtest_get_nr(void);
1248c2ecf20Sopenharmony_ciint test__parse_metric(struct test *test, int subtest);
1258c2ecf20Sopenharmony_ciint test__pe_file_parsing(struct test *test, int subtest);
1268c2ecf20Sopenharmony_ciint test__expand_cgroup_events(struct test *test, int subtest);
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_cibool test__bp_signal_is_supported(void);
1298c2ecf20Sopenharmony_cibool test__bp_account_is_supported(void);
1308c2ecf20Sopenharmony_cibool test__wp_is_supported(void);
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci#if defined(__arm__) || defined(__aarch64__)
1338c2ecf20Sopenharmony_ci#ifdef HAVE_DWARF_UNWIND_SUPPORT
1348c2ecf20Sopenharmony_cistruct thread;
1358c2ecf20Sopenharmony_cistruct perf_sample;
1368c2ecf20Sopenharmony_ciint test__arch_unwind_sample(struct perf_sample *sample,
1378c2ecf20Sopenharmony_ci			     struct thread *thread);
1388c2ecf20Sopenharmony_ci#endif
1398c2ecf20Sopenharmony_ci#endif
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci#if defined(__arm__)
1428c2ecf20Sopenharmony_ciint test__vectors_page(struct test *test, int subtest);
1438c2ecf20Sopenharmony_ci#endif
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci#endif /* TESTS_H */
146