Path: blob/main_old/src/tests/util_tests/PrintSystemInfoTest.cpp
1693 views
//1// Copyright 2017 The ANGLE Project Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4//56// PrintSystemInfoTest.cpp:7// prints the information gathered about the system so that it appears in the test logs89#include <gtest/gtest.h>1011#include <iostream>1213#include "common/platform.h"14#include "common/system_utils.h"15#include "gpu_info_util/SystemInfo.h"1617using namespace angle;1819namespace20{2122#if defined(ANGLE_PLATFORM_WINDOWS) || defined(ANGLE_PLATFORM_LINUX) || \23defined(ANGLE_PLATFORM_APPLE)24# define SYSTEM_INFO_IMPLEMENTED25#endif2627// Prints the information gathered about the system28TEST(PrintSystemInfoTest, Print)29{30#if defined(SYSTEM_INFO_IMPLEMENTED)31SystemInfo info;3233ASSERT_TRUE(GetSystemInfo(&info));34ASSERT_GT(info.gpus.size(), 0u);3536PrintSystemInfo(info);37#else38std::cerr << "GetSystemInfo not implemented, skipping" << std::endl;39#endif40}4142TEST(PrintSystemInfoTest, GetSystemInfoNoCrashOnInvalidDisplay)43{44#if defined(SYSTEM_INFO_IMPLEMENTED) && defined(ANGLE_USE_X11)45const char kX11DisplayEnvVar[] = "DISPLAY";46const char kInvalidDisplay[] = "124:";47std::string previous_display = GetEnvironmentVar(kX11DisplayEnvVar);48SetEnvironmentVar(kX11DisplayEnvVar, kInvalidDisplay);49SystemInfo info;5051// This should not crash.52GetSystemInfo(&info);5354if (previous_display.empty())55{56UnsetEnvironmentVar(kX11DisplayEnvVar);57}58else59{60SetEnvironmentVar(kX11DisplayEnvVar, previous_display.c_str());61}62#elif defined(SYSTEM_INFO_IMPLEMENTED)63std::cerr << "GetSystemInfo not implemented, skipping" << std::endl;64#else65std::cerr << "GetSystemInfo X11 test not applicable, skipping" << std::endl;66#endif67}6869} // anonymous namespace707172