George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 1 | gtest_dep = dependency('gtest', main: true, disabler: true, required: false) |
| 2 | gmock_dep = dependency('gmock', disabler: true, required: false) |
| 3 | if 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 Williams | a8ebb1d | 2023-11-29 06:44:15 -0600 | [diff] [blame] | 16 | not get_option('tests').allowed(), |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 17 | 'Googletest is required if tests are enabled' |
| 18 | ) |
| 19 | endif |
| 20 | endif |
| 21 | |
| 22 | test_sources = [ |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 23 | '../occ_pass_through.cpp', |
| 24 | '../occ_manager.cpp', |
| 25 | '../occ_status.cpp', |
| 26 | '../occ_device.cpp', |
| 27 | '../occ_errors.cpp', |
Eddie James | 2f9f9bb | 2021-09-20 14:26:31 -0500 | [diff] [blame] | 28 | '../occ_ffdc.cpp', |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 29 | '../occ_presence.cpp', |
| 30 | '../occ_command.cpp', |
| 31 | '../occ_dbus.cpp', |
| 32 | '../powercap.cpp', |
| 33 | '../i2c_occ.cpp', |
| 34 | '../utils.cpp', |
Patrick Williams | d8aab2a | 2023-04-21 11:15:54 -0500 | [diff] [blame] | 35 | occ_sensor_hpp, |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 36 | ] |
| 37 | |
| 38 | if get_option('with-host-communication-protocol')=='pldm' |
| 39 | test_sources += [ |
| 40 | '../pldm.cpp', |
| 41 | ] |
| 42 | endif |
| 43 | |
Patrick Williams | a8ebb1d | 2023-11-29 06:44:15 -0600 | [diff] [blame] | 44 | if get_option('power10-support').allowed() |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 45 | test_sources += [ |
| 46 | '../powermode.cpp', |
| 47 | ] |
| 48 | endif |
| 49 | |
| 50 | tests = [ |
| 51 | 'error_files_tests.cpp', |
| 52 | 'occ_dbus_test.cpp', |
| 53 | 'TestI2cOcc.cpp', |
| 54 | 'utest.cpp', |
| 55 | ] |
| 56 | |
| 57 | pthread_dep = dependency('threads') |
| 58 | |
| 59 | foreach t : tests |
| 60 | test(t, executable(t.underscorify(), t, |
| 61 | test_sources, |
Patrick Williams | d8aab2a | 2023-04-21 11:15:54 -0500 | [diff] [blame] | 62 | include_directories: '..', |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 63 | dependencies: [ |
| 64 | gtest_dep, |
| 65 | gmock_dep, |
| 66 | pthread_dep, |
| 67 | deps |
| 68 | ]), |
| 69 | workdir: meson.current_source_dir()) |
Patrick Williams | d8aab2a | 2023-04-21 11:15:54 -0500 | [diff] [blame] | 70 | endforeach |