blob: a3c549886244b5c67efa8a3d544e2abaf094d0e6 [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')
Patrick Williamsc322c322025-02-01 08:38:07 -05006 gtest_proj = cmake.subproject('googletest', required: false)
Zane Shelley80183912021-12-21 11:52:25 -06007 if gtest_proj.found()
8 gtest_dep = declare_dependency(
9 dependencies: [
10 dependency('threads'),
11 gtest_proj.dependency('gtest'),
12 gtest_proj.dependency('gtest_main'),
Patrick Williamsc322c322025-02-01 08:38:07 -050013 ],
Zane Shelley80183912021-12-21 11:52:25 -060014 )
15 gmock_dep = gtest_proj.dependency('gmock')
16 else
Patrick Williamsc322c322025-02-01 08:38:07 -050017 assert(
18 not get_option('tests').allowed(),
19 'Googletest is required if tests are enabled',
20 )
Zane Shelley80183912021-12-21 11:52:25 -060021 endif
22endif
23
Zane Shelley9491cdb2022-02-01 10:40:45 -060024################################################################################
25
Zane Shelleyafc6acd2022-01-12 14:32:56 -060026# Compile the test dts into a binary for pdbg.
Patrick Williamsc322c322025-02-01 08:38:07 -050027pdbg_test_dtb = custom_target(
28 'build_pdbg_test_dtb',
29 input: files('pdbg-test.dts'),
30 output: 'pdbg-test.dtb',
31 command: [
32 find_program('dtc'),
33 '-I',
34 'dts',
35 '-O',
36 'dtb',
37 '-o',
38 '@OUTPUT@',
39 '@INPUT@',
40 ],
41)
Zane Shelleyafc6acd2022-01-12 14:32:56 -060042
Zane Shelleyd195b712022-01-26 13:26:34 -060043pdbg_env = 'PDBG_DTB=' + pdbg_test_dtb.full_path()
44
Zane Shelley08c21c22022-01-26 16:58:18 -060045################################################################################
46
austinfcui5dbebde2022-04-12 16:30:38 -050047# Add gtest/gmock dependency to the list of test dependencies.
Patrick Williamsc322c322025-02-01 08:38:07 -050048test_deps = [test_util_deps, gtest_dep]
Zane Shelley985388a2022-03-24 16:35:46 -050049
Patrick Williamsc322c322025-02-01 08:38:07 -050050test_vars = [pdbg_env, 'LG2_FORCE_STDERR=true']
Zane Shelley985388a2022-03-24 16:35:46 -050051
Zane Shelley69e37712022-03-24 16:43:03 -050052# Additional SRCs that are not (or should not be) included in libraries.
53# NOTE: Try to limit this, if possible, to prevent duplicate compilation.
54test_additional_srcs = [
Patrick Williamsc322c322025-02-01 08:38:07 -050055 files(
56 '../analyzer/filter-root-cause.cpp',
57 '../analyzer/plugins/ody-plugins.cpp',
58 '../analyzer/plugins/p10-plugins.cpp',
59 '../analyzer/plugins/p10-tod-plugins.cpp',
60 '../cli.cpp',
61 ),
62 pdbg_test_dtb,
Zane Shelley248cbf82019-05-03 17:07:18 -050063]
64
Zane Shelley08c21c22022-01-26 16:58:18 -060065################################################################################
66
Zane Shelley69e37712022-03-24 16:43:03 -050067testcases = [
Patrick Williamsc322c322025-02-01 08:38:07 -050068 'test-bin-stream',
69 'test-ffdc-file',
70 'test-lpc-timeout',
71 'test-pdbg-dts',
72 'test-pll-unlock',
73 'test-resolution',
74 'test-root-cause-filter',
75 'test-tod-step-check-fault',
76 'test-cli',
Zane Shelley08c21c22022-01-26 16:58:18 -060077]
Zane Shelley979e2872021-09-20 22:46:06 -050078
Caleb Palmerb1ef8c42024-04-04 12:07:16 -050079# allow more time for long running tests
Patrick Williamsc322c322025-02-01 08:38:07 -050080longtests = {'test-pll-unlock': 2}
Caleb Palmerb1ef8c42024-04-04 12:07:16 -050081
Zane Shelley69e37712022-03-24 16:43:03 -050082foreach tc : testcases
Zane Shelleye90b85d2021-12-17 17:24:49 -060083
Patrick Williamsc322c322025-02-01 08:38:07 -050084 exe = executable(
85 tc.underscorify(),
86 sources: [files(tc + '.cpp'), test_additional_srcs],
87 include_directories: incdir,
88 dependencies: test_deps,
89 cpp_args: test_args,
90 link_with: test_libs,
91 )
Zane Shelley08c21c22022-01-26 16:58:18 -060092
Patrick Williamsc322c322025-02-01 08:38:07 -050093 test(tc, exe, env: test_vars, timeout: 30 * longtests.get(tc, 1))
Zane Shelley08c21c22022-01-26 16:58:18 -060094
Zane Shelley69e37712022-03-24 16:43:03 -050095endforeach
Zane Shelley08c21c22022-01-26 16:58:18 -060096
97################################################################################
98
Zane Shelley69e37712022-03-24 16:43:03 -050099testcases = [
Patrick Williamsc322c322025-02-01 08:38:07 -0500100 'test-attention',
101 'test-end2end',
102 'test-util-data-file',
103 'test-ti-handler',
Zane Shelley08c21c22022-01-26 16:58:18 -0600104]
105
Ben Tyner3a80c982022-10-21 12:49:41 -0500106# allow more time for long running tests
Patrick Williamsc322c322025-02-01 08:38:07 -0500107longtests = {'test-end2end': 2}
Ben Tyner3a80c982022-10-21 12:49:41 -0500108
Zane Shelley69e37712022-03-24 16:43:03 -0500109foreach tc : testcases
Zane Shelley08c21c22022-01-26 16:58:18 -0600110
Patrick Williamsc322c322025-02-01 08:38:07 -0500111 exe = executable(
112 tc.underscorify(),
113 sources: [files(tc + '.cpp'), test_additional_srcs],
114 include_directories: incdir,
115 dependencies: test_deps,
116 cpp_args: test_args,
117 link_with: hwdiags_libs, # TODO: should use test_libs instead
118 )
Zane Shelley08c21c22022-01-26 16:58:18 -0600119
Patrick Williamsc322c322025-02-01 08:38:07 -0500120 test(tc, exe, env: test_vars, timeout: 30 * longtests.get(tc, 1))
Zane Shelley08c21c22022-01-26 16:58:18 -0600121
Zane Shelley69e37712022-03-24 16:43:03 -0500122endforeach
Zane Shelleyedfcbc32022-03-24 15:56:52 -0500123