xref: /openbmc/libcper/tests/meson.build (revision a84fc937)
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
30197ea120SJohn Chungrun_command('cp', '-r', '../specification/json/', meson.current_build_dir())
31c833a3acSEd Tanousrun_command(
32c833a3acSEd Tanous    'mv',
33c833a3acSEd Tanous    meson.current_build_dir() / 'json',
34c833a3acSEd Tanous    meson.current_build_dir() / 'specification',
35c833a3acSEd Tanous)
36197ea120SJohn Chung
37*a84fc937SEd Tanouscper_tests = executable(
38c833a3acSEd Tanous    'cper-tests',
39197ea120SJohn Chung    sources,
40197ea120SJohn Chung    implicit_include_directories: false,
41197ea120SJohn Chung    include_directories: include_directories(test_include_dirs),
42197ea120SJohn Chung    cpp_args: '-fpermissive',
43c833a3acSEd Tanous    dependencies: [libcper_parse, libcper_generate, json_c_dep, gtest, gmock],
44197ea120SJohn Chung)
45*a84fc937SEd Tanoustest('test-cper-tests', cper_tests)