xref: /openbmc/phosphor-psu-code-mgmt/test/meson.build (revision 8a08ac1019f7122253630d3a9a4af0d3ddf39b7f)
1oe_sdk = get_option('oe-sdk')
2if oe_sdk.allowed()
3    # Setup OE SYSROOT
4    OECORE_TARGET_SYSROOT = run_command(
5        'sh',
6        '-c',
7        'echo $OECORE_TARGET_SYSROOT',
8    ).stdout().strip()
9    if OECORE_TARGET_SYSROOT == ''
10        error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.')
11    endif
12    message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT)
13    rpath = ':'.join(
14        [OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib'],
15    )
16    ld_so = run_command(
17        'sh',
18        '-c',
19        'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1',
20    ).stdout().strip()
21    dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so]
22else
23    dynamic_linker = []
24endif
25
26gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
27gmock = dependency('gmock', disabler: true, required: build_tests)
28
29configure_file(output: 'config.h', configuration: cdata)
30test_inc = include_directories('.')
31
32test_util = executable(
33    'test_util',
34    '../src/utils.cpp',
35    'test_utils.cpp',
36    include_directories: [psu_inc, test_inc],
37    link_args: dynamic_linker,
38    build_rpath: oe_sdk.allowed() ? rpath : '',
39    dependencies: [
40        gtest,
41        gmock,
42        phosphor_logging,
43        phosphor_dbus_interfaces,
44        sdbusplus,
45        ssl,
46    ],
47)
48
49test_phosphor_psu_manager = executable(
50    'test_phosphor_psu_manager',
51    '../src/activation.cpp',
52    '../src/item_updater.cpp',
53    '../src/version.cpp',
54    'test_item_updater.cpp',
55    'test_activation.cpp',
56    'test_version.cpp',
57    include_directories: [psu_inc, test_inc],
58    link_args: dynamic_linker,
59    build_rpath: oe_sdk.allowed() ? rpath : '',
60    dependencies: [
61        gtest,
62        gmock,
63        phosphor_logging,
64        phosphor_dbus_interfaces,
65        sdbusplus,
66        ssl,
67    ],
68)
69
70test('util', test_util)
71#test('phosphor_psu_manager', test_phosphor_psu_manager)
72test(
73    'phosphor_psu_manager',
74    test_phosphor_psu_manager,
75    workdir: meson.current_source_dir(),
76)
77