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