forked from cil-project/cil
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathtestcil.pl
895 lines (761 loc) · 27.3 KB
/
testcil.pl
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
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
# A regression tester for CIL
#
# Note: comments now start with Bug/Notbug/Minor/Limitation to give some categorisation.
require 5.000;
# Packages to import.
use Getopt::Long; # Command-line option processing
use File::Basename; # File name parsing
use Cwd; # Directory navigation
use strict;
# use Data::Dumper;
use RegTest;
$ENV{LANG} = 'C';
print "Test infrastructure for CIL on $^O\n";
# Create our customized test harness
my $TEST = CilRegTest->new(AvailParams => { 'RUN' => 1,
'SUCCESS' => 0},
LogFile => "cil.log",
CommandName => "testcil");
# sm: I want a global name for this $TEST thing, since I find it is merely
# excess verbiage when adding tests..
$main::globalTEST = $TEST;
my $inferbox="none";
# am I on win32?
my $win32 = ($^O eq 'MSWin32' || $^O eq 'cygwin');
my $unix = !$win32;
my $solaris = $^O eq 'solaris';
my $freebsd = $^O eq 'freebsd';
# operating modes
my $gcc = "_GNUCC=1"; # sm: not sure where/why this is needed
my $make;
if ($solaris || $freebsd) {
$make = "gmake";
} else {
$make = "make";
}
# We watch the log and we remember in what stage we are (so that we can
# interpret the error)
# Stages:
# 1000 - Start (scripts, preprocessors, etc.)
# 1001 - Parsing
# 1002 - cabs2cil
# 1003 - Compilation
# 1004 - Running
my %commonerrors =
("^Parsing " => sub { $_[1]->{instage} = 1001; },
"^Converting CABS" => sub { $_[1]->{instage} = 1002; },
"^Linked the cured program" => sub { $_[1]->{instage} = 1008; },
# We are seeing an error from make. Try to classify it based on the stage
# in which we are
"^make: \\*\\*\\*" =>
sub {
if($_[1]->{ErrorCode} == 0) {
$_[1]->{ErrorCode} = $_[1]->{instage};
}},
#"[sS]yntax error" => sub { $_[1]->{ErrorCode} = 1000; },
# Collect some more parameters
# Now error messages
"^((Error|Bug|Unimplemented): .+)\$"
=> sub { if(! defined $_[1]->{ErrorMsg}) {
$_[1]->{ErrorMsg} = $_[2];} },
"^(.+ : error .+)\$" => sub { if(! defined $_[1]->{ErrorMsg}) {
$_[1]->{ErrorMsg} = $_[2];} },
"^(.+:\\d+: (Error|Unimplemented|Bug):.+)\$"
=> sub { if(! defined $_[1]->{ErrorMsg}) {
$_[1]->{ErrorMsg} = $_[2];} },
"^(.+: fatal error.+)\$" => sub { if(! defined $_[1]->{ErrorMsg}) {
$_[1]->{ErrorMsg} = $_[2];} },
"^stackdump: Dumping stack trace" =>
sub { if(! defined $_[1]->{ErrorMsg}) {
$_[1]->{ErrorMsg} = $_[2];} },
"^user\\s+(\\d+)m([\\d.]+)s"
=> sub { $_[1]->{RUN} = 60 * $_[2] + $_[3]; },
"^TOTAL\\s+([\\d.]+) s" => sub { $_[1]->{CURE} = $_[2]; },
);
# Add a test.
# command is the base name of the tests + space separated arguments
# extrargs are passed on the command line for each test
# fields must be fields to be added to the newly created tests
sub addTest {
my($command, %extrafields) = @_;
my $self = $main::globalTEST;
my ($name, $extraargs) =
($command =~ /^(\S+) ?(.*)$/); # name is first word
my $theargs = $self->testCommandExtras($extraargs);
my %patterns = %commonerrors;
my $kind;
my $ccvar;
if ($ENV{'CC'} ne "") {
$ccvar = "CC=". $ENV{'CC'};
} else {
$ccvar = "";
}
my $tst =
$self->newTest(Name => $name,
Dir => ".",
Cmd => "$ccvar $make " . $name . $theargs,
Group => [ ],
Patterns => \%patterns);
# Add the extra fields
my $key;
foreach $key (keys %extrafields) {
$tst->{$key} = $extrafields{$key};
}
return $tst;
}
sub addTestFail {
my($command, $failpattern) = @_;
addTest($command, MustFail => $failpattern);
}
sub addBadComment {
my($name, $comm) = @_;
my $self = $main::globalTEST;
$self->addComment($name, $comm);
$self->addGroups($name, "bad");
}
sub addToGroup {
my ($name, @groups) = @_;
my $self = $main::globalTEST;
$self->addGroups($name, @groups);
}
# Now add tests
addTest("testrun/const-array-init WARNINGS_ARE_ERRORS=1");
addTest("testrun/const-struct-init WARNINGS_ARE_ERRORS=1");
addTest("test/const-struct-init WARNINGS_ARE_ERRORS=1");
addTest("test/warnings-noreturn WARNINGS_ARE_ERRORS=1");
addTest("testrun/warnings-unused-label WARNINGS_ARE_ERRORS=1");
addTest("test/warnings-cast WARNINGS_ARE_ERRORS=1");
addTest("testrun/castincr WARNINGS_ARE_ERRORS=1");
addTest("test/castunion");
addTest("test/castcall");
addTest("test/apachebits");
addTest("testrun/apachebuf");
addTest("testrun/apachefptr");
addTest("testrun/asm1 _GNUCC=1");
addTest("test/asm2 _GNUCC=1");
addTest("test/asm3 _GNUCC=1");
addTest("test/asm4 _GNUCC=1");
addTest("test/asm_emptyclobberallowed _GNUCC=1");
addTest("testobj/asm5 _GNUCC=1");
addTest("testrun/offsetof");
addTest("testrun/offsetof1");
addTest("testrun/offsetof2");
addTest("testrun/offsetof3");
addTest("testrun/question-fold-float USE_LOGICAL_OPERATORS=1");
addTest("testrun/question");
addTest("testrun/question2");
addTest("testrun/question3 USE_LOGICAL_OPERATORS=1");
addTest("test/argcast");
addBadComment("test/argcast",
"Notbug. CIL bases type for implicit functions based on first call's argument.");
addTest("test/array1");
addTest("test/array2");
addTest("testrun/array_varsize");
addTest("testrun/array_multi_varsize");
addBadComment("testrun/array_multi_varsize",
"Limitation. CIL does not handle variable-length multidimensional arrays.");
addTest("testrun/array_formal");
addTest("testrun/formalscope");
addTest("test/matrix");
addTest("runall/switch");
addTest("testrun/strloop");
addTest("testrun/strloop3");
addTest("testrun/percentm");
addTest("testrun/percent400");
addTest("testrun/caserange _GNUCC=1");
addTest("test/attr2 _GNUCC=1");
addTest("test/attr3 _GNUCC=1");
addTest("testrun/attr4 _GNUCC=1");
addTest("testrun/attr5_GNUCC=1");
addTest("test/attr6 _GNUCC=1");
addTest("test/attr7 _GNUCC=1");
addTest("test/attr8 _GNUCC=1");
addTest("test/attr9 _GNUCC=1 WARNINGS_ARE_ERRORS=1");
addTest("test/attr10 _GNUCC=1");
addTest("test/attr11 _GNUCC=1");
addTest("test/attr12 _GNUCC=1");
addTest("test/attr13 _GNUCC=1");
addTest("testrun/packed _GNUCC=1 WARNINGS_ARE_ERRORS=1");
addTest("test/packed2 _GNUCC=1");
addTest("test/bitfield");
addTest("testrun/bitfield3");
addTest("testrun/bitfield2");
addTest("testrun/call2 ");
addTest("test/cast1");
addTest("test/cast2");
addTest("test/cast4 _GNUCC=1");
addTest("testrun/cast8 ");
addTest("test/constprop");
addTest("testrun/const1 _GNUCC=1");
addTest("testrun/const2 ");
addTest("testrun/const3 ");
addTest("testrun/const4 _GNUCC=1");
addTest("testrun/const5 _GNUCC=1");
addTest("testrun/const6 ");
addTest("test/const7 ");
addTest("testrun/const8 ");
addTest("test/const9 ");
addTest("testrun/const10 ");
addTest("testrun/const11 ");
addTest("testrun/const12 ");
addTest("test/const13 WARNINGS_ARE_ERRORS=1");
addBadComment("test/const13", "Minor. Const warnings from generated code - need more casts.");
addTest("test/const14");
addTest("testrun/const15 ");
addTest("testrun/const16 ");
addTest("test/deref _GNUCC=1");
addTest("test_i/empty");
addTest("test/enum");
addTest("testrun/enum2");
addTest("test/func");
addTest("test/funcarg ");
addBadComment("test/funcarg",
"Bug. In parser (argument of function type)");
addTest("testrun/func2");
addTest("testrun/func3");
addTest("testrun/func4");
addTest("test/func10 ");
addBadComment("test/func10",
"Bug. Cannot parse some strange K&R function definition");
addTest("test/globals");
addTest("test/globals2 ");
addBadComment("test/globals2", "Bug. we print array size expressions that refer to variables that haven't been defined yet.");
addTest("testrun/float");
addTest("testrun/float2 ");
addTest("test/huff1");
addTest("testrun/init");
addTest("testrun/init1");
addTest("testrun/init2 _GNUCC=1");
addTest("testrun/init3 _GNUCC=1");
addTest("testrun/init4 _GNUCC=1");
addTest("testrun/init5 _GNUCC=1");
addTest("testrun/init6 ");
addTest("test/init8 _GNUCC=1");
addTest("testrun/init9 _GNUCC=1");
addTest("testrun/init9 _GNUCC=1");
addTest("testrun/init10 _GNUCC=1");
addTest("testrun/init11 _GNUCC=1");
addTest("testrun/init12 _GNUCC=1");
addTest("testrun/init13 _GNUCC=1");
addTest("testrun/init14 _GNUCC=1");
addTest("testrun/init15 _GNUCC=1");
addTest("testrun/init16 ");
addTest("testrun/init17 ");
addTest("testrun/init18 ");
addTest("testrun/init19 WARNINGS_ARE_ERRORS=1");
addTest("testrun/init20 _GNUCC=1");
addTest("testrun/init21 _GNUCC=1");
addTest("testrun/init22 ");
addTest("test/array-size-trick ");
addTest("testrun/logical ");
addTest("testrun/logical1 USE_LOGICAL_OPERATORS=1");
addTest("testrun/logical2 USE_LOGICAL_OPERATORS=1");
addTest("testrun/cond1 _GNUCC=1");
addTest("testrun/cond2 _GNUCC=1");
addTest("testrun/initial _GNUCC=1");
addTest("testrun/inline1 _GNUCC=1");
addBadComment("testrun/inline1", "Notbug. CIL now matches gcc's new behavior for extern inline, this test checks for the old behavior.");
addTest("testrun/inline2 _GNUCC=1");
addTest("test/inline3 _GNUCC=1");
addTest("test/decl2 _GNUCC=1");
addBadComment("test/decl2",
"Bug. An old-style argument type should go through the default type conversion before being added to the function's type.");
addTest("test/jmp_buf");
addTest("test/linux_atomic _GNUCC=1");
addTest("testrun/linux_signal _GNUCC=1");
addTest("test/li");
addTest("test_i/lineno");
addTest("test/list");
addTest("testrun/localinit ");
addTest('testrun/longBlock', '');
addTest("testrun/perror");
addTest("testrun/perror1");
addTest("test/pure");
addTest("testrun/post-assign ");
addBadComment("testrun/post-assign",
"Minor. CIL does not have the same evaluation order for ++ as gcc");
addTest("test/printf ");
addTest("test/printf_const ");
addTest("testrun/printf2");
addTest("test/unimplemented");
addTest("testrun/vararg1");
addTest("testrun/vararg2");
addTest("testrun/vararg3");
addTest("testrun/vararg4");
addTest("testrun/varargauto1");
addTest("testrun/vararg5 _GNUCC=1");
addTest("testrun/vararg6");
addTest("test/vararg7 _GNUCC=1");
addTest("testrun/va-arg-1 _GNUCC=1");
addTest("testrun/va-arg-2 _GNUCC=1");
addTest("testrun/va-arg-7 _GNUCC=1");
addTest("test/arrsize ");
addTest("testrun/comma1 _GNUCC=1");
addTest("test/retval");
addTest("testrun/static ");
addTest("test/static1");
addTest("testrun/static2 ");
addTest("test/strcpy");
addTest("test/struct_init");
addTest("test/structassign");
addTest("testrun/align1 _GNUCC=1");
addTest("testrun/align2 _GNUCC=1 EXTRAARGS=-O2");
addTest("test/align3 _GNUCC=1");
addTest("test/tags");
addTest("test/task _GNUCC=1");
addTest("test/power1");
addTest("testrun/scope1");
addTest("test/scope2");
addTest("test/scope3");
addBadComment("test/scope3", "Notbug. This failure is ok - enum's may be represented by a type other than int, even though enum constants are of type int...");
addTest("test/scope4");
addTest("testrun/scope5 _GNUCC=1");
addTest("testrun/scope6");
addTest("testrun/scope8");
addTest("testrun/scope9 ");
addTest("testrun/scope10 ");
addTest("testrun/scope11 ");
addTest("test/scope12 ");
addTest("test/voidstar");
addTest("testrun/memcpy1");
addTest("testrun/land_expr");
addTest("test/noreturn ");
addTest("test/constrexpr ");
addTest("testrun/flexible-array-member ");
addTest("test-bad1/flexible-array-member-bad ");
addTest("testrun/label1");
addTest("testrun/label2");
addTest("testrun/label3");
addTest("testrun/label4 _GNUCC=1");
addTest("testrun/label2b COMPUTEDGOTO=1");
addTest("testrun/label3b COMPUTEDGOTO=1 LOCALINIT=1");
addTest("testrun/label4b COMPUTEDGOTO=1 _GNUCC=1");
addTest("test/label5");
addTest("testrun/label6");
addTest("test/label7");
addTest("test/label8");
addTest("test/label9 EXTRAARGS=--domakeCFG");
addTest("testrun/case_then_default_in_switch EXTRAARGS=--domakeCFG");
addTestFail("test/switch_default_parse_bug ", "Empty default in switch ");
addTestFail("test/break1 ", "No enclosing loop for break");
addTest("testrun/wchar1");
addTest("testrun/wchar2");
addTest("testrun/wchar3");
addTest("testrun/wchar4");
addTest("testrun/wchar5 ");
addTest("testrun/wchar6");
addTest("testrun/wchar7");
addTest("testrun/escapes");
addTest("test-bad1/wchar-bad ");
addTest("testrun/addrof3 _GNUCC=1");
addTest("testrun/lval1 _GNUCC=1");
#MIA: addTest("test/bind2 EXTRAARGS=--allowInlineAssembly");
#addToGroup("test/bind2", "slow");
addTest("testrun/addr-array");
addTest("testrun/addr-string");
addTest("combine1 ");
addTest("combine2 ");
addTest("combine3 ");
addTest("combine5 ");
addTest("combine6 ");
addTest("combine8 ");
addTestFail("combine9 ", "Incompatible declaration for g");
addTest("combine10 ");
addTest("combine11 ");
addTest("combine12 ");
addTest("combine13 ");
addTest("combine14 ");
addTest("combine15 ");
addTest("combine16 ");
addTest("combine17 ");
addTest("combine18 ");
addTest("combine20 ");
addTest("combine21 ");
addTest("combine22 ");
addBadComment("combine22", "Bug. Outstanding since 1.3.6 at least");
addTest("combinealias ");
addTest("combinelibrik ");
addTest("combineenum1 ");
addTest("combineenum2 ");
addTest("combineenum3 ");
addTest("combine_init ");
addTest("combineinline1 ");
addBadComment("combineinline1", "Bug. Outstanding since 1.3.6 at least");
addTest("combineinline2 ");
addTest("combineinline3 ");
addBadComment("combineinline3", "Bug. Outstanding since 1.3.6 at least");
addTest("combineinline4 ");
addBadComment("combineinline4", "Bug. Outstanding since 1.3.6 at least");
addTest("combineinline6 ");
addTest("combinestruct1 ");
addTest("mixedcomb ");
addTest("testrun/math1 ");
addTest("test/linuxcombine1_1 ");
addTest("arcombine _GNUCC=1");
addTest("testrun/funptr1");
addTest("testrun/typespec1 _GNUCC=1");
addBadComment("testrun/typespec1",
"Notbug. GCC 4 no longer allows this, so the error is fine.");
addTest("testrun/returnvoid ");
addTest("testrun/returnvoid1 ");
addTest("testrun/return1 ");
addTest("testrun/for1 ");
addTest("testrun/void _GNUCC=1");
addTest("test/voidtypedef ");
addTest("testrun/wrongnumargs ");
addBadComment("testrun/wrongnumargs",
"Notbug. Should fail since we don't pad argument lists");
addTest("test/restrict EXTRAARGS=-std=c9x _GNUCC=1");
addTest("test/restrict1 _GNUCC=1");
addTest("testrun/rmtmps1 ");
addTest("testrun/rmtmps2 _GNUCC=1");
addTest("test/proto1 ");
addBadComment("test/proto1",
"Bug. CIL doesn't like pointers to old-style functions...");
addTest("test/proto2 ");
addBadComment("test/proto2",
"Bug. In parser (precedences)");
addTest("testrun/struct1 ");
addTest("testrun/voidarg ");
addTest("testrun/union2 ");
addTest("testrun/union3 ");
addTest("test/union5 ");
addTest("testrun/union6 ");
addBadComment("testrun/union6",
"Bug. Unsupported C11 implicit initialization of union padding.");
addTest("runall/extinline ");
addTest("testrun/rmtmps-attr ");
addBadComment("testrun/rmtmps-attr",
"Bug. A limitation of our support for attributes");
addTest("testrun/vsp");
addTest("test/cpp-2 ");
addBadComment("test/cpp-2",
"Bug. In parser (empty pragmas)");
addTest("test/cpp-3 _GNUCC=1");
addTest("testrungcc/enum3 _GNUCC=1");
addTest("testrungcc/enum3a _GNUCC=1");
addTest("testrungcc/enum3b _GNUCC=1");
addTest("testrungcc/enum3c _GNUCC=1");
addBadComment("testrungcc/enum3c",
"Limitation. CIL constant folder doesn't consider x << y constant if y is strange (negative or bigger than #bits in x's type)");
addTest("testrungcc/enum3d _GNUCC=1");
addTest("testrungcc/enum3e _GNUCC=1");
addTest("testrungcc/enum3f _GNUCC=1");
addTest("testrungcc/enum3g _GNUCC=1");
addTest("testrungcc/enum3h _GNUCC=1");
addTest("testrungcc/enum3i _GNUCC=1");
addTest("testrungcc/enum3j _GNUCC=1");
addTest("testrungcc/enum3k _GNUCC=1");
addTest("testrungcc/enum3l _GNUCC=1");
addTest("testrun/msvc1 ");
addTest("testrun/msvc5 ");
addTest("testrun/extern1 ");
addTest("test/duplicate ");
addTest("testrun/simon6");
addTest("testrun/stringsize");
addTest("testrun/min ");
addTest("testrun/typeof1 ");
addTest("testrun/semicolon _GNUCC=1");
addTest("merge-ar ");
addTest("testrun/sizeof1");
addTest("testrun/sizeof2");
addTest("test/sizeof3");
addBadComment("test/sizeof3", "Bug. Constant-folding of very large arrays does not work on 32-bit machines.");
addTest("test/outofmem ");
addTest("testrun/builtin ");
addTest("test/builtin2 ");
addTest("testrun/builtin3 ");
addTest("testrun/builtin_choose_expr");
addTest("testrungcc/builtin_object_size _GNUCC=1 OPTIMIZE=1");
addTest("testrun/builtin4 ");
addTest("test/builtin5 ");
addTest("test/sync-1 _GNUCC=1");
addTest("test/sync-2 _GNUCC=1");
addTest("test/sync-3 _GNUCC=1");
addTest("testrun/comparisons");
addTest("testrun/assign");
# self-contained tests of specific things which had problems before
addTest("scott/multiplestatics");
addTest("scott/partialbracket");
addTest("scott/enuminit");
addTest("scott/gimpdouble");
addTest("scott/struct_cs");
addTest("scott-nogcc/bogus_redef");
addTest("scott/s59");
addTest("scott/putc $gcc");
addTest("scott/lexnum");
addTest("scott/ctype");
# function pointers don't work with inferred wildness
addTest("scott/funcptr");
# transparent unions are a problem for network apps
addTest("scott/transpunion $gcc");
addTest("scott/sockaddr $gcc");
# misc...
addTest("scott/constdecl");
addTest("scott/oldstyle");
addTest("scott/typeof $gcc");
addTest("scott/asmfndecl $gcc");
addBadComment("scott/asmfndecl", "Notbug. Not a bug if fails on a non-Linux machine ;-)");
addTest("scott/open $gcc");
addTest("scott/constfold");
addTest("scott/mode_sizes $gcc"); # mode(__QI__) stuff
addTest("scott-nolink/brlock $gcc");
addTest("scott/regparm0 $gcc"); # this works, unfortunately... but the bug has been fixed in CIL
addBadComment("scott/regparm0", "Notbug. Some gcc versions fail to compile this test on i386");
addTest("scott/unscomp"); # kernel/fs/buffer.c
addTest("scott/thing");
# current problematic test cases
addTest("mergeinline");
addTest("scott/uninit_tmp");
addTest("combine_samefn");
addBadComment("combine_samefn", "Bug. Outstanding since 1.3.6 at least");
addTest("combine_node_alloc");
addBadComment("combine_node_alloc", "Bug. Outstanding since 1.3.6 at least");
addTest("combine_sbump");
addTest("combine_sbumpB");
addTest("combine_sbumpB MERGEINLINES=1");
addTest("combine_allocate");
addTest("combine_allocate MERGEINLINES=1");
addTest("combine_theFunc");
addTest("combine_theFunc MERGEINLINES=1");
addTest("combine_syserr");
addTest("combine_syserr MERGEINLINES=1");
addTest("combine_copyptrs WARNINGS_ARE_ERRORS=1");
addTest("combine_copyptrs WARNINGS_ARE_ERRORS=1 MERGEINLINES=1");
addTest("testrun/constfold EXTRAARGS=\"--domakeCFG --dopartial\"");
addBadComment("testrun/constfold", "Bug. Wrong constant folding. #2276515 on sourceforge.");
# tests of things implemented for EDG compatibility
addTest("mergestruct");
# Test for a merge bug in global variables initializations
addTest("mergeinit");
# a few things that should fail
addTest("test-bad/trivial-tb");
addTest("runall/runall_misc");
# simple test of combiner
addTest("comb $gcc");
# test combiner's ability to detect inconsistency
addTest("baddef");
# does not work: complains of many incompatible type redefinitions
#runTest $make apache/rewrite
addTest("test/init");
addTest("test/initial WARNINGS_ARE_ERRORS=1");
addTest("test/jmp_buf");
addTest("test/static");
# more random stuff
addTest("scott-nogcc/funcname $gcc");
addTest("scott/litstruct $gcc");
addTest("scott/main $gcc");
addTest("scott/globalprob $gcc");
addBadComment("scott/globalprob", "Notbug. Not a bug if fails on a non-Linux machine ;-)");
addTest("scott/bisonerror $gcc");
addTest("scott/cmpzero");
addTest("scott/kernel1 $gcc");
addTest("scott/kernel2 $gcc");
addTest("scott/xcheckers $gcc");
addTest("scott/memberofptr $gcc");
addTest("scott/invalredef $gcc");
addTest("scott/invalredef2 $gcc");
addTest("scott/errorinfn");
addTest("scott/unionassign");
addTest("scott/structattr");
addTest("scott/neg64");
addTest("testrun/arrayinitsize");
addTest("test-bad/enuminit2");
addTest("scott/volatilestruct");
addTest("scott/sizeofchar");
addTest("scott/initedextern");
addTest("scott/arrayinit");
addTest("runall/structattr2");
addTest("scott/structattr3");
addTest("scott/enumerator_sizeof");
addTest("testrun/decl_mix_stmt");
addTest("scott/enumattr");
addTest("runall/alpha");
addTest("testrun/blockattr2 USECFG=1");
addTest("testrun/extinline2");
addTest("test/extinline3");
addTest("testrun/bool");
addTest("testrun/var_named_hidden");
addTest("testrun/macro_hidden");
addTest("testrun/booleanOp USE_LOGICAL_OPERATORS=1");
addTest("test/va_arg_pack");
addTest("testrun/compound1");
addBadComment("testrun/compound1", "Notbug. Undefined behavior (probably).");
addTest("testrun/compound2");
addTest("testrun/large_unsigned_long");
addTest("test/shell-escape SHELL_ESCAPE=1");
# c99 readiness tests
addTest("testrunc99/c99-bool");
addTest("testrunc99/c99-predefined");
addTest("testrunc99/c99-struct");
addTest("testrunc99/c99-complex");
addTest("testrunc99/c99-universal-character-names");
addBadComment("testrunc99/c99-universal-character-names", "Universal character names are not yet supported");
addTest("testrunc99/c99-tgmath");
addTest("testrunc99/c99-float-pragma");
addTest("combinec99inline");
addBadComment("combinec99inline", "C99 inline semantic not fully supported.");
addTest("testrunc11/c11-generic");
addTest("testrunc11/c11-caserange");
addTest("testrunc11/c11-noreturn");
addTest("testrunc11/gcc-c11-generic-1");
# TODO: these messages are not even checked?
addTestFail("testc11/gcc-c11-generic-2-1", "Multiple defaults in generic");
# addTestFail("testc11/gcc-c11-generic-2-2", "TODO");
# addTestFail("testc11/gcc-c11-generic-2-3", "TODO");
# addTestFail("testc11/gcc-c11-generic-2-4", "TODO");
# addTestFail("testc11/gcc-c11-generic-2-5", "TODO");
# addTestFail("testc11/gcc-c11-generic-2-6", "TODO");
addTestFail("testc11/gcc-c11-generic-2-7", "No compatible associations or default in generic");
addTest("testc11/gcc-c11-generic-3-1");
addTestFail("testc11/gcc-c11-generic-3-2", "No compatible associations or default in generic");
addTestFail("testc11/gcc-c11-generic-3-3", "No compatible associations or default in generic");
addTestFail("testc11/gcc-c11-generic-3-4", "No compatible associations or default in generic");
addTestFail("testc11/clang-c11-generic-1-1", "Multiple compatible associations in generic");
addTestFail("testc11/clang-c11-generic-1-2", "No compatible associations or default in generic");
addTest("testc11/clang-c11-generic-2");
# ---------------- c-torture -------------
## if we have the c-torture tests add them
## But only if the ctorture group was specfied
my $ctorture = '/usr/local/src/gcc/gcc/testsuite/gcc.c-torture';
if(-d $ctorture &&
defined $TEST->{option}->{group} &&
grep { $_ eq 'ctorture'} @{$TEST->{option}->{group}}) {
# Omit some tests because they use __complex__
my @omit = ('compile/20000804-1', 'compile/20001222-1', 'compile/941019-1',
'compile/981223-1', 'compile/991213-1', 'compile/20010605-2',
'compile/960512-1', 'compile/complex-1',
'compile/complex-2', 'compile/complex-4',
'compile/complex-5', 'execute/complex-2', 'execute/complex-5',
'execute/960512-1', 'execute/complex-4',
'execute/complex-1', 'execute/20010605-2');
# Also omit those with inner functions
push @omit,
('compile/951116-1', 'compile/920415-1',
'execute/920415-1', 'compile/20010605-1',
'execute/20010605-1', 'compile/20011023-1',
'compile/20010903-2', 'execute/comp-goto-2', 'execute/nestfunc-2',
'execute/921215-1', 'execute/920428-2', 'execute/921017-1',
'execute/nest-stdar-1', 'execute/nestfunc-3', 'execute/920501-7',
'execute/920721-4', 'execute/920612-2', 'execute/20010209',
'execute/931002-1', 'execute/nestfunc-1', 'execute/20000822-1',
'compile/930506-2', 'execute/20010209-1');
# Read the compile tests
my @tortures;
foreach my $tortdir ('compile', 'execute', 'compat') {
@tortures =
map { $_ =~ m|$ctorture/$tortdir/(.+)\.c|; $1 }
(glob "$ctorture/$tortdir/*.c");
# Remove those that were produced in previous runs
@tortures = grep { $_ !~ m|cil$| } @tortures;
# Remove those that we know should fail
@tortures = grep { my $t = "$tortdir/$_";
! grep { $_ =~ m|$t|} @omit } @tortures;
foreach my $tst (@tortures) {
addTest("tort/$tortdir/$tst _GNUCC=1");
$TEST->addGroups("tort/$tortdir/$tst", 'ctorture');
}
}
}
## We add here a mechanism for adding new tests
if(defined $ENV{CILEXTRATESTS}) {
require $ENV{CILEXTRATESTS};
}
# print Dumper($TEST);
# Now invoke it
$TEST->doit();
# print Dumper($TEST);
exit(0);
###
###
###
### Specialize RegTest
###
package CilRegTest;
use strict;
# use Data::Dumper;
BEGIN {
use RegTest;
@CilRegTest::ISA = qw(RegTest); # Inherit from RegTest
}
# The constructor
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my $self = $class->SUPER::new(@_);
return $self;
}
# Special command line options
sub extraOptions {
my($self) = @_;
my @supopt = $self->SUPER::extraOptions();
return (
@supopt,
"--cildebug!",
"--noremake!",
);
}
sub extraHelpMessage {
my($self) = @_;
my ($scriptname, $extra) = $self->SUPER::extraHelpMessage();
return ("testcil",
$extra . << "EOF");
Additional arguments for SafeC test harness
--cildebug Use the debug versions of everything (default is false)
--noremake Does not try to remake the executable before each test.
(so that you can modify the sources while the test
is running)
Default log file is safec.log
EOF
}
sub errorHeading {
my($self, $err) = @_;
return "Not executed" if $err == -1;
return "Success" if $err == 0;
return "Preprocessor error" if $err == 1000;
return "Parse error" if $err == 1001;
return "Cabs2cil error" if $err == 1002;
return "Compilation error" if $err == 1007;
return "Execution error" if $err == 1008;
return $self->SUPER::errorHeading($err);
}
sub startParsingLog {
my($self, $tst) = @_;
$tst->{instage} = 1000;
$tst->{ErrorCode} = 0;
}
sub availableParameters {
my($self) = @_;
return %::availpars;
}
# given the current options configuration, return a string of
# additional 'make' arguments to append to test commands
sub testCommandExtras {
my ($self, $extraargs) = @_;
# (sm: pulled this out of addTests so I could write my own addTests)
my $theargs = " $extraargs ";
if(defined $self->{option}->{noremake}) {
$theargs .= " NOREMAKE=1";
}
# Turn on the verbose flag
$theargs .= " STATS=1 PRINTSTAGES=1 ";
# Turn on the strings
# $theargs .= " EXTRAARGS=--useStrings ";
return $theargs;
}
# ensure uniqueness of names (I don't like using these names to
# name tests.. regrtest used numbers.. oh well)
sub uniqueName {
my ($self, $name) = @_;
if (!$self->testExists($name)) {
return $name; # already unique
}
else {
my $ct = 2;
while ($self->testExists($name . $ct)) {
$ct++;
}
return $name . $ct;
}
}
1;