VirtualBox

source: vbox/trunk/src/VBox/Main/src-helper-apps/OpenGLTest/OpenGLTest.cpp@ 98103

Last change on this file since 98103 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 3.2 KB
Line 
1/* $Id: OpenGLTest.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox host opengl support test - generic implementation.
4 */
5
6/*
7 * Copyright (C) 2009-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.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 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#include <VBox/err.h>
29#include <iprt/assert.h>
30#include <iprt/env.h>
31#include <iprt/param.h>
32#include <iprt/path.h>
33#include <iprt/process.h>
34#include <iprt/string.h>
35#include <iprt/time.h>
36#include <iprt/thread.h>
37#include <iprt/env.h>
38#include <iprt/log.h>
39
40#include <VBox/VBoxOGL.h>
41
42bool RTCALL VBoxOglIs3DAccelerationSupported(void)
43{
44 if (RTEnvExist("VBOX_3D_FORCE_SUPPORTED"))
45 {
46 LogRel(("VBOX_3D_FORCE_SUPPORTED is specified, skipping 3D test, and treating as supported\n"));
47 return true;
48 }
49
50 static char pszVBoxPath[RTPATH_MAX];
51 const char *papszArgs[4] = { NULL, "-test", "3D", NULL};
52 int rc;
53 RTPROCESS Process;
54 RTPROCSTATUS ProcStatus;
55 uint64_t StartTS;
56
57#ifdef __SANITIZE_ADDRESS__
58 /* The OpenGL test tool contains a number of memory leaks which cause it to
59 * return failure when run with ASAN unless we disable the leak detector. */
60 RTENV env;
61 if (RT_FAILURE(RTEnvClone(&env, RTENV_DEFAULT)))
62 return false;
63 RTEnvPutEx(env, "ASAN_OPTIONS=detect_leaks=0"); /* If this fails we will notice later */
64#endif
65 rc = RTPathExecDir(pszVBoxPath, RTPATH_MAX); AssertRCReturn(rc, false);
66#if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)
67 rc = RTPathAppend(pszVBoxPath, RTPATH_MAX, "VBoxTestOGL.exe");
68#else
69 rc = RTPathAppend(pszVBoxPath, RTPATH_MAX, "VBoxTestOGL");
70#endif
71 papszArgs[0] = pszVBoxPath; /* argv[0] */
72 AssertRCReturn(rc, false);
73
74#ifndef __SANITIZE_ADDRESS__
75 rc = RTProcCreate(pszVBoxPath, papszArgs, RTENV_DEFAULT, 0, &Process);
76#else
77 rc = RTProcCreate(pszVBoxPath, papszArgs, env, 0, &Process);
78 RTEnvDestroy(env);
79#endif
80 if (RT_FAILURE(rc))
81 return false;
82
83 StartTS = RTTimeMilliTS();
84
85 while (1)
86 {
87 rc = RTProcWait(Process, RTPROCWAIT_FLAGS_NOBLOCK, &ProcStatus);
88 if (rc != VERR_PROCESS_RUNNING)
89 break;
90
91#ifndef DEBUG_misha
92 if (RTTimeMilliTS() - StartTS > 30*1000 /* 30 sec */)
93 {
94 RTProcTerminate(Process);
95 RTThreadSleep(100);
96 RTProcWait(Process, RTPROCWAIT_FLAGS_NOBLOCK, &ProcStatus);
97 return false;
98 }
99#endif
100 RTThreadSleep(100);
101 }
102
103 if (RT_SUCCESS(rc))
104 {
105 if ((ProcStatus.enmReason==RTPROCEXITREASON_NORMAL) && (ProcStatus.iStatus==0))
106 {
107 return true;
108 }
109 }
110
111 return false;
112}
113
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