2 * A Wrapper for Interactive Tests
4 * (c) 2001 Martin Mares <mj@ucw.cz>
19 #include <sys/ptrace.h>
20 #include <sys/signal.h>
21 #include <sys/sysinfo.h>
22 #include <sys/syscall.h>
23 #include <sys/resource.h>
25 #define NONRET __attribute__((noreturn))
26 #define UNUSED __attribute__((unused))
28 static void NONRET __attribute__((format(printf,1,2)))
33 vfprintf(stderr, msg, args);
44 while (c = read(fd, buf, sizeof(buf)))
49 main(int argc, char **argv)
54 int inpipe[2], outpipe[2], boxepipe[2], chkepipe[2];
55 int exited = 0, sbox, schk;
57 for (sep=1; sep < argc; sep++)
58 if (!strcmp(argv[sep], "@@"))
61 die("Usage: iwrapper <testee> @@ <tester>");
63 abox = alloca((nbox+1) * sizeof(char *));
64 memcpy(abox, argv+1, nbox*sizeof(char *));
66 nchk = argc - sep - 1;
67 achk = alloca((nchk+1) * sizeof(char *));
68 memcpy(achk, argv+sep+1, nchk*sizeof(char *));
71 if (pipe(inpipe) < 0 ||
119 execv(achk[0], achk);
148 die("Unknown process %d died", p);
151 if (!WIFEXITED(sbox))
152 die("Sandbox fault, status=%x", sbox);
153 if (!WIFEXITED(schk) || WEXITSTATUS(schk) >= 100)
154 die("Checker fault, status=%x", schk);
155 if (WEXITSTATUS(sbox))
161 else if (WEXITSTATUS(schk))