diff options
author | fche <fche> | 2006-08-12 05:13:09 +0000 |
---|---|---|
committer | fche <fche> | 2006-08-12 05:13:09 +0000 |
commit | 814bc89d4635f101b2c0077598f31aad95ed15b7 (patch) | |
tree | 407a49dbaf446af4751f5068607a7fb8dad0611d /testsuite/systemtap.base | |
parent | 6b6d04673a1ef175821afc7d4fabdb496698e8e3 (diff) | |
download | systemtap-steved-814bc89d4635f101b2c0077598f31aad95ed15b7.tar.gz systemtap-steved-814bc89d4635f101b2c0077598f31aad95ed15b7.tar.xz systemtap-steved-814bc89d4635f101b2c0077598f31aad95ed15b7.zip |
2006-08-12 Frank Ch. Eigler <fche@elastic.org>
* configure.ac, Makefile.am: Descend into testsuite/
directory. Remove local test logic.
* configure, Makefile.in: Regenerated.
* runtest.sh: Not yet removed.
* HACKING: Update for new testsuite layout.
2006-08-12 Frank Ch. Eigler <fche@elastic.org>
* all: Reorganized old pass-1..4 tests one dejagnu bucket.
Moved over old pass-5 tests, except for disabled syscalls tests.
* Makefile (installcheck): New target for running pass-1..5
tests against installed systemtap.
Diffstat (limited to 'testsuite/systemtap.base')
30 files changed, 668 insertions, 0 deletions
diff --git a/testsuite/systemtap.base/add.exp b/testsuite/systemtap.base/add.exp new file mode 100644 index 00000000..e0522ae2 --- /dev/null +++ b/testsuite/systemtap.base/add.exp @@ -0,0 +1,7 @@ +# Simple function to test that systemtap addition works + +load_lib "stap_run.exp" + +set test "add" + +stap_run $srcdir/$subdir/$test.stp no_load $all_pass_string diff --git a/testsuite/systemtap.base/add.stp b/testsuite/systemtap.base/add.stp new file mode 100644 index 00000000..3fa7be38 --- /dev/null +++ b/testsuite/systemtap.base/add.stp @@ -0,0 +1,26 @@ +/* + * add.stp + * + * Check the systemtap "addition" works + */ + +global x3 +global x1 +global x2 + +probe begin +{ + log("systemtap starting probe") + x1 = 42; x2 = 53; +} + +probe end +{ + log("systemtap ending probe") + x3 = x1 + x2; + if (x3 != 95 ) { + log("systemtap test failure"); + } else { + log("systemtap test success"); + } +} diff --git a/testsuite/systemtap.base/bench.exp b/testsuite/systemtap.base/bench.exp new file mode 100644 index 00000000..bc3b28bb --- /dev/null +++ b/testsuite/systemtap.base/bench.exp @@ -0,0 +1,14 @@ +set test "bench" + +if {![installtest_p]} {untested $test; return} + +spawn stap -tu $srcdir/$subdir/bench.stp +set ok 0 +expect { + -timeout 180 + -re {probe[^\r]*\r} { incr ok; exp_continue } + timeout { fail "$test (timeout)" } + eof { } +} +wait +if {$ok > 10} { pass "$test ($ok)" } { fail "$test ($ok)" } diff --git a/testsuite/systemtap.base/bench.stp b/testsuite/systemtap.base/bench.stp new file mode 100644 index 00000000..0568bc97 --- /dev/null +++ b/testsuite/systemtap.base/bench.stp @@ -0,0 +1,31 @@ + +// This bucket aims to trigger all basic generated C code constructs. +// It should be run with "-tu". + +probe repeat = begin,begin,begin,begin,begin,begin,begin,begin, + begin,begin,begin,begin,begin,begin,begin,begin, + begin,begin,begin,begin,begin,begin,begin,begin, + begin,begin,begin,begin,begin,begin,begin,begin, + begin,begin,begin,begin,begin,begin,begin,begin + {} + +probe test.null = repeat {} probe test.null {} // null probe +probe test.intassmt = repeat {i = 0} probe test.intassmt {} +probe test.gintassmt = repeat {gn = 0} probe test.gintassmt {} global gn +probe test.intincr = repeat {i++} probe test.intincr {} +probe test.gintincr = repeat {gn++} probe test.gintincr {} + +probe test.strassmt = repeat {s=""} probe test.strassmt {} +probe test.gstrassmt = repeat {gs=""} probe test.gstrassmt {} global gs + +probe test.forloop = repeat {for(i=0;i<10;i++) ;} probe test.forloop {} +probe test.ifgint = repeat {if (gn>0) ;} probe test.ifgint {} +probe test.next = repeat {next} probe test.next {} + +probe test.stataccum = repeat {gS <<< 1} probe test.stataccum {} global gS +probe test.statcount = repeat {@count(gS)} probe test.statcount {} + +probe test.nnarrassmt = repeat {gnn[1] = 1} probe test.nnarrassmt {} global gnn +probe test.ssarrassmt = repeat {gss["foo"] = "bar"} probe test.ssarrassmt {} global gss + +probe begin { exit () } diff --git a/testsuite/systemtap.base/div0.exp b/testsuite/systemtap.base/div0.exp new file mode 100644 index 00000000..169ded56 --- /dev/null +++ b/testsuite/systemtap.base/div0.exp @@ -0,0 +1,10 @@ +# Simple function to test that systemtap divide by 0 doesn't kill the machine +# FIXME correct the output check + +load_lib "stap_run.exp" + +set test "div0" + +set output_string "(.*)division by 0 near(.*)" + +stap_run $srcdir/$subdir/$test.stp no_load $output_string diff --git a/testsuite/systemtap.base/div0.stp b/testsuite/systemtap.base/div0.stp new file mode 100644 index 00000000..65710f09 --- /dev/null +++ b/testsuite/systemtap.base/div0.stp @@ -0,0 +1,27 @@ +/* + * div.stp0 + * + * Check the systemtap divide by 0 does not kill the machine + * FIXME this test needs to be refined + */ + +global x3 +global x1 +global x2 + +probe begin +{ + log("systemtap starting probe") + x1 = 56088; x2 = 0; +} + +probe end +{ + log("systemtap ending probe") + x3 = x1 / x2; + if (x3 != 456 ) { + log("systemtap test failure"); + } else { + log("systemtap test success"); + } +} diff --git a/testsuite/systemtap.base/equal.exp b/testsuite/systemtap.base/equal.exp new file mode 100644 index 00000000..eda645d2 --- /dev/null +++ b/testsuite/systemtap.base/equal.exp @@ -0,0 +1,10 @@ +# Simple function to test that equal operation works + +load_lib "stap_run.exp" + +set test "equal" + +# better have a count other than zero to show that probe fired +set output_string "count = \[1-9\]\[0-9\]*\r\ncount2 = \[1-9\]\[0-9\]*\r\nsystemtap test success\r\n" + +stap_run $srcdir/$subdir/$test.stp no_load $output_string diff --git a/testsuite/systemtap.base/equal.stp b/testsuite/systemtap.base/equal.stp new file mode 100644 index 00000000..83ca0115 --- /dev/null +++ b/testsuite/systemtap.base/equal.stp @@ -0,0 +1,28 @@ +/* + * equal.stp + * + * Simple function to test that equal operation works + */ + +global count +global count2 + +probe begin { log("systemtap starting probe") } + +probe kernel.function("schedule") { ++count; ++count2; } + +probe end +{ + log("systemtap ending probe") + log("count = " . sprint(count)); + log("count2 = " . sprint(count)); + if ( count == count2) { + if ( (count-1) == count2 ) { + log("systemtap test failure"); + } else { + log("systemtap test success"); + } + } else { + log("systemtap test failure"); + } +} diff --git a/testsuite/systemtap.base/finloop2.exp b/testsuite/systemtap.base/finloop2.exp new file mode 100644 index 00000000..1b253cba --- /dev/null +++ b/testsuite/systemtap.base/finloop2.exp @@ -0,0 +1,11 @@ +# Simple function to test that systemtap can generate a kernel module that +# instruments a function, install it, and get some output. + +load_lib "stap_run.exp" + +set test "finloop2" + +# better have a count other than zero to show that probe fired +set output_string "count = \[1-9\]\[0-9\]*\r\nloop_count = \[1-9\]\[0-9\]*\r\nsystemtap test success\r\n" + +stap_run $srcdir/$subdir/$test.stp no_load $output_string diff --git a/testsuite/systemtap.base/finloop2.stp b/testsuite/systemtap.base/finloop2.stp new file mode 100644 index 00000000..8f12fd8a --- /dev/null +++ b/testsuite/systemtap.base/finloop2.stp @@ -0,0 +1,34 @@ +/* + * kfunct.stp + * + * Check the systemtap avoids infinite loops + * install it, and get some output. + */ + +global count +global loop_count + +probe begin +{ + log("systemtap starting probe") +} + +probe kernel.function("schedule") +{ + ++count; + for(a = 1; a <=10; ++a) { + ++loop_count; + } +} + +probe end +{ + log("systemtap ending probe") + log("count = " . sprint(count)); + log("loop_count = " . sprint(loop_count)); + if ( count * 10 == loop_count) { + log("systemtap test success"); + } else { + log("systemtap test failure"); + } +} diff --git a/testsuite/systemtap.base/if.exp b/testsuite/systemtap.base/if.exp new file mode 100644 index 00000000..5fbcbf2c --- /dev/null +++ b/testsuite/systemtap.base/if.exp @@ -0,0 +1,8 @@ +# Simple function to test that systemtap can generate a kernel module that +# instruments a function, install it, and get some output. + +load_lib "stap_run.exp" + +set test "if" + +stap_run $srcdir/$subdir/$test.stp no_load $all_pass_string diff --git a/testsuite/systemtap.base/if.stp b/testsuite/systemtap.base/if.stp new file mode 100644 index 00000000..bcbafd51 --- /dev/null +++ b/testsuite/systemtap.base/if.stp @@ -0,0 +1,22 @@ +/* + * if.stp + * + * Check the systemtap if statement works + */ + +probe begin { log("systemtap starting probe") } + +probe end +{ + log("systemtap ending probe") + if (1) { + log("systemtap test success"); + } else { + log("systemtap test failure"); + } + if (0) { + log("systemtap test failure"); + } else { + log("systemtap test success"); + } +} diff --git a/testsuite/systemtap.base/inc.exp b/testsuite/systemtap.base/inc.exp new file mode 100644 index 00000000..977ad4be --- /dev/null +++ b/testsuite/systemtap.base/inc.exp @@ -0,0 +1,7 @@ +# Simple function to test that systemtap ++ works + +load_lib "stap_run.exp" + +set test "inc" + +stap_run $srcdir/$subdir/$test.stp no_load $all_pass_string diff --git a/testsuite/systemtap.base/inc.stp b/testsuite/systemtap.base/inc.stp new file mode 100644 index 00000000..f37b2cee --- /dev/null +++ b/testsuite/systemtap.base/inc.stp @@ -0,0 +1,24 @@ +/* + * inc.stp + * + * Check the systemtap ++ works + */ + +global x1 + +probe begin +{ + log("systemtap starting probe"); + x1 = 41; +} + +probe end +{ + log("systemtap ending probe"); + ++x1; + if (x1 != 42 ) { + log("systemtap test failure"); + } else { + log("systemtap test success"); + } +} diff --git a/testsuite/systemtap.base/kfunct.exp b/testsuite/systemtap.base/kfunct.exp new file mode 100644 index 00000000..e0a0f709 --- /dev/null +++ b/testsuite/systemtap.base/kfunct.exp @@ -0,0 +1,11 @@ +# Simple function to test that systemtap can generate a kernel module that +# instruments a function, install it, and get some output. + +load_lib "stap_run.exp" + +set test "kfunct" + +# better have a count other than zero to show that probe fired +set output_string "count = \[1-9\]\[0-9\]*\r\n" + +stap_run $srcdir/$subdir/$test.stp no_load $output_string diff --git a/testsuite/systemtap.base/kfunct.stp b/testsuite/systemtap.base/kfunct.stp new file mode 100644 index 00000000..15be51bd --- /dev/null +++ b/testsuite/systemtap.base/kfunct.stp @@ -0,0 +1,24 @@ +/* + * kfunct.stp + * + * Very simple function to test that systemtap can generate a kernel module, + * install it, and get some output. + */ + +global count + +probe begin +{ + log("systemtap starting probe") +} + +probe kernel.function("schedule") +{ + ++count; +} + +probe end +{ + log("systemtap ending probe") + log("count = " . sprint(count)); +} diff --git a/testsuite/systemtap.base/kmodule.exp b/testsuite/systemtap.base/kmodule.exp new file mode 100644 index 00000000..05f464f8 --- /dev/null +++ b/testsuite/systemtap.base/kmodule.exp @@ -0,0 +1,22 @@ +# Simple function to test that systemtap can generate instument a module +# function, install it, and get some output. + +load_lib "stap_run.exp" + +set test "kmodule" + +proc kmodule_load {} { + # force the filesystem to be synced + if {[lindex [local_exec "sync" "" "" 100] 0] == 0} { + return 0 + } else { + return 1 + } +} + +# better have a count other than zero to show that probe fired +set output_string "count = \[0-9\]\[0-9\]*\r\n" + +#make sure have ext3 module loaded before trying this + +stap_run $srcdir/$subdir/$test.stp kmodule_load $output_string diff --git a/testsuite/systemtap.base/kmodule.stp b/testsuite/systemtap.base/kmodule.stp new file mode 100644 index 00000000..e8f0287f --- /dev/null +++ b/testsuite/systemtap.base/kmodule.stp @@ -0,0 +1,24 @@ +/* + * kmodule.stp + * + * Simple function to test that systemtap can generate instument a module + * function, install it, and get some output. + */ + +global count + +probe begin +{ + log("systemtap starting probe") +} + +probe module("ext3").function("ext3_sync_file") +{ + ++count; +} + +probe end +{ + log("systemtap ending probe") + log("count = " . sprint(count)); +} diff --git a/testsuite/systemtap.base/logical_and.exp b/testsuite/systemtap.base/logical_and.exp new file mode 100644 index 00000000..5dc86760 --- /dev/null +++ b/testsuite/systemtap.base/logical_and.exp @@ -0,0 +1,7 @@ +# Simple function to test that systemtap logial and works + +load_lib "stap_run.exp" + +set test "logical_and" + +stap_run $srcdir/$subdir/$test.stp no_load $all_pass_string diff --git a/testsuite/systemtap.base/logical_and.stp b/testsuite/systemtap.base/logical_and.stp new file mode 100644 index 00000000..5017190b --- /dev/null +++ b/testsuite/systemtap.base/logical_and.stp @@ -0,0 +1,41 @@ +/* + * logical_and.stp + * + * Check the systemtap "logical and" works + */ + +global x1_0 +global x2_1 +global x3_0 +global x4_1 + +probe begin +{ + log("systemtap starting probe") + x1_0 = 0; x2_1 = 1; x3_0 = 0; x4_1 = 1; +} + +probe end +{ + log("systemtap ending probe") + if (x1_0 && x3_0 ) { + log("systemtap test failure"); + } else { + log("systemtap test success"); + } + if (x2_1 && x3_0 ) { + log("systemtap test failure"); + } else { + log("systemtap test success"); + } + if (x1_0 && x4_1 ) { + log("systemtap test failure"); + } else { + log("systemtap test success"); + } + if (x2_1 && x4_1 ) { + log("systemtap test success"); + } else { + log("systemtap test failure"); + } +} diff --git a/testsuite/systemtap.base/not.exp b/testsuite/systemtap.base/not.exp new file mode 100644 index 00000000..9898c2e2 --- /dev/null +++ b/testsuite/systemtap.base/not.exp @@ -0,0 +1,7 @@ +# Simple function to test that systemtap binary not works + +load_lib "stap_run.exp" + +set test "not" + +stap_run $srcdir/$subdir/$test.stp no_load $all_pass_string diff --git a/testsuite/systemtap.base/not.stp b/testsuite/systemtap.base/not.stp new file mode 100644 index 00000000..3e1bbd50 --- /dev/null +++ b/testsuite/systemtap.base/not.stp @@ -0,0 +1,24 @@ +/* + * neg.stp + * + * Check the systemtap negation works + */ + +global x2, x1 + +probe begin +{ + log("systemtap starting probe") + x1 = 0xaaaaaaaaaaaaaaaa +} + +probe end +{ + log("systemtap ending probe") + x2 = ~x1; + if ( x2 != 0x5555555555555555 ) { + log("systemtap test failure"); + } else { + log("systemtap test success"); + } +} diff --git a/testsuite/systemtap.base/probefunc.exp b/testsuite/systemtap.base/probefunc.exp new file mode 100644 index 00000000..10190fc9 --- /dev/null +++ b/testsuite/systemtap.base/probefunc.exp @@ -0,0 +1,58 @@ +# Test cases for probefunc() function + +load_lib "stap_run.exp" + +proc grep {fd re } { + while {[gets $fd s] >= 0} { + if [regexp $re $s] { + return $s + } + } +} + +proc sleep_one_sec {} { + after 1000; + return 0; +} + +set systemtap_script { + global funcname + probe %s { + funcname = probefunc() + } + probe begin { + log("systemtap starting probe") + } + probe end { + log("systemtap ending probe") + printf("%%s\n", funcname) + } +} + +# open /proc/kallsyms to get address for scheduler_tick symbol +set symf "/proc/kallsyms" +set symfd [open $symf r] +set re "\\mscheduler_tick\\M" +set rs [grep $symfd $re] +set flds [split $rs " "] +set addr [lindex $flds 0] +close $symfd + +set prefix "probefunc:" + +# test probefunc() with kernel.statement() +set output_string "\\mscheduler_tick\\M" +set probepoint "kernel.statement(0x$addr)" +set script [format $systemtap_script $probepoint] +stap_run $prefix$probepoint sleep_one_sec $output_string -e $script + +# test probefunc() with kernel.function() +set probepoint "kernel.function(\"scheduler_tick\")" +set script [format $systemtap_script $probepoint] +stap_run $prefix$probepoint sleep_one_sec $output_string -e $script + +# test probefunc() with kernel.inline() +set output_string "\\mcontext_switch\\M" +set probepoint "kernel.inline(\"context_switch\")" +set script [format $systemtap_script $probepoint] +stap_run $prefix$probepoint sleep_one_sec $output_string -e $script diff --git a/testsuite/systemtap.base/simple.exp b/testsuite/systemtap.base/simple.exp new file mode 100644 index 00000000..b22114f9 --- /dev/null +++ b/testsuite/systemtap.base/simple.exp @@ -0,0 +1,11 @@ +# Very simple function to test that systemtap can generate a kernel module, +# install it, and get some output. + +load_lib "stap_run.exp" + +set test "simple" + +#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. +stap_run $srcdir/$subdir/$test.stp diff --git a/testsuite/systemtap.base/simple.stp b/testsuite/systemtap.base/simple.stp new file mode 100644 index 00000000..28a81cff --- /dev/null +++ b/testsuite/systemtap.base/simple.stp @@ -0,0 +1,16 @@ +/* + * simple.stp + * + * Very simple function to test that systemtap can generate a kernel module, + * install it, and get some output. + */ + +probe begin +{ + log("systemtap starting probe") +} + +probe end +{ + log("systemtap ending probe") +} diff --git a/testsuite/systemtap.base/timeofday.exp b/testsuite/systemtap.base/timeofday.exp new file mode 100644 index 00000000..0597b153 --- /dev/null +++ b/testsuite/systemtap.base/timeofday.exp @@ -0,0 +1,30 @@ +# timeofday.exp +# +# This test is meant to make sure that our time functions can still be called +# from contexts where do_gettimeofday is unsafe (e.g. when xtime_lock is held). +# See bug #2525 for more details. + +load_lib "stap_run.exp" + +proc sleep_one_sec {} { + after 1000; + return 0; +} + +set systemtap_script { + global timeofday + probe kernel.function("do_timer") { + timeofday = gettimeofday_us() + } + probe begin { + log("systemtap starting probe") + } + probe end { + log("systemtap ending probe") + printf("%d\n", timeofday) + } +} + +set output_string "\\d+\\r\\n" + +stap_run "timeofday test" sleep_one_sec $output_string -e $systemtap_script diff --git a/testsuite/systemtap.base/timers.exp b/testsuite/systemtap.base/timers.exp new file mode 100644 index 00000000..40870f61 --- /dev/null +++ b/testsuite/systemtap.base/timers.exp @@ -0,0 +1,18 @@ +# Test the functionality of the various timer.* probes. + +load_lib "stap_run.exp" + +set test "timers" + +# A simple load that give the timers a chance to run +proc sleep_ten_secs {} { + after 10000; + return 0; +} + +#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.*)?" + +stap_run $srcdir/$subdir/$test.stp sleep_ten_secs $output_string diff --git a/testsuite/systemtap.base/timers.stp b/testsuite/systemtap.base/timers.stp new file mode 100644 index 00000000..9f370e74 --- /dev/null +++ b/testsuite/systemtap.base/timers.stp @@ -0,0 +1,73 @@ +/* + * timers.stp + * + * Test the functionality of the various timer.* probes. + */ + +global p +global j1, j2, jmax +global ms1, ms500, msmax + +probe begin +{ + log("systemtap starting probe") +} + +probe timer.profile { ++p } + +probe timer.jiffies(1) { ++j1 } +probe timer.jiffies(2) { ++j2 } +probe timer.jiffies(1000000) { ++jmax } + +/* as long as HZ>2, ms(1) and ms(500) + * will produce different counts */ +probe timer.ms(1) { ++ms1 } +probe timer.ms(500) { ++ms500 } +probe timer.ms(1000000) { ++msmax } + +probe end +{ + log("systemtap ending probe") + log("p = " . sprint(p)) + log("j1 = " . sprint(j1)) + log("j2 = " . sprint(j2)) + log("jmax = " . sprint(jmax)) + log("ms1 = " . sprint(ms1)) + log("ms500 = " . sprint(ms500)) + log("msmax = " . sprint(msmax)) + + /* profile counter should be non-zero, and at + * least as many as the jiffies(1) counter */ + if ((p > 0) && (p >= j1)) { + log("systemtap test success") + } else { + log("unexpected profile count") + log("systemtap test failure"); + } + + /* jiffies(1) should count more than jiffies(2), + * and both should be non-zero. */ + if ((j2 > 0) && (j2 < j1)) { + log("systemtap test success") + } else { + log("unexpected jiffies count") + log("systemtap test failure"); + } + + /* ms(1) should count more than ms(500), + * and both should be non-zero. */ + if ((ms500 > 0) && (ms500 < ms1)) { + log("systemtap test success") + } else { + log("unexpected ms count") + log("systemtap test failure"); + } + + /* both 'infinite' intervals should register zero counts */ + if ((jmax == 0) && (msmax == 0)) { + log("systemtap test success") + } else { + log("unexpected count on 'infinite' interval") + log("systemtap test failure"); + } +} diff --git a/testsuite/systemtap.base/tri.exp b/testsuite/systemtap.base/tri.exp new file mode 100644 index 00000000..5f418e5b --- /dev/null +++ b/testsuite/systemtap.base/tri.exp @@ -0,0 +1,7 @@ +# Simple function to test that systemtap ?: operation works + +load_lib "stap_run.exp" + +set test "tri" + +stap_run $srcdir/$subdir/$test.stp no_load $all_pass_string diff --git a/testsuite/systemtap.base/tri.stp b/testsuite/systemtap.base/tri.stp new file mode 100644 index 00000000..80aed1e7 --- /dev/null +++ b/testsuite/systemtap.base/tri.stp @@ -0,0 +1,36 @@ +/* + * tri.stp + * + * Check the systemtap ?: operator works + */ + +global x1, x2, x3, x4, x5, x6 + +probe begin +{ + log("systemtap starting probe"); + x1 = 0; x2 = 1; x3=30; +} + +probe end +{ + log("systemtap ending probe") + x4 = x1 ? 9: 10; + x5 = x2 ? 99: 100; + x6 = x3 ? 999: 1000; + if (x4 != 10 ) { + log("systemtap test failure"); + } else { + log("systemtap test success"); + } + if (x5 != 99 ) { + log("systemtap test failure"); + } else { + log("systemtap test success"); + } + if (x6 != 999 ) { + log("systemtap test failure"); + } else { + log("systemtap test success"); + } +} |