xref: /openbmc/openpower-hw-diags/test/meson.build (revision d195b7163dfe3dc54147932c4227c188d1076916)
18018391dSZane Shelley# Get the gtest/gmock dependencies.
28018391dSZane Shelleygtest_dep = dependency('gtest', main: true, disabler: true, required: false)
38018391dSZane Shelleygmock_dep = dependency('gmock', disabler: true, required: false)
48018391dSZane Shelleyif not gtest_dep.found() or not gmock_dep.found()
58018391dSZane Shelley    cmake = import('cmake')
68018391dSZane Shelley    gtest_proj = cmake.subproject('googletest',
78018391dSZane Shelley                                  required: false)
88018391dSZane Shelley    if gtest_proj.found()
98018391dSZane Shelley        gtest_dep = declare_dependency(
108018391dSZane Shelley            dependencies: [
118018391dSZane Shelley                dependency('threads'),
128018391dSZane Shelley                gtest_proj.dependency('gtest'),
138018391dSZane Shelley                gtest_proj.dependency('gtest_main'),
148018391dSZane Shelley            ]
158018391dSZane Shelley        )
168018391dSZane Shelley        gmock_dep = gtest_proj.dependency('gmock')
178018391dSZane Shelley    else
188018391dSZane Shelley        assert(not get_option('tests').enabled(),
198018391dSZane Shelley               'Googletest is required if tests are enabled')
208018391dSZane Shelley    endif
218018391dSZane Shelleyendif
228018391dSZane Shelley
230c44c2feSZane Shelleytest_arg = [
240c44c2feSZane Shelley    '-DTEST_TRACE',
250c44c2feSZane Shelley]
260c44c2feSZane Shelley
27afc6acdaSZane Shelley# Compile the test dts into a binary for pdbg.
28afc6acdaSZane Shelleypdbg_test_dtb = custom_target('build_pdbg_test_dtb',
29afc6acdaSZane Shelley    input   : files('pdbg_test.dts'),
30afc6acdaSZane Shelley    output  : 'pdbg_test.dtb',
31afc6acdaSZane Shelley    command : [ find_program('dtc'), '-I', 'dts', '-O', 'dtb',
32afc6acdaSZane Shelley                '-o', '@OUTPUT@', '@INPUT@' ])
33afc6acdaSZane Shelley
34*d195b716SZane Shelleypdbg_env = 'PDBG_DTB=' + pdbg_test_dtb.full_path()
35*d195b716SZane Shelley
369ae5ca41SBen Tyner# end2end code exerciser for experiment and testing
379ae5ca41SBen Tynersubdir('end2end')
389ae5ca41SBen Tyner
39248cbf83SZane Shelleytests = [
40d26298b1SZane Shelley  'bin_stream_test',
41982f1722SZane Shelley  'ffdc_file_test',
420b8368cbSZane Shelley  'resolution_test',
4335257fd2Saustinfcui  'pdbg_dts_test',
44e90b85dcSZane Shelley  'test-lpc-timeout',
452c228cdcSZane Shelley  'test-pll-unlock',
46248cbf83SZane Shelley]
47248cbf83SZane Shelley
48979e2871SZane Shelleyanalyzer_src = files(
492c228cdcSZane Shelley  '../analyzer/plugins/p10-plugins.cpp',
50979e2871SZane Shelley  '../analyzer/service_data.cpp',
51cb766a45SZane Shelley  '../analyzer/resolution.cpp',
52cb766a45SZane Shelley)
53cb766a45SZane Shelley
54cb766a45SZane Shelley# We cannot link to `util_lib` because that is built without `-DTEST_TRACE` and
55cb766a45SZane Shelley# any of the util functions that use `trace.hpp` will throw a linker error
56cb766a45SZane Shelley# because we don't have access to phosphor-logging in test ... yet.
57cb766a45SZane Shelleyutil_src = files(
58cb766a45SZane Shelley    '../util/ffdc_file.cpp',
59cb766a45SZane Shelley    '../util/pdbg.cpp',
60cb766a45SZane Shelley    '../util/temporary_file.cpp',
61979e2871SZane Shelley)
62979e2871SZane Shelley
63e90b85dcSZane Shelleysim_src = files(
64e90b85dcSZane Shelley  'pdbg-sim-only.cpp',
65e90b85dcSZane Shelley)
66e90b85dcSZane Shelley
67248cbf83SZane Shelleyforeach t : tests
68afc6acdaSZane Shelley    test(t,
69afc6acdaSZane Shelley         executable(t.underscorify(),
70cb766a45SZane Shelley                    [ files(t + '.cpp'), pdbg_test_dtb,
71e90b85dcSZane Shelley                      analyzer_src, util_src, sim_src ],
72cb766a45SZane Shelley                    dependencies : [ libhei_dep, libpdbg_dep, gtest_dep ],
738af9e46fSZane Shelley                    cpp_args : test_arg,
74afc6acdaSZane Shelley                    include_directories : incdir),
75*d195b716SZane Shelley         env : pdbg_env)
76248cbf83SZane Shelleyendforeach
77*d195b716SZane Shelley
78*d195b716SZane Shelley################################################################################
79*d195b716SZane Shelley
80*d195b716SZane Shelleytc = 'test-tod-step-check-fault'
81*d195b716SZane Shelley
82*d195b716SZane Shelleysrc = [
83*d195b716SZane Shelley  files(
84*d195b716SZane Shelley    tc + '.cpp',
85*d195b716SZane Shelley    '../analyzer/plugins/p10-tod-plugins.cpp',
86*d195b716SZane Shelley    '../analyzer/service_data.cpp',
87*d195b716SZane Shelley    '../util/pdbg.cpp',
88*d195b716SZane Shelley  ),
89*d195b716SZane Shelley  pdbg_test_dtb,
90*d195b716SZane Shelley]
91*d195b716SZane Shelley
92*d195b716SZane Shelleydep = [ libhei_dep, libpdbg_dep, gtest_dep ]
93*d195b716SZane Shelley
94*d195b716SZane Shelleyvar = [ pdbg_env ]
95*d195b716SZane Shelley
96*d195b716SZane Shelleyexe = executable(tc.underscorify(), src, dependencies: dep,
97*d195b716SZane Shelley                 cpp_args: test_arg, include_directories: incdir)
98*d195b716SZane Shelley
99*d195b716SZane Shelleytest(tc, exe, env: var)
100*d195b716SZane Shelley
101