update test suite with new assert_delta

This commit is contained in:
tildearrow 2022-09-10 17:01:58 -05:00
parent 8e256d4dd5
commit 7c9384a63f
3 changed files with 68 additions and 2 deletions

1
.gitignore vendored
View File

@ -14,6 +14,7 @@ linuxbuild/
test/songs/
test/delta/
test/result/
test/assert_delta
android/.gradle/
android/app/build/
android/app/.cxx/

49
test/assert_delta.c Normal file
View File

@ -0,0 +1,49 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sndfile.h>
#define BUF_SIZE 8192
// usage: assert_delta file
// return values:
// - 0: pass (file is silence)
// - 1: fail (noise found)
// - 2: command line error
// - 3: file open error
int main(int argc, char** argv) {
if (argc<2) return 2;
SF_INFO si;
memset(&si,0,sizeof(SF_INFO));
SNDFILE* sf=sf_open(argv[1],SFM_READ,&si);
if (sf==NULL) {
fprintf(stderr,"open: %s\n",sf_strerror(NULL));
return 3;
}
if (si.channels<1) {
fprintf(stderr,"invalid channel count\n");
return 3;
}
float* buf=malloc(BUF_SIZE*si.channels*sizeof(float));
sf_count_t totalRead=0;
size_t seekPos=0;
while ((totalRead=sf_readf_float(sf,buf,BUF_SIZE))!=0) {
for (int i=0; i<totalRead*si.channels; i++) {
if (buf[i]!=0.0f) {
printf("%ld\n",seekPos+(i/si.channels));
sf_close(sf);
free(buf);
return 1;
}
}
seekPos+=BUF_SIZE;
}
sf_close(sf);
free(buf);
return 0;
}

View File

@ -12,6 +12,14 @@ fi
echo "lastTest is $lastTest"
if [ -e "test/assert_delta" ]; then
echo "assert_delta present."
else
echo "compiling assert_delta..."
gcc -Wall -Wextra -Werror -o "test/assert_delta" "test/assert_delta.c" -lsndfile || exit 1
fi
echo "furnace test suite begin..."
echo "--- STEP 1: render test files"
mkdir -p "test/result/$testDir" || exit 1
@ -23,9 +31,17 @@ else
mkdir -p "test/delta/$testDir" || exit 1
ls "test/result/$testDir/" | parallel --verbose -j4 ffmpeg -i "test/result/$lastTest/{0}" -i "test/result/$testDir/{0}" -filter_complex stereotools=phasel=1:phaser=1,amix=inputs=2:duration=longest -c:a pcm_s16le -y "test/delta/$testDir/{0}"
fi
echo "--- STEP 3: make delta images"
echo "--- STEP 3: check deltas"
if [ -z $lastTest ]; then
echo "skipping since this apparently is your first run."
else
ls "test/result/$testDir/" | parallel --verbose -j4 ffmpeg -i "test/delta/$testDir/{0}" -lavfi showspectrumpic "test/delta/$testDir/{0}.png"
for i in `ls "test/result/$testDir"`; do
echo -n "$i... "
if ./test/assert_delta "test/delta/$testDir/$i"; then
echo "OK"
else
echo "FAIL FAIL FAIL"
ffmpeg -loglevel quiet -i "test/delta/$testDir/$i" -lavfi showspectrumpic "test/delta/$testDir/$i.png"
fi
done
fi