core/tests: Write a script to generate empty albums

gen_tracks.sh will read a specially configured file and create a
directory containing empty tracks to use for testing.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-12-04 10:10:10 -05:00
parent 92806c5201
commit 18311afcfe
5 changed files with 61 additions and 0 deletions

1
tests/.gitignore vendored
View File

@ -1,3 +1,4 @@
*-core
*-lib
sanity
*.ogg

View File

@ -0,0 +1,16 @@
Koji Kondo
1998 Hyrule Symphony
Game
243 Title Theme
130 Kokiri Forest
227 Hyrule Field
130 Hyrule Castle
206 Lon Lon Ranch
186 Kakariko Village
178 Death Mountain
221 Zora's Domain
273 Gerudo Valley
66 Ganondorf
185 Princess Zelda
232 Ocarina Medley
288 The Legend of Zelda Medley

7
tests/Music/Sconscript Normal file
View File

@ -0,0 +1,7 @@
#!/usr/bin/python
import subprocess
albums = [ "Hyrule_Symphony.album" ]
for album in albums:
subprocess.call(["sh", "gen_tracks.sh", album])

34
tests/Music/gen_tracks.sh Normal file
View File

@ -0,0 +1,34 @@
#!/bin/bash
TRACK=1
FFMPEG="ffmpeg -hide_banner -nostdin -f s16le -i /dev/zero -codec libvorbis -loglevel warning"
while read -r line; do
if [ -z "$ARTIST" ]; then
ARTIST="$line"
elif [ -z "$ALBUM" ]; then
YEAR=$(echo "$line" | cut -f 1 -d ' ')
ALBUM=$(echo "$line" | cut -f 1 -d ' ' --complement)
mkdir -p "$ALBUM"
elif [ -z "$GENRE" ]; then
GENRE="$line"
else
LENGTH=$(echo "$line" | cut -f 1 -d ' ')
TITLE=$(echo "$line" | cut -f -1 -d ' ' --complement)
NUMBER=$(printf "%02d" $TRACK)
FILE="$ALBUM/$NUMBER - $TITLE.ogg"
if [ ! -f "$FILE" ]; then
echo "$FILE"
$FFMPEG -t "$LENGTH" "$FILE"
vorbiscomment -w "$FILE" -t "TITLE=$TITLE" \
-t "ARTIST=$ARTIST" \
-t "ALBUM=$ALBUM" \
-t "GENRE=$GENRE" \
-t "DATE=$YEAR" \
-t "TRACKNUMBER=$NUMBER"
fi
let TRACK=$TRACK+1
fi
done < $1

View File

@ -26,6 +26,9 @@ def UnitTest(test, sources):
return run
Export("UnitTest")
#Generate empty audio files
SConscript("Music/Sconscript")
res = SConscript("core/Sconscript")
if check_sanity == True:
res = [ UnitTest("sanity", [ "sanity.c" ]) ] + res