1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
#include<unistd.h>
#include<stdlib.h>
#include<stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/wait.h>
#include<sched.h>
int main(int c,char**v) {
char*p;
if(c!=2) return 1;
for(p=v[1];*p;++p);
if(p-4<v[1]) return 1;
if(p[-1]!='o'||p[-2]!='r'||p[-3]!='p'||p[-4]!='.') return 1;
*(p-4)=0;
setenv("LC_COLLATE","C",1);
setenv("GDL_PATH","+/home/marc/gdl-0.9.5/testsuite/:+/home/marc/gdl-0.9.5/src/pro/",1);
unsetenv("GDL_STARTUP");
unsetenv("IDL_STARTUP");
int devnull = open("/dev/null",O_RDONLY);
dup2(devnull, 0);
int child_pid = fork();
if(child_pid == 0) {
execl("/home/marc/gdl-0.9.5/build/src/gdl","-quiet","-e",v[1],(char*)0);
exit(1);
} else {
sched_yield();
int child_status;
waitpid(child_pid, &child_status, 0);
if (WEXITSTATUS(child_status) == 77) {
printf("TEST SKIPPED");
exit(0);
} else if (WIFSIGNALED(child_status)) {
printf("TEST EXITED FROM SIGNAL %d", WTERMSIG(child_status));
exit(1);
} else {
exit(WEXITSTATUS(child_status));
}
}
}
|