diff options
-rw-r--r-- | testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | testsuite/lib/stap_run.exp | 1 | ||||
-rw-r--r-- | testsuite/systemtap.base/procfs.exp | 112 |
3 files changed, 119 insertions, 0 deletions
diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index 65de1866..6f523a83 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2007-09-18 David Smith <dsmith@redhat.com> + + * systemtap.base/procfs.exp: New test case. + * lib/stap_run.exp (stap_run): Handles the case where the stap + '-m' option was used. + 2007-09-17 David Smith <dsmith@redhat.com> * semko/procfs06.stp: New test case. diff --git a/testsuite/lib/stap_run.exp b/testsuite/lib/stap_run.exp index 14786218..ff93ed8a 100644 --- a/testsuite/lib/stap_run.exp +++ b/testsuite/lib/stap_run.exp @@ -32,6 +32,7 @@ proc stap_run { TEST_NAME {LOAD_GEN_FUNCTION ""} {OUTPUT_CHECK_STRING ""} args } eval spawn $cmd expect { -timeout 180 + -re {^Warning: using '-m' disables cache support.\r\n} {exp_continue} -re {^Pass\ ([1234]):[^\r]*\ in\ ([0-9]+)usr/([0-9]+)sys/([0-9]+)real\ ms\.\r\n} {set pass$expect_out(1,string) "\t$expect_out(2,string)\t$expect_out(3,string)\t$expect_out(4,string)"; exp_continue} -re {^Pass\ ([34]): using cached [^\r]+\r\n} diff --git a/testsuite/systemtap.base/procfs.exp b/testsuite/systemtap.base/procfs.exp new file mode 100644 index 00000000..ac00acc6 --- /dev/null +++ b/testsuite/systemtap.base/procfs.exp @@ -0,0 +1,112 @@ +# Test cases for procfs probes + +set test "PROCFS" + +if {![installtest_p]} { untested $test; return } + +proc proc_read_value { test path} { + set value "<unknown>" + if [catch {open $path RDONLY} channel] { + fail "$test $channel" + } else { + set value [read -nonewline $channel] + close $channel + pass "$test read $value" + } + return $value +} + +proc proc_write_value { test path value} { + if [catch {open $path WRONLY} channel] { + fail "$test $channel" + } else { + puts $channel $value + close $channel + pass "$test wrote $value" + } +} + +proc proc_read_write {} { + set test "PROCFS" + set path "/proc/systemtap/$test/command" + + # read the initial value, which should be '100' + set value [proc_read_value $test $path] + if { $value == "100" } { + pass "$test received correct initial value" + } else { + fail "$test received incorrect initial value: $value" + } + + # write a new value of '200' + proc_write_value $test $path "200" + + # make sure it got set to '200' + set value [proc_read_value $test $path] + if { $value == "200" } { + pass "$test received correct value" + } else { + fail "$test received incorrect value: $value" + } + + # read it again to make sure nothing changed + set value [proc_read_value $test $path] + if { $value == "200" } { + pass "$test received correct value" + } else { + fail "$test received incorrect value: $value" + } + + # write a new value of 'hello' + proc_write_value $test $path "hello" + + # make sure it got set to 'hello' + set value [proc_read_value $test $path] + if { $value == "hello" } { + pass "$test received correct value" + } else { + fail "$test received incorrect value: $value" + } + + # write a new value of 'goodbye' + proc_write_value $test $path "goodbye" + + # make sure it got set to 'goodbye' + set value [proc_read_value $test $path] + if { $value == "goodbye" } { + pass "$test received correct value" + } else { + fail "$test received incorrect value: $value" + } + + return 0; +} + +# The script starts with a value of "100". If the user writes into +# /proc/systemtap/MODNAME/command, that value is returned by the next +# read. + + +set systemtap_script { + global saved_value + + probe procfs("command").read { + $value = saved_value + } + probe procfs("command").write { + saved_value = $value + } + + probe begin { + saved_value = "100\n" + printf("systemtap starting probe\n") + } + probe end { + printf("systemtap ending probe\n") + printf("final value = %s", saved_value) + } +} + +# test procfs probes +set output_string "\\mfinal value = goodbye\\M\r\n" +stap_run $test proc_read_write $output_string -e $systemtap_script -m $test |