-re $warning_regexp {
set probe_errors $expect_out(1,string)
set skipped_probes $expect_out(2,string)}
+ default {
+ fail "$TEST_NAME unexpected output (after passing output)"
+ }
}
}
+ default {
+ fail "$TEST_NAME unexpected output"
+ }
timeout {
fail "$TEST_NAME shutdown (timeout)"
kill -INT -[exp_pid]
# BZ692445 was fixed by removing the '$' at the end of
# all_pass_string. Yet another expect regular expression oddity. The
# '\r\n' is good enough at finding the EOL.
-set all_pass_string "(systemtap test success\r\n)+"
+set all_pass_string "systemtap test success\r\n"
set test_name array_slicing
-# basic version of the script to be used. values need to be subbed in for each test
+# basic version of the script to be used. values need to be subbed in
+# for each test
set script { \
global val; \
probe begin { \
}
# this is set up to act like a normal for loop
-stap_run {$test_name foreach (... val[*, *])} "" "11 end" -e $script 2 {"hello"} 1 1 {"hey"} 1 * *
+stap_run "$test_name foreach (... val\[*, *\])" "" "11 end" -e $script 2 {"hello"} 1 1 {"hey"} 1 * *
# testing foreach( a=[b,c] in val[int, int] )
-stap_run {$test_name foreach (... val[int, int])} "" "2 end" -e $script 2 2 2 3 3 3 2 2
+stap_run "$test_name foreach (... val\[int, int\])" "" "2 end" -e $script 2 2 2 3 3 3 2 2
# testing foreach( a=[b,c] in val[string, string] ), where there is a match
-stap_run {$test_name foreach (... val[string, string])} "" "1 end" -e $script {"asdf"} {"jkl"} 1 {"fdsa"} {"lkj"} 2 {"asdf"} {"jkl"}
+stap_run "$test_name foreach (... val\[string, string\])" "" "1 end" -e $script {"asdf"} {"jkl"} 1 {"fdsa"} {"lkj"} 2 {"asdf"} {"jkl"}
# testing foreach( a=[b,c] in val[variable, *] ), where there is a match
-stap_run {$test_name foreach (... val[variable, *])} "" "4 end" -e $script 9 1 4 8 9 9 {val[8,9]} *
+stap_run "$test_name foreach (... val\[variable, *\])" "" "4 end" -e $script 9 1 4 8 9 9 {val[8,9]} *
-# testing foreach( a=[b,c] in val[string, variable/string] ), where there is a match
-stap_run {$test_name foreach (... val[variable, string])} "" "asdf end" -e $script {"hi"} {"hello"} {"asdf"} {"hi"} {"hi"} {"hello"} {"hi"} {val["hi","hi"]}
+# testing foreach( a=[b,c] in val[string, variable/string] ), where
+# there is a match
+stap_run "$test_name foreach (... val\[variable, string\])" "" "asdf end" -e $script {"hi"} {"hello"} {"asdf"} {"hi"} {"hi"} {"hello"} {"hi"} {val["hi","hi"]}
# testing foreach(... val[c,d]){c++;d++}
-# in this case, expecting the c++ and d++ to not affect the c and d in the array slice
+# in this case, expecting the c++ and d++ to not affect the c and d in
+# the array slice
set script { \
global val, c=1, d=3; \
probe begin { \
foreach ([a,b] in val[c,d]){print(val[a,b]);c++;d++} \
} \
}
-stap_run {$test_name foreach (... val[c,d]) {c++;d++;}} "" "5" -e $script
+stap_run "$test_name foreach (... val\[c,d\]) {c++;d++;}" "" "5" -e $script
# testing foreach(.. val[expression, *])
set script { \
foreach ([a,b] in val[(c==d ? d : c), *]){print(val[a,b])} \
} \
}
-stap_run {$test_name foreach (... val[expression,*])} "" "5" -e $script
+stap_run "$test_name foreach (... val\[expression,*\])" "" "5" -e $script
# testing sorting in foreach loops
set script { \
foreach ([a,b] in stats[*,1] @sum-) print(@sum(stats[a,b])); \
} \
}
-stap_run {$test_name foreach sorting} "" "1234554321985" -e $script
+stap_run "$test_name foreach sorting" "" "1234554321985" -e $script
# testing array slicing with delete statements
}
# testing delete val[*,*]
-stap_run {$test_name delete val[*,*]} "" "00" -e $script * *
+stap_run "$test_name delete val\[*,*\]" "" "00" -e $script * *
# testing delete val[*, string]
-stap_run {$test_name delete val[*, string]} "" "06" -e $script * {"hello"}
+stap_run "$test_name delete val\[*, string\]" "" "06" -e $script * {"hello"}
# testing delete val[int,*]
-stap_run {$test_name delete val[int, *]} "" "90" -e $script 300 *
+stap_run "$test_name delete val\[int, *\]" "" "90" -e $script 300 *
# testing delete val[expression,*]
-stap_run {$test_name delete val[epression, *]} "" "90" -e $script {(val[9,"hello"] == val[300,"there"] ? 9 : 300)} *
+stap_run "$test_name delete val\[epression, *\]" "" "90" -e $script {(val[9,"hello"] == val[300,"there"] ? 9 : 300)} *
# testing delete statements on pmaps
set script { \
print (@count(stats[1, 1])); print(@count(stats[2,2])); \
} \
}
-stap_run {$test_name delete pmaps} "" "01" -e $script
+stap_run "$test_name delete pmaps" "" "01" -e $script
# testing membership, [*, *] in foo
set script { \
} \
}
# testing membership [*,*]
-stap_run {$test_name membership [*,*] in val} "" "in" -e $script * *
+stap_run "$test_name membership \[*,*\] in val" "" "in" -e $script * *
# testing membership [*, string]
-stap_run {$test_name membership [*, string] in val} "" "in" -e $script * {"hello"}
+stap_run "$test_name membership \[*, string\] in val" "" "in" -e $script * {"hello"}
# testing membership [int,*]
-stap_run {$test_name membership [int, *] in val} "" "not in" -e $script 309 *
+stap_run "$test_name membership \[int, *\] in val" "" "not in" -e $script 309 *
# testing membership [expression,*]
-stap_run {$test_name membership [expression,*] in val} "" "not in" -e $script {(val[9, "hello"] == val[300, "there"]? 9 : 900)} *
+stap_run "$test_name membership \[expression,*\] in val" "" "not in" -e $script {(val[9, "hello"] == val[300, "there"]? 9 : 900)} *
# testing membership with pmaps
set script { global stats \
print([1, *] in stats); print([2, *] in stats) \
} \
}
-stap_run {$test_name membership pmaps} "" "10" -e $script
+stap_run "$test_name membership pmaps" "" "10" -e $script
-# testing membership with pmaps, to make sure it doesn't re-aggregate in the loop
+# testing membership with pmaps, to make sure it doesn't re-aggregate
+# in the loop
set script { global stats \
probe begin {stats[1,1] <<< 2; exit();} \
probe end { \
print("systemtap starting probe\nsystemtap ending probe\n"); \
- foreach([x,y] in stats) println([1,*] in stats) \
+ foreach([x,y] in stats) print([1,*] in stats) \
} \
}
-stap_run {$test_name membership pmaps (2)} "" "1" -e $script
+stap_run "$test_name membership pmaps (2)" "" "1" -e $script
set testpath "$srcdir/$subdir"
# Check @var() is usable in the kernel tracepoint probes.
-set output_string "sys_tz = {.tz_minuteswest=-?\\d+, .tz_dsttime=\\d+}"
+set output_string "sys_tz = {.tz_minuteswest=-?\\d+, .tz_dsttime=\\d+}\r\n"
# Only run on make installcheck
if {! [installtest_p]} { untested "$test"; return }
# Test global vars are usable in the kernel tracepoint probes.
+global sys_tz_str
+
+probe begin
+{
+ log("systemtap starting probe")
+}
+
probe kernel.trace("sched_switch")
{
- log("systemtap starting probe");
- log("systemtap ending probe");
- printf("sys_tz = %s\n", @var("sys_tz@time.c")$$);
- exit();
+ sys_tz_str = @var("sys_tz@time.c")$$
+ exit()
+}
+
+probe end
+{
+ log("systemtap ending probe")
+ printf("sys_tz = %s\n", sys_tz_str)
}
probe end(0) { endstr .= "x" }
probe end(9223372036854775807) {
endstr .= "z"
+ rc = 0
if (beginstr == "abccde")
- println("systemtap test success")
+ rc += 1
else
printf("systemtap test failure - beginstr:%s != abccde\n", beginstr)
if (endstr == "vwxxyz")
- println("systemtap test success")
+ rc += 1
else
printf("systemtap test failure - endstr:%s != vwxxyz\n", endstr)
+
+ if (rc == 2)
+ println("systemtap test success")
+ else
+ printf("systemtap test failure (%d passes)\n", rc)
}
probe end(-9223372036854775808) { endstr .= "v" }
set test "div0"
-set output_string "(.*)division by 0 near(.*)"
+set output_string {ERROR: division by 0 near[^\r\n]+\r\n}
foreach runtime [get_runtime_list] {
if {$runtime != ""} {
foreach runtime [get_runtime_list] {
if {$runtime != ""} {
- stap_run $srcdir/$subdir/$test.stp no_load ".*synthetic error.*" \
+ stap_run $srcdir/$subdir/$test.stp no_load "ERROR: synthetic error\r\n" \
--runtime=$runtime
} else {
- stap_run $srcdir/$subdir/$test.stp no_load ".*synthetic error.*"
+ stap_run $srcdir/$subdir/$test.stp no_load "ERROR: synthetic error\r\n"
}
}
}
probe end {
+ rc = 0
if (gnum_saved == 42)
- println("systemtap test success")
+ rc += 1
else
printf("systemtap test failure - gnum_saved:%d != 42\n", gnum_saved)
if (gstr_saved == "foobar")
- println("systemtap test success")
+ rc += 1
else
printf("systemtap test failure - gstr_saved:%s != foobar\n", gstr_saved)
+
+ if (rc == 2)
+ println("systemtap test success")
+ else
+ printf("systemtap test failure (%d passes)\n", rc)
}
# Check the righ "kernel/time.c" is picked up (both in the syscall probe
# context and the stap function context.
-set output_string "sys_tz = {.tz_minuteswest=-?\\d+, .tz_dsttime=\\d+}\r\nf: {.tz_minuteswest=-?\\d+, .tz_dsttime=\\d+}"
+set output_string "sys_tz = {.tz_minuteswest=-?\\d+, .tz_dsttime=\\d+}\r\nf: {.tz_minuteswest=-?\\d+, .tz_dsttime=\\d+}\r\n"
# Only run on make installcheck
if {! [installtest_p]} { untested "$test"; return }
}
probe end {
+ rc = 0
if (c == 42)
- println("systemtap test success")
+ rc += 1
else
printf("systemtap test failure - c:%d != 42\n", c)
if (d == (c + g))
- println("systemtap test success")
+ rc += 1
else
printf("systemtap test failure - d:%d != %d\n", d, (c+g))
if (a == d)
- println("systemtap test success")
+ rc += 1
else
printf("systemtap test failure - a:%d != %d\n", a, d)
if (f == c)
- println("systemtap test success")
+ rc += 1
else
printf("systemtap test failure - f:%d != %d\n", f, c)
if (e[0] == "a")
- println("systemtap test success")
+ rc += 1
else
printf("systemtap test failure - e:%s != a\n", e[0])
if (gstr_saved == "foobar")
- println("systemtap test success")
+ rc += 1
else
printf("systemtap test failure - gstr_saved:%s != foobar\n", gstr_saved)
+
+ if (rc == 6)
+ println("systemtap test success")
+ else
+ printf("systemtap test failure (%d passes)\n", rc)
}
set test "if"
-# Note that we're looking for the all_pass_string twice, since the
-# test case prints it twice.
-
foreach runtime [get_runtime_list] {
if {$runtime != ""} {
- stap_run $srcdir/$subdir/$test.stp no_load "${all_pass_string}${all_pass_string}" \
+ stap_run $srcdir/$subdir/$test.stp no_load $all_pass_string \
--runtime=$runtime
} else {
- stap_run $srcdir/$subdir/$test.stp no_load "${all_pass_string}${all_pass_string}"
+ stap_run $srcdir/$subdir/$test.stp no_load $all_pass_string
}
}
probe end
{
+ rc = 0
println("systemtap ending probe")
if (1) {
- println("systemtap test success");
+ rc += 1
} else {
println("systemtap test failure");
}
if (0) {
println("systemtap test failure");
} else {
- println("systemtap test success");
+ rc += 1
}
+
+ if (rc == 2)
+ println("systemtap test success")
+ else
+ printf("systemtap test failure (%d passes)\n", rc)
}
set test "kprobes"
-stap_run $srcdir/$subdir/$test.stp no_load "probe point hit"
+stap_run $srcdir/$subdir/$test.stp no_load "probe point hit\r\n"
probe end
{
+ rc = 0
println("systemtap ending probe")
if (x1_0 && x3_0 ) {
println("systemtap test failure");
} else {
- println("systemtap test success");
+ rc += 1
}
if (x2_1 && x3_0 ) {
println("systemtap test failure");
} else {
- println("systemtap test success");
+ rc += 1
}
if (x1_0 && x4_1 ) {
println("systemtap test failure");
} else {
- println("systemtap test success");
+ rc += 1
}
if (x2_1 && x4_1 ) {
- println("systemtap test success");
+ rc += 1
} else {
println("systemtap test failure");
}
+
+ if (rc == 4)
+ println("systemtap test success")
+ else
+ printf("systemtap test failure (%d passes)\n", rc)
}
kernel.function("do_select").return { foo++ }
probe timer.ms(1000) { exit(); }
- probe begin { log("systemtap starting probe"); log("systemtap ending probe");}
+ probe begin { log("systemtap starting probe") }
+ probe end { log("systemtap ending probe"); printf("foo = %d\n", foo) }
}
# Run script1 and save the number of skipped probes (which will most
# likely be 0).
-stap_run "MAXACTIVE01" sleep_one_sec "" -e $script1
+stap_run "MAXACTIVE01" sleep_one_sec {foo = \d+\r\n} -e $script1
set skipped1 $skipped_probes
# Script2. For 1 second, probe the return of "vfs_read" and
kernel.function("do_select").return.maxactive(1) { foo++ }
probe timer.ms(1000) { exit(); }
- probe begin { log("systemtap starting probe"); log("systemtap ending probe");}
+ probe begin { log("systemtap starting probe") }
+ probe end { log("systemtap ending probe"); printf("foo = %d\n", foo) }
}
# Run script2 and save the number of skipped probes.
-set output_string "(WARNING: Number of errors: 0, skipped probes: \\d+\r\n)?"
+set output_string {foo = \d+\r\n(WARNING: Number of errors: 0, skipped probes: \d+\r\n)?}
stap_run "MAXACTIVE02" sleep_one_sec $output_string -e $script2
set skipped2 $skipped_probes
proc opener {} { # the test uses syscall.open -- make sure it happens
exec cat /dev/null
+ exec cat /dev/null
+ wait_n_secs 1
return 0;
}
set test "print"
+set output_string "(${all_pass_string}){9}"
foreach runtime [get_runtime_list] {
if {$runtime != ""} {
- stap_run $srcdir/$subdir/$test.stp no_load $all_pass_string \
+ stap_run $srcdir/$subdir/$test.stp no_load $output_string \
--runtime=$runtime
} else {
- stap_run $srcdir/$subdir/$test.stp no_load $all_pass_string
+ stap_run $srcdir/$subdir/$test.stp no_load $output_string
}
}
}
# Expected output
-set output_string "Encountered \[0-4\] functions, and \[0-2\] marks"
+set output_string "Encountered \[0-4\] functions, and \[0-2\] marks\r\n"
# Running the test program and script
foreach runtime [get_runtime_list] {
}
# expected output
-set output_string "pass"
+set output_string "pass\r\n"
# running multiple instances of the test program
# the idea behind this is that in the stap script, it will check the pid it is
# Buffer is exactly large enough to hold contents
set test "PROCFS_BUFFER9"
-stap_run $test proc_read_write_46 "" -DSTP_PROCFS_BUFSIZE=46 -e $script5 -m $test
+stap_run $test proc_read_write_46 "\r\n" -DSTP_PROCFS_BUFSIZE=46 -e $script5 -m $test
exec /bin/rm -f ${test}.ko
}
# test procfs umask probes
-set output_string "Testing permissions\r\n"
+set output_string "Testing permissions\r\nvalue=\"600\r\n\"\r\n"
stap_run $test check_perm_val $output_string -e $systemtap_script -m $test
exec /bin/rm -f ${test}.ko
foreach test_name $test_names {
set test_val 6
# Expected output
- set output_string "pass"
+ set output_string "pass\r\n"
if {! [installtest_p]} {
untested $test_name
return
printf("systemtap ending probe\n");
if (num = (num + $1))
- printf("passed the test\n");
+ printf("pass\n");
else
- printf("failed the test\n");
+ printf("fail\n");
exit();
}
printf("systemtap ending probe\n");
if (num == 5)
- printf("passed the test\n");
+ printf("pass\n");
else
- printf("failed the test\n");
+ printf("fail\n");
exit();
}
#check to see whether get the marker indicating the probe is loaded and running
#should check to see whether exited for some reason
#should be error is something else is printed.
-set output_string "(\\w+ = \\d+\r\n){7}${all_pass_string}(WARNING.*skipped.*)?"
+set output_string "(\\w+ = \\d+\r\n){7}(${all_pass_string}){4}(WARNING.*skipped.*)?"
stap_run $srcdir/$subdir/$test.stp sleep_ten_secs $output_string
probe end
{
+ rc = 0
println("systemtap ending probe")
x4 = x1 ? 9: 10;
x5 = x2 ? 99: 100;
if (x4 != 10 ) {
println("systemtap test failure");
} else {
- println("systemtap test success");
+ rc += 1
}
if (x5 != 99 ) {
println("systemtap test failure");
} else {
- println("systemtap test success");
+ rc += 1
}
if (x6 != 999 ) {
println("systemtap test failure");
} else {
- println("systemtap test success");
+ rc += 1
}
+
+ if (rc == 3)
+ println("systemtap test success")
+ else
+ printf("systemtap test failure (%d passes)\n", rc)
}
# can't really test user_ns right now since we don't know other uids
set ns_tests { pid_ns }
-set output_string "END"
+set output_string "END\r\n"
# before we can even run the test, check that unshare is available
# probably only available in kernels >= 2.6.16
return
}
+# Note we have to be root to run "unshare".
+set effective_uid [exec /usr/bin/id -u]
+if {$effective_uid != 0} {
+ untested "$test_name (must be root)"
+ return
+}
# use unshare to generate new namespaces to use
# the returned pid is not the new proc's pid (as seen in the root ns)
// all that we can really do is make a comparison between the original
// and the namespace aware versions.
// need to check all the conditionals otherwise this test case will fail when it should just be untested
- if (check_for_pid_ns() && !hit_pp){
- hit_pp = 1;
- if (pid() == ns_pid()) println("FAIL: pid() matches ns_pid()");;
- if (tid() == ns_tid()) println("FAIL: tid() matches ns_tid()");
- if (ppid() == ns_ppid()) println("FAIL: ppid() matches ns_ppid()");
- if (sid() == ns_sid()) println("FAIL: sid() matches ns_sid()");
- if (pgrp() == ns_pgrp()) println("FAIL: pgrp() matches ns_pgrp()");
+ if (check_for_pid_ns()) {
+ if (!hit_pp) {
+ hit_pp = 1;
+ if (pid() == ns_pid()) println("FAIL: pid() matches ns_pid()");;
+ if (tid() == ns_tid()) println("FAIL: tid() matches ns_tid()");
+ if (ppid() == ns_ppid()) println("FAIL: ppid() matches ns_ppid()");
+ if (sid() == ns_sid()) println("FAIL: sid() matches ns_sid()");
+ if (pgrp() == ns_pgrp()) println("FAIL: pgrp() matches ns_pgrp()");
+ }
} else {
// this test case is kind of skipped. this should be checked in the tcl file
println("FAIL: not configured for pid namespaces");
}
set tests {usymfileline usymline usymfile}
-set expectedoutput {".*usymfileline.cxx:\[4-5]" "\[4-5]" ".*usymfileline.cxx"}
+set expectedoutput {".*usymfileline.cxx:\[4-5]\r\n" "\[4-5]\r\n" ".*usymfileline.cxx\r\n"}
foreach test $tests eoutput $expectedoutput {
set testscript [string map "TAPSETFUNCTION $test" $script]
# test with an invalid address. the expected output is the same for all cases
- stap_run "$test ()" no_load "0x0" -e $testscript 0 -c ./usymfileline
+ stap_run "$test ()" no_load "0x0\r\n" -e $testscript 0 -c ./usymfileline
# test with uaddr()
stap_run "$test ()" no_load $eoutput -e $testscript uaddr() -c ./usymfileline
}
}\
probe end { if (failed == 0) println("passed") }\
}
-stap_run "pp == usymfileline" no_load "passed" -e $script -c ./usymfileline
+stap_run "pp == usymfileline" no_load "passed\r\n" -e $script -c ./usymfileline
eval exec objcopy -R .debug_line $testname
foreach test $tests {
set testscript [string map "TAPSETFUNCTION $test" $script]
# test with uaddr(). check that it can still fail gracefully.
- stap_run "$test (no debug_line)" no_load "0x\[0-9,a-f]*" -e $testscript uaddr() -c ./usymfileline
+ stap_run "$test (no debug_line)" no_load "0x\[0-9,a-f]*\r\n" -e $testscript uaddr() -c ./usymfileline
}
exec rm -f ./$testname
set test "memory1"
-set ::result_string {Test passed}
+set ::result_string {Test passed\r\n}
if {![installtest_p]} {
untested $test
return 0
}
-set output_string "(\\w+ = \\d+\r\n){5}${all_pass_string}(WARNING.*skipped.*)?"
+set output_string "(\\w+ = \\d+\r\n){5}(${all_pass_string}){2}(WARNING.*skipped.*)?"
stap_run $srcdir/$subdir/$test.stp current_load $output_string -g -w