From dca7aaf7042f765bebba3497b4c3007efbf70a8b Mon Sep 17 00:00:00 2001 From: Damian Pietruchowski Date: Tue, 21 Mar 2017 11:15:39 +0100 Subject: [PATCH] [SmokeTest] Regex match for uninstall in tear down After all tests, apps are uninstalled based on names of directories in globalapps or apps_rw directory. It should avoid trying to uninstall apps like "tmp" or "pkgdid.bck". Change-Id: Iebf0f903c62c250e09ea282ec085a14126a35302 Signed-off-by: Damian Pietruchowski --- src/unit_tests/smoke_utils.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/unit_tests/smoke_utils.cc b/src/unit_tests/smoke_utils.cc index c0ebd16..177bcfa 100644 --- a/src/unit_tests/smoke_utils.cc +++ b/src/unit_tests/smoke_utils.cc @@ -28,6 +28,7 @@ #include #include #include +#include #include "tpk/tpk_app_query_interface.h" @@ -707,10 +708,13 @@ void UninstallAllAppsInDirectory(bf::path dir, bool is_readonly) { bf::directory_iterator(dir), bf::directory_iterator())) { if (dir_entry.path().string().find("smoke") != std::string::npos && bf::is_directory(dir_entry)) { - if (Uninstall(dir_entry.path().filename().string(), is_readonly, - RequestResult::NORMAL) != ci::AppInstaller::Result::OK) { - LOG(ERROR) << "Cannot uninstall smoke test app: " - << dir_entry.path().filename().string(); + std::string package = dir_entry.path().filename().string(); + std::regex pkg_regex("smoke[a-zA-Z]{3,}[1-9]{2,}"); + if (std::regex_match(package, pkg_regex)) { + if (Uninstall(package, is_readonly, RequestResult::NORMAL) != + ci::AppInstaller::Result::OK) { + LOG(ERROR) << "Cannot uninstall smoke test app: " << package; + } } } } -- 2.7.4