summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Huerner <ingo_huerner@mentor.com>2017-05-05 10:01:57 +0200
committerIngo Huerner <ingo_huerner@mentor.com>2017-05-05 10:01:57 +0200
commite90b8c8a5719423ebf83b8cd47123f0a43807b61 (patch)
tree57a2b9cf035868f9b27dae0c0be141003442f56a
parentc1cd0d398ee0c25b5af6e4ff96b9991a1b24959d (diff)
downloadpersistence-common-object-e90b8c8a5719423ebf83b8cd47123f0a43807b61.tar.gz
Removed memset in qhasharr (prevents allocated mamory to be marked as "used").
Added tests for RCT comparing function. Make define PERS_CACHE_MAX_SLOTS configurable using --with-cachemaxslots (default 100.000).
-rw-r--r--configure.ac16
-rw-r--r--src/key-value-store/hashtable/qhasharr.c2
-rw-r--r--src/key-value-store/hashtable/qhasharr.h5
-rw-r--r--test/Makefile.am23
-rw-r--r--test/data/attachToExistingCache.tar.gzbin0 -> 27821 bytes
-rw-r--r--test/data/rct_compare.tar.gzbin0 -> 23131 bytes
-rw-r--r--test/persistence_common_object_test.c115
-rw-r--r--test/test_pco_key_value_store.c374
8 files changed, 528 insertions, 7 deletions
diff --git a/configure.ac b/configure.ac
index ca2cd10..959567c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -90,6 +90,8 @@ PKG_CHECK_MODULES([GIO], [gio-2.0 >= 2.30.0])
PKG_CHECK_MODULES([GIO_UNIX], [gio-unix-2.0 >= 2.30.0])
PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.30.0])
PKG_CHECK_MODULES([DLT], [automotive-dlt >= 2.2.0])
+PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.5])
+PKG_CHECK_MODULES([ARCHIVELIB], [libarchive >= 3.0.4])
dnl *************************************
dnl *** Database support ***
@@ -212,6 +214,20 @@ else
fi
+
+######################################################################
+### max numberr of database slots, default is 100.000
+######################################################################
+AC_ARG_WITH([cachemaxslots],
+ [AS_HELP_STRING([--with-cachemaxslots=numberOfMaxSlots],[NUmber of max db slots])],
+ [with_cachemaxslots=$withval],[with_cachemaxslots=100000])
+
+AC_SUBST([cachemaxslots], [$with_cachemaxslots])
+AC_MSG_NOTICE([Cache Max slots is: $cachemaxslots])
+AC_DEFINE_UNQUOTED(PERS_CACHE_MAX_SLOTS, $cachemaxslots, "max db slots for cache")
+
+
+
dnl *************************************
dnl *** Define extra paths ***
dnl *************************************
diff --git a/src/key-value-store/hashtable/qhasharr.c b/src/key-value-store/hashtable/qhasharr.c
index 4075687..5967b27 100644
--- a/src/key-value-store/hashtable/qhasharr.c
+++ b/src/key-value-store/hashtable/qhasharr.c
@@ -237,7 +237,7 @@ qhasharr_t *qhasharr(void *memory, size_t memsize)
return NULL;
}
// Set memory.
- memset((void *) data, 0, memsize);
+ //memset((void *) data, 0, memsize); // remove memset in order to get all the memory NOT preallocated
data->maxslots = maxslots;
data->usedslots = 0;
data->num = 0;
diff --git a/src/key-value-store/hashtable/qhasharr.h b/src/key-value-store/hashtable/qhasharr.h
index 2c00977..104232f 100644
--- a/src/key-value-store/hashtable/qhasharr.h
+++ b/src/key-value-store/hashtable/qhasharr.h
@@ -53,7 +53,10 @@ extern "C" {
#define _Q_HASHARR_KEYSIZE (128) /*!< knob for maximum key size. */
#define _Q_HASHARR_VALUESIZE (32) /*!< knob for maximum data size in a slot. */
-#define PERS_CACHE_MAX_SLOTS 100000 /**< Max. number of slots in the cache */
+
+//#define PERS_CACHE_MAX_SLOTS 100000 /**< Max. number of slots in the cache */
+// moved the definition of PERS_CACHE_MAX_SLOTS to configure.ac, size can be adjusted via configure step now
+// use --with-cachemaxslots to set the size, default is now 100000
#define PERS_CACHE_MEMSIZE (sizeof(qhasharr_data_t)+ (sizeof(qhasharr_slot_t) * (PERS_CACHE_MAX_SLOTS)))
/* types */
diff --git a/test/Makefile.am b/test/Makefile.am
index 6216cc4..06c2ac4 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -7,10 +7,25 @@ AM_CFLAGS = $(DEPS_CFLAGS) $(CHECK_CFLAGS)
endif
-noinst_PROGRAMS = test_pco_key_value_store
+localstate_DATA = data/attachToExistingCache.tar.gz data/rct_compare.tar.gz
+
+# Add config file to distribution
+EXTRA_DIST = $(localstate_DATA)
+
+noinst_PROGRAMS = test_pco_key_value_store persistence_common_object_test
+#persistence_sqlite_experimental
test_pco_key_value_store_SOURCES = test_pco_key_value_store.c
-test_pco_key_value_store_LDADD = $(DLT_LIBS) $(DEPS_LIBS) $(CHECK_LIBS)\
+test_pco_key_value_store_CFLAGS = $(AM_CFLAGS) $(ARCHIVELIB_CFLAGS) $(ZLIB_CFLAGS)
+test_pco_key_value_store_LDADD = $(DLT_LIBS) $(SQLITE_LIBS) $(DEPS_LIBS) $(CHECK_LIBS) $(ARCHIVELIB_LIBS) $(ZLIB_LIBS) \
$(top_srcdir)/src/libpers_common.la
-
-TESTS=test_pco_key_value_store
+
+
+persistence_common_object_test_SOURCES = persistence_common_object_test.c
+persistence_common_object_test_LDADD = $(DLT_LIBS) $(SQLITE_LIBS) $(DEPS_LIBS) $(CHECK_LIBS)\
+ $(top_srcdir)/src/libpers_common.la
+
+#persistence_sqlite_experimental_SOURCES = persistence_sqlite_experimental.c
+#persistence_sqlite_experimental_LDADD = $(DLT_LIBS) $(SQLITE_LIBS) $(DEPS_LIBS)
+
+TESTS=test_pco_key_value_store persistence_common_object_test
diff --git a/test/data/attachToExistingCache.tar.gz b/test/data/attachToExistingCache.tar.gz
new file mode 100644
index 0000000..1002c89
--- /dev/null
+++ b/test/data/attachToExistingCache.tar.gz
Binary files differ
diff --git a/test/data/rct_compare.tar.gz b/test/data/rct_compare.tar.gz
new file mode 100644
index 0000000..4f5ec2b
--- /dev/null
+++ b/test/data/rct_compare.tar.gz
Binary files differ
diff --git a/test/persistence_common_object_test.c b/test/persistence_common_object_test.c
index 2815744..a1750c1 100644
--- a/test/persistence_common_object_test.c
+++ b/test/persistence_common_object_test.c
@@ -2525,8 +2525,116 @@ END_TEST
+START_TEST(test_CrashTest)
+{
+ X_TEST_REPORT_TEST_NAME("persistence_common_object_test");
+ X_TEST_REPORT_COMP_NAME("libpers_common");
+ X_TEST_REPORT_REFERENCE("NONE");
+ X_TEST_REPORT_DESCRIPTION("Test to see if API could be used to cause a segmentation fault");
+ X_TEST_REPORT_TYPE(GOOD);
+
+ int rval = 0;
+ int handle = 0;
+ int outBufferSize = 10;
+ const char* path = NULL;
+ const char* nullKey = NULL;
+ char* nullData = NULL;
+ int dataSize = 1000;
+ char* outbuffer;
+ char* validData = "This is some test data written into the database";
+
+
+
+ outbuffer = malloc(outBufferSize);
+ memset(outbuffer, 0 , outBufferSize);
+
+
+ // //Cleaning up testdata folder
+ if (remove("/tmp/crash.db") == 0)
+ printf("File %s deleted.\n", "/tmp/crash.db");
+ else
+ fprintf(stderr, "Warning: Could not delete file [%s].\n", "/tmp/crash.db");
+
+
+ rval = persComDbOpen(path, 0);
+ x_fail_unless(rval < 0, "Success persComDbOpen: retval: [%d]", rval);
+ rval = persComDbOpen("/", 0);
+ x_fail_unless(rval < 0, "Success persComDbOpen: retval: [%d]", rval);
+ rval = persComDbOpen(" ", 0);
+ x_fail_unless(rval < 0, "Success persComDbOpen: retval: [%d]", rval);
+ rval = persComDbOpen(" ", -1);
+ x_fail_unless(rval < 0, "Success persComDbOpen: retval: [%d]", rval);
+ rval = persComDbOpen(" ", 100u);
+ x_fail_unless(rval < 0, "Success persComDbOpen: retval: [%d]", rval);
+
+
+ rval = persComDbClose(-1);
+ x_fail_unless(rval < 0, "Success persComDbClose: retval: [%d]", rval);
+
+
+ handle = persComDbOpen("/tmp/crash.db", 1);
+ x_fail_unless(handle >= 0, "Success persComDbOpen: retval: [%d]", handle);
+
+ rval = persComDbWriteKey(handle, nullKey, nullData, dataSize);
+ x_fail_unless(rval < 0, "Success persComDbWriteKey, but should not: retval: [%d]", rval);
+
+ rval = persComDbWriteKey(handle, nullKey, nullData, dataSize);
+ x_fail_unless(rval < 0, "Success persComDbWriteKey, but should not: retval: [%d]", rval);
+
+ rval = persComDbWriteKey(handle, "A_Test_Key", validData, strlen(validData));
+ x_fail_unless(rval >= 0, "Success persComDbWriteKey: retval: [%d]", rval);
+
+ rval = persComDbWriteKey(handle, "A_Test_Key_02", validData, strlen(validData));
+ x_fail_unless(rval >= 0, "Success persComDbWriteKey: retval: [%d]", rval);
+
+ rval = persComDbWriteKey(handle, "A_Test_Key_01", validData, strlen(validData));
+ x_fail_unless(rval >= 0, "Success persComDbWriteKey: retval: [%d]", rval);
+ rval = persComDbWriteKey(handle, "A_Test_Key_03", validData, strlen(validData));
+ x_fail_unless(rval >= 0, "Success persComDbWriteKey: retval: [%d]", rval);
+ rval = persComDbWriteKey(handle, "A_Test_Key_05", validData, strlen(validData));
+ x_fail_unless(rval >= 0, "Success persComDbWriteKey: retval: [%d]", rval);
+
+
+ rval = persComDbReadKey(handle, "A_Test_Key", nullData, 100);
+ x_fail_unless(rval < 0, "Success persComDbReadKey, but should not: retval: [%d]", rval);
+
+ rval = persComDbReadKey(handle, "A_Test_Key", outbuffer, outBufferSize);
+ x_fail_unless(rval < 0, "Success persComDbReadKey, but should not: retval: [%d]", rval);
+
+
+ rval = persComDbGetKeySize(handle, nullKey) ;
+ x_fail_unless(rval < 0, "Success persComDbGetKeySize, but should not: retval: [%d]", rval);
+
+
+
+ rval = persComDbDeleteKey(handle, nullKey);
+ x_fail_unless(rval < 0, "Success persComDbDeleteKey, but should not: retval: [%d]", rval);
+
+
+ rval = persComDbGetSizeKeysList(-1);
+ x_fail_unless(rval < 0, "Success persComDbGetSizeKeysList, but should not: retval: [%d]", rval);
+
+
+
+ rval = persComDbGetSizeKeysList(100);
+ x_fail_unless(rval < 0, "Success persComDbGetSizeKeysList, but should not: retval: [%d]", rval);
+
+
+ rval = persComDbGetKeysList(handle, nullData, 10) ;
+ x_fail_unless(rval < 0, "Success persComDbGetKeysList, but should not: retval: [%d]", rval);
+
+#if 0
+ rval = persComDbGetKeysList(handle, outbuffer, outBufferSize) ;
+ x_fail_unless(rval < 0, "Success persComDbGetKeysList, but should not: retval: [%d]", rval);
+#endif
+ rval = persComDbClose(handle);
+
+ free(outbuffer);
+
+}
+END_TEST
static Suite * persistenceCommonLib_suite()
{
@@ -2602,8 +2710,11 @@ static Suite * persistenceCommonLib_suite()
tcase_add_test(tc_Backups, test_Backups);
tcase_set_timeout(tc_Backups, 5);
+ TCase * tc_CrashTest = tcase_create("BadParameters");
+ tcase_add_test(tc_CrashTest, test_CrashTest);
+ tcase_set_timeout(tc_CrashTest, 5);
-
+#if 1
suite_add_tcase(s, tc_persOpenLocalDB);
suite_add_tcase(s, tc_persOpenRCT);
suite_add_tcase(s, tc_persSetDataLocalDB);
@@ -2622,6 +2733,8 @@ static Suite * persistenceCommonLib_suite()
//suite_add_tcase(s, tc_RemapHashtableHeader);
//suite_add_tcase(s, tc_SupportedChars);
suite_add_tcase(s, tc_BadParameters);
+#endif
+ suite_add_tcase(s, tc_CrashTest);
//suite_add_tcase(s, tc_Backups);
return s;
diff --git a/test/test_pco_key_value_store.c b/test/test_pco_key_value_store.c
index 62b9866..f876eb9 100644
--- a/test/test_pco_key_value_store.c
+++ b/test/test_pco_key_value_store.c
@@ -35,6 +35,11 @@
#include <check.h>
#include <sys/wait.h>
+
+#include <archive.h>
+#include <archive_entry.h>
+
+
#define BUF_SIZE 64
#define NUM_OF_FILES 3
#define READ_SIZE 1024
@@ -3159,6 +3164,227 @@ END_TEST
+static int doCopyData(struct archive *ar, struct archive *aw)
+{
+ int s32Result = ARCHIVE_OK;
+ int s32Size = 0;
+ char buffer[128];
+
+ while( ARCHIVE_OK == s32Result )
+ {
+ s32Size = archive_read_data(ar, buffer, 128);
+ if( 0 > s32Size )
+ {
+ printf("doCopyData - archive_read_data ERR\n");
+ s32Result = ARCHIVE_FAILED;
+ }
+ else
+ {
+ if( 0 < s32Size )
+ {
+ s32Size = archive_write_data(aw, buffer, 128);
+ if( 0 > s32Size )
+ {
+ printf("doCopyData - archive_write_data ERR\n");
+ s32Result = ARCHIVE_FAILED;
+ }
+ }
+ else
+ {
+ /* nothing to copy; */
+ break;
+ }
+ }
+ }
+
+ /* return result; */
+ return s32Result;
+
+}
+
+
+
+static int doUncompress(const char* extractFrom, const char* extractTo)
+{
+ struct archive *psArchive = NULL;
+ struct archive *psExtract = NULL;
+ struct archive_entry *psEntry = NULL;
+ int s32Result = ARCHIVE_OK;
+ int s32Flags = ARCHIVE_EXTRACT_TIME;
+
+ /* select which attributes to restore; */
+ s32Flags |= ARCHIVE_EXTRACT_PERM;
+ s32Flags |= ARCHIVE_EXTRACT_ACL;
+ s32Flags |= ARCHIVE_EXTRACT_FFLAGS;
+ s32Flags |= ARCHIVE_EXTRACT_OWNER;
+
+ if( (NULL == extractFrom) ||
+ (NULL == extractTo) )
+ {
+ s32Result = ARCHIVE_FAILED;
+ printf("doUncompress - invalid parameters\n");
+ }
+
+ if( ARCHIVE_OK == s32Result )
+ {
+ psArchive = archive_read_new();
+ if( NULL == psArchive )
+ {
+ s32Result = ARCHIVE_FAILED;
+ printf("doUncompress - archive_read_new ERR\n");
+ }
+ }
+
+ if( ARCHIVE_OK == s32Result )
+ {
+ archive_read_support_format_all(psArchive);
+ archive_read_support_compression_all(psArchive);
+ psExtract = archive_write_disk_new();
+ s32Result = ((NULL == psExtract) ? ARCHIVE_FAILED : s32Result);
+ archive_write_disk_set_options(psExtract, s32Flags);
+ archive_write_disk_set_standard_lookup(psExtract);
+ }
+
+ if( ARCHIVE_OK == s32Result )
+ {
+ s32Result = archive_read_open_filename(psArchive, extractFrom, 10240);
+ /* exit if s32Result != ARCHIVE_OK; */
+ }
+
+ while( ARCHIVE_OK == s32Result )
+ {
+ s32Result = archive_read_next_header(psArchive, &psEntry);
+ switch( s32Result )
+ {
+ case ARCHIVE_EOF:
+ {
+ /* nothing else to do; */
+ break;
+ }
+ case ARCHIVE_OK:
+ {
+ /* modify entry here to extract to the needed location; */
+ char pstrTemp[512];
+ memset(pstrTemp, 0, sizeof(pstrTemp));
+ snprintf(pstrTemp, sizeof(pstrTemp), "%s%s", extractTo, archive_entry_pathname(psEntry));
+ printf("doUncompress - archive_entry_pathname %s\n", pstrTemp);
+ archive_entry_copy_pathname(psEntry, pstrTemp);
+
+ s32Result = archive_write_header(psExtract, psEntry);
+ if( ARCHIVE_OK == s32Result )
+ {
+ if( archive_entry_size(psEntry) > 0 )
+ {
+ s32Result = doCopyData(psArchive, psExtract);
+ if( ARCHIVE_OK != s32Result )
+ {
+ printf("doUncompress - copy_data ERR %s\n", archive_error_string(psExtract));
+ }
+ /* if( ARCHIVE_WARN > s32Result ) exit; */
+ }
+
+ if( ARCHIVE_OK == s32Result )
+ {
+ s32Result = archive_write_finish_entry(psExtract);
+ if( ARCHIVE_OK != s32Result )
+ {
+ printf("persadmin_uncompress - archive_write_finish_entry ERR %s\n", archive_error_string(psExtract));
+ }
+ /* if( ARCHIVE_WARN > s32Result ) exit; */
+ }
+ }
+ else
+ {
+ printf("doUncompress - archive_write_header ERR %s\n", archive_error_string(psExtract));
+ }
+
+ break;
+ }
+ default:
+ {
+ printf("doUncompress - archive_read_next_header ERR %d\n", s32Result);
+ break;
+ }
+ }
+ }
+
+ /* perform cleaning operations; */
+ if( NULL != psArchive )
+ {
+ archive_read_close(psArchive);
+ archive_read_free(psArchive);
+ }
+ if( NULL != psExtract )
+ {
+ archive_write_close(psExtract);
+ archive_write_free(psExtract);
+ }
+
+ /* overwrite result; */
+ s32Result = (s32Result == ARCHIVE_EOF) ? ARCHIVE_OK : s32Result;
+
+ /* return result; */
+ return s32Result;
+
+}
+
+
+START_TEST(test_Compare_RCT)
+{
+ int result = 0;
+
+ // extract test RCT databases
+ result = doUncompress("/usr/local/var/rct_compare.tar.gz", "/tmp/");
+ fail_unless(result == 0, "Failed to extract test data");
+
+
+
+ // Compare to identical RCT's
+ result = check_for_same_file_content("/tmp/rct_compare/resource-table-cfg.itz",
+ "/tmp/rct_compare/resource-table-cfg_new.itz");
+ fail_unless(result == 1, "Failed: Two identical RCT's are reported to be different");
+
+
+ //Compare completely differernt RCT's
+ result = check_for_same_file_content("/tmp/rct_compare/resource-table-cfg.itz",
+ "/tmp/rct_compare/resource-table-cfg_wrong.itz");
+ fail_unless(result == 0, "Failed: Two different RCT's are reported to identical");
+
+
+ // Compare almost identical RCT's ==> configuration of one key differs
+ result = check_for_same_file_content("/tmp/rct_compare/resource-table-cfg.itz",
+ "/tmp/rct_compare/resource-table-cfg_new_modified.itz");
+ fail_unless(result == 0, "Failed: Two different RCT's are reported to identical");
+
+
+ // Compare an empty RCT with an RCT with some content
+ result = check_for_same_file_content("/tmp/rct_compare/resource-table-cfg_empty.itz",
+ "/tmp/rct_compare/resource-table-cfg_new_modified.itz");
+ fail_unless(result == 0, "Failed: An empty RCT is identicyl to an non empty one");
+
+
+ // Compare two empty RCT's
+ result = check_for_same_file_content("/tmp/rct_compare/resource-table-cfg_empty.itz",
+ "/tmp/rct_compare/resource-table-cfg_empty2.itz");
+ fail_unless(result == 1, "Failed: Two empty RCT's reported to be different");
+
+
+ // Compare RCT with invalid path
+ result = check_for_same_file_content("/tmppppp/rct_compare/resource-table-cfg_empty.itz",
+ "/tmp/rct_compare/resource-table-cfg_new_modified.itz");
+ fail_unless(result == 0, "Failed: A RCT with an invalid path reported to be identical to an existing one");
+
+
+ // Pass NULL string 1
+ result = check_for_same_file_content("/tmp/rct_compare/resource-table-cfg.itz", NULL);
+ fail_unless(result == 0, "Failed: Null pointer in RCT filename reported as identical");
+
+
+ // Pass NULL string 2
+ result = check_for_same_file_content(NULL, "/tmp/rct_compare/resource-table-cfg.itz");
+ fail_unless(result == 0, "Failed: Null pointer in RCT filename reported as identical");
+}
+END_TEST
static Suite* persistenceCommonLib_suite()
{
@@ -3241,7 +3467,10 @@ static Suite* persistenceCommonLib_suite()
tcase_add_test(tc_AddKey_DeleteKey_AddShorterKeyName, test_AddKey_DeleteKey_AddShorterKeyName);
tcase_set_timeout(tc_AddKey_DeleteKey_AddShorterKeyName, 60);
+ TCase* tc_Compare_RCT = tcase_create("Compare_RCT");
+ tcase_add_test(tc_Compare_RCT, test_Compare_RCT);
+#if 1
suite_add_tcase(s, tc_persOpenLocalDB);
tcase_add_checked_fixture(tc_persOpenLocalDB, data_setup, data_teardown);
@@ -3311,6 +3540,11 @@ static Suite* persistenceCommonLib_suite()
suite_add_tcase(s, tc_AddKey_DeleteKey_AddShorterKeyName);
+ suite_add_tcase(s, tc_Compare_RCT);
+#else
+
+#endif
+
return s;
}
@@ -3433,3 +3667,143 @@ int main(int argc, char* argv[])
return (0 == nr_failed) ? EXIT_SUCCESS : EXIT_FAILURE;
}
+
+
+#define MAX_RESOURCE_LIST_ENTRY 512
+
+int check_for_same_file_content(char* file1Path, char* file2Path)
+{
+ int ret = 0;
+ int rval = 1;
+ int handle1 = 0;
+ int handle2 = 0;
+ char* resourceList = NULL;
+ int listSize = 0;
+ PersistenceConfigurationKey_s psConfig1, psConfig2;
+
+ if((NULL == file1Path) || (NULL == file2Path))
+ {
+ return 0;
+ }
+
+ //Open database
+ handle1 = persComRctOpen(file1Path, 0x0);
+ if(handle1 < 0)
+ {
+ return 0;
+ }
+
+ handle2 = persComRctOpen(file2Path, 0x0);
+ if(handle2 < 0)
+ {
+ (void)persComRctClose(handle1);
+ return 0;
+ }
+
+ listSize = persComRctGetSizeResourcesList(handle1);
+ if(listSize != 0)
+ {
+ if(listSize > 0)
+ {
+ resourceList = (char*) malloc(listSize);
+ if(resourceList != NULL)
+ {
+ ret = persComRctGetResourcesList(handle1, resourceList, listSize);
+ if(ret > 0)
+ {
+ int i = 0, idx = 0, numResources = 0, doContinue = 1;
+ int resourceStartIdx[MAX_RESOURCE_LIST_ENTRY] = {0};
+
+ resourceStartIdx[idx] = 0; // initial start
+
+ for(i=1; i<listSize; i++ )
+ {
+ if(resourceList[i] == '\0')
+ {
+ numResources++;
+ resourceStartIdx[++idx] = i+1;
+ if(idx > MAX_RESOURCE_LIST_ENTRY)
+ {
+ doContinue = 0;
+ break;
+ }
+ }
+ }
+
+ if(doContinue == 1)
+ {
+ for(i=0; i<numResources; i++)
+ {
+ memset(psConfig1.custom_name, 0, sizeof(psConfig1.custom_name));
+ memset(psConfig1.customID, 0, sizeof(psConfig1.customID));
+ memset(psConfig1.reponsible, 0, sizeof(psConfig1.reponsible));
+
+ memset(psConfig2.custom_name, 0, sizeof(psConfig2.custom_name));
+ memset(psConfig2.customID, 0, sizeof(psConfig2.customID));
+ memset(psConfig2.reponsible, 0, sizeof(psConfig2.reponsible));
+
+ //printf("RCT content [%d]: %s\n", i, &resourceList[resourceStartIdx[i]]);
+
+ ret = persComRctRead(handle1, &resourceList[resourceStartIdx[i]], &psConfig1);
+ if(ret != sizeof(psConfig1))
+ {
+ break;
+ }
+
+ ret = persComRctRead(handle2, &resourceList[resourceStartIdx[i]], &psConfig2);
+ if(ret != sizeof(psConfig2))
+ {
+ rval = 0;
+ break;
+ }
+
+ if(0 != memcmp(&psConfig1, &psConfig2, sizeof(psConfig1)))
+ {
+ rval = 0;
+ break;
+ }
+ }
+ }
+ else
+ {
+ printf("Num of array entries exceeded\n");
+ rval = 0;
+ }
+ }
+ free(resourceList);
+ }
+ else
+ {
+ rval = 0; // failure
+ }
+ }
+ else
+ {
+ rval = 0; // failure
+ }
+ }
+ else
+ {
+ // empty src database, check if other database is also empty
+ listSize = persComRctGetSizeResourcesList(handle2);
+ if(listSize != 0)
+ {
+ rval = 0; // other database is not empty ==> databases are not identicyl
+ }
+ }
+
+ //Close database
+ ret = persComRctClose(handle1);
+ if (ret != 0)
+ {
+ //DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR), DLT_STRING("Not able to close : "), DLT_STRING(file1Path));
+ }
+
+ ret = persComRctClose(handle2);
+ if (ret != 0)
+ {
+ //DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR), DLT_STRING("Not able to close : "), DLT_STRING(file2Path));
+ }
+
+ return rval;
+}