blob: f54bbcc3dc78eb2f37ccb92dd21e489e88e15bb8 [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'),
Patrick Williams601cea42025-02-01 08:36:51 -050011 ],
George Liubddcf852021-09-08 08:46:22 +080012 )
13 gmock_dep = gtest_proj.dependency('gmock')
Patrick Williams601cea42025-02-01 08:36:51 -050014 else
George Liubddcf852021-09-08 08:46:22 +080015 assert(
Patrick Williamsa8ebb1d2023-11-29 06:44:15 -060016 not get_option('tests').allowed(),
Patrick Williams601cea42025-02-01 08:36:51 -050017 'Googletest is required if tests are enabled',
George Liubddcf852021-09-08 08:46:22 +080018 )
Patrick Williams601cea42025-02-01 08:36:51 -050019 endif
George Liubddcf852021-09-08 08:46:22 +080020endif
21
22test_sources = [
Patrick Williams601cea42025-02-01 08:36:51 -050023 '../occ_pass_through.cpp',
24 '../occ_manager.cpp',
25 '../occ_status.cpp',
26 '../occ_device.cpp',
27 '../occ_errors.cpp',
28 '../occ_ffdc.cpp',
29 '../occ_presence.cpp',
30 '../occ_command.cpp',
31 '../occ_dbus.cpp',
32 '../powercap.cpp',
33 '../i2c_occ.cpp',
34 '../utils.cpp',
35 occ_sensor_hpp,
George Liubddcf852021-09-08 08:46:22 +080036]
37
Patrick Williams601cea42025-02-01 08:36:51 -050038if get_option('with-host-communication-protocol') == 'pldm'
39 test_sources += ['../pldm.cpp']
George Liubddcf852021-09-08 08:46:22 +080040endif
41
Patrick Williamsa8ebb1d2023-11-29 06:44:15 -060042if get_option('power10-support').allowed()
Patrick Williams601cea42025-02-01 08:36:51 -050043 test_sources += ['../powermode.cpp']
George Liubddcf852021-09-08 08:46:22 +080044endif
45
46tests = [
Patrick Williams601cea42025-02-01 08:36:51 -050047 'error_files_tests.cpp',
48 'occ_dbus_test.cpp',
49 'TestI2cOcc.cpp',
50 'utest.cpp',
George Liubddcf852021-09-08 08:46:22 +080051]
52
53pthread_dep = dependency('threads')
54
55foreach t : tests
Patrick Williams601cea42025-02-01 08:36:51 -050056 test(
57 t,
58 executable(
59 t.underscorify(),
60 t,
61 test_sources,
62 include_directories: '..',
63 dependencies: [gtest_dep, gmock_dep, pthread_dep, deps],
64 ),
65 workdir: meson.current_source_dir(),
66 )
Patrick Williamsd8aab2a2023-04-21 11:15:54 -050067endforeach