VirtualBox

source: vbox/trunk/src/VBox/Main/generic/OpenGLTest.cpp@ 20499

Last change on this file since 20499 was 20499, checked in by vboxsync, 16 years ago

OpenGLTest.cpp: Fixed RTProcCreate argument list and executable name construction. Use monotonic time instead of wall time for timeout. (fixes compile but are otherwise untested)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1/* $Id: OpenGLTest.cpp 20499 2009-06-12 11:27:00Z vboxsync $ */
2/** @file
3 * VBox host opengl support test - generic implementation.
4 */
5
6/*
7 * Copyright (C) 2009 Sun Microsystems, Inc.
8 *
9 * Sun Microsystems, Inc. confidential
10 * All rights reserved
11 */
12
13#include <VBox/err.h>
14#include <iprt/assert.h>
15#include <iprt/env.h>
16#include <iprt/param.h>
17#include <iprt/path.h>
18#include <iprt/process.h>
19#include <iprt/string.h>
20#include <iprt/time.h>
21
22bool is3DAccelerationSupported()
23{
24 static char pszVBoxPath[RTPATH_MAX];
25 const char *papszArgs[3] = { NULL, "-test", NULL};
26 int rc;
27 RTPROCESS Process;
28 RTPROCSTATUS ProcStatus;
29 uint64_t StartTS;
30
31 rc = RTPathExecDir(pszVBoxPath, RTPATH_MAX); AssertRCReturn(rc, false);
32#if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)
33 rc = RTPathAppend(pszVBoxPath, RTPATH_MAX, "VBoxTestOGL");
34#else
35 rc = RTPathAppend(pszVBoxPath, RTPATH_MAX, "VBoxTestOGL.exe");
36#endif
37 AssertRCReturn(rc, false);
38 papszArgs[0] = pszVBoxPath; /* argv[0] */
39
40 rc = RTProcCreate(pszVBoxPath, papszArgs, RTENV_DEFAULT, 0, &Process);
41 if (RT_FAILURE(rc))
42 return false;
43
44 StartTS = RTTimeMilliTS();
45
46 while (1)
47 {
48 rc = RTProcWait(Process, RTPROCWAIT_FLAGS_NOBLOCK, &ProcStatus);
49 if (rc != VERR_PROCESS_RUNNING)
50 break;
51
52 if (RTTimeMilliTS() - StartTS > 30*1000 /* 30 sec */)
53 {
54 RTProcTerminate(Process);
55 RTThreadSleep(100);
56 RTProcWait(Process, RTPROCWAIT_FLAGS_NOBLOCK, &ProcStatus);
57 return false;
58 }
59 RTThreadSleep(100);
60 }
61
62 if (RT_SUCCESS(rc))
63 {
64 if ((ProcStatus.enmReason==RTPROCEXITREASON_NORMAL) && (ProcStatus.iStatus==0))
65 {
66 return true;
67 }
68 }
69
70 return false;
71}
72
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