blob: 4a751c4e6c93e97b391d3abf311accb4dec5fee4 [file] [log] [blame]
George Liubddcf852021-09-08 08:46:22 +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
22test_sources = [
23 generated_sources,
24 '../occ_pass_through.cpp',
25 '../occ_manager.cpp',
26 '../occ_status.cpp',
27 '../occ_device.cpp',
28 '../occ_errors.cpp',
29 '../occ_presence.cpp',
30 '../occ_command.cpp',
31 '../occ_dbus.cpp',
32 '../powercap.cpp',
33 '../i2c_occ.cpp',
34 '../utils.cpp',
35]
36
37if get_option('with-host-communication-protocol')=='pldm'
38 test_sources += [
39 '../pldm.cpp',
40 ]
41endif
42
43if get_option('power10-support').enabled()
44 test_sources += [
45 '../powermode.cpp',
46 ]
47endif
48
49tests = [
50 'error_files_tests.cpp',
51 'occ_dbus_test.cpp',
52 'TestI2cOcc.cpp',
53 'utest.cpp',
54]
55
56pthread_dep = dependency('threads')
57
58foreach t : tests
59 test(t, executable(t.underscorify(), t,
60 test_sources,
61 include_directories: ['..', '../gen'],
62 dependencies: [
63 gtest_dep,
64 gmock_dep,
65 pthread_dep,
66 deps
67 ]),
68 workdir: meson.current_source_dir())
69endforeach