Create test-only version of util_lib
Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
Change-Id: Ifd63af2772b936ec07ca4bbcf13c70429ffd5693
diff --git a/test/meson.build b/test/meson.build
index ed7ef5c..d34e59b 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -22,16 +22,6 @@
################################################################################
-# NOTE: We cannot link to `util_lib` because that is built without
-# `-DTEST_TRACE` and any of the util functions that use `trace.hpp` will
-# throw a linker error because we don't have access to phosphor-logging
-# in test ... yet.
-
-test_arg = [
- '-DTEST_TRACE',
- package_args,
-]
-
# Compile the test dts into a binary for pdbg.
pdbg_test_dtb = custom_target('build_pdbg_test_dtb',
input : files('pdbg-test.dts'),
@@ -43,6 +33,58 @@
################################################################################
+# IMPORTANT NOTE:
+# We cannot link to `util_lib` because:
+# - It is built without `-DTEST_TRACE` and any of the util functions that use
+# `trace.hpp` will throw a linker error because we don't have access to
+# phosphor-logging in test ... yet.
+# - Some functions related to pdbg and dbus simply cannot be built in the test
+# environment. Instead, there are alternate implementation of those
+# functions to simulate them for testing.
+
+test_args = [
+ '-DTEST_TRACE',
+ package_args,
+]
+
+test_util_srcs = [
+ files(
+ '../util/data_file.cpp',
+ '../util/ffdc_file.cpp',
+ '../util/pdbg.cpp',
+ '../util/temporary_file.cpp',
+ 'dbus-sim-only.cpp',
+ 'pdbg-sim-only.cpp',
+ ),
+ pdbg_test_dtb
+]
+
+test_deps = [
+ libhei_dep,
+ libpdbg_dep,
+ gtest_dep,
+]
+
+test_vars = [
+ pdbg_env,
+]
+
+test_util_lib = static_library('test_util_lib',
+ sources : test_util_srcs,
+ include_directories : incdir,
+ dependencies : test_deps,
+ cpp_args : test_args,
+ install : false,
+)
+
+test_libs = [
+ analyzer_lib,
+ attn_lib,
+ test_util_lib,
+]
+
+################################################################################
+
tc = 'test-bin-stream'
src = [
@@ -56,7 +98,8 @@
var = [ ]
exe = executable(tc.underscorify(), src, dependencies: dep,
- cpp_args: test_arg, include_directories: incdir)
+ link_with: test_libs,
+ cpp_args: test_args, include_directories: incdir)
test(tc, exe, env: var)
@@ -67,8 +110,6 @@
src = [
files(
tc + '.cpp',
- '../util/ffdc_file.cpp',
- '../util/temporary_file.cpp',
),
]
@@ -77,7 +118,8 @@
var = [ ]
exe = executable(tc.underscorify(), src, dependencies: dep,
- cpp_args: test_arg, include_directories: incdir)
+ link_with: test_libs,
+ cpp_args: test_args, include_directories: incdir)
test(tc, exe, env: var)
@@ -89,12 +131,7 @@
files(
tc + '.cpp',
'../analyzer/plugins/p10-plugins.cpp',
- '../analyzer/service_data.cpp',
- '../util/pdbg.cpp',
- 'dbus-sim-only.cpp',
- 'pdbg-sim-only.cpp',
),
- pdbg_test_dtb,
]
dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
@@ -102,7 +139,8 @@
var = [ pdbg_env ]
exe = executable(tc.underscorify(), src, dependencies: dep,
- cpp_args: test_arg, include_directories: incdir)
+ link_with: test_libs,
+ cpp_args: test_args, include_directories: incdir)
test(tc, exe, env: var)
@@ -113,11 +151,7 @@
src = [
files(
tc + '.cpp',
- '../util/pdbg.cpp',
- 'dbus-sim-only.cpp',
- 'pdbg-sim-only.cpp',
),
- pdbg_test_dtb,
]
dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
@@ -125,7 +159,8 @@
var = [ pdbg_env ]
exe = executable(tc.underscorify(), src, dependencies: dep,
- cpp_args: test_arg, include_directories: incdir)
+ link_with: test_libs,
+ cpp_args: test_args, include_directories: incdir)
test(tc, exe, env: var)
@@ -137,15 +172,7 @@
files(
tc + '.cpp',
'../analyzer/plugins/p10-plugins.cpp',
- '../analyzer/ras-data/ras-data-parser.cpp',
- '../analyzer/resolution.cpp',
- '../analyzer/service_data.cpp',
- '../util/data_file.cpp',
- '../util/pdbg.cpp',
- 'dbus-sim-only.cpp',
- 'pdbg-sim-only.cpp',
),
- pdbg_test_dtb,
]
dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
@@ -153,7 +180,8 @@
var = [ pdbg_env ]
exe = executable(tc.underscorify(), src, dependencies: dep,
- cpp_args: test_arg, include_directories: incdir)
+ link_with: test_libs,
+ cpp_args: test_args, include_directories: incdir)
test(tc, exe, env: var)
@@ -164,13 +192,7 @@
src = [
files(
tc + '.cpp',
- '../analyzer/resolution.cpp',
- '../analyzer/service_data.cpp',
- '../util/pdbg.cpp',
- 'dbus-sim-only.cpp',
- 'pdbg-sim-only.cpp',
),
- pdbg_test_dtb,
]
dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
@@ -178,7 +200,8 @@
var = [ pdbg_env ]
exe = executable(tc.underscorify(), src, dependencies: dep,
- cpp_args: test_arg, include_directories: incdir)
+ link_with: test_libs,
+ cpp_args: test_args, include_directories: incdir)
test(tc, exe, env: var)
@@ -190,12 +213,7 @@
files(
tc + '.cpp',
'../analyzer/plugins/p10-tod-plugins.cpp',
- '../analyzer/service_data.cpp',
- '../util/pdbg.cpp',
- 'dbus-sim-only.cpp',
- 'pdbg-sim-only.cpp',
),
- pdbg_test_dtb,
]
dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
@@ -203,7 +221,8 @@
var = [ pdbg_env ]
exe = executable(tc.underscorify(), src, dependencies: dep,
- cpp_args: test_arg, include_directories: incdir)
+ link_with: test_libs,
+ cpp_args: test_args, include_directories: incdir)
test(tc, exe, env: var)
@@ -222,8 +241,8 @@
var = [ ]
exe = executable(tc.underscorify(), src, dependencies: dep,
- link_with : hwdiags_libs,
- cpp_args: test_arg, include_directories: incdir)
+ link_with : hwdiags_libs, # TODO: should use test_libs instead
+ cpp_args: test_args, include_directories: incdir)
test(tc, exe, env: var)
@@ -243,8 +262,8 @@
var = [ pdbg_env ]
exe = executable(tc.underscorify(), src, dependencies: dep,
- link_with : hwdiags_libs,
- cpp_args: test_arg, include_directories: incdir)
+ link_with : hwdiags_libs, # TODO: should use test_libs instead
+ cpp_args: test_args, include_directories: incdir)
test(tc, exe, env: var)
@@ -263,8 +282,8 @@
var = [ ]
exe = executable(tc.underscorify(), src, dependencies: dep,
- link_with : hwdiags_libs,
- cpp_args: test_arg, include_directories: incdir)
+ link_with : hwdiags_libs, # TODO: should use test_libs instead
+ cpp_args: test_args, include_directories: incdir)
test(tc, exe, env: var)
@@ -285,8 +304,8 @@
var = [ pdbg_env ]
exe = executable(tc.underscorify(), src, dependencies: dep,
- link_with : hwdiags_libs,
- cpp_args: test_arg, include_directories: incdir)
+ link_with : hwdiags_libs, # TODO: should use test_libs instead
+ cpp_args: test_args, include_directories: incdir)
test(tc, exe, env: var)