VirtualBox

source: vbox/trunk/src/VBox/Runtime/testcase/tstIoCtl.cpp@ 8245

Last change on this file since 8245 was 8245, checked in by vboxsync, 17 years ago

rebranding: IPRT files again.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.6 KB
Line 
1/* $Id: tstIoCtl.cpp 8245 2008-04-21 17:24:28Z vboxsync $ */
2/** @file
3 * IPRT Testcase - file IoCtl.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27 * Clara, CA 95054 USA or visit http://www.sun.com if you need
28 * additional information or have any questions.
29 */
30
31/*******************************************************************************
32* Header Files *
33*******************************************************************************/
34//#include <sys/types.h>
35#include "soundcard.h"
36//#include <VBox/pdm.h>
37#include <VBox/err.h>
38
39#include <iprt/log.h>
40#include <VBox/log.h>
41#define LOG_GROUP LOG_GROUP_DEV_AUDIO
42//#include <iprt/assert.h>
43//#include <iprt/uuid.h>
44//#include <iprt/string.h>
45//#include <iprt/alloc.h>
46#include <iprt/file.h>
47
48//#include "audio.h"
49//#include "audio_int.h"
50
51#include <stdio.h>
52#include <iprt/uuid.h>
53
54#ifdef RT_OS_L4
55extern char **__environ;
56char *myenv[] = { "+all.e", NULL };
57#endif
58
59int main()
60{
61#ifdef RT_OS_L4
62 __environ = myenv;
63#endif
64 int rcRet = 0;
65 int ret, err;
66 printf("tstIoCtl: TESTING\n");
67
68 RTFILE File;
69
70 if (RT_FAILURE(err = RTFileOpen(&File, "/dev/dsp", (RTFILE_O_READWRITE) | RTFILE_O_NON_BLOCK))) {
71 printf("Fatal error: failed to open /dev/dsp:\n"
72 "VBox error code: %d\n", err);
73 return 1;
74 }
75
76 int rate = 100;
77
78 if (RT_FAILURE(err = RTFileIoCtl(File, SNDCTL_DSP_SPEED, &rate, sizeof(rate), &ret)) || ret) {
79 printf("Failed to set playback speed on /dev/dsp\n"
80 "VBox error code: %d, IOCTL return value: %d\n",
81 err, ret);
82 rcRet++;
83 } else printf("Playback speed successfully set to 100, reported speed is %d\n",
84 rate);
85
86 rate = 48000;
87
88 if (RT_FAILURE(err = RTFileIoCtl(File, SNDCTL_DSP_SPEED, &rate, sizeof(rate), &ret)) || ret) {
89 printf("Failed to set playback speed on /dev/dsp\n"
90 "VBox error code: %d, IOCTL return value: %d\n",
91 err, ret);
92 rcRet++;
93 } else printf("Playback speed successfully set to 48000, reported speed is %d\n",
94 rate);
95
96 /*
97 * Cleanup.
98 */
99 ret = RTFileClose(File);
100 if (RT_FAILURE(ret))
101 {
102 printf("Failed to close /dev/dsp. ret=%d\n", ret);
103 rcRet++;
104 }
105
106 /* Under Linux and L4, this involves ioctls internally */
107 RTUUID TestUuid;
108 if (RT_FAILURE(RTUuidCreate(&TestUuid)))
109 {
110 printf("Failed to create a UUID. ret=%d\n", ret);
111 rcRet++;
112 }
113
114 /*
115 * Summary
116 */
117 if (rcRet == 0)
118 printf("tstIoCtl: SUCCESS\n");
119 else
120 printf("tstIoCtl: FAILURE - %d errors\n", rcRet);
121 return rcRet;
122}
Note: See TracBrowser for help on using the repository browser.

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