xref: /aosp_15_r20/external/flac/test/test_grabbag.sh (revision 600f14f40d737144c998e2ec7a483122d3776fbc)
1*600f14f4SXin Li#!/bin/sh -e
2*600f14f4SXin Li
3*600f14f4SXin Li#  FLAC - Free Lossless Audio Codec
4*600f14f4SXin Li#  Copyright (C) 2001-2009  Josh Coalson
5*600f14f4SXin Li#  Copyright (C) 2011-2023  Xiph.Org Foundation
6*600f14f4SXin Li#
7*600f14f4SXin Li#  This file is part the FLAC project.  FLAC is comprised of several
8*600f14f4SXin Li#  components distributed under different licenses.  The codec libraries
9*600f14f4SXin Li#  are distributed under Xiph.Org's BSD-like license (see the file
10*600f14f4SXin Li#  COPYING.Xiph in this distribution).  All other programs, libraries, and
11*600f14f4SXin Li#  plugins are distributed under the GPL (see COPYING.GPL).  The documentation
12*600f14f4SXin Li#  is distributed under the Gnu FDL (see COPYING.FDL).  Each file in the
13*600f14f4SXin Li#  FLAC distribution contains at the top the terms under which it may be
14*600f14f4SXin Li#  distributed.
15*600f14f4SXin Li#
16*600f14f4SXin Li#  Since this particular file is relevant to all components of FLAC,
17*600f14f4SXin Li#  it may be distributed under the Xiph.Org license, which is the least
18*600f14f4SXin Li#  restrictive of those mentioned above.  See the file COPYING.Xiph in this
19*600f14f4SXin Li#  distribution.
20*600f14f4SXin Li
21*600f14f4SXin Li. ./common.sh
22*600f14f4SXin Li
23*600f14f4SXin LiPATH=../src/test_grabbag/cuesheet:$PATH
24*600f14f4SXin LiPATH=../src/test_grabbag/picture:$PATH
25*600f14f4SXin LiPATH=../objs/$BUILD/bin:$PATH
26*600f14f4SXin Li
27*600f14f4SXin Litest_cuesheet -h 1>/dev/null 2>/dev/null || die "ERROR can't find test_cuesheet executable"
28*600f14f4SXin Litest_picture -h 1>/dev/null 2>/dev/null || die "ERROR can't find test_picture executable"
29*600f14f4SXin Li
30*600f14f4SXin Lirun_test_cuesheet ()
31*600f14f4SXin Li{
32*600f14f4SXin Li	if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then
33*600f14f4SXin Li		echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 test_cuesheet $*" >>test_grabbag.valgrind.log
34*600f14f4SXin Li		valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_cuesheet${EXE} $* 4>>test_grabbag.valgrind.log
35*600f14f4SXin Li	else
36*600f14f4SXin Li		test_cuesheet${EXE} $*
37*600f14f4SXin Li	fi
38*600f14f4SXin Li}
39*600f14f4SXin Li
40*600f14f4SXin Lirun_test_picture ()
41*600f14f4SXin Li{
42*600f14f4SXin Li	if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then
43*600f14f4SXin Li		echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 test_picture $*" >>test_grabbag.valgrind.log
44*600f14f4SXin Li		valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_picture${EXE} $* 4>>test_grabbag.valgrind.log
45*600f14f4SXin Li	else
46*600f14f4SXin Li		test_picture${EXE} $*
47*600f14f4SXin Li	fi
48*600f14f4SXin Li}
49*600f14f4SXin Li
50*600f14f4SXin Li########################################################################
51*600f14f4SXin Li#
52*600f14f4SXin Li# test_picture
53*600f14f4SXin Li#
54*600f14f4SXin Li########################################################################
55*600f14f4SXin Li
56*600f14f4SXin Lilog=picture.log
57*600f14f4SXin Lipicture_dir=${top_srcdir}/test/pictures
58*600f14f4SXin Li
59*600f14f4SXin Liecho "Running test_picture..."
60*600f14f4SXin Li
61*600f14f4SXin Lirm -f $log
62*600f14f4SXin Li
63*600f14f4SXin Lirun_test_picture $picture_dir >> $log 2>&1
64*600f14f4SXin Li
65*600f14f4SXin Liif [ $is_win = yes ] ; then
66*600f14f4SXin Li	diff -w ${top_srcdir}/test/picture.ok $log > picture.diff || die "Error: .log file does not match .ok file, see picture.diff"
67*600f14f4SXin Lielse
68*600f14f4SXin Li	diff ${top_srcdir}/test/picture.ok $log > picture.diff || die "Error: .log file does not match .ok file, see picture.diff"
69*600f14f4SXin Lifi
70*600f14f4SXin Li
71*600f14f4SXin Liecho "PASSED (results are in $log)"
72*600f14f4SXin Li
73*600f14f4SXin Li########################################################################
74*600f14f4SXin Li#
75*600f14f4SXin Li# test_cuesheet
76*600f14f4SXin Li#
77*600f14f4SXin Li########################################################################
78*600f14f4SXin Li
79*600f14f4SXin Lilog=cuesheet.log
80*600f14f4SXin Libad_cuesheets=${top_srcdir}/test/cuesheets/bad.*.cue
81*600f14f4SXin Ligood_cuesheets=${top_srcdir}/test/cuesheets/good.*.cue
82*600f14f4SXin Ligood_leadout=$((80 * 60 * 44100))
83*600f14f4SXin Libad_leadout=$((good_leadout + 1))
84*600f14f4SXin Li
85*600f14f4SXin Liecho "Running test_cuesheet..."
86*600f14f4SXin Li
87*600f14f4SXin Lirm -f $log
88*600f14f4SXin Li
89*600f14f4SXin Li#
90*600f14f4SXin Li# negative tests
91*600f14f4SXin Li#
92*600f14f4SXin Lifor cuesheet in $bad_cuesheets ; do
93*600f14f4SXin Li	echo "NEGATIVE $cuesheet" | sed "s|${top_srcdir}/test/||" >> $log 2>&1
94*600f14f4SXin Li	run_test_cuesheet $cuesheet $good_leadout 44100 cdda >> $log 2>&1 || exit_code=$?
95*600f14f4SXin Li	if [ "$exit_code" = 255 ] ; then
96*600f14f4SXin Li		die "Error: test script is broken"
97*600f14f4SXin Li	fi
98*600f14f4SXin Li	cuesheet_pass1=${cuesheet}.1
99*600f14f4SXin Li	cuesheet_pass2=${cuesheet}.2
100*600f14f4SXin Li	rm -f $cuesheet_pass1 $cuesheet_pass2
101*600f14f4SXin Lidone
102*600f14f4SXin Li
103*600f14f4SXin Li#
104*600f14f4SXin Li# positive tests
105*600f14f4SXin Li#
106*600f14f4SXin Lifor cuesheet in $good_cuesheets ; do
107*600f14f4SXin Li	echo "POSITIVE $cuesheet" | sed "s|${top_srcdir}/test/||" >> $log 2>&1
108*600f14f4SXin Li	run_test_cuesheet $cuesheet $good_leadout 44100 cdda >> $log 2>&1
109*600f14f4SXin Li	exit_code=$?
110*600f14f4SXin Li	if [ "$exit_code" = 255 ] ; then
111*600f14f4SXin Li		die "Error: test script is broken"
112*600f14f4SXin Li	elif [ "$exit_code" != 0 ] ; then
113*600f14f4SXin Li		die "Error: good cuesheet is broken"
114*600f14f4SXin Li	fi
115*600f14f4SXin Li	cuesheet_out=$(echo $cuesheet | sed "s|${top_srcdir}/test/||")
116*600f14f4SXin Li	cuesheet_pass1=${cuesheet_out}.1
117*600f14f4SXin Li	cuesheet_pass2=${cuesheet_out}.2
118*600f14f4SXin Li	diff $cuesheet_pass1 $cuesheet_pass2 >> $log 2>&1 || die "Error: pass1 and pass2 output differ"
119*600f14f4SXin Li	rm -f $cuesheet_pass1 $cuesheet_pass2
120*600f14f4SXin Lidone
121*600f14f4SXin Li
122*600f14f4SXin Liif [ $is_win = yes ] ; then
123*600f14f4SXin Li	diff -w ${top_srcdir}/test/cuesheet.ok $log > cuesheet.diff || die "Error: .log file does not match .ok file, see cuesheet.diff"
124*600f14f4SXin Lielse
125*600f14f4SXin Li	diff ${top_srcdir}/test/cuesheet.ok $log > cuesheet.diff || die "Error: .log file does not match .ok file, see cuesheet.diff"
126*600f14f4SXin Lifi
127*600f14f4SXin Li
128*600f14f4SXin Liecho "PASSED (results are in $log)"
129