# HG changeset patch # User Chris Cannam # Date 1478797655 0 # Node ID 19fb654630e7a80ac9e2e95039e59720289ec8be # Parent baa3ddcb0dced92ba230a6b2a8eba57176452e25 Permit running test with only one arg (picking up first plugin as default), check for successful response, etc diff -r baa3ddcb0dce -r 19fb654630e7 test/node-load-test.js --- a/test/node-load-test.js Thu Nov 10 15:07:24 2016 +0000 +++ b/test/node-load-test.js Thu Nov 10 17:07:35 2016 +0000 @@ -4,14 +4,19 @@ console.log(blah); } -if (process.argv.length < 4) { - note("\nUsage: " + process.argv[0] + " "); +if (process.argv.length < 3 || process.argv.length > 4) { + note("\nUsage: " + process.argv[0] + " []"); + note("e.g. " + process.argv[0] + " ./VampExamplePlugins.js"); note("e.g. " + process.argv[0] + " ./VampExamplePlugins.js vamp-example-plugins:zerocrossing"); - throw "Wrong number of command-line args (2 expected)" + throw "Wrong number of command-line args (1 or 2 expected)" } var libraryPath = process.argv[2]; -var pluginKey = process.argv[3]; + +var pluginKey = ""; +if (process.argv.length > 3) { + pluginKey = process.argv[3]; +} var base64 = require("./base64"); @@ -141,12 +146,32 @@ return features; } +function checkSuccess(response) { + if (response.error) { + console.log("Request type " + response.method + " failed: " + + response.error.message); + throw response.error.message; + } +} + function test() { const rate = 44100; + + note("Listing plugins..."); + let response = request({ + method: "list" + }); + checkSuccess(response); + + if (pluginKey === "") { + pluginKey = response.result.available[0].key; + note("Loading first plugin \"" + pluginKey + "\"..."); + } else { + note("Loading requested plugin \"" + pluginKey + "\"..."); + } - note("Loading plugin \"" + pluginKey + "\"..."); - let response = request({ + response = request({ method: "load", params: { key: pluginKey, @@ -154,8 +179,10 @@ adapterFlags: ["AdaptAllSafe"] } }); + checkSuccess(response); - const blockSize = 1024; + const blockSize = response.result.defaultConfiguration.blockSize; + const stepSize = response.result.defaultConfiguration.stepSize; response = request({ method: "configure", @@ -163,11 +190,12 @@ handle: 1, configuration: { blockSize: blockSize, - channelCount: 1, - stepSize: blockSize + stepSize: stepSize, + channelCount: 1 } } }); + checkSuccess(response); const nblocks = 1000; @@ -196,7 +224,6 @@ for (let featureList of features.values()) { featureCount += featureList.length; } - console.log(i); } note("Cleaning up the plugin and getting any remaining features..."); @@ -206,6 +233,7 @@ handle: 1 } }); + checkSuccess(response); let features = responseToFeatureSet(response); for (let featureList of features.values()) {