blob: b7f0b472398dbeee9e3719ba5d1e6c62b6d17395 [file] [log] [blame]
George Liu687fe072021-05-04 16:16:43 +08001gtest_dep = dependency('gtest', main: true, disabler: true, required: false)
2gmock_dep = dependency('gmock', disabler: true, required: false)
3if 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 Williams95b0db92023-11-29 06:43:59 -060016 not get_option('tests').allowed(),
George Liu687fe072021-05-04 16:16:43 +080017 'Googletest is required if tests are enabled'
18 )
19 endif
20endif
21
Alexander Hanseneb1f46a2024-07-30 16:09:07 +020022test_yamls = [
Jason M. Billsf2669fa2024-09-05 13:29:16 -070023 'test-empty-group',
Alexander Hanseneb1f46a2024-07-30 16:09:07 +020024 'test-group-priority',
25 'test-led-priority'
26]
27
George Liu4b062012020-10-13 15:26:58 +080028test_sources = [
Patrick Williams953315d2022-03-16 14:30:39 -050029 '../manager/manager.cpp',
Alexander Hansen638d1482024-08-21 17:39:57 +020030 '../manager/config-validator.cpp',
Alexander Hanseneb1f46a2024-07-30 16:09:07 +020031 '../utils.cpp',
George Liu4b062012020-10-13 15:26:58 +080032]
33
Alexander Hanseneb1f46a2024-07-30 16:09:07 +020034foreach yaml : test_yamls
35 gen_hpp = custom_target(
36 yaml + '.hpp',
37 command : [
38 prog_python,
39 meson.project_source_root() + '/scripts/parse_led.py',
40 '--filename', meson.project_source_root() + '/test/config/' + yaml + '.yaml',
41 '-o', meson.current_build_dir(),
42 '--output-filename', yaml + '.hpp'
43 ],
44 output : yaml + '.hpp')
45
46 test_sources += [ gen_hpp ]
47endforeach
48
George Liu4b062012020-10-13 15:26:58 +080049tests = [
50 'utest.cpp',
George Liufb00eeb2021-06-15 10:04:17 +080051 'utest-led-json.cpp',
Alexander Hansenee2ecbf2024-07-29 16:30:45 +020052 'utest-group-priority.cpp',
Alexander Hanseneb1f46a2024-07-30 16:09:07 +020053 'utest-led-yaml-group-priority.cpp',
54 'utest-led-yaml-led-priority.cpp',
Jason M. Billsf2669fa2024-09-05 13:29:16 -070055 'utest-led-yaml-empty-group.cpp',
Alexander Hansen638d1482024-08-21 17:39:57 +020056 'utest-config-validator.cpp'
George Liu4b062012020-10-13 15:26:58 +080057]
Patrick Williams95b0db92023-11-29 06:43:59 -060058if get_option('persistent-led-asserted').allowed()
George Liu54671852023-10-30 09:09:39 +080059 test_sources += [
60 '../manager/serialize.cpp',
61 ]
62 tests += [
63 'utest-serialize.cpp',
64 ]
65endif
George Liu4b062012020-10-13 15:26:58 +080066
George Liu4b062012020-10-13 15:26:58 +080067foreach t : tests
68 test(t, executable(t.underscorify(), t,
69 test_sources,
Patrick Williams953315d2022-03-16 14:30:39 -050070 include_directories: ['..', '../manager'],
George Liu4b062012020-10-13 15:26:58 +080071 dependencies: [
George Liu687fe072021-05-04 16:16:43 +080072 gtest_dep,
73 gmock_dep,
George Liu4b062012020-10-13 15:26:58 +080074 deps
75 ]),
76 workdir: meson.current_source_dir())
Patrick Williams953315d2022-03-16 14:30:39 -050077endforeach