Hash :
2d873e0c
Author :
Date :
2021-03-01T14:38:39
GL: Workaround to sanitize amdgpu renderer strings. On Linux with the amdgpu driver, the GL_RENDERER string contains precise kernel and DRM version info. We should sanitize this info before using these strings for user privacy. Bug: chromium:1181193 Change-Id: I047d1abf5b51412b4258a021761cc450385ef0fe Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2727658 Commit-Queue: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@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
//
// Copyright 2021 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.
//
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "tests/angle_unittests_utils.h"
namespace rx
{
extern std::string SanitizeRendererString(std::string rendererString);
extern std::string SanitizeVersionString(std::string versionString, bool isES);
namespace testing
{
namespace
{
TEST(DisplayGLTest, SanitizeRendererStringIntel)
{
std::string testString = "Mesa DRI Intel(R) HD Graphics 4000 (IVB GT2)";
std::string testExpectation = "Mesa DRI Intel(R) HD Graphics 4000 (IVB GT2)";
EXPECT_EQ(SanitizeRendererString(testString), testExpectation);
}
TEST(DisplayGLTest, SanitizeRendererStringLLVMPipe)
{
std::string testString = "llvmpipe (LLVM 11.0.0, 256 bits)";
std::string testExpectation = "llvmpipe (LLVM 11.0.0, 256 bits)";
EXPECT_EQ(SanitizeRendererString(testString), testExpectation);
}
TEST(DisplayGLTest, SanitizeRendererStringRadeonVega)
{
std::string testString = "Radeon RX Vega";
std::string testExpectation = "Radeon RX Vega";
EXPECT_EQ(SanitizeRendererString(testString), testExpectation);
}
TEST(DisplayGLTest, SanitizeRendererStringRadeonTM)
{
std::string testString =
"AMD Radeon (TM) RX 460 Graphics (POLARIS11, DRM 3.35.0, 5.4.0-65-generic, LLVM 11.0.0)";
std::string testExpectation = "AMD Radeon (TM) RX 460 Graphics (POLARIS11)";
EXPECT_EQ(SanitizeRendererString(testString), testExpectation);
}
TEST(DisplayGLTest, SanitizeRendererStringRadeonWithoutGeneration)
{
std::string testString = "AMD Radeon RX 5700 (DRM 3.35.0, 5.4.0-65-generic, LLVM 11.0.0)";
std::string testExpectation = "AMD Radeon RX 5700";
EXPECT_EQ(SanitizeRendererString(testString), testExpectation);
}
TEST(DisplayGLTest, SanitizeVersionStringOpenGLMissing)
{
std::string testString = "4.6.0 NVIDIA 391.76";
std::string testExpectation = "OpenGL 4.6.0 NVIDIA 391.76";
EXPECT_EQ(SanitizeVersionString(testString, false), testExpectation);
}
// Note: OpenGL renderers with this prefix don't actually seem to be present in the wild
TEST(DisplayGLTest, SanitizeVersionStringOpenGLPresent)
{
std::string testString = "OpenGL 4.5.0 - Build 22.20.16.4749";
std::string testExpectation = "OpenGL 4.5.0 - Build 22.20.16.4749";
EXPECT_EQ(SanitizeVersionString(testString, false), testExpectation);
}
TEST(DisplayGLTest, SanitizeVersionStringOpenGLESMissing)
{
std::string testString = "4.6.0 NVIDIA 419.67";
std::string testExpectation = "OpenGL ES 4.6.0 NVIDIA 419.67";
EXPECT_EQ(SanitizeVersionString(testString, true), testExpectation);
}
TEST(DisplayGLTest, SanitizeVersionStringOpenGLESPresent)
{
std::string testString = "OpenGL ES 3.2 v1.r12p0-04rel0.44f2946824bb8739781564bffe2110c9";
std::string testExpectation = "OpenGL ES 3.2 v1.r12p0-04rel0.44f2946824bb8739781564bffe2110c9";
EXPECT_EQ(SanitizeVersionString(testString, true), testExpectation);
}
} // anonymous namespace
} // namespace testing
} // namespace rx