Add initialize db function for smoke test 53/210253/4
authorIlho Kim <ilho159.kim@samsung.com>
Wed, 17 Jul 2019 07:53:37 +0000 (16:53 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Thu, 18 Jul 2019 07:02:48 +0000 (16:02 +0900)
After below patch
   https://review.tizen.org/gerrit/#/c/platform/core/appfw/pkgmgr-info/+/207513/
The smoke test requires the process of creatring db for testing.
This is because opening the db with the "SQLITE_OPEN_READWRITE" flag doesn't create a db.

Related changes
   [tpk-backend] https://review.tizen.org/gerrit/#/c/platform/core/appfw/tpk-backend/+/210255/
   [wgt-backend] https://review.tizen.org/gerrit/#/c/platform/core/appfw/wgt-backend/+/210254/

Change-Id: I16161eba7b8b649a7e912891def3b81c1dc6dff6
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
src/unit_tests/common/smoke_utils.cc
src/unit_tests/common/smoke_utils.h

index 5c7db50..1ad087b 100644 (file)
@@ -8,6 +8,7 @@
 #include <gum/gum-user-service.h>
 #include <gum/common/gum-user-types.h>
 #include <manifest_parser/utils/version_number.h>
+#include <pkgmgr_parser_db.h>
 
 #include <boost/filesystem/path.hpp>
 #include <gtest/gtest.h>
@@ -36,9 +37,11 @@ const char kMigrateTestDBName[] = "app2sd_migrate.db";
 // common entries
 const std::vector<std::string> kDBEntries = {
   {".pkgmgr_parser.db"},
-  {".pkgmgr_parser.db-journal"},
+  {".pkgmgr_parser.db-shm"},
+  {".pkgmgr_parser.db-wal"},
   {".pkgmgr_cert.db"},
-  {".pkgmgr_cert.db-journal"},
+  {".pkgmgr_cert.db-shm"},
+  {".pkgmgr_cert.db-wal"},
   {".app2sd.db"},
   {".app2sd.db-journal"},
 };
@@ -834,6 +837,14 @@ bool RestorePath(const bf::path& path) {
   return true;
 }
 
+bool InitTestDB(uid_t test_uid) {
+  if (pkgmgr_parser_create_and_initialize_db(test_uid) < 0) {
+    LOG(ERROR) << "Failed to initialize db for uid : " << test_uid;
+    return false;
+  }
+  return true;
+}
+
 std::vector<bf::path> SetupBackupDirectories(uid_t test_uid) {
   std::vector<bf::path> entries;
   bf::path db_dir = bf::path(tzplatform_getenv(TZ_SYS_DB));
index 3c8dd30..5834426 100644 (file)
@@ -281,6 +281,8 @@ bool BackupPath(const boost::filesystem::path& path);
 
 bool RestorePath(const boost::filesystem::path& path);
 
+bool InitTestDB(uid_t test_uid);
+
 std::vector<boost::filesystem::path> SetupBackupDirectories(uid_t test_uid);
 
 void UninstallAllAppsInDirectory(boost::filesystem::path dir, bool is_preload,