summaryrefslogtreecommitdiff
path: root/tests/run_vectors.sh
blob: 81b68f3cb01af22e3a00e64896dac599e543058e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/sh

if [ "$#" -ne "2" ]; then
    echo "usage: run_vectors.sh <exec path> <vector path>"
    exit 1
fi

CMD_PATH=$1
VECTOR_PATH=$2

OPUS_DEMO=$CMD_PATH/opus_demo
OPUS_COMPARE=$CMD_PATH/opus_compare

if [ -d $VECTOR_PATH ]; then
    echo Test vectors found in $VECTOR_PATH
else
    echo No test vectors found
    #Don't make the test fail here because the test vectors will be 
    #distributed separateyl
    exit 0
fi

if [ -x $OPUS_DEMO ]; then
    echo Decoding with $OPUS_DEMO
else
    echo ERROR: Decoder not found: $OPUS_DEMO
    exit 1
fi

echo "=============="
echo Testing mono
echo "=============="
echo

for file in test1_mono test2_mono test3_mono test4_mono test5_mono
do
    if [ -e $VECTOR_PATH/$file.bit ]; then
        echo Testing $file
    else 
        echo Bitstream file not found: $file
    fi
    if $OPUS_DEMO -d 48000 1 $VECTOR_PATH/$file.bit tmp.out > /dev/null 2>&1; then
        echo successfully decoded
    else
        echo ERROR: decoding failed
        exit 1
    fi
    $OPUS_COMPARE $VECTOR_PATH/$file.float tmp.out > /dev/null 2>&1
    float_ret=$?
    $OPUS_COMPARE $VECTOR_PATH/$file.fixed tmp.out > /dev/null 2>&1
    fixed_ret=$?
    if [ "$float_ret" -eq "0" -o "$fixed_ret" -eq "0" ]; then
        echo output matches reference
    else
        echo ERROR: output does not match reference
        exit 1
    fi
    echo
done

echo "=============="
echo Testing stereo
echo "=============="
echo

for file in test1_stereo test2_stereo test3_stereo test4_stereo
do
    if [ -e $VECTOR_PATH/$file.bit ]; then
        echo Testing $file
    else 
        echo Bitstream file not found: $file
    fi
    if $OPUS_DEMO -d 48000 2 $VECTOR_PATH/$file.bit tmp.out > /dev/null 2>&1; then
        echo successfully decoded
    else
        echo ERROR: decoding failed
        exit 1
    fi
    $OPUS_COMPARE -s $VECTOR_PATH/$file.float tmp.out > /dev/null 2>&1
    float_ret=$?
    $OPUS_COMPARE -s $VECTOR_PATH/$file.fixed tmp.out > /dev/null 2>&1
    fixed_ret=$?
    if [ "$float_ret" -eq "0" -o "$fixed_ret" -eq "0" ]; then
        echo output matches reference
    else
        echo ERROR: output does not match reference
        exit 1
    fi
    echo
done



echo All tests have passed successfully