blob: eb822494bfd49f3b86e2c9f47cba076f01c3bf83 [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()
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 Williams85c1c2a2023-11-29 06:44:37 -060016 not get_option('tests').allowed(),
George Liuc7d70b62021-05-17 16:02:18 +080017 'Googletest is required if tests are enabled'
18 )
19 endif
20endif
21
22test_sources = [
23 '../physical.cpp',
24 '../sysfs.cpp',
25]
26
27tests = [
28 'physical.cpp',
29 'sysfs.cpp',
Alexander Hansen24d124f2024-07-16 13:49:55 +020030 'test_led_description.cpp',
George Liuc7d70b62021-05-17 16:02:18 +080031]
32
33foreach t : tests
34 test(t,
35 executable(
36 t.underscorify(),
37 t,
38 test_sources,
39 include_directories: ['..'],
40 dependencies: [
41 gtest_dep,
42 gmock_dep,
43 deps
44 ]
45 )
46 )
Alexander Hansen24d124f2024-07-16 13:49:55 +020047endforeach