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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <sal/types.h>
#include <cppunit/TestAssert.h>
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/plugin/TestPlugIn.h>
#include <unotest/bootstrapfixturebase.hxx>
#include <driverblocklist.hxx>
using namespace DriverBlocklist;
namespace
{
class BlocklistParserTest : public test::BootstrapFixtureBase
{
void testParse();
void testEvaluate();
void testVulkan();
CPPUNIT_TEST_SUITE(BlocklistParserTest);
CPPUNIT_TEST(testParse);
CPPUNIT_TEST(testEvaluate);
CPPUNIT_TEST(testVulkan);
CPPUNIT_TEST_SUITE_END();
};
void BlocklistParserTest::testParse()
{
std::vector<DriverInfo> aDriveInfos;
Parser aBlocklistParser(m_directories.getURLFromSrc(u"vcl/qa/cppunit/") + "test_blocklist_parse.xml",
aDriveInfos, VersionType::OpenGL);
aBlocklistParser.parse();
size_t const n = aDriveInfos.size();
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(16), n);
size_t i = 0;
for (bool bIsAllowlisted : {true, false})
{
DriverInfo& aDriveInfo = aDriveInfos[i++];
CPPUNIT_ASSERT_EQUAL(bIsAllowlisted, aDriveInfo.mbAllowlisted);
CPPUNIT_ASSERT_EQUAL(GetVendorId(VendorAll), aDriveInfo.maAdapterVendor); // "all"
CPPUNIT_ASSERT_EQUAL(VersionComparisonOp::DRIVER_LESS_THAN, aDriveInfo.meComparisonOp);
CPPUNIT_ASSERT_EQUAL(OpenGLVersion(10,20,30,40), aDriveInfo.mnDriverVersion);
aDriveInfo = aDriveInfos[i++];
CPPUNIT_ASSERT_EQUAL(bIsAllowlisted, aDriveInfo.mbAllowlisted);
CPPUNIT_ASSERT_EQUAL(GetVendorId(VendorNVIDIA), aDriveInfo.maAdapterVendor);
CPPUNIT_ASSERT_EQUAL(VersionComparisonOp::DRIVER_EQUAL, aDriveInfo.meComparisonOp);
aDriveInfo = aDriveInfos[i++];
CPPUNIT_ASSERT_EQUAL(bIsAllowlisted, aDriveInfo.mbAllowlisted);
CPPUNIT_ASSERT_EQUAL(GetVendorId(VendorMicrosoft), aDriveInfo.maAdapterVendor);
CPPUNIT_ASSERT_EQUAL(VersionComparisonOp::DRIVER_NOT_EQUAL, aDriveInfo.meComparisonOp);
aDriveInfo = aDriveInfos[i++];
CPPUNIT_ASSERT_EQUAL(bIsAllowlisted, aDriveInfo.mbAllowlisted);
CPPUNIT_ASSERT_EQUAL(OUString("0xcafe"), aDriveInfo.maAdapterVendor);
CPPUNIT_ASSERT_EQUAL(VersionComparisonOp::DRIVER_NOT_EQUAL, aDriveInfo.meComparisonOp);
aDriveInfo = aDriveInfos[i++];
CPPUNIT_ASSERT_EQUAL(bIsAllowlisted, aDriveInfo.mbAllowlisted);
CPPUNIT_ASSERT_EQUAL(GetVendorId(VendorAll), aDriveInfo.maAdapterVendor);
CPPUNIT_ASSERT_EQUAL(VersionComparisonOp::DRIVER_BETWEEN_EXCLUSIVE, aDriveInfo.meComparisonOp);
aDriveInfo = aDriveInfos[i++];
CPPUNIT_ASSERT_EQUAL(bIsAllowlisted, aDriveInfo.mbAllowlisted);
CPPUNIT_ASSERT_EQUAL(GetVendorId(VendorAll), aDriveInfo.maAdapterVendor);
CPPUNIT_ASSERT_EQUAL(VersionComparisonOp::DRIVER_BETWEEN_INCLUSIVE, aDriveInfo.meComparisonOp);
aDriveInfo = aDriveInfos[i++];
CPPUNIT_ASSERT_EQUAL(bIsAllowlisted, aDriveInfo.mbAllowlisted);
CPPUNIT_ASSERT_EQUAL(GetVendorId(VendorAll), aDriveInfo.maAdapterVendor);
CPPUNIT_ASSERT_EQUAL(VersionComparisonOp::DRIVER_BETWEEN_INCLUSIVE_START, aDriveInfo.meComparisonOp);
aDriveInfo = aDriveInfos[i++];
CPPUNIT_ASSERT_EQUAL(bIsAllowlisted, aDriveInfo.mbAllowlisted);
CPPUNIT_ASSERT_EQUAL(GetVendorId(VendorAll), aDriveInfo.maAdapterVendor);
CPPUNIT_ASSERT_EQUAL(VersionComparisonOp::DRIVER_COMPARISON_IGNORED, aDriveInfo.meComparisonOp);
}
}
void BlocklistParserTest::testEvaluate()
{
std::vector<DriverInfo> aDriveInfos;
Parser aBlocklistParser(m_directories.getURLFromSrc(u"vcl/qa/cppunit/") + "test_blocklist_evaluate.xml",
aDriveInfos, VersionType::OpenGL);
aBlocklistParser.parse();
OUString vendorAMD = GetVendorId(VendorAMD);
OUString vendorNVIDIA = GetVendorId(VendorNVIDIA);
OUString vendorIntel = GetVendorId(VendorIntel);
OUString vendorMicrosoft = GetVendorId(VendorMicrosoft);
// Check OS
CPPUNIT_ASSERT_EQUAL(false, FindBlocklistedDeviceInList(
aDriveInfos, VersionType::OpenGL, u"10.20.30.40", vendorNVIDIA, "all", DRIVER_OS_WINDOWS_7));
CPPUNIT_ASSERT_EQUAL(false, FindBlocklistedDeviceInList(
aDriveInfos, VersionType::OpenGL, u"10.20.30.40", vendorNVIDIA, "all", DRIVER_OS_WINDOWS_8));
CPPUNIT_ASSERT_EQUAL(false, FindBlocklistedDeviceInList(
aDriveInfos, VersionType::OpenGL, u"10.20.30.40", vendorNVIDIA, "all", DRIVER_OS_WINDOWS_10));
// Check generic OS
CPPUNIT_ASSERT_EQUAL(false, FindBlocklistedDeviceInList(
aDriveInfos, VersionType::OpenGL, u"10.20.30.50", vendorMicrosoft, "all", DRIVER_OS_WINDOWS_10));
CPPUNIT_ASSERT_EQUAL(true, FindBlocklistedDeviceInList(
aDriveInfos, VersionType::OpenGL, u"10.20.30.50", vendorMicrosoft, "all", DRIVER_OS_LINUX));
CPPUNIT_ASSERT_EQUAL(true, FindBlocklistedDeviceInList(
aDriveInfos, VersionType::OpenGL, u"10.20.30.50", vendorMicrosoft, "all", DRIVER_OS_OSX_10_7));
CPPUNIT_ASSERT_EQUAL(true, FindBlocklistedDeviceInList(
aDriveInfos, VersionType::OpenGL, u"10.20.30.50", vendorMicrosoft, "all", DRIVER_OS_OSX_10_8));
// Check Vendors
CPPUNIT_ASSERT_EQUAL(true, FindBlocklistedDeviceInList(
aDriveInfos, VersionType::OpenGL, u"10.20.30.40", vendorMicrosoft, "all", DRIVER_OS_WINDOWS_7));
CPPUNIT_ASSERT_EQUAL(true, FindBlocklistedDeviceInList(
aDriveInfos, VersionType::OpenGL, u"10.20.30.40", vendorMicrosoft, "all", DRIVER_OS_WINDOWS_10));
// Check Versions
CPPUNIT_ASSERT_EQUAL(true, FindBlocklistedDeviceInList(
aDriveInfos, VersionType::OpenGL, u"10.20.30.39", vendorAMD, "all", DRIVER_OS_WINDOWS_7));
CPPUNIT_ASSERT_EQUAL(false, FindBlocklistedDeviceInList(
aDriveInfos, VersionType::OpenGL, u"10.20.30.40", vendorAMD, "all", DRIVER_OS_WINDOWS_7));
CPPUNIT_ASSERT_EQUAL(false, FindBlocklistedDeviceInList(
aDriveInfos, VersionType::OpenGL, u"10.20.30.41", vendorAMD, "all", DRIVER_OS_WINDOWS_7));
// Check
CPPUNIT_ASSERT_EQUAL(true, FindBlocklistedDeviceInList(
aDriveInfos, VersionType::OpenGL, u"9.17.10.4229", vendorIntel, "all", DRIVER_OS_WINDOWS_7));
}
void BlocklistParserTest::testVulkan()
{
std::vector<DriverInfo> aDriveInfos;
Parser aBlocklistParser(m_directories.getURLFromSrc(u"vcl/qa/cppunit/") + "test_blocklist_vulkan.xml",
aDriveInfos, VersionType::Vulkan);
aBlocklistParser.parse();
OUString vendorAMD = GetVendorId(VendorAMD);
// Check Versions
CPPUNIT_ASSERT_EQUAL(false, FindBlocklistedDeviceInList(
aDriveInfos, VersionType::Vulkan, u"1.2.3", vendorAMD, "all", DRIVER_OS_ALL));
CPPUNIT_ASSERT_EQUAL(true, FindBlocklistedDeviceInList(
aDriveInfos, VersionType::Vulkan, u"1.2.2", vendorAMD, "all", DRIVER_OS_ALL));
CPPUNIT_ASSERT_EQUAL(false, FindBlocklistedDeviceInList(
aDriveInfos, VersionType::Vulkan, u"1.2.20", vendorAMD, "all", DRIVER_OS_ALL));
}
} // namespace
CPPUNIT_TEST_SUITE_REGISTRATION(BlocklistParserTest);
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|