Commit 6218b344 authored by Josh Coalson's avatar Josh Coalson
Browse files

clean up code by emulating perl's 'die' command

parent 8fac5d67
......@@ -17,13 +17,18 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
die ()
{
echo $* 1>&2
exit 1
}
LD_LIBRARY_PATH=../src/libFLAC/.libs:../obj/release/lib:../obj/debug/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
PATH=../src/flac:../obj/release/bin:../obj/debug/bin:$PATH
BINS_PATH=../../test_files/bins
flac --help 1>/dev/null 2>/dev/null || (echo "ERROR can't find flac executable" 1>&2 && exit 1)
if [ $? != 0 ] ; then exit 1 ; fi
flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
run_flac ()
{
......@@ -47,26 +52,21 @@ test_file ()
cmd="run_flac --verify --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels $encode_options $name.bin"
echo "### ENCODE $name #######################################################" >> ./streams.log
echo "### cmd=$cmd" >> ./streams.log
if $cmd 2>>./streams.log ; then : ; else
echo "ERROR during encode of $name" 1>&2
exit 1
fi
$cmd 2>>./streams.log || die "ERROR during encode of $name"
echo -n "decode..."
cmd="run_flac --silent --endian=big --sign=signed --decode --force-raw-format $name.flac";
echo "### DECODE $name #######################################################" >> ./streams.log
echo "### cmd=$cmd" >> ./streams.log
if $cmd 2>>./streams.log ; then : ; else
echo "ERROR during decode of $name" 1>&2
exit 1
fi
$cmd 2>>./streams.log || die "ERROR during decode of $name"
ls -1l $name.bin >> ./streams.log
ls -1l $name.flac >> ./streams.log
ls -1l $name.raw >> ./streams.log
echo -n "compare..."
if cmp $name.bin $name.raw ; then : ; else
echo "ERROR during compare of $name" 1>&2
exit 1
fi
cmp $name.bin $name.raw || die "ERROR during compare of $name"
echo OK
}
......
......@@ -17,12 +17,17 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
die ()
{
echo $* 1>&2
exit 1
}
LD_LIBRARY_PATH=../src/libFLAC/.libs:../src/share/grabbag/.libs:../obj/release/lib:../obj/debug/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
PATH=../src/test_grabbag/cuesheet:../obj/release/bin:../obj/debug/bin:$PATH
test_cuesheet -h 1>/dev/null 2>/dev/null || (echo "ERROR can't find test_cuesheet executable" 1>&2 && exit 1)
if [ $? != 0 ] ; then exit 1 ; fi
test_cuesheet -h 1>/dev/null 2>/dev/null || die "ERROR can't find test_cuesheet executable"
run_test_cuesheet ()
{
......@@ -55,8 +60,7 @@ for cuesheet in $bad_cuesheets ; do
run_test_cuesheet $cuesheet $good_leadout cdda >> $log 2>&1
exit_code=$?
if [ "$exit_code" = 255 ] ; then
echo "Error: test script is broken"
exit 1
die "Error: test script is broken"
fi
cuesheet_pass1=${cuesheet}.1
cuesheet_pass2=${cuesheet}.2
......@@ -71,24 +75,14 @@ for cuesheet in $good_cuesheets ; do
run_test_cuesheet $cuesheet $good_leadout cdda >> $log 2>&1
exit_code=$?
if [ "$exit_code" = 255 ] ; then
echo "Error: test script is broken"
exit 1
die "Error: test script is broken"
elif [ "$exit_code" != 0 ] ; then
echo "Error: good cuesheet is broken"
exit 1
die "Error: good cuesheet is broken"
fi
cuesheet_pass1=${cuesheet}.1
cuesheet_pass2=${cuesheet}.2
diff $cuesheet_pass1 $cuesheet_pass2 >> $log 2>&1
if [ $? != 0 ] ; then
echo "Error: pass1 and pass2 output differ"
exit 1
fi
diff $cuesheet_pass1 $cuesheet_pass2 >> $log 2>&1 || die "Error: pass1 and pass2 output differ"
rm -f $cuesheet_pass1 $cuesheet_pass2
done
diff cuesheet.ok $log > cuesheet.diff
if [ $? != 0 ] ; then
echo "Error: .log file does not match .ok file, see cuesheet.diff"
exit 1
fi
diff cuesheet.ok $log > cuesheet.diff || die "Error: .log file does not match .ok file, see cuesheet.diff"
......@@ -17,6 +17,12 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
die ()
{
echo $* 1>&2
exit 1
}
LD_LIBRARY_PATH=../src/libFLAC++/.libs:../src/libFLAC/.libs:../obj/release/lib:../obj/debug/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
PATH=../src/test_libFLAC++:../obj/release/bin:../obj/debug/bin:$PATH
......@@ -31,7 +37,4 @@ run_test_libFLACpp ()
fi
}
if run_test_libFLACpp ; then : ; else
echo "ERROR during test_libFLAC++" 1>&2
exit 1
fi
run_test_libFLACpp || die "ERROR during test_libFLAC++"
......@@ -17,6 +17,12 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
die ()
{
echo $* 1>&2
exit 1
}
LD_LIBRARY_PATH=../src/libFLAC/.libs:../obj/release/lib:../obj/debug/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
PATH=../src/test_libFLAC:../obj/release/bin:../obj/debug/bin:$PATH
......@@ -31,7 +37,4 @@ run_test_libFLAC ()
fi
}
if run_test_libFLAC ; then : ; else
echo "ERROR during test_libFLAC" 1>&2
exit 1
fi
run_test_libFLAC || die "ERROR during test_libFLAC"
......@@ -17,6 +17,12 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
die ()
{
echo $* 1>&2
exit 1
}
LD_LIBRARY_PATH=../src/libOggFLAC++/.libs:../src/libOggFLAC/.libs:../src/libFLAC/.libs:../obj/release/lib:../obj/debug/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
PATH=../src/test_libOggFLAC++:../obj/release/bin:../obj/debug/bin:$PATH
......@@ -31,7 +37,4 @@ run_test_libOggFLACpp ()
fi
}
if run_test_libOggFLACpp ; then : ; else
echo "ERROR during test_libOggFLAC++" 1>&2
exit 1
fi
run_test_libOggFLACpp || die "ERROR during test_libOggFLAC++"
......@@ -17,6 +17,12 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
die ()
{
echo $* 1>&2
exit 1
}
LD_LIBRARY_PATH=../src/libOggFLAC/.libs../src/libFLAC/.libs:../obj/release/lib:../obj/debug/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
PATH=../src/test_libOggFLAC:../obj/release/bin:../obj/debug/bin:$PATH
......@@ -31,7 +37,4 @@ run_test_libOggFLAC ()
fi
}
if run_test_libOggFLAC ; then : ; else
echo "ERROR during test_libOggFLAC" 1>&2
exit 1
fi
run_test_libOggFLAC || die "ERROR during test_libOggFLAC"
......@@ -17,17 +17,20 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
die ()
{
echo $* 1>&2
exit 1
}
LD_LIBRARY_PATH=../src/libFLAC/.libs:../obj/release/lib:../obj/debug/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
PATH=../src/flac:../src/metaflac:../obj/release/bin:../obj/debug/bin:$PATH
flacfile=metaflac.flac
flac --help 1>/dev/null 2>/dev/null || (echo "ERROR can't find flac executable" 1>&2 && exit 1)
if [ $? != 0 ] ; then exit 1 ; fi
metaflac --help 1>/dev/null 2>/dev/null || (echo "ERROR can't find metaflac executable" 1>&2 && exit 1)
if [ $? != 0 ] ; then exit 1 ; fi
flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
metaflac --help 1>/dev/null 2>/dev/null || die "ERROR can't find metaflac executable"
run_flac ()
{
......@@ -56,25 +59,18 @@ fi
if run_flac --verify -0 --output-name=$flacfile --force-raw-format --endian=big --sign=signed --channels=1 --bps=8 --sample-rate=44100 $inputfile ; then
chmod +w $flacfile
else
echo "ERROR during generation" 1>&2
exit 1
die "ERROR during generation"
fi
check_exit ()
{
exit_code=$?
if [ $exit_code != 0 ] ; then
echo "ERROR, exit code = $exit_code" 1>&2
exit 1
fi
[ $exit_code = 0 ] || die "ERROR, exit code = $exit_code"
}
check_flac ()
{
if run_flac --silent --test $flacfile ; then : ; else
echo "ERROR in $flacfile" 1>&2
exit 1
fi
run_flac --silent --test $flacfile || die "ERROR in $flacfile" 1>&2
}
check_flac
......@@ -305,10 +301,7 @@ check_flac
(set -x && run_metaflac --export-cuesheet-to=$cs_out2 $flacfile)
check_exit
echo "comparing cuesheets:"
if diff $cs_out $cs_out2 ; then : ; else
echo "ERROR, cuesheets should be identical"
exit 1
fi
diff $cs_out $cs_out2 || die "ERROR, cuesheets should be identical"
echo identical
rm -f $cs_out $cs_out2
......
......@@ -17,12 +17,17 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
die ()
{
echo $* 1>&2
exit 1
}
LD_LIBRARY_PATH=../src/libFLAC/.libs:../obj/release/lib:../obj/debug/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
PATH=../src/flac:../src/test_streams:../obj/release/bin:../obj/debug/bin:$PATH
flac --help 1>/dev/null 2>/dev/null || (echo "ERROR can't find flac executable" 1>&2 && exit 1)
if [ $? != 0 ] ; then exit 1 ; fi
flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
run_flac ()
{
......@@ -35,10 +40,7 @@ run_flac ()
echo "Generating streams..."
if [ ! -f wacky1.wav ] ; then
if test_streams ; then : ; else
echo "ERROR during test_streams" 1>&2
exit 1
fi
test_streams || die "ERROR during test_streams"
fi
#
......@@ -56,26 +58,21 @@ test_file ()
cmd="run_flac --verify --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels $encode_options $name.raw"
echo "### ENCODE $name #######################################################" >> ./streams.log
echo "### cmd=$cmd" >> ./streams.log
if $cmd 2>>./streams.log ; then : ; else
echo "ERROR during encode of $name" 1>&2
exit 1
fi
$cmd 2>>./streams.log || die "ERROR during encode of $name"
echo -n "decode..."
cmd="run_flac --silent --endian=big --sign=signed --decode --force-raw-format --output-name=$name.cmp $name.flac"
echo "### DECODE $name #######################################################" >> ./streams.log
echo "### cmd=$cmd" >> ./streams.log
if $cmd 2>>./streams.log ; then : ; else
echo "ERROR during decode of $name" 1>&2
exit 1
fi
$cmd 2>>./streams.log || die "ERROR during decode of $name"
ls -1l $name.raw >> ./streams.log
ls -1l $name.flac >> ./streams.log
ls -1l $name.cmp >> ./streams.log
echo -n "compare..."
if cmp $name.raw $name.cmp ; then : ; else
echo "ERROR during compare of $name" 1>&2
exit 1
fi
cmp $name.raw $name.cmp || die "ERROR during compare of $name"
echo OK
}
......@@ -97,45 +94,32 @@ test_file_piped ()
cmd="run_flac --verify --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels $encode_options --stdout $name.raw"
echo "### ENCODE $name #######################################################" >> ./streams.log
echo "### cmd=$cmd" >> ./streams.log
if $cmd 1>$name.flac 2>>./streams.log ; then : ; else
echo "ERROR during encode of $name" 1>&2
exit 1
fi
$cmd 1>$name.flac 2>>./streams.log || die "ERROR during encode of $name"
else
cmd="run_flac --verify --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels $encode_options --stdout -"
echo "### ENCODE $name #######################################################" >> ./streams.log
echo "### cmd=$cmd" >> ./streams.log
if cat $name.raw | $cmd 1>$name.flac 2>>./streams.log ; then : ; else
echo "ERROR during encode of $name" 1>&2
exit 1
fi
cat $name.raw | $cmd 1>$name.flac 2>>./streams.log || die "ERROR during encode of $name"
fi
echo -n "decode via pipes..."
if [ $is_win = yes ] ; then
cmd="run_flac --silent --endian=big --sign=signed --decode --force-raw-format --stdout $name.flac"
echo "### DECODE $name #######################################################" >> ./streams.log
echo "### cmd=$cmd" >> ./streams.log
if $cmd 1>$name.cmp 2>>./streams.log ; then : ; else
echo "ERROR during decode of $name" 1>&2
exit 1
fi
$cmd 1>$name.cmp 2>>./streams.log || die "ERROR during decode of $name"
else
cmd="run_flac --silent --endian=big --sign=signed --decode --force-raw-format --stdout -"
echo "### DECODE $name #######################################################" >> ./streams.log
echo "### cmd=$cmd" >> ./streams.log
if cat $name.flac | $cmd 1>$name.cmp 2>>./streams.log ; then : ; else
echo "ERROR during decode of $name" 1>&2
exit 1
fi
cat $name.flac | $cmd 1>$name.cmp 2>>./streams.log || die "ERROR during decode of $name"
fi
ls -1l $name.raw >> ./streams.log
ls -1l $name.flac >> ./streams.log
ls -1l $name.cmp >> ./streams.log
echo -n "compare..."
if cmp $name.raw $name.cmp ; then : ; else
echo "ERROR during compare of $name" 1>&2
exit 1
fi
cmp $name.raw $name.cmp || die "ERROR during compare of $name"
echo OK
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment