summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Huerner <ingo_huerner@mentor.com>2017-03-07 10:32:32 +0100
committerIngo Huerner <ingo_huerner@mentor.com>2017-03-07 10:32:32 +0100
commit0c7939b0c1725224ff85827a8e44eb1e23dcd40b (patch)
treea79419fc4eceb91d78862f76aee9191a8216561a
parente88cdcdee8aa92d62b6a77ed1e938afb107229f4 (diff)
downloadpersistence-client-library-0c7939b0c1725224ff85827a8e44eb1e23dcd40b.tar.gz
Added pclCustomLibConfigFileTest.cfg.in config file for tests.
Removed in pclCustomLibConfigFile.cfg.in entries for test plugins. Replaced sync call by syncfs (process_prepare_shutdown function). Removed some unnecessary close calls (findings static code analysis tool).
-rw-r--r--Makefile.am3
-rw-r--r--config/pclCustomLibConfigFile.cfg.in7
-rw-r--r--config/pclCustomLibConfigFileTest.cfg.in8
-rw-r--r--configure.ac1
-rw-r--r--src/persistence_client_library.c88
-rw-r--r--src/persistence_client_library_backup_filelist.c35
-rw-r--r--src/persistence_client_library_data_organization.c5
-rw-r--r--src/persistence_client_library_data_organization.h5
-rw-r--r--src/persistence_client_library_dbus_cmd.c3
-rw-r--r--test/Makefile.am9
-rw-r--r--test/persistence_client_library_benchmark.c628
-rw-r--r--test/persistence_client_library_test.c32
-rw-r--r--test/persistence_client_library_test_file.c22
-rw-r--r--tools/persistence_client_tool.c4
14 files changed, 777 insertions, 73 deletions
diff --git a/Makefile.am b/Makefile.am
index 7e1f631..7de20a2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -11,6 +11,7 @@ endif
# Write the config file for customer plugins to the config destination
sysconf_DATA = config/pclCustomLibConfigFile.cfg \
+ config/pclCustomLibConfigFileTest.cfg \
config/pclCustomLibConfigFileEmpty.cfg \
config/pclCustomLibConfigFileWrongDefault.cfg
@@ -22,5 +23,5 @@ pkgconfig_DATA=persistence_client_library.pc
MAINTAINERCLEANFILES = \
Makefile.in aclocal.m4 compile config.guess config.h.in config.sub \
- configure depcomp install-sh ltmain.sh persistence_client_library.pc config/pclCustomLibConfigFile.cfg \
+ configure depcomp install-sh ltmain.sh persistence_client_library.pc config/pclCustomLibConfigFile.cfg config/pclCustomLibConfigFileTest.cfg\
config/pclCustomLibConfigFileEmpty.cfg config/pclCustomLibConfigFileWrongDefault.cfg config.h.in~ Makefile missing
diff --git a/config/pclCustomLibConfigFile.cfg.in b/config/pclCustomLibConfigFile.cfg.in
index 185cab4..56e949b 100644
--- a/config/pclCustomLibConfigFile.cfg.in
+++ b/config/pclCustomLibConfigFile.cfg.in
@@ -1,8 +1 @@
-hwinfo @prefix@/lib/libhwinfoperscustom.so init async
-secure @prefix@/lib/libsecureperscustom.so od sync
-custom3 @prefix@/lib/libcustom3perscustom.so init sync
default @prefix@/lib/libpers_common.so init sync
-emergency @prefix@/lib/libemergencyperscustom.so od async
-early @prefix@/lib/libearlyperscustom.so od sync
-anInvalidEntry /wrongPath/wrongLib do cnys
-custom2 @prefix@/lib/libcustom2perscustom.so init sync
diff --git a/config/pclCustomLibConfigFileTest.cfg.in b/config/pclCustomLibConfigFileTest.cfg.in
new file mode 100644
index 0000000..185cab4
--- /dev/null
+++ b/config/pclCustomLibConfigFileTest.cfg.in
@@ -0,0 +1,8 @@
+hwinfo @prefix@/lib/libhwinfoperscustom.so init async
+secure @prefix@/lib/libsecureperscustom.so od sync
+custom3 @prefix@/lib/libcustom3perscustom.so init sync
+default @prefix@/lib/libpers_common.so init sync
+emergency @prefix@/lib/libemergencyperscustom.so od async
+early @prefix@/lib/libearlyperscustom.so od sync
+anInvalidEntry /wrongPath/wrongLib do cnys
+custom2 @prefix@/lib/libcustom2perscustom.so init sync
diff --git a/configure.ac b/configure.ac
index 7747d0f..af74151 100644
--- a/configure.ac
+++ b/configure.ac
@@ -206,6 +206,7 @@ AM_CONDITIONAL(DEBUG, test x"$debug" = x"true")
AC_CONFIG_FILES([Makefile
persistence_client_library.pc
config/pclCustomLibConfigFile.cfg
+ config/pclCustomLibConfigFileTest.cfg
config/pclCustomLibConfigFileEmpty.cfg
config/pclCustomLibConfigFileWrongDefault.cfg
src/Makefile
diff --git a/src/persistence_client_library.c b/src/persistence_client_library.c
index 1b1b551..f64a5bd 100644
--- a/src/persistence_client_library.c
+++ b/src/persistence_client_library.c
@@ -54,11 +54,19 @@ static int gCancelCounter = 0;
static pthread_mutex_t gInitMutex = PTHREAD_MUTEX_INITIALIZER;
/// name of the backup blacklist file (contains all the files which are excluded from backup creation)
-const char* gBackupFilename = "BackupFileList.info";
+static const char* gBackupFilename = "BackupFileList.info";
+
+static const char* gNsmAppId = "NodeStateManager";
+
+static char gAppFolder[PERS_ORG_MAX_LENGTH_PATH_FILENAME] = {0};
+
#if USE_APPCHECK
/// global flag
static int gAppCheckFlag = -1;
+
+static char gRctFilename[PERS_ORG_MAX_LENGTH_PATH_FILENAME] = {0};
+
#endif
int customAsyncInitClbk(int errcode)
@@ -80,11 +88,11 @@ static int private_pclDeinitLibrary(void);
#if USE_APPCHECK
static void doInitAppcheck(const char* appName)
{
+ // no need for NULL ptr check for appName, already done in calling function
- char rctFilename[PERS_ORG_MAX_LENGTH_PATH_FILENAME] = {0};
- snprintf(rctFilename, PERS_ORG_MAX_LENGTH_PATH_FILENAME, getLocalWtPathKey(), appName, plugin_gResTableCfg);
+ snprintf(gRctFilename, PERS_ORG_MAX_LENGTH_PATH_FILENAME, getLocalWtPathKey(), appName, plugin_gResTableCfg);
- if(access(rctFilename, F_OK) == 0)
+ if(access(gRctFilename, F_OK) == 0)
{
gAppCheckFlag = 1; // "trusted" application
DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("initLibrary - app check: "), DLT_STRING(appName), DLT_STRING("trusted app"));
@@ -105,9 +113,7 @@ int doAppcheck(void)
if(gAppCheckFlag != 1)
{
- char rctFilename[PERS_ORG_MAX_LENGTH_PATH_FILENAME] = {0};
- snprintf(rctFilename, PERS_ORG_MAX_LENGTH_PATH_FILENAME, getLocalWtPathKey(), gAppId, plugin_gResTableCfg);
- if(access(rctFilename, F_OK) == 0)
+ if(access(gRctFilename, F_OK) == 0)
{
gAppCheckFlag = 1; // "trusted" application
}
@@ -204,26 +210,35 @@ int pclInitLibrary(const char* appName, int shutdownMode)
int lock = pthread_mutex_lock(&gInitMutex);
if(lock == 0)
{
- if(gPclInitCounter == 0)
+ if(appName != NULL)
{
- DLT_REGISTER_CONTEXT(gPclDLTContext,"PCL","Ctx for PCL Logging");
+ if(gPclInitCounter == 0)
+ {
+ DLT_REGISTER_CONTEXT(gPclDLTContext,"PCL","Ctx for PCL Logging");
- DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("pclInitLibrary => App:"), DLT_STRING(appName),
- DLT_STRING("- init counter: "), DLT_UINT(gPclInitCounter) );
+ DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("pclInitLibrary => App:"), DLT_STRING(appName),
+ DLT_STRING("- init counter: "), DLT_UINT(gPclInitCounter) );
- // do check if there are remaining shared memory and semaphores for local app
- checkLocalArtefacts("/dev/shm/", appName);
- //checkGroupArtefacts("/dev/shm", "group_");
+ // do check if there are remaining shared memory and semaphores for local app
+ checkLocalArtefacts("/dev/shm/", appName);
+ //checkGroupArtefacts("/dev/shm", "group_");
- rval = private_pclInitLibrary(appName, shutdownMode);
+ rval = private_pclInitLibrary(appName, shutdownMode);
+ }
+ else
+ {
+ DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("pclInitLibrary - App:"), DLT_STRING(gAppId),
+ DLT_STRING("- ONLY INCREMENT init counter: "), DLT_UINT(gPclInitCounter) );
+ }
+
+ gPclInitCounter++; // increment after private init, otherwise atomic access is too early
}
else
{
- DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("pclInitLibrary - App:"), DLT_STRING(gAppId),
- DLT_STRING("- ONLY INCREMENT init counter: "), DLT_UINT(gPclInitCounter) );
+ DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("pclInitLibrary - appName NULL"));
+ rval = EPERS_COMMON;
}
- gPclInitCounter++; // increment after private init, otherwise atomic access is too early
pthread_mutex_unlock(&gInitMutex);
}
else
@@ -236,16 +251,36 @@ int pclInitLibrary(const char* appName, int shutdownMode)
static int private_pclInitLibrary(const char* appName, int shutdownMode)
{
+ // no need for NULL ptr check for appName, already done in calling function
+
int rval = 1;
- char blacklistPath[PERS_ORG_MAX_LENGTH_PATH_FILENAME] = {0};
+ char blacklistPath[PERS_ORG_MAX_LENGTH_PATH_FILENAME] = {0};
gShutdownMode = shutdownMode;
-#if USE_APPCHECK
- doInitAppcheck(appName); // check if we have a trusted application
-#endif
+ strncpy(gAppId, appName, PERS_RCT_MAX_LENGTH_RESPONSIBLE); // assign application name
+ gAppId[PERS_RCT_MAX_LENGTH_RESPONSIBLE-1] = '\0';
+ if(strcmp(appName, gNsmAppId) != 0) // check for NodeStateManager
+ {
+ // get and fd to the app folder, needed to call syncfs when cmd CMD_LC_PREPARE_SHUTDOWN is called
+ // (commit buffer cache to disk)
+ // only if not NSM ==> if NSM ha an handle to the folder, it may interfere with PAS installation sequence
+ memset(gAppFolder, 0, PERS_ORG_MAX_LENGTH_PATH_FILENAME-1);
+ snprintf(gAppFolder, PERS_ORG_MAX_LENGTH_PATH_FILENAME, "/Data/mnt-c/%s/", appName);
+ gAppFolder[PERS_ORG_MAX_LENGTH_PATH_FILENAME-1] = '\0';
+
+ gSyncFd = open(gAppFolder, O_RDONLY);
+ if(gSyncFd == -1)
+ {
+ DLT_LOG(gPclDLTContext, DLT_LOG_WARN, DLT_STRING("Failed to open syncfd:"), DLT_STRING(strerror(errno)));
+ }
+ }
+ else
+ {
+ gIsNodeStateManager = 1;
+ }
#if USE_FILECACHE
DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("Using the filecache!!!"));
@@ -266,7 +301,6 @@ static int private_pclInitLibrary(const char* appName, int shutdownMode)
return EPERS_DBUS_MAINLOOP;
}
-
if(gShutdownMode != PCL_SHUTDOWN_TYPE_NONE)
{
if(register_lifecycle(shutdownMode) == -1) // register for lifecycle dbus messages
@@ -297,8 +331,9 @@ static int private_pclInitLibrary(const char* appName, int shutdownMode)
init_key_handle_array();
- strncpy(gAppId, appName, PERS_RCT_MAX_LENGTH_RESPONSIBLE); // assign application name
- gAppId[PERS_RCT_MAX_LENGTH_RESPONSIBLE-1] = '\0';
+#if USE_APPCHECK
+ doInitAppcheck(appName); // check if we have a trusted application
+#endif
pers_unlock_access();
@@ -392,6 +427,9 @@ static int private_pclDeinitLibrary(void)
pfcDeinitCache();
#endif
+ if(gIsNodeStateManager == 0)
+ close(gSyncFd);
+
return rval;
}
diff --git a/src/persistence_client_library_backup_filelist.c b/src/persistence_client_library_backup_filelist.c
index 0896dc5..19cd22a 100644
--- a/src/persistence_client_library_backup_filelist.c
+++ b/src/persistence_client_library_backup_filelist.c
@@ -239,6 +239,11 @@ int pclCreateFile(const char* path, int chached)
char thePath[PERS_ORG_MAX_LENGTH_PATH_FILENAME] = {0};
int numTokens = 0, i = 0, validPath = 1, handle = -1;
+ if (path == NULL)
+ {
+ return handle;
+ }
+
strncpy(thePath, path, PERS_ORG_MAX_LENGTH_PATH_FILENAME);
thePath[PERS_ORG_MAX_LENGTH_PATH_FILENAME-1] = '\0'; // Ensures 0-Termination
@@ -348,26 +353,20 @@ int pclVerifyConsistency(const char* origPath, const char* backupPath, const cha
}
// else case: checksum matches ==> keep original file ==> nothing to do
}
- else
- {
- close(handle);
- handle = -1; // error: file corrupt
- }
}
}
close(fdCsum);
}
else
{
- close(fdCsum);
handle = -1; // error: file corrupt
}
+ close(fdBackup);
}
else
{
handle = -1;
}
- close(fdBackup);
}
// *************************************************
// there is ONLY a checksum file
@@ -398,11 +397,6 @@ int pclVerifyConsistency(const char* origPath, const char* backupPath, const cha
}
// else case: checksum matches ==> keep original file ==> nothing to do
}
- else
- {
- close(handle);
- handle = -1; // error: file corrupt
- }
}
else
{
@@ -430,20 +424,15 @@ int pclVerifyConsistency(const char* origPath, const char* backupPath, const cha
if(strcmp(backCsumBuf, origCsumBuf) != 0)
{
- close(handle);
handle = -1; // checksum does NOT match ==> error: file corrupt
}
// else case: checksum matches ==> keep original file ==> nothing to do
- }
- else
- {
close(handle);
- handle = -1; // error: file corrupt
}
+ close(fdBackup);
}
else
{
- close(fdBackup);
handle = -1; // error: file corrupt
}
}
@@ -482,6 +471,11 @@ int pclCreateBackup(const char* dstPath, int srcfd, const char* csumPath, const
{
int dstFd = 0, csfd = 0, readSize = -1;
+ if ((dstPath == NULL) || (csumPath == NULL))
+ {
+ return readSize;
+ }
+
if(access(dstPath, F_OK) != 0)
{
int handle = -1;
@@ -491,7 +485,10 @@ int pclCreateBackup(const char* dstPath, int srcfd, const char* csumPath, const
pathToCreate[PERS_ORG_MAX_LENGTH_PATH_FILENAME-1] = '\0'; // Ensures 0-Termination
handle = pclCreateFile(pathToCreate, 0);
- close(handle); // don't need the open file
+ if (handle != -1)
+ {
+ close(handle); // don't need the open file
+ }
}
// create checksum file and and write checksum
diff --git a/src/persistence_client_library_data_organization.c b/src/persistence_client_library_data_organization.c
index db26ef5..7fd9ace 100644
--- a/src/persistence_client_library_data_organization.c
+++ b/src/persistence_client_library_data_organization.c
@@ -30,6 +30,11 @@ unsigned int gPclInitCounter = 0;
/// flag to indicate if PCL has registered to PAS
int gPasRegistered = 0;
+int gSyncFd = -1;
+
+int gIsNodeStateManager = 0;
+
+
int(* gChangeNotifyCallback)(pclNotification_s * notifyStruct);
/// character lookup table used for parsing configuration files
diff --git a/src/persistence_client_library_data_organization.h b/src/persistence_client_library_data_organization.h
index 429b77a..e83023d 100644
--- a/src/persistence_client_library_data_organization.h
+++ b/src/persistence_client_library_data_organization.h
@@ -267,6 +267,11 @@ const char* getSharedPublicWtPathKey(void);
*/
const char* getLocalCacheFilePath(void);
+/// file descriptor used to call syncfs to commit buffer cache to disk
+extern int gSyncFd;
+
+/// flag to didicate if the lib is used by the NodeStateManager (appid)
+extern int gIsNodeStateManager;
/// application id
diff --git a/src/persistence_client_library_dbus_cmd.c b/src/persistence_client_library_dbus_cmd.c
index 18b5f74..7c881df 100644
--- a/src/persistence_client_library_dbus_cmd.c
+++ b/src/persistence_client_library_dbus_cmd.c
@@ -249,7 +249,8 @@ void process_prepare_shutdown(unsigned int complete)
}
}
- sync(); // finally make sure data will be written back to the memory device.s
+ if(gIsNodeStateManager == 0)
+ syncfs(gSyncFd); // finally make sure to commit buffer cache to disk
}
diff --git a/test/Makefile.am b/test/Makefile.am
index 4328697..477532f 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -10,10 +10,11 @@ endif
noinst_PROGRAMS = persistence_client_library_test \
persistence_client_library_test_file \
- persistence_client_library_dbus_test
+ persistence_client_library_dbus_test \
+ persistence_client_library_benchmark
persistence_client_library_dbus_test_SOURCES = persistence_client_library_dbus_test.c
-persistence_client_library_dbus_test_LDADD = $(DEPS_LIBS) \
+persistence_client_library_dbus_test_LDADD = $(DEPS_LIBS) \
$(top_builddir)/src/libpersistence_client_library.la
persistence_client_library_test_SOURCES = persistence_client_library_test.c
@@ -24,6 +25,10 @@ persistence_client_library_test_file_SOURCES = persistence_client_library_test_f
persistence_client_library_test_file_LDADD = $(DEPS_LIBS) $(CHECK_LIBS) \
$(top_builddir)/src/libpersistence_client_library.la
+persistence_client_library_benchmark_SOURCES = persistence_client_library_benchmark.c
+persistence_client_library_benchmark_LDADD = $(DEPS_LIBS) $(CHECK_LIBS) \
+ $(top_builddir)/src/libpersistence_client_library.la
+
TESTS=persistence_client_library_test persistence_client_library_test_file
diff --git a/test/persistence_client_library_benchmark.c b/test/persistence_client_library_benchmark.c
new file mode 100644
index 0000000..3c48469
--- /dev/null
+++ b/test/persistence_client_library_benchmark.c
@@ -0,0 +1,628 @@
+/******************************************************************************
+ * Project Persistency
+ * (c) copyright 2014
+ * Company XS Embedded GmbH
+ *****************************************************************************/
+/******************************************************************************
+ * This Source Code Form is subject to the terms of the
+ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
+ * with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+******************************************************************************/
+ /**
+ * @file persistence_client_library_benchmark.c
+ * @ingroup Persistence client library benchmark
+ * @author Ingo Huerner
+ * @brief Benchmark of persistence client library
+ * @see
+ */
+
+#include "../include/persistence_client_library_key.h"
+#include "../include/persistence_client_library_file.h"
+#include "../include/persistence_client_library_error_def.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h> /* atoi */
+
+#include <dlt.h>
+#include <dlt_common.h>
+
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <pthread.h>
+
+
+#define SECONDS2NANO 1000000000L
+#define NANO2MIL 1000000L
+#define MIL2SEC 1000L
+
+#define BUFFER_SIZE 2048
+
+// define for the used clock: "CLOCK_MONOTONIC" or "CLOCK_REALTIME"
+#define CLOCK_ID CLOCK_MONOTONIC
+
+const char* gAppName = "lt-persistence_client_library_test";
+
+extern const char* gWriteBuffer;
+extern const char* gWriteBuffer2;
+
+
+double gDurationMsWrite = 0, gSizeMbWrite = 0;
+double gAverageBytesWrite = 0, gAverageTimeWrite = 0;
+double gAverageBytesWriteSecond = 0, gAverageTimeWriteSecond = 0;
+double gDurationRead = 0, gSizeRead = 0;
+double gDurationReadSecond = 0, gSizeReadSecond = 0;
+double gDurationInit = 0, gDurationDeinit = 0;
+
+
+inline long long getNsDuration(struct timespec* start, struct timespec* end)
+{
+ return ((end->tv_sec * SECONDS2NANO) + end->tv_nsec) - ((start->tv_sec * SECONDS2NANO) + start->tv_nsec);
+}
+
+
+inline long getMsDuration(struct timespec* start, struct timespec* end)
+{
+ return (((end->tv_sec * SECONDS2NANO) + end->tv_nsec) - ((start->tv_sec * SECONDS2NANO) + start->tv_nsec))/NANO2MIL;
+}
+
+
+
+void init_benchmark(int numLoops)
+{
+ int i = 0;
+ long durationInit = 0;
+ long durationDeInit = 0;
+ struct timespec initStart, initEnd;
+ struct timespec deInitStart, deInitEnd;
+ int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+
+ for(i=0; i<numLoops; i++)
+ {
+ // init
+ clock_gettime(CLOCK_ID, &initStart);
+ (void)pclInitLibrary(gAppName , shutdownReg);
+ clock_gettime(CLOCK_ID, &initEnd);
+ durationInit += getNsDuration(&initStart, &initEnd);
+
+ // deinit
+ clock_gettime(CLOCK_ID, &deInitStart);
+ (void)pclDeinitLibrary();
+ clock_gettime(CLOCK_ID, &deInitEnd);
+ durationDeInit += getNsDuration(&deInitStart, &deInitEnd);
+ }
+
+ gDurationInit = (double)durationInit/(double)numLoops/(double)NANO2MIL;
+ gDurationDeinit = (double)durationDeInit/(double)numLoops/(double)NANO2MIL;
+}
+
+
+
+void read_benchmark(int numLoops)
+{
+ int ret = 0, i = 0;
+ long duration = 0, size = 0;
+ struct timespec readStart, readEnd;
+ char key[128] = { 0 };
+ unsigned char buffer[7168] = {0}; // 7kB
+ int shutdownReg = PCL_SHUTDOWN_TYPE_NONE;
+
+ (void)pclInitLibrary(gAppName , shutdownReg);
+
+ //
+ // populate data
+ //
+ for(i=0; i<numLoops; i++)
+ {
+ memset(key, 0, 128);
+ snprintf(key, 128, "pos/last_position_w_bench%d",i);
+
+ if(i%2)
+ {
+ ret = pclKeyWriteData(PCL_LDBID_LOCAL, key, 10, 10, (unsigned char*)gWriteBuffer, (int)strlen(gWriteBuffer) );
+ }
+ else
+ {
+ ret = pclKeyWriteData(PCL_LDBID_LOCAL, key, 10, 10, (unsigned char*)gWriteBuffer2, (int)strlen(gWriteBuffer2) );
+ }
+ }
+ pclLifecycleSet(PCL_SHUTDOWN);
+ (void)pclDeinitLibrary();
+
+
+ //
+ // read data
+ //
+ (void)pclInitLibrary(gAppName , shutdownReg);
+
+ duration = 0;
+ memset(buffer, 0, 7168);
+ size = 0;
+
+ for(i=0; i<numLoops; i++)
+ {
+ memset(key, 0, 128);
+
+ snprintf(key, 128, "pos/last_position_w_bench%d",i);
+
+ clock_gettime(CLOCK_ID, &readStart);
+ ret = pclKeyReadData(PCL_LDBID_LOCAL, key, 10, 10, buffer, 7168);
+ clock_gettime(CLOCK_ID, &readEnd);
+
+ size += ret;
+ duration += getNsDuration(&readStart, &readEnd);
+
+ memset(buffer, 0, 7168);
+ }
+
+ pclLifecycleSet(PCL_SHUTDOWN);
+ (void)pclDeinitLibrary();
+
+ gDurationRead = (double)duration/(double)numLoops;
+ gSizeRead = (double)size/(double)numLoops/(double)1024;
+}
+
+
+void write_benchmark(int numLoops)
+{
+ int ret = 0, i = 0;
+ long duration = 0, size = 0;
+ struct timespec readStart, readEnd;
+ char key[128] = { 0 };
+ unsigned char buffer[7168] = {0}; // 7kB
+
+ int shutdownReg = PCL_SHUTDOWN_TYPE_NONE;
+
+ (void)pclInitLibrary(gAppName , shutdownReg);
+
+ duration = 0;
+ memset(buffer, 0, 7168);
+ size = 0;
+
+ // write the first time to the data
+ for(i=0; i <numLoops; i++)
+ {
+ memset(key, 0, 128);
+ snprintf(key, 128, "pos/last_position_w_bench%d",i);
+
+ if(i%2)
+ {
+ clock_gettime(CLOCK_ID, &readStart);
+ ret = pclKeyWriteData(PCL_LDBID_LOCAL, key, 20, 20, (unsigned char*)gWriteBuffer, (int)strlen(gWriteBuffer) );
+ clock_gettime(CLOCK_ID, &readEnd);
+ }
+ else
+ {
+ clock_gettime(CLOCK_ID, &readStart);
+ ret = pclKeyWriteData(PCL_LDBID_LOCAL, key, 20, 20, (unsigned char*)gWriteBuffer2, (int)strlen(gWriteBuffer2));
+ clock_gettime(CLOCK_ID, &readEnd);
+ }
+
+ size += ret;
+ duration += getNsDuration(&readStart, &readEnd);
+
+ memset(buffer, 0, 7168);
+ }
+ gAverageBytesWrite = (double)size/(double)numLoops/(double)1024;
+ gAverageTimeWrite = (double)duration/(double)numLoops;
+
+
+ // write the second time to the data
+ duration = 0;
+ size = 0;
+ for(i=0; i <numLoops; i++)
+ {
+ memset(key, 0, 128);
+ snprintf(key, 128, "pos/last_position_w_bench%d",i);
+
+ if(i%2)
+ {
+ clock_gettime(CLOCK_ID, &readStart);
+ ret = pclKeyWriteData(PCL_LDBID_LOCAL, key, 20, 20, (unsigned char*)gWriteBuffer2, (int)strlen(gWriteBuffer2) );
+ clock_gettime(CLOCK_ID, &readEnd);
+ }
+ else
+ {
+ clock_gettime(CLOCK_ID, &readStart);
+ ret = pclKeyWriteData(PCL_LDBID_LOCAL, key, 20, 20, (unsigned char*)gWriteBuffer, (int)strlen(gWriteBuffer));
+ clock_gettime(CLOCK_ID, &readEnd);
+ }
+
+ size += ret;
+ duration += getNsDuration(&readStart, &readEnd);
+
+ memset(buffer, 0, 7168);
+ }
+ gAverageBytesWriteSecond = (double)size/(double)numLoops/(double)1024;
+ gAverageTimeWriteSecond = (double)duration/(double)numLoops;
+
+
+ // measure the write back time
+ duration = 0;
+
+ clock_gettime(CLOCK_ID, &readStart);
+ pclLifecycleSet(PCL_SHUTDOWN);
+ clock_gettime(CLOCK_ID, &readEnd);
+
+ duration = getNsDuration(&readStart, &readEnd);
+ gDurationMsWrite = (double)duration/(double)NANO2MIL;
+ // B to kB - kB to MB
+ gSizeMbWrite = (double)size/(double)1024/(double)1024;
+
+
+ (void)pclDeinitLibrary();
+}
+
+
+
+void printAppManual()
+{
+ printf("\n\n==================================================================================\n");
+ printf("NAME\n");
+ printf(" ./persistence_client_library_benchmark - run PCL benchmarks");
+
+ printf("\nSYNOPSIS\n");
+ printf(" persistence_client_library_benchmark [-l loop] [-irwh]\n");
+
+ printf("\nDESCRIPTION\n");
+ printf(" Run persistence client library benchmarks.\n");
+ printf(" If no option is passed, all benchmarks are run with default (1024) number of loops.\n");
+
+ printf("\nOPTIONS\n");
+ printf(" -l number of loops for each test (init benchmark is bound to 10 loops)\n");
+ printf(" -i Run init/deinit benchmarks\n");
+ printf(" -r Run read benchmarks\n");
+ printf(" -w Run write benchmarks\n");
+ printf(" -h Display this help\n");
+ printf("==================================================================================\n");
+}
+
+
+
+int main(int argc, char *argv[])
+{
+ int ret = 0;
+
+ int numLoops = 1024; // number of default loops
+ long long resolution = 0;
+
+ struct timespec clockRes;
+
+ int opt = 0, doInit = 0, doRead = 0, doWrite = 0, printManual = 0;
+
+ const char* envVariable = "PERS_CLIENT_LIB_CUSTOM_LOAD";
+
+ setenv(envVariable, "/etc/pclCustomLibConfigFileTest.cfg", 1);
+
+ if(argc <= 1)
+ {
+ // if no parameter, run all tests with default loops
+ doInit = 1;
+ doRead = 1;
+ doWrite = 1;
+ printManual = 1;
+ }
+
+
+ while ((opt = getopt(argc, argv, "l:irwh")) != -1)
+ {
+ switch (opt)
+ {
+ case 'l':
+ numLoops = atoi(optarg);
+ break;
+ case 'i':
+ doInit = 1;
+ break;
+ case 'r':
+ doRead = 1;
+ break;
+ case 'w':
+ doWrite = 1;
+ break;
+ case 'h':
+ printManual = 1;
+ break;
+ }
+ }
+
+ /// debug log and trace (DLT) setup
+ DLT_REGISTER_APP("PCLb","tests the persistence client library");
+
+ clock_getres(CLOCK_ID, &clockRes);
+ resolution = ((clockRes.tv_sec * SECONDS2NANO) + clockRes.tv_nsec);
+
+ //
+ // run benchmarks
+ //
+
+ if(doInit == 1)
+ init_benchmark(10); // static number of loops, otherwise it takes to long
+
+ if(doRead == 1)
+ read_benchmark(numLoops);
+
+ if(doWrite == 1)
+ write_benchmark(numLoops);
+
+
+ if(printManual == 1)
+ {
+ printAppManual();
+ }
+
+ printf("\n\n==================================================================================\n");
+ printf(" PCL benchmark - num loop: %d - clock resolution: %f\n", numLoops, (double)((double)resolution));
+ printf("==================================================================================\n");
+ if(doInit == 1)
+ {
+ printf("Init benchmark\n");
+ printf(" Init => %.2f ms \n", gDurationInit);
+ printf(" Deinit => %.2f ms \n", gDurationDeinit);
+ }
+ else
+ {
+ printf("Init benchmark - not activated.\n");
+ }
+ printf("==================================================================================\n");
+ if(doRead == 1)
+ {
+ printf("Read benchmark\n");
+ printf(" Read => %.0f ns for \t [%.2f Kilobytes item]\n", gDurationRead, gSizeRead);
+ printf(" Read => %.0f ns for \t [1 Kilobyte item]\n", (double)gDurationRead/(double)gSizeRead);
+ }
+ else
+ {
+ printf("Read benchmark - not activated.\n");
+ }
+ printf("==================================================================================\n");
+ if(doWrite == 1)
+ {
+ printf("Write benchmark\n");
+ printf(" Write 1. => %.0f ns for \t [%.2f Kilobytes item]\n", gAverageTimeWrite, gAverageBytesWrite);
+ printf(" Write 2. => %.0f ns for \t [%.2f Kilobytes item]\n", gAverageTimeWriteSecond, gAverageBytesWriteSecond);
+ printf(" Write 1. => %.0f ns for \t [1 Kilobyte item]\n", gAverageTimeWrite/gAverageBytesWrite);
+ printf(" Write 2. => %.0f ns for \t [1 Kilobyte item]\n", gAverageTimeWriteSecond/gAverageBytesWriteSecond);
+ printf(" Writeback => %.3f ms for \t [%.2f Megabytes item]\n", gDurationMsWrite, gSizeMbWrite);
+ printf(" Writeback => %.3f ms for \t [1 Megabyte item]\n", (double)gDurationMsWrite/(double)gSizeMbWrite);
+
+ printf("Explanation:\n");
+ printf(" Writing the first time (1.) to an item takes more time.\n");
+ printf(" As we use the copy an write procedure, we create an entry for this item \n");
+ printf(" in the cache and are writing then to the cache.\n");
+ printf(" Further writes (2.) are faster.\n");
+ printf(" When the database will be close, all modified items will be written back\n");
+ printf(" to non-volatile memory device.\n");
+ }
+ else
+ {
+ printf("Write benchmark - not activated.\n");
+ }
+ printf("==================================================================================\n");
+
+ // unregister debug log and trace
+ DLT_UNREGISTER_APP();
+
+ dlt_free();
+
+ return ret;
+}
+
+
+
+const char* gWriteBuffer =
+ "---------> F I R S T write buffer starting block "
+ "Pack my box with five dozen liquor jugs. - "
+ "Jackdaws love my big sphinx of quartz. - "
+ "The five boxing wizards jump quickly. - "
+ "How vexingly quick daft zebras jump! - "
+ "Bright vixens jump; dozy fowl quack - "
+ "Sphinx of black quartz, judge my vow"
+ "Voyez le brick géant que j’examine près du wha"
+ "Zornig und gequält rügen jeweils Pontifex und Volk die maßlose bischöfliche Hybris"
+ "Xaver schreibt für Wikipedia zum Spaß quälend lang über Yoga, Soja und Öko"
+ "Polyfon zwitschernd aßen Mäxchens Vögel Rüben, Joghurt und Quark"
+ "Fix, Schwyz!“ quäkt Jürgen blöd vom Paß"
+ "Welch fieser Katzentyp quält da süße Vögel bloß zum Jux"
+ "Die heiße Zypernsonne quälte Max und Victoria ja böse auf dem Weg bis zur Küste"
+ "Pack my box with five dozen liquor jugs. - "
+ "Jackdaws love my big sphinx of quartz. - "
+ "The five boxing wizards jump quickly. - "
+ "How vexingly quick daft zebras jump! - "
+ "Bright vixens jump; dozy fowl quack - "
+ "Sphinx of black quartz, judge my vow"
+ "Voyez le brick géant que j’examine près du wha"
+ "Zornig und gequält rügen jeweils Pontifex und Volk die maßlose bischöfliche Hybris"
+ "Xaver schreibt für Wikipedia zum Spaß quälend lang über Yoga, Soja und Öko"
+ "Polyfon zwitschernd aßen Mäxchens Vögel Rüben, Joghurt und Quark"
+ "Fix, Schwyz!“ quäkt Jürgen blöd vom Paß"
+ "Welch fieser Katzentyp quält da süße Vögel bloß zum Jux"
+ "Die heiße Zypernsonne quälte Max und Victoria ja böse auf dem Weg bis zur Küste"
+ "Pack my box with five dozen liquor jugs. - "
+ "Jackdaws love my big sphinx of quartz. - "
+ "The five boxing wizards jump quickly. - "
+ "How vexingly quick daft zebras jump! - "
+ "Bright vixens jump; dozy fowl quack - "
+ "Sphinx of black quartz, judge my vow"
+ "Voyez le brick géant que j’examine près du wha"
+ "Zornig und gequält rügen jeweils Pontifex und Volk die maßlose bischöfliche Hybris"
+ "Xaver schreibt für Wikipedia zum Spaß quälend lang über Yoga, Soja und Öko"
+ "Polyfon zwitschernd aßen Mäxchens Vögel Rüben, Joghurt und Quark"
+ "Fix, Schwyz!“ quäkt Jürgen blöd vom Paß"
+ "Welch fieser Katzentyp quält da süße Vögel bloß zum Jux"
+ "Die heiße Zypernsonne quälte Max und Victoria ja böse auf dem Weg bis zur Küste"
+ "Pack my box with five dozen liquor jugs. - "
+ "Jackdaws love my big sphinx of quartz. - "
+ "The five boxing wizards jump quickly. - "
+ "How vexingly quick daft zebras jump! - "
+ "Bright vixens jump; dozy fowl quack - "
+ "Sphinx of black quartz, judge my vow"
+ "Voyez le brick géant que j’examine près du wha"
+ "Zornig und gequält rügen jeweils Pontifex und Volk die maßlose bischöfliche Hybris"
+ "Xaver schreibt für Wikipedia zum Spaß quälend lang über Yoga, Soja und Öko"
+ "Polyfon zwitschernd aßen Mäxchens Vögel Rüben, Joghurt und Quark"
+ "Fix, Schwyz!“ quäkt Jürgen blöd vom Paß"
+ "Welch fieser Katzentyp quält da süße Vögel bloß zum Jux"
+ "Die heiße Zypernsonne quälte Max und Victoria ja böse auf dem Weg bis zur Küste""Pack my box with five dozen liquor jugs. - "
+ "Jackdaws love my big sphinx of quartz. - "
+ "The five boxing wizards jump quickly. - "
+ "How vexingly quick daft zebras jump! - "
+ "Bright vixens jump; dozy fowl quack - "
+ "Sphinx of black quartz, judge my vow"
+ "Voyez le brick géant que j’examine près du wha"
+ "Zornig und gequält rügen jeweils Pontifex und Volk die maßlose bischöfliche Hybris"
+ "Xaver schreibt für Wikipedia zum Spaß quälend lang über Yoga, Soja und Öko"
+ "Polyfon zwitschernd aßen Mäxchens Vögel Rüben, Joghurt und Quark"
+ "Fix, Schwyz!“ quäkt Jürgen blöd vom Paß"
+ "Welch fieser Katzentyp quält da süße Vögel bloß zum Jux"
+ "Die heiße Zypernsonne quälte Max und Victoria ja böse auf dem Weg bis zur Küste"
+ "Pack my box with five dozen liquor jugs. - "
+ "Jackdaws love my big sphinx of quartz. - "
+ "The five boxing wizards jump quickly. - "
+ "How vexingly quick daft zebras jump! - "
+ "Bright vixens jump; dozy fowl quack - "
+ "Sphinx of black quartz, judge my vow"
+ "Voyez le brick géant que j’examine près du wha"
+ "Zornig und gequält rügen jeweils Pontifex und Volk die maßlose bischöfliche Hybris"
+ "Xaver schreibt für Wikipedia zum Spaß quälend lang über Yoga, Soja und Öko"
+ "Polyfon zwitschernd aßen Mäxchens Vögel Rüben, Joghurt und Quark"
+ "Fix, Schwyz!“ quäkt Jürgen blöd vom Paß"
+ "Welch fieser Katzentyp quält da süße Vögel bloß zum Jux"
+ "Die heiße Zypernsonne quälte Max und Victoria ja böse auf dem Weg bis zur Küste"
+ "Pack my box with five dozen liquor jugs. - "
+ "Jackdaws love my big sphinx of quartz. - "
+ "The five boxing wizards jump quickly. - "
+ "How vexingly quick daft zebras jump! - "
+ "Bright vixens jump; dozy fowl quack - "
+ "Sphinx of black quartz, judge my vow"
+ "Voyez le brick géant que j’examine près du wha"
+ "Zornig und gequält rügen jeweils Pontifex und Volk die maßlose bischöfliche Hybris"
+ "Xaver schreibt für Wikipedia zum Spaß quälend lang über Yoga, Soja und Öko"
+ "Polyfon zwitschernd aßen Mäxchens Vögel Rüben, Joghurt und Quark"
+ "Fix, Schwyz!“ quäkt Jürgen blöd vom Paß"
+ "Welch fieser Katzentyp quält da süße Vögel bloß zum Jux"
+ "Die heiße Zypernsonne quälte Max und Victoria ja böse auf dem Weg bis zur Küste"
+ "Pack my box with five dozen liquor jugs. - "
+ "Jackdaws love my big sphinx of quartz. - "
+ "The five boxing wizards jump quickly. - "
+ "How vexingly quick daft zebras jump! - "
+ "Bright vixens jump; dozy fowl quack - "
+ "Sphinx of black quartz, judge my vow"
+ "Voyez le brick géant que j’examine près du wha"
+ "Zornig und gequält rügen jeweils Pontifex und Volk die maßlose bischöfliche Hybris"
+ "Xaver schreibt für Wikipedia zum Spaß quälend lang über Yoga, Soja und Öko"
+ "Polyfon zwitschernd aßen Mäxchens Vögel Rüben, Joghurt und Quark"
+ "Fix, Schwyz!“ quäkt Jürgen blöd vom Paß"
+ "Welch fieser Katzentyp quält da süße Vögel bloß zum Jux"
+ "Die heiße Zypernsonne quälte Max und Victoria ja böse auf dem Weg bis zur Küste"
+ "F I R S T write buffer ending block <---------";
+
+const char* gWriteBuffer2 =
+ "---------> S E C O N D write buffer starting block "
+ "Pack my box with five dozen liquor jugs. - "
+ "Jackdaws love my big sphinx of quartz. - "
+ "The five boxing wizards jump quickly. - "
+ "How vexingly quick daft zebras jump! - "
+ "Bright vixens jump; dozy fowl quack - "
+ "Sphinx of black quartz, judge my vow"
+ "Voyez le brick géant que j’examine près du wha"
+ "Zornig und gequält rügen jeweils Pontifex und Volk die maßlose bischöfliche Hybris"
+ "Xaver schreibt für Wikipedia zum Spaß quälend lang über Yoga, Soja und Öko"
+ "Polyfon zwitschernd aßen Mäxchens Vögel Rüben, Joghurt und Quark"
+ "Fix, Schwyz!“ quäkt Jürgen blöd vom Paß"
+ "Welch fieser Katzentyp quält da süße Vögel bloß zum Jux"
+ "Die heiße Zypernsonne quälte Max und Victoria ja böse auf dem Weg bis zur Küste"
+ "Pack my box with five dozen liquor jugs. - "
+ "Jackdaws love my big sphinx of quartz. - "
+ "The five boxing wizards jump quickly. - "
+ "How vexingly quick daft zebras jump! - "
+ "Bright vixens jump; dozy fowl quack - "
+ "Sphinx of black quartz, judge my vow"
+ "Voyez le brick géant que j’examine près du wha"
+ "Zornig und gequält rügen jeweils Pontifex und Volk die maßlose bischöfliche Hybris"
+ "Xaver schreibt für Wikipedia zum Spaß quälend lang über Yoga, Soja und Öko"
+ "Polyfon zwitschernd aßen Mäxchens Vögel Rüben, Joghurt und Quark"
+ "Fix, Schwyz!“ quäkt Jürgen blöd vom Paß"
+ "Welch fieser Katzentyp quält da süße Vögel bloß zum Jux"
+ "Die heiße Zypernsonne quälte Max und Victoria ja böse auf dem Weg bis zur Küste"
+ "Pack my box with five dozen liquor jugs. - "
+ "Jackdaws love my big sphinx of quartz. - "
+ "The five boxing wizards jump quickly. - "
+ "How vexingly quick daft zebras jump! - "
+ "Bright vixens jump; dozy fowl quack - "
+ "Sphinx of black quartz, judge my vow"
+ "Voyez le brick géant que j’examine près du wha"
+ "Zornig und gequält rügen jeweils Pontifex und Volk die maßlose bischöfliche Hybris"
+ "Xaver schreibt für Wikipedia zum Spaß quälend lang über Yoga, Soja und Öko"
+ "Polyfon zwitschernd aßen Mäxchens Vögel Rüben, Joghurt und Quark"
+ "Fix, Schwyz!“ quäkt Jürgen blöd vom Paß"
+ "Welch fieser Katzentyp quält da süße Vögel bloß zum Jux"
+ "Die heiße Zypernsonne quälte Max und Victoria ja böse auf dem Weg bis zur Küste"
+ "Pack my box with five dozen liquor jugs. - "
+ "Jackdaws love my big sphinx of quartz. - "
+ "The five boxing wizards jump quickly. - "
+ "How vexingly quick daft zebras jump! - "
+ "Bright vixens jump; dozy fowl quack - "
+ "Sphinx of black quartz, judge my vow"
+ "Voyez le brick géant que j’examine près du wha"
+ "Zornig und gequält rügen jeweils Pontifex und Volk die maßlose bischöfliche Hybris"
+ "Xaver schreibt für Wikipedia zum Spaß quälend lang über Yoga, Soja und Öko"
+ "Polyfon zwitschernd aßen Mäxchens Vögel Rüben, Joghurt und Quark"
+ "Fix, Schwyz!“ quäkt Jürgen blöd vom Paß"
+ "Welch fieser Katzentyp quält da süße Vögel bloß zum Jux"
+ "Die heiße Zypernsonne quälte Max und Victoria ja böse auf dem Weg bis zur Küste""Pack my box with five dozen liquor jugs. - "
+ "Jackdaws love my big sphinx of quartz. - "
+ "The five boxing wizards jump quickly. - "
+ "How vexingly quick daft zebras jump! - "
+ "Bright vixens jump; dozy fowl quack - "
+ "Sphinx of black quartz, judge my vow"
+ "Voyez le brick géant que j’examine près du wha"
+ "Zornig und gequält rügen jeweils Pontifex und Volk die maßlose bischöfliche Hybris"
+ "Xaver schreibt für Wikipedia zum Spaß quälend lang über Yoga, Soja und Öko"
+ "Polyfon zwitschernd aßen Mäxchens Vögel Rüben, Joghurt und Quark"
+ "Fix, Schwyz!“ quäkt Jürgen blöd vom Paß"
+ "Welch fieser Katzentyp quält da süße Vögel bloß zum Jux"
+ "Die heiße Zypernsonne quälte Max und Victoria ja böse auf dem Weg bis zur Küste"
+ "Pack my box with five dozen liquor jugs. - "
+ "Jackdaws love my big sphinx of quartz. - "
+ "The five boxing wizards jump quickly. - "
+ "How vexingly quick daft zebras jump! - "
+ "Bright vixens jump; dozy fowl quack - "
+ "Sphinx of black quartz, judge my vow"
+ "Voyez le brick géant que j’examine près du wha"
+ "Zornig und gequält rügen jeweils Pontifex und Volk die maßlose bischöfliche Hybris"
+ "Xaver schreibt für Wikipedia zum Spaß quälend lang über Yoga, Soja und Öko"
+ "Polyfon zwitschernd aßen Mäxchens Vögel Rüben, Joghurt und Quark"
+ "Fix, Schwyz!“ quäkt Jürgen blöd vom Paß"
+ "Welch fieser Katzentyp quält da süße Vögel bloß zum Jux"
+ "Die heiße Zypernsonne quälte Max und Victoria ja böse auf dem Weg bis zur Küste"
+ "Pack my box with five dozen liquor jugs. - "
+ "Jackdaws love my big sphinx of quartz. - "
+ "The five boxing wizards jump quickly. - "
+ "How vexingly quick daft zebras jump! - "
+ "Bright vixens jump; dozy fowl quack - "
+ "Sphinx of black quartz, judge my vow"
+ "Voyez le brick géant que j’examine près du wha"
+ "Zornig und gequält rügen jeweils Pontifex und Volk die maßlose bischöfliche Hybris"
+ "Xaver schreibt für Wikipedia zum Spaß quälend lang über Yoga, Soja und Öko"
+ "Polyfon zwitschernd aßen Mäxchens Vögel Rüben, Joghurt und Quark"
+ "Fix, Schwyz!“ quäkt Jürgen blöd vom Paß"
+ "Welch fieser Katzentyp quält da süße Vögel bloß zum Jux"
+ "Die heiße Zypernsonne quälte Max und Victoria ja böse auf dem Weg bis zur Küste"
+ "Pack my box with five dozen liquor jugs. - "
+ "Jackdaws love my big sphinx of quartz. - "
+ "The five boxing wizards jump quickly. - "
+ "How vexingly quick daft zebras jump! - "
+ "Bright vixens jump; dozy fowl quack - "
+ "Sphinx of black quartz, judge my vow"
+ "Voyez le brick géant que j’examine près du wha"
+ "Zornig und gequält rügen jeweils Pontifex und Volk die maßlose bischöfliche Hybris"
+ "Xaver schreibt für Wikipedia zum Spaß quälend lang über Yoga, Soja und Öko"
+ "Polyfon zwitschernd aßen Mäxchens Vögel Rüben, Joghurt und Quark"
+ "Fix, Schwyz!“ quäkt Jürgen blöd vom Paß"
+ "Welch fieser Katzentyp quält da süße Vögel bloß zum Jux"
+ "Die heiße Zypernsonne quälte Max und Victoria ja böse auf dem Weg bis zur Küste"
+ "S E C O N D write buffer ending block <---------";
+
+
+
diff --git a/test/persistence_client_library_test.c b/test/persistence_client_library_test.c
index c9556ce..ad7ad8a 100644
--- a/test/persistence_client_library_test.c
+++ b/test/persistence_client_library_test.c
@@ -80,6 +80,10 @@ void run_concurrency_test();
void data_setup(void)
{
int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+ const char* envVariable = "PERS_CLIENT_LIB_CUSTOM_LOAD";
+
+ setenv(envVariable, "/etc/pclCustomLibConfigFileTest.cfg", 1);
+
(void)pclInitLibrary(gTheAppId, shutdownReg);
}
@@ -805,6 +809,11 @@ START_TEST(test_InitDeinit)
pclDeinitLibrary();
+ pclInitLibrary("NodeStateManager", PCL_SHUTDOWN_TYPE_NONE);
+
+ pclDeinitLibrary();
+
+
}
END_TEST
@@ -1158,7 +1167,13 @@ START_TEST(test_NoRct)
DLT_LOG(gPcltDLTContext, DLT_LOG_INFO, DLT_STRING("PCL_TEST test_NoRct"));
ret = pclKeyWriteData(PCL_LDBID_LOCAL, "someResourceId", 0, 0, (unsigned char*)writeBuffer, (int)strlen(writeBuffer));
+
+#if USE_APPCHECK
+ fail_unless(ret == EPERS_SHUTDOWN_NO_TRUSTED, "Shutdown is trusted, but should not");
+#else
fail_unless(ret == EPERS_NOPRCTABLE, "RCT available, but should not");
+#endif
+
}
END_TEST
@@ -1458,12 +1473,11 @@ START_TEST(test_NoPluginFunc)
// change to an wrong plugin configuration file using environment variable
setenv(envVariable, "/etc/pclCustomLibConfigFileWrongDefault.cfg", 1);
- sleep(3);
+ sleep(2);
(void)pclInitLibrary(gTheAppId, shutdownReg); // use the app id, the resource is registered for
ret = pclKeyReadData(PCL_LDBID_LOCAL, "status/open_document", 3, 2, buffer, READ_SIZE);
- printf("*** ret: %d\n", ret);
ck_assert_int_eq(ret, EPERS_COMMON);
ret = pclKeyGetSize(PCL_LDBID_LOCAL, "status/open_document", 3, 2);
@@ -1601,13 +1615,16 @@ static Suite * persistenceClientLib_suite()
tcase_set_timeout(tc_MultiThreadedWrite, 20);
#endif
+
+
+ suite_add_tcase(s, tc_NoPluginFunc);
+
suite_add_tcase(s, tc_persSetData);
tcase_add_checked_fixture(tc_persSetData, data_setup, data_teardown);
suite_add_tcase(s, tc_persGetData);
tcase_add_checked_fixture(tc_persGetData, data_setup, data_teardown);
-
suite_add_tcase(s, tc_persGetDataHandle);
tcase_add_checked_fixture(tc_persGetDataHandle, data_setup, data_teardown);
@@ -1663,18 +1680,15 @@ static Suite * persistenceClientLib_suite()
suite_add_tcase(s, tc_InitDeinit);
- //suite_add_tcase(s, tc_NoPluginFunc);
-
- //suite_add_tcase(s, tc_SharedData);
- //tcase_add_checked_fixture(tc_SharedData, data_setup, data_teardown);
+ suite_add_tcase(s, tc_SharedData);
+ tcase_add_checked_fixture(tc_SharedData, data_setup, data_teardown);
#if USE_APPCHECK
suite_add_tcase(s, tc_ValidApplication);
-#else
-
#endif
+
#if 0
suite_add_tcase(s, tc_PAS_DbusInterface);
tcase_add_checked_fixture(tc_PAS_DbusInterface, data_setup, data_teardown);
diff --git a/test/persistence_client_library_test_file.c b/test/persistence_client_library_test_file.c
index 27a3bba..06fdf9e 100644
--- a/test/persistence_client_library_test_file.c
+++ b/test/persistence_client_library_test_file.c
@@ -92,14 +92,6 @@ void data_setup_browser(void)
}
-void data_setup_norct(void)
-{
- int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
-
- (void)pclInitLibrary("norct", shutdownReg);
-}
-
-
void data_teardown(void)
{
pclDeinitLibrary();
@@ -1834,6 +1826,17 @@ void doListTest()
}
+void doPclInitTest()
+{
+ int rval = pclInitLibrary(gTheAppId, PCL_SHUTDOWN_TYPE_NORMAL);
+
+ printf("Wait until a key has been pressed - return: %d\n", rval);
+ getchar();
+
+
+ pclDeinitLibrary();
+}
+
int main(int argc, char *argv[])
{
int nr_failed = 0;
@@ -1879,6 +1882,9 @@ int main(int argc, char *argv[])
case 1:
doListTest();
break;
+ case 2:
+ doPclInitTest();
+ break;
default:
printf("invalid parameter\n");
break;
diff --git a/tools/persistence_client_tool.c b/tools/persistence_client_tool.c
index fdd2562..80a267a 100644
--- a/tools/persistence_client_tool.c
+++ b/tools/persistence_client_tool.c
@@ -362,7 +362,7 @@ int main(int argc, char *argv[])
{
printf("Application name: %s\n", appName);
- int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+ int shutdownReg = PCL_SHUTDOWN_TYPE_NONE;
(void)pclInitLibrary(appName, shutdownReg);
switch(opMode)
@@ -435,6 +435,8 @@ int main(int argc, char *argv[])
free(fileName);
+ pclLifecycleSet(PCL_SHUTDOWN);
+
pclDeinitLibrary();
}
else