[PATCH] tests: add NO_FORK option

Marek Chalupa mchqwerty at gmail.com
Wed Aug 6 02:23:42 PDT 2014


When WAYLAND_TEST_NO_FORK environment variable is set, then
do not run the test in fork. It's convenient for debugging

Signed-off-by: Marek Chalupa <mchqwerty at gmail.com>
---
 tests/test-runner.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tests/test-runner.c b/tests/test-runner.c
index 8f3d5d3..4f363a0 100644
--- a/tests/test-runner.c
+++ b/tests/test-runner.c
@@ -137,7 +137,7 @@ int main(int argc, char *argv[])
 {
 	const struct test *t;
 	pid_t pid;
-	int total, pass;
+	int total, pass, no_fork = 0;
 	siginfo_t info;
 
 	/* Load system malloc, free, and realloc */
@@ -147,6 +147,7 @@ int main(int argc, char *argv[])
 	sys_free = dlsym(RTLD_NEXT, "free");
 
 	leak_check_enabled = !getenv("NO_ASSERT_LEAK_CHECK");
+	no_fork = !!getenv("WAYLAND_TESTS_NO_FORK");
 
 	if (argc == 2 && strcmp(argv[1], "--help") == 0)
 		usage(argv[0], EXIT_SUCCESS);
@@ -165,6 +166,12 @@ int main(int argc, char *argv[])
 	for (t = &__start_test_section; t < &__stop_test_section; t++) {
 		int success = 0;
 
+		/* no_fork option is useful for debuging */
+		if (no_fork) {
+			run_test(t);
+			continue;
+		}
+
 		pid = fork();
 		assert(pid >= 0);
 
-- 
2.0.4



More information about the wayland-devel mailing list