Enhance CynaraTestEnv with operations on service plugins 83/33083/6
authorLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Fri, 2 Jan 2015 19:18:13 +0000 (20:18 +0100)
committerLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Wed, 14 Jan 2015 06:36:51 +0000 (07:36 +0100)
save() and restore() methods were enhanced with saving and restoring
cynara service plugins libraries.

Change-Id: If21707314d4a628db7c9d4034f1d4d7a9e82c55b

tests/cynara-tests/common/cynara_test_commons.cpp
tests/cynara-tests/common/cynara_test_commons.h
tests/cynara-tests/common/cynara_test_env.cpp
tests/cynara-tests/common/cynara_test_env.h

index f500c26..af724da 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@ const std::string DB_DIR(CYNARA_DB_DIR);
 const std::string USER("cynara");
 const std::string LABEL("System");
 const std::string SERVICE("cynara.service");
+const std::string SERVICE_PLUGINS_DIR("/usr/lib/cynara/plugin/service/");
 
 }
 
index d56b6eb..555084a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -35,6 +35,7 @@ extern const std::string DB_DIR;
 extern const std::string USER;
 extern const std::string LABEL;
 extern const std::string SERVICE;
+extern const std::string SERVICE_PLUGINS_DIR;
 
 }
 
index d855c69..7a20291 100644 (file)
@@ -27,7 +27,9 @@ using namespace FileOperations;
 CynaraTestEnv::CynaraTestEnv(const char *dirName)
     : m_dbPresent(false)
 {
-    m_dir = TMP_DIR + "/" + dirName;
+    m_saveDir = TMP_DIR + "/" + dirName;
+    m_dbSaveDir = m_saveDir + "/db";
+    m_pluginsSaveDir = m_saveDir + "/plugins";
 }
 
 CynaraTestEnv::~CynaraTestEnv()
@@ -38,14 +40,20 @@ void CynaraTestEnv::save()
 {
     CynaraMask mask;
 
-    clear(m_dir);
-    removeDirIfExists(m_dir);
+    clear(m_dbSaveDir);
+    removeDirIfExists(m_dbSaveDir);
+    clear(m_pluginsSaveDir);
+    removeDirIfExists(m_pluginsSaveDir);
+    removeDirIfExists(m_saveDir);
 
+    makeDir(m_saveDir);
     m_dbPresent = dirExists(CynaraTestConsts::DB_DIR);
     if (m_dbPresent) {
-        makeDir(m_dir);
-        copyDir(CynaraTestConsts::DB_DIR, m_dir);
+        makeDir(m_dbSaveDir);
+        copyDir(CynaraTestConsts::DB_DIR, m_dbSaveDir);
     }
+    makeDir(m_pluginsSaveDir);
+    copyDir(CynaraTestConsts::SERVICE_PLUGINS_DIR, m_pluginsSaveDir);
 }
 
 void CynaraTestEnv::restore()
@@ -54,10 +62,16 @@ void CynaraTestEnv::restore()
 
     clear(CynaraTestConsts::DB_DIR);
     if (m_dbPresent)
-        copyDir(m_dir, CynaraTestConsts::DB_DIR);
+        copyDir(m_dbSaveDir, CynaraTestConsts::DB_DIR);
     else
         removeDirIfExists(CynaraTestConsts::DB_DIR);
 
-    clear(m_dir);
-    removeDirIfExists(m_dir);
+    clear(CynaraTestConsts::SERVICE_PLUGINS_DIR);
+    copyDir(m_pluginsSaveDir, CynaraTestConsts::SERVICE_PLUGINS_DIR);
+
+    clear(m_dbSaveDir);
+    removeDirIfExists(m_dbSaveDir);
+    clear(m_pluginsSaveDir);
+    removeDirIfExists(m_pluginsSaveDir);
+    removeDirIfExists(m_saveDir);
 }
index a368a61..707e852 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -29,7 +29,9 @@ public:
     void restore();
 
 private:
-    std::string m_dir;
+    std::string m_saveDir;
+    std::string m_dbSaveDir;
+    std::string m_pluginsSaveDir;
     bool m_dbPresent;
 };