Debian Codegraph @

doc/SystemTap_Beginners_Guide/testsuite/systemtap.bpf/bpf-asm.exp

raw
1 # bpf-asm.exp
2 #
3 # TODO: Very basic test driver. Need to work out a way of signaling correctness.
4
5 set testdir "$srcdir/$subdir/asm_tests"
6
7 # This testcase stalls on s390x, skip it there
8 if { "$::tcl_platform(machine)" == "s390x" } {
9 untested "bpf-asm.exp"
10 return
11 }
12
13 proc stapbpf_run { TEST_NAME args } {
14 global rc
15 set rc -1
16
17 # return codes
18 set pass 0
19 #set fail 1
20 set bad_output 2
21 set eof_start 3
22 set eof_end 4
23 set timeout_start 5
24 set timeout_end 6
25 set invalid_prog 7
26 set comp_err 8
27
28 set cmd [concat stap -vg --runtime=bpf $args]
29 send_log "executing: $cmd\n"
30 eval spawn $cmd
31 set mypid [exp_pid -i $spawn_id]
32 expect {
33 -timeout 30
34 -re {Pass 5: starting run} {
35 expect {
36 -timeout 20
37 -re {Pass 5: run completed} {
38 set rc $pass
39 }
40 -re "bpf program load failed:" { set rc $invalid_prog }
41 default {
42 set rc $bad_output
43 }
44 timeout {
45 set rc $timeout_end
46 kill -INT -$mypid
47 }
48 eof {
49 set rc $eof_end
50 }
51 }
52 }
53 -re "semantic error:" { set rc $comp_err }
54 -re "bpf program load failed:" { set rc $invalid_prog }
55 timeout {
56 set rc $timeout_start
57 kill -INT -$mypid
58 }
59 eof {
60 set rc $eof_start
61 }
62 }
63 # again for good measure with KILL after 3s
64 kill -INT -$mypid 3
65 catch close
66 wait
67 return $rc
68 }
69
70 set stap_files [lsort [glob -nocomplain $testdir/*.stp]]
71
72 foreach file $stap_files {
73 global mypid
74 set mypid 0
75 set test [file tail $file]
76 if {! [installtest_p]} { untested $test; continue }
77 if {! [bpf_p]} { untested $test; continue }
78
79 set errtest_p [regexp {^err} [file tail $file]]
80 verbose -log "Running $file"
81 switch [stapbpf_run $test $file] {
82 0 {
83 if $errtest_p {
84 fail "$test unexpected success"
85 } else {
86 pass $test
87 }
88 }
89 1 { fail "$test incorrect result" }
90 2 { fail "$test unexpected output" }
91 3 { fail "$test eof (startup)" }
92 4 { fail "$test eof (shutdown)" }
93 5 { fail "$test timeout (startup)" }
94 6 { fail "$test timeout (startup)" }
95 7 { fail "$test invalid bpf program" }
96 8 {
97 if $errtest_p {
98 pass $test
99 } else {
100 fail "$test compilation"
101 }
102 }
103 default { fail "$test unknown return value" }
104 }
105
106 if { $mypid > 0 } {
107 kill -INT -$mypid 3
108 catch close
109 wait
110 }
111 }