Debian Codegraph @

debian/tests/test-decode

raw
1 #!/bin/bash
2
3 set -e
4
5 DECODE=/usr/bin/heif-dec
6 if [ ! -f /usr/bin/heif-dec ]; then
7 # Running from "override_dh_auto_test" in debian/rules during package build.
8 DEB_HOST_GNU_TYPE=$(dpkg-architecture -qDEB_HOST_GNU_TYPE)
9 DECODE=./obj-$DEB_HOST_GNU_TYPE/examples/heif-dec
10 fi
11
12 if [ ! -f "$DECODE" ]; then
13 echo Decode utility not found
14 exit 1
15 fi
16
17 output=$(mktemp)
18 tmpdir=$(mktemp -d)
19
20 decode_file() {
21 local filename="$1"
22 local destination="$2"
23 set +e
24 "$DECODE" "$filename" "$destination" > "$output" 2>&1
25 status=$?
26 set -e
27 if [ $status -ne 0 ]; then
28 echo "Decoding failed, exit code $status"
29 cat "$output"
30 ls -la "$tmpdir"
31 return 255
32 fi
33 }
34
35 check_file() {
36 local filename="$1"
37 if [ ! -f "$filename" ]; then
38 echo "Decoding failed, file $filename not found"
39 cat "$output"
40 ls -la "$tmpdir"
41 return 255
42 fi
43 }
44
45 decode_file "./examples/example.heic" "$tmpdir/example-heic.png"
46 check_file "$tmpdir/example-heic-1.png"
47 check_file "$tmpdir/example-heic-2.png"
48
49 decode_file "./examples/example.avif" "$tmpdir/example-avif.jpg"
50 check_file "$tmpdir/example-avif.jpg"