Hash :
d83f64f5
Author :
Date :
2017-02-16T10:58:46
gpu_info_util: Implement GetSystemInfo on OSX Also adds a test that prints the gathered information for manual checking and to help know what the system is when looking at the logs. BUG=angleproject:1874 Change-Id: Icb0cc390c9808fd8db0f966d667b94dde4b94e62 Reviewed-on: https://chromium-review.googlesource.com/443845 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
//
// Copyright 2017 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// SystemInfo_unittest.cpp: Unit tests for SystemInfo* helper functions.
//
#include "gpu_info_util/SystemInfo_internal.h"
#include <gtest/gtest.h>
using namespace angle;
namespace
{
// Test AMD Brahma driver version parsing
TEST(SystemInfoTest, AMDBrahmaVersionParsing)
{
std::string version;
// Check parsing fails when no version string is present.
ASSERT_FALSE(ParseAMDBrahmaDriverVersion("I am a lumberjack.", &version));
ASSERT_EQ("", version);
// Check parsing when the string is just the version string, with and without dots
ASSERT_TRUE(ParseAMDBrahmaDriverVersion("42", &version));
ASSERT_EQ("42", version);
ASSERT_TRUE(ParseAMDBrahmaDriverVersion("42.0.56", &version));
ASSERT_EQ("42.0.56", version);
// Check parsing with prefix / suffix
ASSERT_TRUE(ParseAMDBrahmaDriverVersion("Version=42.0.56", &version));
ASSERT_EQ("42.0.56", version);
ASSERT_TRUE(ParseAMDBrahmaDriverVersion("42.0.56 is the version", &version));
ASSERT_EQ("42.0.56", version);
ASSERT_TRUE(ParseAMDBrahmaDriverVersion("42.0.56 is the version, 111", &version));
ASSERT_EQ("42.0.56", version);
}
// Test AMD Catalyst version parsing
TEST(SystemInfoTest, AMDCatalystVersionParsing)
{
std::string version;
// Check parsing fails when no version string is present.
ASSERT_FALSE(ParseAMDCatalystDriverVersion("I am a lumberjack.\nReleaseVersion=", &version));
ASSERT_EQ("", version);
// Check parsing fails when ReleaseVersion= is present but no number appears in the line
ASSERT_FALSE(ParseAMDCatalystDriverVersion("11\nReleaseVersion=\n12", &version));
ASSERT_EQ("", version);
// Check parsing works on the simple case
ASSERT_TRUE(ParseAMDCatalystDriverVersion("ReleaseVersion=42.0.56", &version));
ASSERT_EQ("42.0.56", version);
// Check parsing works if there are other lines
ASSERT_TRUE(ParseAMDCatalystDriverVersion("11\nReleaseVersion=42.0.56\n12", &version));
ASSERT_EQ("42.0.56", version);
// Check parsing get the first version string
ASSERT_TRUE(
ParseAMDCatalystDriverVersion("ReleaseVersion=42.0.56\nReleaseVersion=0", &version));
ASSERT_EQ("42.0.56", version);
// Check parsing with prefix / suffix
ASSERT_TRUE(ParseAMDCatalystDriverVersion("ReleaseVersion=version is 42.0.56", &version));
ASSERT_EQ("42.0.56", version);
ASSERT_TRUE(ParseAMDCatalystDriverVersion("ReleaseVersion=42.0.56 is the version", &version));
ASSERT_EQ("42.0.56", version);
}
// Test Mac machine model parsing
TEST(SystemInfoTest, MacMachineModelParsing)
{
std::string model;
int32_t major = 1, minor = 2;
// Test on the empty string, that is returned by GetMachineModel on an error
EXPECT_FALSE(ParseMacMachineModel("", &model, &major, &minor));
EXPECT_EQ(0U, model.length());
EXPECT_EQ(1, major);
EXPECT_EQ(2, minor);
// Test on an invalid string
EXPECT_FALSE(ParseMacMachineModel("FooBar", &model, &major, &minor));
// Test on a MacPro model
EXPECT_TRUE(ParseMacMachineModel("MacPro4,1", &model, &major, &minor));
EXPECT_EQ("MacPro", model);
EXPECT_EQ(4, major);
EXPECT_EQ(1, minor);
// Test on a MacBookPro model
EXPECT_TRUE(ParseMacMachineModel("MacBookPro6,2", &model, &major, &minor));
EXPECT_EQ("MacBookPro", model);
EXPECT_EQ(6, major);
EXPECT_EQ(2, minor);
}
} // anonymous namespace