xref: /openbmc/phosphor-modbus/tests/meson.build (revision 7f9d41ddfad8c74d51fa1cf4a591b7f085254396)
19695bd28SJagpal Singh Gillgtest_dep = dependency('gtest', main: true, disabler: true, required: false)
29695bd28SJagpal Singh Gillgmock_dep = dependency('gmock', disabler: true, required: false)
39695bd28SJagpal Singh Gillif not gtest_dep.found() or not gmock_dep.found()
49695bd28SJagpal Singh Gill    gtest_proj = import('cmake').subproject('googletest', required: false)
59695bd28SJagpal Singh Gill    if gtest_proj.found()
69695bd28SJagpal Singh Gill        gtest_dep = declare_dependency(
79695bd28SJagpal Singh Gill            dependencies: [
89695bd28SJagpal Singh Gill                dependency('threads'),
99695bd28SJagpal Singh Gill                gtest_proj.dependency('gtest'),
109695bd28SJagpal Singh Gill                gtest_proj.dependency('gtest_main'),
119695bd28SJagpal Singh Gill            ],
129695bd28SJagpal Singh Gill        )
139695bd28SJagpal Singh Gill        gmock_dep = gtest_proj.dependency('gmock')
149695bd28SJagpal Singh Gill    else
159695bd28SJagpal Singh Gill        assert(
169695bd28SJagpal Singh Gill            not get_option('tests').enabled(),
179695bd28SJagpal Singh Gill            'Googletest is required if tests are enabled',
189695bd28SJagpal Singh Gill        )
199695bd28SJagpal Singh Gill    endif
209695bd28SJagpal Singh Gillendif
210fffb59bSJagpal Singh Gill
229695bd28SJagpal Singh Gilltest(
239695bd28SJagpal Singh Gill    'test_modbus_commands',
249695bd28SJagpal Singh Gill    executable(
259695bd28SJagpal Singh Gill        'test_modbus_commands',
269695bd28SJagpal Singh Gill        'test_modbus_commands.cpp',
279695bd28SJagpal Singh Gill        dependencies: [gtest_dep, gmock_dep, default_deps, modbus_rtu_dep],
289695bd28SJagpal Singh Gill        include_directories: ['.'],
299695bd28SJagpal Singh Gill    ),
309695bd28SJagpal Singh Gill)
31a32d241bSJagpal Singh Gill
32a32d241bSJagpal Singh Gilltest(
33a32d241bSJagpal Singh Gill    'test_modbus',
34a32d241bSJagpal Singh Gill    executable(
35a32d241bSJagpal Singh Gill        'test_modbus',
36a32d241bSJagpal Singh Gill        'test_modbus.cpp',
37a32d241bSJagpal Singh Gill        'modbus_server_tester.cpp',
38a32d241bSJagpal Singh Gill        dependencies: [gtest_dep, gmock_dep, default_deps, modbus_rtu_dep],
39a32d241bSJagpal Singh Gill        include_directories: ['.'],
40a32d241bSJagpal Singh Gill    ),
41a32d241bSJagpal Singh Gill)
42*7f9d41ddSJagpal Singh Gill
43*7f9d41ddSJagpal Singh Gilltest(
44*7f9d41ddSJagpal Singh Gill    'test_port',
45*7f9d41ddSJagpal Singh Gill    executable(
46*7f9d41ddSJagpal Singh Gill        'test_port',
47*7f9d41ddSJagpal Singh Gill        'test_port.cpp',
48*7f9d41ddSJagpal Singh Gill        'modbus_server_tester.cpp',
49*7f9d41ddSJagpal Singh Gill        dependencies: [gtest_dep, gmock_dep, default_deps, modbus_rtu_dep],
50*7f9d41ddSJagpal Singh Gill        include_directories: ['.', common_include],
51*7f9d41ddSJagpal Singh Gill    ),
52*7f9d41ddSJagpal Singh Gill)
53