From 674427d3a018d0f89c9669db8dcf952aab8b4423 Mon Sep 17 00:00:00 2001 From: fche Date: Fri, 25 Jan 2008 04:47:11 +0000 Subject: staplog crash(8) module tests 2008-01-24 Frank Ch. Eigler * Makefile.am: Make another $(MKDIR) call visible. * Makefile.in: Regenerated. 2008-01-24 Frank Ch. Eigler crash(8) tests, based on Masami Hiramatsu : * Makefile.am (CRASH_LIBDIR): Pass in $(RUNTEST). * lib/systemtap.exp (as_root): Trace command string, output, and result. * sysetmtap.samples/crash.*, testlog.stp: New test case. * Makefile.in: Regenerated. --- testsuite/systemtap.samples/crash.exp | 45 +++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 testsuite/systemtap.samples/crash.exp (limited to 'testsuite/systemtap.samples/crash.exp') diff --git a/testsuite/systemtap.samples/crash.exp b/testsuite/systemtap.samples/crash.exp new file mode 100644 index 00000000..629cff54 --- /dev/null +++ b/testsuite/systemtap.samples/crash.exp @@ -0,0 +1,45 @@ +# 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 { send "\003"; close ; wait } + +# The crash(8) script creates testlog/global or testlog/cpu +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 } + -- cgit