-
-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathBasicTests.cpp
More file actions
820 lines (641 loc) · 28.8 KB
/
BasicTests.cpp
File metadata and controls
820 lines (641 loc) · 28.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
/*==============================================================================
Copyright 2018 by Tracktion Corporation.
For more information visit www.tracktion.com
You may also use this code under the terms of the GPL v3 (see
www.gnu.org/licenses).
pluginval IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================*/
#include "../PluginTests.h"
#include "../TestUtilities.h"
#include <future>
#include <thread>
#include <chrono>
//==============================================================================
struct PluginInfoTest : public PluginTest
{
PluginInfoTest()
: PluginTest ("Plugin info", 1)
{
}
void runTest (PluginTests& ut, juce::AudioPluginInstance& instance) override
{
ut.logMessage ("\nPlugin name: " + instance.getName());
ut.logMessage ("Alternative names: " + instance.getAlternateDisplayNames().joinIntoString ("|"));
ut.logMessage ("SupportsDoublePrecision: " + juce::String (instance.supportsDoublePrecisionProcessing() ? "yes" : "no"));
ut.logMessage ("Reported latency: " + juce::String (instance.getLatencySamples()));
ut.logMessage ("Reported taillength: " + juce::String (instance.getTailLengthSeconds()));
}
};
static PluginInfoTest pluginInfoTest;
//==============================================================================
struct PluginPrgramsTest : public PluginTest
{
PluginPrgramsTest()
: PluginTest ("Plugin programs", 2)
{
}
void runTest (PluginTests& ut, juce::AudioPluginInstance& instance) override
{
const int numPrograms = instance.getNumPrograms();
ut.logMessage ("Num programs: " + juce::String (numPrograms));
for (int i = 0; i < numPrograms; ++i)
ut.logVerboseMessage (juce::String ("Program 123 name: XYZ")
.replace ("123",juce::String (i))
.replace ("XYZ", instance.getProgramName (i)));
ut.logMessage ("All program names checked");
if (numPrograms > 0)
{
ut.logMessage ("\nChanging program");
const int currentProgram = instance.getCurrentProgram();
auto r = ut.getRandom();
for (int i = 0; i < 5; ++i)
{
const int programNum = r.nextInt (numPrograms);
ut.logVerboseMessage ("Changing program to: " + juce::String (programNum));
instance.setCurrentProgram (programNum);
}
if (currentProgram >= 0)
{
ut.logVerboseMessage ("Resetting program to: " + juce::String (currentProgram));
instance.setCurrentProgram (currentProgram);
}
else
{
ut.logMessage ("!!! WARNING: Current program is -1... Is this correct?");
}
}
}
};
static PluginPrgramsTest pluginPrgramsTest;
//==============================================================================
struct EditorTest : public PluginTest
{
EditorTest()
: PluginTest ("Editor", 2,
{ Requirements::Thread::messageThread, Requirements::GUI::requiresGUI })
{
}
void runTest (PluginTests& ut, juce::AudioPluginInstance& instance) override
{
if (instance.hasEditor())
{
StopwatchTimer timer;
{
ScopedEditorShower editorShower (instance);
ut.expect (editorShower.editor != nullptr, "Unable to create editor");
ut.logVerboseMessage ("\nTime taken to open editor (cold): " + timer.getDescription());
}
{
timer.reset();
ScopedEditorShower editorShower (instance);
ut.expect (editorShower.editor != nullptr, "Unable to create editor on second attempt");
ut.logVerboseMessage ("Time taken to open editor (warm): " + timer.getDescription());
}
}
}
};
static EditorTest editorTest;
//==============================================================================
struct EditorWhilstProcessingTest : public PluginTest
{
EditorWhilstProcessingTest()
: PluginTest ("Open editor whilst processing", 4,
{ Requirements::Thread::messageThread, Requirements::GUI::requiresGUI })
{
}
void runTest (PluginTests& ut, juce::AudioPluginInstance& instance) override
{
if (instance.hasEditor())
{
callReleaseResourcesOnMessageThreadIfVST3 (instance);
const std::vector<double>& sampleRates = ut.getOptions().sampleRates;
const std::vector<int>& blockSizes = ut.getOptions().blockSizes;
jassert (sampleRates.size() > 0 && blockSizes.size() > 0);
callPrepareToPlayOnMessageThreadIfVST3 (instance, sampleRates[0], blockSizes[0]);
const int numChannelsRequired = juce::jmax (instance.getTotalNumInputChannels(), instance.getTotalNumOutputChannels());
juce::AudioBuffer<float> ab (numChannelsRequired, instance.getBlockSize());
juce::MidiBuffer mb;
juce::WaitableEvent threadStartedEvent;
std::atomic<bool> shouldProcess { true };
auto processThread = std::async (std::launch::async,
[&]
{
while (shouldProcess)
{
fillNoise (ab);
instance.processBlock (ab, mb);
mb.clear();
threadStartedEvent.signal();
}
});
threadStartedEvent.wait();
// Show the editor
ScopedEditorShower editor (instance);
ut.expect (editor.editor.get() != nullptr || ! instance.hasEditor(), "Unable to create editor");
shouldProcess = false;
}
}
};
static EditorWhilstProcessingTest editorWhilstProcessingTest;
//==============================================================================
struct AudioProcessingTest : public PluginTest
{
AudioProcessingTest()
: PluginTest ("Audio processing", 3)
{
}
static void runAudioProcessingTest (PluginTests& ut, juce::AudioPluginInstance& instance,
bool callReleaseResourcesBeforeSampleRateChange)
{
const bool isPluginInstrument = instance.getPluginDescription().isInstrument;
const std::vector<double>& sampleRates = ut.getOptions().sampleRates;
const std::vector<int>& blockSizes = ut.getOptions().blockSizes;
jassert (sampleRates.size()>0 && blockSizes.size()>0);
callPrepareToPlayOnMessageThreadIfVST3 (instance, sampleRates[0], blockSizes[0]);
const int numBlocks = 10;
auto r = ut.getRandom();
for (auto sr : sampleRates)
{
for (auto bs : blockSizes)
{
ut.logMessage (juce::String ("Testing with sample rate [SR] and block size [BS]")
.replace ("SR",juce::String (sr, 0), false)
.replace ("BS",juce::String (bs), false));
if (callReleaseResourcesBeforeSampleRateChange)
callReleaseResourcesOnMessageThreadIfVST3 (instance);
callPrepareToPlayOnMessageThreadIfVST3 (instance, sr, bs);
const int numChannelsRequired = juce::jmax (instance.getTotalNumInputChannels(), instance.getTotalNumOutputChannels());
juce::AudioBuffer<float> ab (numChannelsRequired, bs);
juce::MidiBuffer mb;
// Add a random note on if the plugin is a synth
const int noteChannel = r.nextInt ({ 1, 17 });
const int noteNumber = r.nextInt (128);
if (isPluginInstrument)
addNoteOn (mb, noteChannel, noteNumber, juce::jmin (10, bs));
for (int i = 0; i < numBlocks; ++i)
{
// Add note off in last block if plugin is a synth
if (isPluginInstrument && i == (numBlocks - 1))
addNoteOff (mb, noteChannel, noteNumber, 0);
fillNoise (ab);
instance.processBlock (ab, mb);
mb.clear();
ut.expectEquals (countNaNs (ab), 0, "NaNs found in buffer");
ut.expectEquals (countInfs (ab), 0, "Infs found in buffer");
ut.expectEquals (countSubnormals (ab), 0, "Subnormals found in buffer");
}
}
}
}
void runTest (PluginTests& ut, juce::AudioPluginInstance& instance) override
{
runAudioProcessingTest (ut, instance, true);
}
};
static AudioProcessingTest audioProcessingTest;
//==============================================================================
/**
Test that process some audio changing the sample rate between runs but doesn't
call releaseResources between calls to prepare to play.
*/
struct NonReleasingAudioProcessingTest : public PluginTest
{
NonReleasingAudioProcessingTest()
: PluginTest ("Non-releasing audio processing", 6)
{
}
void runTest (PluginTests& ut, juce::AudioPluginInstance& instance) override
{
AudioProcessingTest::runAudioProcessingTest (ut, instance, false);
}
};
static NonReleasingAudioProcessingTest nonReleasingAudioProcessingTest;
//==============================================================================
struct PluginStateTest : public PluginTest
{
PluginStateTest()
: PluginTest ("Plugin state", 2)
{
}
void runTest (PluginTests& ut, juce::AudioPluginInstance& instance) override
{
auto r = ut.getRandom();
// Read state
auto originalState = callGetStateInformationOnMessageThreadIfVST3 (instance);
// Set random parameter values
for (auto parameter : getNonBypassAutomatableParameters (instance))
parameter->setValue (r.nextFloat());
// Restore original state
callSetStateInformationOnMessageThreadIfVST3 (instance, originalState);
}
};
static PluginStateTest pluginStateTest;
//==============================================================================
struct PluginStateTestRestoration : public PluginTest
{
PluginStateTestRestoration()
: PluginTest ("Plugin state restoration", 6)
{
}
void runTest (PluginTests& ut, juce::AudioPluginInstance& instance) override
{
auto r = ut.getRandom();
// Read state
auto originalState = callGetStateInformationOnMessageThreadIfVST3 (instance);
const auto tolaratedDiff = 0.1f;
// Set random parameter values
for (auto parameter : getNonBypassAutomatableParameters(instance))
{
const auto originalValue = parameter->getValue();
parameter->setValue(r.nextFloat());
// Restore original state
callSetStateInformationOnMessageThreadIfVST3(instance, originalState);
// Check parameter values return to original
ut.expectWithinAbsoluteError(parameter->getValue(), originalValue, tolaratedDiff,
parameter->getName(1024) + juce::String(" not restored on setStateInformation"));
}
if (strictnessLevel >= 8)
{
// Read state again and compare to what we set
auto duplicateState = callGetStateInformationOnMessageThreadIfVST3 (instance);
ut.expect (duplicateState.matches (originalState.getData(), originalState.getSize()),
"Returned state differs from that set by host");
}
}
};
static PluginStateTestRestoration pluginStateTestRestoration;
//==============================================================================
struct AutomationTest : public PluginTest
{
AutomationTest()
: PluginTest ("Automation", 3)
{
}
void runTest (PluginTests& ut, juce::AudioPluginInstance& instance) override
{
const bool subnormalsAreErrors = ut.getOptions().strictnessLevel > 5;
const bool isPluginInstrument = instance.getPluginDescription().isInstrument;
const std::vector<double>& sampleRates = ut.getOptions().sampleRates;
const std::vector<int>& blockSizes = ut.getOptions().blockSizes;
jassert (sampleRates.size() > 0 && blockSizes.size() > 0);
callReleaseResourcesOnMessageThreadIfVST3 (instance);
callPrepareToPlayOnMessageThreadIfVST3 (instance, sampleRates[0], blockSizes[0]);
auto r = ut.getRandom();
for (auto sr : sampleRates)
{
for (auto bs : blockSizes)
{
const int subBlockSize = 32;
ut.logMessage (juce::String ("Testing with sample rate [SR] and block size [BS] and sub-block size [SB]")
.replace ("SR",juce::String (sr, 0), false)
.replace ("BS",juce::String (bs), false)
.replace ("SB",juce::String (subBlockSize), false));
callReleaseResourcesOnMessageThreadIfVST3 (instance);
callPrepareToPlayOnMessageThreadIfVST3 (instance, sr, bs);
int numSamplesDone = 0;
const int numChannelsRequired = juce::jmax (instance.getTotalNumInputChannels(), instance.getTotalNumOutputChannels());
juce::AudioBuffer<float> ab (numChannelsRequired, bs);
juce::MidiBuffer mb;
// Add a random note on if the plugin is a synth
const int noteChannel = r.nextInt ({ 1, 17 });
const int noteNumber = r.nextInt (128);
if (isPluginInstrument)
addNoteOn (mb, noteChannel, noteNumber, juce::jmin (10, subBlockSize));
for (;;)
{
// Set random parameter values
{
auto parameters = getNonBypassAutomatableParameters (instance);
for (int i = 0; i < juce::jmin (10, parameters.size()); ++i)
{
const int paramIndex = r.nextInt (parameters.size());
parameters[paramIndex]->setValue (r.nextFloat());
}
}
// Create a sub-buffer and process
const int numSamplesThisTime = juce::jmin (subBlockSize, bs - numSamplesDone);
// Trigger a note off in the last sub block
if (isPluginInstrument && (bs - numSamplesDone) <= subBlockSize)
addNoteOff (mb, noteChannel, noteNumber, juce::jmin (10, subBlockSize));
juce::AudioBuffer<float> subBuffer (ab.getArrayOfWritePointers(),
ab.getNumChannels(),
numSamplesDone,
numSamplesThisTime);
fillNoise (subBuffer);
instance.processBlock (subBuffer, mb);
numSamplesDone += numSamplesThisTime;
mb.clear();
if (numSamplesDone >= bs)
break;
}
ut.expectEquals (countNaNs (ab), 0, "NaNs found in buffer");
ut.expectEquals (countInfs (ab), 0, "Infs found in buffer");
const int subnormals = countSubnormals (ab);
if (subnormalsAreErrors)
ut.expectEquals (countInfs (ab), 0, "Subnormals found in buffer");
else if (subnormals > 0)
ut.logMessage ("!!! WARNING: " + juce::String (countSubnormals (ab)) + " subnormals found in buffer");
}
}
}
};
static AutomationTest automationTest;
//==============================================================================
struct EditorAutomationTest : public PluginTest
{
EditorAutomationTest()
: PluginTest ("Editor Automation", 5,
{ Requirements::Thread::backgroundThread, Requirements::GUI::requiresGUI })
{
}
void runTest (PluginTests& ut, juce::AudioPluginInstance& instance) override
{
const ScopedEditorShower editor (instance);
auto r = ut.getRandom();
const auto& parameters = instance.getParameters();
int numBlocks = ut.getOptions().strictnessLevel > 5 ? 1000 : 100;
// Set random parameter values
while (--numBlocks >= 0)
{
for (auto parameter : parameters)
parameter->setValue (r.nextFloat());
ut.resetTimeout();
juce::Thread::sleep (10);
}
}
};
static EditorAutomationTest editorAutomationTest;
//==============================================================================
namespace ParameterHelpers
{
static void testParameterInfo (PluginTests& ut, juce::AudioProcessorParameter& parameter)
{
const int index = parameter.getParameterIndex();
const juce::String paramName = parameter.getName (512);
const float defaultValue = parameter.getDefaultValue();
const juce::String label = parameter.getLabel();
const int numSteps = parameter.getNumSteps();
const bool isDiscrete = parameter.isDiscrete();
const bool isBoolean = parameter.isBoolean();
const juce::StringArray allValueStrings = parameter.isDiscrete() ? parameter.getAllValueStrings() : juce::StringArray();
const bool isOrientationInverted = parameter.isOrientationInverted();
const bool isAutomatable = parameter.isAutomatable();
const bool isMetaParameter = parameter.isMetaParameter();
const auto category = parameter.getCategory();
#define LOGP(x) JUCE_STRINGIFY(x) + " - " + juce::String (x) + ", "
#define LOGP_B(x) JUCE_STRINGIFY(x) + " - " + juce::String (static_cast<int> (x)) + ", "
ut.logVerboseMessage (juce::String ("Parameter info: ")
+ LOGP(index)
+ LOGP(paramName)
+ LOGP(defaultValue)
+ LOGP(label)
+ LOGP(numSteps)
+ LOGP_B(isDiscrete)
+ LOGP_B(isBoolean)
+ LOGP_B(isOrientationInverted)
+ LOGP_B(isAutomatable)
+ LOGP_B(isMetaParameter)
+ LOGP_B(category)
+ "all value strings - " + allValueStrings.joinIntoString ("|"));
}
static void testParameterDefaults (PluginTests& ut, juce::AudioProcessorParameter& parameter)
{
ut.logVerboseMessage ("Testing accessors");
const float value = parameter.getValue();
const juce::String text = parameter.getText (value, 1024);
const float valueForText = parameter.getValueForText (text);
const juce::String currentValueAsText = parameter.getCurrentValueAsText();
ignoreUnused (value, text, valueForText, currentValueAsText);
}
}
struct AutomatableParametersTest : public PluginTest
{
AutomatableParametersTest()
: PluginTest ("Automatable Parameters", 2)
{
}
void runTest (PluginTests& ut, juce::AudioPluginInstance& instance) override
{
for (auto parameter : getNonBypassAutomatableParameters (instance))
{
ut.logVerboseMessage (juce::String ("\nTesting parameter: ") + juce::String (parameter->getParameterIndex()) + " - " + parameter->getName (512));
ParameterHelpers::testParameterInfo (ut, *parameter);
ParameterHelpers::testParameterDefaults (ut, *parameter);
}
}
};
static AutomatableParametersTest automatableParametersTest;
//==============================================================================
struct AllParametersTest : public PluginTest
{
AllParametersTest()
: PluginTest ("Parameters", 7)
{
}
void runTest (PluginTests& ut, juce::AudioPluginInstance& instance) override
{
for (auto parameter : getNonBypassAutomatableParameters (instance))
{
ut.logVerboseMessage (juce::String ("\nTesting parameter: ") + juce::String (parameter->getParameterIndex()) + " - " + parameter->getName (512));
ParameterHelpers::testParameterInfo (ut, *parameter);
ParameterHelpers::testParameterDefaults (ut, *parameter);
}
}
};
static AllParametersTest allParametersTest;
//==============================================================================
/** Sets plugin state from a background thread whilst the plugin window is
created on the main thread. This simulates behaviour seen in certain hosts.
*/
struct BackgroundThreadStateTest : public PluginTest
{
BackgroundThreadStateTest()
: PluginTest ("Background thread state", 7,
{ Requirements::Thread::backgroundThread, Requirements::GUI::requiresGUI })
{
}
void runTest (PluginTests& ut, juce::AudioPluginInstance& instance) override
{
auto r = ut.getRandom();
ScopedEditorShower editor (instance);
auto parameters = getNonBypassAutomatableParameters (instance);
// Read state
auto originalState = callGetStateInformationOnMessageThreadIfVST3 (instance);
// Set random parameter values
for (auto parameter : parameters)
parameter->setValue (r.nextFloat());
// Restore original state
callSetStateInformationOnMessageThreadIfVST3 (instance, originalState);
// Allow for async reaction to state changes
juce::Thread::sleep (2000);
}
};
static BackgroundThreadStateTest backgroundThreadStateTest;
//==============================================================================
/** Sets plugin parameters from a background thread and the main thread at the
same time, as if via host automation and UI simultaneously.
*/
struct ParameterThreadSafetyTest : public PluginTest
{
ParameterThreadSafetyTest()
: PluginTest ("Parameter thread safety", 7)
{
}
void runTest (PluginTests& ut, juce::AudioPluginInstance& instance) override
{
juce::WaitableEvent startWaiter, endWaiter;
auto r = ut.getRandom();
auto parameters = getNonBypassAutomatableParameters (instance);
const bool isPluginInstrument = instance.getPluginDescription().isInstrument;
const int numBlocks = 500;
// This emulates the plugin itself setting a value for example from a slider within its UI
juce::MessageManager::callAsync ([&, threadRandom = r]() mutable
{
startWaiter.signal();
for (int i = 0; i < numBlocks; ++i)
for (auto param : parameters)
param->setValueNotifyingHost (threadRandom.nextFloat());
endWaiter.signal();
});
const int blockSize = 32;
callReleaseResourcesOnMessageThreadIfVST3 (instance);
callPrepareToPlayOnMessageThreadIfVST3 (instance, 44100.0, blockSize);
const int numChannelsRequired = juce::jmax (instance.getTotalNumInputChannels(), instance.getTotalNumOutputChannels());
juce::AudioBuffer<float> ab (numChannelsRequired, blockSize);
juce::MidiBuffer mb;
// Add a random note on if the plugin is a synth
const int noteChannel = r.nextInt ({ 1, 17 });
const int noteNumber = r.nextInt (128);
if (isPluginInstrument)
addNoteOn (mb, noteChannel, noteNumber, juce::jmin (10, blockSize));
startWaiter.wait();
for (int i = 0; i < numBlocks; ++i)
{
// Add note off in last block if plugin is a synth
if (isPluginInstrument && i == (numBlocks - 1))
addNoteOff (mb, noteChannel, noteNumber, 0);
for (auto param : parameters)
param->setValue (r.nextFloat());
fillNoise (ab);
instance.processBlock (ab, mb);
mb.clear();
}
endWaiter.wait();
}
};
static ParameterThreadSafetyTest parameterThreadSafetyTest;
//==============================================================================
/** Runs auval on the plugin if it's an Audio Unit.
*/
struct AUvalTest : public PluginTest
{
AUvalTest()
: PluginTest ("auval", 5)
{
}
void runTest (PluginTests& ut, juce::AudioPluginInstance& instance) override
{
const auto desc = instance.getPluginDescription();
if (desc.pluginFormatName != "AudioUnit")
return;
// Use -stress on strictness levels greater than 5
const auto cmd = juce::String ("auval -strict STRESS -v ").replace ("STRESS", ut.getOptions().strictnessLevel > 5 ? "-stress 20" : "")
+ desc.fileOrIdentifier.fromLastOccurrenceOf ("/", false, false).replace (",", " ");
juce::ChildProcess cp;
const auto started = cp.start (cmd);
ut.expect (started);
if (! started)
return;
juce::MemoryOutputStream outputBuffer;
for (;;)
{
for (;;)
{
char buffer[2048];
if (const auto numBytesRead = cp.readProcessOutput (buffer, sizeof (buffer));
numBytesRead > 0)
{
std::string msg (buffer, (size_t) numBytesRead);
ut.logVerboseMessage (msg);
outputBuffer << juce::String (msg);
}
else
{
break;
}
}
if (! cp.isRunning())
break;
using namespace std::literals;
std::this_thread::sleep_for (100ms);
}
const auto exitedCleanly = cp.getExitCode() == 0;
ut.expect (exitedCleanly);
ut.logMessage ("auval exited with code: " + juce::String (cp.getExitCode()));
if (! exitedCleanly && ! ut.getOptions().verbose)
ut.logMessage (outputBuffer.toString());
}
};
static AUvalTest auvalTest;
//==============================================================================
/** Runs Steinberg's validator on the plugin if it's a VST3.
*/
struct VST3validator : public PluginTest
{
VST3validator()
: PluginTest ("vst3 validator", 5)
{
}
void runTest (PluginTests& ut, juce::AudioPluginInstance& instance) override
{
const auto desc = instance.getPluginDescription();
if (desc.pluginFormatName != "VST3")
return;
auto vst3Validator = ut.getOptions().vst3Validator;
if (vst3Validator == juce::File())
{
ut.logMessage ("INFO: Skipping vst3 validator as validator path hasn't been set");
return;
}
juce::StringArray cmd (vst3Validator.getFullPathName());
if (ut.getOptions().strictnessLevel > 5)
cmd.add ("-e");
cmd.add (desc.fileOrIdentifier);
juce::ChildProcess cp;
const auto started = cp.start (cmd);
ut.expect (started, "VST3 validator app has been set but is unable to start");
if (! started)
return;
juce::MemoryOutputStream outputBuffer;
for (;;)
{
for (;;)
{
char buffer[2048];
if (const auto numBytesRead = cp.readProcessOutput (buffer, sizeof (buffer));
numBytesRead > 0)
{
std::string msg (buffer, (size_t) numBytesRead);
ut.logVerboseMessage (msg);
outputBuffer << juce::String (msg);
}
else
{
break;
}
}
if (! cp.isRunning())
break;
using namespace std::literals;
std::this_thread::sleep_for (100ms);
}
const auto exitedCleanly = cp.getExitCode() == 0;
ut.expect (exitedCleanly);
ut.logMessage ("vst3 validator exited with code: " + juce::String (cp.getExitCode()));
if (! exitedCleanly && ! ut.getOptions().verbose)
ut.logMessage (outputBuffer.toString());
}
};
static VST3validator vst3validator;