VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/utils/audio/vkat.cpp@ 89761

Last change on this file since 89761 was 89761, checked in by vboxsync, 4 years ago

Audio/ValKit: Change the ATS command line parameters to be the same for test and self-test. bugref:10008

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 40.6 KB
Line 
1/* $Id: vkat.cpp 89761 2021-06-17 09:11:54Z vboxsync $ */
2/** @file
3 * Validation Kit Audio Test (VKAT) utility for testing and validating the audio stack.
4 */
5
6/*
7 * Copyright (C) 2021 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*********************************************************************************************************************************
29* Header Files *
30*********************************************************************************************************************************/
31#include <iprt/buildconfig.h>
32#include <iprt/ctype.h>
33#include <iprt/dir.h>
34#include <iprt/errcore.h>
35#include <iprt/file.h>
36#include <iprt/initterm.h>
37#include <iprt/getopt.h>
38#include <iprt/message.h>
39#include <iprt/path.h>
40#include <iprt/process.h>
41#include <iprt/rand.h>
42#include <iprt/stream.h>
43#include <iprt/string.h>
44#include <iprt/test.h>
45
46#include <package-generated.h>
47#include "product-generated.h"
48
49#include <VBox/version.h>
50#include <VBox/log.h>
51
52#ifdef RT_OS_WINDOWS
53# include <iprt/win/windows.h> /* for CoInitializeEx */
54#endif
55#include <signal.h>
56
57#include "vkatInternal.h"
58
59
60/*********************************************************************************************************************************
61* Internal Functions *
62*********************************************************************************************************************************/
63static int audioTestCombineParms(PAUDIOTESTPARMS pBaseParms, PAUDIOTESTPARMS pOverrideParms);
64static int audioVerifyOne(const char *pszPathSetA, const char *pszPathSetB);
65
66
67/*********************************************************************************************************************************
68* Global Variables *
69*********************************************************************************************************************************/
70/**
71 * Backends.
72 *
73 * @note The first backend in the array is the default one for the platform.
74 */
75struct
76{
77 /** The driver registration structure. */
78 PCPDMDRVREG pDrvReg;
79 /** The backend name.
80 * Aliases are implemented by having multiple entries for the same backend. */
81 const char *pszName;
82} const g_aBackends[] =
83{
84#if defined(VBOX_WITH_AUDIO_ALSA) && defined(RT_OS_LINUX)
85 { &g_DrvHostALSAAudio, "alsa" },
86#endif
87#ifdef VBOX_WITH_AUDIO_PULSE
88 { &g_DrvHostPulseAudio, "pulseaudio" },
89 { &g_DrvHostPulseAudio, "pulse" },
90 { &g_DrvHostPulseAudio, "pa" },
91#endif
92#ifdef VBOX_WITH_AUDIO_OSS
93 { &g_DrvHostOSSAudio, "oss" },
94#endif
95#if defined(RT_OS_DARWIN)
96 { &g_DrvHostCoreAudio, "coreaudio" },
97 { &g_DrvHostCoreAudio, "core" },
98 { &g_DrvHostCoreAudio, "ca" },
99#endif
100#if defined(RT_OS_WINDOWS)
101 { &g_DrvHostAudioWas, "wasapi" },
102 { &g_DrvHostAudioWas, "was" },
103 { &g_DrvHostDSound, "directsound" },
104 { &g_DrvHostDSound, "dsound" },
105 { &g_DrvHostDSound, "ds" },
106#endif
107 { &g_DrvHostValidationKitAudio, "valkit" }
108};
109AssertCompile(sizeof(g_aBackends) > 0 /* port me */);
110
111/**
112 * Long option values for the 'test' command.
113 */
114enum
115{
116 VKAT_TEST_OPT_COUNT = 900,
117 VKAT_TEST_OPT_DEV,
118 VKAT_TEST_OPT_GUEST_ATS_ADDR,
119 VKAT_TEST_OPT_GUEST_ATS_PORT,
120 VKAT_TEST_OPT_HOST_ATS_ADDR,
121 VKAT_TEST_OPT_HOST_ATS_PORT,
122 VKAT_TEST_OPT_MODE,
123 VKAT_TEST_OPT_NO_VERIFY,
124 VKAT_TEST_OPT_OUTDIR,
125 VKAT_TEST_OPT_PAUSE,
126 VKAT_TEST_OPT_PCM_HZ,
127 VKAT_TEST_OPT_PCM_BIT,
128 VKAT_TEST_OPT_PCM_CHAN,
129 VKAT_TEST_OPT_PCM_SIGNED,
130 VKAT_TEST_OPT_TAG,
131 VKAT_TEST_OPT_TEMPDIR,
132 VKAT_TEST_OPT_VOL
133};
134
135/**
136 * Long option values for the 'verify' command.
137 */
138enum
139{
140 VKAT_VERIFY_OPT_TAG = 900
141};
142
143/**
144 * Common command line parameters.
145 */
146static const RTGETOPTDEF g_aCmdCommonOptions[] =
147{
148 { "--quiet", 'q', RTGETOPT_REQ_NOTHING },
149 { "--verbose", 'v', RTGETOPT_REQ_NOTHING },
150 { "--debug-audio", AUDIO_TEST_OPT_CMN_DEBUG_AUDIO_ENABLE, RTGETOPT_REQ_NOTHING },
151 { "--debug-audio-path", AUDIO_TEST_OPT_CMN_DEBUG_AUDIO_PATH, RTGETOPT_REQ_STRING },
152};
153
154/**
155 * Command line parameters for test mode.
156 */
157static const RTGETOPTDEF g_aCmdTestOptions[] =
158{
159 { "--backend", 'b', RTGETOPT_REQ_STRING },
160 { "--drvaudio", 'd', RTGETOPT_REQ_NOTHING },
161 { "--exclude", 'e', RTGETOPT_REQ_UINT32 },
162 { "--exclude-all", 'a', RTGETOPT_REQ_NOTHING },
163 { "--guest-ats-addr", VKAT_TEST_OPT_GUEST_ATS_ADDR, RTGETOPT_REQ_STRING },
164 { "--guest-ats-port", VKAT_TEST_OPT_GUEST_ATS_PORT, RTGETOPT_REQ_UINT32 },
165 { "--host-ats-address", VKAT_TEST_OPT_HOST_ATS_ADDR, RTGETOPT_REQ_STRING },
166 { "--host-ats-port", VKAT_TEST_OPT_HOST_ATS_PORT, RTGETOPT_REQ_UINT32 },
167 { "--include", 'i', RTGETOPT_REQ_UINT32 },
168 { "--outdir", VKAT_TEST_OPT_OUTDIR, RTGETOPT_REQ_STRING },
169 { "--count", VKAT_TEST_OPT_COUNT, RTGETOPT_REQ_UINT32 },
170 { "--device", VKAT_TEST_OPT_DEV, RTGETOPT_REQ_STRING },
171 { "--pause", VKAT_TEST_OPT_PAUSE, RTGETOPT_REQ_UINT32 },
172 { "--pcm-bit", VKAT_TEST_OPT_PCM_BIT, RTGETOPT_REQ_UINT8 },
173 { "--pcm-chan", VKAT_TEST_OPT_PCM_CHAN, RTGETOPT_REQ_UINT8 },
174 { "--pcm-hz", VKAT_TEST_OPT_PCM_HZ, RTGETOPT_REQ_UINT16 },
175 { "--pcm-signed", VKAT_TEST_OPT_PCM_SIGNED, RTGETOPT_REQ_BOOL },
176 { "--mode", VKAT_TEST_OPT_MODE, RTGETOPT_REQ_STRING },
177 { "--no-verify", VKAT_TEST_OPT_NO_VERIFY, RTGETOPT_REQ_NOTHING },
178 { "--tag", VKAT_TEST_OPT_TAG, RTGETOPT_REQ_STRING },
179 { "--tempdir", VKAT_TEST_OPT_TEMPDIR, RTGETOPT_REQ_STRING },
180 { "--volume", VKAT_TEST_OPT_VOL, RTGETOPT_REQ_UINT8 }
181};
182
183/**
184 * Command line parameters for verification mode.
185 */
186static const RTGETOPTDEF g_aCmdVerifyOptions[] =
187{
188 { "--tag", VKAT_VERIFY_OPT_TAG, RTGETOPT_REQ_STRING }
189};
190
191/** Terminate ASAP if set. Set on Ctrl-C. */
192bool volatile g_fTerminate = false;
193/** The release logger. */
194PRTLOGGER g_pRelLogger = NULL;
195/** The test handle. */
196RTTEST g_hTest;
197/** The current verbosity level. */
198unsigned g_uVerbosity = 0;
199/** DrvAudio: Enable debug (or not). */
200bool g_fDrvAudioDebug = 0;
201/** DrvAudio: The debug output path. */
202const char *g_pszDrvAudioDebug = NULL;
203
204
205/**
206 * Get default backend.
207 */
208PCPDMDRVREG AudioTestGetDefaultBackend(void)
209{
210 return g_aBackends[0].pDrvReg;
211}
212
213
214/**
215 * Helper for handling --backend options.
216 *
217 * @returns Pointer to the specified backend, NULL if not found (error
218 * displayed).
219 * @param pszBackend The backend option value.
220 */
221PCPDMDRVREG AudioTestFindBackendOpt(const char *pszBackend)
222{
223 for (uintptr_t i = 0; i < RT_ELEMENTS(g_aBackends); i++)
224 if ( strcmp(pszBackend, g_aBackends[i].pszName) == 0
225 || strcmp(pszBackend, g_aBackends[i].pDrvReg->szName) == 0)
226 return g_aBackends[i].pDrvReg;
227 RTMsgError("Unknown backend: '%s'", pszBackend);
228 return NULL;
229}
230
231
232/**
233 * Overrides audio test base parameters with another set.
234 *
235 * @returns VBox status code.
236 * @param pBaseParms Base parameters to override.
237 * @param pOverrideParms Override parameters to use for overriding the base parameters.
238 *
239 * @note Overriding a parameter depends on its type / default values.
240 */
241static int audioTestCombineParms(PAUDIOTESTPARMS pBaseParms, PAUDIOTESTPARMS pOverrideParms)
242{
243 RT_NOREF(pBaseParms, pOverrideParms);
244
245 /** @todo Implement parameter overriding. */
246 return VERR_NOT_IMPLEMENTED;
247}
248
249
250/*********************************************************************************************************************************
251* Test callbacks *
252*********************************************************************************************************************************/
253
254/**
255 * @copydoc FNAUDIOTESTSETUP
256 */
257static DECLCALLBACK(int) audioTestPlayToneSetup(PAUDIOTESTENV pTstEnv, PAUDIOTESTDESC pTstDesc, PAUDIOTESTPARMS pTstParmsAcq, void **ppvCtx)
258{
259 RT_NOREF(pTstEnv, pTstDesc, ppvCtx);
260
261 pTstParmsAcq->enmType = AUDIOTESTTYPE_TESTTONE_PLAY;
262
263 PDMAudioPropsInit(&pTstParmsAcq->Props, 16 /* bit */ / 8, true /* fSigned */, 2 /* Channels */, 44100 /* Hz */);
264
265 pTstParmsAcq->enmDir = PDMAUDIODIR_OUT;
266#ifdef DEBUG
267 pTstParmsAcq->cIterations = 2;
268#else
269 pTstParmsAcq->cIterations = RTRandU32Ex(1, 10);
270#endif
271 pTstParmsAcq->idxCurrent = 0;
272
273 return VINF_SUCCESS;
274}
275
276/**
277 * @copydoc FNAUDIOTESTEXEC
278 */
279static DECLCALLBACK(int) audioTestPlayToneExec(PAUDIOTESTENV pTstEnv, void *pvCtx, PAUDIOTESTPARMS pTstParms)
280{
281 RT_NOREF(pvCtx);
282
283 int rc = VINF_SUCCESS;
284
285 for (uint32_t i = 0; i < pTstParms->cIterations; i++)
286 {
287 AudioTestToneParamsInitRandom(&pTstParms->TestTone, &pTstParms->Props);
288
289 PAUDIOTESTTONEPARMS const pToneParms = &pTstParms->TestTone;
290 rc = AudioTestSvcClientToneRecord(&pTstEnv->u.Host.AtsClValKit, pToneParms);
291 if (RT_SUCCESS(rc))
292 rc = AudioTestSvcClientTonePlay(&pTstEnv->u.Host.AtsClGuest, pToneParms);
293
294 if (RT_FAILURE(rc))
295 RTTestFailed(g_hTest, "Playing tone failed\n");
296 }
297
298 return rc;
299}
300
301/**
302 * @copydoc FNAUDIOTESTDESTROY
303 */
304static DECLCALLBACK(int) audioTestPlayToneDestroy(PAUDIOTESTENV pTstEnv, void *pvCtx)
305{
306 RT_NOREF(pTstEnv, pvCtx);
307
308 return VINF_SUCCESS;
309}
310
311/**
312 * @copydoc FNAUDIOTESTSETUP
313 */
314static DECLCALLBACK(int) audioTestRecordToneSetup(PAUDIOTESTENV pTstEnv, PAUDIOTESTDESC pTstDesc, PAUDIOTESTPARMS pTstParmsAcq, void **ppvCtx)
315{
316 RT_NOREF(pTstEnv, pTstDesc, ppvCtx);
317
318 pTstParmsAcq->enmType = AUDIOTESTTYPE_TESTTONE_RECORD;
319
320 PDMAudioPropsInit(&pTstParmsAcq->Props, 16 /* bit */ / 8, true /* fSigned */, 2 /* Channels */, 44100 /* Hz */);
321
322 pTstParmsAcq->enmDir = PDMAUDIODIR_IN;
323#ifdef DEBUG
324 pTstParmsAcq->cIterations = 2;
325#else
326 pTstParmsAcq->cIterations = RTRandU32Ex(1, 10);
327#endif
328 pTstParmsAcq->idxCurrent = 0;
329
330 return VINF_SUCCESS;
331}
332
333/**
334 * @copydoc FNAUDIOTESTEXEC
335 */
336static DECLCALLBACK(int) audioTestRecordToneExec(PAUDIOTESTENV pTstEnv, void *pvCtx, PAUDIOTESTPARMS pTstParms)
337{
338 RT_NOREF(pvCtx);
339
340 int rc = VINF_SUCCESS;
341
342 for (uint32_t i = 0; i < pTstParms->cIterations; i++)
343 {
344 pTstParms->TestTone.Props = pTstParms->Props;
345#ifdef DEBUG_andy
346 pTstParms->TestTone.msDuration = RTRandU32Ex(50 /* ms */, 2000);
347#else
348 pTstParms->TestTone.msDuration = RTRandU32Ex(50 /* ms */, RT_MS_30SEC); /** @todo Record even longer? */
349#endif
350 /*
351 * 1. Arm the ValKit ATS with the recording parameters.
352 */
353 rc = AudioTestSvcClientTonePlay(&pTstEnv->u.Host.AtsClValKit, &pTstParms->TestTone);
354 if (RT_SUCCESS(rc))
355 {
356 /*
357 * 2. Tell the guest ATS to start recording.
358 */
359 rc = AudioTestSvcClientToneRecord(&pTstEnv->u.Host.AtsClGuest, &pTstParms->TestTone);
360 }
361
362 if (RT_FAILURE(rc))
363 RTTestFailed(g_hTest, "Recording tone failed\n");
364 }
365
366 return rc;
367}
368
369/**
370 * @copydoc FNAUDIOTESTDESTROY
371 */
372static DECLCALLBACK(int) audioTestRecordToneDestroy(PAUDIOTESTENV pTstEnv, void *pvCtx)
373{
374 RT_NOREF(pTstEnv, pvCtx);
375
376 return VINF_SUCCESS;
377}
378
379
380/*********************************************************************************************************************************
381* Test execution *
382*********************************************************************************************************************************/
383
384/** Test definition table. */
385AUDIOTESTDESC g_aTests[] =
386{
387 /* pszTest fExcluded pfnSetup */
388 { "PlayTone", false, audioTestPlayToneSetup, audioTestPlayToneExec, audioTestPlayToneDestroy },
389 { "RecordTone", false, audioTestRecordToneSetup, audioTestRecordToneExec, audioTestRecordToneDestroy }
390};
391/** Number of tests defined. */
392unsigned g_cTests = RT_ELEMENTS(g_aTests);
393
394/**
395 * Runs one specific audio test.
396 *
397 * @returns VBox status code.
398 * @param pTstEnv Test environment to use for running the test.
399 * @param pTstDesc Test to run.
400 * @param uSeq Test sequence # in case there are more tests.
401 * @param pOverrideParms Test parameters for overriding the actual test parameters. Optional.
402 */
403static int audioTestOne(PAUDIOTESTENV pTstEnv, PAUDIOTESTDESC pTstDesc,
404 unsigned uSeq, PAUDIOTESTPARMS pOverrideParms)
405{
406 RT_NOREF(uSeq);
407
408 int rc;
409
410 AUDIOTESTPARMS TstParms;
411 audioTestParmsInit(&TstParms);
412
413 RTTestSub(g_hTest, pTstDesc->pszName);
414
415 if (pTstDesc->fExcluded)
416 {
417 RTTestSkipped(g_hTest, "Excluded from list");
418 return VINF_SUCCESS;
419 }
420
421 void *pvCtx = NULL; /* Test-specific opaque context. Optional and can be NULL. */
422
423 if (pTstDesc->pfnSetup)
424 {
425 rc = pTstDesc->pfnSetup(pTstEnv, pTstDesc, &TstParms, &pvCtx);
426 if (RT_FAILURE(rc))
427 {
428 RTTestFailed(g_hTest, "Test setup failed with %Rrc\n", rc);
429 return rc;
430 }
431 }
432
433 audioTestCombineParms(&TstParms, pOverrideParms);
434
435 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%u: %RU32 iterations\n", uSeq, TstParms.cIterations);
436
437 if (TstParms.Dev.pszName && strlen(TstParms.Dev.pszName)) /** @todo Refine this check. Use pszId for starters! */
438 rc = audioTestDeviceOpen(&TstParms.Dev);
439
440 AssertPtr(pTstDesc->pfnExec);
441 rc = pTstDesc->pfnExec(pTstEnv, pvCtx, &TstParms);
442 if (RT_FAILURE(rc))
443 RTTestFailed(g_hTest, "Test failed with %Rrc\n", rc);
444
445 RTTestSubDone(g_hTest);
446
447 if (pTstDesc->pfnDestroy)
448 {
449 int rc2 = pTstDesc->pfnDestroy(pTstEnv, pvCtx);
450 if (RT_SUCCESS(rc))
451 rc = rc2;
452
453 if (RT_FAILURE(rc2))
454 RTTestFailed(g_hTest, "Test destruction failed with %Rrc\n", rc2);
455 }
456
457 rc = audioTestDeviceClose(&TstParms.Dev);
458
459 audioTestParmsDestroy(&TstParms);
460
461 return rc;
462}
463
464/**
465 * Runs all specified tests in a row.
466 *
467 * @returns VBox status code.
468 * @param pTstEnv Test environment to use for running all tests.
469 * @param pOverrideParms Test parameters for (some / all) specific test parameters. Optional.
470 */
471int audioTestWorker(PAUDIOTESTENV pTstEnv, PAUDIOTESTPARMS pOverrideParms)
472{
473 int rc = VINF_SUCCESS;
474
475 if (pTstEnv->enmMode == AUDIOTESTMODE_GUEST)
476 {
477 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Guest ATS running\n");
478
479 while (!g_fTerminate)
480 RTThreadSleep(100);
481
482 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Shutting down guest ATS ...\n");
483
484 int rc2 = AudioTestSvcShutdown(&pTstEnv->u.Guest.Srv);
485 if (RT_SUCCESS(rc))
486 rc = rc2;
487
488 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Guest ATS shutdown complete\n");
489 }
490 else if (pTstEnv->enmMode == AUDIOTESTMODE_HOST)
491 {
492 RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Using tag '%s'\n", pTstEnv->szTag);
493
494 rc = AudioTestSvcClientTestSetBegin(&pTstEnv->u.Host.AtsClValKit, pTstEnv->szTag);
495 if (RT_SUCCESS(rc))
496 rc = AudioTestSvcClientTestSetBegin(&pTstEnv->u.Host.AtsClGuest, pTstEnv->szTag);
497
498 if (RT_SUCCESS(rc))
499 {
500 unsigned uSeq = 0;
501 for (unsigned i = 0; i < RT_ELEMENTS(g_aTests); i++)
502 {
503 int rc2 = audioTestOne(pTstEnv, &g_aTests[i], uSeq, pOverrideParms);
504 if (RT_SUCCESS(rc))
505 rc = rc2;
506
507 if (!g_aTests[i].fExcluded)
508 uSeq++;
509
510 if (g_fTerminate)
511 break;
512 }
513
514 int rc2 = AudioTestSvcClientTestSetEnd(&pTstEnv->u.Host.AtsClGuest, pTstEnv->szTag);
515 if (RT_SUCCESS(rc))
516 rc = rc2;
517
518 rc2 = AudioTestSvcClientTestSetEnd(&pTstEnv->u.Host.AtsClValKit, pTstEnv->szTag);
519 if (RT_SUCCESS(rc))
520 rc = rc2;
521
522 if (RT_SUCCESS(rc))
523 {
524 /*
525 * Download guest + Validation Kit audio driver test sets to our output directory.
526 */
527 char szFileName[RTPATH_MAX];
528 if (RTStrPrintf2(szFileName, sizeof(szFileName), "%s-guest.tar.gz", pTstEnv->szTag))
529 {
530 rc = RTPathJoin(pTstEnv->u.Host.szPathTestSetGuest, sizeof(pTstEnv->u.Host.szPathTestSetGuest),
531 pTstEnv->szPathOut, szFileName);
532 if (RT_SUCCESS(rc))
533 {
534 if (RTStrPrintf2(szFileName, sizeof(szFileName), "%s-host.tar.gz", pTstEnv->szTag))
535 {
536 rc = RTPathJoin(pTstEnv->u.Host.szPathTestSetValKit, sizeof(pTstEnv->u.Host.szPathTestSetValKit),
537 pTstEnv->szPathOut, szFileName);
538 }
539 else
540 rc = VERR_BUFFER_OVERFLOW;
541 }
542 else
543 rc = VERR_BUFFER_OVERFLOW;
544
545 if (RT_SUCCESS(rc))
546 {
547 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Downloading guest test set to '%s'\n",
548 pTstEnv->u.Host.szPathTestSetGuest);
549 rc = AudioTestSvcClientTestSetDownload(&pTstEnv->u.Host.AtsClGuest,
550 pTstEnv->szTag, pTstEnv->u.Host.szPathTestSetGuest);
551 }
552
553 if (RT_SUCCESS(rc))
554 {
555 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Downloading host test set to '%s'\n",
556 pTstEnv->u.Host.szPathTestSetValKit);
557 rc = AudioTestSvcClientTestSetDownload(&pTstEnv->u.Host.AtsClValKit,
558 pTstEnv->szTag, pTstEnv->u.Host.szPathTestSetValKit);
559 }
560 }
561 else
562 rc = VERR_BUFFER_OVERFLOW;
563
564 if ( RT_SUCCESS(rc)
565 && !pTstEnv->fSkipVerify)
566 {
567 rc = audioVerifyOne(pTstEnv->u.Host.szPathTestSetGuest, pTstEnv->u.Host.szPathTestSetValKit);
568 }
569 else
570 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Verification skipped\n");
571
572 RTFileDelete(pTstEnv->u.Host.szPathTestSetGuest);
573 RTFileDelete(pTstEnv->u.Host.szPathTestSetValKit);
574 }
575 }
576 }
577 else
578 AssertFailed();
579
580 /* Clean up. */
581 RTDirRemove(pTstEnv->szPathTemp);
582 RTDirRemove(pTstEnv->szPathOut);
583
584 if (RT_FAILURE(rc))
585 RTTestFailed(g_hTest, "Test worker failed with %Rrc", rc);
586
587 return rc;
588}
589
590/** Option help for the 'test' command. */
591static DECLCALLBACK(const char *) audioTestCmdTestHelp(PCRTGETOPTDEF pOpt)
592{
593 switch (pOpt->iShort)
594 {
595 case 'd': return "Go via DrvAudio instead of directly interfacing with the backend";
596 case VKAT_TEST_OPT_DEV: return "Use the specified audio device";
597 case VKAT_TEST_OPT_GUEST_ATS_ADDR: return "Address of guest ATS to connect to.";
598 case VKAT_TEST_OPT_GUEST_ATS_PORT: return "Port of guest ATS to connect to [6052].";
599 case VKAT_TEST_OPT_HOST_ATS_ADDR: return "Address of host ATS to connect to.";
600 case VKAT_TEST_OPT_HOST_ATS_PORT: return "Port of host ATS to connect to [6052].";
601 case VKAT_TEST_OPT_MODE: return "Specifies the mode this program runs at";
602 case VKAT_TEST_OPT_NO_VERIFY: return "Skips the verification step.";
603 case 'e': return "Exclude the given test id from the list";
604 case 'a': return "Exclude all tests from the list (useful to enable single tests later with --include)";
605 case 'i': return "Include the given test id in the list";
606 }
607 return NULL;
608}
609
610/**
611 * Main (entry) function for the testing functionality of VKAT.
612 *
613 * @returns Program exit code.
614 * @param pGetState RTGetOpt state.
615 */
616static DECLCALLBACK(RTEXITCODE) audioTestMain(PRTGETOPTSTATE pGetState)
617{
618 AUDIOTESTENV TstEnv;
619 RT_ZERO(TstEnv);
620
621 AUDIOTESTPARMS TstCust;
622 audioTestParmsInit(&TstCust);
623
624 const char *pszDevice = NULL; /* Custom device to use. Can be NULL if not being used. */
625 const char *pszTag = NULL; /* Custom tag to use. Can be NULL if not being used. */
626 PCPDMDRVREG pDrvReg = AudioTestGetDefaultBackend();
627 bool fWithDrvAudio = false;
628 uint8_t cPcmSampleBit = 0;
629 uint8_t cPcmChannels = 0;
630 uint32_t uPcmHz = 0;
631 bool fPcmSigned = true;
632
633 const char *pszGuestTcpAddr = NULL;
634 uint16_t uGuestTcpPort = ATS_TCP_GUEST_DEFAULT_PORT;
635 const char *pszValKitTcpAddr = NULL;
636 uint16_t uValKitTcpPort = ATS_TCP_HOST_DEFAULT_PORT;
637
638 int rc;
639 RTGETOPTUNION ValueUnion;
640 while ((rc = RTGetOpt(pGetState, &ValueUnion)))
641 {
642 switch (rc)
643 {
644 case 'a':
645 for (unsigned i = 0; i < RT_ELEMENTS(g_aTests); i++)
646 g_aTests[i].fExcluded = true;
647 break;
648
649 case 'b':
650 pDrvReg = AudioTestFindBackendOpt(ValueUnion.psz);
651 if (pDrvReg == NULL)
652 return RTEXITCODE_SYNTAX;
653 break;
654
655 case 'd':
656 fWithDrvAudio = true;
657 break;
658
659 case 'e':
660 if (ValueUnion.u32 >= RT_ELEMENTS(g_aTests))
661 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid test number %u passed to --exclude", ValueUnion.u32);
662 g_aTests[ValueUnion.u32].fExcluded = true;
663 break;
664
665 case VKAT_TEST_OPT_GUEST_ATS_ADDR:
666 pszGuestTcpAddr = ValueUnion.psz;
667 break;
668
669 case VKAT_TEST_OPT_GUEST_ATS_PORT:
670 uGuestTcpPort = ValueUnion.u32;
671 break;
672
673 case VKAT_TEST_OPT_HOST_ATS_ADDR:
674 pszValKitTcpAddr = ValueUnion.psz;
675 break;
676
677 case VKAT_TEST_OPT_HOST_ATS_PORT:
678 uValKitTcpPort = ValueUnion.u32;
679 break;
680
681 case VKAT_TEST_OPT_MODE:
682 if (TstEnv.enmMode != AUDIOTESTMODE_UNKNOWN)
683 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Test mode (guest / host) already specified");
684 TstEnv.enmMode = RTStrICmp(ValueUnion.psz, "guest") == 0 ? AUDIOTESTMODE_GUEST : AUDIOTESTMODE_HOST;
685 break;
686
687 case VKAT_TEST_OPT_NO_VERIFY:
688 TstEnv.fSkipVerify = true;
689 break;
690
691 case 'i':
692 if (ValueUnion.u32 >= RT_ELEMENTS(g_aTests))
693 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid test number %u passed to --include", ValueUnion.u32);
694 g_aTests[ValueUnion.u32].fExcluded = false;
695 break;
696
697 case VKAT_TEST_OPT_COUNT:
698 return RTMsgErrorExitFailure("Not yet implemented!");
699
700 case VKAT_TEST_OPT_DEV:
701 pszDevice = ValueUnion.psz;
702 break;
703
704 case VKAT_TEST_OPT_PAUSE:
705 return RTMsgErrorExitFailure("Not yet implemented!");
706
707 case VKAT_TEST_OPT_OUTDIR:
708 rc = RTStrCopy(TstEnv.szPathOut, sizeof(TstEnv.szPathOut), ValueUnion.psz);
709 if (RT_FAILURE(rc))
710 return RTMsgErrorExitFailure("Failed to copy out directory: %Rrc", rc);
711 break;
712
713 case VKAT_TEST_OPT_PCM_BIT:
714 cPcmSampleBit = ValueUnion.u8;
715 break;
716
717 case VKAT_TEST_OPT_PCM_CHAN:
718 cPcmChannels = ValueUnion.u8;
719 break;
720
721 case VKAT_TEST_OPT_PCM_HZ:
722 uPcmHz = ValueUnion.u32;
723 break;
724
725 case VKAT_TEST_OPT_PCM_SIGNED:
726 fPcmSigned = ValueUnion.f;
727 break;
728
729 case VKAT_TEST_OPT_TAG:
730 pszTag = ValueUnion.psz;
731 break;
732
733 case VKAT_TEST_OPT_TEMPDIR:
734 rc = RTStrCopy(TstEnv.szPathTemp, sizeof(TstEnv.szPathTemp), ValueUnion.psz);
735 if (RT_FAILURE(rc))
736 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Temp dir invalid, rc=%Rrc", rc);
737 break;
738
739 case VKAT_TEST_OPT_VOL:
740 TstCust.TestTone.uVolumePercent = ValueUnion.u8;
741 break;
742
743 AUDIO_TEST_COMMON_OPTION_CASES(ValueUnion);
744
745 default:
746 return RTGetOptPrintError(rc, &ValueUnion);
747 }
748 }
749
750 /*
751 * Start testing.
752 */
753 RTTestBanner(g_hTest);
754
755 /* Initialize the custom test parameters with sensible defaults if nothing else is given. */
756 PDMAudioPropsInit(&TstCust.TestTone.Props,
757 cPcmSampleBit ? cPcmSampleBit / 8 : 2 /* 16-bit */, fPcmSigned, cPcmChannels ? cPcmChannels : 2,
758 uPcmHz ? uPcmHz : 44100);
759
760 if (TstEnv.enmMode == AUDIOTESTMODE_UNKNOWN)
761 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "No test mode specified!\n");
762
763 if (TstEnv.enmMode == AUDIOTESTMODE_HOST)
764 {
765 if (!pszGuestTcpAddr)
766 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "--guest-ats-address missing\n");
767 }
768
769 /* For now all tests have the same test environment. */
770 rc = audioTestEnvInit(&TstEnv, pDrvReg, fWithDrvAudio,
771 pszValKitTcpAddr, uValKitTcpPort,
772 pszGuestTcpAddr, uGuestTcpPort);
773 if (RT_SUCCESS(rc))
774 {
775 audioTestWorker(&TstEnv, &TstCust);
776 audioTestEnvDestroy(&TstEnv);
777 }
778
779 audioTestParmsDestroy(&TstCust);
780
781 if (RT_FAILURE(rc)) /* Let us know that something went wrong in case we forgot to mention it. */
782 RTTestFailed(g_hTest, "Testing failed with %Rrc\n", rc);
783
784 /*
785 * Print summary and exit.
786 */
787 return RTTestSummaryAndDestroy(g_hTest);
788}
789
790
791const VKATCMD g_CmdTest =
792{
793 "test",
794 audioTestMain,
795 "Runs audio tests and creates an audio test set.",
796 g_aCmdTestOptions,
797 RT_ELEMENTS(g_aCmdTestOptions),
798 audioTestCmdTestHelp
799};
800
801
802/*********************************************************************************************************************************
803* Command: verify *
804*********************************************************************************************************************************/
805
806static int audioVerifyOpenTestSet(const char *pszPathSet, PAUDIOTESTSET pSet)
807{
808 int rc;
809
810 char szPathExtracted[RTPATH_MAX];
811
812 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Opening test set '%s'\n", pszPathSet);
813
814 const bool fPacked = AudioTestSetIsPacked(pszPathSet);
815 if (fPacked)
816 {
817 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test set is an archive and needs to be unpacked\n");
818
819 char szPathTemp[RTPATH_MAX];
820 rc = RTPathTemp(szPathTemp, sizeof(szPathTemp));
821 if (RT_SUCCESS(rc))
822 {
823 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Using temporary directory '%s'\n", szPathTemp);
824
825 rc = RTPathJoin(szPathExtracted, sizeof(szPathExtracted), szPathTemp, "vkat-XXXX");
826 if (RT_SUCCESS(rc))
827 {
828 rc = RTDirCreateTemp(szPathExtracted, 0755);
829 if (RT_SUCCESS(rc))
830 {
831 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Unpacking archive to '%s'\n", szPathExtracted);
832 rc = AudioTestSetUnpack(pszPathSet, szPathExtracted);
833 if (RT_SUCCESS(rc))
834 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Archive successfully unpacked\n");
835 }
836 }
837 }
838 }
839 else
840 rc = VINF_SUCCESS;
841
842 if (RT_SUCCESS(rc))
843 rc = AudioTestSetOpen(pSet, fPacked ? szPathExtracted : pszPathSet);
844
845 if (RT_FAILURE(rc))
846 RTTestFailed(g_hTest, "Unable to open / unpack test set archive: %Rrc", rc);
847
848 return rc;
849}
850
851/**
852 * Verifies one test set pair.
853 *
854 * @returns VBox status code.
855 * @param pszPathSetA Absolute path to test set A.
856 * @param pszPathSetB Absolute path to test set B.
857 */
858static int audioVerifyOne(const char *pszPathSetA, const char *pszPathSetB)
859{
860 RTTestSubF(g_hTest, "Verifying");
861 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Verifying test set '%s' with test set '%s'\n", pszPathSetA, pszPathSetB);
862
863 AUDIOTESTSET SetA, SetB;
864 int rc = audioVerifyOpenTestSet(pszPathSetA, &SetA);
865 if (RT_SUCCESS(rc))
866 rc = audioVerifyOpenTestSet(pszPathSetB, &SetB);
867
868 if (RT_SUCCESS(rc))
869 {
870 AUDIOTESTERRORDESC errDesc;
871 rc = AudioTestSetVerify(&SetA, &SetB, &errDesc);
872 if (RT_SUCCESS(rc))
873 {
874 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "%RU32 errors occurred while verifying\n", AudioTestErrorDescCount(&errDesc));
875 if (AudioTestErrorDescFailed(&errDesc))
876 {
877 /** @todo Use some AudioTestErrorXXX API for enumeration here later. */
878 PAUDIOTESTERRORENTRY pErrEntry;
879 RTListForEach(&errDesc.List, pErrEntry, AUDIOTESTERRORENTRY, Node)
880 RTTestFailed(g_hTest, pErrEntry->szDesc);
881 }
882 else
883 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Verification successful\n");
884
885 AudioTestErrorDescDestroy(&errDesc);
886 }
887 else
888 RTTestFailed(g_hTest, "Verification failed with %Rrc", rc);
889 }
890
891 AudioTestSetWipe(&SetA);
892 AudioTestSetClose(&SetA);
893
894 AudioTestSetWipe(&SetB);
895 AudioTestSetClose(&SetB);
896
897 RTTestSubDone(g_hTest);
898
899 return rc;
900}
901
902/**
903 * Main (entry) function for the verification functionality of VKAT.
904 *
905 * @returns Program exit code.
906 * @param pGetState RTGetOpt state.
907 */
908static DECLCALLBACK(RTEXITCODE) audioVerifyMain(PRTGETOPTSTATE pGetState)
909{
910 /*
911 * Parse options and process arguments.
912 */
913 const char *apszSets[2] = { NULL, NULL };
914 unsigned iTestSet = 0;
915
916 int rc;
917 RTGETOPTUNION ValueUnion;
918 while ((rc = RTGetOpt(pGetState, &ValueUnion)))
919 {
920 switch (rc)
921 {
922 case VKAT_VERIFY_OPT_TAG:
923 break;
924
925 case VINF_GETOPT_NOT_OPTION:
926 if (iTestSet == 0)
927 RTTestBanner(g_hTest);
928 if (iTestSet >= RT_ELEMENTS(apszSets))
929 return RTMsgErrorExitFailure("Only two test sets can be verified at one time");
930 apszSets[iTestSet++] = ValueUnion.psz;
931 break;
932
933 AUDIO_TEST_COMMON_OPTION_CASES(ValueUnion);
934
935 default:
936 return RTGetOptPrintError(rc, &ValueUnion);
937 }
938 }
939
940 if (!iTestSet)
941 return RTMsgErrorExitFailure("At least one test set must be specified");
942
943 /*
944 * If only test set A is given, default to the current directory
945 * for test set B.
946 */
947 char szDirCur[RTPATH_MAX];
948 if (iTestSet == 1)
949 {
950 rc = RTPathGetCurrent(szDirCur, sizeof(szDirCur));
951 if (RT_SUCCESS(rc))
952 apszSets[1] = szDirCur;
953 else
954 RTTestFailed(g_hTest, "Failed to retrieve current directory: %Rrc", rc);
955 }
956
957 if (RT_SUCCESS(rc))
958 audioVerifyOne(apszSets[0], apszSets[1]);
959
960 /*
961 * Print summary and exit.
962 */
963 return RTTestSummaryAndDestroy(g_hTest);
964}
965
966
967const VKATCMD g_CmdVerify =
968{
969 "verify",
970 audioVerifyMain,
971 "Verifies a formerly created audio test set.",
972 g_aCmdVerifyOptions,
973 RT_ELEMENTS(g_aCmdVerifyOptions),
974 NULL,
975};
976
977
978/*********************************************************************************************************************************
979* Main *
980*********************************************************************************************************************************/
981
982/**
983 * Ctrl-C signal handler.
984 *
985 * This just sets g_fTerminate and hope it will be noticed soon. It restores
986 * the SIGINT action to default, so that a second Ctrl-C will have the normal
987 * effect (just in case the code doesn't respond to g_fTerminate).
988 */
989static void audioTestSignalHandler(int iSig) RT_NOEXCEPT
990{
991 Assert(iSig == SIGINT); RT_NOREF(iSig);
992 RTPrintf("Ctrl-C!\n");
993 ASMAtomicWriteBool(&g_fTerminate, true);
994 signal(SIGINT, SIG_DFL);
995}
996
997/**
998 * Commands.
999 */
1000const VKATCMD *g_apCommands[] =
1001{
1002 &g_CmdTest,
1003 &g_CmdVerify,
1004 &g_CmdEnum,
1005 &g_CmdPlay,
1006 &g_CmdRec,
1007 &g_CmdSelfTest
1008};
1009
1010/**
1011 * Shows tool usage text.
1012 */
1013RTEXITCODE audioTestUsage(PRTSTREAM pStrm)
1014{
1015 RTStrmPrintf(pStrm, "usage: %s [global options] <command> [command-options]\n",
1016 RTPathFilename(RTProcExecutablePath()));
1017 RTStrmPrintf(pStrm,
1018 "\n"
1019 "Global Options:\n"
1020 " --debug-audio\n"
1021 " Enables DrvAudio debugging.\n"
1022 " --debug-audio-path=<path>\n"
1023 " Tells DrvAudio where to put its debug output (wav-files).\n"
1024 " -q, --quiet\n"
1025 " Sets verbosity to zero.\n"
1026 " -v, --verbose\n"
1027 " Increase verbosity.\n"
1028 " -V, --version\n"
1029 " Displays version.\n"
1030 " -h, -?, --help\n"
1031 " Displays help.\n"
1032 );
1033
1034 for (uintptr_t iCmd = 0; iCmd < RT_ELEMENTS(g_apCommands); iCmd++)
1035 {
1036 PCVKATCMD const pCmd = g_apCommands[iCmd];
1037 RTStrmPrintf(pStrm,
1038 "\n"
1039 "Command '%s':\n"
1040 " %s\n"
1041 "Options for '%s':\n",
1042 pCmd->pszCommand, pCmd->pszDesc, pCmd->pszCommand);
1043 PCRTGETOPTDEF const paOptions = pCmd->paOptions;
1044 for (unsigned i = 0; i < pCmd->cOptions; i++)
1045 {
1046 if (RT_C_IS_PRINT(paOptions[i].iShort))
1047 RTStrmPrintf(pStrm, " -%c, %s\n", paOptions[i].iShort, paOptions[i].pszLong);
1048 else
1049 RTStrmPrintf(pStrm, " %s\n", paOptions[i].pszLong);
1050
1051 const char *pszHelp = NULL;
1052 if (pCmd->pfnOptionHelp)
1053 pszHelp = pCmd->pfnOptionHelp(&paOptions[i]);
1054 if (pszHelp)
1055 RTStrmPrintf(pStrm, " %s\n", pszHelp);
1056 }
1057 }
1058 return RTEXITCODE_SUCCESS;
1059}
1060
1061/**
1062 * Shows tool version.
1063 */
1064RTEXITCODE audioTestVersion(void)
1065{
1066 RTPrintf("%s\n", RTBldCfgRevisionStr());
1067 return RTEXITCODE_SUCCESS;
1068}
1069
1070/**
1071 * Shows the logo.
1072 *
1073 * @param pStream Output stream to show logo on.
1074 */
1075static void audioTestShowLogo(PRTSTREAM pStream)
1076{
1077 RTStrmPrintf(pStream, VBOX_PRODUCT " VKAT (Validation Kit Audio Test) Version " VBOX_VERSION_STRING " - r%s\n"
1078 "(C) " VBOX_C_YEAR " " VBOX_VENDOR "\n"
1079 "All rights reserved.\n\n", RTBldCfgRevisionStr());
1080}
1081
1082int main(int argc, char **argv)
1083{
1084 /*
1085 * Init IPRT and globals.
1086 */
1087 RTEXITCODE rcExit = RTTestInitAndCreate("AudioTest", &g_hTest);
1088 if (rcExit != RTEXITCODE_SUCCESS)
1089 return rcExit;
1090
1091#ifdef RT_OS_WINDOWS
1092 HRESULT hrc = CoInitializeEx(NULL /*pReserved*/, COINIT_MULTITHREADED | COINIT_SPEED_OVER_MEMORY | COINIT_DISABLE_OLE1DDE);
1093 if (FAILED(hrc))
1094 RTMsgWarning("CoInitializeEx failed: %#x", hrc);
1095#endif
1096
1097 /*
1098 * Configure release logging to go to stderr.
1099 */
1100 static const char * const g_apszLogGroups[] = VBOX_LOGGROUP_NAMES;
1101 int rc = RTLogCreate(&g_pRelLogger, RTLOGFLAGS_PREFIX_THREAD, "all.e.l", "VKAT_RELEASE_LOG",
1102 RT_ELEMENTS(g_apszLogGroups), g_apszLogGroups, RTLOGDEST_STDERR, NULL /*"vkat-release.log"*/);
1103 if (RT_SUCCESS(rc))
1104 RTLogRelSetDefaultInstance(g_pRelLogger);
1105 else
1106 RTMsgWarning("Failed to create release logger: %Rrc", rc);
1107
1108 /*
1109 * Install a Ctrl-C signal handler.
1110 */
1111#ifdef RT_OS_WINDOWS
1112 signal(SIGINT, audioTestSignalHandler);
1113#else
1114 struct sigaction sa;
1115 RT_ZERO(sa);
1116 sa.sa_handler = audioTestSignalHandler;
1117 sigaction(SIGINT, &sa, NULL);
1118#endif
1119
1120 /*
1121 * Process common options.
1122 */
1123 RTGETOPTSTATE GetState;
1124 rc = RTGetOptInit(&GetState, argc, argv, g_aCmdCommonOptions,
1125 RT_ELEMENTS(g_aCmdCommonOptions), 1 /*idxFirst*/, 0 /*fFlags - must not sort! */);
1126 AssertRCReturn(rc, RTEXITCODE_INIT);
1127
1128 RTGETOPTUNION ValueUnion;
1129 while ((rc = RTGetOpt(&GetState, &ValueUnion)) != 0)
1130 {
1131 switch (rc)
1132 {
1133 case 'q':
1134 g_uVerbosity = 0;
1135 if (g_pRelLogger)
1136 RTLogGroupSettings(g_pRelLogger, "all=0 all.e");
1137 break;
1138
1139 case 'v':
1140 g_uVerbosity++;
1141 if (g_pRelLogger)
1142 RTLogGroupSettings(g_pRelLogger, g_uVerbosity == 1 ? "all.e.l" : g_uVerbosity == 2 ? "all.e.l.f" : "all=~0");
1143 break;
1144
1145 case 'V':
1146 return audioTestVersion();
1147
1148 case 'h':
1149 audioTestShowLogo(g_pStdOut);
1150 return audioTestUsage(g_pStdOut);
1151
1152 case VINF_GETOPT_NOT_OPTION:
1153 {
1154 for (uintptr_t iCmd = 0; iCmd < RT_ELEMENTS(g_apCommands); iCmd++)
1155 {
1156 PCVKATCMD const pCmd = g_apCommands[iCmd];
1157 if (strcmp(ValueUnion.psz, pCmd->pszCommand) == 0)
1158 {
1159 size_t const cCombinedOptions = pCmd->cOptions + RT_ELEMENTS(g_aCmdCommonOptions);
1160 PRTGETOPTDEF paCombinedOptions = (PRTGETOPTDEF)RTMemAlloc(cCombinedOptions * sizeof(RTGETOPTDEF));
1161 if (paCombinedOptions)
1162 {
1163 memcpy(paCombinedOptions, g_aCmdCommonOptions, sizeof(g_aCmdCommonOptions));
1164 memcpy(&paCombinedOptions[RT_ELEMENTS(g_aCmdCommonOptions)],
1165 pCmd->paOptions, pCmd->cOptions * sizeof(RTGETOPTDEF));
1166
1167 rc = RTGetOptInit(&GetState, argc, argv, paCombinedOptions, cCombinedOptions,
1168 GetState.iNext /*idxFirst*/, RTGETOPTINIT_FLAGS_OPTS_FIRST);
1169 if (RT_SUCCESS(rc))
1170 {
1171
1172 rcExit = pCmd->pfnHandler(&GetState);
1173 RTMemFree(paCombinedOptions);
1174 return rcExit;
1175 }
1176 return RTMsgErrorExitFailure("RTGetOptInit failed for '%s': %Rrc", ValueUnion.psz, rc);
1177 }
1178 return RTMsgErrorExitFailure("Out of memory!");
1179 }
1180 }
1181 RTMsgError("Unknown command '%s'!\n", ValueUnion.psz);
1182 audioTestUsage(g_pStdErr);
1183 return RTEXITCODE_SYNTAX;
1184 }
1185
1186 default:
1187 return RTGetOptPrintError(rc, &ValueUnion);
1188 }
1189 }
1190
1191 RTMsgError("No command specified!\n");
1192 audioTestUsage(g_pStdErr);
1193 return RTEXITCODE_SYNTAX;
1194}
1195
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette