| 50 |
50 |
|
| 51 |
51 |
using namespace std;
|
| 52 |
52 |
|
|
53 |
static const std::string VERSION="1.1";
|
|
54 |
|
| 53 |
55 |
void usage(const char *name)
|
| 54 |
56 |
{
|
| 55 |
57 |
cerr << "\n"
|
| ... | ... | |
| 58 |
60 |
"Copyright 2009-2012 QMUL.\n"
|
| 59 |
61 |
"Freely redistributable; published under a BSD-style license.\n\n"
|
| 60 |
62 |
"Usage:\n"
|
| 61 |
|
" " << name << " [-nv] <pluginbasename>:<plugin>\n"
|
| 62 |
|
" " << name << " [-nv] -a\n\n"
|
|
63 |
" " << name << " [-nv] [-t <test>] <pluginbasename>:<plugin>\n"
|
|
64 |
" " << name << " [-nv] [-t <test>] -a\n"
|
|
65 |
" " << name << " -l\n\n"
|
| 63 |
66 |
"Example:\n"
|
| 64 |
67 |
" " << name << " vamp-example-plugins:amplitudefollower\n\n"
|
| 65 |
68 |
"Options:\n"
|
| ... | ... | |
| 67 |
70 |
" -n, --nondeterministic Plugins may be nondeterministic: print a note\n"
|
| 68 |
71 |
" instead of an error if results differ between runs\n\n"
|
| 69 |
72 |
" -v, --verbose Show returned features each time a note, warning,\n"
|
| 70 |
|
" or error arises from feature data\n"
|
|
73 |
" or error arises from feature data\n\n"
|
|
74 |
" -t, --test <test> Run only a single test, not the full test suite.\n"
|
|
75 |
" Identify the test by its id, e.g. A3\n\n"
|
|
76 |
" -l, --list-tests List tests by id and name\n\n"
|
|
77 |
" --version Display the version of " << name << "\n"
|
| 71 |
78 |
"\nIf you have access to a runtime memory checker, you may find it especially\n"
|
| 72 |
79 |
"helpful to run this tester under it and watch for errors thus provoked.\n"
|
| 73 |
80 |
<< endl;
|
| ... | ... | |
| 87 |
94 |
bool nondeterministic = false;
|
| 88 |
95 |
bool verbose = false;
|
| 89 |
96 |
bool all = false;
|
| 90 |
|
string argument;
|
|
97 |
bool list = false;
|
|
98 |
string plugin;
|
|
99 |
string single;
|
|
100 |
|
|
101 |
// Would be better to use getopt, but let's avoid the dependency for now
|
| 91 |
102 |
for (int i = 1; i < argc; ++i) {
|
| 92 |
103 |
if (!argv[i]) break;
|
| 93 |
104 |
if (argv[i][0] == '-') {
|
|
105 |
if (!strcmp(argv[i], "-vn") ||
|
|
106 |
!strcmp(argv[i], "-nv")) {
|
|
107 |
verbose = true;
|
|
108 |
nondeterministic = true;
|
|
109 |
continue;
|
|
110 |
}
|
| 94 |
111 |
if (!strcmp(argv[i], "-v") ||
|
| 95 |
112 |
!strcmp(argv[i], "--verbose")) {
|
| 96 |
113 |
verbose = true;
|
| ... | ... | |
| 106 |
123 |
all = true;
|
| 107 |
124 |
continue;
|
| 108 |
125 |
}
|
|
126 |
if (!strcmp(argv[i], "-l") ||
|
|
127 |
!strcmp(argv[i], "--list-tests")) {
|
|
128 |
list = true;
|
|
129 |
continue;
|
|
130 |
}
|
|
131 |
if (!strcmp(argv[i], "-t") ||
|
|
132 |
!strcmp(argv[i], "--test")) {
|
|
133 |
if (i + 1 < argc) {
|
|
134 |
single = argv[i+1];
|
|
135 |
++i;
|
|
136 |
} else {
|
|
137 |
usage(name);
|
|
138 |
}
|
|
139 |
continue;
|
|
140 |
}
|
|
141 |
if (!strcmp(argv[i], "--version")) {
|
|
142 |
cout << "v" << VERSION << endl;
|
|
143 |
return 0;
|
|
144 |
}
|
| 109 |
145 |
usage(name);
|
| 110 |
146 |
} else {
|
| 111 |
|
if (argument != "") usage(name);
|
| 112 |
|
else argument = argv[i];
|
|
147 |
if (plugin != "") usage(name);
|
|
148 |
else plugin = argv[i];
|
| 113 |
149 |
}
|
| 114 |
150 |
}
|
|
151 |
|
|
152 |
if (list) {
|
|
153 |
if (all || nondeterministic || (single != "") || (plugin != "")) {
|
|
154 |
usage(name);
|
|
155 |
}
|
|
156 |
Tester::listTests();
|
|
157 |
return 0;
|
|
158 |
}
|
| 115 |
159 |
|
| 116 |
|
if (argument == "" && !all) usage(name);
|
| 117 |
|
if (argument != "" && all) usage(name);
|
|
160 |
if (plugin == "" && !all) usage(name);
|
|
161 |
if (plugin != "" && all) usage(name);
|
| 118 |
162 |
|
| 119 |
163 |
cerr << name << ": Running..." << endl;
|
| 120 |
164 |
|
| 121 |
|
std::string single = "";
|
| 122 |
|
|
| 123 |
165 |
Test::Options opts = Test::NoOption;
|
| 124 |
166 |
if (nondeterministic) opts |= Test::NonDeterministic;
|
| 125 |
167 |
if (verbose) opts |= Test::Verbose;
|
| ... | ... | |
| 163 |
205 |
return 1;
|
| 164 |
206 |
}
|
| 165 |
207 |
} else {
|
| 166 |
|
string key = argument;
|
| 167 |
|
Tester tester(key, opts, single);
|
|
208 |
Tester tester(plugin, opts, single);
|
| 168 |
209 |
int notes = 0, warnings = 0, errors = 0;
|
| 169 |
210 |
if (tester.test(notes, warnings, errors)) {
|
| 170 |
211 |
cout << name << ": All tests succeeded";
|