mirror of
https://github.com/X11Libre/xserver.git
synced 2026-04-14 17:18:09 +00:00
tests: Convert test/xi1/ to single binary
Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Mihail Konev <k.mvc@ya.ru>
This commit is contained in:
committed by
Adam Jackson
parent
ff66bca3e8
commit
371576f64b
33
test/tests-common.c
Normal file
33
test/tests-common.c
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "tests-common.h"
|
||||
|
||||
void
|
||||
run_test_in_child(int (*func)(void), const char *funcname)
|
||||
{
|
||||
int cpid;
|
||||
int csts;
|
||||
int exit_code = -1;
|
||||
|
||||
printf("\n---------------------\n%s...\n", funcname);
|
||||
cpid = fork();
|
||||
if (cpid) {
|
||||
waitpid(cpid, &csts, 0);
|
||||
if (!WIFEXITED(csts))
|
||||
goto child_failed;
|
||||
exit_code = WEXITSTATUS(csts);
|
||||
if (exit_code == 0)
|
||||
printf(" Pass\n");
|
||||
else {
|
||||
child_failed:
|
||||
printf(" FAIL\n");
|
||||
exit(exit_code);
|
||||
}
|
||||
} else {
|
||||
exit(func());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user