Add db_util_open negative case
authorHyunjee Kim <hj0426.kim@samsung.com>
Thu, 23 Apr 2020 00:23:05 +0000 (09:23 +0900)
committerHyunjee Kim <hj0426.kim@samsung.com>
Thu, 23 Apr 2020 00:23:39 +0000 (09:23 +0900)
Change-Id: I44ca060768876dc5dea1c58bd2d8d7445730cf60
Signed-off-by: Hyunjee Kim <hj0426.kim@samsung.com>
unittest/db-util_gtest.cc

index d8d3d80..a6ecf20 100644 (file)
@@ -92,6 +92,20 @@ TEST_F(DbUtil, db_util_open_with_options_n2) {
         rc = db_util_open_with_options(pszFilePath, NULL, flags, zVfs);
         ASSERT_NE ( DB_UTIL_OK , rc );
 }
+
+TEST_F(DbUtil, db_util_open_n4) {
+    int rc;
+
+    rc = db_util_open(pszFilePath, &db, nOption);
+    ASSERT_EQ ( DB_UTIL_OK , rc );
+
+       // In case of (geteuid() != 0) && access(pszFilePath, R_OK)
+       system("chmod 000 test.db");
+       setuid(1000);
+
+    rc = db_util_open(pszFilePath, &db, nOption);
+    ASSERT_EQ ( SQLITE_PERM , rc );
+}
 //=======================================================================================