rpcgen: tests: Allow running test_demo from anywhere

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@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Michal Privoznik 2023-11-29 12:22:21 +01:00
parent 944fe54b6e
commit dec02f101e
2 changed files with 4 additions and 2 deletions

View File

@ -8,7 +8,9 @@ rpcgen_tests = files([
test_demo = executable( test_demo = executable(
'test_demo', 'test_demo',
[ 'test_demo.c' ], [ 'test_demo.c' ],
c_args: cc_flags_relaxed_frame_limit, c_args: [
'-Dabs_srcdir="@0@"'.format(meson.current_source_dir()),
] + cc_flags_relaxed_frame_limit,
dependencies: [ dependencies: [
xdr_dep, glib_dep xdr_dep, glib_dep
], ],

View File

@ -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 */ /* 128kb is big enough for any of our test data */
size_t buflen = 128 * 1000; size_t buflen = 128 * 1000;
g_autofree char *buf = g_new0(char, buflen); 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; g_autofree char *expected = NULL;
size_t explen; size_t explen;
size_t actlen; size_t actlen;