Debian Codegraph @

testsuite/parseok/macros09.stp

raw
1 #! /bin/sh
2
3 # Test macro deprecation PR18462.
4
5 # Testcase wrapper (parseok.exp) checks for exitcode, so we need to terminate right after an error occurs.
6 set -e
7
8 # let's play in temporary directory writable by any user potentially involved
9 MYTMPD=$( mktemp -d )
10 MYSTPM=$MYTMPD/PR18462.stpm
11
12 export SYSTEMTAP_TAPSET=$MYTMPD
13
14 # basic tests
15 # ______________________________________________________________________________
16
17 cat > $MYSTPM <<EOF01
18 @define __testmacro %( 7 %)
19 EOF01
20
21 stap -p1 - <<EOF02
22 probe begin { println(@__testmacro) }
23 EOF02
24
25 cat > $MYSTPM <<EOF03
26 %( 1 == 1 %?
27 @define __testmacroA %( 7 %)
28 %:
29 @define __testmacroB %( 7 %)
30 %)
31 EOF03
32
33 stap -p1 - <<EOF04
34 probe begin { println(@__testmacroA) }
35 EOF04
36
37 ! stap -p1 - <<EOF05
38 probe begin { println(@__testmacroB) }
39 EOF05
40
41 cat > $MYSTPM <<EOF06
42 %( "a" == "b" %?
43 @define __testmacroC %( 7 %)
44 %:
45 @define __testmacroD %( 7 %)
46 %)
47 EOF06
48
49 ! stap -p1 - <<EOF07
50 probe begin { println(@__testmacroC) }
51 EOF07
52
53 stap -p1 - <<EOF08
54 probe begin { println(@__testmacroD) }
55 EOF08
56
57 # both the true and false side of a conditional are defining the same macro name
58 # ______________________________________________________________________________
59
60 cat > $MYSTPM <<EOF09
61 %( 1 == 1 %?
62 @define __testmacroE %( 7 %)
63 %:
64 @define __testmacroE %( 9 %)
65 %)
66 EOF09
67
68 stap -p1 - <<EOF10
69 probe begin { println(@__testmacroE) }
70 EOF10
71
72 cat > $MYSTPM <<EOF11
73 %( 1 != 1 %?
74 @define __testmacroF %( 7 %)
75 %:
76 @define __testmacroF %( 9 %)
77 %)
78 EOF11
79
80 stap -p1 - <<EOF12
81 probe begin { println(@__testmacroF) }
82 EOF12
83
84 # test nested conditionals
85 # ______________________________________________________________________________
86
87 cat > $MYSTPM <<EOF13
88 %( 1 == 1 %?
89 %( 1 == 1 %?
90 @define __testmacroG %( 7 %)
91 %:
92 @define __testmacroH %( 7 %)
93 %)
94 %:
95 @define __testmacroI %( 7 %)
96 %)
97 EOF13
98
99 stap -p1 - <<EOF14
100 probe begin { println(@__testmacroG) }
101 EOF14
102
103 ! stap -p1 - <<EOF15
104 probe begin { println(@__testmacroH) }
105 EOF15
106
107 ! stap -p1 - <<EOF16
108 probe begin { println(@__testmacroI) }
109 EOF16
110
111 # test some expected errors
112 # ______________________________________________________________________________
113
114 # incomplete conditional at end of file
115 cat > $MYSTPM <<EOF17
116 %( 1 == 1 %?
117 @define __testmacroJ %( 7 %)
118 EOF17
119
120 ! stap -p1 - <<EOF18
121 probe begin { println(@__testmacroJ) }
122 EOF18
123
124 rm -rf $MYTMPD
125
126 set +e
127