From 2f496d6a1e83ec234ce7479c5397c04dc126b12c Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Mon, 15 Feb 2016 15:10:03 +0100 Subject: Unit test for opengl blocklist parsing and evaluating Parsing unit test checks that the xml values are parsed correctly and that the DriverInfo structure is populated with the expected values. Evaluate unit test checks that blacklisting / whitelisting logic blocks OS/vendor/driver/device as expected. Change-Id: Ib1b0926606f0835207c324193bbe19ba83f86bdc Reviewed-on: https://gerrit.libreoffice.org/22377 Reviewed-by: Michael Meeks Tested-by: Jenkins --- vcl/CppunitTest_vcl_blocklistparser_test.mk | 49 +++++++++ vcl/Module_vcl.mk | 1 + vcl/inc/opengl/win/WinDeviceInfo.hxx | 14 ++- vcl/inc/opengl/win/blocklist_parser.hxx | 43 ++++++++ vcl/opengl/win/WinDeviceInfo.cxx | 57 +++++----- vcl/opengl/win/blocklist_parser.cxx | 2 +- vcl/opengl/win/blocklist_parser.hxx | 45 -------- vcl/qa/cppunit/blocklistparsertest.cxx | 161 ++++++++++++++++++++++++++++ vcl/qa/cppunit/test_blocklist_evaluate.xml | 47 ++++++++ vcl/qa/cppunit/test_blocklist_parse.xml | 75 +++++++++++++ 10 files changed, 419 insertions(+), 75 deletions(-) create mode 100644 vcl/CppunitTest_vcl_blocklistparser_test.mk create mode 100644 vcl/inc/opengl/win/blocklist_parser.hxx delete mode 100644 vcl/opengl/win/blocklist_parser.hxx create mode 100644 vcl/qa/cppunit/blocklistparsertest.cxx create mode 100755 vcl/qa/cppunit/test_blocklist_evaluate.xml create mode 100755 vcl/qa/cppunit/test_blocklist_parse.xml diff --git a/vcl/CppunitTest_vcl_blocklistparser_test.mk b/vcl/CppunitTest_vcl_blocklistparser_test.mk new file mode 100644 index 000000000000..95b75076b32b --- /dev/null +++ b/vcl/CppunitTest_vcl_blocklistparser_test.mk @@ -0,0 +1,49 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# 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/. +# + +$(eval $(call gb_CppunitTest_CppunitTest,vcl_blocklistparser_test)) + +$(eval $(call gb_CppunitTest_set_include,vcl_blocklistparser_test,\ + $$(INCLUDE) \ + -I$(SRCDIR)/vcl/inc \ +)) + +$(eval $(call gb_CppunitTest_add_exception_objects,vcl_blocklistparser_test, \ + vcl/qa/cppunit/blocklistparsertest \ +)) + +$(eval $(call gb_CppunitTest_use_externals,vcl_blocklistparser_test,\ + boost_headers \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,vcl_blocklistparser_test, \ + sal \ + test \ + unotest \ + vcl \ + $(gb_UWINAPI) \ +)) + +$(eval $(call gb_CppunitTest_use_api,vcl_blocklistparser_test,\ + udkapi \ + offapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,vcl_blocklistparser_test)) +$(eval $(call gb_CppunitTest_use_vcl,vcl_blocklistparser_test)) + +$(eval $(call gb_CppunitTest_use_components,vcl_blocklistparser_test,\ + configmgr/source/configmgr \ + i18npool/util/i18npool \ + ucb/source/core/ucb1 \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,vcl_blocklistparser_test)) + +# vim: set noet sw=4 ts=4: diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk index 1480504c72bb..90a16b39f076 100644 --- a/vcl/Module_vcl.mk +++ b/vcl/Module_vcl.mk @@ -121,6 +121,7 @@ endif ifeq ($(OS),WNT) $(eval $(call gb_Module_add_check_targets,vcl,\ CppunitTest_vcl_timer \ + CppunitTest_vcl_blocklistparser_test \ )) endif # vim: set noet sw=4 ts=4: diff --git a/vcl/inc/opengl/win/WinDeviceInfo.hxx b/vcl/inc/opengl/win/WinDeviceInfo.hxx index 974d6b312f7d..8dcbd553dfe9 100644 --- a/vcl/inc/opengl/win/WinDeviceInfo.hxx +++ b/vcl/inc/opengl/win/WinDeviceInfo.hxx @@ -10,7 +10,10 @@ #ifndef INCLUDED_VCL_OPENGL_WIN_WINDEVICEINFO_HXX #define INCLUDED_VCL_OPENGL_WIN_WINDEVICEINFO_HXX +#include + #include "opengl/DeviceInfo.hxx" + #include #include #include @@ -60,14 +63,14 @@ enum DeviceVendor { bool ParseDriverVersion(const OUString& rString, uint64_t& rVersion); -struct DriverInfo +struct VCL_DLLPUBLIC DriverInfo { DriverInfo(OperatingSystem os, const OUString& vendor, VersionComparisonOp op, uint64_t driverVersion, bool bWhiteListed = false, const char *suggestedVersion = nullptr); DriverInfo(); - ~DriverInfo(); + virtual ~DriverInfo(); OperatingSystem meOperatingSystem; uint32_t mnOperatingSystemVersion; @@ -96,7 +99,7 @@ struct DriverInfo #define GFX_DRIVER_VERSION(a,b,c,d) \ ((uint64_t(a)<<48) | (uint64_t(b)<<32) | (uint64_t(c)<<16) | uint64_t(d)) -inline uint64_t V(uint32_t a, uint32_t b, uint32_t c, uint32_t d) +inline VCL_DLLPUBLIC uint64_t V(uint32_t a, uint32_t b, uint32_t c, uint32_t d) { // We make sure every driver number is padded by 0s, this will allow us the // easiest 'compare as if decimals' approach. See ParseDriverVersion for a @@ -115,7 +118,7 @@ inline uint64_t V(uint32_t a, uint32_t b, uint32_t c, uint32_t d) } -class WinOpenGLDeviceInfo : public OpenGLDeviceInfo +class VCL_DLLPUBLIC WinOpenGLDeviceInfo : public OpenGLDeviceInfo { private: OUString maDriverVersion; @@ -204,6 +207,9 @@ public: return mnWindowsVersion; } + static bool FindBlocklistedDeviceInList(std::vector& aDeviceInfos, + OUString sDriverVersion, OUString sAdapterVendorID, + OUString sAdapterDeviceID, uint32_t nWindowsVersion); }; #endif diff --git a/vcl/inc/opengl/win/blocklist_parser.hxx b/vcl/inc/opengl/win/blocklist_parser.hxx new file mode 100644 index 000000000000..f30734436f22 --- /dev/null +++ b/vcl/inc/opengl/win/blocklist_parser.hxx @@ -0,0 +1,43 @@ +/* -*- 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 +#include +#include +#include "opengl/win/WinDeviceInfo.hxx" + +class InvalidFileException +{ +}; + +class VCL_DLLPUBLIC WinBlocklistParser +{ +public: + WinBlocklistParser(const OUString& rURL, std::vector& rDriverList); + void parse(); + +private: + void handleEntry(wgl::DriverInfo& rDriver, xmlreader::XmlReader& rReader); + void handleDevices(wgl::DriverInfo& rDriver, xmlreader::XmlReader& rReader); + void handleList(xmlreader::XmlReader& rReader); + void handleContent(xmlreader::XmlReader& rReader); + + enum class BlockType + { + WHITELIST, + BLACKLIST, + UNKNOWN + }; + + BlockType meBlockType; + std::vector& mrDriverList; + OUString maURL; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/opengl/win/WinDeviceInfo.cxx b/vcl/opengl/win/WinDeviceInfo.cxx index 3f226c31cfa3..1cb85da3f5ed 100644 --- a/vcl/opengl/win/WinDeviceInfo.cxx +++ b/vcl/opengl/win/WinDeviceInfo.cxx @@ -9,7 +9,7 @@ #include "opengl/win/WinDeviceInfo.hxx" -#include "blocklist_parser.hxx" +#include "opengl/win/blocklist_parser.hxx" #include #include @@ -451,67 +451,69 @@ private: } -bool WinOpenGLDeviceInfo::FindBlocklistedDeviceInList() +bool WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(std::vector& aDeviceInfos, + OUString sDriverVersion, OUString sAdapterVendorID, + OUString sAdapterDeviceID, uint32_t nWindowsVersion) { uint64_t driverVersion; - wgl::ParseDriverVersion(maDriverVersion, driverVersion); + wgl::ParseDriverVersion(sDriverVersion, driverVersion); - wgl::OperatingSystem eOS = WindowsVersionToOperatingSystem(mnWindowsVersion); + wgl::OperatingSystem eOS = WindowsVersionToOperatingSystem(nWindowsVersion); bool match = false; uint32_t i = 0; - for (; i < maDriverInfo.size(); i++) + for (; i < aDeviceInfos.size(); i++) { - if (maDriverInfo[i].meOperatingSystem != wgl::DRIVER_OS_ALL && - maDriverInfo[i].meOperatingSystem != eOS) + if (aDeviceInfos[i].meOperatingSystem != wgl::DRIVER_OS_ALL && + aDeviceInfos[i].meOperatingSystem != eOS) { continue; } - if (maDriverInfo[i].mnOperatingSystemVersion && maDriverInfo[i].mnOperatingSystemVersion != mnWindowsVersion) + if (aDeviceInfos[i].mnOperatingSystemVersion && aDeviceInfos[i].mnOperatingSystemVersion != nWindowsVersion) { continue; } - if (!maDriverInfo[i].maAdapterVendor.equalsIgnoreAsciiCase(GetDeviceVendor(wgl::VendorAll)) && - !maDriverInfo[i].maAdapterVendor.equalsIgnoreAsciiCase(maAdapterVendorID)) + if (!aDeviceInfos[i].maAdapterVendor.equalsIgnoreAsciiCase(GetDeviceVendor(wgl::VendorAll)) && + !aDeviceInfos[i].maAdapterVendor.equalsIgnoreAsciiCase(sAdapterVendorID)) { continue; } - if (std::none_of(maDriverInfo[i].maDevices.begin(), maDriverInfo[i].maDevices.end(), compareIgnoreAsciiCase("all")) && - std::none_of(maDriverInfo[i].maDevices.begin(), maDriverInfo[i].maDevices.end(), compareIgnoreAsciiCase(maAdapterDeviceID))) + if (std::none_of(aDeviceInfos[i].maDevices.begin(), aDeviceInfos[i].maDevices.end(), compareIgnoreAsciiCase("all")) && + std::none_of(aDeviceInfos[i].maDevices.begin(), aDeviceInfos[i].maDevices.end(), compareIgnoreAsciiCase(sAdapterDeviceID))) { continue; } - switch (maDriverInfo[i].meComparisonOp) + switch (aDeviceInfos[i].meComparisonOp) { case wgl::DRIVER_LESS_THAN: - match = driverVersion < maDriverInfo[i].mnDriverVersion; + match = driverVersion < aDeviceInfos[i].mnDriverVersion; break; case wgl::DRIVER_LESS_THAN_OR_EQUAL: - match = driverVersion <= maDriverInfo[i].mnDriverVersion; + match = driverVersion <= aDeviceInfos[i].mnDriverVersion; break; case wgl::DRIVER_GREATER_THAN: - match = driverVersion > maDriverInfo[i].mnDriverVersion; + match = driverVersion > aDeviceInfos[i].mnDriverVersion; break; case wgl::DRIVER_GREATER_THAN_OR_EQUAL: - match = driverVersion >= maDriverInfo[i].mnDriverVersion; + match = driverVersion >= aDeviceInfos[i].mnDriverVersion; break; case wgl::DRIVER_EQUAL: - match = driverVersion == maDriverInfo[i].mnDriverVersion; + match = driverVersion == aDeviceInfos[i].mnDriverVersion; break; case wgl::DRIVER_NOT_EQUAL: - match = driverVersion != maDriverInfo[i].mnDriverVersion; + match = driverVersion != aDeviceInfos[i].mnDriverVersion; break; case wgl::DRIVER_BETWEEN_EXCLUSIVE: - match = driverVersion > maDriverInfo[i].mnDriverVersion && driverVersion < maDriverInfo[i].mnDriverVersionMax; + match = driverVersion > aDeviceInfos[i].mnDriverVersion && driverVersion < aDeviceInfos[i].mnDriverVersionMax; break; case wgl::DRIVER_BETWEEN_INCLUSIVE: - match = driverVersion >= maDriverInfo[i].mnDriverVersion && driverVersion <= maDriverInfo[i].mnDriverVersionMax; + match = driverVersion >= aDeviceInfos[i].mnDriverVersion && driverVersion <= aDeviceInfos[i].mnDriverVersionMax; break; case wgl::DRIVER_BETWEEN_INCLUSIVE_START: - match = driverVersion >= maDriverInfo[i].mnDriverVersion && driverVersion < maDriverInfo[i].mnDriverVersionMax; + match = driverVersion >= aDeviceInfos[i].mnDriverVersion && driverVersion < aDeviceInfos[i].mnDriverVersionMax; break; case wgl::DRIVER_COMPARISON_IGNORED: // We don't have a comparison op, so we match everything. @@ -522,17 +524,17 @@ bool WinOpenGLDeviceInfo::FindBlocklistedDeviceInList() break; } - if (match || maDriverInfo[i].mnDriverVersion == wgl::DriverInfo::allDriverVersions) + if (match || aDeviceInfos[i].mnDriverVersion == wgl::DriverInfo::allDriverVersions) { // white listed drivers - if (maDriverInfo[i].mbWhitelisted) + if (aDeviceInfos[i].mbWhitelisted) { SAL_WARN("vcl.opengl", "whitelisted driver"); return false; } match = true; - SAL_WARN("vcl.opengl", "use : " << maDriverInfo[i].maSuggestedVersion); + SAL_WARN("vcl.opengl", "use : " << aDeviceInfos[i].maSuggestedVersion); break; } } @@ -541,6 +543,11 @@ bool WinOpenGLDeviceInfo::FindBlocklistedDeviceInList() return match; } +bool WinOpenGLDeviceInfo::FindBlocklistedDeviceInList() +{ + return FindBlocklistedDeviceInList(maDriverInfo, maDriverVersion, maAdapterVendorID, maAdapterDeviceID, mnWindowsVersion); +} + namespace { OUString getCacheFolder() diff --git a/vcl/opengl/win/blocklist_parser.cxx b/vcl/opengl/win/blocklist_parser.cxx index 7a8d01229eb8..119732abe11c 100644 --- a/vcl/opengl/win/blocklist_parser.cxx +++ b/vcl/opengl/win/blocklist_parser.cxx @@ -7,7 +7,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "blocklist_parser.hxx" +#include "opengl/win/blocklist_parser.hxx" WinBlocklistParser::WinBlocklistParser(const OUString& rURL, std::vector& rDriverList) diff --git a/vcl/opengl/win/blocklist_parser.hxx b/vcl/opengl/win/blocklist_parser.hxx deleted file mode 100644 index bc2e2a14baa7..000000000000 --- a/vcl/opengl/win/blocklist_parser.hxx +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- 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 "opengl/win/WinDeviceInfo.hxx" - -#include - -#include - -class InvalidFileException -{ -}; - -class WinBlocklistParser -{ -public: - WinBlocklistParser(const OUString& rURL, std::vector& rDriverList); - void parse(); - -private: - void handleEntry(wgl::DriverInfo& rDriver, xmlreader::XmlReader& rReader); - void handleDevices(wgl::DriverInfo& rDriver, xmlreader::XmlReader& rReader); - void handleList(xmlreader::XmlReader& rReader); - void handleContent(xmlreader::XmlReader& rReader); - - - enum class BlockType - { - WHITELIST, - BLACKLIST, - UNKNOWN - }; - - BlockType meBlockType; - std::vector& mrDriverList; - OUString maURL; -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qa/cppunit/blocklistparsertest.cxx b/vcl/qa/cppunit/blocklistparsertest.cxx new file mode 100644 index 000000000000..66a4f7051651 --- /dev/null +++ b/vcl/qa/cppunit/blocklistparsertest.cxx @@ -0,0 +1,161 @@ +/* -*- 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 + +#include +#include +#include +#include + +#include + +#include "opengl/win/blocklist_parser.hxx" + +namespace +{ + +class BlocklistParserTest : public test::BootstrapFixtureBase +{ + void testParse(); + void testEvaluate(); + + CPPUNIT_TEST_SUITE(BlocklistParserTest); + CPPUNIT_TEST(testParse); + CPPUNIT_TEST(testEvaluate); + CPPUNIT_TEST_SUITE_END(); +}; + +void BlocklistParserTest::testParse() +{ + std::vector aDriveInfos; + + WinBlocklistParser aBlocklistParser(getURLFromSrc("vcl/qa/cppunit/") + "test_blocklist_parse.xml", aDriveInfos); + aBlocklistParser.parse(); + + CPPUNIT_ASSERT_EQUAL(20U, aDriveInfos.size()); + + size_t i = 0; + + for (bool bIsWhitelisted : {true, false}) + { + wgl::DriverInfo& aDriveInfo = aDriveInfos[i++]; + CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted); + CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAll), aDriveInfo.maAdapterVendor); // "all" + CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_LESS_THAN, aDriveInfo.meComparisonOp); + CPPUNIT_ASSERT_EQUAL(wgl::V(10,20,30,40), aDriveInfo.mnDriverVersion); + + aDriveInfo = aDriveInfos[i++]; + CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted); + CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorIntel), aDriveInfo.maAdapterVendor); + CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_LESS_THAN_OR_EQUAL, aDriveInfo.meComparisonOp); + CPPUNIT_ASSERT_EQUAL(wgl::V(11,21,31,41), aDriveInfo.mnDriverVersion); + + aDriveInfo = aDriveInfos[i++]; + CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted); + CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorATI), aDriveInfo.maAdapterVendor); + CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_GREATER_THAN, aDriveInfo.meComparisonOp); + CPPUNIT_ASSERT_EQUAL(wgl::V(12,22,32,42), aDriveInfo.mnDriverVersion); + + aDriveInfo = aDriveInfos[i++]; + CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted); + CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAMD), aDriveInfo.maAdapterVendor); + CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_GREATER_THAN_OR_EQUAL, aDriveInfo.meComparisonOp); + + aDriveInfo = aDriveInfos[i++]; + CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted); + CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorNVIDIA), aDriveInfo.maAdapterVendor); + CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_EQUAL, aDriveInfo.meComparisonOp); + + aDriveInfo = aDriveInfos[i++]; + CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted); + CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorMicrosoft), aDriveInfo.maAdapterVendor); + CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_NOT_EQUAL, aDriveInfo.meComparisonOp); + + aDriveInfo = aDriveInfos[i++]; + CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted); + CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAll), aDriveInfo.maAdapterVendor); + CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_BETWEEN_EXCLUSIVE, aDriveInfo.meComparisonOp); + + aDriveInfo = aDriveInfos[i++]; + CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted); + CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAll), aDriveInfo.maAdapterVendor); + CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_BETWEEN_INCLUSIVE, aDriveInfo.meComparisonOp); + + aDriveInfo = aDriveInfos[i++]; + CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted); + CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAll), aDriveInfo.maAdapterVendor); + CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_BETWEEN_INCLUSIVE_START, aDriveInfo.meComparisonOp); + + aDriveInfo = aDriveInfos[i++]; + CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted); + CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAll), aDriveInfo.maAdapterVendor); + CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_COMPARISON_IGNORED, aDriveInfo.meComparisonOp); + } +} + +void BlocklistParserTest::testEvaluate() +{ + std::vector aDriveInfos; + + WinBlocklistParser aBlocklistParser(getURLFromSrc("vcl/qa/cppunit/") + "test_blocklist_evaluate.xml", aDriveInfos); + aBlocklistParser.parse(); + + OUString vendorAMD = WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAMD); + OUString vendorNVIDIA = WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorNVIDIA); + OUString vendorIntel = WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorIntel); + OUString vendorMicrosoft = WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorMicrosoft); + + uint32_t osWindowsXP = 0x00050001; + uint32_t osWindowsVista = 0x00060000; + uint32_t osWindows7 = 0x00060001; + uint32_t osWindows8 = 0x00060002; + uint32_t osWindows10 = 0x000A0000; + + // Check OS + CPPUNIT_ASSERT_EQUAL(true, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList( + aDriveInfos, "10.20.30.40", vendorNVIDIA, "all", osWindowsXP)); + CPPUNIT_ASSERT_EQUAL(true, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList( + aDriveInfos, "10.20.30.40", vendorNVIDIA, "all", osWindowsVista)); + CPPUNIT_ASSERT_EQUAL(false, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList( + aDriveInfos, "10.20.30.40", vendorNVIDIA, "all", osWindows7)); + CPPUNIT_ASSERT_EQUAL(false, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList( + aDriveInfos, "10.20.30.40", vendorNVIDIA, "all", osWindows8)); + CPPUNIT_ASSERT_EQUAL(false, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList( + aDriveInfos, "10.20.30.40", vendorNVIDIA, "all", osWindows10)); + + + // Check Vendors + CPPUNIT_ASSERT_EQUAL(true, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList( + aDriveInfos, "10.20.30.40", vendorMicrosoft, "all", osWindows7)); + CPPUNIT_ASSERT_EQUAL(true, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList( + aDriveInfos, "10.20.30.40", vendorMicrosoft, "all", osWindows10)); + + // Check Versions + CPPUNIT_ASSERT_EQUAL(true, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList( + aDriveInfos, "10.20.30.39", vendorAMD, "all", osWindows7)); + CPPUNIT_ASSERT_EQUAL(false, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList( + aDriveInfos, "10.20.30.40", vendorAMD, "all", osWindows7)); + CPPUNIT_ASSERT_EQUAL(false, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList( + aDriveInfos, "10.20.30.41", vendorAMD, "all", osWindows7)); + + // Check + CPPUNIT_ASSERT_EQUAL(true, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList( + aDriveInfos, "9.17.10.4229", vendorIntel, "all", osWindows7)); + + +} + +} // namespace + +CPPUNIT_TEST_SUITE_REGISTRATION(BlocklistParserTest); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qa/cppunit/test_blocklist_evaluate.xml b/vcl/qa/cppunit/test_blocklist_evaluate.xml new file mode 100755 index 000000000000..7ffbe3a1b588 --- /dev/null +++ b/vcl/qa/cppunit/test_blocklist_evaluate.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vcl/qa/cppunit/test_blocklist_parse.xml b/vcl/qa/cppunit/test_blocklist_parse.xml new file mode 100755 index 000000000000..65646685aa7d --- /dev/null +++ b/vcl/qa/cppunit/test_blocklist_parse.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit