Mercurial > hg > vamp-plugin-tester
comparison vamp-plugin-tester.cpp @ 8:3019cb6b538d
* Add nondeterministic and verbose options to control output
* Dump returned features in a few more situations, if verbose is set
* Dump features to stdout rather than stderr
author | cannam |
---|---|
date | Wed, 18 Mar 2009 10:51:30 +0000 |
parents | d8724c5a6d83 |
children | 7cc55187f5db |
comparison
equal
deleted
inserted
replaced
7:43eb3a4b95c8 | 8:3019cb6b538d |
---|---|
42 #include <vamp-hostsdk/PluginLoader.h> | 42 #include <vamp-hostsdk/PluginLoader.h> |
43 | 43 |
44 #include <iostream> | 44 #include <iostream> |
45 | 45 |
46 #include <cstdlib> | 46 #include <cstdlib> |
47 #include <cstring> | |
47 | 48 |
48 #include "Tester.h" | 49 #include "Tester.h" |
49 | 50 |
50 using namespace std; | 51 using namespace std; |
51 | 52 |
55 << name << ": A Vamp plugin host that tests plugins for some likely errors.\n" | 56 << name << ": A Vamp plugin host that tests plugins for some likely errors.\n" |
56 "Chris Cannam, Centre for Digital Music, Queen Mary, University of London.\n" | 57 "Chris Cannam, Centre for Digital Music, Queen Mary, University of London.\n" |
57 "Copyright 2009 QMUL.\n" | 58 "Copyright 2009 QMUL.\n" |
58 "Freely redistributable; published under a BSD-style license.\n\n" | 59 "Freely redistributable; published under a BSD-style license.\n\n" |
59 "Usage:\n" | 60 "Usage:\n" |
60 " " << name << " [<pluginbasename>:<plugin>]\n\n" | 61 " " << name << " [-n] [-v] [<pluginbasename>:<plugin>]\n\n" |
61 "Example:\n" | 62 "Example:\n" |
62 " " << name << " vamp-example-plugins:amplitudefollower\n\n" | 63 " " << name << " vamp-example-plugins:amplitudefollower\n\n" |
63 "With an argument, tests one plugin; without, tests all plugins in Vamp path.\n" | 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 "helpful to run this tester under it and watch for errors thus provoked.\n" | 71 "helpful to run this tester under it and watch for errors thus provoked.\n" |
66 << endl; | 72 << endl; |
67 exit(2); | 73 exit(2); |
68 } | 74 } |
69 | 75 |
74 while (scooter && *scooter) { | 80 while (scooter && *scooter) { |
75 if (*scooter == '/' || *scooter == '\\') name = ++scooter; | 81 if (*scooter == '/' || *scooter == '\\') name = ++scooter; |
76 else ++scooter; | 82 else ++scooter; |
77 } | 83 } |
78 if (!name || !*name) name = argv[0]; | 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 cerr << name << ": Running..." << endl; | 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 bool good = true; | 116 bool good = true; |
87 Vamp::HostExt::PluginLoader::PluginKeyList keys = | 117 Vamp::HostExt::PluginLoader::PluginKeyList keys = |
88 Vamp::HostExt::PluginLoader::getInstance()->listPlugins(); | 118 Vamp::HostExt::PluginLoader::getInstance()->listPlugins(); |
89 int notes = 0, warnings = 0, errors = 0; | 119 int notes = 0, warnings = 0, errors = 0; |
90 for (int i = 0; i < (int)keys.size(); ++i) { | 120 for (int i = 0; i < (int)keys.size(); ++i) { |
91 cout << "Testing plugin: " << keys[i] << endl; | 121 cout << "Testing plugin: " << keys[i] << endl; |
92 Tester tester(keys[i]); | 122 Tester tester(keys[i], opts); |
93 if (tester.test(notes, warnings, errors)) { | 123 if (tester.test(notes, warnings, errors)) { |
94 cout << name << ": All tests succeeded for this plugin" << endl; | 124 cout << name << ": All tests succeeded for this plugin" << endl; |
95 } else { | 125 } else { |
96 cout << name << ": Some tests failed for this plugin" << endl; | 126 cout << name << ": Some tests failed for this plugin" << endl; |
97 good = false; | 127 good = false; |
113 } else { | 143 } else { |
114 cout << name << ": Some tests failed" << endl; | 144 cout << name << ": Some tests failed" << endl; |
115 return 1; | 145 return 1; |
116 } | 146 } |
117 } else { | 147 } else { |
118 string key = argv[1]; | 148 string key = argument; |
119 Tester tester(key); | 149 Tester tester(key, opts); |
120 int notes = 0, warnings = 0, errors = 0; | 150 int notes = 0, warnings = 0, errors = 0; |
121 if (tester.test(notes, warnings, errors)) { | 151 if (tester.test(notes, warnings, errors)) { |
122 cout << name << ": All tests succeeded"; | 152 cout << name << ": All tests succeeded"; |
123 if (warnings > 0) { | 153 if (warnings > 0) { |
124 cout << ", with " << warnings << " warning(s)"; | 154 cout << ", with " << warnings << " warning(s)"; |