File: valid_pid.exp

package info (click to toggle)
systemtap 5.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 47,556 kB
  • sloc: cpp: 81,117; ansic: 54,933; xml: 49,795; exp: 43,595; sh: 11,526; python: 5,003; perl: 2,252; tcl: 1,312; makefile: 1,006; javascript: 149; lisp: 105; awk: 101; asm: 91; java: 70; sed: 16
file content (57 lines) | stat: -rw-r--r-- 2,271 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
set test_scripts {
"probe process(\$1).syscall{exit();}"
"probe process(\$1).begin{exit();}"
"probe process(\$1).end{exit();}"
"probe process(\$1).thread.begin{exit();}"
"probe process(\$1).function(\"main\"){exit();}"
"probe process(\$1).mark(\"*\"){exit();}"
"probe process(\$1).plt(\"*\"){exit();}"
"probe process(\$1).provider(\"*\").mark(\"*\"){exit();}"

"probe process.begin{exit();}"
"probe process.end{exit();}"
"probe process.thread.begin{exit();}"
"probe process.function(\"main\"){exit();}"
"probe process.plt(\"*\"){exit();}"
"probe process.mark(\"*\"){exit();}"
"probe process.provider(\"*\").mark(\"*\"){exit();}"

"probe process(\$1).statement(200){exit();}"
}

spawn stap -e "probe begin{}"
set exe_id $spawn_id
set valid_pid [exp_pid -i $exe_id]
verbose -log "valid pid is: $valid_pid"

# pids are: invalid, valid
set pids "1234567890 $valid_pid"

foreach test_script $test_scripts {
    foreach pid $pids {
       verbose -log "PID under test is $pid"
       if {(([regexp {insn} $test_script] || [regexp {statement} $test_script]) || ![uprobes_p]) || ([regexp {plt} $test_script] && ![plt_probes_p])} {
            untested "script: $test_script"
            continue
        } else {
            if { [regexp {1} $test_script] } { 
                spawn stap -p2 -e $test_script $pid
            } else {
                spawn stap -p2 -e $test_script -x $pid
            }
        }
        set exe_id2 $spawn_id
        expect {
            -re {semantic error: [ A-Za-z]*pid[ A-Za-z]*} { if {$pid != $valid_pid } { pass "$test_script" } else { fail "$test_script" } }
            -re {semantic error: [ A-Za-z]*cannot find executable[ A-Za-z]*} { if {(([regexp {function} $test_script] || [regexp {plt} $test_script]) || [regexp {mark} $test_script]) && $pid != $valid_pid} { pass "$test_script" } }
            # only checking that a semantic error about a pid is not raised 
            # when a valid pid is given. don't really care if other errors are
            # thrown
            eof  { if {$pid == $valid_pid } { pass "$test_script" } else { fail "$test_script" } }
        }
        catch { close -i $exe_id2 }; catch { wait -i $exe_id2 }
    }
}

kill -INT -[exp_pid -i $exe_id] 2
catch { close -i $exe_id }; catch { wait -i $exe_id }