Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/src/tests/util_tests/PrintSystemInfoTest.cpp
1693 views
1
//
2
// Copyright 2017 The ANGLE Project Authors. All rights reserved.
3
// Use of this source code is governed by a BSD-style license that can be
4
// found in the LICENSE file.
5
//
6
7
// PrintSystemInfoTest.cpp:
8
// prints the information gathered about the system so that it appears in the test logs
9
10
#include <gtest/gtest.h>
11
12
#include <iostream>
13
14
#include "common/platform.h"
15
#include "common/system_utils.h"
16
#include "gpu_info_util/SystemInfo.h"
17
18
using namespace angle;
19
20
namespace
21
{
22
23
#if defined(ANGLE_PLATFORM_WINDOWS) || defined(ANGLE_PLATFORM_LINUX) || \
24
defined(ANGLE_PLATFORM_APPLE)
25
# define SYSTEM_INFO_IMPLEMENTED
26
#endif
27
28
// Prints the information gathered about the system
29
TEST(PrintSystemInfoTest, Print)
30
{
31
#if defined(SYSTEM_INFO_IMPLEMENTED)
32
SystemInfo info;
33
34
ASSERT_TRUE(GetSystemInfo(&info));
35
ASSERT_GT(info.gpus.size(), 0u);
36
37
PrintSystemInfo(info);
38
#else
39
std::cerr << "GetSystemInfo not implemented, skipping" << std::endl;
40
#endif
41
}
42
43
TEST(PrintSystemInfoTest, GetSystemInfoNoCrashOnInvalidDisplay)
44
{
45
#if defined(SYSTEM_INFO_IMPLEMENTED) && defined(ANGLE_USE_X11)
46
const char kX11DisplayEnvVar[] = "DISPLAY";
47
const char kInvalidDisplay[] = "124:";
48
std::string previous_display = GetEnvironmentVar(kX11DisplayEnvVar);
49
SetEnvironmentVar(kX11DisplayEnvVar, kInvalidDisplay);
50
SystemInfo info;
51
52
// This should not crash.
53
GetSystemInfo(&info);
54
55
if (previous_display.empty())
56
{
57
UnsetEnvironmentVar(kX11DisplayEnvVar);
58
}
59
else
60
{
61
SetEnvironmentVar(kX11DisplayEnvVar, previous_display.c_str());
62
}
63
#elif defined(SYSTEM_INFO_IMPLEMENTED)
64
std::cerr << "GetSystemInfo not implemented, skipping" << std::endl;
65
#else
66
std::cerr << "GetSystemInfo X11 test not applicable, skipping" << std::endl;
67
#endif
68
}
69
70
} // anonymous namespace
71
72