Skip to content

Commit

Permalink
test(x11): Warn for missing Xvfb program
Browse files Browse the repository at this point in the history
Xvfb is required for *running* X11 tests. We do not make it mandatory
in the meson setup though, because we did not find a way to require a
*run* time dependency.
  • Loading branch information
wismill committed Mar 25, 2024
1 parent 4052a64 commit d1547f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,10 @@ test(
env: test_env,
)
if get_option('enable-x11')
has_xvfb = find_program("Xvfb", required=false)
if not has_xvfb.found()
warning('Xvfb program not found, but is required to run X11 tests.')
endif
test(
'x11',
executable('test-x11', 'test/x11.c', dependencies: x11_test_dep),
Expand Down
6 changes: 5 additions & 1 deletion test/xvfb-wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ xvfb_wrapper(int (*test_func)(char* display))
goto err_display_fd;
}
snprintf(display_fd_string, sizeof(display_fd_string), "%d", fileno(display_fd));
fprintf(stderr, "display_fd_string: %s\n", display_fd_string);

/* Set SIGUSR1 to SIG_IGN so Xvfb will send us that signal
* when it's ready to accept connections */
Expand All @@ -92,6 +91,11 @@ xvfb_wrapper(int (*test_func)(char* display))
ret = posix_spawnp(&xvfb_pid, "Xvfb", NULL, NULL, xvfb_argv, envp);
if (ret != 0) {
fprintf(stderr, "posix_spawnp error %d: %s\n", ret, strerror(ret));
if (ret == ENOENT) {
fprintf(stderr,
"Xvfb may be missing. Please install the corresponding "
"package, e.g. \"xvfb\" or \"xorg-x11-server-Xvfb\".\n");
}
ret = TEST_SETUP_FAILURE;
goto err_xvfd;
}
Expand Down

0 comments on commit d1547f1

Please sign in to comment.