aboutsummaryrefslogtreecommitdiff
path: root/tests/m4a/run.sh
blob: 0a1a98e7600e56b787555c501ab3c58183c328cc (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
#!/bin/sh
# Host check of libm4a's index parser (lib/rbcodec/codecs/libm4a/demux.c):
# runs qtmovie_read() on an M4B through a model of the playback buffer and
# prints the seek table it builds and what it cost (buffer calls, card
# reads, rebuffers, yields).
#
#   tests/m4a/run.sh FILE.m4b [HEAP_BYTES] [ROCKBOX_TREE] [STOP_AFTER]
# STOP_AFTER: load_progress says "stop" from that call on, and the load
# must give up there.
set -eu
HERE=$(cd "$(dirname "$0")" && pwd)
REPO=$(cd "$HERE/../.." && pwd)
FILE=$1
HEAP=${2:-65536}
TREE=${3:-$REPO/build/rockbox}
STOP=${4:-}
M4A=$TREE/lib/rbcodec/codecs/libm4a
T=$(mktemp -d)
trap 'rm -rf "$T"' EXIT
# m4a.c's stream_* helpers, up to stream_create() (its seek code needs the
# whole codec API)
awk '{print} /^void stream_create/{f=1} f && /^}/{exit}' "$M4A/m4a.c" > "$T/stream.c"
gcc -O2 -g -fsanitize=address,undefined -fno-sanitize-recover=all \
    -Wall -Wno-unused-parameter -Wno-unused-function -Wno-unused-variable \
    -I"$HERE/shim" -I"$M4A" -o "$T/harness" \
    "$HERE/harness.c" "$M4A/demux.c" "$T/stream.c"
"$T/harness" "$FILE" "$HEAP" $STOP