File: macros09.stp

package info (click to toggle)
systemtap 3.1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 32,860 kB
  • ctags: 12,513
  • sloc: cpp: 58,610; ansic: 58,189; exp: 37,322; sh: 10,633; xml: 7,771; perl: 2,252; python: 2,066; tcl: 1,305; makefile: 969; lisp: 105; java: 100; awk: 94; asm: 91; sed: 16
file content (127 lines) | stat: -rwxr-xr-x 2,314 bytes parent folder | download | duplicates (7)
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
#! /bin/sh

# Test macro deprecation PR18462.

# Testcase wrapper (parseok.exp) checks for exitcode, so we need to terminate right after an error occurs.
set -e

# let's play in temporary directory writable by any user potentially involved
MYTMPD=$( mktemp -d )
MYSTPM=$MYTMPD/PR18462.stpm

export SYSTEMTAP_TAPSET=$MYTMPD

# basic tests
# ______________________________________________________________________________

cat > $MYSTPM <<EOF01
@define __testmacro %( 7 %)
EOF01

stap -p1 - <<EOF02
probe begin { println(@__testmacro) }
EOF02

cat > $MYSTPM <<EOF03
%( 1 == 1 %?
@define __testmacroA %( 7 %)
%:
@define __testmacroB %( 7 %)
%)
EOF03

stap -p1 - <<EOF04
probe begin { println(@__testmacroA) }
EOF04

! stap -p1 - <<EOF05
probe begin { println(@__testmacroB) }
EOF05

cat > $MYSTPM <<EOF06
%( "a" == "b" %?
@define __testmacroC %( 7 %)
%:
@define __testmacroD %( 7 %)
%)
EOF06

! stap -p1 - <<EOF07
probe begin { println(@__testmacroC) }
EOF07

stap -p1 - <<EOF08
probe begin { println(@__testmacroD) }
EOF08

# both the true and false side of a conditional are defining the same macro name
# ______________________________________________________________________________

cat > $MYSTPM <<EOF09
%( 1 == 1 %?
@define __testmacroE %( 7 %)
%:
@define __testmacroE %( 9 %)
%)
EOF09

stap -p1 - <<EOF10
probe begin { println(@__testmacroE) }
EOF10

cat > $MYSTPM <<EOF11
%( 1 != 1 %?
@define __testmacroF %( 7 %)
%:
@define __testmacroF %( 9 %)
%)
EOF11

stap -p1 - <<EOF12
probe begin { println(@__testmacroF) }
EOF12

# test nested conditionals
# ______________________________________________________________________________

cat > $MYSTPM <<EOF13
%( 1 == 1 %?
  %( 1 == 1 %?
    @define __testmacroG %( 7 %)
  %:
    @define __testmacroH %( 7 %)
  %)
%:
@define __testmacroI %( 7 %)
%)
EOF13

stap -p1 - <<EOF14
probe begin { println(@__testmacroG) }
EOF14

! stap -p1 - <<EOF15
probe begin { println(@__testmacroH) }
EOF15

! stap -p1 - <<EOF16
probe begin { println(@__testmacroI) }
EOF16

# test some expected errors
# ______________________________________________________________________________

# incomplete conditional at end of file
cat > $MYSTPM <<EOF17
%( 1 == 1 %?
@define __testmacroJ %( 7 %)
EOF17

! stap -p1 - <<EOF18
probe begin { println(@__testmacroJ) }
EOF18

rm -rf $MYTMPD

set +e