File: TEST

package info (click to toggle)
indent 2.2.12-4%2Bdeb12u3
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 5,980 kB
  • sloc: ansic: 37,897; sh: 5,187; makefile: 708; yacc: 291; sed: 16; cpp: 5
file content (490 lines) | stat: -rwxr-xr-x 15,903 bytes parent folder | download
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
#!/bin/sh

# Compare the output of ../src/indent to correct output
# generated by earlier versions

INDENT=../src/indent

# First, make sure the executable exists

if test -x $INDENT; then
  if test -d ./output; then
    echo '****'
    echo 'Errors remain; output directory still exists'
    echo '****'
    ls -ld ./output
    exit 1
  fi
  printf "Regression testing "
  $INDENT --version
  echo
else
  echo '****'
  echo First, you must make $INDENT
  echo '****'
  echo
  exit 1
fi


# Code to be tested with default options

EXAMPLES="do.c else.c for.c func-def.c lshift.c ncs.c \
        proto.c typedef.h no-newline.c emacs-compatible.h fp.c unary.c \
        struct_param.c no-newline2.c no-newline3.c wide.c goto.c"

BUGS="case-label.c one-line-1.c one-line-2.c one-line-3.c \
        one-line-4.c struct-decl.c sizeof-in-while.c line-break-comment.c \
        macro.c enum.c elif.c nested.c wrapped-string.c minus_predecrement.c \
        bug-gnu-33364.c float-constant-suffix.c block-comments.c \
        no-forced-nl-in-block-init.c hexadecimal_float.c"

INDENTSRC="args.c backup.h backup.c dirent_def.h globs.c indent.h \
        indent.c indent_globs.h io.c lexi.c memcpy.c parse.c pr_comment.c \
        sys.h version.h"

mkdir output

printf "Generating indent et al with default settings..."

for i in $EXAMPLES $INDENTSRC $BUGS
do
    $INDENT -npro input/$i -o output/$i
done
echo "Done."


# Cases testing certain options
printf "Generating special option examples..."

SPECIALS="typedef-bug.c bug-hp.c bug-di.c newlined-parms.c indent.pro.c \
        comments1.c comments1-fca.c ncs-on-return.c cs-on-return.c sob.c continue.c continue-lp.c \
        kr.c struct-decl-kr.c embedded-cuddle1.c embedded-cuddle2.c kr-proc-decls.c \
        bbb-test.c preesc-comment.c if-decl-else-decl.c cp-indent.c comments.c \
        elipsis-attribute.c comments2.c comments3.c comments4.c brackets.c brackets33.c \
        brackets34.c brackets35.c brackets36.c brackets37.c brackets38.c \
        initializers.c else-if.c else-comment-br.c else-comment-bl.c \
        else-comment-br-ce.c const.c case.c case-br.c scope.c scope-br.c \
        comment-break.c cdb.c bbreak.c bad-break.c pre.c pre_lps.c pre_nlps.c dont-line-up-parentheses.c \
        bad-comment.c unknown-type.c unknown-type-npsl.c bug-npsl.c bug-psl.c do-cdw.c \
        label.c goto-1.c goto-2.c line-count.c decl_block.c pointer-pal.c else-comment-2-br.c else-comment-2-bl.c \
        else-comment-2-br-ce.c preserve-newline-after-right-brace.c gettext-strings.c single-line-conditionals.c \
        align-with-spaces.c no-space-after-fp-name.c spaces-around-initializers.c dont-tab-align-comments.c c99-compound-literal.c"

ARGS="-bad"
$INDENT -npro $ARGS input/bad-break.c -o output/bad-break.c
$INDENT -npro $ARGS input/bad-comment.c -o output/bad-comment.c

ARGS="-cdb"
$INDENT -npro $ARGS input/cdb.c -o output/cdb.c

ARGS="-kr"
$INDENT -npro $ARGS input/kr.c -o output/kr.c
$INDENT -npro $ARGS input/struct-decl.c -o output/struct-decl-kr.c
$INDENT -npro $ARGS input/embedded-cuddle1.c -o output/embedded-cuddle1.c
$INDENT -npro $ARGS input/embedded-cuddle2.c -o output/embedded-cuddle2.c
$INDENT -npro $ARGS input/kr-proc-decls.c -o output/kr-proc-decls.c

ARGS="-cli23 -bli8 -di50 -cbi1 -ci7 -i5"
$INDENT -npro $ARGS     input/case.c -o output/case.c
$INDENT -npro $ARGS -br input/case.c -o output/case-br.c
$INDENT -npro $ARGS     input/scope.c -o output/scope.c
$INDENT -npro $ARGS -br input/scope.c -o output/scope-br.c

ARGS="-nlp -ci3 -fca"
$INDENT -npro $ARGS input/continue.c -o output/continue.c
ARGS="-lp"
$INDENT -npro $ARGS input/continue.c -o output/continue-lp.c

ARGS="-sob"
$INDENT -npro $ARGS input/sob.c -o output/sob.c

ARGS="-ncs -TUNCH"
$INDENT -npro $ARGS input/typedef-bug.c -o output/typedef-bug.c
$INDENT -npro $ARGS input/ncs-on-return.c -o output/ncs-on-return.c

ARGS="-cs"
$INDENT -npro $ARGS input/ncs-on-return.c -o output/cs-on-return.c

ARGS="-kr -i2"
$INDENT -npro $ARGS input/bug-hp.c -o output/bug-hp.c

ARGS="-orig"
$INDENT -npro $ARGS input/bug-di.c -o output/bug-di.c
$INDENT -npro $ARGS input/newlined-parms.c -o output/newlined-parms.c

ARGS="-bad -bap -nbc -bl -c36 -cd36 -ncdb -nce -ci8 -cli0 -cs -d0 \
-di1 -nfca -i2 -ip0 -l80 -nlp -npcs -npsl -nsc -nsob -ss -nv"
$INDENT -npro $ARGS input/indent.pro.c -o output/indent.pro.c

ARGS="-fca"
$INDENT -npro $ARGS input/comments1.c -o output/comments1-fca.c

ARGS="-bbb"
$INDENT -npro $ARGS input/bbb-test.c -o output/bbb-test.c

$INDENT -npro input/comments1.c -o output/comments1.c
$INDENT -npro input/unknown-type.c -o output/unknown-type.c

$INDENT -npro input/preesc-comment.c -o output/preesc-comment.c

ARGS="-npsl"
$INDENT -npro $ARGS input/if-decl-else-decl.c -o output/if-decl-else-decl.c
$INDENT -npro $ARGS input/unknown-type.c -o output/unknown-type-npsl.c
$INDENT -npro $ARGS input/bug-npsl.c -o output/bug-npsl.c
$INDENT -npro       input/bug-npsl.c -o output/bug-psl.c

ARGS="-cp9"
$INDENT -npro $ARGS input/cp-indent.c -o output/cp-indent.c

ARGS="-di7"
$INDENT -npro $ARGS input/comments.c -o output/comments.c

ARGS="-ci5 -T aClient"
$INDENT -npro $ARGS input/elipsis-attribute.c -o output/elipsis-attribute.c

ARGS="-npsl -npcs -di3"
$INDENT -npro $ARGS input/comments2.c -o output/comments2.c
$INDENT -npro $ARGS input/comments3.c -o output/comments3.c

ARGS="-cdb -sc"
$INDENT -npro $ARGS input/comments4.c -o output/comments4.c

$INDENT -npro input/brackets.c -o output/brackets.c
$INDENT -npro --line-length33 input/brackets.c -o output/brackets33.c
$INDENT -npro --line-length34 input/brackets.c -o output/brackets34.c
$INDENT -npro --line-length35 input/brackets.c -o output/brackets35.c
$INDENT -npro --line-length36 input/brackets.c -o output/brackets36.c
$INDENT -npro --line-length37 input/brackets.c -o output/brackets37.c
$INDENT -npro --line-length38 input/brackets.c -o output/brackets38.c

$INDENT -npro --line-length40 input/bbreak.c -o output/bbreak.c

ARGS="-ci5"
$INDENT -npro $ARGS input/initializers.c -o output/initializers.c

ARGS="-nhnl --brace-indent0 --indent-level2 --dont-line-up-parentheses --continuation-indentation4 --paren-indentation0 --line-length80"
$INDENT -npro $ARGS input/else-if.c -o output/else-if.c

ARGS=""
$INDENT -npro -bl     input/else-comment.c -o output/else-comment-bl.c
$INDENT -npro -br     input/else-comment.c -o output/else-comment-br.c
$INDENT -npro -br -ce input/else-comment.c -o output/else-comment-br-ce.c
$INDENT -npro -bl     input/else-comment-2.c -o output/else-comment-2-bl.c
$INDENT -npro -br     input/else-comment-2.c -o output/else-comment-2-br.c
$INDENT -npro -br -ce input/else-comment-2.c -o output/else-comment-2-br-ce.c
$INDENT -npro -br -ce input/preserve-newline-after-right-brace.c -o output/preserve-newline-after-right-brace.c

ARGS=""
$INDENT -npro -slc input/single-line-conditionals.c -o output/single-line-conditionals.c
$INDENT -npro -br -ut -i8 -l70 -ts8 -as input/align-with-spaces.c -o output/align-with-spaces.c
$INDENT -npro -npcs input/fp.c -o output/no-space-after-fp-name.c
$INDENT -npro -sar input/spaces-around-initializers.c -o output/spaces-around-initializers.c
$INDENT -npro -c0 -ntac input/dont-tab-align-comments.c -o output/dont-tab-align-comments.c
$INDENT -npro -Tchrename_t input/c99-compound-literal.c -o output/c99-compound-literal.c

ARGS="-kr -cp0 -l132 -lps -br -psl"
$INDENT -npro $ARGS input/const.c -o output/const.c

ARGS="--dont-break-procedure-type --ignore-newlines"
$INDENT -npro $ARGS input/comment-break.c -o output/comment-break.c

ARGS="-ppi 5"
$INDENT -npro $ARGS input/pre.c -o output/pre.c

ARGS="-nlps"
$INDENT -npro $ARGS input/pre.c -o output/pre_nlps.c

ARGS="-lps"
$INDENT -npro $ARGS input/pre.c -o output/pre_lps.c

ARGS="-i4 -l100 -nlp"
$INDENT -npro $ARGS input/dont-line-up-parentheses.c -o output/dont-line-up-parentheses.c

# Check line counting of input file
$INDENT -npro input/line-count.c -o /dev/null 2>&1 | cut -d: -f3 > output/line-count.c

ARGS="-cdw -bli0"
$INDENT -npro input/do-cdw.c $ARGS -o output/do-cdw.c

ARGS="-il2 -linux"
$INDENT -npro input/label.c $ARGS -o output/label.c

ARGS="-il1"
$INDENT -npro input/goto.c $ARGS -o output/goto-1.c

ARGS="-il-4"
$INDENT -npro input/goto.c $ARGS -o output/goto-2.c

ARGS="-bad"
$INDENT -npro input/decl_block.c $ARGS -o output/decl_block.c

ARGS="-pal"
$INDENT -npro input/pointer-pal.c $ARGS -o output/pointer-pal.c

ARGS="-gts"
$INDENT -npro input/gettext-strings.c $ARGS -o output/gettext-strings.c

echo "Done."

ERR=output/errors

# Now diff all the new files with the old standard
echo
echo "Diffing generated code against standard..."

for i in $EXAMPLES $INDENTSRC $SPECIALS $BUGS
do
  printf ...$i...

  if [ ! -f standard/$i ]
  then
     echo ERROR: standard/$i missing
  fi

  if [ ! -f output/$i ]
  then
     echo ERROR: output/$i missing
  fi

  diff --initial-tab standard/$i output/$i > output/$i-diffs 2>&1
  if [ -s output/$i-diffs ]
  then
    echo ERROR: $i failed | tee -a $ERR
  else
    rm output/$i-diffs
    rm output/$i
    echo
  fi
done
echo "Diffing generated code against standard...Done."

# Testing indent (x) == indent (indent (x))
echo
printf "Testing meta-indent..."

ARGS="-bacc -nbad -nbap -nbc -br -cdb -nce -ci4 -cli4 -cs -nfc1 \
-fca -i4 -ip0 -l78 -lp -npcs -psl -sc -ss -ts4"
$INDENT -npro $ARGS input/meta-indent.c -o output/meta-indent.c
diff --initial-tab output/meta-indent.c standard/meta-indent.c > output/meta-diffs

if [ -s output/meta-diffs ]
then
  echo ERROR: 1st Meta test failed | tee -a $ERR
else
  rm output/meta-diffs
fi

for j in 1 2 3 4 5
do
  printf " $j"
  $INDENT -npro $ARGS output/meta-indent.c -o output/meta-indent.c-o

  diff --initial-tab output/meta-indent.c-o standard/meta-indent.c  > output/meta-diffs-$j

  if [ -s output/meta-diffs-$j ]
  then
    echo ERROR: Meta test $i failed | tee -a $ERR
  else
    rm output/meta-diffs-$j
    mv output/meta-indent.c-o output/meta-indent.c
    if [ $j -eq 5 ]
    then
       rm output/meta-indent.c
    fi
  fi
done

echo " Done"

# This section was added when `pr_comment.c' was rewritten, to test
# the new comment-handling code.

echo
echo Testing new comment stuff...

A1="-fca"
A2="-fc1"
A3="-fca -fc1"
A4="-fca -fc1 -cdb"
A5="-fca -fc1 -cdb -sc"
A6="-fca -fc1 -sc"
A7="-sc -fc1"
A8="-cdb -fc1"
A9="-sc -cdb -fc1"
A10="-sc -cdb"

$INDENT -npro -st     input/boxed.c > output/boxed.c-0
$INDENT -npro -st $A1 input/boxed.c > output/boxed.c-1
$INDENT -npro -st $A2 input/boxed.c > output/boxed.c-2
$INDENT -npro -st $A3 input/boxed.c > output/boxed.c-3
$INDENT -npro -st $A4 input/boxed.c > output/boxed.c-4
$INDENT -npro -st $A5 input/boxed.c > output/boxed.c-5
$INDENT -npro -st $A6 input/boxed.c > output/boxed.c-6
$INDENT -npro -st $A7 input/boxed.c > output/boxed.c-7
$INDENT -npro -st $A8 input/boxed.c > output/boxed.c-8
$INDENT -npro -st $A9 input/boxed.c > output/boxed.c-9

$INDENT -npro     input/outer.c -o output/outer.c-0
$INDENT -npro $A1 input/outer.c -o output/outer.c-1
$INDENT -npro $A2 input/outer.c -o output/outer.c-2
$INDENT -npro $A3 input/outer.c -o output/outer.c-3
$INDENT -npro $A4 input/outer.c -o output/outer.c-4
$INDENT -npro $A5 input/outer.c -o output/outer.c-5
$INDENT -npro $A6 input/outer.c -o output/outer.c-6
$INDENT -npro $A7 input/outer.c -o output/outer.c-7
$INDENT -npro $A8 input/outer.c -o output/outer.c-8
$INDENT -npro $A9 input/outer.c -o output/outer.c-9

A1="-fc1 -fca"
A2="-fc1 -fca -cdb"
A3="-fc1 -fca -cdb -sc"
A4="-fc1 -fca -sc"
A5="-fc1 -fca -l 50 -lc 50"
A6="-fc1 -fca -l 50 -lc 50 -cdb"
A7="-fc1 -fca -l 50 -lc 50 -sc"
A8="-fc1 -fca -l 50 -lc 50 -sc -cdb"

$INDENT -npro     input/newlines.c -o output/newlines.c-0
$INDENT -npro $A1 input/newlines.c -o output/newlines.c-1
$INDENT -npro $A2 input/newlines.c -o output/newlines.c-2
$INDENT -npro $A3 input/newlines.c -o output/newlines.c-3
$INDENT -npro $A4 input/newlines.c -o output/newlines.c-4
$INDENT -npro $A5 input/newlines.c -o output/newlines.c-5
$INDENT -npro $A6 input/newlines.c -o output/newlines.c-6
$INDENT -npro $A7 input/newlines.c -o output/newlines.c-7
$INDENT -npro $A8 input/newlines.c -o output/newlines.c-8

A1="-l 50 -lc 50"
A2="-l 50 -lc 50 -c 20"
A3="-l 50 -lc 50 -cd 30"
A4="-c 20 -cd 30"
A5="-fc1 -fca"
A6="-l 50 -lc 50 -fc1 -fca"
A7="-cp 10"
A8="-fc1 -fca -l50 -lc50 -c 30 -cd 20 -cp 8"
A9="-cdb -sc -l 50 -lc 50 -fca -fc1"

$INDENT -npro     input/cplus.c -o output/cplus.c-0
$INDENT -npro $A1 input/cplus.c -o output/cplus.c-1
$INDENT -npro $A2 input/cplus.c -o output/cplus.c-2
$INDENT -npro $A3 input/cplus.c -o output/cplus.c-3
$INDENT -npro $A4 input/cplus.c -o output/cplus.c-4
$INDENT -npro $A5 input/cplus.c -o output/cplus.c-5
$INDENT -npro $A6 input/cplus.c -o output/cplus.c-6
$INDENT -npro $A7 input/cplus.c -o output/cplus.c-7
$INDENT -npro $A8 input/cplus.c -o output/cplus.c-8
$INDENT -npro $A9 input/cplus.c -o output/cplus.c-9

A1="-sc -cdb -fc1"
A2="-i 10 -fc1"

$INDENT -npro     input/tabs.c -o -fc1 output/tabs.c-0
$INDENT -npro $A1 input/tabs.c -o output/tabs.c-1
$INDENT -npro $A2 input/tabs.c -o output/tabs.c-2

$INDENT -npro input/cplus-one.c -o output/cplus-one.c
$INDENT -npro input/class-func.cc -o output/class-func.cc
$INDENT -npro input/empty.c -o output/empty.c
$INDENT -npro input/already-starred.c -o output/already-starred.c
$INDENT -npro input/box-comm.c -o output/box-comm.c
$INDENT -npro input/long-comm.c -o output/long-comm.c
$INDENT -npro input/ind-star.c -o output/ind-star.c
$INDENT -npro input/first-in-block.c -o output/first-in-block.c
# currently fails $INDENT -npro input/two-on-line.c -o output/two-on-line.c
$INDENT -npro input/method.c -o output/method.c

A1="-fca"
$INDENT -npro input/right-margin-comment.c $A1 -o output/right-margin-comment.c

# These aren't really comment testing, they test the indent control
# statements '*INDENT-ON*' and '*INDENT-OFF*'
$INDENT -npro input/on-off-1.c -o output/on-off-1.c
$INDENT -npro input/on-off-2.c -o output/on-off-2.c

cd output
ERR=errors
# currently fails:       two-on-line.c 
for i in boxed.c-* outer.c-* newlines.c-* cplus.c-* tabs.c-* cplus-one.c class-func.cc \
        empty.c already-starred.c box-comm.c long-comm.c ind-star.c first-in-block.c \
        on-off-1.c on-off-2.c \
        method.c right-margin-comment.c
do
  printf ...$i...
  diff --initial-tab ../standard/$i $i > $i-diffs 2>&1
  if [ -s $i-diffs ]
  then
    printf ERROR: $i failed | tee -a $ERR
    echo >> $ERR
  else
    rm $i-diffs $i
  fi
  echo
done
cd ..
echo Testing new comment stuff...Done.


echo Testing bad code handling....

# print_comment() was reading past the end of the buffer...
echo -ne '/*' | $INDENT -npro -st > /dev/null 2>&1
if [ $? -ne 0 ]
then
    echo "ERROR: print_comment reads past the end of the buffer." | tee -a $ERR
    echo >> $ERR
fi

# Heap corruption by writing past the end of combuf
$INDENT -npro -st > /dev/null 2>&1 < input/combuf-heap-corruption
if [ $? -ne 0 ]
then
    echo "ERROR: heap corruption in comments.c" | tee -a $ERR
    echo >> $ERR
fi

# This ends in a error from indent but it shouldn't coredump.
$INDENT -npro input/bug206785.c -o output/bug206785.c 2>output/bug206785.err

if [ $? -ne 2 ]
then
    printf ERROR: bad return status from indent. | tee -a $ERR
    echo >> $ERR
fi
cd output

for i in bug206785.c bug206785.err
do
  printf ...$i...
  diff --initial-tab ../standard/$i $i > $i-diffs 2>&1
  if [ -s $i-diffs ]
  then
    printf ERROR: $i failed | tee -a $ERR
    echo >> $ERR
  else
    rm $i-diffs
    rm $i
  fi
  echo
done

echo Testing bad code handling...Done.

# Now see if any errors occured.  If so, bitch and moan, otherwise,
# remove the output directory.
#
if test -s $ERR
then
  echo '****  Errors occured:'
  cat  $ERR   
  echo '****  Errors occured: ./output not removed'
  echo
  exit 1
else
  cd ..
    ls -l output
  rm -rf output
  echo
  echo Regression test successfully completed.
  echo
fi