blob: ae1b8e6f8f832d6dffe7693f9fff8ba4e618f7ee [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
George Liu4b062012020-10-13 15:26:58 +080022test_sources = [
Patrick Williams953315d2022-03-16 14:30:39 -050023 '../manager/manager.cpp',
George Liu4b062012020-10-13 15:26:58 +080024 '../utils.cpp'
25]
26
27tests = [
28 'utest.cpp',
George Liufb00eeb2021-06-15 10:04:17 +080029 'utest-led-json.cpp',
Alexander Hansenee2ecbf2024-07-29 16:30:45 +020030 'utest-group-priority.cpp',
George Liu4b062012020-10-13 15:26:58 +080031]
Patrick Williams95b0db92023-11-29 06:43:59 -060032if get_option('persistent-led-asserted').allowed()
George Liu54671852023-10-30 09:09:39 +080033 test_sources += [
34 '../manager/serialize.cpp',
35 ]
36 tests += [
37 'utest-serialize.cpp',
38 ]
39endif
George Liu4b062012020-10-13 15:26:58 +080040
George Liu4b062012020-10-13 15:26:58 +080041foreach t : tests
42 test(t, executable(t.underscorify(), t,
43 test_sources,
Patrick Williams953315d2022-03-16 14:30:39 -050044 include_directories: ['..', '../manager'],
George Liu4b062012020-10-13 15:26:58 +080045 dependencies: [
George Liu687fe072021-05-04 16:16:43 +080046 gtest_dep,
47 gmock_dep,
George Liu4b062012020-10-13 15:26:58 +080048 deps
49 ]),
50 workdir: meson.current_source_dir())
Patrick Williams953315d2022-03-16 14:30:39 -050051endforeach