changeset 117:5be4995f4029

Tests (and minor resulting fixes) for remote file download
author Chris Cannam
date Wed, 08 Oct 2014 13:14:39 +0100
parents 1c0799754670
children 0fe5abb56a6e eb0f3a2029b8
files .hgsubstate runner/FeatureExtractionManager.cpp runner/main.cpp tests/audio/6clicks.ogg tests/audio/playlist.m3u tests/expected/transforms-summaries-percussiononsets-all-files.csv tests/expected/transforms-summaries-percussiononsets-playlist.csv tests/test-multiple-audio.sh
diffstat 8 files changed, 81 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/.hgsubstate	Fri Oct 03 15:42:55 2014 +0100
+++ b/.hgsubstate	Wed Oct 08 13:14:39 2014 +0100
@@ -1,2 +1,2 @@
 d16f0fd6db6104d87882bc43788a3bb1b0f8c528 dataquay
-7a8f7a553b37bf8054cff054a4561271f897506e svcore
+60e2927b1475b752d14615da9516d893332878a3 svcore
--- a/runner/FeatureExtractionManager.cpp	Fri Oct 03 15:42:55 2014 +0100
+++ b/runner/FeatureExtractionManager.cpp	Wed Oct 08 13:14:39 2014 +0100
@@ -453,7 +453,11 @@
         FileSource source(audioSource, &retrievalProgress);
         if (!source.isAvailable()) {
             cerr << "ERROR: File or URL \"" << audioSource.toStdString()
-                 << "\" could not be located" << endl;
+                 << "\" could not be located";
+            if (source.getErrorString() != "") {
+                cerr << ": " << source.getErrorString();
+            }
+            cerr << endl;
             throw FileNotFound(audioSource);
         }
     
--- a/runner/main.cpp	Fri Oct 03 15:42:55 2014 +0100
+++ b/runner/main.cpp	Wed Oct 08 13:14:39 2014 +0100
@@ -354,14 +354,17 @@
 {
     QStringList expanded;
     foreach (QString path, sources) {
-        cerr << "expandPlaylists: looking at " << path << endl;
         if (QFileInfo(path).suffix().toLower() == "m3u") {
             ProgressPrinter retrievalProgress("Opening playlist file...");
             FileSource source(path, &retrievalProgress);
             if (!source.isAvailable()) {
-                cerr << "ERROR: File or URL \"" << path.toStdString()
-                     << "\" could not be located" << endl;
-                throw FileNotFound(path);
+                // Don't fail or throw an exception here, just keep
+                // the file in the list -- it will be tested again
+                // when adding it as a source and that's the proper
+                // time to fail. All we're concluding here is that it
+                // isn't a valid playlist
+                expanded.push_back(path);
+                continue;
             }
             source.waitForData();
             PlaylistFileReader reader(source);
@@ -728,7 +731,7 @@
     }
 
     sources = expandPlaylists(sources);
-
+        
     bool good = true;
     QSet<QString> badSources;
 
Binary file tests/audio/6clicks.ogg has changed
--- a/tests/audio/playlist.m3u	Fri Oct 03 15:42:55 2014 +0100
+++ b/tests/audio/playlist.m3u	Wed Oct 08 13:14:39 2014 +0100
@@ -1,2 +1,2 @@
-3clicks8.wav
-6clicks8.wav
+3clicks.mp3
+6clicks.ogg
--- a/tests/expected/transforms-summaries-percussiononsets-all-files.csv	Fri Oct 03 15:42:55 2014 +0100
+++ b/tests/expected/transforms-summaries-percussiononsets-all-files.csv	Wed Oct 08 13:14:39 2014 +0100
@@ -14,6 +14,10 @@
 ,0.000000000,5.201269840,median,168,"(median value, continuous-time average)"
 ,0.000000000,5.201269840,mode,0,"(modal value, continuous-time average)"
 ,0.000000000,5.201269840,mean,677.241,"(mean value, continuous-time average)"
+"./audio/6clicks.ogg",0.000000000,10.031020407,mean,166.612,"(mean value, continuous-time average)"
+,0.000000000,10.031020407,median,167,"(median value, continuous-time average)"
+,0.000000000,10.031020407,mode,170,"(modal value, continuous-time average)"
+,0.000000000,10.031020407,mean,713.148,"(mean value, continuous-time average)"
 "./audio/6clicks8.wav",0.000000000,10.031020407,mean,169.079,"(mean value, continuous-time average)"
 ,0.000000000,10.031020407,median,169,"(median value, continuous-time average)"
 ,0.000000000,10.031020407,mode,164,"(modal value, continuous-time average)"
--- a/tests/expected/transforms-summaries-percussiononsets-playlist.csv	Fri Oct 03 15:42:55 2014 +0100
+++ b/tests/expected/transforms-summaries-percussiononsets-playlist.csv	Wed Oct 08 13:14:39 2014 +0100
@@ -1,8 +1,8 @@
-"3clicks8.wav",0.000000000,5.201269840,mean,162.585,"(mean value, continuous-time average)"
-,0.000000000,5.201269840,median,168,"(median value, continuous-time average)"
+"3clicks.mp3",0.000000000,5.201269840,mean,164.674,"(mean value, continuous-time average)"
+,0.000000000,5.201269840,median,169,"(median value, continuous-time average)"
 ,0.000000000,5.201269840,mode,0,"(modal value, continuous-time average)"
-,0.000000000,5.201269840,mean,677.241,"(mean value, continuous-time average)"
-"6clicks8.wav",0.000000000,10.031020407,mean,169.079,"(mean value, continuous-time average)"
-,0.000000000,10.031020407,median,169,"(median value, continuous-time average)"
-,0.000000000,10.031020407,mode,164,"(modal value, continuous-time average)"
-,0.000000000,10.031020407,mean,695.759,"(mean value, continuous-time average)"
+,0.000000000,5.201269840,mean,680.411,"(mean value, continuous-time average)"
+"6clicks.ogg",0.000000000,10.031020407,mean,166.612,"(mean value, continuous-time average)"
+,0.000000000,10.031020407,median,167,"(median value, continuous-time average)"
+,0.000000000,10.031020407,mode,170,"(modal value, continuous-time average)"
+,0.000000000,10.031020407,mean,713.148,"(mean value, continuous-time average)"
--- a/tests/test-multiple-audio.sh	Fri Oct 03 15:42:55 2014 +0100
+++ b/tests/test-multiple-audio.sh	Wed Oct 08 13:14:39 2014 +0100
@@ -11,6 +11,11 @@
 
 transform=$mypath/transforms/transforms-summaries-percussiononsets-detectionfunction.n3 
 
+urlbase=http://vamp-plugins.org/sonic-annotator/testfiles
+
+
+# 1. Recursive local directory
+
 # Note, the output here depends on all the audio files present -- we
 # would have to regenerate it if we added more test audio files. Note
 # that the -r flag is not supposed to pick up playlist files, only
@@ -22,18 +27,25 @@
 csvcompare $tmpfile $expected.csv || \
     faildiff "Output mismatch for transform $transform with summaries and recursive dir option" $tmpfile $expected.csv
 
-# Here we remove any leading path from the audio file in the output,
+
+# 2. Local playlist file referring to local audio files
+
+# Here we strip any leading path from the audio file in the output,
 # because the playlist reader will have resolved files to absolute
 # paths and those will differ between systems
-$r -t $transform -w csv --csv-stdout $mypath/audio/playlist.m3u --summary-only 2>/dev/null | sed 's,^"\.*/[^"]*/,",' > $tmpfile || \
+$r -t $transform -w csv --csv-stdout $mypath/audio/playlist.m3u --summary-only 2>/dev/null | sed 's,^"[^"]*/,",' > $tmpfile || \
     fail "Fails to run transform $transform with playlist input"
 
 expected=$mypath/expected/transforms-summaries-percussiononsets-playlist
 csvcompare $tmpfile $expected.csv || \
     faildiff "Output mismatch for transform $transform with summaries and playlist input" $tmpfile $expected.csv
 
-# Same here, just so we can use the same output comparison file as above
-$r -t $transform -w csv --csv-stdout $mypath/audio/3clicks8.wav $mypath/audio/6clicks8.wav --summary-only 2>/dev/null | sed 's,^"\.*/[^"]*/,",' > $tmpfile || \
+
+# 3. Multiple files supplied directly on command line
+
+# Strip paths again, just so we can use the same output comparison
+# file as above
+$r -t $transform -w csv --csv-stdout $mypath/audio/3clicks.mp3 $mypath/audio/6clicks.ogg --summary-only 2>/dev/null | sed 's,^"[^"]*/,",' > $tmpfile || \
     fail "Fails to run transform $transform with 2-file input"
 
 expected=$mypath/expected/transforms-summaries-percussiononsets-playlist
@@ -41,4 +53,42 @@
     faildiff "Output mismatch for transform $transform with summaries and 2-file input" $tmpfile $expected.csv
 
 
+# 4. Remote playlist file referring to remote audio files
 
+$r -t $transform -w csv --csv-stdout $urlbase/playlist.m3u --summary-only 2>/dev/null | sed 's,^"[^"]*/,",' > $tmpfile || \
+    fail "Fails to run transform $transform with remote playlist input"
+
+expected=$mypath/expected/transforms-summaries-percussiononsets-playlist
+csvcompare $tmpfile $expected.csv || \
+    faildiff "Output mismatch for transform $transform with summaries and remote playlist input" $tmpfile $expected.csv
+
+
+# 5. Local playlist file referring to mixture of remote and local audio files
+
+$r -t $transform -w csv --csv-stdout $mypath/audio/remote-playlist.m3u --summary-only 2>/dev/null | sed 's,^"[^"]*/,",' > $tmpfile || \
+    fail "Fails to run transform $transform with playlist of remote files"
+
+expected=$mypath/expected/transforms-summaries-percussiononsets-playlist
+csvcompare $tmpfile $expected.csv || \
+    faildiff "Output mismatch for transform $transform with summaries and remote playlist input" $tmpfile $expected.csv
+
+
+# 6. Multiple remote files supplied directly on command line
+
+$r -t $transform -w csv --csv-stdout $urlbase/3clicks.mp3 $urlbase/6clicks.ogg --summary-only 2>/dev/null | sed 's,^"[^"]*/,",' > $tmpfile || \
+    fail "Fails to run transform $transform with 2-file remote input"
+
+expected=$mypath/expected/transforms-summaries-percussiononsets-playlist
+csvcompare $tmpfile $expected.csv || \
+    faildiff "Output mismatch for transform $transform with summaries and 2-file input" $tmpfile $expected.csv
+
+
+# 7. Mixture of remote and local files supplied on command line
+
+$r -t $transform -w csv --csv-stdout $mypath/audio/3clicks.mp3 $urlbase/6clicks.ogg --summary-only 2>/dev/null | sed 's,^"[^"]*/,",' > $tmpfile || \
+    fail "Fails to run transform $transform with 2-file remote input"
+
+expected=$mypath/expected/transforms-summaries-percussiononsets-playlist
+csvcompare $tmpfile $expected.csv || \
+    faildiff "Output mismatch for transform $transform with summaries and mixed local/remote 2-file input" $tmpfile $expected.csv
+