summaryrefslogtreecommitdiff
path: root/compare_dg_tests.pl
blob: cc45605323e0f45c6b3da3ce20bec9556aaad6cd (plain)
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
#!/usr/bin/env perl
use strict;
use warnings;

use File::Glob;
use Getopt::Long;
use Term::ANSIColor qw(:constants);
use File::Basename;
use Cwd;

my $app = $0;

sub read_sum($);
sub read_unstable($);
sub dump_result($);
sub compare_results($$);
sub usage();
sub print_compare_results_summary($$);
sub nothing($$$$);

# OK
my $STILL_PASSES          = "Still passes              [PASS => PASS]";
my $STILL_FAILS           = "Still fails               [FAIL => FAIL]";
my $STILL_XPASS           = "Still xpass               [XPASS=>XPASS]";
my $STILL_XFAIL           = "Still xfail               [XFAIL=>XFAIL]";

# TO BE CHECKED
my $PASS_NOW_XFAIL        = "PASS now XFAIL            [PASS =>XFAIL]";
my $XFAIL_APPEARS         = "XFAIL appears             [     =>XFAIL]";
my $FAIL_NOW_XFAIL        = "FAIL now XFAIL            [FAIL =>XFAIL]";
my $XPASS_NOW_XFAIL       = "XPASS now XFAIL           [XPASS=>XFAIL]";
my $PASSED_NOW_TIMEOUTS   = "Timeout                   [PASS =>T.OUT]";
my $FAIL_DISAPPEARS	  = "FAIL disappears           [FAIL =>     ]";
my $XPASS_NOW_PASSES      = "XPASS now PASS            [XPASS=> PASS]";
my $XFAIL_NOW_PASSES      = "XFAIL now PASS            [XFAIL=> PASS]";
my $XFAIL_NOW_XPASS       = "XFAIL now XPASS           [XFAIL=>XPASS]";
my $FAIL_NOW_PASSES       = "FAIL now PASS             [FAIL => PASS]";
my $FAIL_NOW_XPASS        = "FAIL now XPASS            [FAIL =>XPASS]";
my $NEW_PASSES		  = "New PASS                  [     => PASS]";
my $UNHANDLED_CASES	  = "Unhandled cases           [   ..??..   ]";
my $UNSTABLE_CASES	  = "Unstable cases, ignored   [~RANDOM     ]";
my $UNSUPPORTED_XPASS     = "UNSUPPORTED now XPASS     [UNSUP=>XPASS]";
my $UNSUPPORTED_XFAIL     = "UNSUPPORTED now XFAIL     [UNSUP=>XFAIL]";
my $UNSUPPORTED_DISAPPEARS= "UNSUPPORTED disappears    [UNSUP=>     ]";
my $UNTESTED_PASS         = "UNTESTED now PASS         [UNTES=> PASS]";
my $UNTESTED_XFAIL        = "UNTESTED now XFAIL        [UNTES=>XFAIL]";
my $UNTESTED_DISAPPEARS   = "UNTESTED disappears       [UNTES=>     ]";
my $UNRESOLVED_PASS       = "UNRESOLVED now PASS       [UNRES=> PASS]";
my $UNRESOLVED_XFAIL      = "UNRESOLVED now XFAIL      [UNRES=>XFAIL]";
my $UNRESOLVED_DISAPPEARS = "UNRESOLVED disappears     [UNRES=>     ]";

# REGRESSIONS
my $PASS_NOW_XPASS        = "PASS now XPASS            [PASS =>XPASS]";
my $PASSED_NOW_FAILS      = "PASS now FAIL             [PASS => FAIL]";
my $PASS_DISAPPEARS       = "PASS disappears           [PASS =>     ]";
my $XPASS_DISAPPEARS      = "XPASS disappears          [XPASS=>     ]";
my $FAIL_APPEARS          = "FAIL appears              [     => FAIL]";
my $XPASS_APPEARS         = "XPASS appears             [     =>XPASS]";
my $XPASS_NOW_FAIL        = "XPASS now FAIL            [XPASS=> FAIL]";
my $XFAIL_NOW_FAIL        = "XFAIL now FAIL            [XFAIL=> FAIL]";
my $XFAIL_DISAPPEARS	  = "XFAIL disappears          [XFAIL=>     ]";

my $UNSUPPORTED_PASS      = "UNSUPPORTED now PASS      [UNSUP=> PASS]";
my $UNSUPPORTED_FAIL      = "UNSUPPORTED now FAIL      [UNSUP=> FAIL]";
my $UNTESTED_FAIL         = "UNTESTED now FAIL         [UNTES=> FAIL]";
my $UNTESTED_XPASS        = "UNTESTED now XPASS        [UNTES=>XPASS]";
my $UNRESOLVED_FAIL       = "UNRESOLVED now FAIL       [UNRES=> FAIL]";
my $UNRESOLVED_XPASS      = "UNRESOLVED now XPASS      [UNRES=>XPASS]";

my @handler_list = (
  {was=>"PASS",     is=>"PASS",     cat=>$STILL_PASSES},
  {was=>"PASS",     is=>"XPASS",    cat=>$PASS_NOW_XPASS},
  {was=>"XPASS",    is=>"PASS",     cat=>$XPASS_NOW_PASSES},
  {was=>"XPASS",    is=>"XPASS",    cat=>$STILL_XPASS},
  {was=>"FAIL",     is=>"FAIL",     cat=>$STILL_FAILS},
  {was=>"FAIL",     is=>"XFAIL",    cat=>$FAIL_NOW_XFAIL},
  {was=>"XFAIL",    is=>"FAIL",     cat=>$XFAIL_NOW_FAIL},
  {was=>"XFAIL",    is=>"XFAIL",    cat=>$STILL_XFAIL},

  {was=>"XPASS",    is=>"XFAIL",    cat=>$XPASS_NOW_XFAIL},
  {was=>"PASS",     is=>"XFAIL",    cat=>$PASS_NOW_XFAIL},
  {was=>"FAIL",     is=>"NO_EXIST", cat=>$FAIL_DISAPPEARS},
  {was=>"XFAIL",    is=>"NO_EXIST", cat=>$XFAIL_DISAPPEARS},
  {was=>"XFAIL",    is=>"PASS",     cat=>$XFAIL_NOW_PASSES},
  {was=>"XFAIL",    is=>"XPASS",    cat=>$XFAIL_NOW_XPASS},
  {was=>"FAIL",     is=>"PASS",     cat=>$FAIL_NOW_PASSES},
  {was=>"FAIL",     is=>"XPASS",    cat=>$FAIL_NOW_XPASS},
  {was=>"NO_EXIST", is=>"PASS",     cat=>$NEW_PASSES},
  {was=>"NO_EXIST", is=>"XPASS",    cat=>$XPASS_APPEARS},

  {was=>"PASS",     is=>"FAIL",     handler=>\&handle_pass_fail},
  {was=>"XPASS",    is=>"FAIL",     cat=>$XPASS_NOW_FAIL},
  {was=>"PASS",     is=>"NO_EXIST", cat=>$PASS_DISAPPEARS},
  {was=>"XPASS",    is=>"NO_EXIST", cat=>$XPASS_DISAPPEARS},
  {was=>"NO_EXIST", is=>"FAIL",     cat=>$FAIL_APPEARS},
  {was=>"NO_EXIST", is=>"XFAIL",    cat=>$XFAIL_APPEARS},

  {was=>"UNSUPPORTED", is=>"PASS", cat=>$UNSUPPORTED_PASS},
  {was=>"UNSUPPORTED", is=>"XPASS", cat=>$UNSUPPORTED_XPASS},
  {was=>"UNSUPPORTED", is=>"FAIL", cat=>$UNSUPPORTED_FAIL},
  {was=>"UNSUPPORTED", is=>"XFAIL", cat=>$UNSUPPORTED_XFAIL},
  {was=>"UNSUPPORTED", is=>"NO_EXIST", cat=>$UNSUPPORTED_DISAPPEARS},

  {was=>"UNTESTED", is=>"PASS", cat=>$UNTESTED_PASS},
  {was=>"UNTESTED", is=>"XPASS", cat=>$UNTESTED_XPASS},
  {was=>"UNTESTED", is=>"FAIL", cat=>$UNTESTED_FAIL},
  {was=>"UNTESTED", is=>"XFAIL", cat=>$UNTESTED_XFAIL},
  {was=>"UNTESTED", is=>"NO_EXIST", cat=>$UNTESTED_DISAPPEARS},

  {was=>"UNRESOLVED", is=>"PASS", cat=>$UNRESOLVED_PASS},
  {was=>"UNRESOLVED", is=>"XPASS", cat=>$UNRESOLVED_XPASS},
  {was=>"UNRESOLVED", is=>"FAIL", cat=>$UNRESOLVED_FAIL},
  {was=>"UNRESOLVED", is=>"XFAIL", cat=>$UNRESOLVED_XFAIL},
  {was=>"UNRESOLVED", is=>"NO_EXIST", cat=>$UNRESOLVED_DISAPPEARS},

#  {was=>"NO_EXIST", is=>"NO_EXIST", handler=>\&handle_not_yet_supported}
);

######################################################
# TREAT ARGUMENTS

my $verbose=0;
my $quiet=0;
my $long=0;
my $short=0;
my $debug=0;
my ($testroot, $basename);
my ($ref_file_name, $res_file_name);
my $nounstable=0;
my $unstablefile=0;
my @unstable_markers=();

GetOptions ("l"           => \$long,
            "s"           => \$short,
            "q"           => \$quiet,
            "v"           => \$verbose,
            "dbg"         => \$debug,
            "testroot=s"  => \$testroot,
            "basename=s"  => \$basename,
            "no-unstable"  => \$nounstable,
            "unstable-tests=s" => \$unstablefile,
            "unstable-marker=s"    => \@unstable_markers);

$ref_file_name = $ARGV[0] if ($#ARGV == 1);
$res_file_name = $ARGV[1] if ($#ARGV == 1);

$ref_file_name = $testroot."/expected_results/".$basename if ($testroot and $basename);
$res_file_name = $testroot."/testing/run/".$basename if ($testroot and $basename);
&usage if (not $ref_file_name or not $res_file_name);

my ($col_boldred, $col_red, $col_boldgreen, $col_green, $col_boldpink, $col_pink, $col_reset)
    = ("\033[31;1m","\033[31;3m","\033[32;1m","\033[32;3m","\033[35;1m","\033[35;2m","\033[0m");
($col_boldred, $col_red, $col_boldgreen, $col_green, $col_boldpink, $col_pink, $col_reset)
    = ("","","","","","","") if (not I_am_interactive());

######################################################
# MAIN PROGRAM
# print "comparing $ref_file_name $res_file_name\n";

# If none of the 2 .sum exists, nothing to compare: exit early.
exit 0 if ( (! -e $ref_file_name) && (! -e $res_file_name ));

my $ref = read_sum($ref_file_name) ;
my $res = read_sum($res_file_name) ;
my @unstablelist = ();

@unstablelist = read_unstable($unstablefile) if ($unstablefile ne 0);

compare_results($ref, $res);

my $final_result = print_compare_results_summary($ref, $res);

exit $final_result;

######################################################
# UTILITIES

sub empty_result()
{
   my %empty_result;# = {PASS=>0, FAIL=>0, XPASS=>0, XFAIL=>0, UNSUPPORTED=>0, UNTESTED=>0, UNRESOLVED=>0};
   $empty_result{PASS}=$empty_result{FAIL}=$empty_result{XPASS}=$empty_result{XFAIL}=0;
   $empty_result{UNSUPPORTED}=$empty_result{UNTESTED}=$empty_result{UNRESOLVED}=$empty_result{NO_EXIST}=0;
   return \%empty_result;
}
sub I_am_interactive {
  return -t STDIN && -t STDOUT;
}
sub usage()
{
	print "Usage : $app <ref_file.sum> <result_file.sum>\n";
	exit 1;
}


######################################################
# PARSING
sub read_sum($)
{
   my ($sum_file) = @_;
   my $res = empty_result();
   my %testcases;
   my %unsupported;
   $res->{testcases} = \%testcases;
   my $pending_timeout=0;

   $res->{EXEC}->{PASS} = 0;
   $res->{EXEC}->{FAIL} = 0;

   open SUMFILE, $sum_file or die $!;
   while (<SUMFILE>)
   {
	  if (m/^(PASS|XPASS|FAIL|XFAIL|UNSUPPORTED|UNTESTED|UNRESOLVED): (.*)/)
	  {
	  	my ($diag,$tc) = ($1,$2);
		my %tcresult;
		$tc =~ s/==[0-9]+== Shadow memory range interleaves with an existing memory mapping. ASan cannot proceed correctly./==<pid>== Shadow memory range interleaves with an existing memory mapping. ASan cannot proceed correctly./;
		$testcases{$tc} = empty_result() if (not exists $testcases{$tc});
		$testcases{$tc}->{$diag}++;
		$testcases{$tc}->{HAS_TIMED_OUT} = $pending_timeout;
		$pending_timeout = 0;
		$res->{$diag}++;
		# Count execution tests, for a sanity check
		if ($tc =~ /execution/)
		{
		    $res->{EXEC}->{$diag}++;
		}
	  }
	  elsif (m/WARNING: program timed out/) 
	  {
	  	$pending_timeout = 1;
	  }
	  elsif (m/^(# of expected passes|# of unexpected failures|# of expected failures|# of known failures|# of unsupported tests|# of untested testcases)\s+(.*)/)
	  {
	  	 $res->{"summary - "."$1"} = $2;
	  }
	  elsif (m/^\/.*\/([^\/]+)\s+version\s+(.*)/)
	  {
	  	 $res->{tool} = $1;
	  	 $res->{version} = $2;
		 $res->{version} =~ s/ [-(].*//;
	  }
   }
   close SUMFILE;
   return $res;
}

# Parse list on unstable tests
sub read_unstable($)
{
   my ($unstable_file) = @_;
   my @unstable_tests = ();

   open UNSTABLEFILE, $unstable_file or die $!;
   while (<UNSTABLEFILE>)
   {
       # Skip lines starting with '#', or with spaces only
       if ((/^#/) || (/^[ 	]*$/))
       {
       }
       else
       {
	   chomp;

	   my $test = $_;

	   # Check if line is of type: target:testname
	   if (/^(.*?):/)
	   {
	       foreach my $unstable_marker (@unstable_markers)
	       {
		   if ($unstable_marker eq $1) {
		       # If target matches the one supplied as script
		       # argument, add the testname to the list
		       $test =~ s/.*?://;
		       push @unstable_tests, $test;
		   }
	       }
	   } else {
	       push @unstable_tests, $test;
	   }
       }
   }
   close UNSTABLEFILE;
   return @unstable_tests;
}

######################################################
# DIFFING
sub handle_pass_fail($$$$)
{
   my ($ref, $res, $diag_diag, $tc) = @_;
   if ($res->{testcases}->{$tc}->{HAS_TIMED_OUT})
   {
     push @{$res->{$PASSED_NOW_TIMEOUTS}}, $tc;
   }
   else
   {
     push @{$res->{$PASSED_NOW_FAILS}}, $tc;
   }
}

sub compare_results($$)
{
   my ($ref, $res) = @_;

   @{$res->{$STILL_PASSES}} = ();
   @{$res->{$STILL_FAILS}} = ();
   @{$res->{$STILL_XPASS}} = ();
   @{$res->{$PASSED_NOW_FAILS}} = ();
   @{$res->{$XPASS_NOW_FAIL}} = ();
   @{$res->{$PASS_DISAPPEARS}} = ();
   @{$res->{$XPASS_DISAPPEARS}} = ();
   @{$res->{$FAIL_APPEARS}} = ();
   @{$res->{$XPASS_APPEARS}} = ();
   @{$res->{$NEW_PASSES}} = ();
   @{$res->{$FAIL_DISAPPEARS}} = ();
   @{$res->{$XFAIL_DISAPPEARS}} = ();
   @{$res->{$XFAIL_APPEARS}} = ();
   @{$res->{$FAIL_NOW_XFAIL}} = ();
   @{$res->{$PASS_NOW_XFAIL}} = ();
   @{$res->{$XPASS_NOW_XFAIL}} = ();
   @{$res->{$XPASS_APPEARS}} = ();
   @{$res->{$PASS_NOW_XPASS}} = ();
   @{$res->{$XPASS_NOW_PASSES}} = ();
   @{$res->{$XFAIL_NOW_PASSES}} = ();
   @{$res->{$XFAIL_NOW_XPASS}} = ();
   @{$res->{$XFAIL_NOW_FAIL}} = ();
   @{$res->{$FAIL_NOW_PASSES}} = ();
   @{$res->{$FAIL_NOW_XPASS}} = ();
   @{$res->{$PASSED_NOW_TIMEOUTS}} = ();
   @{$res->{$UNSUPPORTED_PASS}} = ();
   @{$res->{$UNSUPPORTED_XPASS}} = ();
   @{$res->{$UNSUPPORTED_FAIL}} = ();
   @{$res->{$UNSUPPORTED_XFAIL}} = ();
   @{$res->{$UNSUPPORTED_DISAPPEARS}} = ();
   @{$res->{$UNTESTED_PASS}} = ();
   @{$res->{$UNTESTED_XPASS}} = ();
   @{$res->{$UNTESTED_FAIL}} = ();
   @{$res->{$UNTESTED_XFAIL}} = ();
   @{$res->{$UNTESTED_DISAPPEARS}} = ();
   @{$res->{$UNRESOLVED_PASS}} = ();
   @{$res->{$UNRESOLVED_XPASS}} = ();
   @{$res->{$UNRESOLVED_FAIL}} = ();
   @{$res->{$UNRESOLVED_XFAIL}} = ();
   @{$res->{$UNRESOLVED_DISAPPEARS}} = ();
   @{$res->{$UNHANDLED_CASES}} = ();
   @{$res->{$UNSTABLE_CASES}} = ();

   #### MERGE REF AND RES
   foreach my $key (sort (keys %{$res->{testcases}}))
   {
		if (not exists $ref->{testcases}->{$key}) {
		   $ref->{testcases}->{$key} = empty_result();
		   $ref->{testcases}->{$key}->{NO_EXIST} = 1;
		}
   }
   foreach my $key (keys %{$ref->{testcases}})
   {
   		if (not exists $res->{testcases}->{$key})
		{
		   $res->{testcases}->{$key} = empty_result();
		   $res->{testcases}->{$key}->{NO_EXIST} = 1;
		}
   }

   #### ACTIONS FOR EACH CASES
   my %unstable_found;

   foreach my $key (sort (keys %{$ref->{testcases}}))
   {
       foreach my $diag_diag (@handler_list)
       {
	   if ($ref->{testcases}->{$key}->{$diag_diag->{was}} != $res->{testcases}->{$key}->{$diag_diag->{was}}
	       and $res->{testcases}->{$key}->{$diag_diag->{is}})
	   {
	       # If testcase is listed as 'unstable' mark it as
	       # such and skip other processing.
	       {
		   if (grep { (index $key,$_)!=-1} @unstablelist)
		   {
		       print "[unstable] $key\n" if ($debug);
		       $unstable_found{$key}=1;
		   }
		   else {
		       print "[$diag_diag->{was} => $diag_diag->{is}] $key\n" if ($debug);
		       if ($diag_diag->{handler})
		       {
			   $diag_diag->{handler} ($ref, $res, $diag_diag, $key);
		       }
		       else
		       {
			   push @{$res->{$diag_diag->{cat}}}, $key;
		       }
		   }
	       }
	   }
       }
   }
   push @{$res->{$UNSTABLE_CASES}}, (sort (keys (%unstable_found)))  if ($nounstable == 0);

}

######################################################
# PRINTING
sub print_tclist($@)
{
   my ($cat, @tclist) = @_;
   print "  - ".$cat.":\n\n  ". join("\n  ",@tclist) . "\n\n" if (scalar(@tclist));
}

sub print_compare_results_summary($$)
{
   my ($ref, $res) = @_;
   my $return_value=0;
   my $total_better = 0;
   my $rtotal = 0;
   my $quiet_reg = $quiet;
   my $ref_ratio = 0;
   my $res_ratio = 0;
   my $ratio_thresh = 0.95; # Warn if pass ratio is below this threshold
   my $ignore_exec = 0;
   my $ref_has_exec_tests = 0;
   my $res_has_exec_tests = 0;

   # Compute the pass ratio as a sanity check
   $ref_ratio = ($ref->{PASS} + $ref->{XFAIL}) /
       ($ref->{PASS} + $ref->{XFAIL}
	+ $ref->{XPASS} + $ref->{FAIL}
	+ $ref->{UNRESOLVED}
	+ $ref->{UNSUPPORTED}
	+ $ref->{UNTESTED});
   $res_ratio = ($res->{PASS} + $res->{XFAIL}) /
       ($res->{PASS} + $res->{XFAIL}
	+ $res->{XPASS} + $res->{FAIL}
	+ $res->{UNRESOLVED}
	+ $res->{UNSUPPORTED}
	+ $res->{UNTESTED});

   if (not $quiet)
   {
       printf "Comparing:\n";
       printf "REFERENCE:$ref_file_name\n";
       printf "CURRENT:  $res_file_name\n\n";
   }

   #### TESTS STATUS
   if (not $quiet and not $short)
   {
       printf "              `                              +---------+---------+\n";
       printf "o  RUN STATUS:                               |   REF   |   RES   |\n";
       printf "  +------------------------------------------+---------+---------+\n";
       printf "  | %-40s | %7d | %7d |\n", "Passes                            [PASS]", $ref->{PASS}, $res->{PASS};
       printf "  | %-40s | %7d | %7d |\n", "Unexpected fails                  [FAIL]", $ref->{FAIL}, $res->{FAIL};
       printf "  | %-40s | %7d | %7d |\n", "Unexpected passes                [XPASS]", $ref->{XPASS}, $res->{XPASS};
       printf "  | %-40s | %7d | %7d |\n", "Expected fails                   [XFAIL]", $ref->{XFAIL}, $res->{XFAIL};
       printf "  | %-40s | %7d | %7d |\n", "Unresolved                  [UNRESOLVED]", $ref->{UNRESOLVED}, $res->{UNRESOLVED};
       printf "  | %-40s | %7d | %7d |\n", "Unsupported                [UNSUPPORTED]", $ref->{UNSUPPORTED}, $res->{UNSUPPORTED};
       printf "  | %-40s | %7d | %7d |\n", "Untested                      [UNTESTED]", $ref->{UNTESTED}, $res->{UNTESTED};
       printf "  +------------------------------------------+---------+---------+\n";
       printf "\n";

       printf "    REF PASS ratio: %.2f\n", $ref_ratio;
       printf "    RES PASS ratio: %.2f\n", $res_ratio;
       if ($ref_ratio < $ratio_thresh)
       {
	   printf "    ***** ERROR: REF PASS ratio is abnormally low *****\n";
       }
       if ($res_ratio < $ratio_thresh)
       {
	   printf "    ***** ERROR: RES PASS ratio is abnormally low *****\n";
       }

       # If both PASS and FAIL EXEC tests are zero, assume there is no
       # execution test for this tool, and do not warn.
       $ref_has_exec_tests = ($ref->{EXEC}->{PASS} + $ref->{EXEC}->{FAIL}) != 0;
       if ($ref_has_exec_tests)
       {
	   printf "    ***** ERROR: No REF execution test PASSed. Check execution engine configuration. *****\n" if ($ref->{EXEC}->{PASS} == 0);
	   printf "    ***** WARNING: No REF execution test FAILed. Check execution engine configuration. *****\n" if ($ref->{EXEC}->{FAIL} == 0);
       }

       $res_has_exec_tests = ($res->{EXEC}->{PASS} + $res->{EXEC}->{FAIL}) != 0;
       if ($res_has_exec_tests)
       {
	   printf "    ***** ERROR: No RES execution test PASSed. Check execution engine configuration. *****\n" if ($res->{EXEC}->{PASS} == 0);
	   printf "    ***** WARNING: No RES execution test FAILed. Check execution engine configuration. *****\n" if ($res->{EXEC}->{FAIL} == 0);
       }

       # Ignore number of execution tests when computing the return
       # value, if both REF and RES have no execution test.
       $ignore_exec = !$ref_has_exec_tests && !$res_has_exec_tests;
   }

   #### REGRESSIONS ?
   $rtotal = scalar(@{$res->{$PASSED_NOW_FAILS}})
       +scalar(@{$res->{$XPASS_NOW_FAIL}})
       +scalar(@{$res->{$PASS_DISAPPEARS}})
       +scalar(@{$res->{$XPASS_DISAPPEARS}})
       +scalar(@{$res->{$FAIL_APPEARS}})
       +scalar(@{$res->{$XPASS_APPEARS}})
       +scalar(@{$res->{$PASS_NOW_XPASS}})
       +scalar(@{$res->{$XFAIL_NOW_FAIL}})
       +scalar(@{$res->{$XFAIL_DISAPPEARS}})
       +scalar(@{$res->{$UNSUPPORTED_FAIL}})
       +scalar(@{$res->{$UNSUPPORTED_XPASS}})
       +scalar(@{$res->{$UNTESTED_FAIL}})
       +scalar(@{$res->{$UNTESTED_XPASS}})
       +scalar(@{$res->{$UNRESOLVED_FAIL}})
       +scalar(@{$res->{$UNRESOLVED_XPASS}})
       +scalar(@{$res->{$PASSED_NOW_TIMEOUTS}});

   $quiet_reg=1 if ($short and not $rtotal);

   if (not $quiet_reg)
   {
       printf "\n$col_red"."o  REGRESSIONS:\n";
       printf "  +------------------------------------------+---------+\n";
       printf "  | %-40s | %7d |\n", $PASSED_NOW_FAILS, scalar(@{$res->{$PASSED_NOW_FAILS}}) if (scalar(@{$res->{$PASSED_NOW_FAILS}}));
       printf "  | %-40s | %7d |\n", $XPASS_NOW_FAIL, scalar(@{$res->{$XPASS_NOW_FAIL}}) if (scalar(@{$res->{$XPASS_NOW_FAIL}}));
       printf "  | %-40s | %7d |\n", $PASS_DISAPPEARS, scalar(@{$res->{$PASS_DISAPPEARS}}) if (scalar(@{$res->{$PASS_DISAPPEARS}}));
       printf "  | %-40s | %7d |\n", $XPASS_DISAPPEARS, scalar(@{$res->{$XPASS_DISAPPEARS}}) if (scalar(@{$res->{$XPASS_DISAPPEARS}}));
       printf "  | %-40s | %7d |\n", $FAIL_APPEARS, scalar(@{$res->{$FAIL_APPEARS}}) if (scalar(@{$res->{$FAIL_APPEARS}}));
       printf "  | %-40s | %7d |\n", $XPASS_APPEARS, scalar(@{$res->{$XPASS_APPEARS}}) if (scalar(@{$res->{$XPASS_APPEARS}}));
       printf "  | %-40s | %7d |\n", $PASS_NOW_XPASS, scalar(@{$res->{$PASS_NOW_XPASS}}) if (scalar(@{$res->{$PASS_NOW_XPASS}}));
       printf "  | %-40s | %7d |\n", $XFAIL_NOW_FAIL, scalar(@{$res->{$XFAIL_NOW_FAIL}}) if (scalar(@{$res->{$XFAIL_NOW_FAIL}}));
       printf "  | %-40s | %7d |\n", $XFAIL_DISAPPEARS, scalar(@{$res->{$XFAIL_DISAPPEARS}}) if (scalar(@{$res->{$XFAIL_DISAPPEARS}}));
       printf "  | %-40s | %7d |\n", $UNSUPPORTED_FAIL, scalar(@{$res->{$UNSUPPORTED_FAIL}}) if (scalar(@{$res->{$UNSUPPORTED_FAIL}}));
       printf "  | %-40s | %7d |\n", $UNSUPPORTED_XPASS, scalar(@{$res->{$UNSUPPORTED_XPASS}}) if (scalar(@{$res->{$UNSUPPORTED_XPASS}}));
       printf "  | %-40s | %7d |\n", $UNTESTED_FAIL, scalar(@{$res->{$UNTESTED_FAIL}}) if (scalar(@{$res->{$UNTESTED_FAIL}}));
       printf "  | %-40s | %7d |\n", $UNTESTED_XPASS, scalar(@{$res->{$UNTESTED_XPASS}}) if (scalar(@{$res->{$UNTESTED_XPASS}}));
       printf "  | %-40s | %7d |\n", $UNRESOLVED_FAIL, scalar(@{$res->{$UNRESOLVED_FAIL}}) if (scalar(@{$res->{$UNRESOLVED_FAIL}}));
       printf "  | %-40s | %7d |\n", $UNRESOLVED_XPASS, scalar(@{$res->{$UNRESOLVED_XPASS}}) if (scalar(@{$res->{$UNRESOLVED_XPASS}}));
       printf "  | %-40s | %7d |\n", $PASSED_NOW_TIMEOUTS, scalar(@{$res->{$PASSED_NOW_TIMEOUTS}}) if (scalar(@{$res->{$PASSED_NOW_TIMEOUTS}}));
       printf "  +------------------------------------------+---------+\n";
       printf "  | %-40s | %7d |\n", "TOTAL_REGRESSIONS", $rtotal;
       printf "  +------------------------------------------+---------+\n";
       printf "\n";

       if ($long)
       {
	      print_tclist($PASSED_NOW_FAILS, @{$res->{$PASSED_NOW_FAILS}});
	      print_tclist($XPASS_NOW_FAIL, @{$res->{$XPASS_NOW_FAIL}});
	      print_tclist($PASS_DISAPPEARS, @{$res->{$PASS_DISAPPEARS}});
	      print_tclist($XPASS_DISAPPEARS, @{$res->{$XPASS_DISAPPEARS}});
	      print_tclist($FAIL_APPEARS, @{$res->{$FAIL_APPEARS}});
	      print_tclist($XPASS_APPEARS, @{$res->{$XPASS_APPEARS}});
	      print_tclist($PASS_NOW_XPASS, @{$res->{$PASS_NOW_XPASS}});
	      print_tclist($XFAIL_NOW_FAIL, @{$res->{$XFAIL_NOW_FAIL}});
	      print_tclist($XFAIL_DISAPPEARS, @{$res->{$XFAIL_DISAPPEARS}});
	      print_tclist($UNSUPPORTED_FAIL, @{$res->{$UNSUPPORTED_FAIL}});
	      print_tclist($UNSUPPORTED_XPASS, @{$res->{$UNSUPPORTED_XPASS}});
	      print_tclist($UNTESTED_FAIL, @{$res->{$UNTESTED_FAIL}});
	      print_tclist($UNTESTED_XPASS, @{$res->{$UNTESTED_XPASS}});
	      print_tclist($UNRESOLVED_FAIL, @{$res->{$UNRESOLVED_FAIL}});
	      print_tclist($UNRESOLVED_XPASS, @{$res->{$UNRESOLVED_XPASS}});
	      print_tclist($PASSED_NOW_TIMEOUTS, @{$res->{$PASSED_NOW_TIMEOUTS}});
       }
       printf "$col_reset\n";
   }

   #### MINOR TO BE CHECKED ?
   if (not $quiet and not $short)
   {
       $total_better = scalar(@{$res->{$XPASS_NOW_PASSES}})+
	   scalar(@{$res->{$XFAIL_NOW_PASSES}})+
	   scalar(@{$res->{$XFAIL_NOW_XPASS}})+
	   scalar(@{$res->{$FAIL_NOW_PASSES}})+
	   scalar(@{$res->{$FAIL_NOW_XPASS}})+
	   scalar(@{$res->{$NEW_PASSES}})+
	   scalar(@{$res->{$FAIL_DISAPPEARS}})+
	   scalar(@{$res->{$XFAIL_APPEARS}})+
	   scalar(@{$res->{$FAIL_NOW_XFAIL}})+
	   scalar(@{$res->{$PASS_NOW_XFAIL}})+
	   scalar(@{$res->{$XPASS_NOW_XFAIL}})+
	   scalar(@{$res->{$UNSUPPORTED_PASS}})+
	   scalar(@{$res->{$UNSUPPORTED_XFAIL}})+
	   scalar(@{$res->{$UNSUPPORTED_DISAPPEARS}})+
	   scalar(@{$res->{$UNTESTED_PASS}})+
	   scalar(@{$res->{$UNTESTED_XFAIL}})+
	   scalar(@{$res->{$UNTESTED_DISAPPEARS}})+
	   scalar(@{$res->{$UNRESOLVED_PASS}})+
	   scalar(@{$res->{$UNRESOLVED_XFAIL}})+
	   scalar(@{$res->{$UNRESOLVED_DISAPPEARS}})+
	   scalar(@{$res->{$UNHANDLED_CASES}});

       printf "$col_pink"."o  MINOR TO BE CHECKED:\n";
       printf "  +------------------------------------------+---------+\n";
       printf "  | %-40s | %7d |\n", $XFAIL_APPEARS, scalar(@{$res->{$XFAIL_APPEARS}}) if (scalar(@{$res->{$XFAIL_APPEARS}}));
       printf "  | %-40s | %7d |\n", $FAIL_NOW_XFAIL, scalar(@{$res->{$FAIL_NOW_XFAIL}}) if (scalar(@{$res->{$FAIL_NOW_XFAIL}}));
       printf "  | %-40s | %7d |\n", $PASS_NOW_XFAIL, scalar(@{$res->{$PASS_NOW_XFAIL}}) if (scalar(@{$res->{$PASS_NOW_XFAIL}}));
       printf "  | %-40s | %7d |\n", $XPASS_NOW_XFAIL, scalar(@{$res->{$XPASS_NOW_XFAIL}}) if (scalar(@{$res->{$XPASS_NOW_XFAIL}}));
       printf "  | %-40s | %7d |\n", $FAIL_DISAPPEARS, scalar(@{$res->{$FAIL_DISAPPEARS}}) if (scalar(@{$res->{$FAIL_DISAPPEARS}}));
       printf "  | %-40s | %7d |\n", $XPASS_NOW_PASSES, scalar(@{$res->{$XPASS_NOW_PASSES}}) if (scalar(@{$res->{$XPASS_NOW_PASSES}}));
       printf "  | %-40s | %7d |\n", $XFAIL_NOW_PASSES, scalar(@{$res->{$XFAIL_NOW_PASSES}}) if (scalar(@{$res->{$XFAIL_NOW_PASSES}}));
       printf "  | %-40s | %7d |\n", $XFAIL_NOW_XPASS, scalar(@{$res->{$XFAIL_NOW_XPASS}}) if (scalar(@{$res->{$XFAIL_NOW_XPASS}}));
       printf "  | %-40s | %7d |\n", $FAIL_NOW_PASSES, scalar(@{$res->{$FAIL_NOW_PASSES}}) if (scalar(@{$res->{$FAIL_NOW_PASSES}}));
       printf "  | %-40s | %7d |\n", $FAIL_NOW_XPASS, scalar(@{$res->{$FAIL_NOW_XPASS}}) if (scalar(@{$res->{$FAIL_NOW_XPASS}}));
       printf "  | %-40s | %7d |\n", $NEW_PASSES, scalar(@{$res->{$NEW_PASSES}}) if (scalar(@{$res->{$NEW_PASSES}}));
       printf "  | %-40s | %7d |\n", $UNSUPPORTED_PASS, scalar(@{$res->{$UNSUPPORTED_PASS}}) if (scalar(@{$res->{$UNSUPPORTED_PASS}}));
       printf "  | %-40s | %7d |\n", $UNSUPPORTED_XFAIL, scalar(@{$res->{$UNSUPPORTED_XFAIL}}) if (scalar(@{$res->{$UNSUPPORTED_XFAIL}}));
       printf "  | %-40s | %7d |\n", $UNSUPPORTED_DISAPPEARS, scalar(@{$res->{$UNSUPPORTED_DISAPPEARS}}) if (scalar(@{$res->{$UNSUPPORTED_DISAPPEARS}}));
       printf "  | %-40s | %7d |\n", $UNTESTED_PASS, scalar(@{$res->{$UNTESTED_PASS}}) if (scalar(@{$res->{$UNTESTED_PASS}}));
       printf "  | %-40s | %7d |\n", $UNTESTED_XFAIL, scalar(@{$res->{$UNTESTED_XFAIL}}) if (scalar(@{$res->{$UNTESTED_XFAIL}}));
       printf "  | %-40s | %7d |\n", $UNTESTED_DISAPPEARS, scalar(@{$res->{$UNTESTED_DISAPPEARS}}) if (scalar(@{$res->{$UNTESTED_DISAPPEARS}}));
       printf "  | %-40s | %7d |\n", $UNRESOLVED_PASS, scalar(@{$res->{$UNRESOLVED_PASS}}) if (scalar(@{$res->{$UNRESOLVED_PASS}}));
       printf "  | %-40s | %7d |\n", $UNRESOLVED_XFAIL, scalar(@{$res->{$UNRESOLVED_XFAIL}}) if (scalar(@{$res->{$UNRESOLVED_XFAIL}}));
       printf "  | %-40s | %7d |\n", $UNRESOLVED_DISAPPEARS, scalar(@{$res->{$UNRESOLVED_DISAPPEARS}}) if (scalar(@{$res->{$UNRESOLVED_DISAPPEARS}}));
       printf "  | %-40s | %7d |\n", $UNHANDLED_CASES, scalar(@{$res->{$UNHANDLED_CASES}}) if (scalar(@{$res->{$UNHANDLED_CASES}}));
       printf "  | %-40s | %7d |\n", $UNSTABLE_CASES, scalar(@{$res->{$UNSTABLE_CASES}}) if (scalar(@{$res->{$UNSTABLE_CASES}}));
       printf "  +------------------------------------------+---------+\n";
       printf "  | %-40s | %7d |\n", "TOTAL_MINOR_TO_BE_CHECKED", $total_better + scalar(@{$res->{$UNSTABLE_CASES}});;
       printf "  +------------------------------------------+---------+\n";
       printf "\n";

       if ($long)
       {
	      print_tclist($XPASS_NOW_PASSES, @{$res->{$XPASS_NOW_PASSES}});
	      print_tclist($XFAIL_NOW_PASSES, @{$res->{$XFAIL_NOW_PASSES}});
	      print_tclist($XFAIL_NOW_XPASS, @{$res->{$XFAIL_NOW_XPASS}});
	      print_tclist($FAIL_NOW_PASSES, @{$res->{$FAIL_NOW_PASSES}});
	      print_tclist($FAIL_NOW_XPASS, @{$res->{$FAIL_NOW_XPASS}});
	      print_tclist($FAIL_DISAPPEARS, @{$res->{$FAIL_DISAPPEARS}});
	      print_tclist($XFAIL_APPEARS, @{$res->{$XFAIL_APPEARS}});
	      print_tclist($FAIL_NOW_XFAIL, @{$res->{$FAIL_NOW_XFAIL}});
	      print_tclist($PASS_NOW_XFAIL, @{$res->{$PASS_NOW_XFAIL}});
	      print_tclist($XPASS_NOW_XFAIL, @{$res->{$XPASS_NOW_XFAIL}});
	      print_tclist($UNHANDLED_CASES, @{$res->{$UNHANDLED_CASES}});
	      print_tclist($UNSUPPORTED_PASS, @{$res->{$UNSUPPORTED_PASS}});
	      print_tclist($UNSUPPORTED_XFAIL, @{$res->{$UNSUPPORTED_XFAIL}});
	      print_tclist($UNSUPPORTED_DISAPPEARS, @{$res->{$UNSUPPORTED_DISAPPEARS}});
	      print_tclist($UNTESTED_PASS, @{$res->{$UNTESTED_PASS}});
	      print_tclist($UNTESTED_XFAIL, @{$res->{$UNTESTED_XFAIL}});
	      print_tclist($UNTESTED_DISAPPEARS, @{$res->{$UNTESTED_DISAPPEARS}});
	      print_tclist($UNRESOLVED_PASS, @{$res->{$UNRESOLVED_PASS}});
	      print_tclist($UNRESOLVED_XFAIL, @{$res->{$UNRESOLVED_XFAIL}});
	      print_tclist($UNRESOLVED_DISAPPEARS, @{$res->{$UNRESOLVED_DISAPPEARS}});
	      print_tclist($UNSTABLE_CASES, @{$res->{$UNSTABLE_CASES}});
	      print_tclist($NEW_PASSES, @{$res->{$NEW_PASSES}});
       }
       printf "$col_reset\n";
   }

   $return_value = 1 if ($total_better);

   $return_value = 2 if ($rtotal);

   # Error if there was no PASS (eg when sth went wrong and no .sum was generated)
   $return_value = 2 if (($res->{PASS} + $res->{XFAIL}) == 0);

   # Error if every test passed, or the ratio was too low. This
   # generally means the simulator is not configured well.
   $return_value = 2 if (($ref_ratio == 100) || ($ref_ratio < $ratio_thresh));
   $return_value = 2 if (($res_ratio == 100) || ($res_ratio < $ratio_thresh));

   # Error if no execution test passed.
   # It is possible that no execution test fails, though.
   $return_value = 2 if (($ignore_exec == 0)
			 && (($ref->{EXEC}->{PASS} == 0)
			     || ($res->{EXEC}->{PASS} == 0)));

   return $return_value;
}