From 6f813dcf985d42857d536c53199c9daaf2784b3d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christian=20W=C3=BCrdig?= Date: Thu, 10 Aug 2006 18:55:47 +0000 Subject: [PATCH] added script to create difference between two reports --- ir/be/test/diffreports.pl | 126 +++++++++++++++++++++++++++++++++++ ir/be/test/makediffhtml.xslt | 76 +++++++++++++++++++++ 2 files changed, 202 insertions(+) create mode 100644 ir/be/test/diffreports.pl create mode 100644 ir/be/test/makediffhtml.xslt diff --git a/ir/be/test/diffreports.pl b/ir/be/test/diffreports.pl new file mode 100644 index 000000000..40e3fead6 --- /dev/null +++ b/ir/be/test/diffreports.pl @@ -0,0 +1,126 @@ +#!/usr/bin/perl -w + +use strict; +use XML::Simple; +use Data::Dumper; + +my $old_file = $ARGV[0]; +my $new_file = $ARGV[1]; +my $diff_file = "results_diff.xml"; + +$| = 1; # perform flush after each write to STDOUT + +print "reading $old_file ... "; +my $start = time; +my $res_old = XMLin("$old_file", forcearray => 1); +print "done (", time - $start," s)\n"; + +print "reading $new_file ... "; +$start = time; +my $res_new = XMLin("$new_file", forcearray => 1); +print "done (", time - $start," s)\n"; + +open(DIFF, ">$diff_file") or die "Could not open $diff_file, reason:$!\n"; + +print DIFF "\n"; +print DIFF "\n"; +print DIFF " \n"; +print DIFF " $old_file\n"; +print DIFF " $new_file\n"; +print DIFF " \n"; + +if (! exists($res_old->{"environment"})) { + print "environment missing in $old_file!\n"; +} +elsif (! exists($res_new->{"environment"})) { + print "environment missing in $new_file!\n"; +} +else { + print DIFF " \n"; + print DIFF " \n"; + + my %env = %{ @{ $res_old->{"environment"} }[0] }; + + foreach (keys(%env)) { + print DIFF " <$_>", @{ $env{"$_"} }[0], "\n"; + } + print DIFF " \n"; + print DIFF " \n"; + + %env = %{ @{ $res_new->{"environment"} }[0] }; + + foreach (keys(%env)) { + print DIFF " <$_>", @{ $env{"$_"} }[0], "\n"; + } + print DIFF " \n"; + print DIFF " \n"; +} + +my $section_old = $res_old->{"section"}; +my $section_new = $res_new->{"section"}; + +foreach (keys(%{ $section_old })) { + if (! exists($section_new->{"$_"})) { + print "Section $_ missing in $new_file!\n"; + next; + } + + print DIFF "
\n"; + + my $old = $section_old->{"$_"}{"result"}; + my $new = $section_new->{"$_"}{"result"}; + + foreach my $test (keys(%{ $old })) { + my $entry_old = $old->{"$test"}; + my $entry_new = $new->{"$test"}; + my $has_diff = 0; + + if (! exists($new->{"$test"})) { + foreach my $k1 (keys(%{ $entry_old })) { + $entry_new->{"$k1"} = [ 'missing' ]; + $has_diff = 1; + } + } + else { + foreach my $k (keys(%{ $entry_old })) { + if (! exists($entry_new->{"$k"})) { + $entry_new->{"$k"} = [ 'missing' ]; + $has_diff = 1; + } + else { + my @val_old = @{ $entry_old->{"$k"} }; + my @val_new = @{ $entry_new->{"$k"} }; + if ($val_old[0] ne $val_new[0]) { + $has_diff = 1; + } + } + } + } + + if ($has_diff == 1) { + print DIFF " \n"; + print DIFF " \n"; + emit_entry($entry_old); + print DIFF " \n"; + print DIFF " \n"; + emit_entry($entry_new); + print DIFF " \n"; + print DIFF " \n"; + } + } + + print DIFF "
\n"; +} + +print DIFF "
\n"; + +close(DIFF); + +sub emit_entry { + my $href = shift; + + foreach (keys(%{ $href })) { + my @val = @{ $href->{"$_"} }; + print DIFF " <$_>", $val[0], "\n"; + } +} diff --git a/ir/be/test/makediffhtml.xslt b/ir/be/test/makediffhtml.xslt new file mode 100644 index 000000000..54e5e2d1f --- /dev/null +++ b/ir/be/test/makediffhtml.xslt @@ -0,0 +1,76 @@ + + + + + + + + background-color: green; color: white; + + + background-color: red; color: white; + + + background-color: black; color: white; + + + + + + + + + Results + + + OLD:
+ NEW:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameCompileLinkGCC CompileGCC RunFirm RunResults
+ + buildresult_.txt + + +
+ + +
+
-- 2.20.1