From 849628568612d515babc5552365ad30b86142984 Mon Sep 17 00:00:00 2001 From: Derek Sollenberger Date: Fri, 15 Jul 2022 16:20:02 -0400 Subject: [PATCH] Correct CTS SkQP test enforcement criteria. Restrict enforcement of CTS unit tests to only be applied to devices that have a vendor image whose API level is >= when the SkQP unit tests were introduced into CTS. Bug: b/235849228 Bug: b/229804433 Change-Id: Ie69a12dc320a65e4cceb42095dfa26ac38324e0d Reviewed-on: https://skia-review.googlesource.com/c/skia/+/559156 Reviewed-by: Leon Scroggins Commit-Queue: Derek Sollenberger --- tools/skqp/src/skqp.cpp | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/tools/skqp/src/skqp.cpp b/tools/skqp/src/skqp.cpp index 64d88ea9d8..5350e5829f 100644 --- a/tools/skqp/src/skqp.cpp +++ b/tools/skqp/src/skqp.cpp @@ -65,6 +65,15 @@ public: void initialize(SkQPAssetManager* assetManager, sk_sp dat, int enforcedAndroidAPILevel); bool isExcluded(const std::string& name) const { +#if defined(SK_BUILD_FOR_ANDROID) && defined(SK_BUILD_FOR_SKQP) + // Exclude all unit tests from enforcement if ALL the following conditions are true: + // 1) We are building the CTS variant of SkQP (guarded by the SK_BUILD_FOR_SKQP define). + // 2) The enforced Android API level is older than when this test suite was introduced + // into CTS in Android T (API level 33). + if (fEnforcedAndroidAPILevel < 33) { + return true; + } +#endif for (const auto& entry : fEntries) { if (std::regex_match(name, entry.regexPattern)) { return fEnforcedAndroidAPILevel < entry.excludeUntilAndroidAPILevel; @@ -293,13 +302,29 @@ void SkQP::init(SkQPAssetManager* assetManager, const char* reportDirectory) { SkGraphics::Init(); gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr; - int minAndroidAPILevel = 0; -#ifdef SK_BUILD_FOR_ANDROID - char firstAPIVersionStr[PROP_VALUE_MAX]; - int strLength = __system_property_get("ro.product.first_api_level", firstAPIVersionStr); // Defaults to zero since most checks care if it is greater than a specific value. So this will // just default to it being less. - minAndroidAPILevel = (strLength == 0) ? 0 : atoi(firstAPIVersionStr); + int minAndroidAPILevel = 0; +#ifdef SK_BUILD_FOR_ANDROID + // check for the minAPI level based on the order defined in + // docs.partner.android.com/gms/building/integrating/extending-os-upgrade-support-windows + // 1. board's current api level (for boards that have been upgraded by the SoC vendor) + // 2. board's first api level (for devices that initially shipped with an older version) + // 3. product's first api level + // 4. product's current api level + const auto propertyIds = { "ro.board.api_level", + "ro.board.first_api_level", + "ro.product.first_api_level", + "ro.build.version.sdk" }; + + char minAPIVersionStr[PROP_VALUE_MAX]; + for (const char* property : propertyIds) { + int strLength = __system_property_get(property, minAPIVersionStr); + if (strLength != 0) { + minAndroidAPILevel = atoi(minAPIVersionStr); + break; + } + } #endif // Load the exclusion list `skqp/unittests.txt`, if it exists.