add more tests and with more options
[platform/upstream/flac.git] / test / test_streams.sh
1 #!/bin/sh
2
3 LD_LIBRARY_PATH=../src/libFLAC/.libs:../obj/lib:$LD_LIBRARY_PATH
4 export LD_LIBRARY_PATH
5 PATH=../src/flac:../src/test_streams:../obj/bin:$PATH
6
7 if test_streams ; then : ; else
8         echo "ERROR during test_streams" 1>&2
9         exit 1
10 fi
11
12 test_file ()
13 {
14         name=$1
15         channels=$2
16         bps=$3
17         encode_options="$4"
18
19         echo -n "$name: encode..."
20         cmd="flac -V -s -fr -fb -fs 44100 -fp $bps -fc $channels $encode_options $name.raw $name.flac"
21         echo "### ENCODE $name #######################################################" >> ./streams.log
22         echo "###    cmd=$cmd" >> ./streams.log
23         if $cmd 1>/dev/null 2>>./streams.log ; then : ; else
24                 echo "ERROR during encode of $name" 1>&2
25                 exit 1
26         fi
27         echo -n "decode..."
28         cmd="flac -s -fb -d -fr $name.flac $name.cmp";
29         echo "### DECODE $name #######################################################" >> ./streams.log
30         echo "###    cmd=$cmd" >> ./streams.log
31         if $cmd 2>>./streams.log ; then : ; else
32                 echo "ERROR during decode of $name" 1>&2
33                 exit 1
34         fi
35         ls -1l $name.raw >> ./streams.log
36         ls -1l $name.flac >> ./streams.log
37         ls -1l $name.cmp >> ./streams.log
38         echo -n "compare..."
39         if cmp $name.raw $name.cmp ; then : ; else
40                 echo "ERROR during compare of $name" 1>&2
41                 exit 1
42         fi
43         echo OK
44 }
45
46 echo "Testing small files..."
47 test_file test01 1 16 "-0 -l 8 -m -e"
48 test_file test02 2 16 "-0 -l 8 -m -e"
49 test_file test03 1 16 "-0 -l 8 -m -e"
50 test_file test04 2 16 "-0 -l 8 -m -e"
51
52 echo "Testing 8-bit full-scale deflection streams..."
53 for b in 01 02 03 04 05 06 07 ; do
54         test_file fsd8-$b 1 8 "-0 -l 8 -m -e -q 15"
55 done
56
57 echo "Testing 16-bit full-scale deflection streams..."
58 for b in 01 02 03 04 05 06 07 ; do
59         test_file fsd16-$b 1 16 "-0 -l 8 -m -e -q 15"
60 done
61
62 echo "Testing sine wave streams..."
63 for b in 00 01 02 03 04 ; do
64         test_file sine-$b 1 16 "-0 -l 8 -m -e"
65 done
66 for b in 10 11 12 13 14 15 16 17 18 19 ; do
67         test_file sine-$b 2 16 "-0 -l 8 -m -e"
68 done
69
70 echo "Testing some frame header variations..."
71 test_file sine-01 1 16 "-0 -l 8 -m -e --lax -b 16"
72 test_file sine-01 1 16 "-0 -l 8 -m -e --lax -b 65535"
73 test_file sine-01 1 16 "-0 -l 8 -m -e -b 16"
74 test_file sine-01 1 16 "-0 -l 8 -m -e -b 65535"
75 test_file sine-01 1 16 "-0 -l 8 -m -e --lax -fs 9"
76 test_file sine-01 1 16 "-0 -l 8 -m -e --lax -fs 90"
77 test_file sine-01 1 16 "-0 -l 8 -m -e --lax -fs 90000"
78 test_file sine-01 1 16 "-0 -l 8 -m -e -fs 9"
79 test_file sine-01 1 16 "-0 -l 8 -m -e -fs 90"
80 test_file sine-01 1 16 "-0 -l 8 -m -e -fs 90000"
81
82 echo "Testing option variations..."
83 for f in 00 01 02 03 04 ; do
84         for opt in 0 1 2 4 5 6 8 ; do
85                 for extras in fr p e ; do
86                         test_file sine-$f 1 16 "-$opt -$extras"
87                 done
88         done
89 done
90 for f in 10 11 12 13 14 15 16 17 18 19 ; do
91         for opt in 0 1 2 4 5 6 8 ; do
92                 for extras in fr p e ; do
93                         test_file sine-$f 2 16 "-$opt -$extras"
94                 done
95         done
96 done
97
98 echo "Testing noise..."
99 for opt in 0 1 2 4 5 6 8 ; do
100         for extras in fr p e ; do
101                 for blocksize in '' '-b 32' '-b 32768' '-b 65535' ; do
102                         for channels in 1 2 4 ; do
103                                 for bps in 8 16 ; do
104                                         test_file noise $channels $bps "-$opt -$extras $blocksize"
105                                 done
106                         done
107                 done
108         done
109 done