Revision 4:d8724c5a6d83
| Test.h | ||
|---|---|---|
| 88 | 88 |
float **createTestAudio(size_t channels, size_t blocksize, size_t blocks); |
| 89 | 89 |
void destroyTestAudio(float **audio, size_t channels); |
| 90 | 90 |
|
| 91 |
// use plugin's preferred step/block size, return them: |
|
| 91 | 92 |
bool initDefaults(Vamp::Plugin *, size_t &channels, |
| 92 | 93 |
size_t &step, size_t &block, Results &r); |
| 93 | 94 |
|
| 95 |
// use the given step/block size and an adapter: |
|
| 94 | 96 |
bool initAdapted(Vamp::Plugin *, size_t &channels, |
| 95 | 97 |
size_t step, size_t block, Results &r); |
| 96 | 98 |
|
| TestInputExtremes.cpp | ||
|---|---|---|
| 49 | 49 |
#include <cmath> |
| 50 | 50 |
|
| 51 | 51 |
Tester::TestRegistrar<TestNormalInput> |
| 52 |
TestNormalInput::m_registrar("Normal input");
|
|
| 52 |
TestNormalInput::m_registrar("C1 Normal input");
|
|
| 53 | 53 |
|
| 54 | 54 |
Tester::TestRegistrar<TestNoInput> |
| 55 |
TestNoInput::m_registrar("Empty input");
|
|
| 55 |
TestNoInput::m_registrar("C2 Empty input");
|
|
| 56 | 56 |
|
| 57 | 57 |
Tester::TestRegistrar<TestShortInput> |
| 58 |
TestShortInput::m_registrar("Short input");
|
|
| 58 |
TestShortInput::m_registrar("C3 Short input");
|
|
| 59 | 59 |
|
| 60 | 60 |
Tester::TestRegistrar<TestSilentInput> |
| 61 |
TestSilentInput::m_registrar("Absolutely silent input");
|
|
| 61 |
TestSilentInput::m_registrar("C4 Absolutely silent input");
|
|
| 62 | 62 |
|
| 63 | 63 |
Tester::TestRegistrar<TestTooLoudInput> |
| 64 |
TestTooLoudInput::m_registrar("Input beyond expected +/-1 range");
|
|
| 64 |
TestTooLoudInput::m_registrar("C5 Input beyond expected +/-1 range");
|
|
| 65 | 65 |
|
| 66 | 66 |
Tester::TestRegistrar<TestRandomInput> |
| 67 |
TestRandomInput::m_registrar("Random input");
|
|
| 67 |
TestRandomInput::m_registrar("C6 Random input");
|
|
| 68 | 68 |
|
| 69 | 69 |
Test::Results |
| 70 | 70 |
TestNormalInput::test(string key) |
| TestMultipleRuns.cpp | ||
|---|---|---|
| 48 | 48 |
#include <cmath> |
| 49 | 49 |
|
| 50 | 50 |
Tester::TestRegistrar<TestDistinctRuns> |
| 51 |
TestDistinctRuns::m_registrar("Consecutive runs with separate instances");
|
|
| 51 |
TestDistinctRuns::m_registrar("D1 Consecutive runs with separate instances");
|
|
| 52 | 52 |
|
| 53 | 53 |
Tester::TestRegistrar<TestReset> |
| 54 |
TestReset::m_registrar("Consecutive runs with a single instance using reset");
|
|
| 54 |
TestReset::m_registrar("D2 Consecutive runs with a single instance using reset");
|
|
| 55 | 55 |
|
| 56 | 56 |
Tester::TestRegistrar<TestInterleavedRuns> |
| 57 |
TestInterleavedRuns::m_registrar("Simultaneous interleaved runs in a single thread");
|
|
| 57 |
TestInterleavedRuns::m_registrar("D3 Simultaneous interleaved runs in a single thread");
|
|
| 58 | 58 |
|
| 59 | 59 |
static const size_t _step = 1000; |
| 60 | 60 |
|
| TestOutputs.cpp | ||
|---|---|---|
| 40 | 40 |
#include "TestOutputs.h" |
| 41 | 41 |
|
| 42 | 42 |
#include <vamp-hostsdk/Plugin.h> |
| 43 |
#include <vamp-hostsdk/PluginLoader.h> |
|
| 43 | 44 |
using namespace Vamp; |
| 45 |
using namespace Vamp::HostExt; |
|
| 44 | 46 |
|
| 45 | 47 |
#include <set> |
| 46 | 48 |
#include <memory> |
| ... | ... | |
| 49 | 51 |
#include <cmath> |
| 50 | 52 |
|
| 51 | 53 |
Tester::TestRegistrar<TestOutputNumbers> |
| 52 |
TestOutputNumbers::m_registrar("Output number mismatching");
|
|
| 54 |
TestOutputNumbers::m_registrar("B1 Output number mismatching");
|
|
| 53 | 55 |
|
| 54 | 56 |
Tester::TestRegistrar<TestTimestamps> |
| 55 |
TestTimestamps::m_registrar("Invalid or dubious timestamp usage");
|
|
| 57 |
TestTimestamps::m_registrar("B2 Invalid or dubious timestamp usage");
|
|
| 56 | 58 |
|
| 57 | 59 |
static const size_t _step = 1000; |
| 58 | 60 |
|
| ... | ... | |
| 87 | 89 |
i != fs.end(); ++i) {
|
| 88 | 90 |
int o = i->first; |
| 89 | 91 |
used.insert(o); |
| 90 |
if (o < 0 || o >= outputs.size()) {
|
|
| 92 |
if (o < 0 || o >= (int)outputs.size()) {
|
|
| 91 | 93 |
r.push_back(error("Data returned on nonexistent output"));
|
| 92 | 94 |
} |
| 93 | 95 |
} |
| 94 |
for (int o = 0; o < outputs.size(); ++o) {
|
|
| 96 |
for (int o = 0; o < (int)outputs.size(); ++o) {
|
|
| 95 | 97 |
if (used.find(o) == used.end()) {
|
| 96 |
r.push_back(note("No results returned for one or more outputs")); }
|
|
| 98 |
r.push_back(note("No results returned for one or more outputs"));
|
|
| 99 |
} |
|
| 97 | 100 |
} |
| 98 | 101 |
|
| 99 | 102 |
return r; |
| ... | ... | |
| 103 | 106 |
TestTimestamps::test(string key) |
| 104 | 107 |
{
|
| 105 | 108 |
int rate = 44100; |
| 106 |
auto_ptr<Plugin> p(load(key, rate)); |
|
| 109 |
|
|
| 110 |
// we want to be sure that a buffer size adapter is not used: |
|
| 111 |
auto_ptr<Plugin> p(PluginLoader::getInstance()->loadPlugin |
|
| 112 |
(key, rate, PluginLoader::ADAPT_ALL_SAFE)); |
|
| 113 |
|
|
| 107 | 114 |
Plugin::FeatureSet f; |
| 108 | 115 |
Results r; |
| 109 | 116 |
float **data = 0; |
| ... | ... | |
| 111 | 118 |
size_t step = 0, block = 0; |
| 112 | 119 |
size_t count = 100; |
| 113 | 120 |
|
| 114 |
//!!! want to ensure buffer size adapter is not used: |
|
| 115 | 121 |
if (!initDefaults(p.get(), channels, step, block, r)) return r; |
| 116 | 122 |
if (!data) data = createTestAudio(channels, block, count); |
| 117 | 123 |
for (size_t i = 0; i < count; ++i) {
|
| TestStaticData.cpp | ||
|---|---|---|
| 48 | 48 |
#include <cmath> |
| 49 | 49 |
|
| 50 | 50 |
Tester::TestRegistrar<TestIdentifiers> |
| 51 |
TestIdentifiers::m_registrar("Invalid identifiers");
|
|
| 51 |
TestIdentifiers::m_registrar("A1 Invalid identifiers");
|
|
| 52 | 52 |
|
| 53 | 53 |
Tester::TestRegistrar<TestEmptyFields> |
| 54 |
TestEmptyFields::m_registrar("Empty metadata fields");
|
|
| 54 |
TestEmptyFields::m_registrar("A2 Empty metadata fields");
|
|
| 55 | 55 |
|
| 56 | 56 |
Tester::TestRegistrar<TestValueRanges> |
| 57 |
TestValueRanges::m_registrar("Inappropriate value extents");
|
|
| 57 |
TestValueRanges::m_registrar("A3 Inappropriate value extents");
|
|
| 58 | 58 |
|
| 59 | 59 |
Test::Results |
| 60 | 60 |
TestIdentifiers::test(string key) |
| Tester.cpp | ||
|---|---|---|
| 46 | 46 |
#include <cstring> |
| 47 | 47 |
#include <cstdlib> |
| 48 | 48 |
#include <cmath> |
| 49 |
#include <set> |
|
| 49 | 50 |
|
| 50 | 51 |
#include "Tester.h" |
| 51 | 52 |
|
| ... | ... | |
| 75 | 76 |
} |
| 76 | 77 |
|
| 77 | 78 |
bool |
| 78 |
Tester::test() |
|
| 79 |
Tester::test(int ¬es, int &warnings, int &errors)
|
|
| 79 | 80 |
{
|
| 80 | 81 |
/* |
| 81 | 82 |
|
| ... | ... | |
| 152 | 153 |
Test *test = i->second->makeTest(); |
| 153 | 154 |
Test::Results results = test->test(m_key); |
| 154 | 155 |
delete test; |
| 156 |
|
|
| 157 |
set<string> printed; |
|
| 155 | 158 |
|
| 156 | 159 |
for (int j = 0; j < (int)results.size(); ++j) {
|
| 160 |
string message = results[j].message(); |
|
| 161 |
if (printed.find(message) != printed.end()) continue; |
|
| 162 |
printed.insert(message); |
|
| 157 | 163 |
switch (results[j].code()) {
|
| 158 | 164 |
case Test::Result::Success: |
| 159 | 165 |
break; |
| 160 | 166 |
case Test::Result::Note: |
| 161 | 167 |
std::cout << " ** NOTE: " << results[j].message() << std::endl; |
| 168 |
++notes; |
|
| 162 | 169 |
break; |
| 163 | 170 |
case Test::Result::Warning: |
| 164 | 171 |
std::cout << " ** WARNING: " << results[j].message() << std::endl; |
| 172 |
++warnings; |
|
| 165 | 173 |
break; |
| 166 | 174 |
case Test::Result::Error: |
| 167 | 175 |
std::cout << " ** ERROR: " << results[j].message() << std::endl; |
| 176 |
++errors; |
|
| 168 | 177 |
good = false; |
| 169 | 178 |
break; |
| 170 | 179 |
} |
| Tester.h | ||
|---|---|---|
| 50 | 50 |
Tester(std::string pluginKey); |
| 51 | 51 |
~Tester(); |
| 52 | 52 |
|
| 53 |
bool test(); |
|
| 53 |
bool test(int ¬es, int &warnings, int &errors);
|
|
| 54 | 54 |
|
| 55 | 55 |
class Registrar {
|
| 56 | 56 |
public: |
| vamp-plugin-tester.cpp | ||
|---|---|---|
| 86 | 86 |
bool good = true; |
| 87 | 87 |
Vamp::HostExt::PluginLoader::PluginKeyList keys = |
| 88 | 88 |
Vamp::HostExt::PluginLoader::getInstance()->listPlugins(); |
| 89 |
int notes = 0, warnings = 0, errors = 0; |
|
| 89 | 90 |
for (int i = 0; i < (int)keys.size(); ++i) {
|
| 90 | 91 |
cout << "Testing plugin: " << keys[i] << endl; |
| 91 | 92 |
Tester tester(keys[i]); |
| 92 |
if (tester.test()) {
|
|
| 93 |
if (tester.test(notes, warnings, errors)) {
|
|
| 93 | 94 |
cout << name << ": All tests succeeded for this plugin" << endl; |
| 94 | 95 |
} else {
|
| 95 | 96 |
cout << name << ": Some tests failed for this plugin" << endl; |
| ... | ... | |
| 98 | 99 |
cout << endl; |
| 99 | 100 |
} |
| 100 | 101 |
if (good) {
|
| 101 |
cout << name << ": All tests succeeded" << endl; |
|
| 102 |
cout << name << ": All tests succeeded"; |
|
| 103 |
if (warnings > 0) {
|
|
| 104 |
cout << ", with " << warnings << " warning(s)"; |
|
| 105 |
if (notes > 0) {
|
|
| 106 |
cout << " and " << notes << " other note(s)"; |
|
| 107 |
} |
|
| 108 |
} else if (notes > 0) {
|
|
| 109 |
cout << ", with " << notes << " note(s)"; |
|
| 110 |
} |
|
| 111 |
cout << endl; |
|
| 102 | 112 |
return 0; |
| 103 | 113 |
} else {
|
| 104 | 114 |
cout << name << ": Some tests failed" << endl; |
| ... | ... | |
| 107 | 117 |
} else {
|
| 108 | 118 |
string key = argv[1]; |
| 109 | 119 |
Tester tester(key); |
| 110 |
if (tester.test()) {
|
|
| 111 |
cout << name << ": All tests succeeded" << endl; |
|
| 120 |
int notes = 0, warnings = 0, errors = 0; |
|
| 121 |
if (tester.test(notes, warnings, errors)) {
|
|
| 122 |
cout << name << ": All tests succeeded"; |
|
| 123 |
if (warnings > 0) {
|
|
| 124 |
cout << ", with " << warnings << " warning(s)"; |
|
| 125 |
if (notes > 0) {
|
|
| 126 |
cout << " and " << notes << " other note(s)"; |
|
| 127 |
} |
|
| 128 |
} else if (notes > 0) {
|
|
| 129 |
cout << ", with " << notes << " note(s)"; |
|
| 130 |
} |
|
| 131 |
cout << endl; |
|
| 112 | 132 |
return 0; |
| 113 | 133 |
} else {
|
| 114 | 134 |
cout << name << ": Some tests failed" << endl; |
Also available in: Unified diff