aboutsummaryrefslogtreecommitdiff
path: root/tests/m4a/run.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/m4a/run.sh')
-rwxr-xr-xtests/m4a/run.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/m4a/run.sh b/tests/m4a/run.sh
new file mode 100755
index 0000000..0a1a98e
--- /dev/null
+++ b/tests/m4a/run.sh
@@ -0,0 +1,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