]> xenbits.xensource.com Git - libvirt.git/commitdiff
rpcgen: tests: Allow running test_demo from anywhere
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 29 Nov 2023 11:22:21 +0000 (12:22 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 29 Nov 2023 13:34:11 +0000 (14:34 +0100)
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>
scripts/rpcgen/tests/meson.build
scripts/rpcgen/tests/test_demo.c

index 075b5a82cfd0059c19442c46aca0a01af82d8a17..dfd757de7c1e0671c476eb991f43bfd0e9c4121e 100644 (file)
@@ -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@"'.format(meson.current_source_dir()),
+    ] + cc_flags_relaxed_frame_limit,
     dependencies: [
         xdr_dep, glib_dep
     ],
index d6be9e236d6e73acbd0d780ed94daedbc898028d..1cdb9cfb825ee78b885a849dd808272296659454 100644 (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 */
     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;