docs: tweak formatting in pmrep(1) archive folio example
[pcp.git] / qa / 853
blobaffd1b7f053c89313d68faf9668781ea1f063cab
1 #!/bin/sh
2 # PCP QA Test No. 853
3 # pmcpp -s testing
5 # Copyright (c) 2015 Ken McDonell. All Rights Reserved.
8 seq=`basename $0`
9 echo "QA output created by $seq"
11 # get standard environment, filters and checks
12 . ./common.product
13 . ./common.filter
14 . ./common.check
16 # handle these ...
17 # 1 "/tmp/853-3145.inc"
19 _filter()
21 sed \
22 -e "/^# [1-9]/s@$tmp@TMP@" \
23 # end
26 status=1 # failure is the default!
27 $sudo rm -rf $tmp.* $seq.full
28 trap "cd $here; rm -rf $tmp.* $tmp; exit \$status" 0 1 2 3 15
30 # real QA test starts here
31 cat <<End-of-File >$tmp.inc
32 %define eek urk
33 %define mumble 'mumble and "fumble"'
34 text from .inc file
35 End-of-File
36 cat <<End-of-File >$tmp.in
37 %include "$tmp.inc"
38 Firstly, there is the mumble ...
39 %ifdef eek
40 what about eek ? expect this to be \u\r\k not \e\e\k
41 %endif
42 eek at start of line
43 at end of line eek
44 text from .in file
45 %ifndef test_else
46 not-defined if-part
47 %else
48 not-defined else-part
49 %endif
50 %ifdef test_else
51 defined if-part
52 %else
53 defined else-part
54 %endif
55 Text at end of file.
56 End-of-File
58 echo "=== simple cases ==="
59 echo "----------------------"
60 pmcpp -s <$tmp.in 2>&1 | _filter
61 echo "----------------------"
62 pmcpp -s --define=test_else=1 <$tmp.in 2>&1 | _filter
63 echo "----------------------"
65 echo
66 echo "=== expansion with -r ==="
67 echo "----------------------"
68 pmcpp -sr <$tmp.in 2>&1 | _filter
69 echo "----------------------"
70 cat <<End-of-File >$tmp.in2
71 %include "$tmp.inc"
72 Firstly, there is the mumble ...
73 %ifdef eek
74 what about %eek ? expect this to be \u\r\k not \e\e\k
75 and what about %{eek} ? expect this to be \u\r\k not \e\e\k
76 %endif
77 %eek <percent>eek at start of line
78 <percent>eek at end of line %eek
79 %{eek} <percent>{eek} at start of line
80 <percent>{eek} at end of line %{eek}
81 text from .in file
82 End-of-File
83 pmcpp -srd <$tmp.in2 2>&1 | _filter
84 echo "Check lines in and out ..."
85 echo "in: `wc -l <$tmp.in2 | sed -e 's/ //g'` + `wc -l <$tmp.inc | sed -e 's/ //g'`"
86 echo "out: `pmcpp -sr <$tmp.in2 | wc -l | sed -e 's/ //g'`"
87 echo "----------------------"
89 echo
90 echo "=== -D on command line cases ==="
91 echo "----------------------"
92 pmcpp -s -D text="blah=blah=blah=..." <$tmp.in 2>&1 | _filter
93 echo "----------------------"
94 pmcpp -s -D 'text="blah blah blah ..."' <$tmp.in 2>&1 | _filter
95 echo "----------------------"
97 # Note error case coverage is spotty ... real testing for errors
98 # is in qa/463 (without -s)
100 echo
101 echo "=== error cases ==="
102 echo "----------------------"
103 cat <<End-of-File >$tmp.in
105 %ifdef eek
107 End-of-File
108 pmcpp -s <$tmp.in 2>&1 | _filter
109 echo "----------------------"
110 cat <<End-of-File >$tmp.in
111 %macro value with embedded newline - bad
112 %define multi 'one line
113 two lines
114 three lines'
115 And is this multi multiple lines?
116 End-of-File
117 pmcpp -sr <$tmp.in 2>&1 | _filter
118 echo "----------------------"
119 cat <<End-of-File >$tmp.in
120 # exposed #else outside #if ... scope
121 test
122 #else
123 blah
124 #endif
125 End-of-File
126 pmcpp -r <$tmp.in 2>&1 | _filter
127 echo "----------------------"
129 echo
130 echo "=== macro name and corner-case expansion tests ==="
131 echo "----------------------"
132 cat <<End-of-File >$tmp.in
133 %define _underscore_all_over_ urk
134 What about _underscore_all_over_? [expect urk]
135 End-of-File
136 pmcpp -s <$tmp.in 2>&1 | _filter
137 echo "----------------------"
138 cat <<End-of-File >$tmp.in
139 %define long_macro_name_and_short_value "!"
140 %define x '^a very long macro value to be sure, to be sure$'
141 some text %%{long_macro_name_and_short_value}%{long_macro_name_and_short_value}%{long_macro_name_and_short_value}% [expect %!!!%]
142 [expect ^...$^...$^...$] %x%x%x
143 End-of-File
144 pmcpp -d -rs <$tmp.in 2>&1 | _filter
145 echo "----------------------"
146 cat <<End-of-File >$tmp.in
147 #define Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch LLanfair
148 The town of Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch is a village in Wales and is famous for being apparently the longest place name in the world. There are lots of web pages mentioning Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch. Locally Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch is just too much of a mouthful and so it is truncated from "Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch" to "Llanfair". With one more mention of Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch, I think this line will be long enough.
149 Phew that was a long input line ... 593 chars!
150 End-of-File
151 pmcpp -d <$tmp.in 2>&1 | _filter
152 echo "----------------------"
154 echo
155 echo "=== conditionals, bells and whistles ==="
156 echo "----------------------"
157 cat <<End-of-File >$tmp.freq
158 %define dk_freq 1minute
159 %define cpu_freq '15 sec'
160 End-of-File
161 cat <<End-of-File >$tmp.in
162 %include "$tmp.freq"
164 log mandatory on %dk_freq {
165 disk.dev
168 %ifdef want_cpu
169 %define cpu_pfx 'kernel.all.cpu.'
170 log mandatory on %cpu_freq {
171 %{cpu_pfx}user
172 %{cpu_pfx}sys
174 %endif
175 End-of-File
176 pmcpp -rs <$tmp.in 2>&1 | _filter
177 echo "----------------------"
178 pmcpp -rs -Dwant_cpu <$tmp.in 2>&1 | _filter
179 echo "----------------------"
181 echo
182 echo "=== -I tests ==="
183 mkdir $tmp
184 cd $tmp
185 cat <<End-of-File >a
186 #include <b>
187 Text from a.
188 End-of-File
189 cat <<End-of-File >b
190 Text from b.
191 End-of-File
192 echo "----------------------"
193 pmcpp -d a 2>&1 | _filter
194 mkdir sub
195 mv b sub
196 echo "----------------------"
197 pmcpp -d a 2>&1 | _filter
198 echo "----------------------"
199 pmcpp -d -I sub a 2>&1 | _filter
200 cat <<End-of-File >sub/b
201 #include "c-foobar"
202 Text from b.
203 End-of-File
204 mkdir sub/sub-sub
205 cat <<End-of-File >sub/sub-sub/c-foobar
206 Text from c-foobar.
207 End-of-File
208 echo "----------------------"
209 pmcpp -d -I sub -I sub/sub-sub a 2>&1 | _filter
210 echo "----------------------"
211 mv sub/sub-sub/c-foobar sub
212 mv a sub
213 pmcpp -d sub/a 2>&1 | _filter
214 echo "----------------------"
215 cd $here
216 echo "#include <Rebuild>" | pmcpp -P >$tmp.out
217 echo expect no diff lines ...
218 diff $tmp.out $PCP_VAR_DIR/pmns/Rebuild
219 echo "----------------------"
221 # success, all done
222 status=0
224 exit