blob: d9cc97719a235811166e62ac44c1eadb64b8007f [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',
Sheldon Bailey16a5adb2025-06-10 14:10:06 -050032 '../pldm.cpp',
Patrick Williams601cea42025-02-01 08:36:51 -050033 '../powercap.cpp',
Sheldon Bailey16a5adb2025-06-10 14:10:06 -050034 '../powermode.cpp',
Patrick Williams601cea42025-02-01 08:36:51 -050035 '../utils.cpp',
36 occ_sensor_hpp,
George Liubddcf852021-09-08 08:46:22 +080037]
38
Sheldon Bailey16a5adb2025-06-10 14:10:06 -050039tests = ['error_files_tests.cpp', 'occ_dbus_test.cpp', 'utest.cpp']
George Liubddcf852021-09-08 08:46:22 +080040
41pthread_dep = dependency('threads')
42
43foreach t : tests
Patrick Williams601cea42025-02-01 08:36:51 -050044 test(
45 t,
46 executable(
47 t.underscorify(),
48 t,
49 test_sources,
50 include_directories: '..',
51 dependencies: [gtest_dep, gmock_dep, pthread_dep, deps],
52 ),
53 workdir: meson.current_source_dir(),
54 )
Patrick Williamsd8aab2a2023-04-21 11:15:54 -050055endforeach