xref: /openbmc/phosphor-led-manager/test/meson.build (revision 42a4acb88a7cd54b9e267544d0a15b06cf95cec7)
1gtest_dep = dependency('gtest', main: true, disabler: true, required: false)
2gmock_dep = dependency('gmock', disabler: true, required: false)
3if 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').allowed(),
17            'Googletest is required if tests are enabled',
18        )
19    endif
20endif
21
22test_yamls = ['test-empty-group', 'test-group-priority', 'test-led-priority']
23
24test_sources = [
25    '../manager/manager.cpp',
26    '../manager/config-validator.cpp',
27    '../utils.cpp',
28]
29
30foreach yaml : test_yamls
31    gen_hpp = custom_target(
32        yaml + '.hpp',
33        command: [
34            prog_python,
35            meson.project_source_root() + '/scripts/parse_led.py',
36            '--filename',
37            meson.project_source_root() + '/test/config/' + yaml + '.yaml',
38            '-o',
39            meson.current_build_dir(),
40            '--output-filename',
41            yaml + '.hpp',
42        ],
43        output: yaml + '.hpp',
44    )
45
46    test_sources += [gen_hpp]
47endforeach
48
49tests = [
50    'utest.cpp',
51    'utest-led-json.cpp',
52    'utest-group-priority.cpp',
53    'utest-led-yaml-group-priority.cpp',
54    'utest-led-yaml-led-priority.cpp',
55    'utest-led-yaml-empty-group.cpp',
56    'utest-config-validator.cpp',
57]
58if get_option('persistent-led-asserted').allowed()
59    test_sources += ['../manager/serialize.cpp']
60    tests += ['utest-serialize.cpp']
61endif
62
63foreach t : tests
64    test(
65        t,
66        executable(
67            t.underscorify(),
68            t,
69            test_sources,
70            include_directories: ['..', '../manager'],
71            dependencies: [gtest_dep, gmock_dep, deps],
72        ),
73        workdir: meson.current_source_dir(),
74    )
75endforeach
76