summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Huerner <ingo_huerner@mentor.com>2017-04-05 10:46:24 +0200
committerIngo Huerner <ingo_huerner@mentor.com>2017-04-05 10:46:24 +0200
commitf852152afc97b0367a7c1c1a5780b08f56fc5ac6 (patch)
tree4bcdc3b4876bc095d6325c61f302b570bec07225
parentdabd117ee5728dfbe3ac3d3dd312cfded0da6048 (diff)
downloadpersistence-client-library-f852152afc97b0367a7c1c1a5780b08f56fc5ac6.tar.gz
Corrected argument type for LifecycleRequestComplete message; extended checkLocalArtefacts function; makeShmName function adjusted
-rw-r--r--src/persistence_client_library.c21
-rw-r--r--src/persistence_client_library_dbus_cmd.c4
-rw-r--r--test/persistence_client_library_test.c81
3 files changed, 89 insertions, 17 deletions
diff --git a/src/persistence_client_library.c b/src/persistence_client_library.c
index e3c0f6e..dbbe424 100644
--- a/src/persistence_client_library.c
+++ b/src/persistence_client_library.c
@@ -55,8 +55,9 @@ static pthread_mutex_t gInitMutex = PTHREAD_MUTEX_INITIALIZER;
/// name of the backup blacklist file (contains all the files which are excluded from backup creation)
static const char* gBackupFilename = "BackupFileList.info";
-
static const char* gNsmAppId = "NodeStateManager";
+static const char* gShmWtNameTemplate = "_Data_mnt_c_%s";
+static const char* gShmCNameTemplate = "_Data_mnt_wt_%s";
static char gAppFolder[PERS_ORG_MAX_LENGTH_PATH_FILENAME] = {0};
@@ -69,6 +70,7 @@ static char gRctFilename[PERS_ORG_MAX_LENGTH_PATH_FILENAME] = {0};
#endif
+
int customAsyncInitClbk(int errcode)
{
//printf("Dummy async init Callback: %d\n", errcode);
@@ -134,11 +136,12 @@ int doAppcheck(void)
char* makeShmName(const char* path)
{
size_t pathLen = strlen(path);
- char* result = (char*) malloc(pathLen + 1); //free happens at lifecycle shutdown
+ char* result = (char*)malloc(pathLen+1); //free happens in checkLocalArtefacts
int i =0;
if(result != NULL)
{
+ memset(result, 0, pathLen+1);
for(i = 0; i < pathLen; i++)
{
if(!isalnum(path[i]))
@@ -150,7 +153,7 @@ char* makeShmName(const char* path)
result[i] = path[i];
}
}
- result[i + 1] = '\0';
+ result[i] = '\0';
}
else
{
@@ -178,7 +181,17 @@ void checkLocalArtefacts(const char* thePath, const char* appName)
{
if(FILE_DIR_NOT_SELF_OR_PARENT(dirent->d_name))
{
- if(strstr(dirent->d_name, name))
+ char shmWtBuffer[128] = {0};
+ char shmCBuffer[128] = {0};
+
+ memset(shmWtBuffer, 0, 128);
+ memset(shmCBuffer, 0, 128);
+
+ snprintf(shmWtBuffer, 128, gShmWtNameTemplate, name);
+ snprintf(shmCBuffer, 128, gShmCNameTemplate, name);
+
+ if( strstr(dirent->d_name, shmWtBuffer)
+ || strstr(dirent->d_name, shmCBuffer) )
{
size_t len = strlen(thePath) + strlen(dirent->d_name)+1;
char* fileName = malloc(len);
diff --git a/src/persistence_client_library_dbus_cmd.c b/src/persistence_client_library_dbus_cmd.c
index 7a1b417..609b421 100644
--- a/src/persistence_client_library_dbus_cmd.c
+++ b/src/persistence_client_library_dbus_cmd.c
@@ -429,8 +429,8 @@ void process_send_lifecycle_request(DBusConnection* conn, unsigned int requestId
"LifecycleRequestComplete"); // method
if(message != NULL)
{
- dbus_message_append_args(message, DBUS_TYPE_INT32, &requestId,
- DBUS_TYPE_INT32, &status, DBUS_TYPE_INVALID);
+ dbus_message_append_args(message, DBUS_TYPE_UINT32, &requestId,
+ DBUS_TYPE_UINT32, &status, DBUS_TYPE_INVALID);
DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("sendLcmRequest: "), DLT_UINT(requestId), DLT_UINT(status) );
if(!dbus_connection_send(conn, message, 0))
diff --git a/test/persistence_client_library_test.c b/test/persistence_client_library_test.c
index ad7ad8a..a89e940 100644
--- a/test/persistence_client_library_test.c
+++ b/test/persistence_client_library_test.c
@@ -1240,19 +1240,40 @@ END_TEST
void* readThread(void* userData)
{
- int ret = 0, i = 0;
+ int ret = 0, i = 0, handleOne = 0, handleTwo = 0, handleThree = 0;
unsigned char buffer[READ_SIZE] = {0};
char threadName[64] = {0};
char* uData = NULL;
uData = (char*)userData;
+ int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+ const char* envVariable = "PERS_CLIENT_LIB_CUSTOM_LOAD";
+
memset(threadName, 0, 64-1);
memcpy(threadName, uData, 64-1);
threadName[64-1] = '\0';
+ setenv(envVariable, "/etc/pclCustomLibConfigFileTest.cfg", 1);
+
+ (void)pclInitLibrary(gTheAppId, shutdownReg);
+
+
pthread_barrier_wait(&gBarrierOne);
usleep(5000);
+ handleOne = pclKeyHandleOpen(PCL_LDBID_LOCAL, "pos/last_satellites", 1, 2);
+ handleTwo = pclKeyHandleOpen(PCL_LDBID_LOCAL, "pos/last_satellites", 2, 3);
+ handleThree = pclKeyHandleOpen(PCL_LDBID_LOCAL, "pos/last_satellites", 3, 4);
+
+ ret = pclKeyHandleWriteData(handleOne, (unsigned char*)"pos/last_satellites_1_2_data", (int)strlen("pos/last_satellites_1_2_data"));
+ fail_unless(ret == (int)strlen("pos/last_satellites_1_2_data"));
+
+ ret = pclKeyHandleWriteData(handleTwo, (unsigned char*)"pos/last_satellites_2_3_data_23", (int)strlen("pos/last_satellites_2_3_data_23"));
+ fail_unless(ret == (int)strlen("pos/last_satellites_2_3_data_23"));
+
+ ret = pclKeyHandleWriteData(handleThree, (unsigned char*)"pos/last_satellites_3_4_data_34_34", (int)strlen("pos/last_satellites_3_4_data_34_34"));
+ fail_unless(ret == (int)strlen("pos/last_satellites_3_4_data_34_34"));
+
for(i=0; i<NUM_OF_READS; i++)
{
/**
@@ -1266,6 +1287,13 @@ void* readThread(void* userData)
fail_unless(ret == strlen("CACHE_ +48 10' 38.95, +8 44' 39.06"));
usleep(3000);
+ memset(buffer, 0, READ_SIZE);
+ ret = pclKeyHandleReadData(handleOne, buffer, READ_SIZE);
+ fail_unless(strncmp((char*)buffer, "pos/last_satellites_1_2_data",
+ strlen((char*)buffer)) == 0, "Buffer not correctly read - pos/last_satellites_1_2_data");
+ fail_unless(ret == strlen("pos/last_satellites_1_2_data"));
+ usleep(3000);
+
/**
* Logical DB ID: PCL_LDBID_LOCAL with user 3 and seat 2
* ==> local USER value (user 3, seat 2)
@@ -1277,6 +1305,7 @@ void* readThread(void* userData)
fail_unless(ret == strlen("WT_ /var/opt/user_manual_climateControl.pdf"));
usleep(2000);
+#if 1
/**
* Logical DB ID: 0x20 with user 4 and seat 0
* ==> shared user value accessible by a group (user 4 and seat 0)
@@ -1287,6 +1316,15 @@ void* readThread(void* userData)
"Buffer not correctly read - address/home_address");
fail_unless(ret == strlen("WT_ 55327 Heimatstadt, Wohnstrasse 31"));
usleep(5000);
+#endif
+
+ memset(buffer, 0, READ_SIZE);
+ ret = pclKeyHandleReadData(handleTwo, buffer, READ_SIZE);
+ fail_unless(strncmp((char*)buffer, "pos/last_satellites_2_3_data_23",
+ strlen((char*)buffer)) == 0, "Buffer not correctly read - pos/last_satellites_2_3_data_23");
+ fail_unless(ret == strlen("pos/last_satellites_2_3_data_23"));
+ usleep(3000);
+
/**
* Logical DB ID: PCL_LDBID_LOCAL with user 0 and seat 0
@@ -1300,6 +1338,7 @@ void* readThread(void* userData)
fail_unless(ret == strlen("WT_ 17"));
usleep(2000);
+#if 1
/**
* Logical DB ID: 0x20 with user 4 and seat 0
* ==> shared user value accessible by A GROUP (user 4 and seat 0)
@@ -1310,8 +1349,23 @@ void* readThread(void* userData)
"Buffer not correctly read - links/last_link");
fail_unless(ret == strlen("CACHE_ /last_exit/queens"));
usleep(3000);
+#endif
+
+ memset(buffer, 0, READ_SIZE);
+ ret = pclKeyHandleReadData(handleThree, buffer, READ_SIZE);
+ fail_unless(strncmp((char*)buffer, "pos/last_satellites_3_4_data_34_34",
+ strlen((char*)buffer)) == 0, "Buffer not correctly read - pos/last_satellites_3_4_data_34_34");
+ fail_unless(ret == strlen("pos/last_satellites_3_4_data_34_34"));
+ usleep(3000);
}
+ (void)pclKeyHandleClose(handleOne);
+ (void)pclKeyHandleClose(handleTwo);
+ (void)pclKeyHandleClose(handleThree);
+
+
+ pclDeinitLibrary();
+
pthread_exit(0);
}
@@ -1499,7 +1553,6 @@ START_TEST(test_NoPluginFunc)
END_TEST
-
static Suite * persistenceClientLib_suite()
{
const char* testSuiteName = "Persistence Client Library (Key-API)";
@@ -1602,6 +1655,7 @@ static Suite * persistenceClientLib_suite()
tcase_add_test(tc_SharedData, test_SharedData);
tcase_set_timeout(tc_SharedData, 10);
+
#ifdef SKIP_MULTITHREADED_TESTS
printf("INFO: Skipping testcase MultiThreadedRead (%p)\n", test_MultiThreadedRead);
printf("INFO: Skipping testcase MultiThreadedWrite (%p)\n", test_MultiThreadedWrite);
@@ -1616,7 +1670,7 @@ static Suite * persistenceClientLib_suite()
#endif
-
+#if 1
suite_add_tcase(s, tc_NoPluginFunc);
suite_add_tcase(s, tc_persSetData);
@@ -1667,14 +1721,6 @@ static Suite * persistenceClientLib_suite()
suite_add_tcase(s, tc_InvalidPluginfConf);
-#ifndef SKIP_MULTITHREADED_TESTS
- suite_add_tcase(s, tc_MultiThreadedRead);
- tcase_add_checked_fixture(tc_MultiThreadedRead, data_setup, data_teardown);
-
- suite_add_tcase(s, tc_MultiThreadedWrite);
- tcase_add_checked_fixture(tc_MultiThreadedWrite, data_setup, data_teardown);
-#endif
-
suite_add_tcase(s, tc_NoRct);
tcase_add_checked_fixture(tc_NoRct, data_setup_norct, data_teardown);
@@ -1683,12 +1729,24 @@ static Suite * persistenceClientLib_suite()
suite_add_tcase(s, tc_SharedData);
tcase_add_checked_fixture(tc_SharedData, data_setup, data_teardown);
+#endif
+
#if USE_APPCHECK
suite_add_tcase(s, tc_ValidApplication);
#endif
+#ifndef SKIP_MULTITHREADED_TESTS
+ suite_add_tcase(s, tc_MultiThreadedRead);
+ tcase_add_checked_fixture(tc_MultiThreadedRead, data_setup, data_teardown);
+
+ suite_add_tcase(s, tc_MultiThreadedWrite);
+ tcase_add_checked_fixture(tc_MultiThreadedWrite, data_setup, data_teardown);
+
+#endif
+
+
#if 0
suite_add_tcase(s, tc_PAS_DbusInterface);
tcase_add_checked_fixture(tc_PAS_DbusInterface, data_setup, data_teardown);
@@ -1699,6 +1757,7 @@ static Suite * persistenceClientLib_suite()
tcase_set_timeout(tc_LC_DbusInterface, 8);
#endif
+
return s;
}