Revision 10:0c1c60654125

View differences:

Makefile
2 2
LDFLAGS 	+= -lvamp-hostsdk -ldl
3 3
CXXFLAGS	+= -Wall -Wextra
4 4

  
5
OBJECTS		:= vamp-plugin-tester.o Tester.o Test.o TestStaticData.o TestInputExtremes.o TestMultipleRuns.o TestOutputs.o TestDefaults.o
5
OBJECTS		:= vamp-plugin-tester.o Tester.o Test.o TestStaticData.o TestInputExtremes.o TestMultipleRuns.o TestOutputs.o TestDefaults.o TestInitialise.o
6 6

  
7 7
vamp-plugin-tester:	$(OBJECTS)
8 8

  
......
18 18
# DO NOT DELETE
19 19

  
20 20
Test.o: Test.h
21
TestDefaults.o: TestDefaults.h Test.h Tester.h
22
TestInitialise.o: TestOutputs.h Test.h Tester.h
21 23
TestInputExtremes.o: TestInputExtremes.h Test.h Tester.h
22 24
TestMultipleRuns.o: TestMultipleRuns.h Test.h Tester.h
23 25
TestOutputs.o: TestOutputs.h Test.h Tester.h
24 26
TestStaticData.o: TestStaticData.h Test.h Tester.h
25 27
Tester.o: Tester.h Test.h
26 28
vamp-plugin-tester.o: Tester.h Test.h
29
TestDefaults.o: Test.h Tester.h
30
TestInitialise.o: Test.h Tester.h
27 31
TestInputExtremes.o: Test.h Tester.h
28 32
TestMultipleRuns.o: Test.h Tester.h
29 33
TestOutputs.o: Test.h Tester.h
TestDefaults.cpp
54 54
Tester::TestRegistrar<TestDefaultParameters>
55 55
TestDefaultParameters::m_registrar("E2 Inconsistent default parameters");
56 56

  
57
Tester::TestRegistrar<TestLengthyConstructor>
58
TestLengthyConstructor::m_registrar("E3 Lengthy constructor");
59

  
60 57
static const size_t _step = 1000;
61 58

  
62 59
Test::Results
......
154 151

  
155 152
    return r;
156 153
}
157

  
158
Test::Results
159
TestLengthyConstructor::test(string key, Options options)
160
{
161
    time_t t0 = time(0);
162
    auto_ptr<Plugin> p(load(key));
163
    time_t t1 = time(0);
164
    Results r;
165
    if (t1 - t0 > 1) r.push_back(warning("Constructor takes some time to run: work should be deferred to initialise?"));
166
    return r;
167
}
168

  
TestDefaults.h
63 63
    static Tester::TestRegistrar<TestDefaultParameters> m_registrar;
64 64
};
65 65

  
66
class TestLengthyConstructor : public Test
67
{
68
public:
69
    TestLengthyConstructor() : Test() { }
70
    Results test(std::string key, Options options);
71
    
72
protected:
73
    static Tester::TestRegistrar<TestLengthyConstructor> m_registrar;
74
};
75

  
76 66
#endif
TestInitialise.cpp
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 "TestInitialise.h"
41

  
42
#include <vamp-hostsdk/Plugin.h>
43
#include <vamp-hostsdk/PluginLoader.h>
44
using namespace Vamp;
45
using namespace Vamp::HostExt;
46

  
47
#include <set>
48
#include <memory>
49
using namespace std;
50

  
51
#include <cmath>
52

  
53
Tester::TestRegistrar<TestSampleRates>
54
TestSampleRates::m_registrar("F1 Different sample rates");
55

  
56
Tester::TestRegistrar<TestLengthyConstructor>
57
TestLengthyConstructor::m_registrar("F2 Lengthy constructor");
58

  
59
static const size_t _step = 1000;
60

  
61
Test::Results
62
TestSampleRates::test(string key, Options options)
63
{
64
    int rates[] =
65
        { 1, 800, 10099, 11024, 44100, 48000, 96000, 192000, 201011, 1094091 };
66

  
67
    Results r;
68

  
69
    for (int i = 0; i < sizeof(rates)/sizeof(rates[0]); ++i) {
70
    
71
        int rate = rates[i];
72
        auto_ptr<Plugin> p(load(key, rate));
73
        Plugin::FeatureSet f;
74
        float **data = 0;
75
        size_t channels = 0;
76
        size_t count = 100;
77

  
78
        if (!initAdapted(p.get(), channels, _step, _step, r)) continue;
79

  
80
        data = createTestAudio(channels, _step, count);
81
        for (size_t i = 0; i < count; ++i) {
82
            float *ptr[channels];
83
            size_t idx = i * _step;
84
            for (size_t c = 0; c < channels; ++c) ptr[c] = data[c] + idx;
85
            RealTime timestamp = RealTime::frame2RealTime(idx, rate);
86
            Plugin::FeatureSet fs = p->process(ptr, timestamp);
87
            appendFeatures(f, fs);
88
        }
89
        Plugin::FeatureSet fs = p->getRemainingFeatures();
90
        appendFeatures(f, fs);
91
        destroyTestAudio(data, channels);
92
    }
93

  
94
    // We can't actually do anything meaningful with our results.
95
    // We're really just testing to see whether the plugin crashes.  I
96
    // wonder whether it's possible to do any better?  If not, we
97
    // should probably report our limitations
98

  
99
    return r;
100
}
101

  
102
Test::Results
103
TestLengthyConstructor::test(string key, Options options)
104
{
105
    time_t t0 = time(0);
106
    auto_ptr<Plugin> p(load(key));
107
    time_t t1 = time(0);
108
    Results r;
109
    if (t1 - t0 > 1) r.push_back(warning("Constructor takes some time to run: work should be deferred to initialise?"));
110
    return r;
111
}
112

  
TestInitialise.h
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
#ifndef _TEST_INITIALISE_H_
41
#define _TEST_INITIALISE_H_
42

  
43
#include "Test.h"
44
#include "Tester.h"
45

  
46
class TestSampleRates : public Test
47
{
48
public:
49
    TestSampleRates() : Test() { }
50
    Results test(std::string key, Options options);
51
    
52
protected:
53
    static Tester::TestRegistrar<TestSampleRates> m_registrar;
54
};
55

  
56
class TestLengthyConstructor : public Test
57
{
58
public:
59
    TestLengthyConstructor() : Test() { }
60
    Results test(std::string key, Options options);
61
    
62
protected:
63
    static Tester::TestRegistrar<TestLengthyConstructor> m_registrar;
64
};
65

  
66
#endif

Also available in: Unified diff