From: Doni Pracner Date: Sun, 26 Oct 2014 20:25:14 +0000 (+0100) Subject: perl scripts to compare outputs of various versions X-Git-Tag: v0.2.1~45 X-Git-Url: http://svarog.pmf.uns.ac.rs/gitweb/?p=mjc2wsl.git;a=commitdiff_plain;h=54295202d5e5e42905acdda6bea1a04ca6dd96f2;hp=9446af825b9a9f3d14961d6ce1a9c56f0bac7615;ds=sidebyside perl scripts to compare outputs of various versions --- diff --git a/lib/compare-m-w.pl b/lib/compare-m-w.pl new file mode 100644 index 0000000..737cdb8 --- /dev/null +++ b/lib/compare-m-w.pl @@ -0,0 +1,44 @@ +#!/usr/bin/perl +# +# test if the outputs are the same from MicroJava and WSL + +sub read_file($) { + my ($file) = @_; + my $in; + open($in, $file) or die "Cannot read $file: $!\n"; + my $data = join("", <$in>); + close($in); + return($data); +} + +# quit unless we have the correct number of command-line args +$num_args = $#ARGV + 1; +if ($num_args != 2) { + print "\nUsage: compare-m-w.pl directory base_filename \n"; + exit; +} + +$dir=@ARGV[0]; +$base=@ARGV[1]; + +$outm = read_file("$dir/$base.outmj"); +$outw = read_file("$dir/$base.outwsl"); + +#print "inputs:\n"; +#print "$outm\n--\n$outw\n\n"; + +#process the MJ output to remove comments +$outm=~s/Completion took.*$//s; + +#process the WSL output to remove comments +$outw=~s/^.*Starting Execution...//s; +$outw=~s/^.*?\n.*?\n//s; +$outw=~s/Execution time:.*//s; + +if ($outm eq $outw) { + print "$base - OK\n"; +} else { + print "$base - difference detected!:\n"; + print "$outm###\n--\n$outw###\n"; + die(); +} \ No newline at end of file diff --git a/lib/compare-w-wt.pl b/lib/compare-w-wt.pl new file mode 100644 index 0000000..11d4714 --- /dev/null +++ b/lib/compare-w-wt.pl @@ -0,0 +1,44 @@ +#!/usr/bin/perl +# +# test if the outputs are the same from two versions of +# WSL programs - the original and the transformation + +sub read_file($) { + my ($file) = @_; + my $in; + open($in, $file) or die "Cannot read $file: $!\n"; + my $data = join("", <$in>); + close($in); + return($data); +} + +# quit unless we have the correct number of command-line args +$num_args = $#ARGV + 1; +if ($num_args != 2) { + print "\nUsage: compare-w-wt.pl directory base_filename \n"; + exit; +} + +$dir=@ARGV[0]; +$base=@ARGV[1]; + +$outw = read_file("$dir/$base.outwsl"); +$outwt = read_file("$dir/$base.outwslt"); + +#print "inputs:\n"; +#print "$outm\n--\n$outw\n\n"; + +#process the WSL output to remove comments +for ($outw, $outwt) { + s/^.*Starting Execution...//s; + s/^.*?\n.*?\n//s; + s/Execution time:.*//s; +} + +if ($outw eq $outwt) { + print "$base - OK\n"; +} else { + print "$base - difference detected!:\n"; + print "$outw###\n--\n$outwt###\n"; + die(); +} \ No newline at end of file