Debian Codegraph @

tests/test.pl

raw
1 #! /usr/bin/perl
2 #
3 # Regression test for the 'fort77' driver script.
4 #
5
6 #
7 # List of tests to run and of expected files.
8 #
9
10 $test = [
11 [ "../fort77 -c foo.f", qw(foo.o) ],
12 # [ "../fort77 -c bar.F", qw(bar.o) ],
13 [ "../fort77 -c -o gargle.o foo.f", qw(gargle.o) ],
14 [ "../fort77 foo.f", qw(a.out) ],
15 [ "../fort77 baz/bazfoo.f", qw(a.out) ],
16 [ "../fort77 -c baz/bazfoo.f", qw(bazfoo.o) ],
17 [ "../fort77 -o bar.o -c baz/bazfoo.f", qw(bar.o) ],
18 [ "../fort77 -o tscht foo.f", qw(tscht) ],
19 [ "../fort77 -k foo.f", qw(a.out foo.c) ],
20 [ "../fort77 -g -k foo.f", qw(foo.c a.out) ],
21 [ "../fort77 -c -f long.f", qw(long.o) ],
22 # [ "../fort77 mainmiss.f" ],
23 [ "../fort77 -c foo.f && ../fort77 -c mainmiss.f && ../fort77 -o foo foo.o mainmiss.o",
24 qw(foo.o mainmiss.o foo) ],
25 [ "../fort77 -c foo.f && ../fort77 -o foo foo.o mainmiss.f",
26 qw(foo.o foo) ],
27 [ "../fort77 synerr.f && touch gna" ],
28 [ "../fort77 ishift.f", qw(a.out) ],
29 [ "if test ! -d subtest; then mkdir subtest; fi && cd subtest && ../../fort77 -g -c -o fooinclude.o -I ../ ../fooinclude.f", qw(subtest/fooinclude.o) ]
30 ];
31
32 #
33 # These files could possibly be generated by a buggy fort77
34 # script; they are also checked.
35 #
36
37 @unexpected = qw(gargle.c baz/bazfoo.c baz/bazfoo.o mainmiss.o mainmiss.c
38 synerr.o synerr.c baz/a.out bar.c gna ishift.c);
39
40 foreach $ref (@$test) {
41 foreach $file(@$ref[1..@$ref-1]) {
42 $files{$file} ++;
43 }
44 }
45
46 foreach $file(@unexpected) {
47 $files{$file} ++;
48 }
49
50 while ($_ = @ARGV[0]) {
51 shift;
52 if (/^-v/) {
53 $verbose ++;
54 }
55 }
56
57 foreach (keys %files) {
58 unlink $_;
59 }
60
61 $errors = 0;
62 foreach $ref (@$test) {
63
64 $cmd = shift(@$ref);
65 %expect = ();
66 $cmd_error = 0;
67
68 foreach $r (@$ref) {
69 $expect{$r} ++;
70 }
71
72 print STDERR "$cmd ..." if $verbose > 0;
73 $cmd = "( $cmd ) >/dev/null 2>&1" if $verbose <= 1;
74
75 system($cmd);
76
77 foreach (keys %files) {
78 -f $_;
79 if ($expect{$_}) {
80 if (-f) {
81 print STDERR " \"$_\" ok " if $verbose > 2;
82 }
83 else {
84 print STDERR "\"$_\" not generated by \"$cmd\"\n";
85 $errors ++;
86 $error_seen ++;
87 }
88 }
89 else {
90 if (-f) {
91 print STDERR " \"$_\" should not be generated by \"$cmd\"\n";
92 $errors ++;
93 $error_seen ++;
94 }
95 else {
96 print STDERR " \"$_\" n-ok " if $verbose > 3;
97 }
98 }
99 if (-f) {
100 unlink $_ or die ("Could not unlink $_: $!\n");
101 }
102 }
103 print STDERR " test successful.\n" if $verbose && ! $error_seen;
104 }
105
106 if ($errors == 0) {
107 print STDERR "Passed all tests.\n" if $verbose;
108 exit 0;
109 }
110 else {
111 print STDERR "Total $errors error(s) encountered.\n";
112 exit 1;
113 }