xref: /openbmc/openpower-vpd-parser/test/meson.build (revision fa5e4d325ef9cea3c841fe89d202c340f92bd8c6)
1*fa5e4d32SSunny Srivastavagtest_dep = dependency('gtest', main: true, disabler: true, required: false)
2*fa5e4d32SSunny Srivastavagmock_dep = dependency('gmock', disabler: true, required: false)
3*fa5e4d32SSunny Srivastavalibgpiodcxx = dependency(
4*fa5e4d32SSunny Srivastava            'libgpiodcxx',
5*fa5e4d32SSunny Srivastava            default_options: ['bindings=cxx'],
6*fa5e4d32SSunny Srivastava        )
7*fa5e4d32SSunny Srivastavaif not gtest_dep.found() or not gmock_dep.found()
8*fa5e4d32SSunny Srivastava    cmake = import('cmake')
9*fa5e4d32SSunny Srivastava    gtest_opts = cmake.subproject_options()
10*fa5e4d32SSunny Srivastava    gtest_opts.set_override_option('warning_level', '1')
11*fa5e4d32SSunny Srivastava    gtest_opts.set_override_option('werror', 'false')
12*fa5e4d32SSunny Srivastava    gtest_proj = cmake.subproject('googletest',
13*fa5e4d32SSunny Srivastava                                  options: gtest_opts,
14*fa5e4d32SSunny Srivastava                                  required: false)
15*fa5e4d32SSunny Srivastava    if gtest_proj.found()
16*fa5e4d32SSunny Srivastava        gtest_dep = declare_dependency(
17*fa5e4d32SSunny Srivastava            dependencies: [
18*fa5e4d32SSunny Srivastava                dependency('threads'),
19*fa5e4d32SSunny Srivastava                gtest_proj.dependency('gtest'),
20*fa5e4d32SSunny Srivastava                gtest_proj.dependency('gtest_main'),
21*fa5e4d32SSunny Srivastava            ]
22*fa5e4d32SSunny Srivastava        )
23*fa5e4d32SSunny Srivastava        gmock_dep = gtest_proj.dependency('gmock')
247ef54422SSunnySrivastava1984  else
25*fa5e4d32SSunny Srivastava        assert(
26*fa5e4d32SSunny Srivastava            not get_option('tests').allowed(),
27*fa5e4d32SSunny Srivastava            'Googletest is required if tests are enabled'
28*fa5e4d32SSunny Srivastava        )
297ef54422SSunnySrivastava1984  endif
30*fa5e4d32SSunny Srivastavaendif
317ef54422SSunnySrivastava1984
32*fa5e4d32SSunny Srivastavaparser_build_arguments = []
33*fa5e4d32SSunny Srivastavaif get_option('ipz_ecc_check').enabled()
34*fa5e4d32SSunny Srivastava    parser_build_arguments += ['-DIPZ_ECC_CHECK']
35*fa5e4d32SSunny Srivastavaendif
367ef54422SSunnySrivastava1984
37*fa5e4d32SSunny Srivastavadependency_list = [gtest_dep, gmock_dep, sdbusplus, libgpiodcxx]
38*fa5e4d32SSunny Srivastava
39*fa5e4d32SSunny Srivastavaconfiguration_inc = include_directories('..', '../vpd-manager/include', '../vpdecc')
40*fa5e4d32SSunny Srivastava
41*fa5e4d32SSunny Srivastavatest_sources = [
42*fa5e4d32SSunny Srivastava  '../vpd-manager/src/logger.cpp',
43*fa5e4d32SSunny Srivastava  '../vpd-manager/src/ddimm_parser.cpp',
44*fa5e4d32SSunny Srivastava  '../vpd-manager/src/parser.cpp',
45*fa5e4d32SSunny Srivastava  '../vpd-manager/src/parser_factory.cpp',
46*fa5e4d32SSunny Srivastava  '../vpd-manager/src/isdimm_parser.cpp',
47*fa5e4d32SSunny Srivastava  '../vpd-manager/src/ipz_parser.cpp',
48*fa5e4d32SSunny Srivastava  '../vpd-manager/src/keyword_vpd_parser.cpp',
49*fa5e4d32SSunny Srivastava  '../vpd-manager/src/event_logger.cpp',
50*fa5e4d32SSunny Srivastava  '../vpdecc/vpdecc.c'
517ef54422SSunnySrivastava1984]
5297f8df0eSSunnySrivastava1984
53*fa5e4d32SSunny Srivastavatests = [
54*fa5e4d32SSunny Srivastava  'utest_utils.cpp',
55*fa5e4d32SSunny Srivastava  'utest_keyword_parser.cpp',
56*fa5e4d32SSunny Srivastava  'utest_ddimm_parser.cpp',
57*fa5e4d32SSunny Srivastava  'utest_ipz_parser.cpp',
58*fa5e4d32SSunny Srivastava  'utest_json_utility.cpp'
597ef54422SSunnySrivastava1984]
6097f8df0eSSunnySrivastava1984
61*fa5e4d32SSunny Srivastavaforeach test_file : tests
62*fa5e4d32SSunny Srivastava  test(test_file, executable(test_file.underscorify(),
63*fa5e4d32SSunny Srivastava                     test_file,
64*fa5e4d32SSunny Srivastava                     test_sources,
65a4a2adfaSPriyanga Ramasamy                     include_directories: configuration_inc,
66*fa5e4d32SSunny Srivastava                     dependencies: dependency_list,
67*fa5e4d32SSunny Srivastava                     cpp_args: parser_build_arguments
687ef54422SSunnySrivastava1984                     ),
697ef54422SSunnySrivastava1984       workdir: meson.current_source_dir())
707ef54422SSunnySrivastava1984endforeach
71