Commits

Shlomi Fish committed a44a2aa

Add more to test_total.pl.

  • Participants
  • Parent commits 5460e28

Comments (0)

Files changed (1)

File mikmod-test-suite/test_total.pl

 
 use IO::All;
 use FindBin;
+use List::Util qw(first);
 
 my $base = $FindBin::Bin;
+chdir($base);
 
-my $mods_dir = io("$base/mods");
+my $mods_dir = io("./mods");
 $mods_dir->mkpath;
-io("$base/good-wavs")->mkpath;
-io("$base/good-sha256sums")->mkpath;
-io("$base/received")->mkpath;
+my $good_dir = io("./good-wavs");
+$good_dir->mkpath;
+my $sums_dir = io("./good-sha256sums");
+$sums_dir->mkpath;
+my $received_dir = io("./received");
+$received_dir->mkpath;
 
 my @module_files = (qw(
     80472-kingdom.xm
     yonqatan.mod
 ));
 
+my @lines = `mikmod -n`;
+
+my $re = qr/^\s*(\d+)\s*Wav disk writer/;
+
+my $line = first { $_ =~ /$re/ } @lines;
+
+if (!defined($line))
+{
+    die "Your mikmod does not support the Wav disk writer - check `mikmod -n`!";
+}
+
+my ($driver_id) = $line =~ /$re/;
+    
 foreach my $mod (@module_files)
 {
     my $get_mod = sub { $mods_dir->catfile($mod); };
         $mod_in_dir = $get_mod->();
     }
 
+    my $got_wav = io($received_dir)->catfile("$mod.wav");
+    system("mikmod", "-d", "$driver_id,file=$got_wav", $mod_in_dir);
 
+    my $good_wav = io($good_dir)->catfile("$mod.wav");
+    if (! $good_wav->exists())
+    {
+        $got_wav > $good_wav;
+        my $out = `sha256sum $good_wav`;
+        if (my ($checksum) = ($out =~ m/\A([\da-f]+)\s/))
+        {
+            $checksum .= "\n";
+            my $sum_fn = $sums_dir->catfile("$mod.sha256sum");
+
+            if (! $sum_fn->exists() )
+            {
+                $sum_fn->print($checksum);
+            }
+            else
+            {
+                if ($sum_fn->slurp() ne $checksum)
+                {
+                    die "Differening checksums on $mod";
+                }
+            }
+        }
+        else
+        {
+            die "sha256sum returned error on $good_wav.";
+        }
+    }
+    else
+    {
+        if (system("cmp", "-s", $good_wav, $got_wav))
+        {
+            die "Failure in comparing output of $mod - $good_wav vs. $got_wav";
+        }
+    }
 }
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2012 by Shlomi Fish
+
+This program is distributed under the MIT (X11) License:
+L<http://www.opensource.org/licenses/mit-license.php>
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+=cut