To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / Tester.cpp @ 25:612333efd521
History | View | Annotate | Download (6.63 KB)
| 1 |
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
|---|---|
| 2 |
|
| 3 |
/*
|
| 4 |
Vamp Plugin Tester
|
| 5 |
Chris Cannam, cannam@all-day-breakfast.com
|
| 6 |
Centre for Digital Music, Queen Mary, University of London.
|
| 7 |
Copyright 2009 QMUL.
|
| 8 |
|
| 9 |
This program loads a Vamp plugin and tests its susceptibility to a
|
| 10 |
number of common pitfalls, including handling of extremes of input
|
| 11 |
data. If you can think of any additional useful tests that are
|
| 12 |
easily added, please send them to me.
|
| 13 |
|
| 14 |
Permission is hereby granted, free of charge, to any person
|
| 15 |
obtaining a copy of this software and associated documentation
|
| 16 |
files (the "Software"), to deal in the Software without
|
| 17 |
restriction, including without limitation the rights to use, copy,
|
| 18 |
modify, merge, publish, distribute, sublicense, and/or sell copies
|
| 19 |
of the Software, and to permit persons to whom the Software is
|
| 20 |
furnished to do so, subject to the following conditions:
|
| 21 |
|
| 22 |
The above copyright notice and this permission notice shall be
|
| 23 |
included in all copies or substantial portions of the Software.
|
| 24 |
|
| 25 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 26 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 27 |
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 28 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
|
| 29 |
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
| 30 |
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
| 31 |
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
| 32 |
|
| 33 |
Except as contained in this notice, the names of the Centre for
|
| 34 |
Digital Music; Queen Mary, University of London; and Chris Cannam
|
| 35 |
shall not be used in advertising or otherwise to promote the sale,
|
| 36 |
use or other dealings in this Software without prior written
|
| 37 |
authorization.
|
| 38 |
*/
|
| 39 |
|
| 40 |
#include <vamp-hostsdk/PluginHostAdapter.h> |
| 41 |
#include <vamp-hostsdk/PluginInputDomainAdapter.h> |
| 42 |
#include <vamp-hostsdk/PluginLoader.h> |
| 43 |
|
| 44 |
#include <iostream> |
| 45 |
|
| 46 |
#include <cstring> |
| 47 |
#include <cstdlib> |
| 48 |
#include <cmath> |
| 49 |
#include <set> |
| 50 |
|
| 51 |
#include "Tester.h" |
| 52 |
|
| 53 |
using Vamp::Plugin;
|
| 54 |
using Vamp::PluginHostAdapter;
|
| 55 |
using Vamp::RealTime;
|
| 56 |
using Vamp::HostExt::PluginLoader;
|
| 57 |
using Vamp::HostExt::PluginWrapper;
|
| 58 |
using Vamp::HostExt::PluginInputDomainAdapter;
|
| 59 |
|
| 60 |
using namespace std; |
| 61 |
|
| 62 |
Tester::Tester(std::string key, Test::Options options) :
|
| 63 |
m_key(key), |
| 64 |
m_options(options) |
| 65 |
{
|
| 66 |
} |
| 67 |
|
| 68 |
Tester::~Tester() |
| 69 |
{
|
| 70 |
} |
| 71 |
|
| 72 |
Tester::Registry & |
| 73 |
Tester::registry() |
| 74 |
{
|
| 75 |
static Registry r;
|
| 76 |
return r;
|
| 77 |
} |
| 78 |
|
| 79 |
bool
|
| 80 |
Tester::test(int ¬es, int &warnings, int &errors) |
| 81 |
{
|
| 82 |
/*
|
| 83 |
|
| 84 |
Things I would like to see tested:
|
| 85 |
|
| 86 |
* Identifiers for parameters, outputs, or plugin itself contain
|
| 87 |
illegal characters - DONE
|
| 88 |
|
| 89 |
* Any of the plugin's name, maker etc fields are empty - DONE
|
| 90 |
|
| 91 |
* Default value of a parameter is not quantized as specified - DONE
|
| 92 |
|
| 93 |
* Parameter minValue >= maxValue, or defaultValue < minValue
|
| 94 |
or > maxValue - DONE
|
| 95 |
|
| 96 |
* Plugin fails when given zero-length or very short input - DONE
|
| 97 |
|
| 98 |
* Plugin fails when given "all digital zeros" input - DONE
|
| 99 |
|
| 100 |
* Plugin fails when given input that exceeds +/-1 - DONE
|
| 101 |
|
| 102 |
* Plugin fails when given "normal" random input (just in case!) - DONE
|
| 103 |
|
| 104 |
* Plugin returns different results if another instance is
|
| 105 |
constructed and run "interleaved" with it (from same thread) - DONE
|
| 106 |
|
| 107 |
* Plugin's returned timestamps do not change as expected when
|
| 108 |
run with a different base timestamp for input (though there
|
| 109 |
could be legitimate reasons for this) - DONE
|
| 110 |
|
| 111 |
* Plugin produces different results on second run, after reset
|
| 112 |
called - DONE
|
| 113 |
|
| 114 |
* Initial value of a parameter on plugin construction differs
|
| 115 |
from its default value (i.e. plugin produces different
|
| 116 |
results depending on whether parameter is set explicitly by
|
| 117 |
host to default value or not) - DONE
|
| 118 |
|
| 119 |
* If a plugin reports any programs, selecting default program
|
| 120 |
explicitly changes results (as for default parameters) - DONE
|
| 121 |
|
| 122 |
* Output feature does not hasTimestamp when output type is
|
| 123 |
VariableSampleRate - DONE
|
| 124 |
|
| 125 |
* Output feature hasTimestamp or hasDuration when output type is
|
| 126 |
OneSamplePerStep (warning only, this is not an error) - DONE
|
| 127 |
|
| 128 |
* Plugin returns features whose output numbers do not have
|
| 129 |
a corresponding record in output descriptor list - DONE
|
| 130 |
|
| 131 |
* Plugin fails to return any features on some output (warning
|
| 132 |
only) - DONE
|
| 133 |
|
| 134 |
* Constructor takes a long time to run. A fuzzy concept, but
|
| 135 |
suggests that some work should have been deferred to
|
| 136 |
initialise(). Warning only - DONE
|
| 137 |
|
| 138 |
* Plugin fails gracelessly when constructed with "weird" sample
|
| 139 |
rate or initialised with "wrong" step size, block size, or
|
| 140 |
number of channels
|
| 141 |
|
| 142 |
Well, that's quite a lot of tests already. What else?
|
| 143 |
|
| 144 |
*/
|
| 145 |
|
| 146 |
bool good = true; |
| 147 |
|
| 148 |
try {
|
| 149 |
for (Registry::const_iterator i = registry().begin();
|
| 150 |
i != registry().end(); ++i) {
|
| 151 |
|
| 152 |
std::cout << " -- Performing test: " << i->first << std::endl;
|
| 153 |
|
| 154 |
Test *test = i->second->makeTest(); |
| 155 |
Test::Results results = test->test(m_key, m_options); |
| 156 |
delete test;
|
| 157 |
|
| 158 |
set<string> printed;
|
| 159 |
|
| 160 |
for (int j = 0; j < (int)results.size(); ++j) { |
| 161 |
string message = results[j].message();
|
| 162 |
if (printed.find(message) != printed.end()) continue; |
| 163 |
printed.insert(message); |
| 164 |
switch (results[j].code()) {
|
| 165 |
case Test::Result::Success:
|
| 166 |
break;
|
| 167 |
case Test::Result::Note:
|
| 168 |
std::cout << " ** NOTE: " << results[j].message() << std::endl;
|
| 169 |
++notes; |
| 170 |
break;
|
| 171 |
case Test::Result::Warning:
|
| 172 |
std::cout << " ** WARNING: " << results[j].message() << std::endl;
|
| 173 |
++warnings; |
| 174 |
break;
|
| 175 |
case Test::Result::Error:
|
| 176 |
std::cout << " ** ERROR: " << results[j].message() << std::endl;
|
| 177 |
++errors; |
| 178 |
good = false;
|
| 179 |
break;
|
| 180 |
} |
| 181 |
} |
| 182 |
} |
| 183 |
} catch (Test::FailedToLoadPlugin) {
|
| 184 |
std::cout << " ** ERROR: Failed to load plugin (key = \"" << m_key
|
| 185 |
<< "\")" << std::endl;
|
| 186 |
std::cout << " ** NOTE: Vamp plugin path is: " << std::endl;
|
| 187 |
std::vector<std::string> pp = PluginHostAdapter::getPluginPath();
|
| 188 |
for (size_t i = 0; i < pp.size(); ++i) { |
| 189 |
std::cout << " " << pp[i] << std::endl;
|
| 190 |
} |
| 191 |
} |
| 192 |
|
| 193 |
return good;
|
| 194 |
} |
| 195 |
|