blob: c484b2eabe86fa1c09081b86fb4d896fdb269d4b [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 Shelley0c44c2f2020-06-05 17:14:31 -050023test_arg = [
24 '-DTEST_TRACE',
25]
26
Zane Shelleyafc6acd2022-01-12 14:32:56 -060027# Compile the test dts into a binary for pdbg.
28pdbg_test_dtb = custom_target('build_pdbg_test_dtb',
29 input : files('pdbg_test.dts'),
30 output : 'pdbg_test.dtb',
31 command : [ find_program('dtc'), '-I', 'dts', '-O', 'dtb',
32 '-o', '@OUTPUT@', '@INPUT@' ])
33
Zane Shelleyd195b712022-01-26 13:26:34 -060034pdbg_env = 'PDBG_DTB=' + pdbg_test_dtb.full_path()
35
Ben Tyner9ae5ca42020-02-28 13:13:50 -060036# end2end code exerciser for experiment and testing
37subdir('end2end')
38
Zane Shelley248cbf82019-05-03 17:07:18 -050039tests = [
Zane Shelleyd26298b2021-01-28 16:49:19 -060040 'bin_stream_test',
Zane Shelley982f1722021-03-25 10:56:37 -050041 'ffdc_file_test',
Zane Shelley0b8368c2021-03-18 17:33:41 -050042 'resolution_test',
austinfcui35257fd2021-12-09 17:56:00 -060043 'pdbg_dts_test',
Zane Shelleye90b85d2021-12-17 17:24:49 -060044 'test-lpc-timeout',
Zane Shelley2c228cd2021-12-16 23:45:12 -060045 'test-pll-unlock',
Zane Shelley248cbf82019-05-03 17:07:18 -050046]
47
Zane Shelley979e2872021-09-20 22:46:06 -050048analyzer_src = files(
Zane Shelley2c228cd2021-12-16 23:45:12 -060049 '../analyzer/plugins/p10-plugins.cpp',
Zane Shelley979e2872021-09-20 22:46:06 -050050 '../analyzer/service_data.cpp',
Zane Shelleycb766a42022-01-12 17:50:23 -060051 '../analyzer/resolution.cpp',
52)
53
54# We cannot link to `util_lib` because that is built without `-DTEST_TRACE` and
55# any of the util functions that use `trace.hpp` will throw a linker error
56# because we don't have access to phosphor-logging in test ... yet.
57util_src = files(
58 '../util/ffdc_file.cpp',
59 '../util/pdbg.cpp',
60 '../util/temporary_file.cpp',
Zane Shelley979e2872021-09-20 22:46:06 -050061)
62
Zane Shelleye90b85d2021-12-17 17:24:49 -060063sim_src = files(
64 'pdbg-sim-only.cpp',
65)
66
Zane Shelley80183912021-12-21 11:52:25 -060067foreach t : tests
Zane Shelleyafc6acd2022-01-12 14:32:56 -060068 test(t,
69 executable(t.underscorify(),
Zane Shelleycb766a42022-01-12 17:50:23 -060070 [ files(t + '.cpp'), pdbg_test_dtb,
Zane Shelleye90b85d2021-12-17 17:24:49 -060071 analyzer_src, util_src, sim_src ],
Zane Shelleycb766a42022-01-12 17:50:23 -060072 dependencies : [ libhei_dep, libpdbg_dep, gtest_dep ],
Zane Shelleyafc6acd2022-01-12 14:32:56 -060073 cpp_args : test_arg,
74 include_directories : incdir),
Zane Shelleyd195b712022-01-26 13:26:34 -060075 env : pdbg_env)
Zane Shelley80183912021-12-21 11:52:25 -060076endforeach
Zane Shelleyd195b712022-01-26 13:26:34 -060077
78################################################################################
79
80tc = 'test-tod-step-check-fault'
81
82src = [
83 files(
84 tc + '.cpp',
85 '../analyzer/plugins/p10-tod-plugins.cpp',
86 '../analyzer/service_data.cpp',
87 '../util/pdbg.cpp',
88 ),
89 pdbg_test_dtb,
90]
91
92dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
93
94var = [ pdbg_env ]
95
96exe = executable(tc.underscorify(), src, dependencies: dep,
97 cpp_args: test_arg, include_directories: incdir)
98
99test(tc, exe, env: var)
100