Commit 779e8b63 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov

Merge branch 'zdtm' of https://github.com/avagin/crtools

* 'zdtm' of https://github.com/avagin/crtools:
  zdtm: set SA_RESTART everywhere
  zdtm.sh: clean up
  zdtm: print test dir, dump and restore path (if any) in case of error
parents 3f614e44 dd73699b
#!/bin/bash #!/bin/bash
ZP="zdtm/live/" ZP="zdtm/live"
TEST_LIST="\ TEST_LIST="\
$ZP/static/pipe00 $ZP/static/pipe00
...@@ -45,19 +45,24 @@ run_test() ...@@ -45,19 +45,24 @@ run_test()
killall -9 $tname killall -9 $tname
make -C $tdir cleanout $tname.pid make -C $tdir cleanout $tname.pid
pid=`cat $test.pid` pid=`cat $test.pid`
ddump="dump/$tname/$pid" ddump="dump/$tname/$pid"
dump_path=`pwd`"/"$ddump DUMP_PATH=`pwd`"/"$ddump
echo Dump $pid
mkdir -p $ddump mkdir -p $ddump
ls -l /proc/$pid/fd/
setsid $CRTOOLS dump -D $ddump -o dump.log -t $pid $2 || return 1 setsid $CRTOOLS dump -D $ddump -o dump.log -t $pid $2 || return 1
while :; do while :; do
killall -9 $tname &> /dev/null || break; killall -9 $tname &> /dev/null || break;
echo Waiting... echo Waiting...
sleep 1 sleep 1
done done
echo Restore $pid
setsid $CRTOOLS restore -D $ddump -o restore.log -d -t $pid $2 || return 2 setsid $CRTOOLS restore -D $ddump -o restore.log -d -t $pid $2 || return 2
ls -l /proc/$pid/fd/
echo Check results $pid
make -C $tdir $tname.out make -C $tdir $tname.out
for i in `seq 50`; do for i in `seq 50`; do
test -f $test.out && break; test -f $test.out && break;
...@@ -68,34 +73,42 @@ run_test() ...@@ -68,34 +73,42 @@ run_test()
cat $test.out | grep PASS || return 2 cat $test.out | grep PASS || return 2
} }
case_error()
{
test=$1
test_log="`pwd`/$test.out"
echo "Test: $test"
echo "====================== ERROR ======================"
[ -e "$DUMP_PATH/dump.log" ] && echo "Dump log : $DUMP_PATH/dump.log"
[ -e "$DUMP_PATH/restore.log" ] && echo "Restore log: $DUMP_PATH/restore.log"
[ -e "$test_log" ] && echo "Output file: $test_log"
exit 1
}
cd `dirname $0` || exit 1 cd `dirname $0` || exit 1
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
for t in $TEST_LIST; do for t in $TEST_LIST; do
run_test $t "" || exit 1 run_test $t "" || case_error $t
done done
for t in $UTS_TEST_LIST; do for t in $UTS_TEST_LIST; do
run_test $t "-n uts" || exit 1 run_test $t "-n uts" || case_error $t
done done
for t in $IPC_TEST_LIST; do for t in $IPC_TEST_LIST; do
run_test $t "-n ipc" || exit 1 run_test $t "-n ipc" || case_error $t
done done
elif [ "$1" == "-l" ]; then elif [ "$1" == "-l" ]; then
echo $TEST_LIST | sed -e "s#$ZP/##g" -e 's/ /\n/g' echo $TEST_LIST | sed -e "s#$ZP/##g" -e 's/ /\n/g'
echo $UTS_TEST_LIST | sed -e "s#$ZP/##g" -e 's/ /\n/g' echo $UTS_TEST_LIST | sed -e "s#$ZP/##g" -e 's/ /\n/g'
echo $IPC_TEST_LIST | sed -e "s#$ZP/##g" -e 's/ /\n/g'
else else
if echo "$UTS_TEST_LIST" | fgrep -q "$1" ; then if echo "$UTS_TEST_LIST" | fgrep -q "$1" ; then
run_test "$ZP/$1" "-n uts" && exit 0 run_test "$ZP/$1" "-n uts" || case_error "$ZP/$1"
elif echo "$IPC_TEST_LIST" | fgrep -q "$1" ; then elif echo "$IPC_TEST_LIST" | fgrep -q "$1" ; then
run_test "$ZP/$1" "-n ipc" && exit 0 run_test "$ZP/$1" "-n ipc" || case_error "$ZP/$1"
else
run_test "$ZP/$1" && exit 0
fi
result=$?
echo "====================== ERROR ======================"
if [ $result == 1 ]; then
echo "Dump log: "$dump_path"/dump.log"
else else
echo "Restore log: "$dump_path"/restore.log" run_test "$ZP/$1" || case_error "$ZP/$1"
fi fi
fi fi
...@@ -167,7 +167,10 @@ struct zdtm_clone_arg { ...@@ -167,7 +167,10 @@ struct zdtm_clone_arg {
static int do_test_fn(void *_arg) static int do_test_fn(void *_arg)
{ {
struct zdtm_clone_arg *ca = _arg; struct zdtm_clone_arg *ca = _arg;
struct sigaction sa; struct sigaction sa = {
.sa_handler = SIG_DFL,
.sa_flags = SA_RESTART,
};
/* record the test pid to remember the ownership of the pidfile */ /* record the test pid to remember the ownership of the pidfile */
master_pid = getpid(); master_pid = getpid();
...@@ -175,7 +178,6 @@ static int do_test_fn(void *_arg) ...@@ -175,7 +178,6 @@ static int do_test_fn(void *_arg)
fclose(ca->pidf); fclose(ca->pidf);
sigemptyset(&sa.sa_mask); sigemptyset(&sa.sa_mask);
sa.sa_handler = SIG_DFL;
if (sigaction(SIGCHLD, &sa, NULL)) { if (sigaction(SIGCHLD, &sa, NULL)) {
err("Can't reset SIGCHLD handler: %m\n"); err("Can't reset SIGCHLD handler: %m\n");
exit(1); exit(1);
...@@ -200,6 +202,7 @@ void test_init_ns(int argc, char **argv, unsigned long clone_flags, void (*fn)(v ...@@ -200,6 +202,7 @@ void test_init_ns(int argc, char **argv, unsigned long clone_flags, void (*fn)(v
static FILE *pidf; static FILE *pidf;
struct sigaction sa = { struct sigaction sa = {
.sa_handler = sig_hand, .sa_handler = sig_hand,
.sa_flags = SA_RESTART,
}; };
struct zdtm_clone_arg ca; struct zdtm_clone_arg ca;
void *stack; void *stack;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment