From d1cd4267e903d8bb0190e96e572ed42fcd0b25d1 Mon Sep 17 00:00:00 2001 From: hunt Date: Tue, 3 Jul 2007 21:38:40 +0000 Subject: [PATCH] 2007-07-03 Martin Hunt * systemtap.context/pid.tcl: Better error reporting. * systemtap.context/args.*: Ditto. * systemtap.context/context.exp: Build in temp dir. --- testsuite/systemtap.context/args.stp | 4 +- testsuite/systemtap.context/args.tcl | 10 +++- testsuite/systemtap.context/context.exp | 23 ++++++++- testsuite/systemtap.context/pid.tcl | 67 ++++++++----------------- 4 files changed, 54 insertions(+), 50 deletions(-) diff --git a/testsuite/systemtap.context/args.stp b/testsuite/systemtap.context/args.stp index 5d5208a28..e6cf9e928 100644 --- a/testsuite/systemtap.context/args.stp +++ b/testsuite/systemtap.context/args.stp @@ -23,10 +23,10 @@ probe module("systemtap_test_module2").function("yyy_int64").return { printf("yyy_int64 returns %d\n", $return) } probe module("systemtap_test_module2").function("yyy_char") { - printf("yyy_char %d %d %d\n", $a, $b, $c) + printf("yyy_char %1b %1b %1b\n", $a, $b, $c) } probe module("systemtap_test_module2").function("yyy_char").return { - printf("yyy_char returns %d\n", $return) + printf("yyy_char returns %1b\n", $return) } probe module("systemtap_test_module2").function("yyy_str") { printf("yyy_str %s-%s-%s\n", kernel_string($a), kernel_string($b), kernel_string($c)) diff --git a/testsuite/systemtap.context/args.tcl b/testsuite/systemtap.context/args.tcl index bbac1a4b7..6c14c4b75 100644 --- a/testsuite/systemtap.context/args.tcl +++ b/testsuite/systemtap.context/args.tcl @@ -8,6 +8,7 @@ expect { "yyy_int -1 200 300\r\nyyy_int returns 499\r\n" { pass "integer function arguments" } + timeout {fail "integer function arguments"} } exec echo 2 > /proc/stap_test_cmd expect { @@ -15,6 +16,7 @@ expect { "yyy_uint 4294967295 200 300\r\nyyy_uint returns 499\r\n" { pass "unsigned function arguments" } + timeout {fail "unsigned function arguments"} } exec echo 3 > /proc/stap_test_cmd expect { @@ -22,6 +24,7 @@ expect { "yyy_long -1 200 300\r\nyyy_long returns 499\r\n" { pass "long function arguments" } + timeout {fail "long function arguments"} } exec echo 4 > /proc/stap_test_cmd expect { @@ -29,13 +32,15 @@ expect { "yyy_int64 -1 200 300\r\nyyy_int64 returns 499\r\n" { pass "int64 function arguments" } + timeout {fail "int64 function arguments"} } exec echo 5 > /proc/stap_test_cmd expect { -timeout 5 - "yyy_char 97 98 99\r\nyyy_char returns 81\r\n" { + "yyy_char a b c\r\nyyy_char returns Q\r\n" { pass "char function arguments" } + timeout {fail "char function arguments"} } exec echo 6 > /proc/stap_test_cmd expect { @@ -43,9 +48,10 @@ expect { "yyy_str Hello-System-Tap\r\nyyy_str returns XYZZY\r\n" { pass "string function arguments" } + timeout {fail "string function arguments"} } } - eof {} + eof {fail "function arguments: unexpected timeout"} } send "\003" close diff --git a/testsuite/systemtap.context/context.exp b/testsuite/systemtap.context/context.exp index 858596d92..4f134740b 100644 --- a/testsuite/systemtap.context/context.exp +++ b/testsuite/systemtap.context/context.exp @@ -7,34 +7,55 @@ if {![installtest_p]} { return } +set build_dir "" + proc cleanup {} { + global build_dir catch {send "\003"} foreach n {1 2} { catch {exec sudo /bin/rm -f /lib/modules/$::uname/systemtap_test_module$n.ko} catch {exec sudo /sbin/rmmod systemtap_test_module$n} } + if {$build_dir != ""} {exec rm -rf $build_dir} } proc build_modules {} { + global build_dir + + if {[catch {exec mktemp -d staptestXXXXX} build_dir]} { + puts stderr "Failed to create temporary directory: $build_dir" + return 0 + } + + foreach f [glob systemtap_test_module*.c] { + exec cp $f $build_dir + } + set old_dir [pwd] + cd $build_dir + foreach n {1 2} { - exec cp makefile$n Makefile + exec cp $old_dir/makefile$n Makefile if {[catch {exec make clean} res]} { puts $res + cd $old_dir return 0 } catch {exec make} res if {![file exists systemtap_test_module$n.ko]} { puts $res + cd $old_dir return 0 } if {[catch {exec sudo cp systemtap_test_module$n.ko /lib/modules/$::uname} res]} { puts $res + cd $old_dir return 0 } } foreach n {2 1} { catch {exec sudo /sbin/insmod systemtap_test_module$n.ko} } + cd $old_dir return 1 } diff --git a/testsuite/systemtap.context/pid.tcl b/testsuite/systemtap.context/pid.tcl index 36ee6b9cf..e1ae98970 100644 --- a/testsuite/systemtap.context/pid.tcl +++ b/testsuite/systemtap.context/pid.tcl @@ -1,54 +1,31 @@ +set tests [list execname pexecname pid ppid tid uid euid gid egid] spawn stap pid.stp expect { -timeout 240 "READY" { set pid [exec echo 1 > /proc/stap_test_cmd &] - set uid [exec id -ru] - set gid [exec id -rg] - set euid [exec id -u] - set egid [exec id -g] - expect { - -timeout 5 - "execname: echo\r\n" { - pass "execname" - exp_continue - } - "pexecname: expect\r\n" { - pass "pexecname" - exp_continue - } - "pid: $pid\r\n" { - pass "pid" - exp_continue - } - -re {ppid: [^\r\n]+\r\n} { - pass "ppid" - exp_continue - } - "tid: $pid\r\n" { - pass "tid" - exp_continue - } - "uid: $uid\r\n" { - pass "uid" - exp_continue - } - "euid: $euid\r\n" { - pass "euid" - exp_continue - } - "gid: $gid\r\n" { - pass "gid" - exp_continue - } - "egid: $egid\r\n" { - pass "egid" - exp_continue - } - eof {} - } + set ppid [lindex [split [exec grep PPid /proc/$pid/status]] 1] + set uid [exec id -ru] + set gid [exec id -rg] + set euid [exec id -u] + set egid [exec id -g] + set results [list "execname: echo\r\n" "pexecname: expect\r\n" "pid: $pid\r\n" "ppid: $ppid\r\n" "tid: $pid\r\n" "uid: $uid\r\n" "euid: $euid\r\n" "gid: $gid\r\n" "egid: $egid\r\n"] + + set i 0 + foreach t $tests { + expect { + -timeout 5 + [lindex $results $i] { + pass $t + } + timeout {fail "$t - timeout"} + eof {fail "$t - unexpected EOF"} + } + incr i + } } - eof {} + timeout {fail "all pid tests - timeout"} + eof {fail "all pid tests - unexpected EOF"} } catch {close} wait -- 2.43.5