| Jagpal Singh Gill | 9695bd2 | 2025-10-01 14:38:17 -0700 | [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( |
| 16 | not get_option('tests').enabled(), |
| 17 | 'Googletest is required if tests are enabled', |
| 18 | ) |
| 19 | endif |
| 20 | endif |
| Jagpal Singh Gill | 0fffb59 | 2025-05-20 23:45:25 -0700 | [diff] [blame] | 21 | |
| Jagpal Singh Gill | 9695bd2 | 2025-10-01 14:38:17 -0700 | [diff] [blame] | 22 | test( |
| 23 | 'test_modbus_commands', |
| 24 | executable( |
| 25 | 'test_modbus_commands', |
| 26 | 'test_modbus_commands.cpp', |
| 27 | dependencies: [gtest_dep, gmock_dep, default_deps, modbus_rtu_dep], |
| 28 | include_directories: ['.'], |
| 29 | ), |
| 30 | ) |
| Jagpal Singh Gill | a32d241 | 2025-10-01 14:55:05 -0700 | [diff] [blame] | 31 | |
| 32 | test( |
| 33 | 'test_modbus', |
| 34 | executable( |
| 35 | 'test_modbus', |
| 36 | 'test_modbus.cpp', |
| 37 | 'modbus_server_tester.cpp', |
| 38 | dependencies: [gtest_dep, gmock_dep, default_deps, modbus_rtu_dep], |
| 39 | include_directories: ['.'], |
| 40 | ), |
| 41 | ) |
| Jagpal Singh Gill | 7f9d41d | 2025-10-16 09:42:18 -0700 | [diff] [blame] | 42 | |
| 43 | test( |
| 44 | 'test_port', |
| 45 | executable( |
| 46 | 'test_port', |
| 47 | 'test_port.cpp', |
| 48 | 'modbus_server_tester.cpp', |
| 49 | dependencies: [gtest_dep, gmock_dep, default_deps, modbus_rtu_dep], |
| 50 | include_directories: ['.', common_include], |
| 51 | ), |
| 52 | ) |
| Jagpal Singh Gill | cad9ecf | 2025-10-22 19:53:16 -0700 | [diff] [blame] | 53 | |
| 54 | test( |
| 55 | 'test_inventory', |
| 56 | executable( |
| 57 | 'test_inventory', |
| 58 | 'test_inventory.cpp', |
| 59 | 'modbus_server_tester.cpp', |
| 60 | inventory_src, |
| 61 | dependencies: [gtest_dep, gmock_dep, default_deps, modbus_rtu_dep], |
| 62 | include_directories: ['.', common_include], |
| 63 | ), |
| 64 | ) |
| Jagpal Singh Gill | e92aba4 | 2025-10-16 00:00:13 -0700 | [diff] [blame] | 65 | |
| 66 | test( |
| 67 | 'test_sensors', |
| 68 | executable( |
| 69 | 'test_sensors', |
| 70 | 'test_sensors.cpp', |
| 71 | 'modbus_server_tester.cpp', |
| 72 | device_src, |
| Jagpal Singh Gill | 7184805 | 2025-10-16 00:28:58 -0700 | [diff] [blame^] | 73 | link_with: [modbus_common_lib], |
| 74 | dependencies: [gtest_dep, gmock_dep, default_deps, modbus_rtu_dep], |
| 75 | include_directories: ['.', common_include], |
| 76 | ), |
| 77 | ) |
| 78 | |
| 79 | test( |
| 80 | 'test_events', |
| 81 | executable( |
| 82 | 'test_events', |
| 83 | 'test_events.cpp', |
| 84 | link_with: [modbus_common_lib], |
| Jagpal Singh Gill | e92aba4 | 2025-10-16 00:00:13 -0700 | [diff] [blame] | 85 | dependencies: [gtest_dep, gmock_dep, default_deps, modbus_rtu_dep], |
| 86 | include_directories: ['.', common_include], |
| 87 | ), |
| 88 | ) |