xref: /openbmc/libcper/tests/meson.build (revision 9fe2cb5f)
1197ea120SJohn Chunggtest = dependency('gtest', main: true, disabler: true, required: false)
2197ea120SJohn Chunggmock = dependency('gmock', disabler: true, required: false)
3197ea120SJohn Chungif not gtest.found() or not gmock.found()
4197ea120SJohn Chung    gtest_proj = import('cmake').subproject('googletest', required: false)
5197ea120SJohn Chung    if gtest_proj.found()
6197ea120SJohn Chung        gtest = declare_dependency(
7197ea120SJohn Chung            dependencies: [
8197ea120SJohn Chung                dependency('threads'),
9197ea120SJohn Chung                gtest_proj.dependency('gtest'),
10197ea120SJohn Chung                gtest_proj.dependency('gtest_main'),
11c833a3acSEd Tanous            ],
12197ea120SJohn Chung        )
13197ea120SJohn Chung        gmock = gtest_proj.dependency('gmock')
14197ea120SJohn Chung    else
15197ea120SJohn Chung        assert(
16197ea120SJohn Chung            not get_option('tests').allowed(),
17c833a3acSEd Tanous            'Googletest is required if tests are enabled',
18197ea120SJohn Chung        )
19197ea120SJohn Chung    endif
20197ea120SJohn Chungendif
21197ea120SJohn Chung
22197ea120SJohn Chungsources = [
23197ea120SJohn Chung    'ir-tests.cpp',
24197ea120SJohn Chung    'test-utils.cpp',
25a7d2cdddSEd Tanous    'base64_test.cpp',
26197ea120SJohn Chung]
27197ea120SJohn Chung
28197ea120SJohn Chungtest_include_dirs = ['.', '..']
29197ea120SJohn Chung
30a84fc937SEd Tanouscper_tests = executable(
31c833a3acSEd Tanous    'cper-tests',
32197ea120SJohn Chung    sources,
33197ea120SJohn Chung    implicit_include_directories: false,
34197ea120SJohn Chung    include_directories: include_directories(test_include_dirs),
35197ea120SJohn Chung    cpp_args: '-fpermissive',
36*9fe2cb5fSKarthik Rajagopalan    dependencies: [libcper_parse_dep, libcper_generate_dep, json_c_dep, gtest, gmock],
37197ea120SJohn Chung)
38a84fc937SEd Tanoustest('test-cper-tests', cper_tests)
39