xref: /openbmc/openpower-hw-diags/test/meson.build (revision 5dbebde0ac628a62afc0a6a9acb5cc3dd69c5587)
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
239491cdb4SZane Shelley################################################################################
249491cdb4SZane Shelley
25afc6acdaSZane Shelley# Compile the test dts into a binary for pdbg.
26afc6acdaSZane Shelleypdbg_test_dtb = custom_target('build_pdbg_test_dtb',
2708c21c25SZane Shelley    input   : files('pdbg-test.dts'),
2808c21c25SZane Shelley    output  : 'pdbg-test.dtb',
29afc6acdaSZane Shelley    command : [ find_program('dtc'), '-I', 'dts', '-O', 'dtb',
30afc6acdaSZane Shelley                '-o', '@OUTPUT@', '@INPUT@' ])
31afc6acdaSZane Shelley
32d195b716SZane Shelleypdbg_env = 'PDBG_DTB=' + pdbg_test_dtb.full_path()
33d195b716SZane Shelley
3408c21c25SZane Shelley################################################################################
3508c21c25SZane Shelley
36*5dbebde0Saustinfcui# Add gtest/gmock dependency to the list of test dependencies.
37985388a8SZane Shelleytest_deps = [
38*5dbebde0Saustinfcui  test_util_deps,
39985388a8SZane Shelley  gtest_dep,
40985388a8SZane Shelley]
41985388a8SZane Shelley
42985388a8SZane Shelleytest_vars = [
43985388a8SZane Shelley  pdbg_env,
4420ed74dbSZane Shelley  'LG2_FORCE_STDERR=true',
45985388a8SZane Shelley]
46985388a8SZane Shelley
4769e3771fSZane Shelley# Additional SRCs that are not (or should not be) included in libraries.
4869e3771fSZane Shelley# NOTE: Try to limit this, if possible, to prevent duplicate compilation.
4969e3771fSZane Shelleytest_additional_srcs = [
50*5dbebde0Saustinfcui  files(
512c228cdcSZane Shelley    '../analyzer/plugins/p10-plugins.cpp',
52d195b716SZane Shelley    '../analyzer/plugins/p10-tod-plugins.cpp',
53edfcbc38SZane Shelley    '../cli.cpp',
54*5dbebde0Saustinfcui  ),
55*5dbebde0Saustinfcui  pdbg_test_dtb
56edfcbc38SZane Shelley]
57edfcbc38SZane Shelley
5869e3771fSZane Shelley################################################################################
59edfcbc38SZane Shelley
6069e3771fSZane Shelleytestcases = [
6169e3771fSZane Shelley  'test-bin-stream',
6269e3771fSZane Shelley  'test-ffdc-file',
6369e3771fSZane Shelley  'test-lpc-timeout',
6469e3771fSZane Shelley  'test-pdbg-dts',
6569e3771fSZane Shelley  'test-pll-unlock',
6669e3771fSZane Shelley  'test-resolution',
6769e3771fSZane Shelley  'test-tod-step-check-fault',
6869e3771fSZane Shelley]
69edfcbc38SZane Shelley
7069e3771fSZane Shelleyforeach tc : testcases
7169e3771fSZane Shelley
7269e3771fSZane Shelley  exe = executable(tc.underscorify(),
7369e3771fSZane Shelley    sources             : [ files(tc + '.cpp'), test_additional_srcs ],
7469e3771fSZane Shelley    include_directories : incdir,
7569e3771fSZane Shelley    dependencies        : test_deps,
7669e3771fSZane Shelley    cpp_args            : test_args,
7769e3771fSZane Shelley    link_with           : test_libs,
7869e3771fSZane Shelley  )
7969e3771fSZane Shelley
8069e3771fSZane Shelley  test(tc, exe, env: test_vars)
8169e3771fSZane Shelley
8269e3771fSZane Shelleyendforeach
8369e3771fSZane Shelley
8469e3771fSZane Shelley################################################################################
8569e3771fSZane Shelley
8669e3771fSZane Shelleytestcases = [
8769e3771fSZane Shelley  'test-attention',
8869e3771fSZane Shelley  'test-end2end',
8969e3771fSZane Shelley  'test-util-data-file',
9069e3771fSZane Shelley  'test-ti-handler',
9169e3771fSZane Shelley]
9269e3771fSZane Shelley
9369e3771fSZane Shelleyforeach tc : testcases
9469e3771fSZane Shelley
9569e3771fSZane Shelley  exe = executable(tc.underscorify(),
9669e3771fSZane Shelley    sources             : [ files(tc + '.cpp'), test_additional_srcs ],
9769e3771fSZane Shelley    include_directories : incdir,
9869e3771fSZane Shelley    dependencies        : test_deps,
9969e3771fSZane Shelley    cpp_args            : test_args,
100985388a8SZane Shelley    link_with           : hwdiags_libs, # TODO: should use test_libs instead
10169e3771fSZane Shelley  )
102edfcbc38SZane Shelley
10369e3771fSZane Shelley  test(tc, exe, env: test_vars)
10469e3771fSZane Shelley
10569e3771fSZane Shelleyendforeach
106edfcbc38SZane Shelley
107