| 1 |
# Utrace system call argument tests. |
| 2 |
|
| 3 |
set test "utrace_syscall_args" |
| 4 |
if {![installtest_p]} { untested "$test"; return } |
| 5 |
if {![utrace_p]} { untested "$test"; return } |
| 6 |
|
| 7 |
# Create a tempory directory. |
| 8 |
if {[catch {exec mktemp -d -t staptestXXXXXX} tmpdir]} { |
| 9 |
verbose -log "Failed to create temporary directory: $tmpdir" |
| 10 |
return |
| 11 |
} |
| 12 |
|
| 13 |
set flags "" |
| 14 |
set srcpath [file join [pwd] "$srcdir/$subdir/utrace_syscall_args.c"] |
| 15 |
set exepath "${tmpdir}/utrace_syscall_args" |
| 16 |
set stppath [file join [pwd] "$srcdir/$subdir/utrace_syscall_args.stp"] |
| 17 |
|
| 18 |
# Save the current directory and switch to our temporary |
| 19 |
# directory. Why do we want to run in the temporary directory? If the |
| 20 |
# current directory is from an NFS filesystem, we'll get odd results |
| 21 |
# back when calling fstat() on a newly created file. |
| 22 |
set curdir [pwd] |
| 23 |
cd ${tmpdir} |
| 24 |
|
| 25 |
set output_string "mmap\\(\[0-9\]+\\)\\(0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+\\) = 0x\[0-9a-f]+\r\nmunmap\\(\[0-9\]+\\)\\(0x\[0-9a-f]+, 0x\[0-9a-f]+\\) = 0x\[0-9a-f]+\r\nclose\\(\[0-9\]+\\)\\(0x\[0-9a-f]+\\) = 0x\[0-9a-f]+\r\ndup\\(\[0-9\]+\\)\\(0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+\\) = 0x\[0-9a-f]+\r\nbad_syscall\\(-?\[0-9\]+\\)\\(0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+\\) = 0x\[0-9a-f]+\r\nsystemtap test success\r\n" |
| 26 |
|
| 27 |
for {set i 0} {$i < [arch_compile_flags]} {incr i} { |
| 28 |
set flags [arch_compile_flag $i] |
| 29 |
set bits [arch_compile_flag_bits $i] |
| 30 |
|
| 31 |
set testname "${bits}_BIT_UTRACE_SYSCALL_ARGS" |
| 32 |
if {![installtest_p]} { untested $testname; continue } |
| 33 |
if {![utrace_p]} { untested $testname; continue } |
| 34 |
send_log "Testing ${testname}\n" |
| 35 |
|
| 36 |
# Compile our test program. |
| 37 |
set res [target_compile $srcpath $exepath executable $flags] |
| 38 |
if { $res != "" } { |
| 39 |
verbose "target_compile for $exepath failed: $res" 2 |
| 40 |
send_log "$testname: unable to compile $srcpath\n" |
| 41 |
untested $testname |
| 42 |
cd $curdir |
| 43 |
return |
| 44 |
} |
| 45 |
|
| 46 |
# Run the test. |
| 47 |
stap_run $testname wait_5_secs $output_string -g $stppath -c $exepath |
| 48 |
|
| 49 |
catch {exec rm -f $exepath foobar} |
| 50 |
} |
| 51 |
|
| 52 |
# Restore current directory |
| 53 |
cd ${curdir} |
| 54 |
|
| 55 |
# Cleanup |
| 56 |
catch {exec rm -f ${tmpdir}} |