Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perlmod / regreport,1.64.2
CommitLineData
86530b38
AT
1#!/usr/bin/perl
2
3use IO::Handle;
4use Getopt::Long;
5
6BEGIN {chomp ($root = `configsrch Regreport /`);}
7use lib "$ENV{'DV_ROOT'}/tools/perlmod/Regreport/".$root;
8
9use Regreport;
10
11use strict;
12
13my($PROG) = ($0=~ m%([^/]+)$%); # regreport real name
14
15# an initial sanity check.
16#-------------------------
17if(!(defined $ARGV[0])) {die " No arguments specified... please try regreport -h\n"; }
18
19# A cute way to parse the command line. (legacy stuff)
20# This assigns a variable directly from command line ..
21#=================================================================
22eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_]+=)(.*)/ && shift;
23
24my %opt = ();
25my @Options = qw(debug cut_name! sas_only regenerate regress
26 ver 1 h clean_pass fails_only sim=s);
27$opt{debug} = 0;
28$opt{sas_only} = 0;
29$opt{cut_name} = 1;
30$opt{regenerate}= 0;
31$opt{regress} = 0;
32$opt{clean_pass}= 0;
33$opt{fails_only}= 0;
34$opt{ver} = 0;
35$opt{h} = 0;
36$opt{'1'} = 0;
37$opt{sim}="vcs";
38
39GetOptions(\%opt, @Options) or die "Error in arguments!\n";
40$debug = $opt{debug};
41$sas_only = $opt{sas_only};
42$cut_name = $opt{cut_name};
43$clean_pass = $opt{clean_pass};
44$fails_only = $opt{fails_only} || defined ($ENV{REGREPORT_FAILS_ONLY}) ;
45$sim = $opt{sim};
46my $regenerate = $opt{regenerate};
47my $regress = $opt{regress};
48my $ver = $opt{ver};
49my $single = $opt{'1'};
50my $h = $opt{h};
51
52if($h){
53 &usage();
54 exit 0;
55}elsif($ver) {
56 print "You are running: $PROG\n";
57 exit 0;
58}elsif($regenerate){
59 &regenerate();
60 exit 0;
61}elsif($regress) {
62 if((defined $ARGV[0]) && (defined $ARGV[1]) && (-d $ARGV[1])){
63 if (defined ($ENV{CLEAN_PASS})) {
64 $clean_pass = 1;
65 }
66 my $status = wait_regression($ARGV[0], $ARGV[1]);
67 if (!defined ($ENV{REGRESS_MAIL}) ||
68 defined ($ENV{REGRESS_MAIL}) && ($ENV{REGRESS_MAIL} !~ /^no$/i)) {
69 my $mailto = $ENV{USER};
70 $mailto = $mailto.",$ENV{REGRESS_MAIL}" if (defined ($ENV{REGRESS_MAIL}));
71 my $finish = "Completed";
72 if ($status) {
73 $finish = "Incomplete"
74 }
75 my $subject = "'$finish Regression results for $ARGV[1]'";
76 system ("/bin/mailx -s $subject $mailto < $ARGV[0] ");
77 }
78 exit 0;
79 }
80 else{
81 die " -regress options are not correct. Needs file_name, dir_name, try regreport -h\n";
82 }
83}elsif($single) { #1 diag report
84 $rsfh = \*STDOUT;
85 if(defined $ARGV[0]) { &chk_single_diag($ARGV[0]); }
86 else { &chk_single_diag("."); }
87 exit 0;
88}
89
90if((defined $ARGV[0]) && (-d $ARGV[0])) { #regression directory
91 open (STDOUT, "| tee regreport.log") or
92 die "DIE. Could not open regreport.log for stdout" ;
93 $rsfh = \*STDOUT;
94 my$total = 1; my $pass = 0;
95 $total=(regress_stat(0, @ARGV))[0];
96 $pass=(regress_stat(0, @ARGV))[1];
97 print STDERR "\n";
98 STDERR->autoflush(1);
99 STDOUT->autoflush(1);
100 &cutitup;
101
102 if ($clean_pass && ($total == $pass)) {
103 printf STDOUT "Cleaning Run Directories in $ARGV[0]..\n";
104 opendir (DIR, "$ARGV[0]");
105 foreach (grep(!/^\.+$/,readdir DIR)) {
106 system ("rm -rf $ARGV[0]/$_") if (-d "$ARGV[0]/$_");
107 }
108 close DIR;
109 }
110
111 STDERR->autoflush(1);
112 STDOUT->autoflush(1);
113
114}else{
115 print STDERR "Something went wrong. Probably cannot chdir.Try regreport -h \n";
116 exit 1;
117}
118
119
120
121#=========================================================================
122
123sub usage {
124 print <<EOH;
125---------------------------------------------------------------------------
126Usage: regreport <options> [<directory> [<list>]]
127
128OPTIONS
129 -1 [<regress_dir>]:
130 print report for the specified or current-directory diag; [regress dir].
131
132 -regress <output_file> <directory>:
133 in regression mode, regreport writes summary status for finished
134 diags to a file until all diags are finished. NOTE: if
135 some diag does not produce status, $PROG will wait forever.
136
137 -ver
138 print version number and exit.
139
140 -sas_only
141 sims.log will not be parsed, only sas.log will get parsed.
142
143 -[no]cut_name
144 cuts the name from a sss:sss:sss:ddd formatted name. Default is to cut.
145
146 -regenerate
147 will regenerate the status.log files in the diag directories.
148
149 -clean_pass
150 will clean up passing directories.
151
152 -fails_only
153 will show details for fails only
154
155 <directory> [<list>]
156 print report for all diags under <directory>. <list> is
157 0 or more of simulation 'system' names, such as
158 'spc2', 'cmp', 'cmp1', 'cmp8', etc. When nothing
159 specified, all systems are included.
160
161ENVIRONMENT VARIABLES:
162
163 CLEAN_PASS : Clean passing dirs
164 REGRESS_MAIL : Set to comma seperated list. Default is to send user
165 email when run in regress mode. When set to "no"
166 sends no email at all.
167 REGREPORT_FAILS_ONLY : Show details for fails only.
168
169Function:
170 Examine all regression .log files for diags under
171 regression directory
172 and print reports. The most common use is
173
174 $0 <regress_dir>
175---------------------------------------------------------------------------
176EOH
177}
178