add strace bundled test cases
This commit is contained in:
@ -1018,7 +1018,7 @@ void gpe_handler(struct x86_user_context *regs)
|
||||
check_need_resched();
|
||||
}
|
||||
set_cputime(0);
|
||||
// panic("GPF");
|
||||
panic("GPF");
|
||||
}
|
||||
|
||||
void debug_handler(struct x86_user_context *regs)
|
||||
@ -1582,6 +1582,8 @@ void arch_show_interrupt_context(const void *reg)
|
||||
__kprintf("%16lx %16lx %16lx %16lx\n",
|
||||
regs->cs, regs->ss, regs->rflags, regs->error);
|
||||
|
||||
kprintf_unlock(irqflags);
|
||||
return;
|
||||
arch_show_extended_context();
|
||||
|
||||
arch_print_pre_interrupt_stack(regs);
|
||||
|
||||
@ -9340,6 +9340,7 @@ long syscall(int num, ihk_mc_user_context_t *ctx)
|
||||
#endif // DISABLE_SCHED_YIELD
|
||||
set_cputime(1);
|
||||
|
||||
//kprintf("syscall=%d\n", num);
|
||||
#ifdef PROFILE_ENABLE
|
||||
if (thread->profile && thread->profile_start_ts) {
|
||||
unsigned long ts = rdtsc();
|
||||
@ -9473,6 +9474,7 @@ long syscall(int num, ihk_mc_user_context_t *ctx)
|
||||
if (thread->proc->nohost) { // mcexec termination was detected
|
||||
terminate(0, SIGKILL);
|
||||
}
|
||||
//kprintf("syscall=%d returns %lx(%ld)\n", num, l, l);
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
30
test/strace/strace-bundle/init.sh
Normal file
30
test/strace/strace-bundle/init.sh
Normal file
@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
|
||||
ME_="${0##*/}"
|
||||
|
||||
warn_() { printf >&2 '%s\n' "$*"; }
|
||||
fail_() { warn_ "$ME_: failed test: $*"; exit 1; }
|
||||
skip_() { warn_ "$ME_: skipped test: $*"; exit 77; }
|
||||
framework_failure_() { warn_ "$ME_: framework failure: $*"; exit 99; }
|
||||
framework_skip_() { warn_ "$ME_: framework skip: $*"; exit 77; }
|
||||
|
||||
check_prog()
|
||||
{
|
||||
type "$@" > /dev/null 2>&1 ||
|
||||
framework_skip_ "$* is not available"
|
||||
}
|
||||
|
||||
check_strace()
|
||||
{
|
||||
STRACE=${*:-strace}
|
||||
$STRACE -V > /dev/null ||
|
||||
framework_failure_ "$STRACE is not available"
|
||||
}
|
||||
|
||||
timeout_duration=60
|
||||
check_timeout()
|
||||
{
|
||||
TIMEOUT="timeout -s 9 $timeout_duration"
|
||||
$TIMEOUT true > /dev/null 2>&1 ||
|
||||
TIMEOUT=
|
||||
}
|
||||
28
test/strace/strace-bundle/ptrace_setoptions
Executable file
28
test/strace/strace-bundle/ptrace_setoptions
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Ensure that strace tests kernel PTRACE_O_TRACECLONE
|
||||
# and PTRACE_O_TRACESYSGOOD support properly.
|
||||
|
||||
. "${srcdir=.}/init.sh"
|
||||
|
||||
[ "$(uname -s)" = Linux ] ||
|
||||
skip_ 'The kernel is not a Linux kernel'
|
||||
case "$(uname -r)" in
|
||||
2.[6-9]*|2.[1-5][0-9]*|[3-9].*|[12][0-9]*) ;;
|
||||
*) skip_ 'The kernel is not Linux 2.6.* or newer' ;;
|
||||
esac
|
||||
|
||||
check_strace
|
||||
check_timeout
|
||||
|
||||
$TIMEOUT $MCEXEC $STRACE -df -enone / 2>&1 |
|
||||
grep -F -x 'ptrace_setoptions = 0xe' > /dev/null ||
|
||||
fail_ 'strace -f failed to recognize proper kernel PTRACE_O_TRACECLONE support'
|
||||
|
||||
$TIMEOUT $MCEXEC $STRACE -df -enone / 2>&1 |
|
||||
grep -F -x 'ptrace_setoptions = 0x1f' > /dev/null ||
|
||||
fail_ 'strace -f failed to recognize proper kernel PTRACE_O_TRACESYSGOOD support'
|
||||
|
||||
$TIMEOUT $MCEXEC $STRACE -d -enone / 2>&1 |
|
||||
grep -F -x 'ptrace_setoptions = 0x11' > /dev/null ||
|
||||
fail_ 'strace failed to recognize proper kernel PTRACE_O_TRACESYSGOOD support'
|
||||
27
test/strace/strace-bundle/qual_syscall
Executable file
27
test/strace/strace-bundle/qual_syscall
Executable file
@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Ensure that strace -e trace=set works.
|
||||
|
||||
. "${srcdir=.}/init.sh"
|
||||
|
||||
check_strace
|
||||
check_timeout
|
||||
check_prog ls
|
||||
check_prog grep
|
||||
|
||||
$TIMEOUT $MCEXEC $STRACE -e execve ls > /dev/null 2> check.log &&
|
||||
grep '^execve(' check.log > /dev/null ||
|
||||
{ cat check.log; fail_ 'strace -e execve does not work'; }
|
||||
|
||||
grep -v '^execve(' check.log |
|
||||
LC_ALL=C grep '^[[:alnum:]_]*(' > /dev/null &&
|
||||
{ cat check.log; fail_ 'strace -e execve does not work properly'; }
|
||||
|
||||
$TIMEOUT $MCEXEC $STRACE -e trace=process ls > /dev/null 2> check.log &&
|
||||
grep '^execve(' check.log > /dev/null ||
|
||||
{ cat check.log; fail_ 'strace -e trace=process does not work'; }
|
||||
|
||||
grep '^open' check.log > /dev/null &&
|
||||
{ cat check.log; fail_ 'strace -e trace=process does not work properly'; }
|
||||
|
||||
exit 0
|
||||
37
test/strace/strace-bundle/stat
Executable file
37
test/strace/strace-bundle/stat
Executable file
@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Check how ftruncate, lseek and stat family syscalls are traced.
|
||||
|
||||
. "${srcdir=.}/init.sh"
|
||||
|
||||
check_strace
|
||||
check_timeout
|
||||
check_prog dd
|
||||
check_prog find
|
||||
check_prog grep
|
||||
check_prog rm
|
||||
|
||||
umask 022
|
||||
truncate_cmd='dd seek=46118400000 obs=1 count=0 if=/dev/null of=sample'
|
||||
$truncate_cmd > check.log 2>&1 ||
|
||||
{ cat check.log; framework_skip_ 'failed to create a large sparse file'; }
|
||||
rm -f sample
|
||||
|
||||
$TIMEOUT $MCEXEC $STRACE -edesc $truncate_cmd 2>&1 > /dev/null 2> check.log &&
|
||||
LC_ALL=C grep -E -x 'ftruncate(64)?\(1, 46118400000\) += 0' check.log > /dev/null ||
|
||||
{ cat check.log; fail_ 'strace -edesc failed to trace ftruncate/ftruncate64 properly'; }
|
||||
|
||||
LC_ALL=C grep -E -x 'lseek\(1, 46118400000, SEEK_CUR\) += 46118400000|_llseek\(1, 46118400000, \[46118400000\], SEEK_CUR\) += 0' check.log > /dev/null ||
|
||||
{ cat check.log; fail_ 'strace -edesc failed to trace lseek/_llseek properly'; }
|
||||
|
||||
$TIMEOUT $MCEXEC $STRACE -efile find -L sample > /dev/null 2> check.log &&
|
||||
LC_ALL=C grep -E -x 'stat(64)?\("sample", \{st_mode=S_IFREG\|0644, st_size=46118400000, \.\.\.\}\) += 0|(new)?fstatat(64)?\(AT_FDCWD, "sample", \{st_mode=S_IFREG\|0644, st_size=46118400000, \.\.\.\}, 0\) += 0' check.log > /dev/null ||
|
||||
{ cat check.log; fail_ 'strace -efile failed to trace stat/stat64 properly'; }
|
||||
|
||||
$TIMEOUT $MCEXEC $STRACE -efile find sample > /dev/null 2> check.log &&
|
||||
LC_ALL=C grep -E -x 'lstat(64)?\("sample", \{st_mode=S_IFREG\|0644, st_size=46118400000, \.\.\.\}\) += 0|(new)?fstatat(64)?\(AT_FDCWD, "sample", \{st_mode=S_IFREG\|0644, st_size=46118400000, \.\.\.\}, AT_SYMLINK_NOFOLLOW\) += 0' check.log > /dev/null ||
|
||||
{ cat check.log; fail_ 'strace -efile failed to trace fstatat/fstatat64 properly'; }
|
||||
|
||||
rm -f sample
|
||||
|
||||
exit 0
|
||||
13
test/strace/strace-bundle/strace-f
Executable file
13
test/strace/strace-bundle/strace-f
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Ensure that strace -f works.
|
||||
|
||||
. "${srcdir=.}/init.sh"
|
||||
|
||||
check_strace
|
||||
check_timeout
|
||||
time=/usr/bin/time
|
||||
check_prog $time
|
||||
|
||||
$TIMEOUT $MCEXEC $STRACE -f $time /bin/ls > check.log 2>&1 ||
|
||||
{ cat check.log; fail_ 'strace -f does not work'; }
|
||||
216
test/strace/strace-bundle/test-result.txt
Normal file
216
test/strace/strace-bundle/test-result.txt
Normal file
@ -0,0 +1,216 @@
|
||||
スクリプトは Mon Nov 20 13:34:02 2017
|
||||
に開始しました[?1034hbash-4.2$ export MCEXEC=$HOME/wallaby11-smp-x86/development/mic/mcexec
|
||||
bash-4.2$ cat ptrace_setoptions
|
||||
#!/bin/sh
|
||||
|
||||
# Ensure that strace tests kernel PTRACE_O_TRACECLONE
|
||||
# and PTRACE_O_TRACESYSGOOD support properly.
|
||||
|
||||
. "${srcdir=.}/init.sh"
|
||||
|
||||
[ "$(uname -s)" = Linux ] ||
|
||||
skip_ 'The kernel is not a Linux kernel'
|
||||
case "$(uname -r)" in
|
||||
2.[6-9]*|2.[1-5][0-9]*|[3-9].*|[12][0-9]*) ;;
|
||||
*) skip_ 'The kernel is not Linux 2.6.* or newer' ;;
|
||||
esac
|
||||
|
||||
check_strace
|
||||
check_timeout
|
||||
|
||||
$TIMEOUT $MCEXEC $STRACE -df -enone / 2>&1 |
|
||||
grep -F -x 'ptrace_setoptions = 0xe' > /dev/null ||
|
||||
fail_ 'strace -f failed to recognize proper kernel PTRACE_O_TRACECLONE support'
|
||||
|
||||
$TIMEOUT $MCEXEC $STRACE -df -enone / 2>&1 |
|
||||
grep -F -x 'ptrace_setoptions = 0x1f' > /dev/null ||
|
||||
fail_ 'strace -f failed to recognize proper kernel PTRACE_O_TRACESYSGOOD support'
|
||||
|
||||
$TIMEOUT $MCEXEC $STRACE -d -enone / 2>&1 |
|
||||
grep -F -x 'ptrace_setoptions = 0x11' > /dev/null ||
|
||||
fail_ 'strace failed to recognize proper kernel PTRACE_O_TRACESYSGOOD support'
|
||||
bash-4.2$ sh -x ptrace_setoptions
|
||||
+ . ./init.sh
|
||||
++ ME_=ptrace_setoptions
|
||||
++ timeout_duration=60
|
||||
++ uname -s
|
||||
+ '[' Linux = Linux ']'
|
||||
+ case "$(uname -r)" in
|
||||
++ uname -r
|
||||
+ check_strace
|
||||
+ STRACE=../strace
|
||||
+ ../strace -V
|
||||
+ check_timeout
|
||||
+ TIMEOUT='timeout -s 9 60'
|
||||
+ timeout -s 9 60 true
|
||||
+ timeout -s 9 60 /home/shirasawa/wallaby11-smp-x86/development/mic/mcexec ../strace -df -enone /
|
||||
+ grep -F -x 'ptrace_setoptions = 0xe'
|
||||
+ timeout -s 9 60 /home/shirasawa/wallaby11-smp-x86/development/mic/mcexec ../strace -df -enone /
|
||||
+ grep -F -x 'ptrace_setoptions = 0x1f'
|
||||
+ timeout -s 9 60 /home/shirasawa/wallaby11-smp-x86/development/mic/mcexec ../strace -d -enone /
|
||||
+ grep -F -x 'ptrace_setoptions = 0x11'
|
||||
bash-4.2$ echo $?
|
||||
0
|
||||
bash-4.2$ cat strace-f
|
||||
#!/bin/sh
|
||||
|
||||
# Ensure that strace -f works.
|
||||
|
||||
. "${srcdir=.}/init.sh"
|
||||
|
||||
check_strace
|
||||
check_timeout
|
||||
time=/usr/bin/time
|
||||
check_prog $time
|
||||
|
||||
$TIMEOUT $MCEXEC $STRACE -f $time /bin/ls > check.log 2>&1 ||
|
||||
{ cat check.log; fail_ 'strace -f does not work'; }
|
||||
bash-4.2$ sh -x strace-f
|
||||
+ . ./init.sh
|
||||
++ ME_=strace-f
|
||||
++ timeout_duration=60
|
||||
+ check_strace
|
||||
+ STRACE=../strace
|
||||
+ ../strace -V
|
||||
+ check_timeout
|
||||
+ TIMEOUT='timeout -s 9 60'
|
||||
+ timeout -s 9 60 true
|
||||
+ time=/usr/bin/time
|
||||
+ check_prog /usr/bin/time
|
||||
+ type /usr/bin/time
|
||||
+ timeout -s 9 60 /home/shirasawa/wallaby11-smp-x86/development/mic/mcexec ../strace -f /usr/bin/time /bin/ls
|
||||
bash-4.2$ echo ?[K$?
|
||||
0
|
||||
bash-4.2$ cat qual_syscall
|
||||
#!/bin/sh
|
||||
|
||||
# Ensure that strace -e trace=set works.
|
||||
|
||||
. "${srcdir=.}/init.sh"
|
||||
|
||||
check_strace
|
||||
check_timeout
|
||||
check_prog ls
|
||||
check_prog grep
|
||||
|
||||
$TIMEOUT $MCEXEC $STRACE -e execve ls > /dev/null 2> check.log &&
|
||||
grep '^execve(' check.log > /dev/null ||
|
||||
{ cat check.log; fail_ 'strace -e execve does not work'; }
|
||||
|
||||
grep -v '^execve(' check.log |
|
||||
LC_ALL=C grep '^[[:alnum:]_]*(' > /dev/null &&
|
||||
{ cat check.log; fail_ 'strace -e execve does not work properly'; }
|
||||
|
||||
$TIMEOUT $MCEXEC $STRACE -e trace=process ls > /dev/null 2> check.log &&
|
||||
grep '^execve(' check.log > /dev/null ||
|
||||
{ cat check.log; fail_ 'strace -e trace=process does not work'; }
|
||||
|
||||
grep '^open' check.log > /dev/null &&
|
||||
{ cat check.log; fail_ 'strace -e trace=process does not work properly'; }
|
||||
|
||||
exit 0
|
||||
bash-4.2$ sh -x qual_syscall
|
||||
+ . ./init.sh
|
||||
++ ME_=qual_syscall
|
||||
++ timeout_duration=60
|
||||
+ check_strace
|
||||
+ STRACE=../strace
|
||||
+ ../strace -V
|
||||
+ check_timeout
|
||||
+ TIMEOUT='timeout -s 9 60'
|
||||
+ timeout -s 9 60 true
|
||||
+ check_prog ls
|
||||
+ type ls
|
||||
+ check_prog grep
|
||||
+ type grep
|
||||
+ timeout -s 9 60 /home/shirasawa/wallaby11-smp-x86/development/mic/mcexec ../strace -e execve ls
|
||||
+ grep '^execve(' check.log
|
||||
+ grep -v '^execve(' check.log
|
||||
+ LC_ALL=C
|
||||
+ grep '^[[:alnum:]_]*('
|
||||
+ timeout -s 9 60 /home/shirasawa/wallaby11-smp-x86/development/mic/mcexec ../strace -e trace=process ls
|
||||
+ grep '^execve(' check.log
|
||||
+ grep '^open' check.log
|
||||
+ exit 0
|
||||
bash-4.2$ echo $?
|
||||
0
|
||||
bash-4.2$ cat stat
|
||||
#!/bin/sh
|
||||
|
||||
# Check how ftruncate, lseek and stat family syscalls are traced.
|
||||
|
||||
. "${srcdir=.}/init.sh"
|
||||
|
||||
check_strace
|
||||
check_timeout
|
||||
check_prog dd
|
||||
check_prog find
|
||||
check_prog grep
|
||||
check_prog rm
|
||||
|
||||
umask 022
|
||||
truncate_cmd='dd seek=46118400000 obs=1 count=0 if=/dev/null of=sample'
|
||||
$truncate_cmd > check.log 2>&1 ||
|
||||
{ cat check.log; framework_skip_ 'failed to create a large sparse file'; }
|
||||
rm -f sample
|
||||
|
||||
$TIMEOUT $MCEXEC $STRACE -edesc $truncate_cmd 2>&1 > /dev/null 2> check.log &&
|
||||
LC_ALL=C grep -E -x 'ftruncate(64)?\(1, 46118400000\) += 0' check.log > /dev/null ||
|
||||
{ cat check.log; fail_ 'strace -edesc failed to trace ftruncate/ftruncate64 properly'; }
|
||||
|
||||
LC_ALL=C grep -E -x 'lseek\(1, 46118400000, SEEK_CUR\) += 46118400000|_llseek\(1, 46118400000, \[46118400000\], SEEK_CUR\) += 0' check.log > /dev/null ||
|
||||
{ cat check.log; fail_ 'strace -edesc failed to trace lseek/_llseek properly'; }
|
||||
|
||||
$TIMEOUT $MCEXEC $STRACE -efile find -L sample > /dev/null 2> check.log &&
|
||||
LC_ALL=C grep -E -x 'stat(64)?\("sample", \{st_mode=S_IFREG\|0644, st_size=46118400000, \.\.\.\}\) += 0|(new)?fstatat(64)?\(AT_FDCWD, "sample", \{st_mode=S_IFREG\|0644, st_size=46118400000, \.\.\.\}, 0\) += 0' check.log > /dev/null ||
|
||||
{ cat check.log; fail_ 'strace -efile failed to trace stat/stat64 properly'; }
|
||||
|
||||
$TIMEOUT $MCEXEC $STRACE -efile find sample > /dev/null 2> check.log &&
|
||||
LC_ALL=C grep -E -x 'lstat(64)?\("sample", \{st_mode=S_IFREG\|0644, st_size=46118400000, \.\.\.\}\) += 0|(new)?fstatat(64)?\(AT_FDCWD, "sample", \{st_mode=S_IFREG\|0644, st_size=46118400000, \.\.\.\}, AT_SYMLINK_NOFOLLOW\) += 0' check.log > /dev/null ||
|
||||
{ cat check.log; fail_ 'strace -efile failed to trace fstatat/fstatat64 properly'; }
|
||||
|
||||
rm -f sample
|
||||
|
||||
exit 0
|
||||
bash-4.2$ sh -x stat
|
||||
+ . ./init.sh
|
||||
++ ME_=stat
|
||||
++ timeout_duration=60
|
||||
+ check_strace
|
||||
+ STRACE=../strace
|
||||
+ ../strace -V
|
||||
+ check_timeout
|
||||
+ TIMEOUT='timeout -s 9 60'
|
||||
+ timeout -s 9 60 true
|
||||
+ check_prog dd
|
||||
+ type dd
|
||||
+ check_prog find
|
||||
+ type find
|
||||
+ check_prog grep
|
||||
+ type grep
|
||||
+ check_prog rm
|
||||
+ type rm
|
||||
+ umask 022
|
||||
+ truncate_cmd='dd seek=46118400000 obs=1 count=0 if=/dev/null of=sample'
|
||||
+ dd seek=46118400000 obs=1 count=0 if=/dev/null of=sample
|
||||
+ rm -f sample
|
||||
+ timeout -s 9 60 /home/shirasawa/wallaby11-smp-x86/development/mic/mcexec ../strace -edesc dd seek=46118400000 obs=1 count=0 if=/dev/null of=sample
|
||||
+ LC_ALL=C
|
||||
+ grep -E -x 'ftruncate(64)?\(1, 46118400000\) += 0' check.log
|
||||
+ LC_ALL=C
|
||||
+ grep -E -x 'lseek\(1, 46118400000, SEEK_CUR\) += 46118400000|_llseek\(1, 46118400000, \[46118400000\], SEEK_CUR\) += 0' check.log
|
||||
+ timeout -s 9 60 /home/shirasawa/wallaby11-smp-x86/development/mic/mcexec ../strace -efile find -L sample
|
||||
+ LC_ALL=C
|
||||
+ grep -E -x 'stat(64)?\("sample", \{st_mode=S_IFREG\|0644, st_size=46118400000, \.\.\.\}\) += 0|(new)?fstatat(64)?\(AT_FDCWD, "sample", \{st_mode=S_IFREG\|0644, st_size=46118400000, \.\.\.\}, 0\) += 0' check.log
|
||||
+ timeout -s 9 60 /home/shirasawa/wallaby11-smp-x86/development/mic/mcexec ../strace -efile find sample
|
||||
+ LC_ALL=C
|
||||
+ grep -E -x 'lstat(64)?\("sample", \{st_mode=S_IFREG\|0644, st_size=46118400000, \.\.\.\}\) += 0|(new)?fstatat(64)?\(AT_FDCWD, "sample", \{st_mode=S_IFREG\|0644, st_size=46118400000, \.\.\.\}, AT_SYMLINK_NOFOLLOW\) += 0' check.log
|
||||
+ rm -f sample
|
||||
+ exit 0
|
||||
bash-4.2$ echo $?
|
||||
0
|
||||
bash-4.2$ シェルから脱出するには "exit" を使用してください。
|
||||
bash-4.2$ exit
|
||||
|
||||
スクリプトは Mon Nov 20 13:36:26 2017
|
||||
に終了しました
|
||||
Reference in New Issue
Block a user