From 9fbda39bf7687ceeee28813f30f6e3ec5c72fc5d Mon Sep 17 00:00:00 2001 From: William Cohen Date: Thu, 29 Jan 2009 16:55:06 -0500 Subject: Move some systemtap.sample tests to systemtap.base. --- testsuite/ChangeLog | 7 +++ testsuite/systemtap.base/arith.exp | 14 +++++ testsuite/systemtap.base/arith.stp | 79 +++++++++++++++++++++++++ testsuite/systemtap.base/arith_limits.exp | 13 +++++ testsuite/systemtap.base/arith_limits.stp | 80 ++++++++++++++++++++++++++ testsuite/systemtap.base/control_limits.exp | 46 +++++++++++++++ testsuite/systemtap.base/control_limits.stp | 24 ++++++++ testsuite/systemtap.base/gtod.c | 26 +++++++++ testsuite/systemtap.base/gtod.exp | 40 +++++++++++++ testsuite/systemtap.base/gtod.sh | 4 ++ testsuite/systemtap.base/gtod.stp | 8 +++ testsuite/systemtap.base/system_func.exp | 22 +++++++ testsuite/systemtap.base/system_func.stp | 35 +++++++++++ testsuite/systemtap.samples/arith.exp | 14 ----- testsuite/systemtap.samples/arith.stp | 79 ------------------------- testsuite/systemtap.samples/arith_limits.exp | 13 ----- testsuite/systemtap.samples/arith_limits.stp | 80 -------------------------- testsuite/systemtap.samples/control_limits.exp | 46 --------------- testsuite/systemtap.samples/control_limits.stp | 24 -------- testsuite/systemtap.samples/gtod.c | 26 --------- testsuite/systemtap.samples/gtod.exp | 40 ------------- testsuite/systemtap.samples/gtod.sh | 4 -- testsuite/systemtap.samples/gtod.stp | 8 --- testsuite/systemtap.samples/system_func.exp | 22 ------- testsuite/systemtap.samples/system_func.stp | 35 ----------- 25 files changed, 398 insertions(+), 391 deletions(-) create mode 100644 testsuite/systemtap.base/arith.exp create mode 100644 testsuite/systemtap.base/arith.stp create mode 100644 testsuite/systemtap.base/arith_limits.exp create mode 100644 testsuite/systemtap.base/arith_limits.stp create mode 100644 testsuite/systemtap.base/control_limits.exp create mode 100644 testsuite/systemtap.base/control_limits.stp create mode 100644 testsuite/systemtap.base/gtod.c create mode 100644 testsuite/systemtap.base/gtod.exp create mode 100755 testsuite/systemtap.base/gtod.sh create mode 100644 testsuite/systemtap.base/gtod.stp create mode 100644 testsuite/systemtap.base/system_func.exp create mode 100644 testsuite/systemtap.base/system_func.stp delete mode 100644 testsuite/systemtap.samples/arith.exp delete mode 100644 testsuite/systemtap.samples/arith.stp delete mode 100644 testsuite/systemtap.samples/arith_limits.exp delete mode 100644 testsuite/systemtap.samples/arith_limits.stp delete mode 100644 testsuite/systemtap.samples/control_limits.exp delete mode 100644 testsuite/systemtap.samples/control_limits.stp delete mode 100644 testsuite/systemtap.samples/gtod.c delete mode 100644 testsuite/systemtap.samples/gtod.exp delete mode 100755 testsuite/systemtap.samples/gtod.sh delete mode 100644 testsuite/systemtap.samples/gtod.stp delete mode 100644 testsuite/systemtap.samples/system_func.exp delete mode 100644 testsuite/systemtap.samples/system_func.stp diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index 78859666..879e3529 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2009-01-29 Will Cohen + + * systemtap.samples/arith*: + * systemtap.samples/control_limits.*: + * systemtap.samples/gtod.*: + * systemtap.samples/system_func.*: Moved to systemtap.base. + 2009-01-29 Will Cohen * systemtap.samples/args.exp: diff --git a/testsuite/systemtap.base/arith.exp b/testsuite/systemtap.base/arith.exp new file mode 100644 index 00000000..c4f72793 --- /dev/null +++ b/testsuite/systemtap.base/arith.exp @@ -0,0 +1,14 @@ +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.base/arith.stp b/testsuite/systemtap.base/arith.stp new file mode 100644 index 00000000..59016dcb --- /dev/null +++ b/testsuite/systemtap.base/arith.stp @@ -0,0 +1,79 @@ +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.base/arith_limits.exp b/testsuite/systemtap.base/arith_limits.exp new file mode 100644 index 00000000..93794c8e --- /dev/null +++ b/testsuite/systemtap.base/arith_limits.exp @@ -0,0 +1,13 @@ +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.base/arith_limits.stp b/testsuite/systemtap.base/arith_limits.stp new file mode 100644 index 00000000..6c620830 --- /dev/null +++ b/testsuite/systemtap.base/arith_limits.stp @@ -0,0 +1,80 @@ +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.base/control_limits.exp b/testsuite/systemtap.base/control_limits.exp new file mode 100644 index 00000000..513b2c4d --- /dev/null +++ b/testsuite/systemtap.base/control_limits.exp @@ -0,0 +1,46 @@ +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.base/control_limits.stp b/testsuite/systemtap.base/control_limits.stp new file mode 100644 index 00000000..89b0bae4 --- /dev/null +++ b/testsuite/systemtap.base/control_limits.stp @@ -0,0 +1,24 @@ + +# 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.base/gtod.c b/testsuite/systemtap.base/gtod.c new file mode 100644 index 00000000..abc08543 --- /dev/null +++ b/testsuite/systemtap.base/gtod.c @@ -0,0 +1,26 @@ +#include +#include +#include +#include + +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.base/gtod.exp b/testsuite/systemtap.base/gtod.exp new file mode 100644 index 00000000..a8f3c9d6 --- /dev/null +++ b/testsuite/systemtap.base/gtod.exp @@ -0,0 +1,40 @@ +# 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.base/gtod.sh b/testsuite/systemtap.base/gtod.sh new file mode 100755 index 00000000..4d4a28c2 --- /dev/null +++ b/testsuite/systemtap.base/gtod.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +stap $1 -c "$2 $3" | sort + diff --git a/testsuite/systemtap.base/gtod.stp b/testsuite/systemtap.base/gtod.stp new file mode 100644 index 00000000..f252dc0a --- /dev/null +++ b/testsuite/systemtap.base/gtod.stp @@ -0,0 +1,8 @@ +global count = 0 + +probe syscall.setsid { + if (pid() == target()) { + printf("%014d :%02d kern\n", gettimeofday_us(), count); + count ++; + } +} diff --git a/testsuite/systemtap.base/system_func.exp b/testsuite/systemtap.base/system_func.exp new file mode 100644 index 00000000..ec935783 --- /dev/null +++ b/testsuite/systemtap.base/system_func.exp @@ -0,0 +1,22 @@ +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.base/system_func.stp b/testsuite/systemtap.base/system_func.stp new file mode 100644 index 00000000..d14fb25b --- /dev/null +++ b/testsuite/systemtap.base/system_func.stp @@ -0,0 +1,35 @@ +#! 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/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/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 -#include -#include -#include - -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/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") -} -- cgit