--- /dev/null
+#! /usr/bin/perl -w
+#
+# This file is part of DisOrder
+# Copyright (C) 2020 Mark Wooding
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+use autodie;
+use strict;
+
+(our $PROG = $0) =~ s:^.*/::;
+sub usage (\*) { print {$_[0]} "usage: $PROG DELTA FIRST SECOND\n"; }
+sub fail ($;$) { print STDERR "$PROG: $_[0]\n"; exit($_[1] // 2); }
+
+if (@ARGV != 3) { usage *STDERR; exit 2; }
+my $delta = $ARGV[0];
+open my $f, "<", $ARGV[1]; binmode $f;
+open my $g, "<", $ARGV[2]; binmode $g;
+my $off = 0;
+SAMPLE: for (;;) {
+ my $n = read $f, my $a, 2;
+ my $m = read $g, my $b, 2;
+ if (!$n) {
+ if ($m) { fail "$PROG: second file is longer (offset = $off)", 1; }
+ last SAMPLE;
+ } elsif (!$m) { fail "$PROG: first file is longer (offset = $off)", 1; }
+
+ my ($x) = unpack "s>", $a;
+ my ($y) = unpack "s>", $b;
+ if (abs($x - $y) > $delta)
+ { fail "$PROG: content differs (offset = $off: $x != $y)", 1; }
+ $off += 2;
+}
check-mp3: disorder-decode disorder-normalize
./disorder-decode ${top_srcdir}/sounds/scratch.mp3 | \
./disorder-normalize --config ${srcdir}/test-config > mp3ed.raw
- cmp mp3ed.raw ${top_srcdir}/sounds/scratch-mp3.raw
+ $(top_srcdir)/scripts/compare-raw 0 \
+ mp3ed.raw ${top_srcdir}/sounds/scratch-mp3.raw
rm -f mp3ed.raw
# TODO ogg decoding comes out OK but different depending on platform, version
check-ogg: disorder-decode disorder-normalize
./disorder-decode ${top_srcdir}/sounds/scratch.ogg | \
./disorder-normalize --config ${srcdir}/test-config > ogged.raw
- cmp ogged.raw ${top_srcdir}/sounds/scratch.raw
+ $(top_srcdir)/scripts/compare-raw 0 \
+ ogged.raw ${top_srcdir}/sounds/scratch.raw
rm -f ogged.raw
check-wav: disorder-decode disorder-normalize
./disorder-decode ${top_srcdir}/sounds/scratch.wav | \
./disorder-normalize --config ${srcdir}/test-config > waved.raw
- cmp waved.raw ${top_srcdir}/sounds/scratch.raw
+ $(top_srcdir)/scripts/compare-raw 0 \
+ waved.raw ${top_srcdir}/sounds/scratch.raw
rm -rf waved.raw
check-flac: disorder-decode disorder-normalize
./disorder-decode ${top_srcdir}/sounds/scratch.flac | \
./disorder-normalize --config ${srcdir}/test-config > flacced.raw
- cmp flacced.raw ${top_srcdir}/sounds/scratch.raw
+ $(top_srcdir)/scripts/compare-raw 0 \
+ flacced.raw ${top_srcdir}/sounds/scratch.raw
rm -f flacced.raw
EXTRA_DIST=README.dbversions test-config