Debian Codegraph @

doc/SystemTap_Beginners_Guide/testsuite/systemtap.base/crash.exp

raw
1 # Simple test for staplog.so crash(8) extension
2 set test "crash"
3
4 if {![installtest_p]} { untested $test; return }
5 if {![file exists $env(CRASH_LIBDIR)/staplog.so]} { untested "$test - no staplog.so"; return }
6
7 # Load a test script
8 spawn stap -e {probe begin {print("HelloWorld\n")}} -m testlog
9 expect {
10 -timeout 120
11 "HelloWorld\r\n" {
12 pass "$test - testlog.stp"
13 # Need to run crash(8) while this script is still running.
14 # Since crash(8) needs /dev/mem access, need it run as_root too.
15 # This [ eval ... \{ \} ] business is necessary because as_root
16 # evals the given list/variables in its own scope.
17 eval as_root \{ $srcdir/$subdir/crash.sh $env(CRASH_LIBDIR) \}
18 }
19 timeout { fail "$test - testlog.stp timeout" }
20 timeout { fail "$test - testlog.stp eof" }
21 }
22 catch { kill -INT -[exp_pid] 2 }; catch { close }; catch { wait }
23
24 # The crash(8) script creates testlog/global or testlog/cpu<n>
25 as_root { chmod -R a+rX testlog }
26
27 set ok 0
28 foreach f [glob -nocomplain testlog/*] {
29 pass "$test - crash(8) generated $f"
30 set fp [open $f]
31 set chars [read $fp]
32 close $fp
33 if [string match "HelloWorld*" $chars] {
34 incr ok
35 pass "$test - crash(8) data"
36 } else {
37 fail "$test - crash(8) data $chars"
38 }
39 }
40 if {$ok == 0} {
41 fail "$test - crash(8) data"
42 }
43
44 as_root { rm -rf testlog testlog.ko }
45