VirtualBox

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

Last change on this file since 25275 was 24788, checked in by vboxsync, 15 years ago

2D/3D support test: make the test app be invoked with propper args on win in case path with spaces

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.6 KB
Line 
1/* $Id: OpenGLTest.cpp 24788 2009-11-19 13:09:59Z vboxsync $ */
2/** @file
3 * VBox host opengl support test - generic implementation.
4 */
5
6/*
7 * Copyright (C) 2009 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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#include <VBox/err.h>
23#include <iprt/assert.h>
24#include <iprt/env.h>
25#include <iprt/param.h>
26#include <iprt/path.h>
27#include <iprt/process.h>
28#include <iprt/string.h>
29#include <iprt/time.h>
30#include <iprt/thread.h>
31
32bool is3DAccelerationSupported()
33{
34 static char pszVBoxPath[RTPATH_MAX];
35 const char *papszArgs[4] = { NULL, "-test", "3D", NULL};
36 int rc;
37 RTPROCESS Process;
38 RTPROCSTATUS ProcStatus;
39 uint64_t StartTS;
40
41 rc = RTPathExecDir(pszVBoxPath, RTPATH_MAX); AssertRCReturn(rc, false);
42#if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)
43 rc = RTPathAppend(pszVBoxPath, RTPATH_MAX, "VBoxTestOGL.exe");
44 static char pszVBoxPathArg[RTPATH_MAX];
45 pszVBoxPathArg[0] = '"';
46 strcpy(pszVBoxPathArg+1, pszVBoxPath);
47 char *pszPathEnd = (char *)memchr(pszVBoxPathArg, '\0', RTPATH_MAX);
48 pszPathEnd[0] = '"';
49 pszPathEnd[1] = '\0';
50 papszArgs[0] = pszVBoxPathArg; /* argv[0] */
51#else
52 rc = RTPathAppend(pszVBoxPath, RTPATH_MAX, "VBoxTestOGL");
53 papszArgs[0] = pszVBoxPath; /* argv[0] */
54#endif
55 AssertRCReturn(rc, false);
56
57 rc = RTProcCreate(pszVBoxPath, papszArgs, RTENV_DEFAULT, 0, &Process);
58 if (RT_FAILURE(rc))
59 return false;
60
61 StartTS = RTTimeMilliTS();
62
63 while (1)
64 {
65 rc = RTProcWait(Process, RTPROCWAIT_FLAGS_NOBLOCK, &ProcStatus);
66 if (rc != VERR_PROCESS_RUNNING)
67 break;
68
69 if (RTTimeMilliTS() - StartTS > 30*1000 /* 30 sec */)
70 {
71 RTProcTerminate(Process);
72 RTThreadSleep(100);
73 RTProcWait(Process, RTPROCWAIT_FLAGS_NOBLOCK, &ProcStatus);
74 return false;
75 }
76 RTThreadSleep(100);
77 }
78
79 if (RT_SUCCESS(rc))
80 {
81 if ((ProcStatus.enmReason==RTPROCEXITREASON_NORMAL) && (ProcStatus.iStatus==0))
82 {
83 return true;
84 }
85 }
86
87 return false;
88}
89
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use