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( |
Patrick Williams | 95b0db9 | 2023-11-29 06:43:59 -0600 | [diff] [blame] | 16 | not get_option('tests').allowed(), |
George Liu | 687fe07 | 2021-05-04 16:16:43 +0800 | [diff] [blame] | 17 | 'Googletest is required if tests are enabled' |
| 18 | ) |
| 19 | endif |
| 20 | endif |
| 21 | |
Alexander Hansen | eb1f46a | 2024-07-30 16:09:07 +0200 | [diff] [blame] | 22 | test_yamls = [ |
| 23 | 'test-group-priority', |
| 24 | 'test-led-priority' |
| 25 | ] |
| 26 | |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 27 | test_sources = [ |
Patrick Williams | 953315d | 2022-03-16 14:30:39 -0500 | [diff] [blame] | 28 | '../manager/manager.cpp', |
Alexander Hansen | 638d148 | 2024-08-21 17:39:57 +0200 | [diff] [blame] | 29 | '../manager/config-validator.cpp', |
Alexander Hansen | eb1f46a | 2024-07-30 16:09:07 +0200 | [diff] [blame] | 30 | '../utils.cpp', |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 31 | ] |
| 32 | |
Alexander Hansen | eb1f46a | 2024-07-30 16:09:07 +0200 | [diff] [blame] | 33 | foreach yaml : test_yamls |
| 34 | gen_hpp = custom_target( |
| 35 | yaml + '.hpp', |
| 36 | command : [ |
| 37 | prog_python, |
| 38 | meson.project_source_root() + '/scripts/parse_led.py', |
| 39 | '--filename', meson.project_source_root() + '/test/config/' + yaml + '.yaml', |
| 40 | '-o', meson.current_build_dir(), |
| 41 | '--output-filename', yaml + '.hpp' |
| 42 | ], |
| 43 | output : yaml + '.hpp') |
| 44 | |
| 45 | test_sources += [ gen_hpp ] |
| 46 | endforeach |
| 47 | |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 48 | tests = [ |
| 49 | 'utest.cpp', |
George Liu | fb00eeb | 2021-06-15 10:04:17 +0800 | [diff] [blame] | 50 | 'utest-led-json.cpp', |
Alexander Hansen | ee2ecbf | 2024-07-29 16:30:45 +0200 | [diff] [blame] | 51 | 'utest-group-priority.cpp', |
Alexander Hansen | eb1f46a | 2024-07-30 16:09:07 +0200 | [diff] [blame] | 52 | 'utest-led-yaml-group-priority.cpp', |
| 53 | 'utest-led-yaml-led-priority.cpp', |
Alexander Hansen | 638d148 | 2024-08-21 17:39:57 +0200 | [diff] [blame] | 54 | 'utest-config-validator.cpp' |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 55 | ] |
Patrick Williams | 95b0db9 | 2023-11-29 06:43:59 -0600 | [diff] [blame] | 56 | if get_option('persistent-led-asserted').allowed() |
George Liu | 5467185 | 2023-10-30 09:09:39 +0800 | [diff] [blame] | 57 | test_sources += [ |
| 58 | '../manager/serialize.cpp', |
| 59 | ] |
| 60 | tests += [ |
| 61 | 'utest-serialize.cpp', |
| 62 | ] |
| 63 | endif |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 64 | |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 65 | foreach t : tests |
| 66 | test(t, executable(t.underscorify(), t, |
| 67 | test_sources, |
Patrick Williams | 953315d | 2022-03-16 14:30:39 -0500 | [diff] [blame] | 68 | include_directories: ['..', '../manager'], |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 69 | dependencies: [ |
George Liu | 687fe07 | 2021-05-04 16:16:43 +0800 | [diff] [blame] | 70 | gtest_dep, |
| 71 | gmock_dep, |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 72 | deps |
| 73 | ]), |
| 74 | workdir: meson.current_source_dir()) |
Patrick Williams | 953315d | 2022-03-16 14:30:39 -0500 | [diff] [blame] | 75 | endforeach |