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 / Tester.cpp @ 3:0f65bb22172b

History | View | Annotate | Download (5.92 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 <cstring>
47
#include <cstdlib>
48
#include <cmath>
49

    
50
#include "Tester.h"
51

    
52
using Vamp::Plugin;
53
using Vamp::PluginHostAdapter;
54
using Vamp::RealTime;
55
using Vamp::HostExt::PluginLoader;
56
using Vamp::HostExt::PluginWrapper;
57
using Vamp::HostExt::PluginInputDomainAdapter;
58

    
59
using namespace std;
60

    
61
Tester::Tester(std::string key) :
62
    m_key(key)
63
{
64
}
65

    
66
Tester::~Tester()
67
{
68
}
69

    
70
Tester::Registry &
71
Tester::registry()
72
{
73
    static Registry r;
74
    return r;
75
}
76

    
77
bool
78
Tester::test()
79
{
80
    /*
81
      
82
      Things I would like to see tested:
83

84
      * Identifiers for parameters, outputs, or plugin itself contain
85
        illegal characters - DONE
86

87
      * Any of the plugin's name, maker etc fields are empty - DONE
88

89
      * Default value of a parameter is not quantized as specified - DONE
90

91
      * Parameter minValue >= maxValue, or defaultValue < minValue
92
        or > maxValue - DONE
93

94
      * Plugin fails when given zero-length or very short input - DONE
95

96
      * Plugin fails when given "all digital zeros" input - DONE
97

98
      * Plugin fails when given input that exceeds +/-1 - DONE
99

100
      * Plugin fails when given "normal" random input (just in case!) - DONE
101

102
      * Plugin returns different results if another instance is
103
        constructed and run "interleaved" with it (from same thread) - DONE
104
 
105
      * Plugin's returned timestamps do not change as expected when
106
        run with a different base timestamp for input (though there
107
        could be legitimate reasons for this)
108

109
      * Plugin produces different results on second run, after reset
110
        called - DONE
111

112
      * Initial value of a parameter on plugin construction differs
113
        from its default value (i.e. plugin produces different
114
        results depending on whether parameter is set explicitly by
115
        host to default value or not)
116
        
117
      * If a plugin reports any programs, selecting default program
118
        explicitly changes results (as for default parameters)
119

120
      * Output feature does not hasTimestamp when output type is
121
        VariableSampleRate
122

123
      * Output feature hasTimestamp or hasDuration when output type is
124
        OneSamplePerStep (warning only, this is not an error)
125

126
      * Plugin fails gracelessly when constructed with "weird" sample
127
        rate or initialised with "wrong" step size, block size, or
128
        number of channels
129

130
      * Plugin returns features whose output numbers do not have
131
        a corresponding record in output descriptor list
132

133
      * Plugin fails to return any features on some output (warning
134
        only)
135

136
      * Constructor takes a long time to run.  A fuzzy concept, but
137
        suggests that some work should have been deferred to
138
        initialise().  Warning only
139

140
      Well, that's quite a lot of tests already.  What else?
141

142
    */
143

    
144
    bool good = true;
145

    
146
    try {
147
        for (Registry::const_iterator i = registry().begin();
148
             i != registry().end(); ++i) {
149
            
150
            std::cout << " -- Performing test: " << i->first << std::endl;
151

    
152
            Test *test = i->second->makeTest();
153
            Test::Results results = test->test(m_key);
154
            delete test;
155
            
156
            for (int j = 0; j < (int)results.size(); ++j) {
157
                switch (results[j].code()) {
158
                case Test::Result::Success:
159
                    break;
160
                case Test::Result::Note:
161
                    std::cout << " ** NOTE: " << results[j].message() << std::endl;
162
                    break;
163
                case Test::Result::Warning:
164
                    std::cout << " ** WARNING: " << results[j].message() << std::endl;
165
                    break;
166
                case Test::Result::Error:
167
                    std::cout << " ** ERROR: " << results[j].message() << std::endl;
168
                    good = false;
169
                    break;
170
                }
171
            }
172
        }
173
    } catch (Test::FailedToLoadPlugin) {
174
        std::cout << "ERROR: Failed to load plugin (key = \"" << m_key
175
                  << "\")" << std::endl;
176
    }
177

    
178
    return good;
179
}
180