mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
Support running tests from different build directories
The tests that run exec-fd-leak-checker expect the binary to be located in the current directory. This is not always the case; for instance, the binaries could be built under `tests`, but be invoked under the top-level build directory. We can use an environment variable to control what's the location of the test binaries, and fall back to the current directory if the variable is unset. Reviewed-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
parent
8497144faa
commit
a77f6bf6c4
1 changed files with 11 additions and 2 deletions
|
|
@ -29,6 +29,7 @@
|
|||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
|
@ -67,11 +68,19 @@ count_open_fds(void)
|
|||
void
|
||||
exec_fd_leak_check(int nr_expected_fds)
|
||||
{
|
||||
const char *exe = "./exec-fd-leak-checker";
|
||||
const char *exe = "exec-fd-leak-checker";
|
||||
char number[16] = { 0 };
|
||||
const char *test_build_dir = getenv("TEST_BUILD_DIR");
|
||||
char exe_path[256] = { 0 };
|
||||
|
||||
if (test_build_dir == NULL || test_build_dir[0] == 0) {
|
||||
test_build_dir = ".";
|
||||
}
|
||||
|
||||
snprintf(exe_path, sizeof exe_path - 1, "%s/%s", test_build_dir, exe);
|
||||
|
||||
snprintf(number, sizeof number - 1, "%d", nr_expected_fds);
|
||||
execl(exe, exe, number, (char *)NULL);
|
||||
execl(exe_path, exe, number, (char *)NULL);
|
||||
assert(0 && "execing fd leak checker failed");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue