sampledata.sh 1.99 KB
Newer Older
1
#!/bin/sh
2
3
4
5
6
#
# This test uses CCSDS sample data to check decoding and re-encoding.
# Encoded size checks are performed where same size results are to be
# expected.
#
7
set -e
8
AEC="../src/aec"
9
10
11
if [ -n "$1" ]; then
    srcdir=$1
fi
12
13
14
15
CCSDS_DATA="${srcdir}/../data/121B2TestData"
ALLO="${CCSDS_DATA}/AllOptions"
EXTP="${CCSDS_DATA}/ExtendedParameters"
LOWE="${CCSDS_DATA}/LowEntropyOptions"
16

Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
17
filesize () {
18
    wc -c "$1" | awk '{print $1}'
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
19
20
}

21
decode () {
22
23
    "$AEC" -d $3 "$1" test.dat
    dd if=test.dat bs=1 count=$(filesize "$2") | cmp "$2" -
24
25
26
}

code () {
27
28
    "$AEC" $3 "$2" test.rz
    cmp "$1" test.rz
29
30
31
}

code_size () {
32
33
    "$AEC" $3 "$2" test.rz
    if [ ! $(filesize test.rz) -eq $(filesize "$1") ]; then
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
        echo "$1 size mismatch"
        exit 1
    fi
}

codec () {
    code "$@"
    decode "$@"
}

cosdec () {
    code_size "$@"
    decode "$@"
}

49
50
51
echo All Options
for i in 01 02 03 04
do
52
53
54
    uf="${ALLO}/test_p256n${i}.dat"
    codec "${ALLO}/test_p256n${i}-basic.rz" "${uf}" "-n$i -j16 -r16"
    codec "${ALLO}/test_p256n${i}-restricted.rz" "${uf}" "-n$i -j16 -r16 -t"
55
56
57
done
for i in 05 06 07 08 09 10 11 12 13 14 15 16
do
58
    cosdec "${ALLO}/test_p256n${i}.rz" "$ALLO/test_p256n${i}.dat" \
59
        "-n$i -j16 -r16"
60
61
62
done
for i in 17 18 19 20 21 22 23 24
do
63
    cosdec "${ALLO}/test_p512n${i}.rz" "$ALLO/test_p512n${i}.dat" \
64
        "-n$i -j16 -r32"
65
66
67
68
69
70
71
done

echo Low Entropy Options
for i in 1 2 3
do
    for j in 01 02 03 04
    do
72
73
74
75
        uf="${LOWE}/Lowset${i}_8bit.dat"
        codec "${LOWE}/Lowset${i}_8bit.n${j}-basic.rz" "${uf}" "-n$j -j16 -r64"
        codec "${LOWE}/Lowset${i}_8bit.n${j}-restricted.rz" "${uf}" \
              "-n$j -j16 -r64 -t"
76
77
78
    done
    for j in 05 06 07 08
    do
79
        codec "${LOWE}/Lowset${i}_8bit.n${j}.rz" "$LOWE/Lowset${i}_8bit.dat" \
80
            "-n$j -j16 -r64"
81
82
83
84
    done
done

echo Extended Parameters
85
86
87
88
decode "${EXTP}/sar32bit.j16.r256.rz" "${EXTP}/sar32bit.dat" \
       "-n32 -j16 -r256 -p"
decode "${EXTP}/sar32bit.j64.r4096.rz" "${EXTP}/sar32bit.dat" \
       "-n32 -j64 -r4096 -p"