blob: 273087f9f85846ed8f15936579d3370e5e7d63ef [file] [log] [blame]
Zane Shelley80183912021-12-21 11:52:25 -06001# Get the gtest/gmock dependencies.
2gtest_dep = dependency('gtest', main: true, disabler: true, required: false)
3gmock_dep = dependency('gmock', disabler: true, required: false)
4if not gtest_dep.found() or not gmock_dep.found()
5 cmake = import('cmake')
6 gtest_proj = cmake.subproject('googletest',
7 required: false)
8 if gtest_proj.found()
9 gtest_dep = declare_dependency(
10 dependencies: [
11 dependency('threads'),
12 gtest_proj.dependency('gtest'),
13 gtest_proj.dependency('gtest_main'),
14 ]
15 )
16 gmock_dep = gtest_proj.dependency('gmock')
17 else
18 assert(not get_option('tests').enabled(),
19 'Googletest is required if tests are enabled')
20 endif
21endif
22
Zane Shelley9491cdb2022-02-01 10:40:45 -060023################################################################################
24
Zane Shelleyafc6acd2022-01-12 14:32:56 -060025# Compile the test dts into a binary for pdbg.
26pdbg_test_dtb = custom_target('build_pdbg_test_dtb',
Zane Shelley08c21c22022-01-26 16:58:18 -060027 input : files('pdbg-test.dts'),
28 output : 'pdbg-test.dtb',
Zane Shelleyafc6acd2022-01-12 14:32:56 -060029 command : [ find_program('dtc'), '-I', 'dts', '-O', 'dtb',
30 '-o', '@OUTPUT@', '@INPUT@' ])
31
Zane Shelleyd195b712022-01-26 13:26:34 -060032pdbg_env = 'PDBG_DTB=' + pdbg_test_dtb.full_path()
33
Zane Shelley08c21c22022-01-26 16:58:18 -060034################################################################################
35
austinfcui5dbebde2022-04-12 16:30:38 -050036# Add gtest/gmock dependency to the list of test dependencies.
Zane Shelley985388a2022-03-24 16:35:46 -050037test_deps = [
austinfcui5dbebde2022-04-12 16:30:38 -050038 test_util_deps,
Zane Shelley985388a2022-03-24 16:35:46 -050039 gtest_dep,
40]
41
42test_vars = [
43 pdbg_env,
Zane Shelley20ed74d2022-03-26 13:50:57 -050044 'LG2_FORCE_STDERR=true',
Zane Shelley985388a2022-03-24 16:35:46 -050045]
46
Zane Shelley69e37712022-03-24 16:43:03 -050047# Additional SRCs that are not (or should not be) included in libraries.
48# NOTE: Try to limit this, if possible, to prevent duplicate compilation.
49test_additional_srcs = [
austinfcui5dbebde2022-04-12 16:30:38 -050050 files(
Caleb Palmer1a4f0e72022-11-07 15:08:01 -060051 '../analyzer/filter-root-cause.cpp',
Zane Shelleyc62813d2023-08-22 16:52:19 -050052 '../analyzer/plugins/ody-plugins.cpp',
austinfcui5dbebde2022-04-12 16:30:38 -050053 '../analyzer/plugins/p10-plugins.cpp',
54 '../analyzer/plugins/p10-tod-plugins.cpp',
55 '../cli.cpp',
56 ),
57 pdbg_test_dtb
Zane Shelley248cbf82019-05-03 17:07:18 -050058]
59
Zane Shelley08c21c22022-01-26 16:58:18 -060060################################################################################
61
Zane Shelley69e37712022-03-24 16:43:03 -050062testcases = [
63 'test-bin-stream',
64 'test-ffdc-file',
65 'test-lpc-timeout',
66 'test-pdbg-dts',
67 'test-pll-unlock',
68 'test-resolution',
Caleb Palmer1a4f0e72022-11-07 15:08:01 -060069 'test-root-cause-filter',
Zane Shelley69e37712022-03-24 16:43:03 -050070 'test-tod-step-check-fault',
austinfcuid28d5f82022-04-28 16:20:39 -050071 'test-cli',
Zane Shelley08c21c22022-01-26 16:58:18 -060072]
Zane Shelley979e2872021-09-20 22:46:06 -050073
Zane Shelley69e37712022-03-24 16:43:03 -050074foreach tc : testcases
Zane Shelleye90b85d2021-12-17 17:24:49 -060075
Zane Shelley69e37712022-03-24 16:43:03 -050076 exe = executable(tc.underscorify(),
77 sources : [ files(tc + '.cpp'), test_additional_srcs ],
78 include_directories : incdir,
79 dependencies : test_deps,
80 cpp_args : test_args,
81 link_with : test_libs,
82 )
Zane Shelley08c21c22022-01-26 16:58:18 -060083
Zane Shelley69e37712022-03-24 16:43:03 -050084 test(tc, exe, env: test_vars)
Zane Shelley08c21c22022-01-26 16:58:18 -060085
Zane Shelley69e37712022-03-24 16:43:03 -050086endforeach
Zane Shelley08c21c22022-01-26 16:58:18 -060087
88################################################################################
89
Zane Shelley69e37712022-03-24 16:43:03 -050090testcases = [
91 'test-attention',
92 'test-end2end',
93 'test-util-data-file',
94 'test-ti-handler',
Zane Shelley08c21c22022-01-26 16:58:18 -060095]
96
Ben Tyner3a80c982022-10-21 12:49:41 -050097# allow more time for long running tests
98longtests = {
99 'test-end2end': 2,
100}
101
Zane Shelley69e37712022-03-24 16:43:03 -0500102foreach tc : testcases
Zane Shelley08c21c22022-01-26 16:58:18 -0600103
Zane Shelley69e37712022-03-24 16:43:03 -0500104 exe = executable(tc.underscorify(),
105 sources : [ files(tc + '.cpp'), test_additional_srcs ],
106 include_directories : incdir,
107 dependencies : test_deps,
108 cpp_args : test_args,
109 link_with : hwdiags_libs, # TODO: should use test_libs instead
110 )
Zane Shelley08c21c22022-01-26 16:58:18 -0600111
Ben Tyner3a80c982022-10-21 12:49:41 -0500112 test(tc, exe, env: test_vars, timeout: 30 * longtests.get(tc, 1))
Zane Shelley08c21c22022-01-26 16:58:18 -0600113
Zane Shelley69e37712022-03-24 16:43:03 -0500114endforeach
Zane Shelleyedfcbc32022-03-24 15:56:52 -0500115