comparison vamp-client/qt/test.cpp @ 274:532a146b5229

Adjust test output
author Chris Cannam <cannam@all-day-breakfast.com>
date Wed, 17 Oct 2018 15:22:29 +0100
parents 60ff32818c30
children
comparison
equal deleted inserted replaced
273:82a89c4345c6 274:532a146b5229
62 62
63 try { 63 try {
64 cerr << endl << "*** Test: starting transport" << endl; 64 cerr << endl << "*** Test: starting transport" << endl;
65 piper_vamp::client::ProcessQtTransport transport(server, format, logger); 65 piper_vamp::client::ProcessQtTransport transport(server, format, logger);
66 if (!transport.isOK()) { 66 if (!transport.isOK()) {
67 cerr << "ERROR: Transport failed to start" << endl; 67 cerr << "--- ERROR: Transport failed to start" << endl;
68 return 1; 68 return 1;
69 } 69 }
70 cerr << "OK" << endl; 70 cerr << "+++ OK" << endl;
71 71
72 cerr << endl << "*** Test: constructing client" << endl; 72 cerr << endl << "*** Test: constructing client" << endl;
73 piper_vamp::client::CapnpRRClient client(&transport, logger); 73 piper_vamp::client::CapnpRRClient client(&transport, logger);
74 cerr << "OK" << endl; 74 cerr << "+++ OK" << endl;
75 75
76 cerr << endl << "*** Test: listing plugins" << endl; 76 cerr << endl << "*** Test: listing plugins" << endl;
77 piper_vamp::ListResponse lr = client.list({}); 77 piper_vamp::ListResponse lr = client.list({});
78 cerr << "OK; plugins are:" << endl; 78 cerr << "+++ OK; plugins are:" << endl;
79 int i = 1; 79 int i = 1;
80 for (const auto &p: lr.available) { 80 for (const auto &p: lr.available) {
81 cerr << i++ << ". [" << p.pluginKey << "] " << p.basic.name << endl; 81 cerr << i++ << ". [" << p.pluginKey << "] " << p.basic.name << endl;
82 } 82 }
83 83
123 req.inputSampleRate = 16; 123 req.inputSampleRate = 16;
124 req.adapterFlags = adapterFlags; 124 req.adapterFlags = adapterFlags;
125 piper_vamp::LoadResponse resp = client.load(req); 125 piper_vamp::LoadResponse resp = client.load(req);
126 plugin = resp.plugin; 126 plugin = resp.plugin;
127 if (!plugin) { 127 if (!plugin) {
128 cerr << "ERROR: plugin is null" << endl; 128 cerr << "--- ERROR: plugin is null" << endl;
129 return 1; 129 return 1;
130 } 130 }
131 cerr << "OK" << endl; 131 cerr << "+++ OK" << endl;
132 132
133 } else { 133 } else {
134 134
135 cerr << endl << "*** Test: loading \"" << id 135 cerr << endl << "*** Test: loading \"" << id
136 << "\" with auto-plugin" << endl; 136 << "\" with auto-plugin" << endl;
137 137
138 piper_vamp::client::PiperAutoPlugin *ap = 138 piper_vamp::client::PiperAutoPlugin *ap =
139 new piper_vamp::client::PiperAutoPlugin 139 new piper_vamp::client::PiperAutoPlugin
140 (server, id, 16, adapterFlags, logger); 140 (server, id, 16, adapterFlags, logger);
141 if (!ap->isOK()) { 141 if (!ap->isOK()) {
142 cerr << "ERROR: PiperAutoPlugin creation failed" << endl; 142 cerr << "--- ERROR: PiperAutoPlugin creation failed" << endl;
143 return 1; 143 return 1;
144 } 144 }
145 cerr << "OK" << endl; 145 cerr << "+++ OK" << endl;
146 146
147 plugin = ap; 147 plugin = ap;
148 } 148 }
149 149
150 if (domain == frequencyDomainClientSide) { 150 if (domain == frequencyDomainClientSide) {
151 cerr << "*** Test: creating input-domain adapter" << endl; 151 cerr << "*** Test: creating input-domain adapter" << endl;
152 plugin = new Vamp::HostExt::PluginInputDomainAdapter(plugin); 152 plugin = new Vamp::HostExt::PluginInputDomainAdapter(plugin);
153 cerr << "OK" << endl; 153 cerr << "+++ OK" << endl;
154 } 154 }
155 155
156 cerr << endl << "*** Test: initialising plugin" << endl; 156 cerr << endl << "*** Test: initialising plugin" << endl;
157 if (!plugin->initialise(1, 4, 4)) { 157 if (!plugin->initialise(1, 4, 4)) {
158 cerr << "ERROR: initialisation failed" << endl; 158 cerr << "--- ERROR: initialisation failed" << endl;
159 return 1; 159 return 1;
160 } 160 }
161 cerr << "OK" << endl; 161 cerr << "+++ OK" << endl;
162 162
163 for (int round = 1; round <= 2; ++round) { 163 for (int round = 1; round <= 2; ++round) {
164 cerr << endl << "*** Test: processing" 164 cerr << endl << "*** Test: processing"
165 << " (domain " << domain 165 << " (domain " << domain
166 << ", sort " << serverSort 166 << ", sort " << serverSort
168 168
169 vector<float> buf = { 1.0, -1.0, 1.0, -1.0 }; 169 vector<float> buf = { 1.0, -1.0, 1.0, -1.0 };
170 float *bd = buf.data(); 170 float *bd = buf.data();
171 Vamp::Plugin::FeatureSet features = plugin->process 171 Vamp::Plugin::FeatureSet features = plugin->process
172 (&bd, Vamp::RealTime::zeroTime); 172 (&bd, Vamp::RealTime::zeroTime);
173 cerr << "OK, process succeeded" << endl; 173 cerr << "+++ OK, process succeeded" << endl;
174 if (features[0].size() != 1) { 174 if (features[0].size() != 1) {
175 cerr << "ERROR: wrong number of features on output 0" 175 cerr << "--- ERROR: wrong number of features on output 0"
176 << " (expected 1, obtained " << features[0].size() << ")" 176 << " (expected 1, obtained " << features[0].size() << ")"
177 << endl; 177 << endl;
178 return 1; 178 return 1;
179 } 179 }
180 vector<float> expected; 180 vector<float> expected;
190 expected.push_back(1); 190 expected.push_back(1);
191 expected.push_back(4); 191 expected.push_back(4);
192 } 192 }
193 193
194 if (features[0][0].values.size() != expected.size()) { 194 if (features[0][0].values.size() != expected.size()) {
195 cerr << "ERROR: wrong size for feature on output 0" 195 cerr << "--- ERROR: wrong size for feature on output 0"
196 << " (expected " << expected.size() 196 << " (expected " << expected.size()
197 << ", obtained " 197 << ", obtained "
198 << features[0][0].values.size() << ")" << endl; 198 << features[0][0].values.size() << ")" << endl;
199 return 1; 199 return 1;
200 } 200 }
201 for (size_t i = 0; i < expected.size(); ++i) { 201 for (size_t i = 0; i < expected.size(); ++i) {
202 if (features[0][0].values[i] != expected[i]) { 202 if (features[0][0].values[i] != expected[i]) {
203 cerr << "ERROR: wrong value for index " << i 203 cerr << "--- ERROR: wrong value for index " << i
204 << " of feature on output 0" 204 << " of feature on output 0"
205 << " (expected " << expected[i] 205 << " (expected " << expected[i]
206 << ", obtained " 206 << ", obtained "
207 << features[0][0].values[i] << ")" << endl; 207 << features[0][0].values[i] << ")" << endl;
208 cerr << "(All obtained values are:"; 208 cerr << "(All obtained values are:";
211 } 211 }
212 cerr << ")" << endl; 212 cerr << ")" << endl;
213 return 1; 213 return 1;
214 } 214 }
215 } 215 }
216 cerr << "OK, results are correct" << endl; 216 cerr << "+++ OK, results are correct" << endl;
217 217
218 (void)plugin->getRemainingFeatures(); 218 (void)plugin->getRemainingFeatures();
219 219
220 if (round == 1) { 220 if (round == 1) {
221 cerr << endl << "*** Test: resetting plugin for round 2" << endl; 221 cerr << endl << "*** Test: resetting plugin for round 2" << endl;
222 plugin->reset(); 222 plugin->reset();
223 cerr << "OK" << endl; 223 cerr << "+++ OK" << endl;
224 } 224 }
225 } 225 }
226 226
227 cerr << endl << "*** Test: deleting plugin" << endl; 227 cerr << endl << "*** Test: deleting plugin" << endl;
228 delete plugin; 228 delete plugin;
229 cerr << "OK" << endl; 229 cerr << "+++ OK" << endl;
230 } 230 }
231 } 231 }
232 232
233 } catch (const exception &e) { 233 } catch (const exception &e) {
234 cerr << "ERROR: Exception caught: " << e.what() << endl; 234 cerr << "--- ERROR: Exception caught: " << e.what() << endl;
235 return 1; 235 return 1;
236 } 236 }
237 237
238 cerr << endl << "*** All tests succeeded" << endl; 238 cerr << endl << "*** All tests succeeded" << endl;
239 239