File: additional_scripts.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 (131 lines) | stat: -rw-r--r-- 3,722 bytes parent folder | download | duplicates (5)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
set test_name additional_scripts

# test scripts and arguments
set script1 { "probe begin\{printf(\"beginning\")\}" }
set script2 { "probe process.begin\{printf(\"%s\", \$1)\}" }
set timeout_script { "probe timer.s(15) \{ printf(\"ending\") exit ()\}" }
set script_alias { "probe pb=process.begin {exit();} probe process.end{exit();}" }
set bad_script { "probe pppppppp.begin { exit(); }" }
set script_file "$srcdir/$subdir/$test_name.stp"
set arg1 { "\"hello\"" }

# running test scripts
# -E and no -e or script file
# -E is for additional scripts. a "main" script or script file must be given
eval spawn stap -p4 -v -E $timeout_script
expect {
  -timeout 60
  -re {A script must be specified} { pass "$test_name (no script)" }
  eof { fail "$test_name (no script)" }
}
catch { close }; catch { wait }

# -E BAD_SCRIPT, where BAD_SCRIPT causes a semantic error
eval spawn stap -p4 -v -e $script1 -E $bad_script
set success 0
expect {
  -timeout 120
  -re {semantic error[ A-Za-z:]+'pppppppp'} { set success 1 }
}
if { $success == 1 } { pass "$test_name (-E BAD_SCRIPT) " }  { fail "$test_name (-E BAD_SCRIPT)" }
catch { close }; catch { wait }

# -E, with probe point listing
eval spawn stap -l "pb" -E $script_alias
set success 0
expect {
  -timeout 120
  -re {pb} { if { $success == 0 } { set success 1 } }
  -re {process.begin} { if { $success == 0 } { set success 1 } }
  -re {process.end} { set success 4 }
}
if { $success == 1 } { pass "$test_name (-E listing probes) " }  { fail "$test_name (-E listing probes)" }
catch { close }; catch { wait }

# -E BAD_SCRIPT when listing probes. should still list the proper probe pts
eval spawn stap -l "pb" -E $script_alias -E $bad_script
set success 0
expect {
  -timeout 120
  -re {pb} { if { $success == 0 } { set success 1 } }
  -re {process.begin} { if { $success == 0 } { set success 1 } }
  -re {process.end} { set success 4 }
}
if { $success == 1 } { pass "$test_name (-E BAD_SCRIPT listing probes) " }  { fail "$test_name (-E BAD_SCRIPT listing probes)" }
catch { close }; catch { wait }

# part 2: actually running stap with -e/-E
if {! [installtest_p]} then { return }


# -E SCRIPT,
eval spawn stap -v -e $script1 -E $timeout_script
set success 0
expect {
  -timeout 120
  -re {beginning} { 
    set success 1
    verbose -log "saw:beginning"
    exp_continue
  }
  -re {ending} { 
    if { $success == 1 } {
      verbose -log "saw:ending"
      set success 2
    }
    exp_continue 
  }
}
if { $success == 2 } { pass "$test_name (-e and -E ) " }  { fail "$test_name (-e and -E)" }
catch { close }; catch { wait }

# script file  and -E
eval spawn stap -v  $script_file -E $timeout_script
set success 0
expect {
  -timeout 120
  -re {a process began} {
    if { $success == 0 } {
      verbose -log "\nsaw:a process began"
      set success 1 
    }
    exp_continue
  }
  -re {ending} { 
    if { $success == 1 } { 
      set success 2
      verbose -log "\nsaw:ending"
    }
    exp_continue
  }
}
if { $success == 2 } { pass "$test_name (file and -E ) " }  { fail "$test_name (file and -E)" }
catch { close }; catch { wait }

# multiple -E, with an argument mixed in there
eval spawn stap -v -e $script2 -E $script1 -E $timeout_script $arg1
set success 0
expect {
  -timeout 120
  -re {beginning} { 
    set success 1
    verbose -log "\nsaw:beginning"
    exp_continue
  }
  -re {hello} {
    if { $success == 1 } { 
      verbose -log "\nsaw:hello"
      set success 2 
    }
    exp_continue
  }
  -re {ending} { 
    if { $success == 2 } { 
      set success 3
      verbose -log "\nsaw:ending"
    }
    exp_continue 
  }
}
if { $success == 3 } { pass "$test_name (multiple -E ) " }  { fail "$test_name (multiple -E)" }
catch { close }; catch { wait }