From e01f525b49f397322ada23b1be5b2f734fb71327 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Mon, 18 Nov 2019 08:37:58 +0100 Subject: add fork test --- drmtest.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drmtest.c b/drmtest.c index 1ed4f9c..ddaa1b6 100644 --- a/drmtest.c +++ b/drmtest.c @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -347,7 +348,7 @@ int main(int argc, char **argv) bool dmabuf = false; bool autotest = false; bool pixman = false; - int c,i; + int c,i,pid,rc; for (;;) { c = getopt(argc, argv, "hpdaL:c:s:o:i:f:m:"); @@ -462,6 +463,26 @@ int main(int argc, char **argv) drm_show_fb(); drm_check_content("post-show content"); + pid = fork(); + if (pid == 0) { + test_passed = 0; + test_failed = 0; + drm_check_content("post-fork content"); + rc = (test_failed << 4) | + (test_passed << 0); + exit(rc); + } else { + int status = 0; + waitpid(pid, &status, 0); + if (WIFEXITED(status)) { + rc = WEXITSTATUS(status); + test_passed += (rc >> 0) & 0x0f; + test_failed += (rc >> 4) & 0x0f; + } else { + test_failed++; + } + } + if (autotest) fprintf(stdout, "---ok---\n"); tty_raw(); -- cgit