provisioning: Close database in tests 75/22075/5
authorPhilippe Coval <philippe.coval@osg.samsung.com>
Thu, 24 Aug 2017 10:11:29 +0000 (12:11 +0200)
committerMats Wichmann <mats@linux.com>
Thu, 31 Aug 2017 21:14:39 +0000 (21:14 +0000)
Bug: https://jira.iotivity.org/browse/IOT-2599
Change-Id: Ie49d06287bc6fb3b0ac75c0271af3861c729d436
Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/22075
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Mats Wichmann <mats@linux.com>
resource/csdk/security/provisioning/src/provisioningdatabasemanager.c
resource/provisioning/unittests/OCProvisioningTest.cpp

index 9494ebd..9f5e044 100644 (file)
@@ -833,7 +833,11 @@ OCStackResult PDMClose()
 
     CHECK_PDM_INIT(TAG);
     int res = 0;
-    res = sqlite3_close(g_db);
+    if (g_db)
+    {
+        res = sqlite3_close(g_db);
+        g_db = NULL;
+    }
     PDM_VERIFY_SQLITE_OK(TAG, res, ERROR, OC_STACK_ERROR);
     OIC_LOG_V(DEBUG, TAG, "OUT %s", __func__);
     return OC_STACK_OK;
index 196d9d6..c73f46b 100644 (file)
@@ -27,6 +27,7 @@
 #include <srmutility.h>
 #include <OCProvisioningManager.hpp>
 #include <gtest/gtest.h>
+#include "provisioningdatabasemanager.h"
 
 #define TIMEOUT 5
 
@@ -44,6 +45,7 @@ namespace OCProvisioningTest
     {
         std::string dbPath("");
         EXPECT_EQ(OC_STACK_OK, OCSecure::provisionInit(dbPath));
+        EXPECT_EQ(OC_STACK_OK, PDMClose());
     }
 
     TEST(ProvisionInitTest, TestValidPath)