1_FILENAME=${0##*/} 2CUR_DIR=${0/${_FILENAME}} 3CUR_DIR=$(cd $(dirname ${CUR_DIR}); pwd)/$(basename ${CUR_DIR})/ 4 5pushd $CUR_DIR/.. 6 7set -e 8 9CFLAGS="-O2 -std=c89 -Wall -Wextra -Wmissing-prototypes -Werror -fno-asynchronous-unwind-tables -fno-stack-protector -U_FORTIFY_SOURCE \ 10-ffunction-sections -fdata-sections -Wl,--gc-sections" 11 12echo testing mp4 mode... 13gcc $CFLAGS -o minimp3 minimp3_test.c -lm 14scripts/test_mode.sh 3 0 0 15 16echo testing stream mode... 17scripts/test_mode.sh 6 -1 -1 18 19echo testing coverage x86 w sse... 20gcc -coverage -O0 -m32 -std=c89 -msse2 -DMINIMP3_TEST -DMINIMP3_NO_WAV -o minimp3 minimp3_test.c -lm 21scripts/test.sh 22scripts/test_mode.sh 1 0 0 23scripts/test_mode.sh 2 0 0 24scripts/test_mode.sh 3 0 0 25scripts/test_mode.sh 4 0 0 26scripts/test_mode.sh 5 0 0 27scripts/test_mode.sh 6 -1 -1 28scripts/test_mode.sh 7 -1 -1 29scripts/test_mode.sh 8 -1 -1 30scripts/test_mode.sh 6 -2 -1 31scripts/test_mode.sh 7 -2 -1 32scripts/test_mode.sh 8 -2 -1 33scripts/test_mode.sh 9 0 0 34scripts/test_mode.sh 10 0 0 35scripts/test_mode.sh 11 0 0 36set +e 37[[ "$(./minimp3)" != "error: no file names given" ]] && echo fail && exit 1 || echo pass 38[[ "$(./minimp3 do_not_exist)" != "error: read function failed, code=-3" ]] && echo fail && exit 1 || echo pass 39[[ "$(./minimp3 -z)" != "error: unrecognized option" ]] && echo fail && exit 1 || echo pass 40[[ "$(./minimp3 -m -1 vectors/l3-sin1k0db.bit)" != "error: unknown mode" ]] && echo fail && exit 1 || echo pass 41[[ ! "$(./minimp3 vectors/l3-nonstandard-id3v1.bit vectors/ILL2_mono.pcm)" =~ "rate=48000 samples=1152 max_diff=17637 PSNR=15" ]] && echo fail && exit 1 || echo pass 42[[ "$(./minimp3 vectors/l3-nonstandard-id3v1.bit - temp.pcm)" != "rate=48000 samples=1152 max_diff=0 PSNR=99.000000" ]] && echo fail && exit 1 || echo pass 43rm temp.pcm 44 45[[ "$(./minimp3 -m 2 -e 0 vectors/l3-sin1k0db.bit)" != "error: read function failed, code=-3" ]] && echo fail && exit 1 || echo pass 46[[ "$(./minimp3 -m 2 -e 1 vectors/l3-sin1k0db.bit)" != "error: read function failed, code=-3" ]] && echo fail && exit 1 || echo pass 47[[ "$(./minimp3 -m 2 -e 2 vectors/l3-sin1k0db.bit)" != "error: read function failed, code=-3" ]] && echo fail && exit 1 || echo pass 48[[ "$(./minimp3 -m 2 -e 3 vectors/l3-sin1k0db.bit vectors/l3-sin1k0db.pcm)" != "error: reference and produced number of samples do not match (725760/716544)" ]] && echo fail && exit 1 || echo pass 49[[ "$(./minimp3 -m 2 -e 2 vectors/l3-nonstandard-id3v2.bit)" != "error: read function failed, code=-3" ]] && echo fail && exit 1 || echo pass 50[[ "$(./minimp3 -m 2 -e 3 vectors/l3-nonstandard-id3v2.bit)" != "error: read function failed, code=-3" ]] && echo fail && exit 1 || echo pass 51 52[[ "$(./minimp3 -m 5 -e 1 vectors/l3-nonstandard-id3v2.bit)" != "error: read function failed, code=-3" ]] && echo fail && exit 1 || echo pass 53[[ "$(./minimp3 -m 5 -e 2 vectors/l3-nonstandard-id3v2.bit)" != "error: read function failed, code=-3" ]] && echo fail && exit 1 || echo pass 54 55[[ "$(./minimp3 -m 8 -e 0 vectors/l3-sin1k0db.bit)" != "error: mp3dec_ex_open()=-3 failed" ]] && echo fail && exit 1 || echo pass 56[[ "$(./minimp3 -m 8 -e 1 vectors/l3-sin1k0db.bit)" != "error: mp3dec_ex_open()=-3 failed" ]] && echo fail && exit 1 || echo pass 57[[ "$(./minimp3 -m 8 -e 2 vectors/l3-sin1k0db.bit)" != "error: mp3dec_ex_open()=-3 failed" ]] && echo fail && exit 1 || echo pass 58[[ "$(./minimp3 -m 8 -e 3 vectors/l3-sin1k0db.bit)" != "error: mp3dec_ex_open()=-3 failed" ]] && echo fail && exit 1 || echo pass 59[[ "$(./minimp3 -m 8 -e 4 vectors/l3-sin1k0db.bit)" != "error: mp3dec_ex_open()=-3 failed" ]] && echo fail && exit 1 || echo pass 60[[ "$(./minimp3 -m 8 -e 5 vectors/l3-sin1k0db.bit)" != "error: mp3dec_ex_read() readed less than expected, last_error=-3" ]] && echo fail && exit 1 || echo pass 61 62[[ "$(./minimp3 -m 8 -s 2304 -e 5 vectors/l3-sin1k0db.bit)" != "error: mp3dec_ex_seek()=-3 failed" ]] && echo fail && exit 1 || echo pass 63[[ "$(./minimp3 -m 8 -s 2304 -e 6 vectors/l3-sin1k0db.bit)" != "error: mp3dec_ex_seek()=-3 failed" ]] && echo fail && exit 1 || echo pass 64[[ "$(./minimp3 -m 8 -s 2304 -e 7 vectors/l3-sin1k0db.bit)" != "error: mp3dec_ex_seek()=-3 failed" ]] && echo fail && exit 1 || echo pass 65[[ "$(./minimp3 -m 8 -s 2304 -e 8 vectors/l3-sin1k0db.bit)" != "error: mp3dec_ex_seek()=-3 failed" ]] && echo fail && exit 1 || echo pass 66[[ "$(./minimp3 -m 8 -s 2304 -e 9 vectors/l3-sin1k0db.bit)" != "error: mp3dec_ex_seek()=-3 failed" ]] && echo fail && exit 1 || echo pass 67[[ "$(./minimp3 -m 8 -s 2304 -e 12 vectors/l3-sin1k0db.bit)" != "error: mp3dec_ex_seek()=-3 failed" ]] && echo fail && exit 1 || echo pass 68[[ "$(./minimp3 -m 8 -s 2304 -e 4 vectors/l3-nonstandard-sin1k0db_lame_vbrtag.bit)" != "error: mp3dec_ex_seek()=-3 failed" ]] && echo fail && exit 1 || echo pass 69 70[[ "$(./minimp3 vectors/l3-nonstandard-id3v2-only.bit vectors/l3-nonstandard-id3v2-only.pcm)" != "rate=0 samples=0 max_diff=0 PSNR=99.000000" ]] && echo fail && exit 1 || echo pass 71[[ "$(./minimp3 -m 3 vectors/l3-nonstandard-id3v2-only.bit vectors/l3-nonstandard-id3v2-only.pcm)" != "rate=0 samples=0 max_diff=0 PSNR=99.000000" ]] && echo fail && exit 1 || echo pass 72 73[[ "$(./minimp3 -m 2 vectors/l3-nonstandard-small.bit vectors/l3-nonstandard-small.pcm)" != "rate=0 samples=0 max_diff=0 PSNR=99.000000" ]] && echo fail && exit 1 || echo pass 74[[ "$(./minimp3 -m 5 vectors/l3-nonstandard-small.bit vectors/l3-nonstandard-small.pcm)" != "rate=0 samples=0 max_diff=0 PSNR=99.000000" ]] && echo fail && exit 1 || echo pass 75 76[[ "$(./minimp3 -m 6 -s 215 -b vectors/l3-sin1k0db.bit -)" != "rate=44100 samples=725760 max_diff=0 PSNR=99.000000" ]] && echo fail && exit 1 || echo pass 77[[ "$(./minimp3 -m 6 -s 633 -b vectors/l3-sin1k0db.bit -)" != "rate=44100 samples=723456 max_diff=0 PSNR=99.000000" ]] && echo fail && exit 1 || echo pass 78 79[[ "$(./minimp3 -f 0 vectors/l3-sin1k0db.bit vectors/l3-sin1k0db.pcm)" != "error: not enough memory" ]] && echo fail && exit 1 || echo pass 80[[ "$(./minimp3 -f 1 vectors/l3-sin1k0db.bit vectors/l3-sin1k0db.pcm)" != "error: read function failed, code=-3" ]] && echo fail && exit 1 || echo pass 81[[ "$(./minimp3 -f 2 vectors/l3-sin1k0db.bit vectors/l3-sin1k0db.pcm)" != "error: read function failed, code=-2" ]] && echo fail && exit 1 || echo pass 82[[ "$(./minimp3 -f 3 vectors/l3-sin1k0db.bit vectors/l3-sin1k0db.pcm)" != "error: read function failed, code=-2" ]] && echo fail && exit 1 || echo pass 83 84[[ "$(./minimp3 -m 2 -f 0 vectors/l3-sin1k0db.bit)" != "error: not enough memory" ]] && echo fail && exit 1 || echo pass 85[[ "$(./minimp3 -m 2 -f 1 vectors/l3-sin1k0db.bit)" != "error: read function failed, code=-2" ]] && echo fail && exit 1 || echo pass 86[[ "$(./minimp3 -m 2 -f 2 vectors/l3-sin1k0db.bit)" != "error: read function failed, code=-2" ]] && echo fail && exit 1 || echo pass 87[[ "$(./minimp3 -m 2 -f 3 vectors/l3-sin1k0db.bit)" != "error: read function failed, code=-2" ]] && echo fail && exit 1 || echo pass 88 89[[ "$(./minimp3 -m 3 -f 1 vectors/l3-sin1k0db.bit)" != "error: read function failed, code=-2" ]] && echo fail && exit 1 || echo pass 90 91[[ "$(./minimp3 -m 6 -f 1 vectors/l3-sin1k0db.bit)" != "error: mp3dec_ex_open()=-2 failed" ]] && echo fail && exit 1 || echo pass 92 93[[ "$(./minimp3 -m 8 -f 0 vectors/l3-sin1k0db.bit)" != "error: mp3dec_ex_open()=-2 failed" ]] && echo fail && exit 1 || echo pass 94[[ "$(./minimp3 -m 8 -f 1 vectors/l3-sin1k0db.bit)" != "error: mp3dec_ex_open()=-2 failed" ]] && echo fail && exit 1 || echo pass 95 96[[ "$(./minimp3 -m 8 -s 1 vectors/l3-nonstandard-vbrtag-only.bit)" != "error: mp3dec_ex_read() readed less than expected, last_error=0" ]] && echo fail && exit 1 || echo pass 97[[ "$(./minimp3 -m 8 -s 1 -e 4 vectors/l3-nonstandard-vbrtag-only.bit)" != "error: mp3dec_ex_seek()=-3 failed" ]] && echo fail && exit 1 || echo pass 98[[ "$(./minimp3 -m 8 -s 1 -e 5 vectors/l3-nonstandard-vbrtag-only.bit)" != "error: mp3dec_ex_seek()=-3 failed" ]] && echo fail && exit 1 || echo pass 99[[ "$(./minimp3 -m 6 -s 1 -f 2 vectors/l3-nonstandard-sin1k0db_lame_vbrtag.bit)" != "error: mp3dec_ex_seek()=-2 failed" ]] && echo fail && exit 1 || echo pass 100[[ "$(./minimp3 vectors/l3-nonstandard-vbrtag-empty.bit)" != "rate=0 samples=0 max_diff=0 PSNR=99.000000" ]] && echo fail && exit 1 || echo pass 101# Currently vbrtag with no frames flag treated as no vbrtag, not sure if any software produce such files. 102# Delay and padding usage can be implemented if such software/files exists. 103[[ "$(./minimp3 vectors/l3-nonstandard-vbrtag-noframes.bit)" != "rate=44100 samples=0 max_diff=0 PSNR=99.000000" ]] && echo fail && exit 1 || echo pass 104[[ "$(./minimp3 -m 6 vectors/l3-nonstandard-vbrtag-noframes.bit)" != "rate=44100 samples=0 max_diff=0 PSNR=99.000000" ]] && echo fail && exit 1 || echo pass 105 106[[ "$(./minimp3 -m 9 vectors/l3-sin1k0db.pcm)" != "info: not an mp3/mpa file" ]] && echo fail && exit 1 || echo pass 107[[ "$(./minimp3 -m 9 vectors/l3-nonstandard-small.bit)" != "info: not an mp3/mpa file" ]] && echo fail && exit 1 || echo pass 108[[ "$(./minimp3 -m 11 -e 0 vectors/l3-sin1k0db.bit)" != "error: mp3dec_detect*()=-3 failed" ]] && echo fail && exit 1 || echo pass 109[[ "$(./minimp3 -m 11 -e 1 vectors/l3-sin1k0db.bit)" != "error: mp3dec_detect*()=-3 failed" ]] && echo fail && exit 1 || echo pass 110[[ "$(./minimp3 -m 11 -e 2 vectors/l3-sin1k0db.bit)" != "error: mp3dec_detect*()=-3 failed" ]] && echo fail && exit 1 || echo pass 111set -e 112 113./minimp3 -m 6 -s 215 -b vectors/l3-sin1k0db.bit vectors/l3-sin1k0db.pcm 114./minimp3 -m 6 -s 633 -b vectors/l3-sin1k0db.bit vectors/l3-sin1k0db_ofs633.pcm 115./minimp3 -m 8 -s 215 -b vectors/l3-sin1k0db.bit vectors/l3-sin1k0db.pcm 116./minimp3 -m 8 -s 633 -b vectors/l3-sin1k0db.bit vectors/l3-sin1k0db_ofs633.pcm 117 118./minimp3 -m 6 -s 2304 vectors/l3-sin1k0db.bit vectors/l3-sin1k0db.pcm 119./minimp3 -m 8 -s 2304 vectors/l3-sin1k0db.bit vectors/l3-sin1k0db.pcm 120./minimp3 -m 8 -p 2000 vectors/l3-nonstandard-sin1k0db_lame_vbrtag.bit vectors/l3-nonstandard-sin1k0db_lame_vbrtag.pcm 121./minimp3 -m 8 -p 725759 vectors/l3-nonstandard-sin1k0db_lame_vbrtag.bit vectors/l3-nonstandard-sin1k0db_lame_vbrtag.pcm 122 123./minimp3 -t vectors/l3-sin1k0db.bit 124 125gcov minimp3_test.c 126 127echo testing x86 w/o sse... 128gcc $CFLAGS -m32 -o minimp3 minimp3_test.c -lm 129scripts/test.sh 130 131echo testing x64... 132gcc $CFLAGS -o minimp3 minimp3_test.c -lm 133scripts/test.sh 134 135echo testing x64 with float output... 136gcc $CFLAGS -DMINIMP3_FLOAT_OUTPUT -o minimp3 minimp3_test.c -lm 137scripts/test.sh 138scripts/test_mode.sh 1 0 0 139scripts/test_mode.sh 2 0 0 140scripts/test_mode.sh 3 0 0 141scripts/test_mode.sh 4 0 0 142scripts/test_mode.sh 5 0 0 143scripts/test_mode.sh 6 -1 -1 144scripts/test_mode.sh 7 -1 -1 145scripts/test_mode.sh 8 -1 -1 146 147echo testing arm w/o neon... 148arm-none-eabi-gcc $CFLAGS -mthumb -mcpu=arm9e -o minimp3_arm minimp3_test.c --specs=rdimon.specs -lm 149qemu-arm ./minimp3_arm 150 151echo testing arm w neon... 152arm-none-eabi-gcc $CFLAGS -marm -mcpu=cortex-a15 -mfpu=neon -mfloat-abi=softfp -o minimp3_arm minimp3_test.c --specs=rdimon.specs -lm 153qemu-arm ./minimp3_arm 154 155echo testing arm64... 156aarch64-linux-gnu-gcc $CFLAGS -static -march=armv8-a -o minimp3_arm minimp3_test.c -lm 157qemu-aarch64 ./minimp3_arm 158 159echo testing powerpc... 160powerpc-linux-gnu-gcc $CFLAGS -static -o minimp3_ppc minimp3_test.c -lm 161qemu-ppc ./minimp3_ppc 162 163if [ ! "$TRAVIS" = "true" ]; then 164echo testing powerpc64... 165powerpc64-linux-gnu-gcc $CFLAGS -static -o minimp3_ppc minimp3_test.c -lm 166qemu-ppc64 ./minimp3_ppc 167fi 168 169if [ ! "$TRAVIS" = "true" ]; then 170rm emmintrin.h.gcov minimp3_arm minimp3_ppc minimp3_test.gcda minimp3_test.gcno minimp3_test.c.gcov xmmintrin.h.gcov 171fi 172