root/trunk/tsuite/auto/checkall.pl

Revision 2473, 6.2 kB (checked in by rporter, 5 weeks ago)

trunk/tsuite/auto/checkall.pl - nothing was written to crashed.txt (it was just opened and closed). Now write "*.out: crashed". These lines will appear in both serious.txt and crashed.txt. And, yes, I realize an easy-peasy grep could have done this as well.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1#!/usr/bin/perl -w
2#
3# this script looks for problems in the Cloudy test suite
4# it looks for botched asserts, warnings and for simulations that did not end.
5# all serious errors will be reported in serious.txt
6# all lines with PROBLEM will be in minor.txt
7# sims that are close to an assert (but OK) are in close.txt
8# those with DEBUG print statements or TestCode calls are in debug.txt
9#
10# execute this script from within the directory where the
11# *.out files live.  The command is:
12# perl checkall.pl
13#
14
15# this was produced by the optimizers and is not really part of the test suite
16# its presence will fool this script....
17if( -r "optimal.in" )
18{
19    unlink "optimal.in";
20}
21
22print( "\nThis script checks for problems in the output from the Cloudy test suite.\n");
23print( "  It checks for three things in the simulations:\n");
24print( "  1) Botched asserts or warnings:  These are serious problems.\n");
25print( "  2) Whether the PROBLEM or DEBUG string were printed.\n");
26print( "  3) Crashes, in which the code did not end - these are also serious problems.\n");
27
28$nMod = 0;
29$nOK = 0;
30$nSkip = 0;
31$nFail = 0;
32$nCrash = 0;
33$nBotch = 0;
34$nWarn = 0;
35
36open( CRASHED, ">crashed.txt" );
37open( SERIOUS, ">serious.txt" );
38open( BOTCH, ">serious.asr" );
39open( MINOR, ">minor.txt" );
40open( CLOSE, ">close.txt" );
41open( DEBUG, ">debug.txt" );
42open( SKIP, ">skip.txt" );
43
44# loop over all input scripts
45while( defined( $input = glob("*.in") ) )
46{
47    # count the number of simulations
48    ++$nMod;
49
50    # form name of output file
51    $output = $input;
52    $output =~ s/\.in/\.out/gi;
53
54    if( -r $output )
55    {
56        $checkEnd = 0;
57        $nWarnMessage = 0;
58        $lgCrash = 0;
59        $lgFailure = 0;
60        $lgBotch = 0;
61        $lgAtmosNotFound = 0;
62        open( OUTP, $output );
63        while( <OUTP> )
64        {
65# find "DISASTER", "Botched" and "W-" strings in all the output files and write
66# corresponding line into serious.txt file.
67            if( /DISASTER/ || /Botched/ || /W-/ )
68            {
69                print SERIOUS "$output: $_";
70                if( /W-/ )
71                {
72                    ++$nWarnMessage;
73                }
74            }
75            if( /botch/ )
76            {
77                print BOTCH "$output: $_";
78                $lgBotch = 1;
79            }
80# now look for string PROBLEM, which indicates an internal problem
81# during the calculation - this is not a serious problem
82            if( /PROBLEM/ && ! /DISASTER/ )
83            {
84                print MINOR "$output: $_";
85            }
86            if( /ChkAssert ----/ )
87            {
88                print CLOSE "$output: $_";
89            }
90            if( /DEBUG/ || /Test code/ )
91            {
92                print DEBUG "$output: $_";
93            }
94# check output files to see whether they contain any assert output
95# also determine if the program crashed. 
96            if( /ChkAssert/ || /Cloudy exited OK\]/ || /something went wrong\]/ )
97            {
98                ++$checkEnd;
99            }
100            if( /something bad has happened./ )
101            {
102                $lgCrash = 1;
103            }
104# this is the last line, so lgBotch and nWarnMessage are already determined.
105            if( /something went wrong\]/ && !$lgBotch && $nWarnMessage == 0 )
106            {
107                $lgFailure = 1;
108            }
109            if( /Error: stellar atmosphere file not found./ )
110            {
111                $lgAtmosNotFound = 1;
112            }
113        }
114        close( OUTP );
115        if( $lgAtmosNotFound )
116        {
117            ++$nSkip;
118            print SKIP "$input: stellar atmosphere file is not installed\n";
119        }
120        elsif( $checkEnd == 0 || $lgCrash )
121        {
122            ++$nCrash;
123            print SERIOUS "$output: crashed\n";
124            print CRASHED "$output: crashed\n";
125            $lgSeriousProblems = 1;
126        }
127        elsif( $lgFailure )
128        {
129            ++$nFail;
130            print SERIOUS "$output: returned with FAILURE status\n";
131            $lgSeriousProblems = 1;
132        }
133        elsif( $nWarnMessage > 0 )
134        {
135            ++$nWarn;
136        }
137        elsif( $lgBotch )
138        {
139            ++$nBotch;
140        }
141        else
142        {
143            ++$nOK;
144        }
145    }
146    else
147    {
148        ++$nSkip;
149        print SKIP "$input: no corresponding output was found\n";
150    }
151}
152
153close( CRASHED );
154close( SERIOUS );
155close( BOTCH );
156close( MINOR );
157close( CLOSE );
158close( DEBUG );
159close( SKIP );
160
161if( $nMod != $nOK+$nSkip+$nCrash+$nFail+$nWarn+$nBotch )
162{
163    print STDERR "\nINTERNAL ERROR: the number of sims don't add up!!!!!\n\n";
164}
165
166print( "\nLooking for crashes, botched results and warnings:");
167# if this file has non-zero length, we detected a problem
168if( -s "serious.txt" )
169{
170    print "\nWARNING! crashes, failures, botches or warnings were found. This is a serious problem.\n";
171    if( $nCrash > 0 )
172    {
173        print "Cloudy crashed in $nCrash sims.\n";
174    }
175    print "Check the file serious.txt for names, serious.asr for botched asserts.\n";
176    system "grep Cloudy < serious.txt";
177    $lgSeriousProblems = 1;
178}
179else
180{
181    print " good, none found.\n";
182    $lgSeriousProblems = 0;
183}
184
185print( "\nLooking for PROBLEM string in the output files:");
186if( -s "minor.txt" )
187{
188    print "\nPROBLEM string was found.  Check minor.txt for a list of names.\n";     
189    print "This can occur a few times and is not a serious concern.\n";     
190    $lgMinorProblems = 1;
191}
192else
193{
194    print " good, none found.\n";
195    $lgMinorProblems = 0;
196}
197
198if( -s "close.txt" )
199{
200    print "\nSome sims are close to an assert.  Check close.txt for a list of names.\n";     
201    print "This is for information only, not a problem.\n";     
202}
203
204print( "\nLooking for DEBUG string or TestCode call:");
205if( -s "debug.txt" )
206{
207    print "\nDEBUG string or TestCode calls were found.  Check debug.txt for names.\n";     
208    $lgDebugPrint = 1;
209}
210else
211{
212    print " good, none found.\n";
213    $lgDebugPrint = 0;
214}
215   
216# check whether any sims were skipped
217print "\nLooking for skipped sims:";
218if( $nSkip > 0 )
219{
220    print " $nSkip sims were skipped - a list is in skip.txt\n" ;
221}
222else
223{
224    print " good: no sims were skipped.\n";
225}
226
227printf( "\n%i sims are present", $nMod );
228if( $nSkip > 0 )
229{
230    printf( ", %i were skipped", $nSkip );
231}
232if( $nCrash > 0 )
233{
234    printf( ", %i crashed", $nCrash );
235}
236if( $nFail > 0 )
237{
238    printf( ", %i failed", $nFail );
239}
240if( $nWarn > 0 )
241{
242    printf( ", %i have warnings", $nWarn );
243}
244if( $nBotch > 0 )
245{
246    printf( ", %i botched", $nBotch );
247}
248if( $nOK > 0 )
249{
250    printf( ", %i are OK", $nOK );
251}
252print ".\n";
253
254if( $lgMinorProblems )
255{
256    print "Minor problems were found, this is normal, list is in minor.txt\n";
257}
258
259if( $lgDebugPrint )
260{
261    print "DEBUG prints or TestCode calls were found, list is in debug.txt\n";
262}
263
264if( $lgSeriousProblems )
265{
266    print "Serious problems were found. See serious.txt for a summary\n";
267}
268else
269{
270    if( $nOK > 0 )
271    {
272        print "The test suite was successful; you have a valid executable.\n";
273    }
274}
Note: See TracBrowser for help on using the browser.