Zane Shelley | 8018391 | 2021-12-21 11:52:25 -0600 | [diff] [blame] | 1 | # Get the gtest/gmock dependencies. |
| 2 | gtest_dep = dependency('gtest', main: true, disabler: true, required: false) |
| 3 | gmock_dep = dependency('gmock', disabler: true, required: false) |
| 4 | if 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 |
| 21 | endif |
| 22 | |
Zane Shelley | 0c44c2f | 2020-06-05 17:14:31 -0500 | [diff] [blame] | 23 | test_arg = [ |
| 24 | '-DTEST_TRACE', |
| 25 | ] |
| 26 | |
Zane Shelley | afc6acd | 2022-01-12 14:32:56 -0600 | [diff] [blame] | 27 | # Compile the test dts into a binary for pdbg. |
| 28 | pdbg_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 | |
Ben Tyner | 9ae5ca4 | 2020-02-28 13:13:50 -0600 | [diff] [blame] | 34 | # end2end code exerciser for experiment and testing |
| 35 | subdir('end2end') |
| 36 | |
Zane Shelley | 248cbf8 | 2019-05-03 17:07:18 -0500 | [diff] [blame] | 37 | tests = [ |
Zane Shelley | d26298b | 2021-01-28 16:49:19 -0600 | [diff] [blame] | 38 | 'bin_stream_test', |
Zane Shelley | 982f172 | 2021-03-25 10:56:37 -0500 | [diff] [blame] | 39 | 'ffdc_file_test', |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 40 | 'resolution_test', |
Zane Shelley | 248cbf8 | 2019-05-03 17:07:18 -0500 | [diff] [blame] | 41 | ] |
| 42 | |
Zane Shelley | 979e287 | 2021-09-20 22:46:06 -0500 | [diff] [blame] | 43 | analyzer_src = files( |
| 44 | '../analyzer/service_data.cpp', |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 45 | '../analyzer/resolution.cpp', |
| 46 | ) |
| 47 | |
| 48 | # We cannot link to `util_lib` because that is built without `-DTEST_TRACE` and |
| 49 | # any of the util functions that use `trace.hpp` will throw a linker error |
| 50 | # because we don't have access to phosphor-logging in test ... yet. |
| 51 | util_src = files( |
| 52 | '../util/ffdc_file.cpp', |
| 53 | '../util/pdbg.cpp', |
| 54 | '../util/temporary_file.cpp', |
Zane Shelley | 979e287 | 2021-09-20 22:46:06 -0500 | [diff] [blame] | 55 | ) |
| 56 | |
Zane Shelley | 8018391 | 2021-12-21 11:52:25 -0600 | [diff] [blame] | 57 | foreach t : tests |
Zane Shelley | afc6acd | 2022-01-12 14:32:56 -0600 | [diff] [blame] | 58 | test(t, |
| 59 | executable(t.underscorify(), |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 60 | [ files(t + '.cpp'), pdbg_test_dtb, |
| 61 | analyzer_src, util_src ], |
| 62 | dependencies : [ libhei_dep, libpdbg_dep, gtest_dep ], |
Zane Shelley | afc6acd | 2022-01-12 14:32:56 -0600 | [diff] [blame] | 63 | cpp_args : test_arg, |
| 64 | include_directories : incdir), |
| 65 | env : [ 'PDBG_DTB=' + pdbg_test_dtb.full_path() ]) |
Zane Shelley | 8018391 | 2021-12-21 11:52:25 -0600 | [diff] [blame] | 66 | endforeach |