1 | /* $Id: OpenGLTest.cpp 76553 2019-01-01 01:45:53Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox host opengl support test - generic implementation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-2019 Oracle Corporation
|
---|
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 |
|
---|
18 | #include <VBox/err.h>
|
---|
19 | #include <iprt/assert.h>
|
---|
20 | #include <iprt/env.h>
|
---|
21 | #include <iprt/param.h>
|
---|
22 | #include <iprt/path.h>
|
---|
23 | #include <iprt/process.h>
|
---|
24 | #include <iprt/string.h>
|
---|
25 | #include <iprt/time.h>
|
---|
26 | #include <iprt/thread.h>
|
---|
27 | #include <iprt/env.h>
|
---|
28 | #include <iprt/log.h>
|
---|
29 |
|
---|
30 | #include <VBox/VBoxOGL.h>
|
---|
31 |
|
---|
32 | bool RTCALL VBoxOglIs3DAccelerationSupported(void)
|
---|
33 | {
|
---|
34 | if (RTEnvExist("VBOX_CROGL_FORCE_SUPPORTED"))
|
---|
35 | {
|
---|
36 | LogRel(("VBOX_CROGL_FORCE_SUPPORTED is specified, skipping 3D test, and treating as supported\n"));
|
---|
37 | return true;
|
---|
38 | }
|
---|
39 |
|
---|
40 | static char pszVBoxPath[RTPATH_MAX];
|
---|
41 | const char *papszArgs[4] = { NULL, "-test", "3D", NULL};
|
---|
42 | int rc;
|
---|
43 | RTPROCESS Process;
|
---|
44 | RTPROCSTATUS ProcStatus;
|
---|
45 | uint64_t StartTS;
|
---|
46 |
|
---|
47 | #ifdef __SANITIZE_ADDRESS__
|
---|
48 | /* The OpenGL test tool contains a number of memory leaks which cause it to
|
---|
49 | * return failure when run with ASAN unless we disable the leak detector. */
|
---|
50 | RTENV env;
|
---|
51 | if (RT_FAILURE(RTEnvClone(&env, RTENV_DEFAULT)))
|
---|
52 | return false;
|
---|
53 | RTEnvPutEx(env, "ASAN_OPTIONS=detect_leaks=0"); /* If this fails we will notice later */
|
---|
54 | #endif
|
---|
55 | rc = RTPathExecDir(pszVBoxPath, RTPATH_MAX); AssertRCReturn(rc, false);
|
---|
56 | #if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)
|
---|
57 | rc = RTPathAppend(pszVBoxPath, RTPATH_MAX, "VBoxTestOGL.exe");
|
---|
58 | #else
|
---|
59 | rc = RTPathAppend(pszVBoxPath, RTPATH_MAX, "VBoxTestOGL");
|
---|
60 | #endif
|
---|
61 | papszArgs[0] = pszVBoxPath; /* argv[0] */
|
---|
62 | AssertRCReturn(rc, false);
|
---|
63 |
|
---|
64 | #ifndef __SANITIZE_ADDRESS__
|
---|
65 | rc = RTProcCreate(pszVBoxPath, papszArgs, RTENV_DEFAULT, 0, &Process);
|
---|
66 | #else
|
---|
67 | rc = RTProcCreate(pszVBoxPath, papszArgs, env, 0, &Process);
|
---|
68 | RTEnvDestroy(env);
|
---|
69 | #endif
|
---|
70 | if (RT_FAILURE(rc))
|
---|
71 | return false;
|
---|
72 |
|
---|
73 | StartTS = RTTimeMilliTS();
|
---|
74 |
|
---|
75 | while (1)
|
---|
76 | {
|
---|
77 | rc = RTProcWait(Process, RTPROCWAIT_FLAGS_NOBLOCK, &ProcStatus);
|
---|
78 | if (rc != VERR_PROCESS_RUNNING)
|
---|
79 | break;
|
---|
80 |
|
---|
81 | #ifndef DEBUG_misha
|
---|
82 | if (RTTimeMilliTS() - StartTS > 30*1000 /* 30 sec */)
|
---|
83 | {
|
---|
84 | RTProcTerminate(Process);
|
---|
85 | RTThreadSleep(100);
|
---|
86 | RTProcWait(Process, RTPROCWAIT_FLAGS_NOBLOCK, &ProcStatus);
|
---|
87 | return false;
|
---|
88 | }
|
---|
89 | #endif
|
---|
90 | RTThreadSleep(100);
|
---|
91 | }
|
---|
92 |
|
---|
93 | if (RT_SUCCESS(rc))
|
---|
94 | {
|
---|
95 | if ((ProcStatus.enmReason==RTPROCEXITREASON_NORMAL) && (ProcStatus.iStatus==0))
|
---|
96 | {
|
---|
97 | return true;
|
---|
98 | }
|
---|
99 | }
|
---|
100 |
|
---|
101 | return false;
|
---|
102 | }
|
---|
103 |
|
---|