blob: aec8ee3a8176fbf0d8b0d09e6ef23c03759200f0 [file] [log] [blame]
George Liuc7d70b62021-05-17 16:02:18 +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()
Patrick Williams2f51f1a2025-02-01 08:37:23 -05004 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').allowed(),
17 'Googletest is required if tests are enabled',
18 )
19 endif
George Liuc7d70b62021-05-17 16:02:18 +080020endif
21
22test_sources = [
Patrick Williams2f51f1a2025-02-01 08:37:23 -050023 '../physical.cpp',
24 '../sysfs.cpp',
25 '../interfaces/internal_interface.cpp',
George Liuc7d70b62021-05-17 16:02:18 +080026]
27
28tests = [
Patrick Williams2f51f1a2025-02-01 08:37:23 -050029 'physical.cpp',
30 'sysfs.cpp',
31 'test_led_description.cpp',
32 'test_dbus_name.cpp',
George Liuc7d70b62021-05-17 16:02:18 +080033]
34
35foreach t : tests
Patrick Williams2f51f1a2025-02-01 08:37:23 -050036 test(
37 t,
38 executable(
39 t.underscorify(),
40 t,
41 test_sources,
42 include_directories: ['..'],
43 dependencies: [gtest_dep, gmock_dep, deps],
44 ),
45 )
Alexander Hansen24d124f2024-07-16 13:49:55 +020046endforeach