Josh Coalson | 463d0f8 | 2002-12-10 06:41:27 +0000 | [diff] [blame^] | 1 | #!/bin/sh |
| 2 | |
| 3 | # FLAC - Free Lossless Audio Codec |
| 4 | # Copyright (C) 2001,2002 Josh Coalson |
| 5 | # |
| 6 | # This program is part of FLAC; you can redistribute it and/or |
| 7 | # modify it under the terms of the GNU General Public License |
| 8 | # as published by the Free Software Foundation; either version 2 |
| 9 | # of the License, or (at your option) any later version. |
| 10 | # |
| 11 | # This program is distributed in the hope that it will be useful, |
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | # GNU General Public License for more details. |
| 15 | # |
| 16 | # You should have received a copy of the GNU General Public License |
| 17 | # along with this program; if not, write to the Free Software |
| 18 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 19 | |
| 20 | LD_LIBRARY_PATH=../src/libFLAC/.libs:../obj/release/lib:../obj/debug/lib:$LD_LIBRARY_PATH |
| 21 | export LD_LIBRARY_PATH |
| 22 | PATH=../src/flac:../src/test_streams:../obj/release/bin:../obj/debug/bin:$PATH |
| 23 | |
| 24 | flac --help 1>/dev/null 2>/dev/null || (echo "ERROR can't find flac executable" 1>&2 && exit 1) |
| 25 | if [ $? != 0 ] ; then exit 1 ; fi |
| 26 | |
| 27 | run_flac () |
| 28 | { |
| 29 | if [ "$FLAC__VALGRIND" = yes ] ; then |
| 30 | valgrind --leak-check=yes --show-reachable=yes --num-callers=10 --logfile-fd=4 flac $* 4>>valgrind.log |
| 31 | else |
| 32 | flac $* |
| 33 | fi |
| 34 | } |
| 35 | |
| 36 | echo "Checking for --ogg support in flac..." |
| 37 | if flac --ogg --silent --force-raw-format --endian=little --sign=signed --channels=1 --bps=8 --sample-rate=44100 -c $0 1>/dev/null 2>&1 ; then |
| 38 | has_ogg=yes; |
| 39 | echo "flac --ogg works" |
| 40 | else |
| 41 | has_ogg=no; |
| 42 | echo "flac --ogg doesn't work" |
| 43 | fi |
| 44 | |
| 45 | # |
| 46 | # test --skip |
| 47 | # |
| 48 | echo "123456789012345678901234567890123456789" > 39c.raw |
| 49 | echo "012345678901234567890123456789012345678" > 39cu.raw |
| 50 | echo "0123456789012345678901234567890123456789" > 40c.raw |
| 51 | echo "01234567890123456789012345678901234567890123456789" > 50c.raw |
| 52 | |
| 53 | # test encode --skip=# |
| 54 | echo "testing --skip=# (encode)" |
| 55 | if run_flac --silent --verify --lax --force-raw-format --endian=big --sign=signed --sample-rate=10 --bps=8 --channels=1 --skip=10 -o 50c.skip10.flac 50c.raw ; then : ; else |
| 56 | echo "ERROR generating FLAC file" 1>&2 |
| 57 | exit 1 |
| 58 | fi |
| 59 | if run_flac --silent --decode --force-raw-format --endian=big --sign=signed -o 50c.skip10.raw 50c.skip10.flac ; then : ; else |
| 60 | echo "ERROR decoding FLAC file" 1>&2 |
| 61 | exit 1 |
| 62 | fi |
| 63 | if cmp 40c.raw 50c.skip10.raw ; then : ; else |
| 64 | echo "ERROR: file mismatch for --skip=10 (encode)" 1>&2 |
| 65 | exit 1 |
| 66 | fi |
| 67 | rm -f 50c.skip10.flac 50c.skip10.raw |
| 68 | echo OK |
| 69 | |
| 70 | # test encode --skip=mm:ss |
| 71 | echo "testing --skip=mm:ss (encode)" |
| 72 | if run_flac --silent --verify --lax --force-raw-format --endian=big --sign=signed --sample-rate=10 --bps=8 --channels=1 --skip=0:01 -o 50c.skip0:01.flac 50c.raw ; then : ; else |
| 73 | echo "ERROR generating FLAC file" 1>&2 |
| 74 | exit 1 |
| 75 | fi |
| 76 | if run_flac --silent --decode --force-raw-format --endian=big --sign=signed -o 50c.skip0:01.raw 50c.skip0:01.flac ; then : ; else |
| 77 | echo "ERROR decoding FLAC file" 1>&2 |
| 78 | exit 1 |
| 79 | fi |
| 80 | if cmp 40c.raw 50c.skip0:01.raw ; then : ; else |
| 81 | echo "ERROR: file mismatch for --skip=0:01 (encode)" 1>&2 |
| 82 | exit 1 |
| 83 | fi |
| 84 | rm -f 50c.skip0:01.flac 50c.skip0:01.raw |
| 85 | echo OK |
| 86 | |
| 87 | # test encode --skip=mm:ss.sss |
| 88 | echo "testing --skip=mm:ss.sss (encode)" |
| 89 | if run_flac --silent --verify --lax --force-raw-format --endian=big --sign=signed --sample-rate=10 --bps=8 --channels=1 --skip=0:01.1 -o 50c.skip0:01.1.flac 50c.raw ; then : ; else |
| 90 | echo "ERROR generating FLAC file" 1>&2 |
| 91 | exit 1 |
| 92 | fi |
| 93 | if run_flac --silent --decode --force-raw-format --endian=big --sign=signed -o 50c.skip0:01.1.raw 50c.skip0:01.1.flac ; then : ; else |
| 94 | echo "ERROR decoding FLAC file" 1>&2 |
| 95 | exit 1 |
| 96 | fi |
| 97 | if cmp 39c.raw 50c.skip0:01.1.raw ; then : ; else |
| 98 | echo "ERROR: file mismatch for --skip=0:01.1 (encode)" 1>&2 |
| 99 | exit 1 |
| 100 | fi |
| 101 | rm -f 50c.skip0:01.1.flac 50c.skip0:01.1.raw |
| 102 | echo OK |
| 103 | |
| 104 | # test decode --skip=# |
| 105 | echo "testing --skip=# (decode)" |
| 106 | if run_flac --silent --verify --lax --force-raw-format --endian=big --sign=signed --sample-rate=10 --bps=8 --channels=1 -o 50c.flac 50c.raw ; then : ; else |
| 107 | echo "ERROR generating FLAC file" 1>&2 |
| 108 | exit 1 |
| 109 | fi |
| 110 | if run_flac --silent --decode --force-raw-format --endian=big --sign=signed --skip=10 -o 50c.skip10.raw 50c.flac ; then : ; else |
| 111 | echo "ERROR decoding FLAC file" 1>&2 |
| 112 | exit 1 |
| 113 | fi |
| 114 | if cmp 40c.raw 50c.skip10.raw ; then : ; else |
| 115 | echo "ERROR: file mismatch for --skip=10 (decode)" 1>&2 |
| 116 | exit 1 |
| 117 | fi |
| 118 | rm -f 50c.skip10.raw |
| 119 | echo OK |
| 120 | |
| 121 | # test decode --skip=mm:ss |
| 122 | echo "testing --skip=mm:ss (decode)" |
| 123 | if run_flac --silent --decode --force-raw-format --endian=big --sign=signed --skip=0:01 -o 50c.skip0:01.raw 50c.flac ; then : ; else |
| 124 | echo "ERROR decoding FLAC file" 1>&2 |
| 125 | exit 1 |
| 126 | fi |
| 127 | if cmp 40c.raw 50c.skip0:01.raw ; then : ; else |
| 128 | echo "ERROR: file mismatch for --skip=0:01 (decode)" 1>&2 |
| 129 | exit 1 |
| 130 | fi |
| 131 | rm -f 50c.skip0:01.raw |
| 132 | echo OK |
| 133 | |
| 134 | # test decode --skip=mm:ss.sss |
| 135 | echo "testing --skip=mm:ss.sss (decode)" |
| 136 | if run_flac --silent --decode --force-raw-format --endian=big --sign=signed --skip=0:01.1 -o 50c.skip0:01.1.raw 50c.flac ; then : ; else |
| 137 | echo "ERROR decoding FLAC file" 1>&2 |
| 138 | exit 1 |
| 139 | fi |
| 140 | if cmp 39c.raw 50c.skip0:01.1.raw ; then : ; else |
| 141 | echo "ERROR: file mismatch for --skip=0:01.1 (decode)" 1>&2 |
| 142 | exit 1 |
| 143 | fi |
| 144 | rm -f 50c.skip0:01.1.raw |
| 145 | echo OK |
| 146 | |
| 147 | rm -f 50c.flac |
| 148 | |
| 149 | |
| 150 | # |
| 151 | # multi-file tests |
| 152 | # |
| 153 | |
| 154 | echo "Generating streams..." |
| 155 | if [ ! -f wacky1.wav ] ; then |
| 156 | if test_streams ; then : ; else |
| 157 | echo "ERROR during test_streams" 1>&2 |
| 158 | exit 1 |
| 159 | fi |
| 160 | fi |
| 161 | |
| 162 | echo "Generating multiple input files from noise..." |
| 163 | if run_flac --verify --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 noise.raw ; then : ; else |
| 164 | echo "ERROR generating FLAC file" 1>&2 |
| 165 | exit 1 |
| 166 | fi |
| 167 | if run_flac --decode --silent noise.flac ; then : ; else |
| 168 | echo "ERROR generating WAVE file" 1>&2 |
| 169 | exit 1 |
| 170 | fi |
| 171 | rm -f noise.flac |
| 172 | mv noise.wav file0.wav |
| 173 | cp file0.wav file1.wav |
| 174 | cp file1.wav file2.wav |
| 175 | |
| 176 | test_multifile () |
| 177 | { |
| 178 | streamtype=$1 |
| 179 | sector_align=$2 |
| 180 | encode_options="$3" |
| 181 | |
| 182 | if [ $streamtype = ogg ] ; then |
| 183 | suffix=ogg |
| 184 | encode_options="$encode_options --ogg" |
| 185 | else |
| 186 | suffix=flac |
| 187 | fi |
| 188 | |
| 189 | if [ $sector_align = sector_align ] ; then |
| 190 | encode_options="$encode_options --sector-align" |
| 191 | fi |
| 192 | |
| 193 | if run_flac $encode_options file0.wav file1.wav file2.wav ; then : ; else |
| 194 | echo "ERROR" 1>&2 |
| 195 | exit 1 |
| 196 | fi |
| 197 | for n in 0 1 2 ; do |
| 198 | mv file$n.$suffix file${n}x.$suffix |
| 199 | done |
| 200 | if run_flac --decode file0x.$suffix file1x.$suffix file2x.$suffix ; then : ; else |
| 201 | echo "ERROR" 1>&2 |
| 202 | exit 1 |
| 203 | fi |
| 204 | if [ $sector_align != sector_align ] ; then |
| 205 | for n in 0 1 2 ; do |
| 206 | if cmp file$n.wav file${n}x.wav ; then : ; else |
| 207 | echo "ERROR: file mismatch on file #$n" 1>&2 |
| 208 | exit 1 |
| 209 | fi |
| 210 | done |
| 211 | fi |
| 212 | for n in 0 1 2 ; do |
| 213 | rm -f file${n}x.$suffix file${n}x.wav |
| 214 | done |
| 215 | } |
| 216 | |
| 217 | echo "Testing multiple files without verify..." |
| 218 | test_multifile flac no_sector_align "" |
| 219 | |
| 220 | echo "Testing multiple files with verify..." |
| 221 | test_multifile flac no_sector_align "--verify" |
| 222 | |
| 223 | echo "Testing multiple files with --sector-align, without verify..." |
| 224 | test_multifile flac sector_align "" |
| 225 | |
| 226 | echo "Testing multiple files with --sector-align, with verify..." |
| 227 | test_multifile flac sector_align "--verify" |
| 228 | |
| 229 | if [ $has_ogg = "yes" ] ; then |
| 230 | echo "Testing multiple files with --ogg, without verify..." |
| 231 | test_multifile ogg no_sector_align "" |
| 232 | |
| 233 | echo "Testing multiple files with --ogg, with verify..." |
| 234 | test_multifile ogg no_sector_align "--verify" |
| 235 | |
| 236 | echo "Testing multiple files with --ogg and --sector-align, without verify..." |
| 237 | test_multifile ogg sector_align "" |
| 238 | |
| 239 | echo "Testing multiple files with --ogg and --sector-align, with verify..." |
| 240 | test_multifile sector_align ogg "--verify" |
| 241 | |
| 242 | echo "Testing multiple files with --ogg and --serial-number, with verify..." |
| 243 | test_multifile ogg no_sector_align "--serial-number=321 --verify" |
| 244 | fi |