VirtualBox

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

最後變更 在這個檔案是 107909,由 vboxsync 提交於 8 週 前

Audio/VKAT: Added optional parameter '--drvhost-cache-enabled <true|false>' to disable caching code for host backends which support this. Defaults to enabled (as before). bugref:10844

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 61.3 KB
 
1/* $Id: vkat.cpp 107909 2025-01-23 13:53:00Z vboxsync $ */
2/** @file
3 * Validation Kit Audio Test (VKAT) utility for testing and validating the audio stack.
4 */
5
6/*
7 * Copyright (C) 2021-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.alldomusa.eu.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37
38/*********************************************************************************************************************************
39* Header Files *
40*********************************************************************************************************************************/
41#define LOG_GROUP LOG_GROUP_AUDIO_TEST
42
43#include <iprt/buildconfig.h>
44#include <iprt/ctype.h>
45#include <iprt/dir.h>
46#include <iprt/errcore.h>
47#include <iprt/file.h>
48#include <iprt/initterm.h>
49#include <iprt/getopt.h>
50#include <iprt/message.h>
51#include <iprt/path.h>
52#include <iprt/process.h>
53#include <iprt/rand.h>
54#include <iprt/stream.h>
55#include <iprt/string.h>
56#include <iprt/test.h>
57
58#include <package-generated.h>
59#include "product-generated.h"
60
61#include <VBox/version.h>
62#include <VBox/log.h>
63
64#ifdef RT_OS_WINDOWS
65# include <iprt/win/windows.h> /* for CoInitializeEx and SetConsoleCtrlHandler */
66#else
67# include <signal.h>
68#endif
69
70#include "vkatInternal.h"
71
72
73/*********************************************************************************************************************************
74* Internal Functions *
75*********************************************************************************************************************************/
76static int audioVerifyOne(const char *pszPathSetA, const char *pszPathSetB, PAUDIOTESTVERIFYOPTS pOpts);
77
78
79/*********************************************************************************************************************************
80* Global Variables *
81*********************************************************************************************************************************/
82/**
83 * Backends description table.
84 *
85 * @note The first backend in the array is the default one for the platform.
86 */
87AUDIOTESTBACKENDDESC const g_aBackends[] =
88{
89#ifdef VBOX_WITH_AUDIO_PULSE
90 { &g_DrvHostPulseAudio, "pulseaudio" },
91 { &g_DrvHostPulseAudio, "pulse" },
92 { &g_DrvHostPulseAudio, "pa" },
93#endif
94/*
95 * Note: ALSA has to come second so that PulseAudio above always is the default on Linux-y OSes
96 * -- most distros are using an ALSA plugin for PulseAudio nowadays.
97 * However, some of these configurations do not seem to work by default (can't create audio streams).
98 *
99 * If PulseAudio is not available, the (optional) probing ("--probe-backends") will choose the "pure" ALSA stack instead then.
100 */
101#if defined(VBOX_WITH_AUDIO_ALSA) && defined(RT_OS_LINUX)
102 { &g_DrvHostALSAAudio, "alsa" },
103#endif
104#ifdef VBOX_WITH_AUDIO_OSS
105 { &g_DrvHostOSSAudio, "oss" },
106#endif
107#if defined(RT_OS_DARWIN)
108 { &g_DrvHostCoreAudio, "coreaudio" },
109 { &g_DrvHostCoreAudio, "core" },
110 { &g_DrvHostCoreAudio, "ca" },
111#endif
112#if defined(RT_OS_WINDOWS)
113 { &g_DrvHostAudioWas, "wasapi" },
114 { &g_DrvHostAudioWas, "was" },
115 { &g_DrvHostDSound, "directsound" },
116 { &g_DrvHostDSound, "dsound" },
117 { &g_DrvHostDSound, "ds" },
118#endif
119#ifdef VBOX_WITH_AUDIO_DEBUG
120 { &g_DrvHostDebugAudio, "debug" },
121#endif
122 { &g_DrvHostValidationKitAudio, "valkit" }
123};
124AssertCompile(sizeof(g_aBackends) > 0 /* port me */);
125/** Number of backends defined. */
126unsigned g_cBackends = RT_ELEMENTS(g_aBackends);
127
128/**
129 * Long option values for the 'test' command.
130 */
131enum
132{
133 VKAT_TEST_OPT_COUNT = 900,
134 VKAT_TEST_OPT_DEV,
135 VKAT_TEST_OPT_MODE,
136 VKAT_TEST_OPT_NO_AUDIO_OK,
137 VKAT_TEST_OPT_NO_VERIFY,
138 VKAT_TEST_OPT_OUTDIR,
139 VKAT_TEST_OPT_PAUSE,
140 VKAT_TEST_OPT_PCM_HZ,
141 VKAT_TEST_OPT_PCM_BIT,
142 VKAT_TEST_OPT_PCM_CHAN,
143 VKAT_TEST_OPT_PCM_SIGNED,
144 VKAT_TEST_OPT_PROBE_BACKENDS,
145 VKAT_TEST_OPT_TAG,
146 VKAT_TEST_OPT_TIMEOUT,
147 VKAT_TEST_OPT_TEMPDIR,
148 VKAT_TEST_OPT_VOL,
149 VKAT_TEST_OPT_TCP_BIND_ADDRESS,
150 VKAT_TEST_OPT_TCP_BIND_PORT,
151 VKAT_TEST_OPT_TCP_CONNECT_ADDRESS,
152 VKAT_TEST_OPT_TCP_CONNECT_PORT,
153 VKAT_TEST_OPT_TONE_DURATION_MS,
154 VKAT_TEST_OPT_TONE_VOL_PERCENT
155};
156
157/**
158 * Long option values for the 'verify' command.
159 */
160enum
161{
162 VKAT_VERIFY_OPT_MAX_DIFF_COUNT = 900,
163 VKAT_VERIFY_OPT_MAX_DIFF_PERCENT,
164 VKAT_VERIFY_OPT_MAX_SIZE_PERCENT,
165 VKAT_VERIFY_OPT_NORMALIZE
166};
167
168/**
169 * Common command line parameters.
170 */
171static const RTGETOPTDEF g_aCmdCommonOptions[] =
172{
173 { "--quiet", 'q', RTGETOPT_REQ_NOTHING },
174 { "--verbose", 'v', RTGETOPT_REQ_NOTHING },
175 { "--daemonize", AUDIO_TEST_OPT_CMN_DAEMONIZE, RTGETOPT_REQ_NOTHING },
176 { "--daemonized", AUDIO_TEST_OPT_CMN_DAEMONIZED, RTGETOPT_REQ_NOTHING },
177 { "--debug-audio", AUDIO_TEST_OPT_CMN_DEBUG_AUDIO_ENABLE, RTGETOPT_REQ_NOTHING },
178 { "--debug-audio-path", AUDIO_TEST_OPT_CMN_DEBUG_AUDIO_PATH, RTGETOPT_REQ_STRING },
179 { "--drvhost-cache-enabled", AUDIO_TEST_OPT_CMN_DRVHOST_CACHE_ENABLED, RTGETOPT_REQ_BOOL },
180};
181
182/**
183 * Command line parameters for test mode.
184 */
185static const RTGETOPTDEF g_aCmdTestOptions[] =
186{
187 { "--backend", 'b', RTGETOPT_REQ_STRING },
188 { "--drvaudio", 'd', RTGETOPT_REQ_NOTHING },
189 { "--exclude", 'e', RTGETOPT_REQ_UINT32 },
190 { "--exclude-all", 'a', RTGETOPT_REQ_NOTHING },
191 { "--include", 'i', RTGETOPT_REQ_UINT32 },
192 { "--outdir", VKAT_TEST_OPT_OUTDIR, RTGETOPT_REQ_STRING },
193 { "--count", VKAT_TEST_OPT_COUNT, RTGETOPT_REQ_UINT32 },
194 { "--device", VKAT_TEST_OPT_DEV, RTGETOPT_REQ_STRING },
195 { "--pause", VKAT_TEST_OPT_PAUSE, RTGETOPT_REQ_UINT32 },
196 { "--pcm-bit", VKAT_TEST_OPT_PCM_BIT, RTGETOPT_REQ_UINT8 },
197 { "--pcm-chan", VKAT_TEST_OPT_PCM_CHAN, RTGETOPT_REQ_UINT8 },
198 { "--pcm-hz", VKAT_TEST_OPT_PCM_HZ, RTGETOPT_REQ_UINT16 },
199 { "--pcm-signed", VKAT_TEST_OPT_PCM_SIGNED, RTGETOPT_REQ_BOOL },
200 { "--probe-backends", VKAT_TEST_OPT_PROBE_BACKENDS, RTGETOPT_REQ_NOTHING },
201 { "--mode", VKAT_TEST_OPT_MODE, RTGETOPT_REQ_STRING },
202 { "--no-audio-ok", VKAT_TEST_OPT_NO_AUDIO_OK, RTGETOPT_REQ_NOTHING },
203 { "--no-verify", VKAT_TEST_OPT_NO_VERIFY, RTGETOPT_REQ_NOTHING },
204 { "--tag", VKAT_TEST_OPT_TAG, RTGETOPT_REQ_STRING },
205 { "--tempdir", VKAT_TEST_OPT_TEMPDIR, RTGETOPT_REQ_STRING },
206 { "--timeout", VKAT_TEST_OPT_TIMEOUT, RTGETOPT_REQ_UINT32 },
207 { "--vol", VKAT_TEST_OPT_VOL, RTGETOPT_REQ_UINT8 },
208 { "--tcp-bind-addr", VKAT_TEST_OPT_TCP_BIND_ADDRESS, RTGETOPT_REQ_STRING },
209 { "--tcp-bind-port", VKAT_TEST_OPT_TCP_BIND_PORT, RTGETOPT_REQ_UINT16 },
210 { "--tcp-connect-addr", VKAT_TEST_OPT_TCP_CONNECT_ADDRESS, RTGETOPT_REQ_STRING },
211 { "--tcp-connect-port", VKAT_TEST_OPT_TCP_CONNECT_PORT, RTGETOPT_REQ_UINT16 },
212 { "--tone-duration", VKAT_TEST_OPT_TONE_DURATION_MS, RTGETOPT_REQ_UINT32 },
213 { "--tone-vol", VKAT_TEST_OPT_TONE_VOL_PERCENT, RTGETOPT_REQ_UINT8 }
214};
215
216/**
217 * Command line parameters for verification mode.
218 */
219static const RTGETOPTDEF g_aCmdVerifyOptions[] =
220{
221 { "--max-diff-count", VKAT_VERIFY_OPT_MAX_DIFF_COUNT, RTGETOPT_REQ_UINT32 },
222 { "--max-diff-percent", VKAT_VERIFY_OPT_MAX_DIFF_PERCENT, RTGETOPT_REQ_UINT8 },
223 { "--max-size-percent", VKAT_VERIFY_OPT_MAX_SIZE_PERCENT, RTGETOPT_REQ_UINT8 },
224 { "--normalize", VKAT_VERIFY_OPT_NORMALIZE, RTGETOPT_REQ_BOOL }
225};
226
227/** Terminate ASAP if set. Set on Ctrl-C. */
228bool volatile g_fTerminate = false;
229/** The release logger. */
230PRTLOGGER g_pRelLogger = NULL;
231/** The test handle. */
232RTTEST g_hTest;
233/** The current verbosity level. */
234unsigned g_uVerbosity = 0;
235/** DrvAudio: Enable debug (or not). */
236bool g_fDrvAudioDebug = false;
237/** DrvAudio: The debug output path. */
238const char *g_pszDrvAudioDebug = NULL;
239/** Whether the host audio driver backend's caching is enabled or not. Defaults to enabled.
240 * Only implemented for DrvHostAudioWasApi backend so far, ignored otherwise. */
241bool g_fDrvHostAudioCacheEnabled = true;
242
243/**
244 * Get default backend.
245 */
246PCPDMDRVREG AudioTestGetDefaultBackend(void)
247{
248 return g_aBackends[0].pDrvReg;
249}
250
251
252/**
253 * Helper for handling --backend options.
254 *
255 * @returns Pointer to the specified backend, NULL if not found (error
256 * displayed).
257 * @param pszBackend The backend option value.
258 */
259PCPDMDRVREG AudioTestFindBackendOpt(const char *pszBackend)
260{
261 for (uintptr_t i = 0; i < RT_ELEMENTS(g_aBackends); i++)
262 if ( strcmp(pszBackend, g_aBackends[i].pszName) == 0
263 || strcmp(pszBackend, g_aBackends[i].pDrvReg->szName) == 0)
264 return g_aBackends[i].pDrvReg;
265 RTMsgError("Unknown backend: '%s'\n\n", pszBackend);
266 RTPrintf("Supported backend values are: ");
267 for (uintptr_t i = 0; i < RT_ELEMENTS(g_aBackends); i++)
268 {
269 if (i > 0)
270 RTPrintf(", ");
271 RTPrintf(g_aBackends[i].pszName);
272 }
273 RTPrintf("\n");
274 return NULL;
275}
276
277
278/*********************************************************************************************************************************
279* Test callbacks *
280*********************************************************************************************************************************/
281
282/**
283 * @copydoc FNAUDIOTESTSETUP
284 */
285static DECLCALLBACK(int) audioTestPlayToneSetup(PAUDIOTESTENV pTstEnv, PAUDIOTESTDESC pTstDesc, PAUDIOTESTPARMS pTstParmsAcq, void **ppvCtx)
286{
287 RT_NOREF(pTstDesc, ppvCtx);
288
289 int rc = VINF_SUCCESS;
290
291 if (strlen(pTstEnv->szDev))
292 {
293 rc = audioTestDriverStackSetDevice(pTstEnv->pDrvStack, PDMAUDIODIR_OUT, pTstEnv->szDev);
294 if (RT_FAILURE(rc))
295 return rc;
296 }
297
298 pTstParmsAcq->enmType = AUDIOTESTTYPE_TESTTONE_PLAY;
299 pTstParmsAcq->enmDir = PDMAUDIODIR_OUT;
300
301 pTstParmsAcq->TestTone = pTstEnv->ToneParms;
302
303 pTstParmsAcq->TestTone.Hdr.idxTest = pTstEnv->idxTest; /* Assign unique test ID. */
304
305 return rc;
306}
307
308/**
309 * @copydoc FNAUDIOTESTEXEC
310 */
311static DECLCALLBACK(int) audioTestPlayToneExec(PAUDIOTESTENV pTstEnv, void *pvCtx, PAUDIOTESTPARMS pTstParms)
312{
313 RT_NOREF(pvCtx);
314
315 int rc = VINF_SUCCESS;
316
317 PAUDIOTESTTONEPARMS const pToneParms = &pTstParms->TestTone;
318
319 uint32_t const idxTest = pToneParms->Hdr.idxTest;
320
321 RTTIMESPEC NowTimeSpec;
322 RTTimeExplode(&pToneParms->Hdr.tsCreated, RTTimeNow(&NowTimeSpec));
323
324 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%RU32: Playing test tone (%RU16Hz, %RU32ms)\n",
325 idxTest, (uint16_t)pToneParms->dbFreqHz, pToneParms->msDuration);
326
327 /*
328 * 1. Arm the (host) ValKit ATS with the recording parameters.
329 */
330 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS,
331 "Test #%RU32: Telling ValKit audio driver on host to record new tone ...\n", idxTest);
332
333 rc = AudioTestSvcClientToneRecord(&pTstEnv->u.Host.AtsClValKit, pToneParms);
334 if (RT_SUCCESS(rc))
335 {
336 /* Give the Validaiton Kit audio driver on the host a bit of time to register / arming the new test. */
337 RTThreadSleep(5000); /* Fudge factor. */
338
339 /*
340 * 2. Tell VKAT on guest to start playback.
341 */
342 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%RU32: Telling VKAT on guest to play tone ...\n", idxTest);
343
344 rc = AudioTestSvcClientTonePlay(&pTstEnv->u.Host.AtsClGuest, pToneParms);
345 if (RT_FAILURE(rc))
346 RTTestFailed(g_hTest, "Test #%RU32: AudioTestSvcClientTonePlay() failed with %Rrc\n", idxTest, rc);
347 }
348 else
349 RTTestFailed(g_hTest, "Test #%RU32: AudioTestSvcClientToneRecord() failed with %Rrc\n", idxTest, rc);
350
351 if (RT_SUCCESS(rc))
352 {
353 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%RU32: Playing tone done\n", idxTest);
354
355 /* Give the audio stack a random amount of time for draining data before the next iteration. */
356 if (pTstEnv->cIterations > 1)
357 RTThreadSleep(RTRandU32Ex(2000, 5000)); /** @todo Implement some dedicated ATS command for this? */
358 }
359
360 if (RT_FAILURE(rc))
361 RTTestFailed(g_hTest, "Test #%RU32: Playing test tone failed with %Rrc\n", idxTest, rc);
362
363 return rc;
364}
365
366/**
367 * @copydoc FNAUDIOTESTDESTROY
368 */
369static DECLCALLBACK(int) audioTestPlayToneDestroy(PAUDIOTESTENV pTstEnv, void *pvCtx)
370{
371 RT_NOREF(pTstEnv, pvCtx);
372
373 return VINF_SUCCESS;
374}
375
376/**
377 * @copydoc FNAUDIOTESTSETUP
378 */
379static DECLCALLBACK(int) audioTestRecordToneSetup(PAUDIOTESTENV pTstEnv, PAUDIOTESTDESC pTstDesc, PAUDIOTESTPARMS pTstParmsAcq, void **ppvCtx)
380{
381 RT_NOREF(pTstDesc, ppvCtx);
382
383 int rc = VINF_SUCCESS;
384
385 if (strlen(pTstEnv->szDev))
386 {
387 rc = audioTestDriverStackSetDevice(pTstEnv->pDrvStack, PDMAUDIODIR_IN, pTstEnv->szDev);
388 if (RT_FAILURE(rc))
389 return rc;
390 }
391
392 pTstParmsAcq->enmType = AUDIOTESTTYPE_TESTTONE_RECORD;
393 pTstParmsAcq->enmDir = PDMAUDIODIR_IN;
394
395 pTstParmsAcq->TestTone = pTstEnv->ToneParms;
396
397 pTstParmsAcq->TestTone.Hdr.idxTest = pTstEnv->idxTest; /* Assign unique test ID. */
398
399 return rc;
400}
401
402/**
403 * @copydoc FNAUDIOTESTEXEC
404 */
405static DECLCALLBACK(int) audioTestRecordToneExec(PAUDIOTESTENV pTstEnv, void *pvCtx, PAUDIOTESTPARMS pTstParms)
406{
407 RT_NOREF(pvCtx);
408
409 int rc = VINF_SUCCESS;
410
411 PAUDIOTESTTONEPARMS const pToneParms = &pTstParms->TestTone;
412
413 uint32_t const idxTest = pToneParms->Hdr.idxTest;
414
415 RTTIMESPEC NowTimeSpec;
416 RTTimeExplode(&pToneParms->Hdr.tsCreated, RTTimeNow(&NowTimeSpec));
417
418 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%RU32: Recording test tone (%RU16Hz, %RU32ms)\n",
419 idxTest, (uint16_t)pToneParms->dbFreqHz, pToneParms->msDuration);
420
421 /*
422 * 1. Arm the (host) ValKit ATS with the playback parameters.
423 */
424 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS,
425 "Test #%RU32: Telling ValKit audio driver on host to inject recording data ...\n", idxTest);
426
427 rc = AudioTestSvcClientTonePlay(&pTstEnv->u.Host.AtsClValKit, &pTstParms->TestTone);
428 if (RT_SUCCESS(rc))
429 {
430 /*
431 * 2. Tell the guest ATS to start recording.
432 */
433 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%RU32: Telling VKAT on guest to record audio ...\n", idxTest);
434
435 rc = AudioTestSvcClientToneRecord(&pTstEnv->u.Host.AtsClGuest, &pTstParms->TestTone);
436 if (RT_FAILURE(rc))
437 RTTestFailed(g_hTest, "Test #%RU32: AudioTestSvcClientToneRecord() failed with %Rrc\n", idxTest, rc);
438 }
439 else
440 RTTestFailed(g_hTest, "Test #%RU32: AudioTestSvcClientTonePlay() failed with %Rrc\n", idxTest, rc);
441
442 if (RT_SUCCESS(rc))
443 {
444 /* Wait a bit to let the left over audio bits being processed. */
445 if (pTstEnv->cIterations > 1)
446 RTThreadSleep(RTRandU32Ex(2000, 5000)); /** @todo Implement some dedicated ATS command for this? */
447 }
448
449 if (RT_FAILURE(rc))
450 RTTestFailed(g_hTest, "Test #%RU32: Recording test tone failed with %Rrc\n", idxTest, rc);
451
452 return rc;
453}
454
455/**
456 * @copydoc FNAUDIOTESTDESTROY
457 */
458static DECLCALLBACK(int) audioTestRecordToneDestroy(PAUDIOTESTENV pTstEnv, void *pvCtx)
459{
460 RT_NOREF(pTstEnv, pvCtx);
461
462 return VINF_SUCCESS;
463}
464
465
466/*********************************************************************************************************************************
467* Test execution *
468*********************************************************************************************************************************/
469
470/** Test definition table. */
471AUDIOTESTDESC g_aTests[] =
472{
473 /* pszTest fExcluded pfnSetup */
474 { "PlayTone", false, audioTestPlayToneSetup, audioTestPlayToneExec, audioTestPlayToneDestroy },
475 { "RecordTone", false, audioTestRecordToneSetup, audioTestRecordToneExec, audioTestRecordToneDestroy }
476};
477/** Number of tests defined. */
478unsigned g_cTests = RT_ELEMENTS(g_aTests);
479
480/**
481 * Runs one specific audio test.
482 *
483 * @returns VBox status code.
484 * @param pTstEnv Test environment to use for running the test.
485 * @param pTstDesc Test to run.
486 */
487static int audioTestOne(PAUDIOTESTENV pTstEnv, PAUDIOTESTDESC pTstDesc)
488{
489 int rc = VINF_SUCCESS;
490
491 AUDIOTESTPARMS TstParms;
492 audioTestParmsInit(&TstParms);
493
494 RTTestSub(g_hTest, pTstDesc->pszName);
495
496 if (pTstDesc->fExcluded)
497 {
498 RTTestSkipped(g_hTest, "Test #%RU32 is excluded from list, skipping", pTstEnv->idxTest);
499 return VINF_SUCCESS;
500 }
501
502 pTstEnv->cIterations = pTstEnv->cIterations == 0 ? RTRandU32Ex(1, 10) : pTstEnv->cIterations;
503
504 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%RU32 (%RU32 iterations total)\n", pTstEnv->idxTest, pTstEnv->cIterations);
505
506 void *pvCtx = NULL; /* Test-specific opaque context. Optional and can be NULL. */
507
508 AssertPtr(pTstDesc->pfnExec);
509 for (uint32_t i = 0; i < pTstEnv->cIterations; i++)
510 {
511 int rc2;
512
513 if (pTstDesc->pfnSetup)
514 {
515 rc2 = pTstDesc->pfnSetup(pTstEnv, pTstDesc, &TstParms, &pvCtx);
516 if (RT_FAILURE(rc2))
517 RTTestFailed(g_hTest, "Test #%RU32 setup failed with %Rrc\n", pTstEnv->idxTest, rc2);
518 }
519 else
520 rc2 = VINF_SUCCESS;
521
522 if (RT_SUCCESS(rc2))
523 {
524 AssertPtrBreakStmt(pTstDesc->pfnExec, rc = VERR_INVALID_POINTER);
525 rc2 = pTstDesc->pfnExec(pTstEnv, pvCtx, &TstParms);
526 if (RT_FAILURE(rc2))
527 RTTestFailed(g_hTest, "Test #%RU32 execution failed with %Rrc\n", pTstEnv->idxTest, rc2);
528 }
529
530 if (pTstDesc->pfnDestroy)
531 {
532 rc2 = pTstDesc->pfnDestroy(pTstEnv, pvCtx);
533 if (RT_FAILURE(rc2))
534 RTTestFailed(g_hTest, "Test #%RU32 destruction failed with %Rrc\n", pTstEnv->idxTest, rc2);
535 }
536
537 if (RT_SUCCESS(rc))
538 rc = rc2;
539
540 /* Keep going. */
541 pTstEnv->idxTest++;
542 }
543
544 RTTestSubDone(g_hTest);
545
546 audioTestParmsDestroy(&TstParms);
547
548 return rc;
549}
550
551/**
552 * Runs all specified tests in a row.
553 *
554 * @returns VBox status code.
555 * @param pTstEnv Test environment to use for running all tests.
556 */
557int audioTestWorker(PAUDIOTESTENV pTstEnv)
558{
559 int rc = VINF_SUCCESS;
560
561 if (pTstEnv->enmMode == AUDIOTESTMODE_GUEST)
562 {
563 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Guest ATS running\n");
564
565 while (!g_fTerminate)
566 RTThreadSleep(100);
567
568 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Shutting down guest ATS ...\n");
569
570 int rc2 = AudioTestSvcStop(pTstEnv->pSrv);
571 if (RT_SUCCESS(rc))
572 rc = rc2;
573
574 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Guest ATS shutdown complete\n");
575 }
576 else if (pTstEnv->enmMode == AUDIOTESTMODE_HOST)
577 {
578 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Using tag '%s'\n", pTstEnv->szTag);
579
580 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Telling ValKit audio driver on host to begin a new test set ...\n");
581 rc = AudioTestSvcClientTestSetBegin(&pTstEnv->u.Host.AtsClValKit, pTstEnv->szTag);
582 if (RT_SUCCESS(rc))
583 {
584 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Telling VKAT on guest to begin a new test set ...\n");
585 rc = AudioTestSvcClientTestSetBegin(&pTstEnv->u.Host.AtsClGuest, pTstEnv->szTag);
586 if (RT_FAILURE(rc))
587 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS,
588 "Beginning test set on guest failed with %Rrc\n", rc);
589 }
590 else
591 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS,
592 "Beginning test set on host (Validation Kit audio driver) failed with %Rrc\n", rc);
593
594 if (RT_SUCCESS(rc))
595 {
596 for (unsigned i = 0; i < RT_ELEMENTS(g_aTests); i++)
597 {
598 int rc2 = audioTestOne(pTstEnv, &g_aTests[i]);
599 if (RT_SUCCESS(rc))
600 rc = rc2;
601
602 if (g_fTerminate)
603 break;
604 }
605
606 if (RT_SUCCESS(rc))
607 {
608 /** @todo Fudge! */
609 RTMSINTERVAL const msWait = RTRandU32Ex(RT_MS_1SEC, RT_MS_5SEC);
610 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS,
611 "Waiting %RU32ms to let guest and the audio stack process remaining data ...\n", msWait);
612 RTThreadSleep(msWait);
613 }
614
615 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Ending test set on guest ...\n");
616 int rc2 = AudioTestSvcClientTestSetEnd(&pTstEnv->u.Host.AtsClGuest, pTstEnv->szTag);
617 if (RT_FAILURE(rc2))
618 {
619 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Ending test set on guest failed with %Rrc\n", rc2);
620 if (RT_SUCCESS(rc))
621 rc = rc2;
622 }
623
624 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Ending test set on host (Validation Kit audio driver) ...\n");
625 rc2 = AudioTestSvcClientTestSetEnd(&pTstEnv->u.Host.AtsClValKit, pTstEnv->szTag);
626 if (RT_FAILURE(rc2))
627 {
628 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS,
629 "Ending test set on host (Validation Kit audio driver) failed with %Rrc\n", rc2);
630 if (RT_SUCCESS(rc))
631 rc = rc2;
632 }
633
634 if ( !g_fTerminate
635 && RT_SUCCESS(rc))
636 {
637 /*
638 * Download guest + Validation Kit audio driver test sets to our output directory.
639 */
640 char szFileName[RTPATH_MAX];
641 if (RTStrPrintf2(szFileName, sizeof(szFileName), "%s-guest.tar.gz", pTstEnv->szTag))
642 {
643 rc = RTPathJoin(pTstEnv->u.Host.szPathTestSetGuest, sizeof(pTstEnv->u.Host.szPathTestSetGuest),
644 pTstEnv->szPathOut, szFileName);
645 if (RT_SUCCESS(rc))
646 {
647 if (RTStrPrintf2(szFileName, sizeof(szFileName), "%s-host.tar.gz", pTstEnv->szTag))
648 {
649 rc = RTPathJoin(pTstEnv->u.Host.szPathTestSetValKit, sizeof(pTstEnv->u.Host.szPathTestSetValKit),
650 pTstEnv->szPathOut, szFileName);
651 }
652 else
653 rc = VERR_BUFFER_OVERFLOW;
654 }
655 else
656 rc = VERR_BUFFER_OVERFLOW;
657
658 if (RT_SUCCESS(rc))
659 {
660 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Downloading guest test set to '%s'\n",
661 pTstEnv->u.Host.szPathTestSetGuest);
662 rc = AudioTestSvcClientTestSetDownload(&pTstEnv->u.Host.AtsClGuest,
663 pTstEnv->szTag, pTstEnv->u.Host.szPathTestSetGuest);
664 }
665
666 if (RT_SUCCESS(rc))
667 {
668 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Downloading host test set to '%s'\n",
669 pTstEnv->u.Host.szPathTestSetValKit);
670 rc = AudioTestSvcClientTestSetDownload(&pTstEnv->u.Host.AtsClValKit,
671 pTstEnv->szTag, pTstEnv->u.Host.szPathTestSetValKit);
672 }
673 }
674 else
675 rc = VERR_BUFFER_OVERFLOW;
676
677 if ( RT_SUCCESS(rc)
678 && !pTstEnv->fSkipVerify)
679 {
680 rc = audioVerifyOne(pTstEnv->u.Host.szPathTestSetGuest, pTstEnv->u.Host.szPathTestSetValKit, NULL /* pOpts */);
681 }
682 else
683 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Verification skipped\n");
684
685 if (!pTstEnv->fSkipVerify)
686 {
687 RTFileDelete(pTstEnv->u.Host.szPathTestSetGuest);
688 RTFileDelete(pTstEnv->u.Host.szPathTestSetValKit);
689 }
690 else
691 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Leaving test set files behind\n");
692 }
693 }
694 }
695 else
696 rc = VERR_NOT_IMPLEMENTED;
697
698 /* Clean up. */
699 RTDirRemove(pTstEnv->szPathTemp);
700 RTDirRemove(pTstEnv->szPathOut);
701
702 if (RT_FAILURE(rc))
703 RTTestFailed(g_hTest, "Test worker failed with %Rrc", rc);
704
705 return rc;
706}
707
708/** Option help for the 'test' command. */
709static DECLCALLBACK(const char *) audioTestCmdTestHelp(PCRTGETOPTDEF pOpt)
710{
711 switch (pOpt->iShort)
712 {
713 case 'a': return "Exclude all tests from the list (useful to enable single tests later with --include)";
714 case 'b': return "The audio backend to use";
715 case 'd': return "Go via DrvAudio instead of directly interfacing with the backend";
716 case 'e': return "Exclude the given test id from the list";
717 case 'i': return "Include the given test id in the list";
718 case VKAT_TEST_OPT_COUNT: return "Number of test iterations to perform for selected tests\n"
719 " Default: random number";
720 case VKAT_TEST_OPT_DEV: return "Name of the input/output device to use\n"
721 " Default: default device";
722 case VKAT_TEST_OPT_TONE_DURATION_MS: return "Test tone duration to play / record (ms)\n"
723 " Default: random duration";
724 case VKAT_TEST_OPT_TONE_VOL_PERCENT: return "Test tone volume (percent)\n"
725 " Default: 100";
726 case VKAT_TEST_OPT_MODE: return "Test mode to use when running the tests\n"
727 " Available modes:\n"
728 " guest: Run as a guest-side ATS\n"
729 " host: Run as a host-side ATS";
730 case VKAT_TEST_OPT_NO_AUDIO_OK: return "Enables running without any found audio hardware (e.g. servers)";
731 case VKAT_TEST_OPT_NO_VERIFY: return "Skips the verification step";
732 case VKAT_TEST_OPT_OUTDIR: return "Output directory to use";
733 case VKAT_TEST_OPT_PAUSE: return "Not yet implemented";
734 case VKAT_TEST_OPT_PCM_HZ: return "PCM Hertz (Hz) rate to use\n"
735 " Default: 44100";
736 case VKAT_TEST_OPT_PCM_BIT: return "PCM sample bits (i.e. 16) to use\n"
737 " Default: 16";
738 case VKAT_TEST_OPT_PCM_CHAN: return "PCM channels to use\n"
739 " Default: 2";
740 case VKAT_TEST_OPT_PCM_SIGNED: return "PCM samples to use (signed = true, unsigned = false)\n"
741 " Default: true";
742 case VKAT_TEST_OPT_PROBE_BACKENDS: return "Probes all (available) backends until a working one is found";
743 case VKAT_TEST_OPT_TAG: return "Test set tag to use";
744 case VKAT_TEST_OPT_TEMPDIR: return "Temporary directory to use";
745 case VKAT_TEST_OPT_TIMEOUT: return "Timeout to use (in ms)\";"
746 " Default: 5 minutes (300000)";
747 case VKAT_TEST_OPT_VOL: return "Audio volume (percent) to use";
748 case VKAT_TEST_OPT_TCP_BIND_ADDRESS: return "TCP address listening to (server mode)";
749 case VKAT_TEST_OPT_TCP_BIND_PORT: return "TCP port listening to (server mode)";
750 case VKAT_TEST_OPT_TCP_CONNECT_ADDRESS: return "TCP address to connect to (client mode)";
751 case VKAT_TEST_OPT_TCP_CONNECT_PORT: return "TCP port to connect to (client mode)";
752 default:
753 break;
754 }
755 return NULL;
756}
757
758/**
759 * Main (entry) function for the testing functionality of VKAT.
760 *
761 * @returns Program exit code.
762 * @param pGetState RTGetOpt state.
763 */
764static DECLCALLBACK(RTEXITCODE) audioTestMain(PRTGETOPTSTATE pGetState)
765{
766 AUDIOTESTENV TstEnv;
767 audioTestEnvInit(&TstEnv);
768
769 int rc;
770
771 PCPDMDRVREG pDrvReg = AudioTestGetDefaultBackend();
772 uint8_t cPcmSampleBit = 0;
773 uint8_t cPcmChannels = 0;
774 uint32_t uPcmHz = 0;
775 bool fPcmSigned = true;
776 bool fProbeBackends = false;
777 bool fNoAudioOk = false;
778
779 int ch;
780 RTGETOPTUNION ValueUnion;
781 while ((ch = RTGetOpt(pGetState, &ValueUnion)))
782 {
783 switch (ch)
784 {
785 case 'a':
786 for (unsigned i = 0; i < RT_ELEMENTS(g_aTests); i++)
787 g_aTests[i].fExcluded = true;
788 break;
789
790 case 'b':
791 pDrvReg = AudioTestFindBackendOpt(ValueUnion.psz);
792 if (pDrvReg == NULL)
793 return RTEXITCODE_SYNTAX;
794 break;
795
796 case 'd':
797 TstEnv.IoOpts.fWithDrvAudio = true;
798 break;
799
800 case 'e':
801 if (ValueUnion.u32 >= RT_ELEMENTS(g_aTests))
802 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid test number %u passed to --exclude", ValueUnion.u32);
803 g_aTests[ValueUnion.u32].fExcluded = true;
804 break;
805
806 case VKAT_TEST_OPT_MODE:
807 if (TstEnv.enmMode != AUDIOTESTMODE_UNKNOWN)
808 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Test mode (guest / host) already specified");
809 TstEnv.enmMode = RTStrICmp(ValueUnion.psz, "guest") == 0 ? AUDIOTESTMODE_GUEST : AUDIOTESTMODE_HOST;
810 break;
811
812 case VKAT_TEST_OPT_NO_AUDIO_OK:
813 fNoAudioOk = true;
814 break;
815
816 case VKAT_TEST_OPT_NO_VERIFY:
817 TstEnv.fSkipVerify = true;
818 break;
819
820 case 'i':
821 if (ValueUnion.u32 >= RT_ELEMENTS(g_aTests))
822 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid test number %u passed to --include", ValueUnion.u32);
823 g_aTests[ValueUnion.u32].fExcluded = false;
824 break;
825
826 case VKAT_TEST_OPT_COUNT:
827 TstEnv.cIterations = ValueUnion.u32;
828 break;
829
830 case VKAT_TEST_OPT_DEV:
831 rc = RTStrCopy(TstEnv.szDev, sizeof(TstEnv.szDev), ValueUnion.psz);
832 if (RT_FAILURE(rc))
833 return RTMsgErrorExitFailure("Failed to copy out device: %Rrc", rc);
834 break;
835
836 case VKAT_TEST_OPT_TONE_DURATION_MS:
837 TstEnv.ToneParms.msDuration = ValueUnion.u32;
838 break;
839
840 case VKAT_TEST_OPT_TONE_VOL_PERCENT:
841 TstEnv.ToneParms.uVolumePercent = ValueUnion.u8;
842 break;
843
844 case VKAT_TEST_OPT_PAUSE:
845 return RTMsgErrorExitFailure("Not yet implemented!");
846
847 case VKAT_TEST_OPT_OUTDIR:
848 rc = RTStrCopy(TstEnv.szPathOut, sizeof(TstEnv.szPathOut), ValueUnion.psz);
849 if (RT_FAILURE(rc))
850 return RTMsgErrorExitFailure("Failed to copy out directory: %Rrc", rc);
851 break;
852
853 case VKAT_TEST_OPT_PCM_BIT:
854 cPcmSampleBit = ValueUnion.u8;
855 break;
856
857 case VKAT_TEST_OPT_PCM_CHAN:
858 cPcmChannels = ValueUnion.u8;
859 break;
860
861 case VKAT_TEST_OPT_PCM_HZ:
862 uPcmHz = ValueUnion.u32;
863 break;
864
865 case VKAT_TEST_OPT_PCM_SIGNED:
866 fPcmSigned = ValueUnion.f;
867 break;
868
869 case VKAT_TEST_OPT_PROBE_BACKENDS:
870 fProbeBackends = true;
871 break;
872
873 case VKAT_TEST_OPT_TAG:
874 rc = RTStrCopy(TstEnv.szTag, sizeof(TstEnv.szTag), ValueUnion.psz);
875 if (RT_FAILURE(rc))
876 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Tag invalid, rc=%Rrc", rc);
877 break;
878
879 case VKAT_TEST_OPT_TEMPDIR:
880 rc = RTStrCopy(TstEnv.szPathTemp, sizeof(TstEnv.szPathTemp), ValueUnion.psz);
881 if (RT_FAILURE(rc))
882 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Temp dir invalid, rc=%Rrc", rc);
883 break;
884
885 case VKAT_TEST_OPT_TIMEOUT:
886 if (!ValueUnion.u32)
887 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Invalid timeout value given!");
888 TstEnv.msTimeout = ValueUnion.u32;
889 break;
890
891 case VKAT_TEST_OPT_VOL:
892 TstEnv.IoOpts.uVolumePercent = ValueUnion.u8;
893 break;
894
895 case VKAT_TEST_OPT_TCP_BIND_ADDRESS:
896 rc = RTStrCopy(TstEnv.TcpOpts.szBindAddr, sizeof(TstEnv.TcpOpts.szBindAddr), ValueUnion.psz);
897 if (RT_FAILURE(rc))
898 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Bind address invalid, rc=%Rrc", rc);
899 break;
900
901 case VKAT_TEST_OPT_TCP_BIND_PORT:
902 TstEnv.TcpOpts.uBindPort = ValueUnion.u16;
903 break;
904
905 case VKAT_TEST_OPT_TCP_CONNECT_ADDRESS:
906 rc = RTStrCopy(TstEnv.TcpOpts.szConnectAddr, sizeof(TstEnv.TcpOpts.szConnectAddr), ValueUnion.psz);
907 if (RT_FAILURE(rc))
908 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Connect address invalid, rc=%Rrc", rc);
909 break;
910
911 case VKAT_TEST_OPT_TCP_CONNECT_PORT:
912 TstEnv.TcpOpts.uConnectPort = ValueUnion.u16;
913 break;
914
915 AUDIO_TEST_COMMON_OPTION_CASES(ValueUnion, &g_CmdTest);
916
917 default:
918 return RTGetOptPrintError(ch, &ValueUnion);
919 }
920 }
921
922 /*
923 * Start testing.
924 */
925 RTTestBanner(g_hTest);
926
927 if (TstEnv.enmMode == AUDIOTESTMODE_UNKNOWN)
928 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "No test mode (--mode) specified!\n");
929
930 /* Validate TCP options. */
931 if ( TstEnv.TcpOpts.szBindAddr[0]
932 && TstEnv.TcpOpts.szConnectAddr[0])
933 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Only one TCP connection mode (connect as client *or* bind as server) can be specified) at a time!\n");
934
935 /* Set new (override standard) I/O PCM properties if set by the user. */
936 if ( cPcmSampleBit
937 || cPcmChannels
938 || uPcmHz)
939 {
940 PDMAudioPropsInit(&TstEnv.IoOpts.Props,
941 cPcmSampleBit ? cPcmSampleBit / 2 : 2 /* 16-bit */, fPcmSigned /* fSigned */,
942 cPcmChannels ? cPcmChannels : 2 /* Stereo */, uPcmHz ? uPcmHz : 44100);
943 }
944
945 /* Do this first before everything else below. */
946 rc = AudioTestDriverStackPerformSelftest();
947 if (RT_FAILURE(rc))
948 {
949 if (!fNoAudioOk)
950 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Testing driver stack failed: %Rrc\n", rc);
951 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS,
952 "Warning: Testing driver stack not possible (%Rrc), but --no-audio-ok was specified. Running on a server without audio hardware?\n", rc);
953 }
954
955 AUDIOTESTDRVSTACK DrvStack;
956 if (fProbeBackends)
957 rc = audioTestDriverStackProbe(&DrvStack,
958 true /* fEnabledIn */, true /* fEnabledOut */, TstEnv.IoOpts.fWithDrvAudio); /** @todo Make in/out configurable, too. */
959 else
960 rc = audioTestDriverStackInitEx(&DrvStack, pDrvReg,
961 true /* fEnabledIn */, true /* fEnabledOut */, TstEnv.IoOpts.fWithDrvAudio); /** @todo Make in/out configurable, too. */
962 if (RT_FAILURE(rc))
963 {
964 if (!fNoAudioOk)
965 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Unable to init driver stack: %Rrc\n", rc);
966 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS,
967 "Warning: Initializing driver stack not possible (%Rrc), but --no-audio-ok was specified. Running on a server without audio hardware?\n", rc);
968 }
969
970 PPDMAUDIOHOSTDEV pDev;
971 rc = audioTestDevicesEnumerateAndCheck(&DrvStack, TstEnv.szDev, &pDev);
972 if (RT_FAILURE(rc))
973 {
974 if (!fNoAudioOk)
975 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Enumerating device(s) failed: %Rrc\n", rc);
976 }
977
978 /* For now all tests have the same test environment and driver stack. */
979 rc = audioTestEnvCreate(&TstEnv, &DrvStack);
980 if (RT_SUCCESS(rc))
981 rc = audioTestWorker(&TstEnv);
982
983 audioTestEnvDestroy(&TstEnv);
984 audioTestDriverStackDelete(&DrvStack);
985
986 if (RT_FAILURE(rc)) /* Let us know that something went wrong in case we forgot to mention it. */
987 RTTestFailed(g_hTest, "Testing failed with %Rrc\n", rc);
988
989 /*
990 * Print summary and exit.
991 */
992 return RTTestSummaryAndDestroy(g_hTest);
993}
994
995
996const VKATCMD g_CmdTest =
997{
998 "test",
999 audioTestMain,
1000 "Runs audio tests and creates an audio test set.",
1001 g_aCmdTestOptions,
1002 RT_ELEMENTS(g_aCmdTestOptions),
1003 audioTestCmdTestHelp,
1004 true /* fNeedsTransport */
1005};
1006
1007
1008/*********************************************************************************************************************************
1009* Command: verify *
1010*********************************************************************************************************************************/
1011
1012static int audioVerifyOpenTestSet(const char *pszPathSet, PAUDIOTESTSET pSet)
1013{
1014 int rc;
1015
1016 char szPathExtracted[RTPATH_MAX];
1017
1018 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Opening test set '%s'\n", pszPathSet);
1019
1020 const bool fPacked = AudioTestSetIsPacked(pszPathSet);
1021
1022 if (fPacked)
1023 {
1024 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test set is an archive and needs to be unpacked\n");
1025
1026 if (!RTFileExists(pszPathSet))
1027 {
1028 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test set '%s' does not exist\n", pszPathSet);
1029 rc = VERR_FILE_NOT_FOUND;
1030 }
1031 else
1032 rc = VINF_SUCCESS;
1033
1034 if (RT_SUCCESS(rc))
1035 {
1036 char szPathTemp[RTPATH_MAX];
1037 rc = RTPathTemp(szPathTemp, sizeof(szPathTemp));
1038 if (RT_SUCCESS(rc))
1039 {
1040 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Using temporary directory '%s'\n", szPathTemp);
1041
1042 rc = RTPathJoin(szPathExtracted, sizeof(szPathExtracted), szPathTemp, "vkat-testset-XXXX");
1043 if (RT_SUCCESS(rc))
1044 {
1045 rc = RTDirCreateTemp(szPathExtracted, 0755);
1046 if (RT_SUCCESS(rc))
1047 {
1048 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Unpacking archive to '%s'\n", szPathExtracted);
1049 rc = AudioTestSetUnpack(pszPathSet, szPathExtracted);
1050 if (RT_SUCCESS(rc))
1051 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Archive successfully unpacked\n");
1052 }
1053 }
1054 }
1055 }
1056 }
1057 else
1058 rc = VINF_SUCCESS;
1059
1060 if (RT_SUCCESS(rc))
1061 rc = AudioTestSetOpen(pSet, fPacked ? szPathExtracted : pszPathSet);
1062
1063 if (RT_FAILURE(rc))
1064 RTTestFailed(g_hTest, "Unable to open / unpack test set archive: %Rrc", rc);
1065
1066 return rc;
1067}
1068
1069/**
1070 * Verifies one test set pair.
1071 *
1072 * @returns VBox status code.
1073 * @param pszPathSetA Absolute path to test set A.
1074 * @param pszPathSetB Absolute path to test set B.
1075 * @param pOpts Verification options to use. Optional.
1076 * When NULL, the (very strict) defaults will be used.
1077 */
1078static int audioVerifyOne(const char *pszPathSetA, const char *pszPathSetB, PAUDIOTESTVERIFYOPTS pOpts)
1079{
1080 RTTestSubF(g_hTest, "Verifying");
1081 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Verifying test set '%s' with test set '%s'\n", pszPathSetA, pszPathSetB);
1082
1083 AUDIOTESTSET SetA, SetB;
1084 int rc = audioVerifyOpenTestSet(pszPathSetA, &SetA);
1085 if (RT_SUCCESS(rc))
1086 {
1087 rc = audioVerifyOpenTestSet(pszPathSetB, &SetB);
1088 if (RT_SUCCESS(rc))
1089 {
1090 AUDIOTESTERRORDESC errDesc;
1091 if (pOpts)
1092 rc = AudioTestSetVerifyEx(&SetA, &SetB, pOpts, &errDesc);
1093 else
1094 rc = AudioTestSetVerify(&SetA, &SetB, &errDesc);
1095 if (RT_SUCCESS(rc))
1096 {
1097 uint32_t const cErr = AudioTestErrorDescCount(&errDesc);
1098 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "%RU32 errors occurred while verifying\n", cErr);
1099
1100 /** @todo Use some AudioTestErrorXXX API for enumeration here later. */
1101 PAUDIOTESTERRORENTRY pErrEntry;
1102 RTListForEach(&errDesc.List, pErrEntry, AUDIOTESTERRORENTRY, Node)
1103 {
1104 if (RT_FAILURE(pErrEntry->rc))
1105 RTTestFailed(g_hTest, "%s\n", pErrEntry->szDesc);
1106 else
1107 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "%s\n", pErrEntry->szDesc);
1108 }
1109
1110 if (cErr == 0)
1111 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Verification successful\n");
1112
1113 AudioTestErrorDescDestroy(&errDesc);
1114 }
1115 else
1116 RTTestFailed(g_hTest, "Verification failed with %Rrc", rc);
1117
1118#ifdef DEBUG
1119 if (g_fDrvAudioDebug)
1120 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS,
1121 "\n"
1122 "Use the following command line to re-run verification in the debugger:\n"
1123 "gdb --args ./VBoxAudioTest -vvvv --debug-audio verify \"%s\" \"%s\"\n",
1124 SetA.szPathAbs, SetB.szPathAbs);
1125#endif
1126 if (!g_fDrvAudioDebug) /* Don't wipe stuff when debugging. Can be useful for introspecting data. */
1127 AudioTestSetWipe(&SetB);
1128 AudioTestSetClose(&SetB);
1129 }
1130
1131 if (!g_fDrvAudioDebug) /* Ditto. */
1132 AudioTestSetWipe(&SetA);
1133 AudioTestSetClose(&SetA);
1134 }
1135
1136 RTTestSubDone(g_hTest);
1137
1138 return rc;
1139}
1140
1141/** Option help for the 'verify' command. */
1142static DECLCALLBACK(const char *) audioTestCmdVerifyHelp(PCRTGETOPTDEF pOpt)
1143{
1144 switch (pOpt->iShort)
1145 {
1146 case VKAT_VERIFY_OPT_MAX_DIFF_COUNT: return "Specifies the maximum number of differences\n"
1147 " Default: 0 (strict)";
1148 case VKAT_VERIFY_OPT_MAX_DIFF_PERCENT: return "Specifies the maximum difference (percent)\n"
1149 " Default: 0 (strict)";
1150 case VKAT_VERIFY_OPT_MAX_SIZE_PERCENT: return "Specifies the maximum size difference (percent)\n"
1151 " Default: 1 (strict)";
1152 case VKAT_VERIFY_OPT_NORMALIZE: return "Enables / disables audio data normalization\n"
1153 " Default: false";
1154 default:
1155 break;
1156 }
1157 return NULL;
1158}
1159
1160/**
1161 * Main (entry) function for the verification functionality of VKAT.
1162 *
1163 * @returns Program exit code.
1164 * @param pGetState RTGetOpt state.
1165 */
1166static DECLCALLBACK(RTEXITCODE) audioVerifyMain(PRTGETOPTSTATE pGetState)
1167{
1168 /*
1169 * Parse options and process arguments.
1170 */
1171 const char *apszSets[2] = { NULL, NULL };
1172 unsigned iTestSet = 0;
1173
1174 AUDIOTESTVERIFYOPTS Opts;
1175 AudioTestSetVerifyOptsInit(&Opts);
1176
1177 int ch;
1178 RTGETOPTUNION ValueUnion;
1179 while ((ch = RTGetOpt(pGetState, &ValueUnion)))
1180 {
1181 switch (ch)
1182 {
1183 case VKAT_VERIFY_OPT_MAX_DIFF_COUNT:
1184 Opts.cMaxDiff = ValueUnion.u32;
1185 break;
1186
1187 case VKAT_VERIFY_OPT_MAX_DIFF_PERCENT:
1188 Opts.uMaxDiffPercent = ValueUnion.u8;
1189 break;
1190
1191 case VKAT_VERIFY_OPT_MAX_SIZE_PERCENT:
1192 Opts.uMaxSizePercent = ValueUnion.u8;
1193 break;
1194
1195 case VKAT_VERIFY_OPT_NORMALIZE:
1196 Opts.fNormalize = ValueUnion.f;
1197 break;
1198
1199 case VINF_GETOPT_NOT_OPTION:
1200 if (iTestSet == 0)
1201 RTTestBanner(g_hTest);
1202 if (iTestSet >= RT_ELEMENTS(apszSets))
1203 return RTMsgErrorExitFailure("Only two test sets can be verified at one time");
1204 apszSets[iTestSet++] = ValueUnion.psz;
1205 break;
1206
1207 AUDIO_TEST_COMMON_OPTION_CASES(ValueUnion, &g_CmdVerify);
1208
1209 default:
1210 return RTGetOptPrintError(ch, &ValueUnion);
1211 }
1212 }
1213
1214 if (!iTestSet)
1215 return RTMsgErrorExitFailure("At least one test set must be specified");
1216
1217 int rc = VINF_SUCCESS;
1218
1219 /*
1220 * If only test set A is given, default to the current directory
1221 * for test set B.
1222 */
1223 char szDirCur[RTPATH_MAX];
1224 if (iTestSet == 1)
1225 {
1226 rc = RTPathGetCurrent(szDirCur, sizeof(szDirCur));
1227 if (RT_SUCCESS(rc))
1228 apszSets[1] = szDirCur;
1229 else
1230 RTTestFailed(g_hTest, "Failed to retrieve current directory: %Rrc", rc);
1231 }
1232
1233 if (RT_SUCCESS(rc))
1234 audioVerifyOne(apszSets[0], apszSets[1], &Opts);
1235
1236 /*
1237 * Print summary and exit.
1238 */
1239 return RTTestSummaryAndDestroy(g_hTest);
1240}
1241
1242
1243const VKATCMD g_CmdVerify =
1244{
1245 "verify",
1246 audioVerifyMain,
1247 "Verifies a formerly created audio test set.",
1248 g_aCmdVerifyOptions,
1249 RT_ELEMENTS(g_aCmdVerifyOptions),
1250 audioTestCmdVerifyHelp,
1251 false /* fNeedsTransport */
1252};
1253
1254
1255/*********************************************************************************************************************************
1256* Main *
1257*********************************************************************************************************************************/
1258
1259/**
1260 * Ctrl-C signal handler.
1261 *
1262 * This just sets g_fTerminate and hope it will be noticed soon.
1263 *
1264 * On non-Windows it restores the SIGINT action to default, so that a second
1265 * Ctrl-C will have the normal effect (just in case the code doesn't respond to
1266 * g_fTerminate).
1267 */
1268#ifdef RT_OS_WINDOWS
1269static BOOL CALLBACK audioTestConsoleCtrlHandler(DWORD dwCtrlType) RT_NOEXCEPT
1270{
1271 if (dwCtrlType != CTRL_C_EVENT && dwCtrlType != CTRL_BREAK_EVENT)
1272 return false;
1273 RTPrintf(dwCtrlType == CTRL_C_EVENT ? "Ctrl-C!\n" : "Ctrl-Break!\n");
1274
1275 ASMAtomicWriteBool(&g_fTerminate, true);
1276
1277 return true;
1278}
1279#else
1280static void audioTestSignalHandler(int iSig) RT_NOEXCEPT
1281{
1282 Assert(iSig == SIGINT); RT_NOREF(iSig);
1283 RTPrintf("Ctrl-C!\n");
1284
1285 ASMAtomicWriteBool(&g_fTerminate, true);
1286
1287 signal(SIGINT, SIG_DFL);
1288}
1289#endif
1290
1291/**
1292 * Commands.
1293 */
1294static const VKATCMD * const g_apCommands[] =
1295{
1296 &g_CmdTest,
1297 &g_CmdVerify,
1298 &g_CmdBackends,
1299 &g_CmdEnum,
1300 &g_CmdPlay,
1301 &g_CmdRec,
1302 &g_CmdSelfTest
1303};
1304
1305/**
1306 * Shows tool usage text.
1307 */
1308RTEXITCODE audioTestUsage(PRTSTREAM pStrm, PCVKATCMD pOnlyCmd)
1309{
1310 RTStrmPrintf(pStrm, "usage: %s [global options] <command> [command-options]\n", RTProcShortName());
1311 RTStrmPrintf(pStrm,
1312 "\n"
1313 "Global Options:\n"
1314 " --debug-audio\n"
1315 " Enables (DrvAudio) debugging\n"
1316 " --debug-audio-path=<path>\n"
1317 " Tells DrvAudio where to put its debug output (wav-files)\n"
1318 " --drvhost-cache-enabled=<true|false>\n"
1319 " Enables or disables caching code for the host driver (backend)\n"
1320 " -q, --quiet\n"
1321 " Sets verbosity to zero\n"
1322 " -v, --verbose\n"
1323 " Increase verbosity\n"
1324 " -V, --version\n"
1325 " Displays version\n"
1326 " -h, -?, --help\n"
1327 " Displays help\n"
1328 );
1329
1330 for (uintptr_t iCmd = 0; iCmd < RT_ELEMENTS(g_apCommands); iCmd++)
1331 {
1332 PCVKATCMD const pCmd = g_apCommands[iCmd];
1333 if (!pOnlyCmd || pCmd == pOnlyCmd)
1334 {
1335 RTStrmPrintf(pStrm,
1336 "\n"
1337 "Command '%s':\n"
1338 " %s\n"
1339 "Options for '%s':\n",
1340 pCmd->pszCommand, pCmd->pszDesc, pCmd->pszCommand);
1341 PCRTGETOPTDEF const paOptions = pCmd->paOptions;
1342 for (unsigned i = 0; i < pCmd->cOptions; i++)
1343 {
1344 if (RT_C_IS_PRINT(paOptions[i].iShort))
1345 RTStrmPrintf(pStrm, " -%c, %s\n", paOptions[i].iShort, paOptions[i].pszLong);
1346 else
1347 RTStrmPrintf(pStrm, " %s\n", paOptions[i].pszLong);
1348
1349 const char *pszHelp = NULL;
1350 if (pCmd->pfnOptionHelp)
1351 pszHelp = pCmd->pfnOptionHelp(&paOptions[i]);
1352 if (pszHelp)
1353 RTStrmPrintf(pStrm, " %s\n", pszHelp);
1354 }
1355
1356 if (pCmd->fNeedsTransport)
1357 for (uintptr_t iTx = 0; iTx < g_cTransports; iTx++)
1358 g_apTransports[iTx]->pfnUsage(pStrm);
1359 }
1360 }
1361
1362 return RTEXITCODE_SUCCESS;
1363}
1364
1365/**
1366 * Lists the commands and their descriptions.
1367 */
1368static RTEXITCODE audioTestListCommands(PRTSTREAM pStrm)
1369{
1370 RTStrmPrintf(pStrm, "Commands:\n");
1371 for (uintptr_t iCmd = 0; iCmd < RT_ELEMENTS(g_apCommands); iCmd++)
1372 RTStrmPrintf(pStrm, "%8s - %s\n", g_apCommands[iCmd]->pszCommand, g_apCommands[iCmd]->pszDesc);
1373 return RTEXITCODE_SUCCESS;
1374}
1375
1376/**
1377 * Shows tool version.
1378 */
1379RTEXITCODE audioTestVersion(void)
1380{
1381 RTPrintf("%s\n", RTBldCfgRevisionStr());
1382 return RTEXITCODE_SUCCESS;
1383}
1384
1385/**
1386 * Shows the logo.
1387 *
1388 * @param pStream Output stream to show logo on.
1389 */
1390void audioTestShowLogo(PRTSTREAM pStream)
1391{
1392 RTStrmPrintf(pStream, VBOX_PRODUCT " VKAT (Validation Kit Audio Test) Version " VBOX_VERSION_STRING " - r%s\n"
1393 "Copyright (C) " VBOX_C_YEAR " " VBOX_VENDOR "\n\n", RTBldCfgRevisionStr());
1394}
1395
1396int main(int argc, char **argv)
1397{
1398 /*
1399 * Init IPRT.
1400 */
1401 int rc = RTR3InitExe(argc, &argv, 0);
1402 if (RT_FAILURE(rc))
1403 return RTMsgInitFailure(rc);
1404
1405 /*
1406 * Handle special command line options which need parsing before
1407 * everything else.
1408 */
1409 /** @todo r=bird: this isn't at all syntactically sane, because you don't know
1410 * how to parse past the command (can almost be done safely thought, since
1411 * you've got the option definitions for every command at hand). So, if someone
1412 * wants to play a file named "-v.wav", you'll incorrectly take that as two 'v'
1413 * options. The parsing has to stop when you get to the command, i.e. first
1414 * VINF_GETOPT_NOT_OPTION or anything that isn't a common option. Daemonizing
1415 * when for instance encountering an invalid command, is not correct.
1416 *
1417 * Btw. you MUST however process the 'q' option in parallel to 'v' here, they
1418 * are oposites. For instance '-vqvvv' is supposed to give you level 3 logging,
1419 * not quiet! So, either you process both 'v' and 'q' here, or you pospone them
1420 * (better option).
1421 */
1422 /** @todo r=bird: Is the daemonizing needed? The testcase doesn't seem to use
1423 * it... If you don't need it, drop it as it make the parsing complex
1424 * and illogical. The --daemonized / --damonize options should be
1425 * required to before the command, then okay. */
1426 bool fDaemonize = false;
1427 bool fDaemonized = false;
1428
1429 RTGETOPTSTATE GetState;
1430 rc = RTGetOptInit(&GetState, argc, argv, g_aCmdCommonOptions,
1431 RT_ELEMENTS(g_aCmdCommonOptions), 1 /*idxFirst*/, 0 /*fFlags - must not sort! */);
1432 AssertRCReturn(rc, RTEXITCODE_INIT);
1433
1434 int ch;
1435 RTGETOPTUNION ValueUnion;
1436 while ((ch = RTGetOpt(&GetState, &ValueUnion)) != 0)
1437 {
1438 switch (ch)
1439 {
1440 case AUDIO_TEST_OPT_CMN_DAEMONIZE:
1441 fDaemonize = true;
1442 break;
1443
1444 case AUDIO_TEST_OPT_CMN_DAEMONIZED:
1445 fDaemonized = true;
1446 break;
1447
1448 /* Has to be defined here and not in AUDIO_TEST_COMMON_OPTION_CASES, to get the logger
1449 * configured before the specific command handlers down below come into play. */
1450 case 'v':
1451 g_uVerbosity++;
1452 break;
1453
1454 default:
1455 break;
1456 }
1457 }
1458
1459 /** @todo add something to suppress this stuff. */
1460 audioTestShowLogo(g_pStdOut);
1461
1462 if (fDaemonize)
1463 {
1464 if (!fDaemonized)
1465 {
1466 rc = RTProcDaemonize(argv, "--daemonized");
1467 if (RT_FAILURE(rc))
1468 return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTProcDaemonize() failed with %Rrc\n", rc);
1469
1470 RTMsgInfo("Starting in background (daemonizing) ...");
1471 return RTEXITCODE_SUCCESS;
1472 }
1473 /* else continue running in background. */
1474 }
1475
1476 /*
1477 * Init test and globals.
1478 * Note: Needs to be done *after* daemonizing, otherwise the child will fail!
1479 */
1480 rc = RTTestCreate("AudioTest", &g_hTest);
1481 if (RT_FAILURE(rc))
1482 return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTTestCreate() failed with %Rrc\n", rc);
1483
1484#ifdef RT_OS_WINDOWS
1485 HRESULT hrc = CoInitializeEx(NULL /*pReserved*/, COINIT_MULTITHREADED | COINIT_SPEED_OVER_MEMORY | COINIT_DISABLE_OLE1DDE);
1486 if (FAILED(hrc))
1487 RTMsgWarning("CoInitializeEx failed: %#x", hrc);
1488#endif
1489
1490 /*
1491 * Configure release logging to go to stdout.
1492 */
1493 RTUINT fFlags = RTLOGFLAGS_PREFIX_THREAD | RTLOGFLAGS_PREFIX_TIME_PROG;
1494#if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)
1495 fFlags |= RTLOGFLAGS_USECRLF;
1496#endif
1497 static const char * const s_apszLogGroups[] = VBOX_LOGGROUP_NAMES;
1498 rc = RTLogCreate(&g_pRelLogger, fFlags, "all.e.l", "VKAT_RELEASE_LOG",
1499 RT_ELEMENTS(s_apszLogGroups), s_apszLogGroups, RTLOGDEST_STDOUT, NULL /*"vkat-release.log"*/);
1500 if (RT_SUCCESS(rc))
1501 {
1502 RTLogRelSetDefaultInstance(g_pRelLogger);
1503 if (g_uVerbosity)
1504 {
1505 RTMsgInfo("Setting verbosity logging to level %u\n", g_uVerbosity);
1506 switch (g_uVerbosity) /* Not very elegant, but has to do it for now. */
1507 {
1508 case 1:
1509 rc = RTLogGroupSettings(g_pRelLogger,
1510 "drv_audio.e.l+drv_host_audio.e.l+"
1511 "audio_mixer.e.l+audio_test.e.l");
1512 break;
1513
1514 case 2:
1515 rc = RTLogGroupSettings(g_pRelLogger,
1516 "drv_audio.e.l.l2+drv_host_audio.e.l.l2+"
1517 "audio_mixer.e.l.l2+audio_test.e.l.l2");
1518 break;
1519
1520 case 3:
1521 rc = RTLogGroupSettings(g_pRelLogger,
1522 "drv_audio.e.l.l2.l3+drv_host_audio.e.l.l2.l3+"
1523 "audio_mixer.e.l.l2.l3+audio_test.e.l.l2.l3");
1524 break;
1525
1526 case 4:
1527 RT_FALL_THROUGH();
1528 default:
1529 rc = RTLogGroupSettings(g_pRelLogger,
1530 "drv_audio.e.l.l2.l3.l4.f+drv_host_audio.e.l.l2.l3.l4.f+"
1531 "audio_mixer.e.l.l2.l3.l4.f+audio_test.e.l.l2.l3.l4.f");
1532 break;
1533 }
1534 if (RT_FAILURE(rc))
1535 RTMsgError("Setting debug logging failed, rc=%Rrc\n", rc);
1536 }
1537 }
1538 else
1539 RTMsgWarning("Failed to create release logger: %Rrc", rc);
1540
1541 /*
1542 * Install a Ctrl-C signal handler.
1543 */
1544#ifdef RT_OS_WINDOWS
1545 SetConsoleCtrlHandler(audioTestConsoleCtrlHandler, TRUE);
1546#else
1547 struct sigaction sa;
1548 RT_ZERO(sa);
1549 sa.sa_handler = audioTestSignalHandler;
1550 sigaction(SIGINT, &sa, NULL);
1551#endif
1552
1553 /*
1554 * Process common options.
1555 */
1556 RT_ZERO(GetState);
1557 rc = RTGetOptInit(&GetState, argc, argv, g_aCmdCommonOptions,
1558 RT_ELEMENTS(g_aCmdCommonOptions), 1 /*idxFirst*/, 0 /*fFlags - must not sort! */);
1559 AssertRCReturn(rc, RTEXITCODE_INIT);
1560
1561 while ((ch = RTGetOpt(&GetState, &ValueUnion)) != 0)
1562 {
1563 switch (ch)
1564 {
1565 AUDIO_TEST_COMMON_OPTION_CASES(ValueUnion, NULL);
1566
1567 case VINF_GETOPT_NOT_OPTION:
1568 {
1569 for (uintptr_t iCmd = 0; iCmd < RT_ELEMENTS(g_apCommands); iCmd++)
1570 {
1571 PCVKATCMD const pCmd = g_apCommands[iCmd];
1572 if (strcmp(ValueUnion.psz, pCmd->pszCommand) == 0)
1573 {
1574 /* Count the combined option definitions: */
1575 size_t cCombinedOptions = pCmd->cOptions + RT_ELEMENTS(g_aCmdCommonOptions);
1576 if (pCmd->fNeedsTransport)
1577 for (uintptr_t iTx = 0; iTx < g_cTransports; iTx++)
1578 cCombinedOptions += g_apTransports[iTx]->cOpts;
1579
1580 /* Combine the option definitions: */
1581 PRTGETOPTDEF paCombinedOptions = (PRTGETOPTDEF)RTMemAlloc(cCombinedOptions * sizeof(RTGETOPTDEF));
1582 if (paCombinedOptions)
1583 {
1584 uint32_t idxOpts = 0;
1585 memcpy(paCombinedOptions, g_aCmdCommonOptions, sizeof(g_aCmdCommonOptions));
1586 idxOpts += RT_ELEMENTS(g_aCmdCommonOptions);
1587
1588 memcpy(&paCombinedOptions[idxOpts], pCmd->paOptions, pCmd->cOptions * sizeof(RTGETOPTDEF));
1589 idxOpts += (uint32_t)pCmd->cOptions;
1590
1591 if (pCmd->fNeedsTransport)
1592 for (uintptr_t iTx = 0; iTx < g_cTransports; iTx++)
1593 {
1594 memcpy(&paCombinedOptions[idxOpts],
1595 g_apTransports[iTx]->paOpts, g_apTransports[iTx]->cOpts * sizeof(RTGETOPTDEF));
1596 idxOpts += (uint32_t)g_apTransports[iTx]->cOpts;
1597 }
1598
1599 /* Re-initialize the option getter state and pass it to the command handler. */
1600 rc = RTGetOptInit(&GetState, argc, argv, paCombinedOptions, cCombinedOptions,
1601 GetState.iNext /*idxFirst*/, RTGETOPTINIT_FLAGS_OPTS_FIRST);
1602 if (RT_SUCCESS(rc))
1603 {
1604 RTEXITCODE rcExit = pCmd->pfnHandler(&GetState);
1605 RTMemFree(paCombinedOptions);
1606 return rcExit;
1607 }
1608 RTMemFree(paCombinedOptions);
1609 return RTMsgErrorExitFailure("RTGetOptInit failed for '%s': %Rrc", ValueUnion.psz, rc);
1610 }
1611 return RTMsgErrorExitFailure("Out of memory!");
1612 }
1613 }
1614 RTMsgError("Unknown command '%s'!\n", ValueUnion.psz);
1615 audioTestListCommands(g_pStdErr);
1616 return RTEXITCODE_SYNTAX;
1617 }
1618
1619 default:
1620 return RTGetOptPrintError(ch, &ValueUnion);
1621 }
1622 }
1623
1624 RTMsgError("No command specified!\n");
1625 audioTestListCommands(g_pStdErr);
1626 return RTEXITCODE_SYNTAX;
1627}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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