diff options
Diffstat (limited to 'testsuite/systemtap.samples')
41 files changed, 0 insertions, 1291 deletions
diff --git a/testsuite/systemtap.samples/args.exp b/testsuite/systemtap.samples/args.exp deleted file mode 100644 index 6b1fd3d0..00000000 --- a/testsuite/systemtap.samples/args.exp +++ /dev/null @@ -1,82 +0,0 @@ -set test "args" -if {![installtest_p]} { untested $test; return } - -set stappath [exec which stap] -set staprunpath [exec which staprun] - -if [file exists $staprunpath] { - pass "$test search for staprun" -} else { - fail "$test search for staprun" - return -} - -set modname "args_[pid]" -spawn stap -w -k -p4 -m $modname $srcdir/$subdir/args.stp -set tmpdir NO_SUCH_FILE -expect { - -timeout 120 - -re {Keeping temporary directory "([/a-zA-Z0-9_]*)"} { pass "$test compile"; - set tmpdir $expect_out(1,string) } - timeout { fail "$test compile (timeout)" } - eof { } -} -catch {close}; wait - -set modpath_cwd "$modname.ko" -if [file exists $modpath_cwd] { - pass "$test search for probe module" -} else { - fail "$test search for probe module" - return -} -exec /bin/rm -f $modpath_cwd - -if [file exists $tmpdir] { - pass "$test search for tmpdir" -} else { - fail "$test search for tmpdir" - return -} - -set modpath "$tmpdir/$modname.ko" -if [file exists $modpath] { - pass "$test search for tmpdir probe module" -} else { - fail "$test search for tmpdir probe module" - return -} - -spawn $staprunpath $modpath foo=hello bar=999 -set ok 0 -expect { - -timeout 120 - -re {foo=hello bar=999} { incr ok } - timeout { } - eof { } -} -catch {close}; wait -if {$ok == 1} { - pass "$test run 1" -} else { - fail "$test run 1" -} - -spawn $staprunpath $modpath foo=goodbye bar=0 -set ok 0 -expect { - -timeout 120 - -re {foo=goodbye bar=0} { incr ok } - timeout { } - eof { } -} -catch {close}; wait -if {$ok == 1} { - pass "$test run 2" -} else { - fail "$test run 2" -} - - - -exec /bin/rm -rf $tmpdir diff --git a/testsuite/systemtap.samples/args.stp b/testsuite/systemtap.samples/args.stp deleted file mode 100644 index 84b6080e..00000000 --- a/testsuite/systemtap.samples/args.stp +++ /dev/null @@ -1,9 +0,0 @@ -#! stap - -global foo, bar - -probe begin { - printf("foo=%s bar=%d\n", foo, bar) - exit () -} - diff --git a/testsuite/systemtap.samples/arith.exp b/testsuite/systemtap.samples/arith.exp deleted file mode 100644 index c4f72793..00000000 --- a/testsuite/systemtap.samples/arith.exp +++ /dev/null @@ -1,14 +0,0 @@ -set test "arith" -if {![installtest_p]} { untested $test; return } - -spawn stap -DMAXNESTING=5 $srcdir/$subdir/arith.stp -set ok 0 -expect { - -timeout 150 - -re {passes: [0-9]* failures: 0} { incr ok } - timeout { fail "$test (timeout)" } - eof { } -} -close -wait -if {$ok == 1} { pass "$test" } { fail "$test" } diff --git a/testsuite/systemtap.samples/arith.stp b/testsuite/systemtap.samples/arith.stp deleted file mode 100644 index 59016dcb..00000000 --- a/testsuite/systemtap.samples/arith.stp +++ /dev/null @@ -1,79 +0,0 @@ -global testno, passes, failures - -function test (v,n1,n2) { - if (n1 == n2) { - passes ++ - result = "pass" - } else { - failures ++ - result = "fail" - } - println ("test " . (sprint (++testno)) . " [" . v . "]\t" . result) -} - -function stest (v,n1,n2) { - if (n1 == n2) { - passes ++ - result = "pass" - } else { - failures ++ - result = "fail" - } - println ("test " . (sprint (++testno)) . " [" . v . "]\t" . result) -} - - -probe begin { - test ("+", 0, 0+0) - test ("+", 33339999, 33330000+9999) - test ("-", -1, 2-3) - test ("==", 1, -1==-1) - test ("!=", 1, -1!=1) - test ("== s", 1, "foobar"=="foobar") - test ("<= s", 1, "fooban"<="foobar") - test ("> s", 1, "xxx">"aaa") - test ("<", 1, -1<0) - test ("<", 1, 85723838<8273823892) - test ("*", 100300400500, 1003004005 * 100) - test ("*", -1*-500, 500) - test ("/", 1003004005/1000, 1003004) - test ("%", 1003004005%1000, 5) - test ("/", -1/-1, 1) - test ("%", -1%-1, 0) - test ("/", 0/-100, 0) - test ("%", 0%-100, 0) - test ("/", (-2147483647-1)/-1, 2147483648) - test ("%", (-2147483647-1)%-1, 0) - # but (-9223372036854775807-1)/-1 may overflow - test ("%", (-9223372036854775807-1)%-1, 0) - test ("&", 0x555&0xaaa, 0) - test ("|", 0x555|0xaaa, 0xfff) - test ("^", 0x55f^0xaaf, 0xff0) - test ("&&", 0x555&&0xaaa, 1) - test ("||", 0x555||0xaaa, 1) - test ("<<", 0<<5, 0) - test ("<<", 1<<8, 0x100) - test ("<<", 120<<-2, 120) - test ("<<", 120<<0, 120) - test ("<<", -4096<<-3, -4096) - test (">>", -4096>>3, -512) - test (">>", -4096>>-3, -4096) - test (">>", 120>>-2, 120) - test (">>", 120>>0, 120) - i=1; test ("--i", --i, 0) - i=1; test ("++i", ++i, 2) - i=1; test ("i--", i--, 1) - i=1; test ("i++", i++, 1) - i=1; test ("+=", i+=4, 5) test ("after +=", i, 5) - i=5; test ("/=", i/=2, 2) test ("after /=", i, 2) - a="1" b="2"; stest (".=", a .= b, "12") stest ("after .=", a, "12") -} - - -probe timer.jiffies(1) { # some time after all the begin probes - exit () -} - -probe end { - printf ("passes: %d failures: %d\n", passes, failures) -} diff --git a/testsuite/systemtap.samples/arith_limits.exp b/testsuite/systemtap.samples/arith_limits.exp deleted file mode 100644 index 93794c8e..00000000 --- a/testsuite/systemtap.samples/arith_limits.exp +++ /dev/null @@ -1,13 +0,0 @@ -set test "arith_limits" -if {![installtest_p]} { untested $test; return } - -spawn stap -DMAXNESTING=5 $srcdir/$subdir/arith_limits.stp -set ok 0 -expect { - -timeout 150 - -re {passes: [0-9]* failures: 0} { incr ok } - timeout { fail "$test (timeout)" } - eof { } -} -wait -if {$ok == 1} { pass "$test" } { fail "$test" } diff --git a/testsuite/systemtap.samples/arith_limits.stp b/testsuite/systemtap.samples/arith_limits.stp deleted file mode 100644 index 6c620830..00000000 --- a/testsuite/systemtap.samples/arith_limits.stp +++ /dev/null @@ -1,80 +0,0 @@ -global testno, passes, failures - -function test (v,n1,n2) { - if (n1 == n2) { - passes ++ - result = "pass" - } else { - failures ++ - result = "fail" - } - printf ("test %d [%s]\t\t%s\n", testno++, v, result) -} - -# Exactly the same as test() except it will magically work for strings. -# Wouldn't it be nice if we didn't have to do this? - -function teststr (v,n1,n2) { - if (n1 == n2) { - passes ++ - result = "pass" - } else { - failures ++ - result = "fail" - } - printf ("test %d [%s]\t\t%s\n", testno++, v, result) -} - - - -probe begin { - # max/minimum signed 32-bit values. - # these could cause problems for 32-bit cpus when overflows - # occur into 64-but values - lmax = 0x7fffffff - lmin = -0x80000000 - - # max/minimum signed 64-bit values - llmax = 0x7fffffffffffffff - llmin = -0x7fffffffffffffff-1 - - # 32-bit limit tests - teststr ("string lmax", sprint(lmax), "2147483647") - teststr ("hex lmax", sprintf("0x%x", lmax), "0x7fffffff") - teststr ("string lmin", sprint(lmin), "-2147483648") - teststr ("hex lmin", sprintf("0x%x", lmin), "0xffffffff80000000") - test ("lmax/-1", lmax/-1, -2147483647); - test ("lmin/-1", lmin/-1, 2147483648); - test ("lmax +1", lmax+1, 2147483648); - test ("lmin -1", lmin-1, -2147483649); - - # 64-bit limits - teststr ("string llmax", sprint(llmax), "9223372036854775807") - teststr ("hex llmax", sprintf("0x%x", llmax), "0x7fffffffffffffff") - teststr ("string llmin", sprint(llmin), "-9223372036854775808") - teststr ("hex llmin", sprintf("0x%x", llmin), "0x8000000000000000") - test ("llmax/-1", llmax/-1, -llmax) - test ("llmax*-1", llmax*-1, -llmax) - - # the next three overflow and produce predictable, although - # wrong results - test ("llmin/-1", llmin/-1, llmin) - test ("llmin*-1", llmin*-1, llmin) - test ("llmax +1", llmax+1, llmin) - test ("llmin -1", llmin-1, llmax) - - # modulo tests - test ("llmax%1", llmax%1, 0) - test ("llmin%1", llmin%1, 0) - test ("0%1 ", 0%1, 0) - test ("0%lmax", 0%lmax, 0) - test ("1%lmax", 1%lmax, 1) - test ("0%lmin", 0%lmin, 0) - test ("1%lmin", 1%lmin, 1) - - exit() -} - -probe end { - printf ("passes: %d failures: %d\n", passes, failures) -} diff --git a/testsuite/systemtap.samples/control_limits.exp b/testsuite/systemtap.samples/control_limits.exp deleted file mode 100644 index 513b2c4d..00000000 --- a/testsuite/systemtap.samples/control_limits.exp +++ /dev/null @@ -1,46 +0,0 @@ -set test "control_limits MAXNESTING" -if {![installtest_p]} { untested $test; return } - -spawn stap -u -DMAXNESTING=5 $srcdir/$subdir/control_limits.stp -set ok 0 -expect { - -timeout 150 - -re {ERROR.*MAXNESTING} { incr ok; exp_continue } - timeout { fail "$test (timeout)" } - eof { } -} -if {$ok == 1} { pass "$test ($ok)" } { fail "$test ($ok)" } - -set test "control_limits MAXACTION" -spawn stap -u -DMAXACTION_INTERRUPTIBLE=500 $srcdir/$subdir/control_limits.stp -set ok 0 -expect { - -timeout 150 - -re {ERROR.*MAXACTION} { incr ok; exp_continue } - timeout { fail "$test (timeout)" } - eof { } -} -if {$ok == 1} { pass "$test ($ok)" } { fail "$test ($ok)" } - -set test "control_limits MAXSTRINGLEN small" -spawn stap -u -DMAXSTRINGLEN=50 $srcdir/$subdir/control_limits.stp -set ok 0 -expect { - -timeout 150 - -re {ERROR.*MAXSTRINGLEN reduced} { incr ok; exp_continue } - timeout { fail "$test (timeout)" } - eof { } -} -if {$ok == 1} { pass "$test ($ok)" } { fail "$test ($ok)" } - -set test "control_limits MAXSTRINGLEN large" -spawn stap -u -DMAXSTRINGLEN=500 $srcdir/$subdir/control_limits.stp -set ok 0 -expect { - -timeout 150 - -re {ERROR.*MAXSTRINGLEN enlarged} { incr ok; exp_continue } - timeout { fail "$test (timeout)" } - eof { } -} -if {$ok == 1} { pass "$test ($ok)" } { fail "$test ($ok)" } - diff --git a/testsuite/systemtap.samples/control_limits.stp b/testsuite/systemtap.samples/control_limits.stp deleted file mode 100644 index 89b0bae4..00000000 --- a/testsuite/systemtap.samples/control_limits.stp +++ /dev/null @@ -1,24 +0,0 @@ - -# for MAXNESTING testing -function recurse (n) { - if (n > 0) recurse (n-1) -} -probe begin { - recurse (7) -} - -# for MAXACTION testing -probe begin { - for (i=0; i<498; i++) {} -} - -# for MAXSTRINGLEN testing -probe begin { - s = "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678" # last 8 will be \0'd - if (strlen(s) < 127) error ("MAXSTRINGLEN reduced") - if (strlen(s) > 127) error ("MAXSTRINGLEN enlarged") -} - - -probe begin { exit () } - diff --git a/testsuite/systemtap.samples/crash.exp b/testsuite/systemtap.samples/crash.exp deleted file mode 100644 index 9c3e5e05..00000000 --- a/testsuite/systemtap.samples/crash.exp +++ /dev/null @@ -1,45 +0,0 @@ -# Simple test for staplog.so crash(8) extension -set test "crash" - -if {![installtest_p]} { untested $test; return } -if {![file exists $env(CRASH_LIBDIR)/staplog.so]} { untested "$test - no staplog.so"; return } - -# Load a test script -spawn stap $srcdir/$subdir/testlog.stp -m testlog -expect { - -timeout 120 - "HelloWorld\r\n" { - pass "$test - testlog.stp" - # Need to run crash(8) while this script is still running. - # Since crash(8) needs /dev/mem access, need it run as_root too. - # This [ eval ... \{ \} ] business is necessary because as_root - # evals the given list/variables in its own scope. - eval as_root \{ $srcdir/$subdir/crash.sh $env(CRASH_LIBDIR) \} - } - timeout { fail "$test - testlog.stp timeout" } - timeout { fail "$test - testlog.stp eof" } -} -catch { exec kill -INT -[exp_pid]; close ; wait } - -# The crash(8) script creates testlog/global or testlog/cpu<n> -as_root { chmod -R a+rX testlog } - -set ok 0 -foreach f [glob -nocomplain testlog/*] { - pass "$test - crash(8) generated $f" - set fp [open $f] - set chars [read $fp] - close $fp - if [string match "HelloWorld*" $chars] { - incr ok - pass "$test - crash(8) data" - } else { - fail "$test - crash(8) data $chars" - } -} -if {$ok == 0} { - fail "$test - crash(8) data" -} - -as_root { rm -rf testlog testlog.ko } - diff --git a/testsuite/systemtap.samples/crash.sh b/testsuite/systemtap.samples/crash.sh deleted file mode 100755 index 06aa414e..00000000 --- a/testsuite/systemtap.samples/crash.sh +++ /dev/null @@ -1,8 +0,0 @@ -#! /bin/sh - -crash --readnow << END -mod -s testlog testlog.ko -extend $1/staplog.so -staplog testlog -exit -END diff --git a/testsuite/systemtap.samples/gtod.c b/testsuite/systemtap.samples/gtod.c deleted file mode 100644 index abc08543..00000000 --- a/testsuite/systemtap.samples/gtod.c +++ /dev/null @@ -1,26 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <sys/time.h> -#include <unistd.h> - -int main (int argc, char *argv[]) -{ - int i; - struct timeval tv[100][2]; - int us = 0; - if (argc == 2) us = atoi(argv[1]); - for (i=0; i<100; i++) { - gettimeofday(&tv[i][0], NULL); - setsid(); - gettimeofday(&tv[i][1], NULL); - if (us) usleep(us); - } - for (i=0; i<100; i++) { - // change last 4 chars for correctly sorting even if the - // time stamps are completely same. - printf("%8d%06d :%02d appl\n", tv[i][0].tv_sec, tv[i][0].tv_usec, i); - printf("%8d%06d :%02d prog\n", tv[i][1].tv_sec, tv[i][1].tv_usec, i); - } - return 0; -} - diff --git a/testsuite/systemtap.samples/gtod.exp b/testsuite/systemtap.samples/gtod.exp deleted file mode 100644 index a8f3c9d6..00000000 --- a/testsuite/systemtap.samples/gtod.exp +++ /dev/null @@ -1,40 +0,0 @@ -# test for checking monotonic timer (PR3916) -set test "gtod" -if {![installtest_p]} { untested $test; continue } - -set wd [pwd] -set filename "$srcdir/$subdir/gtod.c" - -target_compile $filename $wd/gtod executable "" - -# non interval (check timer drift in short range) -spawn $srcdir/$subdir/gtod.sh $srcdir/$subdir/gtod.stp $wd/gtod -set ok 0 -expect { - -timeout 120 - -re {^[0-9]+ \:([0-9]+) appl\r\n[0-9]+ \:\1 kern\r\n[0-9]+ \:\1 prog\r\n} { incr ok; exp_continue } - timeout { fail "$test (timeout)" } - eof { } -} -wait -#10ms interval (check timer drift in middle range) -spawn $srcdir/$subdir/gtod.sh $srcdir/$subdir/gtod.stp $wd/gtod 10000 -expect { - -timeout 120 - -re {^[0-9]+ \:([0-9]+) appl\r\n[0-9]+ \:\1 kern\r\n[0-9]+ \:\1 prog\r\n} { incr ok; exp_continue } - timeout { fail "$test (timeout)" } - eof { } -} -wait -#100ms interval (calm down processors and CPU freq might be changed) -spawn $srcdir/$subdir/gtod.sh $srcdir/$subdir/gtod.stp $wd/gtod 100000 -expect { - -timeout 120 - -re {^[0-9]+ \:([0-9]+) appl\r\n[0-9]+ \:\1 kern\r\n[0-9]+ \:\1 prog\r\n} { incr ok; exp_continue } - timeout { fail "$test (timeout)" } - eof { } -} -wait -exec rm -f $wd/gtod -if {$ok == 300} { pass "$test ($ok)" } { fail "$test ($ok)" } - diff --git a/testsuite/systemtap.samples/gtod.sh b/testsuite/systemtap.samples/gtod.sh deleted file mode 100755 index 4d4a28c2..00000000 --- a/testsuite/systemtap.samples/gtod.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -stap $1 -c "$2 $3" | sort - diff --git a/testsuite/systemtap.samples/gtod.stp b/testsuite/systemtap.samples/gtod.stp deleted file mode 100644 index f252dc0a..00000000 --- a/testsuite/systemtap.samples/gtod.stp +++ /dev/null @@ -1,8 +0,0 @@ -global count = 0 - -probe syscall.setsid { - if (pid() == target()) { - printf("%014d :%02d kern\n", gettimeofday_us(), count); - count ++; - } -} diff --git a/testsuite/systemtap.samples/iotask.stp b/testsuite/systemtap.samples/iotask.stp deleted file mode 100644 index 1b4c7243..00000000 --- a/testsuite/systemtap.samples/iotask.stp +++ /dev/null @@ -1,44 +0,0 @@ -#! /usr/bin/env stap -# iotask.stp -# A reimplementation of user script: iotask.stp given at OLS 2005 -# in the current language. -# -# Will Cohen -# 9/22/2005 - -global names, opens -global reads, read_bytes -global writes, write_bytes - -probe kernel.function("sys_open") { - ++names[execname()]; ++opens[execname()]; -} - -probe kernel.function("sys_read") { - ++names[execname()]; ++reads[execname()]; - read_bytes[execname()] += $count; -} - -probe kernel.function("sys_write") { - ++names[execname()]; ++writes[execname()]; - write_bytes[execname()] += $count; -} - -probe begin { println( "starting probe" ); } - -probe end { - foreach( name in names){ - printf ("process: %s\n", name); - if (opens[name]) - printf ("opens=%d\n",opens[name]) - if (reads[name]){ - count = reads[name]; total=read_bytes[name]; - printf("reads=%d, sum=%d, avg=%d\n", count, total, total/count); - } - if (writes[name]){ - count = writes[name]; total=write_bytes[name]; - printf("writes=%d, sum=%d, avg=%d\n", count, total, total/count); - } - println(""); - } -} diff --git a/testsuite/systemtap.samples/iotask2.stp b/testsuite/systemtap.samples/iotask2.stp deleted file mode 100644 index cc4707b7..00000000 --- a/testsuite/systemtap.samples/iotask2.stp +++ /dev/null @@ -1,42 +0,0 @@ -global names, opens, reads, writes - -probe begin { println("starting probe") } - -probe timer.ms(10000) { - println("stopping probe after 10 seconds") - exit() -} - -probe kernel.function("sys_open") { - e=execname(); names[e]=1 - opens[e] ++ # simple integer array -} - -probe kernel.function("sys_read") { - e=execname(); names[e]=1 - reads[e] <<< $count # statistics array -} - -probe kernel.function("sys_write") { - e=execname(); names[e]=1 - writes[e] <<< $count # statistics array -} - - -probe end { - foreach (name+ in names) { # sort by name - printf("process: %s\n", name) - if (opens[name]) - printf("opens n=%d\n", opens[name]) - if (@count(reads[name])) - printf("reads n=%d, sum=%d, avg=%d\n", - @count(reads[name]), # extracting stat results - @sum(reads[name]), - @avg(reads[name])) - if (@count(writes[name])) - printf("writes n=%d, sum=%d, avg=%d\n", - @count(writes[name]), # extracting stat results - @sum(writes[name]), - @avg(writes[name])) - } -} diff --git a/testsuite/systemtap.samples/kmalloc-stacks.stp b/testsuite/systemtap.samples/kmalloc-stacks.stp deleted file mode 100644 index 25a23f2d..00000000 --- a/testsuite/systemtap.samples/kmalloc-stacks.stp +++ /dev/null @@ -1,35 +0,0 @@ -global kmalloc_stack - -function reset_maxaction () %{ - if (CONTEXT && CONTEXT->actioncount) - CONTEXT->actioncount=0; -%} - -function write_output() -{ - foreach (stack in kmalloc_stack) { - log("<hashkey>"); - print_stack(stack); - log("</hashkey>"); - print("<hashval>"); - print(sprint(kmalloc_stack[stack])); - log("</hashval>"); - reset_maxaction(); - } -} - -probe timer.jiffies(5000) -{ - write_output(); - delete kmalloc_stack; -} - -probe kernel.function("__kmalloc") -{ - kmalloc_stack[backtrace()]++; -} - -probe end -{ - write_output(); -} diff --git a/testsuite/systemtap.samples/kmalloc-top b/testsuite/systemtap.samples/kmalloc-top deleted file mode 100755 index 42a6d152..00000000 --- a/testsuite/systemtap.samples/kmalloc-top +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/perl -# -# This script accumulates the execution paths of all calls to kmalloc -# in the kernel. On Ctrl-C, it sorts, filters and displays them on -# stdout. -# -# The -e (exclude) option can be used to specify a comma-separated list -# - any stack with contents matching any of the items in the list will -# be excluded from the output. -# -# The -m (min) option can be used to specify the minimum number of -# occurrences a stack needs to be included in the output. -# -# Usage: ./kmalloc-top [-m min] [-i exclude list] -# Ctrl-c - -use Getopt::Std; - -my $kmalloc_stacks; -my $total_kmallocs; -my $sorted_stacks; -my $min_count = 1; -my $exclude; - -$SIG{INT} = \&sigint_handler; - -getopts('e:m:'); - -if ($opt_e) { - $exclude = join('|', split(/,/, $opt_e)); - print "Will exclude stacks containing: $exclude\n"; -} - -if ($opt_m) { - $min_count = $opt_n; -} -print "Will print stacks with counts >= $min_count.\n"; -print STDERR "Press Ctrl-C to stop.\n"; - -open STREAM, "stap -g kmalloc-stacks.stp |" or die "Couldn't get output stream $!"; - -while (<STREAM>) { - if (/<hashval>(.*?)<\/hashval>/) { - update_hash($key, $1); - $key = ""; - } elsif ($_ !~ (/<hashkey>|<\/hashkey>/)) { - $key .= $_; - } -} - -$num_keys_before_filtering = scalar keys %kmalloc_stacks; -filter_stacks(); -$num_keys_after_filtering = scalar keys %kmalloc_stacks; -sort_stacks(); -summarize(); -exit(); - -sub update_hash -{ - my($key, $val) = @_; - $kmalloc_stacks{$key} += $val; - $total_kmallocs += $val; -} - -sub filter_stacks -{ - while (($stack, $count) = each %kmalloc_stacks) { - if ($count < $min_count) { - delete $kmalloc_stacks{$stack}; - } elsif ($exclude && $stack =~ /$exclude/) { - delete $kmalloc_stacks{$stack}; - } - } -} - -sub sort_stacks -{ - @sorted_stacks = sort { $kmalloc_stacks{$b} <=> $kmalloc_stacks{$a} } keys %kmalloc_stacks; -} - -sub summarize { - print "\n"; - foreach $stack(@sorted_stacks) { - print "This path seen $kmalloc_stacks{$stack} times:\n$stack\n"; - } - - print "Total kmallocs (before filtering): $total_kmallocs\n"; - print "Num stacks before filtering: $num_keys_before_filtering\n"; - print "Num stacks after filtering: $num_keys_after_filtering\n"; - - close(STREAM); -} - -sub sigint_handler -{ - system("pkill kmalloc-stacks"); -} diff --git a/testsuite/systemtap.samples/pfaults.exp b/testsuite/systemtap.samples/pfaults.exp deleted file mode 100644 index 2cab7c14..00000000 --- a/testsuite/systemtap.samples/pfaults.exp +++ /dev/null @@ -1,16 +0,0 @@ -set test "pfaults" -if {![installtest_p]} { untested $test; return } - -spawn stap -DMAXACTION=10000 -g $srcdir/$subdir/pfaults.stp -set pid $spawn_id -set ok 0 -expect { - -timeout 240 - -re {Page fault tracking, start time[^\r\n]+\r\n} { incr ok; exp_continue } - -re {Page fault tracking, end time[^\r\n]+\r\n} { incr ok; exp_continue } - timeout { fail "$test (timeout)" } - eof { } -} -#FIXME does not handle case of hanging pfaults.stp correctly -wait -if {$ok == 2} { pass "$test ($ok)" } { fail "$test ($ok)" } diff --git a/testsuite/systemtap.samples/pfaults.stp b/testsuite/systemtap.samples/pfaults.stp deleted file mode 100644 index 577e93cd..00000000 --- a/testsuite/systemtap.samples/pfaults.stp +++ /dev/null @@ -1,58 +0,0 @@ -#! /usr/bin/env stap - -global pidnames, faults, fault_types - -probe vm.pagefault { - # Maintain a pid-to-execname mapping. This logic should get transplanted - # into a tapset script that is automatically included upon reference to - # its exported global variable. - pidnames[pid()] = execname() - - faults [pid(), $write_access ? 1 : 0] ++ -} - -probe vm.pagefault.return { - fault_types [pid(), $return] ++ -} - - -# Some constants, to come from a future "VM tapset" - -global VM_FAULT_OOM, VM_FAULT_SIGBUS, VM_FAULT_MINOR, VM_FAULT_MAJOR -probe begin { - VM_FAULT_OOM=-1 - VM_FAULT_SIGBUS=0 - VM_FAULT_MINOR=1 - VM_FAULT_MAJOR=2 -} - - -# Shut down the probing session after a while -probe timer.ms(1000) { report() } -probe timer.ms(10000) { exit() } - -function _(n) { return sprint(n) } # let's abbreviate - -function report () { - print ("time=" . _(gettimeofday_s()) . "\n") - foreach ([pid] in pidnames) { - if (faults[pid,0]+faults[pid,1] == 0) continue - print (pidnames[pid] . "[" . _(pid) . "]" . - " reads=" . _(faults[pid,0]) . - " writes=" . _(faults[pid,1]) . - " oom=" . _(fault_types[pid,VM_FAULT_OOM]) . - " sigbus=" . _(fault_types[pid,VM_FAULT_SIGBUS]) . - " minor=" . _(fault_types[pid,VM_FAULT_MINOR]) . - " major=" . _(fault_types[pid,VM_FAULT_MAJOR]) . - "\n") - } - delete faults - delete fault_types -} - -probe begin { - print ("Page fault tracking, start time=" . _(gettimeofday_s()) . "\n") -} -probe end { - print ("Page fault tracking, end time=" . _(gettimeofday_s()) . "\n") -} diff --git a/testsuite/systemtap.samples/poll_map.exp b/testsuite/systemtap.samples/poll_map.exp deleted file mode 100644 index 5ade48e6..00000000 --- a/testsuite/systemtap.samples/poll_map.exp +++ /dev/null @@ -1,14 +0,0 @@ -set test "poll_map" -if {![installtest_p]} { untested $test; return } - -spawn stap -g $srcdir/$subdir/poll_map.stp -set ok 0 -expect { - -timeout 400 - -ex "SUCCESS" { incr ok } - timeout { fail "$test (timeout)" } - eof { } -} -close -wait -if {$ok == 1} { pass "$test ($ok)" } { fail "$test ($ok)" } diff --git a/testsuite/systemtap.samples/poll_map.stp b/testsuite/systemtap.samples/poll_map.stp deleted file mode 100755 index cd39b433..00000000 --- a/testsuite/systemtap.samples/poll_map.stp +++ /dev/null @@ -1,33 +0,0 @@ -#! stap - -# test that polling loops do not exit when conflicts happen -# see PR 1379 - -global called, num_polls - -probe kernel.function( "sys_*" ).call { - called[execname(),probefunc()]++ -} - -probe timer.ms(1000) -{ - print("\n\n") - num_to_do = 10 - foreach ([n,f] in called-) { - printf("%s called %s\t%d times\n", n, f, called[n,f]) - num_to_do-- - if (num_to_do <= 0) - break - } - delete called - num_polls++ - if (num_polls > 30) - exit() -} - -probe end { - if (num_polls <= 30) - print ("FAIL\n") - else - print ("SUCCESS\n") -} diff --git a/testsuite/systemtap.samples/primes.exp b/testsuite/systemtap.samples/primes.exp deleted file mode 100644 index f99f67cc..00000000 --- a/testsuite/systemtap.samples/primes.exp +++ /dev/null @@ -1,21 +0,0 @@ -set test "primes" -if {![installtest_p]} { untested $test; return } - -spawn stap $srcdir/$subdir/primes.stp -set ok 0 -expect { - -timeout 150 - -ex {odds[0] = 1} { incr ok; exp_continue } - -ex {odds[1] = 3} { incr ok; exp_continue } - -ex {odds[3] = 7} { incr ok; exp_continue } - -ex {odds[4] = 9} { incr ok; exp_continue } - -ex {evens[2] = 6} { incr ok; exp_continue } - -ex {evens[1] = 4} { incr ok; exp_continue } - -ex {evens[0] = 2} { incr ok; exp_continue } - timeout { fail "$test (timeout)" } - eof { } -} -#FIXME does not handle case of hanging primes.stp correctly -wait - -if {$ok == 7} { pass "$test" } { fail "$test" } diff --git a/testsuite/systemtap.samples/primes.stp b/testsuite/systemtap.samples/primes.stp deleted file mode 100644 index 1072b4b2..00000000 --- a/testsuite/systemtap.samples/primes.stp +++ /dev/null @@ -1,23 +0,0 @@ -#! stap - -global odds, evens - -probe begin { - # "no" and "ne" are local integers - for (i=1; i<10; i++) { - if (i % 2) odds [no++] = i - else evens [ne++] = i - } - delete odds[2] - delete evens[3] - exit () -} - -probe end { - foreach (x+ in odds) { - printf("odds[%d] = %d\n", x, odds[x]) - } - foreach (x in evens-) { - printf("evens[%d] = %d\n", x, evens[x]) - } -} diff --git a/testsuite/systemtap.samples/profile.exp b/testsuite/systemtap.samples/profile.exp deleted file mode 100644 index 87174d2c..00000000 --- a/testsuite/systemtap.samples/profile.exp +++ /dev/null @@ -1,15 +0,0 @@ -set test "profile" -if {![installtest_p]} { untested $test; return } - -spawn stap -DMAXMAPENTRIES=10000 $srcdir/$subdir/profile.stp -set ok 0 -expect { - -timeout 360 - -re {kernel.function[^\r]*ttime=[0-9]*\r} { incr ok; exp_continue } - timeout { fail "$test (timeout)" } - eof { } -} -#FIXME does not handle case of hanging primes.stp correctly -wait - -if {$ok > 0} { pass $test } { fail $test } diff --git a/testsuite/systemtap.samples/profile.stp b/testsuite/systemtap.samples/profile.stp deleted file mode 100644 index 62af76ae..00000000 --- a/testsuite/systemtap.samples/profile.stp +++ /dev/null @@ -1,35 +0,0 @@ -#! /usr/bin/env stap - -global command, syscall_count, syscall_times, this_syscall_time, this_syscall - -function accumulate () { - tid = tid() - if (! ([tid] in command)) command[tid] = execname() - syscall=pp() # just the substring ideally - syscall_count[tid,syscall] ++ - this_syscall[tid] = syscall - this_syscall_time[tid] = gettimeofday_us() -} -function decumulate () { - tid = tid() - syscall = this_syscall[tid] - syscall_times[tid,syscall] += gettimeofday_us() - this_syscall_time[tid] - # free up memory - delete(this_syscall[tid]) - delete(this_syscall_time[tid]) -} -probe kernel.function("sys_*").call { - accumulate () -} -probe kernel.function("sys_*").return { - decumulate () -} -probe timer.ms(5000) { - exit () -} -probe end { - foreach ([tid,syscall] in syscall_count- limit 30) { - printf("%s(%d) %s count=%d ttime=%d\n", command[tid], tid, syscall, - syscall_count[tid,syscall], syscall_times[tid,syscall]) - } -} diff --git a/testsuite/systemtap.samples/queue_demo.exp b/testsuite/systemtap.samples/queue_demo.exp deleted file mode 100644 index 49dfac05..00000000 --- a/testsuite/systemtap.samples/queue_demo.exp +++ /dev/null @@ -1,13 +0,0 @@ -set test "queue_demo" -if {![installtest_p]} { untested $test; return } - -spawn stap $srcdir/$subdir/queue_demo.stp -set ok 0 -expect { - -timeout 240 - -re {block-[^\r]*} { incr ok; exp_continue } - timeout { fail "$test (timeout)" } - eof { } -} - -if {$ok > 4 && $ok < 10} { pass "$test" } { fail "$test" } diff --git a/testsuite/systemtap.samples/queue_demo.stp b/testsuite/systemtap.samples/queue_demo.stp deleted file mode 100644 index 61a3b6d1..00000000 --- a/testsuite/systemtap.samples/queue_demo.stp +++ /dev/null @@ -1,32 +0,0 @@ - -probe begin { - qsq_start ("block-read") - qsq_start ("block-write") -} - -probe timer.ms(3500), end { - qsq_print ("block-read") - qsq_start ("block-read") - qsq_print ("block-write") - qsq_start ("block-write") -} - -probe timer.ms(10000) { exit () } - - -# synthesize queue work/service using three randomized "threads" for each queue. - -global tc -function qs_doit (thread, name) { - n = tc[thread] = (tc[thread]+1) % 3 # per-thread state counter - if (n==1) qs_wait (name) - else if (n==2) qs_run (name) - else if (n==0) qs_done (name) -} - -probe timer.ms(100).randomize(100) { qs_doit (0, "block-read") } -probe timer.ms(100).randomize(100) { qs_doit (1, "block-read") } -probe timer.ms(100).randomize(100) { qs_doit (2, "block-read") } -probe timer.ms(100).randomize(100) { qs_doit (3, "block-write") } -probe timer.ms(100).randomize(100) { qs_doit (4, "block-write") } -probe timer.ms(100).randomize(100) { qs_doit (5, "block-write") } diff --git a/testsuite/systemtap.samples/scf.stp b/testsuite/systemtap.samples/scf.stp deleted file mode 100644 index 1108fdea..00000000 --- a/testsuite/systemtap.samples/scf.stp +++ /dev/null @@ -1,25 +0,0 @@ -# scf.stp -# A reimplementation of user script:smp_call_function example given at OLS 2005 -# in the current language. -# -# Will Cohen -# 9/22/2005 - -global traces - -probe kernel.function("smp_call_function") -{ - traces[pid(), pexecname(), backtrace()] += 1; -} - -probe begin { print( "starting probe\n" ); } - -probe end { - print("end of data collection\n"); - foreach( [pid, name, stack] in traces){ - print( "traces[" . sprint(pid) . "," . name . ",\n" ); - print_stack(stack) - print( "] = " . sprint(traces[pid, name, stack]) ); - print( "\n" ); - } -} diff --git a/testsuite/systemtap.samples/scf2.stp b/testsuite/systemtap.samples/scf2.stp deleted file mode 100644 index 5ad46350..00000000 --- a/testsuite/systemtap.samples/scf2.stp +++ /dev/null @@ -1,13 +0,0 @@ -global traces - -probe kernel.function("smp_call_function") { - traces[pid(), pexecname(), backtrace()] ++ -} -probe timer.ms(1000) { exit () } -probe end { - foreach ([pid+, name, stack] in traces) { # sort by pid - printf ("traces[%d,%s,\n", pid, name) - print_stack (stack) - printf ("] = %d\n", traces[pid, name, stack]); - } -} diff --git a/testsuite/systemtap.samples/symbols.exp b/testsuite/systemtap.samples/symbols.exp deleted file mode 100644 index 0c599b58..00000000 --- a/testsuite/systemtap.samples/symbols.exp +++ /dev/null @@ -1,14 +0,0 @@ -set test "symbols" -if {![installtest_p]} { untested $test; return } - -spawn stap -g $srcdir/$subdir/symbols.stp -set ok 0 -expect { - -timeout 120 - -re { 0x[a-f0-9]+[^\r]*\r} { incr ok; exp_continue } - timeout { fail "$test (timeout)" } - eof { } -} -#FIXME does not handle case of hanging symbols.stp correctly -wait -if {$ok == 11} { pass "$test ($ok)" } { fail "$test ($ok)" } diff --git a/testsuite/systemtap.samples/symbols.stp b/testsuite/systemtap.samples/symbols.stp deleted file mode 100644 index 040c3444..00000000 --- a/testsuite/systemtap.samples/symbols.stp +++ /dev/null @@ -1,11 +0,0 @@ -#! stap - -probe begin { - # a spectrum of figures for 32-bit x86 - print_stack ("0x0 0x80000000 0xc0000000 0xe0000000 0xf0000000 0xffffffff") - # for x86_64 - print_stack ("0xffffffff00000000 0xffffffff80000000 0xffffffff80120000") - print_stack ("0xffffffff88000000 0xffffffffffffffff") - # ... for a total of 11 lines, which symbols.exp counts - exit () -} diff --git a/testsuite/systemtap.samples/syscalls.stp b/testsuite/systemtap.samples/syscalls.stp deleted file mode 100644 index 3ccfb8e5..00000000 --- a/testsuite/systemtap.samples/syscalls.stp +++ /dev/null @@ -1,7 +0,0 @@ -#! stap - -global count -probe kernel.function("sys_*").call { - printf("%d %s\n", pid(), pp()) - if (++count > 100) exit() -} diff --git a/testsuite/systemtap.samples/syscalls1.exp b/testsuite/systemtap.samples/syscalls1.exp deleted file mode 100644 index eb8a0c6d..00000000 --- a/testsuite/systemtap.samples/syscalls1.exp +++ /dev/null @@ -1,14 +0,0 @@ -set test "syscalls-count" -if {![installtest_p]} { untested $test; return } - -spawn stap -p2 $srcdir/$subdir/syscalls.stp -set ok 0 -expect { - -timeout 180 - -re {kernel.function[^\r]*sys_[^\r]*\r} { incr ok; exp_continue } - timeout { fail "$test (timeout)" } - eof { } -} -#FIXME does not handle case of hanging psyscalls.stp correctly -wait -if {$ok > 200 && $ok < 350} { pass "$test ($ok)" } { fail "$test ($ok)" } diff --git a/testsuite/systemtap.samples/syscalls2.exp b/testsuite/systemtap.samples/syscalls2.exp deleted file mode 100644 index 7bbd9a51..00000000 --- a/testsuite/systemtap.samples/syscalls2.exp +++ /dev/null @@ -1,15 +0,0 @@ -set test "syscalls-run" -if {![installtest_p]} { untested $test; return } -spawn stap $srcdir/$subdir/syscalls.stp -set ok 0 -expect { - -timeout 240 - -re {[0-9]* kernel.function[^\r]*\r} { incr ok; exp_continue } - timeout { fail "$test (timeout)" } - eof { } -} -#FIXME does not handle case of hanging psyscalls.stp correctly -wait -# 150 is conservative - it's larger than 100 to allow a bit of slop -# between the exit() call and the actual shutdown -if {$ok >= 100 && $ok < 150} { pass "$test ($ok)" } { fail "$test ($ok)" } diff --git a/testsuite/systemtap.samples/system_func.exp b/testsuite/systemtap.samples/system_func.exp deleted file mode 100644 index ec935783..00000000 --- a/testsuite/systemtap.samples/system_func.exp +++ /dev/null @@ -1,22 +0,0 @@ -set test "system_func" -if {![installtest_p]} { untested $test; return } -spawn stap $srcdir/$subdir/system_func.stp -set open 0 -set done 0 -set saw_user 0 -set user [exec whoami] -expect { - -timeout 30 - -re "($user|sys_open|DONE)\r" { - switch $expect_out(1,string) { - sys_open {incr open} - DONE {incr done} - default {incr saw_user} - } - exp_continue - } - timeout { fail "$test (timeout)" } - eof { } -} -catch {close}; wait -if {$open == 1 && $saw_user == 1 && $done == 1 } { pass "$test" } { fail "$test ($open,$saw_user,$done)" } diff --git a/testsuite/systemtap.samples/system_func.stp b/testsuite/systemtap.samples/system_func.stp deleted file mode 100644 index d14fb25b..00000000 --- a/testsuite/systemtap.samples/system_func.stp +++ /dev/null @@ -1,35 +0,0 @@ -#! stap - -# test the system() function - -global saw_echo, did_cat - -probe kernel.function("sys_open") { - if (!saw_echo) { - # very inefficient. Testing only. DO NOT DO THIS - msg="echo sys_open" - system(msg) - saw_echo = 1 - } -} - -probe timer.ms(100) { - # should fail - system("cat __xyzzy123ABC__") - did_cat = 1 -} - -probe timer.ms(150) { - if (saw_echo && did_cat) - exit() -} - -probe begin { - # should succeed - system("whoami") -} - -probe end { - # should succeed - system("echo DONE") -} diff --git a/testsuite/systemtap.samples/tcp_connections.stp b/testsuite/systemtap.samples/tcp_connections.stp deleted file mode 100644 index a4449b60..00000000 --- a/testsuite/systemtap.samples/tcp_connections.stp +++ /dev/null @@ -1,49 +0,0 @@ -#! stap - -%{ -#include <linux/version.h> -#include <net/sock.h> -#include <net/tcp.h> - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11) -#define LPORT (inet->inet.num) -#define DADDR (&inet->inet.daddr) -#else -#define LPORT (inet->num) -#define DADDR (&inet->daddr) -#endif -%} - -function get_local_port:long(sock) -%{ - unsigned long ptr = (unsigned long) THIS->sock; - - struct inet_sock *inet = (struct inet_sock *) ptr; - THIS->__retvalue = (long long) LPORT; -%} - -function get_ip_source:string(sock) -%{ - unsigned long ptr = (unsigned long) THIS->sock; - struct inet_sock *inet = (struct inet_sock *) ptr; - unsigned char addr[4]; - memcpy(addr, DADDR, sizeof(addr)); - sprintf(THIS->__retvalue, "%d.%d.%d.%d", - addr[0], addr[1], addr[2], addr[3]); - -%} - - -probe begin { - log ("UID\tCMD\t\tPID\t\tPORT\tIP_SOURCE") -} - -probe kernel.function("tcp_accept").return { - sock = $return - if (sock != 0) - log(sprint(uid())."\t". - execname()."\t\t". - sprint(pid())."\t\t ". - sprint(get_local_port(sock))."\t". - get_ip_source(sock)) -} diff --git a/testsuite/systemtap.samples/tcp_connections_wa.stp b/testsuite/systemtap.samples/tcp_connections_wa.stp deleted file mode 100644 index 4c5e2399..00000000 --- a/testsuite/systemtap.samples/tcp_connections_wa.stp +++ /dev/null @@ -1,55 +0,0 @@ -%{ -#include <linux/version.h> -#include <net/sock.h> -#include <net/tcp.h> - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11) -#define LPORT (inet->inet.num) -#define DADDR (&inet->inet.daddr) -#else -#define LPORT (inet->num) -#define DADDR (&inet->daddr) -#endif -%} - - -function get_eax:long () %{ - if (CONTEXT && CONTEXT->regs) - THIS->__retvalue = CONTEXT->regs->eax; - else - THIS->__retvalue = 0; -%} - -function get_local_port:long(sock) -%{ - unsigned long ptr = (unsigned long) THIS->sock; - - struct inet_sock *inet = (struct inet_sock *) ptr; - THIS->__retvalue = (long long) LPORT; -%} - -function get_ip_source:string(sock) -%{ - unsigned long ptr = (unsigned long) THIS->sock; - struct inet_sock *inet = (struct inet_sock *) ptr; - unsigned char addr[4]; - memcpy(addr, DADDR, sizeof(addr)); - sprintf(THIS->__retvalue, "%d.%d.%d.%d", - addr[0], addr[1], addr[2], addr[3]); - -%} - -probe begin { - log ("UID\tCMD\t\tPID\t\tPORT\tIP_SOURCE") -} -probe kernel.function("tcp_accept").return { - sock = get_eax() - if (sock != 0) - log(sprint(uid())."\t". - execname()."\t\t". - sprint(pid())."\t\t ". - sprint(get_local_port(sock))."\t". - get_ip_source(sock)) -} - - diff --git a/testsuite/systemtap.samples/testlog.stp b/testsuite/systemtap.samples/testlog.stp deleted file mode 100644 index 5b702aa9..00000000 --- a/testsuite/systemtap.samples/testlog.stp +++ /dev/null @@ -1,6 +0,0 @@ -probe begin -{ - printf("Hello"); - printf("World"); - printf("\n"); -} diff --git a/testsuite/systemtap.samples/topsys.stp b/testsuite/systemtap.samples/topsys.stp deleted file mode 100644 index da31c858..00000000 --- a/testsuite/systemtap.samples/topsys.stp +++ /dev/null @@ -1,69 +0,0 @@ -#! stap -g -# -# This script continuously lists the top 20 systemcalls in the interval -# of 2000 jiffies. -# - -global syscalls_count, syscalls - -function syscall_name:string () %{ - char *str, buff[80]; - char *tok; - str = buff; - strlcpy(str, CONTEXT->probe_point, sizeof(buff)); - tok = strsep(&str, "\""); - tok = strsep(&str, "@"); - sprintf(str, "%-25s", tok); - strlcpy(THIS->__retvalue, str, MAXSTRINGLEN); -%} - -function reset_maxaction () %{ - if (CONTEXT && CONTEXT->actioncount) - CONTEXT->actioncount=0; -%} - -function accumulate () { - syscall=syscall_name() - syscalls_count[syscall]++ - # I use this array to refer to syscalls_count array in - # the reset_syscalls_count. Initalize with a non-zero. - syscalls[syscall]=1 -} - - -function print_top () { - lcnt=0 - reset_maxaction () - foreach ([syscall] in syscalls_count-) { - sys_cnt = syscalls_count[syscall] - log (syscall . "\t\t\t\t" . sprint(sys_cnt)) - if (lcnt++ == 20) - break; - } - syscalls_count[lsyscall]=0 -} - -function reset_syscalls_count () { - # For some reason, I have to do this to get pass the elaboration - # phase on RHEL4 (seg fault). Under FC4, it works fine with out - # the 'dummy_init' - syscalls["dummy_init"]=0 - foreach ([sys] in syscalls) - syscalls_count[sys]=0 -} - -function print_systop () { - log ("SYSCALL \t\t\t\tCOUNT") - print_top() - reset_syscalls_count () -} - -probe kernel.function("sys_*").call { - accumulate () -} - -probe timer.jiffies(2000) { - print_systop () - log("--------------------------------------------------------------") -} - |