diff --git a/test/strace/issue/result.txt b/test/strace/issue/result.txt index bcd3ab49..15246ac4 100644 --- a/test/strace/issue/result.txt +++ b/test/strace/issue/result.txt @@ -27,7 +27,6 @@ ../../../../mic/mcexec ./946 #946 start #946-1 exit after wait OK -#946-1 exit after wait OK #946-2 exit before wait OK #946 terminated ok=2 ng=0 ../../../../mic/mcexec ./960 diff --git a/test/strace/strace/result.txt b/test/strace/strace/result.txt new file mode 100644 index 00000000..f855a49f --- /dev/null +++ b/test/strace/strace/result.txt @@ -0,0 +1,11 @@ +*** test1 start +test1-1 gettid OK +test1-2 syscal_9999 OK +*** test1 end ok=2 ng=0 +*** test2 start +test2-1 execve OK +test2-2 fork OK +test2-3 execve OK +test2-4 SIGCHLD OK +test2-5 wait OK +*** test2 end ok=5 ng=0 diff --git a/test/strace/strace/test.sh b/test/strace/strace/test.sh new file mode 100755 index 00000000..53076384 --- /dev/null +++ b/test/strace/strace/test.sh @@ -0,0 +1,4 @@ +#!/bin/sh +export MCEXEC=../../../../mic/mcexec +./test1.sh +./test2.sh diff --git a/test/strace/strace/test1.c b/test/strace/strace/test1.c new file mode 100644 index 00000000..5db9e55c --- /dev/null +++ b/test/strace/strace/test1.c @@ -0,0 +1,20 @@ +#define __BSD_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int +main(int argc, char **argv) +{ + syscall(SYS_gettid); + open("/", O_WRONLY); + syscall(9999); + exit(15); +} diff --git a/test/strace/strace/test1.sh b/test/strace/strace/test1.sh new file mode 100755 index 00000000..562d217a --- /dev/null +++ b/test/strace/strace/test1.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +if [ ! -f test1 ]; then + gcc -o test1 test1.c +fi + +rm -f check.log +$MCEXEC strace -o check.log ./test1 + +awk 'BEGIN{ng=0; ok=0; print "*** test1 start"} +/^gettid/{ + if ($0 ~/errno/) { + print "test1-1 gettid NG" + ng++ + } + else { + print "test1-1 gettid OK" + ok++ + } + test1=1 +} +/^syscall_9999/{ + if ($0 ~/errno 38/) { + print "test1-2 syscal_9999 OK" + ok++ + } + else { + print "test1-2 syscall_9999 NG" + ng++ + } + test2=1 +} +END { + if (test1 != 1) { + print "test1-1 gettid NG" + ng++ + } + if (test2 != 1) { + print "test1-2 syscall_9999 NG" + ng++ + } + printf("*** test1 end ok=%d ng=%d\n", ok, ng) + exit(ng) +}' check.log + +rm -f check.log test1 diff --git a/test/strace/strace/test2.c b/test/strace/strace/test2.c new file mode 100644 index 00000000..5774cf84 --- /dev/null +++ b/test/strace/strace/test2.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include +#include +#include +#include + +int +main(int argc, char **argv) +{ + pid_t pid; + int rc; + int st; + + if (argv[1] && !strcmp(argv[1], "exec")) { + exit(1); + } + + pid = fork(); + if (pid == 0) { + sleep(1); + execl("test2", "test2", "exec", NULL); + exit(99); + } + sleep(2); + rc = wait(&st); + if (rc != pid) { + printf("test2 NG\n"); + exit(1); + } + exit(0); +} diff --git a/test/strace/strace/test2.sh b/test/strace/strace/test2.sh new file mode 100755 index 00000000..02b528a3 --- /dev/null +++ b/test/strace/strace/test2.sh @@ -0,0 +1,60 @@ +#!/bin/sh + +if [ ! -f test2 ]; then + gcc -o test2 test2.c +fi + +rm -f check.log +$MCEXEC strace -e trace=process -f -o check.log ./test2 + +awk 'BEGIN{st=0;ng=0; ok=0; print "*** test2 start"} +/execve/{ + st++ + if ($0 ~/ = 0$/) { + print "test2-" st " execve OK" + ok++ + } + else { + print "test2-" st " execve NG" + ng++ + } +} +/clone/{ + st++ + if ($0 ~/ = [1-9][0-9]*$/) { + print "test2-" st " fork OK" + ok++ + } + else { + print "test2-" st " fork NG" + ng++ + } +} +/wait4/{ + st++ + if ($0 ~/ = [1-9][0-9]*$/) { + print "test2-" st " wait OK" + ok++ + } + else { + print "test2-" st " wait NG" + ng++ + } +} +/SIGCHLD {/{ + st++ + print "test2-" st " SIGCHLD OK" + ok++ + sigchld = 1 +} +END { + if (sigchld != 1) { + st++ + print "test2-" st " SIGCHLD NG" + ng++ + } + printf("*** test2 end ok=%d ng=%d\n", ok, ng) + exit(ng) +}' check.log + +rm -f check.log test2