xserver

xserver with xephyr scale patch
git clone https://git.neptards.moe/u3shit/xserver.git
Log | Files | Refs | README | LICENSE

tests-common.c (678B)


      1 #include <sys/types.h>
      2 #include <sys/wait.h>
      3 #include <stdlib.h>
      4 #include <stdio.h>
      5 #include <unistd.h>
      6 
      7 #include "tests-common.h"
      8 
      9 void
     10 run_test_in_child(int (*func)(void), const char *funcname)
     11 {
     12     int cpid;
     13     int csts;
     14     int exit_code = -1;
     15 
     16     printf("\n---------------------\n%s...\n", funcname);
     17     cpid = fork();
     18     if (cpid) {
     19         waitpid(cpid, &csts, 0);
     20         if (!WIFEXITED(csts))
     21             goto child_failed;
     22         exit_code = WEXITSTATUS(csts);
     23         if (exit_code == 0)
     24             printf(" Pass\n");
     25         else {
     26 child_failed:
     27             printf(" FAIL\n");
     28             exit(exit_code);
     29         }
     30     } else {
     31         exit(func());
     32     }
     33 }