blob: 18c1192c29471efd863b38f4d4c3652618abd356 [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(
16 not get_option('tests').enabled(),
17 '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',
24 '../manager/serialize.cpp',
George Liu4b062012020-10-13 15:26:58 +080025 '../utils.cpp'
26]
27
28tests = [
29 'utest.cpp',
30 'utest-serialize.cpp',
George Liufb00eeb2021-06-15 10:04:17 +080031 'utest-led-json.cpp',
George Liu4b062012020-10-13 15:26:58 +080032]
33
George Liu4b062012020-10-13 15:26:58 +080034foreach t : tests
35 test(t, executable(t.underscorify(), t,
36 test_sources,
Patrick Williams953315d2022-03-16 14:30:39 -050037 include_directories: ['..', '../manager'],
George Liu4b062012020-10-13 15:26:58 +080038 dependencies: [
George Liu687fe072021-05-04 16:16:43 +080039 gtest_dep,
40 gmock_dep,
George Liu4b062012020-10-13 15:26:58 +080041 deps
42 ]),
43 workdir: meson.current_source_dir())
Patrick Williams953315d2022-03-16 14:30:39 -050044endforeach