Mercurial > hg > vamp-plugin-tester
changeset 10:0c1c60654125
* Add somewhat unsatisfactory test for constructor with various
sample rates
author | cannam |
---|---|
date | Wed, 18 Mar 2009 11:08:37 +0000 |
parents | 7cc55187f5db |
children | 82ef943a1bd2 |
files | Makefile TestDefaults.cpp TestDefaults.h TestInitialise.cpp TestInitialise.h |
diffstat | 5 files changed, 183 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Wed Mar 18 10:56:10 2009 +0000 +++ b/Makefile Wed Mar 18 11:08:37 2009 +0000 @@ -2,7 +2,7 @@ LDFLAGS += -lvamp-hostsdk -ldl CXXFLAGS += -Wall -Wextra -OBJECTS := vamp-plugin-tester.o Tester.o Test.o TestStaticData.o TestInputExtremes.o TestMultipleRuns.o TestOutputs.o TestDefaults.o +OBJECTS := vamp-plugin-tester.o Tester.o Test.o TestStaticData.o TestInputExtremes.o TestMultipleRuns.o TestOutputs.o TestDefaults.o TestInitialise.o vamp-plugin-tester: $(OBJECTS) @@ -18,12 +18,16 @@ # DO NOT DELETE Test.o: Test.h +TestDefaults.o: TestDefaults.h Test.h Tester.h +TestInitialise.o: TestOutputs.h Test.h Tester.h TestInputExtremes.o: TestInputExtremes.h Test.h Tester.h TestMultipleRuns.o: TestMultipleRuns.h Test.h Tester.h TestOutputs.o: TestOutputs.h Test.h Tester.h TestStaticData.o: TestStaticData.h Test.h Tester.h Tester.o: Tester.h Test.h vamp-plugin-tester.o: Tester.h Test.h +TestDefaults.o: Test.h Tester.h +TestInitialise.o: Test.h Tester.h TestInputExtremes.o: Test.h Tester.h TestMultipleRuns.o: Test.h Tester.h TestOutputs.o: Test.h Tester.h
--- a/TestDefaults.cpp Wed Mar 18 10:56:10 2009 +0000 +++ b/TestDefaults.cpp Wed Mar 18 11:08:37 2009 +0000 @@ -54,9 +54,6 @@ Tester::TestRegistrar<TestDefaultParameters> TestDefaultParameters::m_registrar("E2 Inconsistent default parameters"); -Tester::TestRegistrar<TestLengthyConstructor> -TestLengthyConstructor::m_registrar("E3 Lengthy constructor"); - static const size_t _step = 1000; Test::Results @@ -154,15 +151,3 @@ return r; } - -Test::Results -TestLengthyConstructor::test(string key, Options options) -{ - time_t t0 = time(0); - auto_ptr<Plugin> p(load(key)); - time_t t1 = time(0); - Results r; - if (t1 - t0 > 1) r.push_back(warning("Constructor takes some time to run: work should be deferred to initialise?")); - return r; -} -
--- a/TestDefaults.h Wed Mar 18 10:56:10 2009 +0000 +++ b/TestDefaults.h Wed Mar 18 11:08:37 2009 +0000 @@ -63,14 +63,4 @@ static Tester::TestRegistrar<TestDefaultParameters> m_registrar; }; -class TestLengthyConstructor : public Test -{ -public: - TestLengthyConstructor() : Test() { } - Results test(std::string key, Options options); - -protected: - static Tester::TestRegistrar<TestLengthyConstructor> m_registrar; -}; - #endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TestInitialise.cpp Wed Mar 18 11:08:37 2009 +0000 @@ -0,0 +1,112 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Vamp Plugin Tester + Chris Cannam, cannam@all-day-breakfast.com + Centre for Digital Music, Queen Mary, University of London. + Copyright 2009 QMUL. + + This program loads a Vamp plugin and tests its susceptibility to a + number of common pitfalls, including handling of extremes of input + data. If you can think of any additional useful tests that are + easily added, please send them to me. + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, copy, + modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR + ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + Except as contained in this notice, the names of the Centre for + Digital Music; Queen Mary, University of London; and Chris Cannam + shall not be used in advertising or otherwise to promote the sale, + use or other dealings in this Software without prior written + authorization. +*/ + +#include "TestInitialise.h" + +#include <vamp-hostsdk/Plugin.h> +#include <vamp-hostsdk/PluginLoader.h> +using namespace Vamp; +using namespace Vamp::HostExt; + +#include <set> +#include <memory> +using namespace std; + +#include <cmath> + +Tester::TestRegistrar<TestSampleRates> +TestSampleRates::m_registrar("F1 Different sample rates"); + +Tester::TestRegistrar<TestLengthyConstructor> +TestLengthyConstructor::m_registrar("F2 Lengthy constructor"); + +static const size_t _step = 1000; + +Test::Results +TestSampleRates::test(string key, Options options) +{ + int rates[] = + { 1, 800, 10099, 11024, 44100, 48000, 96000, 192000, 201011, 1094091 }; + + Results r; + + for (int i = 0; i < sizeof(rates)/sizeof(rates[0]); ++i) { + + int rate = rates[i]; + auto_ptr<Plugin> p(load(key, rate)); + Plugin::FeatureSet f; + float **data = 0; + size_t channels = 0; + size_t count = 100; + + if (!initAdapted(p.get(), channels, _step, _step, r)) continue; + + data = createTestAudio(channels, _step, count); + for (size_t i = 0; i < count; ++i) { + float *ptr[channels]; + size_t idx = i * _step; + for (size_t c = 0; c < channels; ++c) ptr[c] = data[c] + idx; + RealTime timestamp = RealTime::frame2RealTime(idx, rate); + Plugin::FeatureSet fs = p->process(ptr, timestamp); + appendFeatures(f, fs); + } + Plugin::FeatureSet fs = p->getRemainingFeatures(); + appendFeatures(f, fs); + destroyTestAudio(data, channels); + } + + // We can't actually do anything meaningful with our results. + // We're really just testing to see whether the plugin crashes. I + // wonder whether it's possible to do any better? If not, we + // should probably report our limitations + + return r; +} + +Test::Results +TestLengthyConstructor::test(string key, Options options) +{ + time_t t0 = time(0); + auto_ptr<Plugin> p(load(key)); + time_t t1 = time(0); + Results r; + if (t1 - t0 > 1) r.push_back(warning("Constructor takes some time to run: work should be deferred to initialise?")); + return r; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TestInitialise.h Wed Mar 18 11:08:37 2009 +0000 @@ -0,0 +1,66 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Vamp Plugin Tester + Chris Cannam, cannam@all-day-breakfast.com + Centre for Digital Music, Queen Mary, University of London. + Copyright 2009 QMUL. + + This program loads a Vamp plugin and tests its susceptibility to a + number of common pitfalls, including handling of extremes of input + data. If you can think of any additional useful tests that are + easily added, please send them to me. + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, copy, + modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR + ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + Except as contained in this notice, the names of the Centre for + Digital Music; Queen Mary, University of London; and Chris Cannam + shall not be used in advertising or otherwise to promote the sale, + use or other dealings in this Software without prior written + authorization. +*/ + +#ifndef _TEST_INITIALISE_H_ +#define _TEST_INITIALISE_H_ + +#include "Test.h" +#include "Tester.h" + +class TestSampleRates : public Test +{ +public: + TestSampleRates() : Test() { } + Results test(std::string key, Options options); + +protected: + static Tester::TestRegistrar<TestSampleRates> m_registrar; +}; + +class TestLengthyConstructor : public Test +{ +public: + TestLengthyConstructor() : Test() { } + Results test(std::string key, Options options); + +protected: + static Tester::TestRegistrar<TestLengthyConstructor> m_registrar; +}; + +#endif