[SmokeTest] Regex match for uninstall in tear down 96/120096/6
authorDamian Pietruchowski <d.pietruchow@samsung.com>
Tue, 21 Mar 2017 10:15:39 +0000 (11:15 +0100)
committerjongmyeong ko <jongmyeong.ko@samsung.com>
Fri, 26 May 2017 07:17:52 +0000 (07:17 +0000)
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 <d.pietruchow@samsung.com>
src/unit_tests/smoke_utils.cc

index c0ebd1655940ab350e922651d8b3e9303cecc403..177bcfaaad65c24ff050fa055a1f5431eeb10430 100644 (file)
@@ -28,6 +28,7 @@
 #include <cstdio>
 #include <cstdlib>
 #include <functional>
+#include <regex>
 
 #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;
+          }
         }
       }
     }