[SmokeTest] Regex match for uninstall in tear down 66/118266/2
authorDamian Pietruchowski <d.pietruchow@samsung.com>
Thu, 9 Mar 2017 14:07:45 +0000 (15:07 +0100)
committerjaekuk lee <juku1999@samsung.com>
Tue, 14 Mar 2017 01:09:05 +0000 (18:09 -0700)
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: If64970a49aa657df759de1173e1f1c96fe7e87ea
Signed-off-by: Damian Pietruchowski <d.pietruchow@samsung.com>
src/unit_tests/smoke_test.cc

index e150b84..d4c0efc 100644 (file)
@@ -32,6 +32,7 @@
 #include <cstdio>
 #include <cstdlib>
 #include <vector>
+#include <regex>
 
 #include "hybrid/hybrid_installer.h"
 #include "wgt/wgt_app_query_interface.h"
@@ -781,11 +782,15 @@ void UninstallAllAppsInDirectory(bf::path dir, bool is_preload) {
         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(), PackageType::WGT,
-            is_preload, 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(dir_entry.path().filename().string(), PackageType::WGT,
+              is_preload, RequestResult::NORMAL) !=
+              ci::AppInstaller::Result::OK) {
+            LOG(ERROR) << "Cannot uninstall smoke test app: "
+                << dir_entry.path().filename().string();
+          }
         }
       }
     }