To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / vamp-plugin-tester.cpp @ 4:d8724c5a6d83

History | View | Annotate | Download (5.1 KB)

1
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
2

    
3
/*
4
    Vamp Plugin Tester
5
    Chris Cannam, cannam@all-day-breakfast.com
6
    Centre for Digital Music, Queen Mary, University of London.
7
    Copyright 2009 QMUL.
8

9
    This program loads a Vamp plugin and tests its susceptibility to a
10
    number of common pitfalls, including handling of extremes of input
11
    data.  If you can think of any additional useful tests that are
12
    easily added, please send them to me.
13
  
14
    Permission is hereby granted, free of charge, to any person
15
    obtaining a copy of this software and associated documentation
16
    files (the "Software"), to deal in the Software without
17
    restriction, including without limitation the rights to use, copy,
18
    modify, merge, publish, distribute, sublicense, and/or sell copies
19
    of the Software, and to permit persons to whom the Software is
20
    furnished to do so, subject to the following conditions:
21

22
    The above copyright notice and this permission notice shall be
23
    included in all copies or substantial portions of the Software.
24

25
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26
    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27
    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28
    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
29
    ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
30
    CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31
    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32

33
    Except as contained in this notice, the names of the Centre for
34
    Digital Music; Queen Mary, University of London; and Chris Cannam
35
    shall not be used in advertising or otherwise to promote the sale,
36
    use or other dealings in this Software without prior written
37
    authorization.
38
*/
39

    
40
#include <vamp-hostsdk/PluginHostAdapter.h>
41
#include <vamp-hostsdk/PluginInputDomainAdapter.h>
42
#include <vamp-hostsdk/PluginLoader.h>
43

    
44
#include <iostream>
45

    
46
#include <cstdlib>
47

    
48
#include "Tester.h"
49

    
50
using namespace std;
51

    
52
void usage(const char *name)
53
{
54
    cerr << "\n"
55
         << 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
        "Copyright 2009 QMUL.\n"
58
        "Freely redistributable; published under a BSD-style license.\n\n"
59
        "Usage:\n"
60
        "  " << name << " [<pluginbasename>:<plugin>]\n\n"
61
        "Example:\n"
62
        "  " << name << " vamp-example-plugins:amplitudefollower\n\n"
63
        "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
        "helpful to run this tester under it and watch for errors thus provoked.\n"
66
         << endl;
67
    exit(2);
68
}
69

    
70
int main(int argc, char **argv)
71
{
72
    char *scooter = argv[0];
73
    char *name = 0;
74
    while (scooter && *scooter) {
75
        if (*scooter == '/' || *scooter == '\\') name = ++scooter;
76
        else ++scooter;
77
    }
78
    if (!name || !*name) name = argv[0];
79
    
80
    if (argc > 2) usage(name);
81
    if (argc == 2 && argv[1][0] == '-') usage(name);
82

    
83
    cerr << name << ": Running..." << endl;
84

    
85
    if (argc == 1) {
86
        bool good = true;
87
        Vamp::HostExt::PluginLoader::PluginKeyList keys =
88
            Vamp::HostExt::PluginLoader::getInstance()->listPlugins();
89
        int notes = 0, warnings = 0, errors = 0;
90
        for (int i = 0; i < (int)keys.size(); ++i) {
91
            cout << "Testing plugin: " << keys[i] << endl;
92
            Tester tester(keys[i]);
93
            if (tester.test(notes, warnings, errors)) {
94
                cout << name << ": All tests succeeded for this plugin" << endl;
95
            } else {
96
                cout << name << ": Some tests failed for this plugin" << endl;
97
                good = false;
98
            }
99
            cout << endl;
100
        }
101
        if (good) {
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;
112
            return 0;
113
        } else {
114
            cout << name << ": Some tests failed" << endl;
115
            return 1;
116
        }   
117
    } else {
118
        string key = argv[1];
119
        Tester tester(key);
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;
132
            return 0;
133
        } else {
134
            cout << name << ": Some tests failed" << endl;
135
            return 1;
136
        }
137
    }
138
}
139