Revision 8:3019cb6b538d vamp-plugin-tester.cpp
| vamp-plugin-tester.cpp | ||
|---|---|---|
| 44 | 44 |
#include <iostream> |
| 45 | 45 |
|
| 46 | 46 |
#include <cstdlib> |
| 47 |
#include <cstring> |
|
| 47 | 48 |
|
| 48 | 49 |
#include "Tester.h" |
| 49 | 50 |
|
| ... | ... | |
| 57 | 58 |
"Copyright 2009 QMUL.\n" |
| 58 | 59 |
"Freely redistributable; published under a BSD-style license.\n\n" |
| 59 | 60 |
"Usage:\n" |
| 60 |
" " << name << " [<pluginbasename>:<plugin>]\n\n" |
|
| 61 |
" " << name << " [-n] [-v] [<pluginbasename>:<plugin>]\n\n"
|
|
| 61 | 62 |
"Example:\n" |
| 62 | 63 |
" " << name << " vamp-example-plugins:amplitudefollower\n\n" |
| 63 | 64 |
"With an argument, tests one plugin; without, tests all plugins in Vamp path.\n" |
| 64 |
"If you have access to a runtime memory checker, you may find it especially\n" |
|
| 65 |
"\nOptions:\n" |
|
| 66 |
" --nondeterministic, -n Plugins may be nondeterministic: print a note\n" |
|
| 67 |
" instead of an error if results differ between runs\n" |
|
| 68 |
" --verbose, -v Show returned features each time a note, warning,\n" |
|
| 69 |
" or error arises from feature data\n" |
|
| 70 |
"\nIf you have access to a runtime memory checker, you may find it especially\n" |
|
| 65 | 71 |
"helpful to run this tester under it and watch for errors thus provoked.\n" |
| 66 | 72 |
<< endl; |
| 67 | 73 |
exit(2); |
| ... | ... | |
| 76 | 82 |
else ++scooter; |
| 77 | 83 |
} |
| 78 | 84 |
if (!name || !*name) name = argv[0]; |
| 85 |
|
|
| 86 |
bool nondeterministic = false; |
|
| 87 |
bool verbose = false; |
|
| 88 |
string argument; |
|
| 89 |
for (int i = 1; i < argc; ++i) {
|
|
| 90 |
if (!argv[i]) break; |
|
| 91 |
if (argv[i][0] == '-') {
|
|
| 92 |
if (!strcmp(argv[i], "-v") || |
|
| 93 |
!strcmp(argv[i], "--verbose")) {
|
|
| 94 |
verbose = 1; |
|
| 95 |
continue; |
|
| 96 |
} |
|
| 97 |
if (!strcmp(argv[i], "-n") || |
|
| 98 |
!strcmp(argv[i], "--nondeterministic")) {
|
|
| 99 |
nondeterministic = 1; |
|
| 100 |
continue; |
|
| 101 |
} |
|
| 102 |
usage(name); |
|
| 103 |
} else {
|
|
| 104 |
if (argument != "") usage(name); |
|
| 105 |
else argument = argv[i]; |
|
| 106 |
} |
|
| 107 |
} |
|
| 79 | 108 |
|
| 80 |
if (argc > 2) usage(name); |
|
| 81 |
if (argc == 2 && argv[1][0] == '-') usage(name); |
|
| 82 |
|
|
| 83 | 109 |
cerr << name << ": Running..." << endl; |
| 84 | 110 |
|
| 85 |
if (argc == 1) {
|
|
| 111 |
Test::Options opts = Test::NoOption; |
|
| 112 |
if (nondeterministic) opts |= Test::NonDeterministic; |
|
| 113 |
if (verbose) opts |= Test::Verbose; |
|
| 114 |
|
|
| 115 |
if (argument == "") {
|
|
| 86 | 116 |
bool good = true; |
| 87 | 117 |
Vamp::HostExt::PluginLoader::PluginKeyList keys = |
| 88 | 118 |
Vamp::HostExt::PluginLoader::getInstance()->listPlugins(); |
| 89 | 119 |
int notes = 0, warnings = 0, errors = 0; |
| 90 | 120 |
for (int i = 0; i < (int)keys.size(); ++i) {
|
| 91 | 121 |
cout << "Testing plugin: " << keys[i] << endl; |
| 92 |
Tester tester(keys[i]); |
|
| 122 |
Tester tester(keys[i], opts);
|
|
| 93 | 123 |
if (tester.test(notes, warnings, errors)) {
|
| 94 | 124 |
cout << name << ": All tests succeeded for this plugin" << endl; |
| 95 | 125 |
} else {
|
| ... | ... | |
| 115 | 145 |
return 1; |
| 116 | 146 |
} |
| 117 | 147 |
} else {
|
| 118 |
string key = argv[1];
|
|
| 119 |
Tester tester(key); |
|
| 148 |
string key = argument;
|
|
| 149 |
Tester tester(key, opts);
|
|
| 120 | 150 |
int notes = 0, warnings = 0, errors = 0; |
| 121 | 151 |
if (tester.test(notes, warnings, errors)) {
|
| 122 | 152 |
cout << name << ": All tests succeeded"; |
Also available in: Unified diff