5 # Copyright (c) 2015 Ken McDonell. All Rights Reserved.
9 echo "QA output created by $seq"
11 # get standard environment, filters and checks
17 # 1 "/tmp/853-3145.inc"
22 -e "/^# [1-9]/s@$tmp@TMP@" \
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
33 %define mumble 'mumble and "fumble"'
36 cat <<End-of-File >$tmp.in
38 Firstly, there is the mumble ...
40 what about eek ? expect this to be \u\r\k not \e\e\k
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 "----------------------"
66 echo "=== expansion with -r ==="
67 echo "----------------------"
68 pmcpp
-sr <$tmp.
in 2>&1 | _filter
69 echo "----------------------"
70 cat <<End-of-File >$tmp.in2
72 Firstly, there is the mumble ...
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
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}
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 "----------------------"
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)
101 echo "=== error cases ==="
102 echo "----------------------"
103 cat <<End-of-File >$tmp.in
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
115 And is this multi multiple lines?
117 pmcpp
-sr <$tmp.
in 2>&1 | _filter
118 echo "----------------------"
119 cat <<End-of-File >$tmp.in
120 # exposed #else outside #if ... scope
126 pmcpp
-r <$tmp.
in 2>&1 | _filter
127 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]
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
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!
151 pmcpp
-d <$tmp.
in 2>&1 | _filter
152 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'
161 cat <<End-of-File >$tmp.in
164 log mandatory on %dk_freq {
169 %define cpu_pfx 'kernel.all.cpu.'
170 log mandatory on %cpu_freq {
176 pmcpp
-rs <$tmp.
in 2>&1 | _filter
177 echo "----------------------"
178 pmcpp
-rs -Dwant_cpu <$tmp.
in 2>&1 | _filter
179 echo "----------------------"
182 echo "=== -I tests ==="
192 echo "----------------------"
193 pmcpp
-d a
2>&1 | _filter
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
205 cat <<End-of-File >sub/sub-sub/c-foobar
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
213 pmcpp
-d sub
/a
2>&1 | _filter
214 echo "----------------------"
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 "----------------------"