George Liu | 687fe07 | 2021-05-04 16:16:43 +0800 | [diff] [blame] | 1 | gtest_dep = dependency('gtest', main: true, disabler: true, required: false) |
| 2 | gmock_dep = dependency('gmock', disabler: true, required: false) |
| 3 | if not gtest_dep.found() or not gmock_dep.found() |
| 4 | gtest_proj = import('cmake').subproject('googletest', required: false) |
| 5 | if gtest_proj.found() |
| 6 | gtest_dep = declare_dependency( |
| 7 | dependencies: [ |
| 8 | dependency('threads'), |
| 9 | gtest_proj.dependency('gtest'), |
| 10 | gtest_proj.dependency('gtest_main'), |
| 11 | ] |
| 12 | ) |
| 13 | gmock_dep = gtest_proj.dependency('gmock') |
| 14 | else |
| 15 | assert( |
| 16 | not get_option('tests').enabled(), |
| 17 | 'Googletest is required if tests are enabled' |
| 18 | ) |
| 19 | endif |
| 20 | endif |
| 21 | |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 22 | test_sources = [ |
Patrick Williams | 953315d | 2022-03-16 14:30:39 -0500 | [diff] [blame] | 23 | '../manager/manager.cpp', |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 24 | '../utils.cpp' |
| 25 | ] |
| 26 | |
| 27 | tests = [ |
| 28 | 'utest.cpp', |
George Liu | fb00eeb | 2021-06-15 10:04:17 +0800 | [diff] [blame] | 29 | 'utest-led-json.cpp', |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 30 | ] |
George Liu | 5467185 | 2023-10-30 09:09:39 +0800 | [diff] [blame^] | 31 | if get_option('persistent-led-asserted').enabled() |
| 32 | test_sources += [ |
| 33 | '../manager/serialize.cpp', |
| 34 | ] |
| 35 | tests += [ |
| 36 | 'utest-serialize.cpp', |
| 37 | ] |
| 38 | endif |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 39 | |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 40 | foreach t : tests |
| 41 | test(t, executable(t.underscorify(), t, |
| 42 | test_sources, |
Patrick Williams | 953315d | 2022-03-16 14:30:39 -0500 | [diff] [blame] | 43 | include_directories: ['..', '../manager'], |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 44 | dependencies: [ |
George Liu | 687fe07 | 2021-05-04 16:16:43 +0800 | [diff] [blame] | 45 | gtest_dep, |
| 46 | gmock_dep, |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 47 | deps |
| 48 | ]), |
| 49 | workdir: meson.current_source_dir()) |
Patrick Williams | 953315d | 2022-03-16 14:30:39 -0500 | [diff] [blame] | 50 | endforeach |