File: mktestsuite

package info (click to toggle)
pike7.8 7.8.700-7~bpo70%2B1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 68,572 kB
  • sloc: ansic: 252,113; xml: 36,537; makefile: 4,216; sh: 2,879; lisp: 655; asm: 591; objc: 212; pascal: 157; sed: 34
file content (282 lines) | stat: -rwxr-xr-x 6,467 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
#!/bin/sh

##
## We attempt to locate a working m4
##
M4=m4

IFS="${IFS= 	}"; save_ifs="$IFS"; IFS="${IFS}:"
HAVEGNU=no
HAVEWORKS=no

# GNU m4 is named gm4 on FreeBSD and Solaris 10.
PATHS=$PATH:/usr/sfw/bin:/opt/sfw/bin:/opt/csw/bin:/opt/gnu/bin:/usr/gnu/bin
for m4 in gm4 m4
do
  for d in $PATHS; do
    test -z "$d" && ac_dir=.

    if test -f $d/$m4; then
      # "m4.c 1.9 89/07/10 SMI" (of SunOS 4.1.1_U1) is broken and hangs
      # during the quote test.
      m4_ident="`strings $d/$m4|grep '@(#)m4.c' 2>/dev/null`"
      if test "x$m4_ident" '!=' "x" && \
	 echo "$m4_ident"|egrep 'm4.c 1\.[0-9] .* SMI' >/dev/null 2>&1; then
	works=no
      elif echo 'divert(-1)changequote([[,]])define(DOIT,ifelse([foo],foo,[DOIT($1)]))DOIT([[m4exit(1)]])' | $d/$m4 >/dev/null; then
        works=yes
      else
        works=no
      fi

      # FIXME: Ought to check for "pushed back more than 4096 chars".

      case `echo __gnu__ | $d/$m4` in
        __gnu__) isgnu=no ;;
        *) isgnu=yes ;;
      esac

      case "$HAVEGNU-$isgnu:$HAVEWORKS-$works" in
        *:no-yes|no-yes:*)
          M4=$d/$m4
          HAVEGNU=$isgnu
          HAVEWORKS=$works
        ;;
      esac
    fi
    if test "$HAVEGNU:$HAVEWORKS" = "yes:yes"; then
      break
    fi
  done
  if test "$HAVEGNU:$HAVEWORKS" = "yes:yes"; then
    break
  fi
done

IFS="$save_ifs"
(
cat <<EOF
divert(-1)

dnl generates a script that is supposed to test Pike
dnl note that not everything is tested yet, you are welcome to
dnl submit more tests.

changequote([[,]])

define(DOIT,ifelse([foo],foo,[DOIT(\$1)]))dnl
DOIT([[errprint([This m4 cannot handle quote strings with more than one character
Please consider installing GNU m4.])
m4exit(1)
]])dnl

changecom

define(real_checkarg,[[dnl
ifelse(index([[\$3]],format([[%c]],255)),-1,,[[dnl
format([%c],255)
errprint(__file__:__line__: [[
Argument \$2 to \$1 contains the character ]]format([[%c]],255)[[,
which is treated as EOF by some m4 implementations.
]])m4exit(1)]])dnl
ifelse(eval(len([[\$3]])>4096),0,,[[dnl
errprint(__file__:__line__: [[
Argument \$2 to \$1 has ]]len([[\$3]])[[ characters,
some m4 implementations only allow 4096.
]])m4exit(1)]])dnl
]])

ifdef([[__gnu__]],
[[define(checkarg,[[[[real_checkarg([[\$1]],\$2,[[\$\$2]])]]]])]],
[[define(checkarg,)]]
)

define(SEPARATOR,[[....]])
define(CONDITION,[[]])
define(M4_TESTDIR,combine_path("$1",".."))

define(DOTEST,dnl
checkarg([[DOTEST]],1)dnl
checkarg([[DOTEST]],2)dnl
[[dnl
divert(0)dnl
define([[TESTNO]],incr(TESTNO))dnl
CONDITION()__file__:__line__: test TESTNO, expected result: [[\$1]]
[[\$2]]
SEPARATOR
divert(-1)dnl]])

define(START_MARKER,[[divert(0)START [[\$1]]
divert(-1)]])
define(END_MARKER,[[divert(0)END
divert(-1)]])

define(ignore_warning, dnl
checkarg([[ignore_warning]],1)dnl
checkarg([[ignore_warning]],2)dnl
[[DOTEST(PUSH_WARNING,dnl
mixed a() { return [[\$1]]; })
\$2
DOTEST(POP_WARNING,dnl
mixed a() { return [[\$1]]; })
]])

define(pop_warning, [[DOTEST(POP_WARNING,dnl
mixed a() { return [[\$1]]; })]])

define(test_any, [[DOTEST(EQ,dnl
mixed a() { [[\$1]]; }
mixed b() { return [[\$2]]; })]])

define(test_any_equal, [[DOTEST(EQUAL,dnl
mixed a() { [[\$1]]; }
mixed b() { return [[\$2]]; })]])

define(test_eq,[[DOTEST(EQ,dnl
mixed a() { return [[\$1]]; }
mixed b() { return [[\$2]]; })]])

define(test_equal,[[DOTEST(EQUAL,dnl
mixed a() { return [[\$1]]; }
mixed b() { return [[\$2]]; })]])

define(test_do,[[DOTEST(RUN,dnl
mixed a() { [[\$1]]; })]])

define(test_true, [[DOTEST(TRUE,dnl
mixed a() { return [[\$1]]; })]])

define(test_false, [[DOTEST(FALSE,dnl
mixed a() { return [[\$1]]; })]])

define(test_compile,[[DOTEST(COMPILE,dnl
void x() { [[\$1]] ; } )]])

define(test_compile_any,[[DOTEST(COMPILE,dnl
[[\$1]] )]])

define(test_compile_error,[[DOTEST(COMPILE_ERROR,dnl
mixed a() { [[\$1]];})]])

define(test_compile_error_any,[[DOTEST(COMPILE_ERROR,dnl
[[\$1]])]])

define(test_compile_warning,[[DOTEST(COMPILE_WARNING,dnl
mixed a() { [[\$1]];})]])

define(test_compile_warning_any,[[DOTEST(COMPILE_WARNING,dnl
[[\$1]])]])

define(test_eval_error,[[DOTEST(EVAL_ERROR,dnl
mixed a() { [[\$1]]; })]])

define(test_define_program,[[DOTEST(RUN,dnl
void a() { add_constant("[[\$1]]",class c {
  [[\$2]]
});})]])

define(test_program, [[DOTEST(TRUE,dnl
[[\$1]])]])

define(test_program_eq, [[DOTEST(EQ,dnl
[[\$1]]
mixed b() {return [[\$2]];})]])

define(test_program_equal, [[DOTEST(EQUAL,dnl
[[\$1]]
mixed b() {return [[\$2]];})]])

define(test_tests, [[DOTEST(RUNCT,dnl
[[\$1]])]])

define(cond_begin,dnl
checkarg([[cond]],1)dnl
[[
define([[CONDITION]],[[COND \$1
]])
]])

define(cond_end,dnl
[[
define([[CONDITION]],[[]])
]])

define(cond,dnl
checkarg([[cond]],2)dnl
[[
cond_begin([[\$1]])
\$2
cond_end
]])

define(cond_resolv,[[cond([[master()->resolv(dnl
  String.trim_all_whites("\$1"))]],[[\$2]])]])
define(ifefun,[[cond([[all_constants()->\$1]],[[\$2]])]])
define(nonregression,[[ifefun(regression,[[\$1]])]])

define(TESTNO,0)

// testing < > <= >=
define([[test_cmp]],[[
test_true(\$1<\$2)
test_false(\$1>\$2)
test_true(\$2>\$1)
test_false(\$2<\$1)
test_true(\$1<=\$2)
test_false(\$1>=\$2)
test_true(\$2>=\$1)
test_false(\$2<=\$1)
test_true(\$2<=\$2)
test_true(\$1>=\$1) ]])

define([[test_cmp3]],[[
test_cmp(\$1,\$2)
test_cmp(\$2,\$3)
test_cmp(\$1,\$3)

 test_true(\`<(\$1,\$2,\$3))
test_false(!\`<(\$1,\$2,\$3))
test_false(\`<(\$1,\$3,\$2))
 test_true(!\`<(\$1,\$3,\$2))
test_false(\`<(\$2,\$3,\$1))
test_false(\`<(\$2,\$1,\$3))
test_false(\`<(\$3,\$1,\$2))
test_false(\`<(\$3,\$2,\$1))
test_false(\`<(\$3,\$2,\$2,\$1))

 test_true(\`<=(\$1,\$2,\$3))
test_false(!\`<=(\$1,\$2,\$3))
test_false(\`<=(\$1,\$3,\$2))
test_false(\`<=(\$2,\$3,\$1))
test_false(\`<=(\$2,\$1,\$3))
 test_true(!\`<=(\$2,\$1,\$3))
test_false(\`<=(\$3,\$1,\$2))
test_false(\`<=(\$3,\$2,\$1))
 test_true(\`<=(\$1,\$1,\$2,\$2,\$3,\$3))

test_false(\`>(\$1,\$2,\$3))
test_false(\`>(\$1,\$3,\$2))
test_false(\`>(\$2,\$3,\$1))
test_false(\`>(\$2,\$1,\$3))
test_false(\`>(\$3,\$1,\$2))
 test_true(\`>(\$3,\$2,\$1))
test_false(\`>(\$3,\$2,\$2,\$1))

test_false(\`>=(\$1,\$2,\$3))
test_false(\`>=(\$1,\$3,\$2))
test_false(\`>=(\$2,\$3,\$1))
test_false(\`>=(\$2,\$1,\$3))
test_false(\`>=(\$3,\$1,\$2))
 test_true(!\`>=(\$3,\$1,\$2))
 test_true(\`>=(\$3,\$2,\$1))
 test_true(\`>=(\$3,\$3,\$2,\$2,\$1,\$1))
test_false(!\`>=(\$3,\$3,\$2,\$2,\$1,\$1))

test_equal(min(\$2,\$1,\$3), \$1)
test_equal(max(\$2,\$1,\$3), \$3)
 ]])

include($1)
EOF
) | (shift ; $M4 -d "$@" - )
exit $?