The test_demo program compares whether XDR encoded data match the
expected output as read from a file. But the file path is not
absolute and thus relative to CWD which means the program can run
only from one specific directory.
Do what we do in the rest of our test suite: define 'abs_srcdir'
macro and prefix the path with it.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
scripts/rpcgen/tests/meson.build | 4 +++-
scripts/rpcgen/tests/test_demo.c | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/scripts/rpcgen/tests/meson.build b/scripts/rpcgen/tests/meson.build
index 075b5a82cf..dfd757de7c 100644
--- a/scripts/rpcgen/tests/meson.build
+++ b/scripts/rpcgen/tests/meson.build
@@ -8,7 +8,9 @@ rpcgen_tests = files([
test_demo = executable(
'test_demo',
[ 'test_demo.c' ],
- c_args: cc_flags_relaxed_frame_limit,
+ c_args: [
+ '-Dabs_srcdir="@0(a)"'.format(meson.current_source_dir()),
+ ] + cc_flags_relaxed_frame_limit,
dependencies: [
xdr_dep, glib_dep
],
diff --git a/scripts/rpcgen/tests/test_demo.c b/scripts/rpcgen/tests/test_demo.c
index d6be9e236d..1cdb9cfb82 100644
--- a/scripts/rpcgen/tests/test_demo.c
+++ b/scripts/rpcgen/tests/test_demo.c
@@ -12,7 +12,7 @@ static void test_xdr(xdrproc_t proc, void *vorig, void *vnew, const char
*testna
/* 128kb is big enough for any of our test data */
size_t buflen = 128 * 1000;
g_autofree char *buf = g_new0(char, buflen);
- g_autofree char *expfile = g_strdup_printf("test_demo_%s.bin", testname);
+ g_autofree char *expfile = g_strdup_printf(abs_srcdir "/test_demo_%s.bin",
testname);
g_autofree char *expected = NULL;
size_t explen;
size_t actlen;
--
2.41.0