| 1 |
#!/bin/sh |
| 2 |
# Copyright 2020 Collabora Ltd. |
| 3 |
# Copyright 2020 Simon McVittie |
| 4 |
# SPDX-License-Identifier: BSD-3-clause |
| 5 |
|
| 6 |
set -eux |
| 7 |
|
| 8 |
if [ -n "${AUTOPKGTEST_ARTIFACTS-}" ]; then |
| 9 |
WORKDIR="$AUTOPKGTEST_ARTIFACTS" |
| 10 |
else |
| 11 |
WORKDIR="$(mktemp -d)" |
| 12 |
trap 'cd /; rm -fr "$WORKDIR"' 0 INT QUIT ABRT PIPE TERM |
| 13 |
fi |
| 14 |
|
| 15 |
if [ -n "${DEB_HOST_GNU_TYPE:-}" ]; then |
| 16 |
CROSS_COMPILE="$DEB_HOST_GNU_TYPE-" |
| 17 |
else |
| 18 |
CROSS_COMPILE= |
| 19 |
fi |
| 20 |
|
| 21 |
# The example programs don't include the headers in the same way that |
| 22 |
# third-party software is expected to |
| 23 |
for program in vorbisfile seeking; do |
| 24 |
sed -e 's,#include "ivorbis\(.*\)",#include <tremor/ivorbis\1>,g' \ |
| 25 |
< "i${program}_example.c" > "$WORKDIR/$program.c" |
| 26 |
done |
| 27 |
|
| 28 |
cd "$WORKDIR" |
| 29 |
|
| 30 |
for program in vorbisfile seeking; do |
| 31 |
# Deliberately word-splitting pkg-config's output: |
| 32 |
# shellcheck disable=SC2046 |
| 33 |
"${CROSS_COMPILE}gcc" -o"$program" "$program.c" \ |
| 34 |
$("${CROSS_COMPILE}pkg-config" --cflags --libs vorbisidec) |
| 35 |
done |
| 36 |
|
| 37 |
./seeking < /usr/share/sounds/freedesktop/stereo/bell.oga |
| 38 |
|
| 39 |
./vorbisfile < /usr/share/sounds/freedesktop/stereo/bell.oga > ivorbis.raw |
| 40 |
|
| 41 |
# Additional manual test: |
| 42 |
# |
| 43 |
# aplay -t raw -f S16_LE -c 2 -r 44100 "$AUTOPKGTEST_ARTIFACTS/ivorbis.raw" |
| 44 |
# ogg123 /usr/share/sounds/freedesktop/stereo/bell.oga |
| 45 |
# |
| 46 |
# should sound roughly the same. They are not precisely the same due to |
| 47 |
# different rounding(?), so we can't do a reference decode with oggdec and |
| 48 |
# use cmp to assert they are identical. |