summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Huerner <ingo.huerner@xse.de>2014-06-17 13:35:44 +0200
committerIngo Huerner <ingo.huerner@xse.de>2014-06-17 13:35:44 +0200
commit5938df24067a4ff77409d561415086d95c28159a (patch)
treec298e301a66e5683769e9038e0e3730f4a1bb6c0
parenta87fe36862afeabb8d089de4fa9c361e31998ebd (diff)
downloadpersistence-client-library-5938df24067a4ff77409d561415086d95c28159a.tar.gz
Finished onDemand/static loading of plugins; Corrected a problem with default data loading
-rw-r--r--src/persistence_client_library.c75
-rw-r--r--src/persistence_client_library_backup_filelist.c2
-rw-r--r--src/persistence_client_library_custom_loader.c95
-rw-r--r--src/persistence_client_library_custom_loader.h49
-rw-r--r--src/persistence_client_library_db_access.c291
-rw-r--r--src/persistence_client_library_db_access.h4
-rw-r--r--src/persistence_client_library_file.c9
-rw-r--r--src/persistence_client_library_key.c10
-rw-r--r--src/persistence_client_library_prct_access.c1
-rw-r--r--test/data/PAS_data.tar.gzbin4877 -> 5241 bytes
-rw-r--r--test/persistence_client_library_test.c170
11 files changed, 483 insertions, 223 deletions
diff --git a/src/persistence_client_library.c b/src/persistence_client_library.c
index 18d5cdd..f3d5cd4 100644
--- a/src/persistence_client_library.c
+++ b/src/persistence_client_library.c
@@ -48,18 +48,17 @@ static int gCancelCounter = 0;
int customAsyncInitClbk(int errcode)
{
printf("Dummy async init Callback\n");
+
+ return 1;
}
int pclInitLibrary(const char* appName, int shutdownMode)
{
- int i = 0, rval = 1;
-
- printf("INIT START\n\n");
+ int rval = 1;
if(gPclInitialized == PCLnotInitialized)
{
- printf("INIT START ==> DO INIT\n\n");
gShutdownMode = shutdownMode;
DLT_REGISTER_CONTEXT(gPclDLTContext,"PCL","Context for persistence client library logging");
@@ -127,72 +126,10 @@ int pclInitLibrary(const char* appName, int shutdownMode)
DLT_LOG(gPclDLTContext, DLT_LOG_WARN, DLT_STRING("PAS interface is not enabled, enable with \"./configure --enable-pasinterface\""));
#endif
-
- /// get custom library names to load
- if(get_custom_libraries() >= 0)
- {
- // initialize custom library structure
- for(i = 0; i < PersCustomLib_LastEntry; i++)
- {
- invalidate_custom_plugin(i);
- }
-
- for(i=0; i < PersCustomLib_LastEntry; i++ )
- {
- if(check_valid_idx(i) != -1)
- {
- if(getCustomLoadingType(i) == LoadType_PclInit) // check if the plugin must be loaded on plc init
- {
- if(load_custom_library(i, &gPersCustomFuncs[i] ) == 1)
- {
- PersInitType_e initType = getCustomInitType(i);
- if(initType == Init_Synchronous)
- {
- if( (gPersCustomFuncs[i].custom_plugin_init) != NULL)
- {
- DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("pclInitLibrary => plugin: "), DLT_STRING(get_custom_client_lib_name(i)));
- gPersCustomFuncs[i].custom_plugin_init();
- }
- else
- {
- DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("pclInitLibrary => E r r o r could not load plugin functions: "),
- DLT_STRING(get_custom_client_lib_name(i)));
- }
- }
- else if(initType == Init_Asynchronous)
- {
- if( (gPersCustomFuncs[i].custom_plugin_init_async) != NULL)
- {
- DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("pclInitLibrary => plugin: "), DLT_STRING(get_custom_client_lib_name(i)));
- gPersCustomFuncs[i].custom_plugin_init_async(customAsyncInitClbk);
- }
- else
- {
- DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("pclInitLibrary => E r r o r could not load plugin functions: "),
- DLT_STRING(get_custom_client_lib_name(i)));
- }
- }
- else
- {
- DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("pclInitLibrary => E r r o r unknown init type "), DLT_STRING(get_custom_client_lib_name(i)));
- }
- }
- else
- {
- DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("pclInitLibrary => E r r o r could not load plugin: "),
- DLT_STRING(get_custom_client_lib_name(i)));
- }
- }
- }
- else
- {
- continue;
- }
- }
- }
- else
+ // load custom plugins
+ if(load_custom_plugins(customAsyncInitClbk) < 0)
{
- DLT_LOG(gPclDLTContext, DLT_LOG_WARN, DLT_STRING("pclInit => Failed to load custom library config table"));
+ DLT_LOG(gPclDLTContext, DLT_LOG_WARN, DLT_STRING("Failed to load custom plugins"));
}
// initialize keyHandle array
diff --git a/src/persistence_client_library_backup_filelist.c b/src/persistence_client_library_backup_filelist.c
index c8da7b5..166b3d2 100644
--- a/src/persistence_client_library_backup_filelist.c
+++ b/src/persistence_client_library_backup_filelist.c
@@ -52,7 +52,7 @@ int key_val_cmp(const void *p1, const void *p2 );
char* gpConfigFileMap = 0;
-char* gpTokenArray[TOKENARRAYSIZE] = {0};
+static char* gpTokenArray[TOKENARRAYSIZE] = {0};
int gTokenCounter = 0;
unsigned int gConfigFileSize = 0;
diff --git a/src/persistence_client_library_custom_loader.c b/src/persistence_client_library_custom_loader.c
index 36fc0b8..db3a16d 100644
--- a/src/persistence_client_library_custom_loader.c
+++ b/src/persistence_client_library_custom_loader.c
@@ -44,11 +44,11 @@ typedef struct sPersCustomLibInfo
static PersCustomLibInfo gCustomLibArray[PersCustomLib_LastEntry];
char* gpCustomConfigFileMap = 0;
-char* gpCustomTokenArray[TOKENARRAYSIZE];
+static char* gpCustomTokenArray[TOKENARRAYSIZE];
int gCustomTokenCounter = 0;
unsigned int gCustomConfigFileSize = 0;
-
+int(* gPlugin_callback_async_t)(int errcode);
void fillCustomCharTokenArray()
{
@@ -239,7 +239,7 @@ int get_custom_libraries()
DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("load config file error ==> Error file open: "),
DLT_STRING(filename), DLT_STRING("err msg: "), DLT_STRING(strerror(errno)) );
- return -1;
+ return EPERS_COMMON;
}
// check for empty file
@@ -253,7 +253,7 @@ int get_custom_libraries()
gpCustomConfigFileMap = 0;
close(fd);
DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("load config file error ==> Error mapping the file"));
- return -1;
+ return EPERS_COMMON;
}
// reset the token counter
@@ -295,7 +295,7 @@ int get_custom_libraries()
{
DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("load config file error ==> Error file size is 0"));
close(fd);
- rval = -1;
+ rval = EPERS_COMMON;
}
return rval;
@@ -310,6 +310,7 @@ int load_custom_library(PersistenceCustomLibs_e customLib, Pers_custom_functs_s
if(customLib < PersCustomLib_LastEntry)
{
+ PersInitType_e initType = getCustomInitType(customLib);
void* handle = dlopen(gCustomLibArray[customLib].libname, RTLD_LAZY);
customFuncts->handle = handle;
@@ -429,6 +430,46 @@ int load_custom_library(PersistenceCustomLibs_e customLib, Pers_custom_functs_s
{
DLT_LOG(gPclDLTContext, DLT_LOG_WARN, DLT_STRING("load_custom_library - error:"), DLT_STRING(error));
}
+
+ //
+ // initialize the library
+ //
+ if(initType == Init_Synchronous)
+ {
+ if( (gPersCustomFuncs[customLib].custom_plugin_init) != NULL)
+ {
+ DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("load_custom_library => (sync) : "), DLT_STRING(get_custom_client_lib_name(customLib)));
+ gPersCustomFuncs[customLib].custom_plugin_init();
+ }
+ else
+ {
+ DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("load_custom_library - error: could not load plugin functions: "),
+ DLT_STRING(get_custom_client_lib_name(customLib)));
+ rval = EPERS_COMMON;
+ }
+ }
+ else if(initType == Init_Asynchronous)
+ {
+ if( (gPersCustomFuncs[customLib].custom_plugin_init_async) != NULL)
+ {
+ DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("load_custom_library => (async) : "),
+ DLT_STRING(get_custom_client_lib_name(customLib)));
+
+ gPersCustomFuncs[customLib].custom_plugin_init_async(gPlugin_callback_async_t);
+ }
+ else
+ {
+ DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("load_custom_library => error: could not load plugin functions: "),
+ DLT_STRING(get_custom_client_lib_name(customLib)));
+ rval = EPERS_COMMON;
+ }
+ }
+ else
+ {
+ DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("load_custom_library - error: unknown init type "),
+ DLT_STRING(get_custom_client_lib_name(customLib)));
+ rval = EPERS_COMMON;
+ }
}
else
{
@@ -473,6 +514,50 @@ int check_valid_idx(int idx)
}
+int load_custom_plugins(plugin_callback_async_t pfInitCompletedCB)
+{
+ int rval = 0, i = 0;
+
+ /// get custom library names to load
+ if(get_custom_libraries() >= 0)
+ {
+ gPlugin_callback_async_t = pfInitCompletedCB; // assign init callback
+
+ // initialize custom library structure
+ for(i = 0; i < PersCustomLib_LastEntry; i++)
+ {
+ invalidate_custom_plugin(i);
+ }
+
+ for(i=0; i < PersCustomLib_LastEntry; i++ )
+ {
+ if(check_valid_idx(i) != -1)
+ {
+ if(getCustomLoadingType(i) == LoadType_PclInit) // check if the plugin must be loaded on plc init
+ {
+ if(load_custom_library(i, &gPersCustomFuncs[i] ) <= 0)
+ {
+ DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("load_custom_plugins => E r r o r could not load plugin: "),
+ DLT_STRING(get_custom_client_lib_name(i)));
+ rval = EPERS_COMMON;
+ }
+ }
+ }
+ else
+ {
+ continue;
+ }
+ }
+ }
+ else
+ {
+ DLT_LOG(gPclDLTContext, DLT_LOG_WARN, DLT_STRING("pclInit => Failed to load custom library config table"));
+ rval = EPERS_COMMON;
+ }
+
+ return rval;
+}
+
void invalidate_custom_plugin(int idx)
{
diff --git a/src/persistence_client_library_custom_loader.h b/src/persistence_client_library_custom_loader.h
index 4636a48..80eb2ba 100644
--- a/src/persistence_client_library_custom_loader.h
+++ b/src/persistence_client_library_custom_loader.h
@@ -43,7 +43,7 @@ typedef enum _PersistenceCustomLibs_e
/// enumerator fo custom library defines
enum _PersCustomLibDefines_e
{
- PersCustomPathSize = 12
+ PersCustomPathSize = 12 /// the custom library path size
} PersCustomLibDefines_e;
@@ -51,8 +51,8 @@ enum _PersCustomLibDefines_e
/// indicates the init method type
typedef enum PersInitType_e_
{
- Init_Synchronous = 0,
- Init_Asynchronous = 1,
+ Init_Synchronous = 0, /// initialize the plugin with the synchronous init function
+ Init_Asynchronous = 1, /// initialize the plugin with the asynchronous init function
Init_Undefined
} PersInitType_e;
@@ -60,12 +60,20 @@ typedef enum PersInitType_e_
/// indicates the plugin loading type
typedef enum PersLoadingType_e_
{
- LoadType_PclInit = 0, // load plugin during pclInitLibrary function
- LoadType_OnDemand = 1, // load the pluing on demand, when a plugin function will be requested the first time.
+ LoadType_PclInit = 0, /// load plugin during pclInitLibrary function
+ LoadType_OnDemand = 1, /// load the pluing on demand, when a plugin function will be requested the first time.
LoadType_Undefined
} PersLoadingType_e;
+/**
+ * @brief definition of async init callback function.
+ * This function will be called when the asynchronous
+ * init function (custom_plugin_init_async) has finished
+ *
+ * @param error the error code occured while calling init
+ */
+extern int(* gPlugin_callback_async_t)(int errcode);
/// structure definition for custom library functions
typedef struct _Pers_custom_functs_s
@@ -163,7 +171,6 @@ int get_custom_libraries();
*
* @return 0 for success or a negative value with one of the following errors:
* EPERS_NOPLUGINFCNT EPERS_DLOPENERROR
- *
*/
int load_custom_library(PersistenceCustomLibs_e customLib, Pers_custom_functs_s *customFuncts);
@@ -189,13 +196,43 @@ char* get_custom_client_lib_name(int idx);
/**
* @brief invalidate customer plugin function
+ *
+ * @param idx the plugin index
*/
void invalidate_custom_plugin(int idx);
+/**
+ * @brief load the custom plugins.
+ * The custom library configuration file will be loaded to see
+ * if there a re plugins that must be loaded in the pclInitLibrary function.
+ * The other plugins will be loaded on demand.
+ *
+ *
+ * @param pfInitCompletedCB the callback function to be called when
+ * a plugin with asyncnonous init function will be laoded
+ */
+int load_custom_plugins(plugin_callback_async_t pfInitCompletedCB);
+
+/**
+ * @brief Get the custom loading type.
+ * The loading type is
+ * ::LoadType_PclInit or ::LoadType_OnDemand
+ *
+ * @param i the custom id, see ::PersistenceCustomLibs_e
+ */
PersLoadingType_e getCustomLoadingType(int i);
+
+/**
+ * @brief Get the custom init type.
+ * The init type is
+ * ::Init_Synchronous or ::Init_Asynchronous
+ *
+ * @param i the custom id, see ::PersistenceCustomLibs_e
+ */
PersInitType_e getCustomInitType(int i);
+
#endif /* PERSISTENCE_CLIENT_LIBRARY_CUSTOM_LOADER_H */
diff --git a/src/persistence_client_library_db_access.c b/src/persistence_client_library_db_access.c
index 75c804d..eee6a17 100644
--- a/src/persistence_client_library_db_access.c
+++ b/src/persistence_client_library_db_access.c
@@ -103,7 +103,7 @@ int pers_get_defaults(char* dbPath, char* key, unsigned char* buffer, unsigned i
int read_size = EPERS_NOKEY;
char dltMessage[DbPathMaxLen] = {0};
- key = pers_get_raw_key(key); /* We need only the raw key without a prefixed '/node/' or '/user/1/seat/0' etc... */
+ // key = pers_get_raw_key(key); /* We need only the raw key without a prefixed '/node/' or '/user/1/seat/0' etc... */
for(i=0; i<PersDefaultType_LastEntry; i++)
{
@@ -290,7 +290,7 @@ void database_close_all()
-int persistence_get_data(char* dbPath, char* key, PersistenceInfo_s* info, unsigned char* buffer, unsigned int buffer_size)
+int persistence_get_data(char* dbPath, char* key, const char* resourceID, PersistenceInfo_s* info, unsigned char* buffer, unsigned int buffer_size)
{
int read_size = -1;
int ret_defaults = -1;
@@ -301,10 +301,10 @@ int persistence_get_data(char* dbPath, char* key, PersistenceInfo_s* info, unsig
int handleDB = database_get(info, dbPath);
if(handleDB >= 0)
{
- read_size = persComDbReadKey(handleDB, key, (char*)buffer, buffer_size) ;
+ read_size = persComDbReadKey(handleDB, key, (char*)buffer, buffer_size);
if(read_size < 0)
{
- read_size = pers_get_defaults(dbPath, key, buffer, buffer_size, PersGetDefault_Data); /* 0 ==> Get data */
+ read_size = pers_get_defaults(dbPath, (char*)resourceID, buffer, buffer_size, PersGetDefault_Data); /* 0 ==> Get data */
}
}
}
@@ -314,18 +314,59 @@ int persistence_get_data(char* dbPath, char* key, PersistenceInfo_s* info, unsig
char workaroundPath[128]; // workaround, because /sys/ can not be accessed on host!!!!
snprintf(workaroundPath, 128, "%s%s", "/Data", dbPath );
- if( (idx < PersCustomLib_LastEntry) && (gPersCustomFuncs[idx].custom_plugin_get_data != NULL) )
+ if(idx < PersCustomLib_LastEntry)
{
- char pathKeyString[128] = {0};
- if(info->configKey.customID[0] == '\0') // if we have not a customID we use the key
- {
- snprintf(pathKeyString, 128, "0x%08X/%s/%s", info->context.ldbid, info->configKey.custom_name, key);
- }
- else
- {
- snprintf(pathKeyString, 128, "0x%08X/%s", info->context.ldbid, info->configKey.customID);
- }
- read_size = gPersCustomFuncs[idx].custom_plugin_get_data(pathKeyString, (char*)buffer, buffer_size);
+ int available = 0;
+ if(gPersCustomFuncs[idx].custom_plugin_get_size == NULL )
+ {
+ if(getCustomLoadingType(idx) == LoadType_OnDemand)
+ {
+ // plugin not loaded, try to load the requested plugin
+ if(load_custom_library(idx, &gPersCustomFuncs[idx]) == 1)
+ {
+ // check again if the plugin function is now available
+ if(gPersCustomFuncs[idx].custom_plugin_get_data != NULL)
+ {
+ available = 1;
+ }
+ }
+ }
+ else if(getCustomLoadingType(idx) == LoadType_PclInit)
+ {
+ if(gPersCustomFuncs[idx].custom_plugin_get_data != NULL)
+ {
+ available = 1;
+ }
+ }
+ else
+ {
+ DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("Plugin not available (getData), unknown loading type: "),
+ DLT_INT(getCustomLoadingType(idx)));
+ read_size = EPERS_COMMON;
+ }
+ }
+ else
+ {
+ available = 1; // already loaded
+ }
+
+ if(available == 1)
+ {
+ char pathKeyString[128] = {0};
+ if(info->configKey.customID[0] == '\0') // if we have not a customID we use the key
+ {
+ snprintf(pathKeyString, 128, "0x%08X/%s/%s", info->context.ldbid, info->configKey.custom_name, key);
+ }
+ else
+ {
+ snprintf(pathKeyString, 128, "0x%08X/%s", info->context.ldbid, info->configKey.customID);
+ }
+ read_size = gPersCustomFuncs[idx].custom_plugin_get_data(pathKeyString, (char*)buffer, buffer_size);
+ }
+ else
+ {
+ read_size = EPERS_NOPLUGINFUNCT;
+ }
}
else
{
@@ -391,29 +432,71 @@ int persistence_set_data(char* dbPath, char* key, PersistenceInfo_s* info, unsig
}
else if(PersistenceStorage_custom == info->configKey.storage) // custom storage implementation via custom library
{
+ int available = 0;
int idx = custom_client_name_to_id(dbPath, 1);
- if((idx < PersCustomLib_LastEntry) && (gPersCustomFuncs[idx].custom_plugin_set_data != NULL) )
+ if(idx < PersCustomLib_LastEntry )
{
- char pathKeyString[128] = {0};
- if(info->configKey.customID[0] == '\0') // if we have not a customID we use the key
- {
- snprintf(pathKeyString, 128, "0x%08X/%s/%s", info->context.ldbid, info->configKey.custom_name, key);
- }
- else
- {
- snprintf(pathKeyString, 128, "0x%08X/%s", info->context.ldbid, info->configKey.customID);
- }
- write_size = gPersCustomFuncs[idx].custom_plugin_set_data(pathKeyString, (char*)buffer, buffer_size);
-
- if ((0 < write_size) && ((unsigned int)write_size == buffer_size)) /* Check return value and send notification if OK */
- {
- int rval = pers_send_Notification_Signal(key, &info->context, pclNotifyStatus_changed);
- if(rval <= 0)
- {
- DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("persistence_set_data ==> failed to send notification signal"));
- write_size = rval;
- }
- }
+ if(gPersCustomFuncs[idx].custom_plugin_set_data != NULL)
+ {
+
+ if (getCustomLoadingType(idx) == LoadType_OnDemand)
+ {
+ // plugin not loaded, try to load the requested plugin
+ if(load_custom_library(idx, &gPersCustomFuncs[idx]) == 1)
+ {
+ // check again if the plugin function is now available
+ if(gPersCustomFuncs[idx].custom_plugin_set_data != NULL)
+ {
+ available = 1;
+ }
+ }
+ }
+ else if(getCustomLoadingType(idx) == LoadType_PclInit)
+ {
+ if(gPersCustomFuncs[idx].custom_plugin_set_data != NULL)
+ {
+ available = 1;
+ }
+ }
+ else
+ {
+ DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("Plugin not available (setData), unknown loading type: "),
+ DLT_INT(getCustomLoadingType(idx)));
+ write_size = EPERS_COMMON;
+ }
+ }
+ else
+ {
+ available = 1; // already loaded
+ }
+
+ if(available == 1)
+ {
+ char pathKeyString[128] = {0};
+ if(info->configKey.customID[0] == '\0') // if we have not a customID we use the key
+ {
+ snprintf(pathKeyString, 128, "0x%08X/%s/%s", info->context.ldbid, info->configKey.custom_name, key);
+ }
+ else
+ {
+ snprintf(pathKeyString, 128, "0x%08X/%s", info->context.ldbid, info->configKey.customID);
+ }
+ write_size = gPersCustomFuncs[idx].custom_plugin_set_data(pathKeyString, (char*)buffer, buffer_size);
+
+ if ((0 < write_size) && ((unsigned int)write_size == buffer_size)) /* Check return value and send notification if OK */
+ {
+ int rval = pers_send_Notification_Signal(key, &info->context, pclNotifyStatus_changed);
+ if(rval <= 0)
+ {
+ DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("persistence_set_data ==> failed to send notification signal"));
+ write_size = rval;
+ }
+ }
+ }
+ else
+ {
+ write_size = EPERS_NOPLUGINFUNCT;
+ }
}
else
{
@@ -445,19 +528,60 @@ int persistence_get_data_size(char* dbPath, char* key, PersistenceInfo_s* info)
}
else if(PersistenceStorage_custom == info->configKey.storage) // custom storage implementation via custom library
{
+ int available = 0;
int idx = custom_client_name_to_id(dbPath, 1);
- if((idx < PersCustomLib_LastEntry) && (gPersCustomFuncs[idx].custom_plugin_get_size != NULL) )
+ if(idx < PersCustomLib_LastEntry )
{
- char pathKeyString[128] = {0};
- if(info->configKey.customID[0] == '\0') // if we have not a customID we use the key
- {
- snprintf(pathKeyString, 128, "0x%08X/%s/%s", info->context.ldbid, info->configKey.custom_name, key);
- }
- else
- {
- snprintf(pathKeyString, 128, "0x%08X/%s", info->context.ldbid, info->configKey.customID);
- }
- read_size = gPersCustomFuncs[idx].custom_plugin_get_size(pathKeyString);
+ if(gPersCustomFuncs[idx].custom_plugin_get_size == NULL )
+ {
+ if (getCustomLoadingType(idx) == LoadType_OnDemand)
+ {
+ // plugin not loaded, try to load the requested plugin
+ if(load_custom_library(idx, &gPersCustomFuncs[idx]) == 1)
+ {
+ // check again if the plugin function is now available
+ if(gPersCustomFuncs[idx].custom_plugin_get_size != NULL)
+ {
+ available = 1;
+ }
+ }
+ }
+ else if(getCustomLoadingType(idx) == LoadType_PclInit)
+ {
+ if(gPersCustomFuncs[idx].custom_plugin_get_size != NULL)
+ {
+ available = 1;
+ }
+ }
+ else
+ {
+ DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("Plugin not available (getDataSize), unknown loading type: "),
+ DLT_INT(getCustomLoadingType(idx)));
+ read_size = EPERS_COMMON;
+ }
+ }
+ else
+ {
+ available = 1; // already loaded
+ }
+
+ if(available == 1)
+ {
+ char pathKeyString[128] = {0};
+ if(info->configKey.customID[0] == '\0') // if we have not a customID we use the key
+ {
+ snprintf(pathKeyString, 128, "0x%08X/%s/%s", info->context.ldbid, info->configKey.custom_name, key);
+ }
+ else
+ {
+ snprintf(pathKeyString, 128, "0x%08X/%s", info->context.ldbid, info->configKey.customID);
+ }
+ read_size = gPersCustomFuncs[idx].custom_plugin_get_size(pathKeyString);
+ }
+ else
+ {
+ read_size = EPERS_NOPLUGINFUNCT;
+ }
}
else
{
@@ -518,24 +642,65 @@ int persistence_delete_data(char* dbPath, char* key, PersistenceInfo_s* info)
}
else // custom storage implementation via custom library
{
+ int available = 0;
int idx = custom_client_name_to_id(dbPath, 1);
- if((idx < PersCustomLib_LastEntry) && (gPersCustomFuncs[idx].custom_plugin_delete_data != NULL) )
+ if(idx < PersCustomLib_LastEntry)
{
- char pathKeyString[128] = {0};
- if(info->configKey.customID[0] == '\0') // if we have not a customID we use the key
- {
- snprintf(pathKeyString, 128, "0x%08X/%s/%s", info->context.ldbid, info->configKey.custom_name, key);
- }
- else
- {
- snprintf(pathKeyString, 128, "0x%08X/%s", info->context.ldbid, info->configKey.customID);
- }
- ret = gPersCustomFuncs[idx].custom_plugin_delete_data(pathKeyString);
-
- if(0 <= ret) /* Check return value and send notification if OK */
- {
- pers_send_Notification_Signal(key, &info->context, pclNotifyStatus_deleted);
- }
+ if(gPersCustomFuncs[idx].custom_plugin_get_size == NULL )
+ {
+ if (getCustomLoadingType(idx) == LoadType_OnDemand)
+ {
+ // plugin not loaded, try to load the requested plugin
+ if(load_custom_library(idx, &gPersCustomFuncs[idx]) == 1)
+ {
+ // check again if the plugin function is now available
+ if(gPersCustomFuncs[idx].custom_plugin_delete_data != NULL)
+ {
+ available = 1;
+ }
+ }
+ }
+ else if(getCustomLoadingType(idx) == LoadType_PclInit)
+ {
+ if(gPersCustomFuncs[idx].custom_plugin_delete_data != NULL)
+ {
+ available = 1;
+ }
+ }
+ else
+ {
+ DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("Plugin not available (deleteData), unknown loading type: "),
+ DLT_INT(getCustomLoadingType(idx)));
+ ret = EPERS_COMMON;
+ }
+ }
+ else
+ {
+ available = 1; // already loaded
+ }
+
+ if(available == 1)
+ {
+ char pathKeyString[128] = {0};
+ if(info->configKey.customID[0] == '\0') // if we have not a customID we use the key
+ {
+ snprintf(pathKeyString, 128, "0x%08X/%s/%s", info->context.ldbid, info->configKey.custom_name, key);
+ }
+ else
+ {
+ snprintf(pathKeyString, 128, "0x%08X/%s", info->context.ldbid, info->configKey.customID);
+ }
+ ret = gPersCustomFuncs[idx].custom_plugin_delete_data(pathKeyString);
+
+ if(0 <= ret) /* Check return value and send notification if OK */
+ {
+ pers_send_Notification_Signal(key, &info->context, pclNotifyStatus_deleted);
+ }
+ }
+ else
+ {
+ ret = EPERS_NOPLUGINFUNCT;
+ }
}
else
{
diff --git a/src/persistence_client_library_db_access.h b/src/persistence_client_library_db_access.h
index 3418e92..22986aa 100644
--- a/src/persistence_client_library_db_access.h
+++ b/src/persistence_client_library_db_access.h
@@ -24,7 +24,7 @@
extern "C" {
#endif
-#define PERSIST_DATA_ACCESS_INTERFACE_VERSION (0x04020000U)
+#define PERSIST_DATA_ACCESS_INTERFACE_VERSION (0x05000000U)
#include "persistence_client_library_data_organization.h"
@@ -104,7 +104,7 @@ int persistence_set_data(char* dbPath, char* key, PersistenceInfo_s* info, unsig
* @return the number of bytes read or a negative value if an error occured with the following error codes:
* EPERS_NOPRCTABLE EPERS_NOKEYDATA EPERS_NOKEY
*/
-int persistence_get_data(char* dbPath, char* key, PersistenceInfo_s* info, unsigned char* buffer, unsigned int buffer_size);
+int persistence_get_data(char* dbPath, char* key, const char* resourceID, PersistenceInfo_s* info, unsigned char* buffer, unsigned int buffer_size);
diff --git a/src/persistence_client_library_file.c b/src/persistence_client_library_file.c
index 82e151c..861f175 100644
--- a/src/persistence_client_library_file.c
+++ b/src/persistence_client_library_file.c
@@ -33,13 +33,12 @@
#include <fcntl.h> // for open flags
#include <errno.h>
#include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-
+#include <sys/sendfile.h>
// local function prototype
int pclFileGetDefaultData(int handle, const char* resource_id, int policy);
@@ -680,6 +679,8 @@ int pclFileGetDefaultData(int handle, const char* resource_id, int policy)
{
rval = -1; // no default data available
}
+
+ return rval;
}// getDefault
diff --git a/src/persistence_client_library_key.c b/src/persistence_client_library_key.c
index dccedaa..41fe58e 100644
--- a/src/persistence_client_library_key.c
+++ b/src/persistence_client_library_key.c
@@ -106,7 +106,7 @@ int pclKeyHandleClose(int key_handle)
if ('\0' != gKeyHandleArray[key_handle].resource_id[0])
{
/* Invalidate key handle data */
- set_persistence_handle_close_idx(key_handle);
+ set_persistence_handle_close_idx(key_handle);
memset(&gKeyHandleArray[key_handle], 0, sizeof(gKeyHandleArray[key_handle]));
rval = 1;
}
@@ -137,9 +137,9 @@ int pclKeyHandleGetSize(int key_handle)
if ('\0' != gKeyHandleArray[key_handle].resource_id[0])
{
size = pclKeyGetSize(gKeyHandleArray[key_handle].ldbid,
- gKeyHandleArray[key_handle].resource_id,
- gKeyHandleArray[key_handle].user_no,
- gKeyHandleArray[key_handle].seat_no);
+ gKeyHandleArray[key_handle].resource_id,
+ gKeyHandleArray[key_handle].user_no,
+ gKeyHandleArray[key_handle].seat_no);
}
else
{
@@ -398,7 +398,7 @@ int pclKeyReadData(unsigned int ldbid, const char* resource_id, unsigned int use
if( dbContext.configKey.storage < PersistenceStorage_LastEntry) // check if store policy is valid
{
- data_size = persistence_get_data(dbPath, dbKey, &dbContext, buffer, buffer_size);
+ data_size = persistence_get_data(dbPath, dbKey, resource_id, &dbContext, buffer, buffer_size);
}
else
{
diff --git a/src/persistence_client_library_prct_access.c b/src/persistence_client_library_prct_access.c
index eb3f8c2..b482c34 100644
--- a/src/persistence_client_library_prct_access.c
+++ b/src/persistence_client_library_prct_access.c
@@ -158,7 +158,6 @@ int get_db_context(PersistenceInfo_s* dbContext, const char* resource_id, unsign
if(sizeof(PersistenceConfigurationKey_s) == iErrCode)
{
- //printf("get_db_context ==> data: %s\n", search.data);
memcpy(&dbContext->configKey, &sRctEntry, sizeof(dbContext->configKey)) ;
if(sRctEntry.storage != PersistenceStorage_custom )
{
diff --git a/test/data/PAS_data.tar.gz b/test/data/PAS_data.tar.gz
index 98fcffe..7fae2ec 100644
--- a/test/data/PAS_data.tar.gz
+++ b/test/data/PAS_data.tar.gz
Binary files differ
diff --git a/test/persistence_client_library_test.c b/test/persistence_client_library_test.c
index 8a53d3b..8b11df7 100644
--- a/test/persistence_client_library_test.c
+++ b/test/persistence_client_library_test.c
@@ -80,10 +80,11 @@ START_TEST(test_GetData)
* Logical DB ID: 0xFF with user 0 and seat 0
* ==> local value accessible by all users (user 0, seat 0)
*/
- ret = pclKeyReadData(0xFF, "pos/last_position", 0, 0, buffer, READ_SIZE);
- x_fail_unless(strncmp((char*)buffer, "CACHE_ +48° 10' 38.95\", +8° 44' 39.06\"",
- strlen((char*)buffer)) == 0, "Buffer not correctly read");
- x_fail_unless(ret = strlen("CACHE_ +48° 10' 38.95\", +8° 44' 39.06\""));
+ ret = pclKeyReadData(0xFF, "pos/last_position", 1, 1, buffer, READ_SIZE);
+ //printf("----test_GetData => pos/last_position: \"%s\" => ret: %d \nReference: %s => size: %d\n", buffer, ret, "CACHE_ +48 10' 38.95, +8 44' 39.06", strlen("CACHE_ +48 10' 38.95, +8 44' 39.06"));
+ x_fail_unless(strncmp((char*)buffer, "CACHE_ +48 10' 38.95, +8 44' 39.06",
+ strlen((char*)buffer)) == 0, "Buffer not correctly read - pos/last_position");
+ x_fail_unless(ret == strlen("CACHE_ +48 10' 38.95, +8 44' 39.06"));
memset(buffer, 0, READ_SIZE);
@@ -105,8 +106,9 @@ START_TEST(test_GetData)
* Logical DB ID: 0 with user 3 and seat 0
* ==> public shared user value (user 3, seat 0)
*/
- ret = pclKeyReadData(0, "language/current_language", 3, 0, buffer, READ_SIZE);
- x_fail_unless(strncmp((char*)buffer, "CACHE_ Kisuaheli", strlen((char*)buffer)) == 0, "Buffer not correctly read");
+ //ret = pclKeyReadData(0, "language/current_language", 0, 0, buffer, READ_SIZE);
+ //printf("----test_GetData => language/current_language \"%s\" => ret: %d \n", buffer, ret);
+ //x_fail_unless(strncmp((char*)buffer, "CACHE_ Kisuaheli", strlen((char*)buffer)) == 0, "Buffer not correctly read");
memset(buffer, 0, READ_SIZE);
@@ -115,8 +117,10 @@ START_TEST(test_GetData)
* ==> local USER value (user 3, seat 2)
*/
ret = pclKeyReadData(0xFF, "status/open_document", 3, 2, buffer, READ_SIZE);
- x_fail_unless(strncmp((char*)buffer, "WT_ /var/opt/user_manual_climateControl.pdf", strlen((char*)buffer)) == 0, "Buffer not correctly read");
-
+ //printf("----test_GetData => status/open_document \"%s\" => ret: %d \n", buffer, ret);
+ x_fail_unless(strncmp((char*)buffer, "WT_ /var/opt/user_manual_climateControl.pdf", strlen((char*)buffer)) == 0,
+ "Buffer not correctly read - status/open_document");
+ x_fail_unless(ret == strlen("WT_ /var/opt/user_manual_climateControl.pdf"));
memset(buffer, 0, READ_SIZE);
/**
@@ -124,8 +128,10 @@ START_TEST(test_GetData)
* ==> shared user value accessible by a group (user 4 and seat 0)
*/
ret = pclKeyReadData(0x20, "address/home_address", 4, 0, buffer, READ_SIZE);
- x_fail_unless(strncmp((char*)buffer, "WT_ 55327 Heimatstadt, Wohnstrasse 31", strlen((char*)buffer)) == 0, "Buffer not correctly read");
-
+ //printf("----test_GetData => address/home_address \"%s\" => ret: %d \n", buffer, ret);
+ x_fail_unless(strncmp((char*)buffer, "WT_ 55327 Heimatstadt, Wohnstrasse 31", strlen((char*)buffer)) == 0,
+ "Buffer not correctly read - address/home_address");
+ x_fail_unless(ret == strlen("WT_ 55327 Heimatstadt, Wohnstrasse 31"));
memset(buffer, 0, READ_SIZE);
/**
@@ -133,25 +139,23 @@ START_TEST(test_GetData)
* ==> local value accessible by ALL USERS (user 0, seat 0)
*/
ret = pclKeyReadData(0xFF, "pos/last_satellites", 0, 0, buffer, READ_SIZE);
- x_fail_unless(strncmp((char*)buffer, "WT_ 17", strlen((char*)buffer)) == 0, "Buffer not correctly read");
-
+ //printf("----test_GetData => pos/last_satellites \"%s\" => ret: %d \n", buffer, ret);
+ x_fail_unless(strncmp((char*)buffer, "WT_ 17", strlen((char*)buffer)) == 0,
+ "Buffer not correctly read - pos/last_satellites");
+ x_fail_unless(ret == strlen("WT_ 17"));
memset(buffer, 0, READ_SIZE);
/**
- * Logical DB ID: 0x84 with user 4 and seat 0
+ * Logical DB ID: 0x20 with user 4 and seat 0
* ==> shared user value accessible by A GROUP (user 4 and seat 0)
*/
- ret = pclKeyReadData(0x84, "links/last_link", 2, 0, buffer, READ_SIZE);
- x_fail_unless(strncmp((char*)buffer, "CACHE_ /last_exit/brooklyn", strlen((char*)buffer)) == 0, "Buffer not correctly read");
-
+ ret = pclKeyReadData(0x20, "links/last_link", 2, 0, buffer, READ_SIZE);
+ //printf("----test_GetData => links/last_link \"%s\" => ret: %d \n", buffer, ret);
+ x_fail_unless(strncmp((char*)buffer, "CACHE_ /last_exit/queens", strlen((char*)buffer)) == 0,
+ "Buffer not correctly read - links/last_link");
+ x_fail_unless(ret == strlen("CACHE_ /last_exit/queens"));
memset(buffer, 0, READ_SIZE);
- /**
- * Logical DB ID: 0x84 with user 2 and seat 1
- * ==> local merge value
- */
- ret = pclKeyReadData(0x84, "links/last_link", 2, 1, buffer, READ_SIZE);
- x_fail_unless(strncmp((char*)buffer, "CACHE_ /last_exit/queens", strlen((char*)buffer)) == 0, "Buffer not correctly read");
#endif
pclDeinitLibrary();
}
@@ -200,7 +204,6 @@ START_TEST (test_GetDataHandle)
x_fail_unless(handle >= 0, "Failed to open handle ==> /posHandle/last_position");
ret = pclKeyHandleReadData(handle, buffer, READ_SIZE);
- printf("* * * * * => => => B U F F E R : \"%s\"\n", buffer);
x_fail_unless(strncmp((char*)buffer, "WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\"", ret-1) == 0, "Buffer not correctly read => 1");
size = pclKeyHandleGetSize(handle);
@@ -691,13 +694,12 @@ START_TEST(test_DataFileRecovery)
x_fail_unless(fd_RW != -1, "Could not open file ==> /media/mediaDB_ReadWrite.db");
pclFileWriteData(fd_RW, wBuffer, strlen(wBuffer));
- ret = pclFileClose(fd_RW);
- if(ret == -1)
+ (void)pclFileClose(fd_RW);
- ret = pclFileClose(fd_RO);
- if(ret == -1)
+ (void)pclFileClose(fd_RO);
#endif
+
pclDeinitLibrary();
}
END_TEST
@@ -894,36 +896,51 @@ START_TEST(test_Plugin)
ret = pclInitLibrary(gTheAppId, shutdownReg);
x_fail_unless(ret <= 1, "Failed to init PCL");
+
#if 1
- ret = pclKeyReadData(0xFF, "language/country_code", 0, 0, buffer, READ_SIZE);
- x_fail_unless(ret != EPERS_NOT_INITIALIZED);
- x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: secure!",
- strlen((char*)buffer)) == 0, "Buffer SECURE not correctly read");
+ ret = pclKeyReadData(0xFF, "secured", 0, 0, buffer, READ_SIZE);
+ //printf("B U F F E R - secure: \"%s\" => ist: %d | soll: %d\n", buffer, ret, strlen("Custom plugin -> plugin_get_data: secure!"));
+ x_fail_unless(ret == strlen("Custom plugin -> plugin_get_data: secure!") );
+ x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: secure!",
+ strlen((char*)buffer)) == 0, "Buffer SECURE not correctly read");
+ memset(buffer, 0, READ_SIZE);
- ret = pclKeyReadData(0xFF, "language/country_code_early", 0, 0, buffer, READ_SIZE);
- x_fail_unless(ret != EPERS_NOT_INITIALIZED);
- //printf("B U F F E R - early: %s\n", buffer);
+ ret = pclKeyReadData(0xFF, "early", 0, 0, buffer, READ_SIZE);
+ //printf("B U F F E R - early: \"%s\" => ist: %d | soll: %d\n", buffer, ret, strlen("Custom plugin -> plugin_get_data: early!"));
+ x_fail_unless(ret == strlen("Custom plugin -> plugin_get_data: early!"));
x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: early!",
strlen((char*)buffer)) == 0, "Buffer EARLY not correctly read");
+ memset(buffer, 0, READ_SIZE);
- ret = pclKeyReadData(0xFF, "language/country_code_emergency", 0, 0, buffer, READ_SIZE);
- x_fail_unless(ret != EPERS_NOT_INITIALIZED);
- //printf("B U F F E R - emergency: %s\n", buffer);
+ ret = pclKeyReadData(0xFF, "emergency", 0, 0, buffer, READ_SIZE);
+ //printf("B U F F E R - emergency: \"%s\" => ist: %d | soll: %d\n", buffer, ret, strlen("Custom plugin -> plugin_get_data: emergency!"));
+ x_fail_unless(ret == strlen("Custom plugin -> plugin_get_data: emergency!"));
x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: emergency!",
strlen((char*)buffer)) == 0, "Buffer EMERGENCY not correctly read");
+ memset(buffer, 0, READ_SIZE);
- ret = pclKeyReadData(0xFF, "language/info", 0, 0, buffer, READ_SIZE);
+ ret = pclKeyReadData(0xFF, "hwinfo", 0, 0, buffer, READ_SIZE);
+ //printf("B U F F E R - hwinfo: \"%s\" => ist: %d | soll: %d\n", buffer, ret, strlen("Custom plugin -> plugin_get_data: hwinfo!"));
x_fail_unless(ret != EPERS_NOT_INITIALIZED);
- //printf("B U F F E R - hwinfo: %s\n", buffer);
x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: hwinfo!",
strlen((char*)buffer)) == 0, "Buffer HWINFO not correctly read");
+ memset(buffer, 0, READ_SIZE);
- ret = pclKeyReadData(0xFF, "language/country_code_custom3", 0, 0, buffer, READ_SIZE);
- x_fail_unless(ret != EPERS_NOT_INITIALIZED);
- //printf("B U F F E R - hwinfo: %s\n", buffer);
+ ret = pclKeyReadData(0xFF, "custom2", 0, 0, buffer, READ_SIZE);
+ //printf("B U F F E R - custom2: \"%s\" => ist: %d | soll: %d\n", buffer, ret, strlen("Custom plugin -> plugin_get_data: custom2!"));
+ x_fail_unless(ret == strlen("Custom plugin -> plugin_get_data: custom2!"));
+ x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: custom2!",
+ strlen((char*)buffer)) == 0, "Buffer CUSTOM 2 not correctly read");
+ memset(buffer, 0, READ_SIZE);
+
+ ret = pclKeyReadData(0xFF, "custom3", 0, 0, buffer, READ_SIZE);
+ //printf("B U F F E R - custom3: \"%s\" => ist: %d | soll: %d\n", buffer, ret, strlen("Custom plugin -> plugin_get_data: custom3!"));
+ x_fail_unless(ret == strlen("Custom plugin -> plugin_get_data: custom3!"));
x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: custom3!",
- strlen((char*)buffer)) == 0, "Buffer CUSTOM 3 not correctly read");
+ strlen((char*)buffer)) == 0, "Buffer CUSTOM 3 not correctly read");
+ memset(buffer, 0, READ_SIZE);
+
#endif
pclDeinitLibrary();
}
@@ -950,13 +967,13 @@ START_TEST(test_ReadDefault)
x_fail_unless(ret <= 1, "Failed to init PCL");
#if 1
ret = pclKeyReadData(0xFF, "statusHandle/default01", 3, 2, buffer, READ_SIZE);
- x_fail_unless(ret != EPERS_NOT_INITIALIZED);
- //printf("B U F F E R: %s\n", buffer);
+ //printf(" --- test_ReadConfDefault => statusHandle/default01: %s => retIst: %d retSoll: %d\n", buffer, ret, strlen("DEFAULT_01!"));
+ x_fail_unless(ret == strlen("DEFAULT_01!"));
x_fail_unless(strncmp((char*)buffer,"DEFAULT_01!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
ret = pclKeyReadData(0xFF, "statusHandle/default02", 3, 2, buffer, READ_SIZE);
- x_fail_unless(ret != EPERS_NOT_INITIALIZED);
- //printf("B U F F E R: %s\n", buffer);
+ //printf(" --- test_ReadConfDefault => statusHandle/default02: %s => retIst: %d retSoll: %d\n", buffer, ret, strlen("DEFAULT_02!"));
+ x_fail_unless(ret == strlen("DEFAULT_02!"));
x_fail_unless(strncmp((char*)buffer,"DEFAULT_02!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
#endif
pclDeinitLibrary();
@@ -982,11 +999,13 @@ START_TEST(test_ReadConfDefault)
x_fail_unless(ret <= 1, "Failed to init PCL");
#if 1
ret = pclKeyReadData(0xFF, "statusHandle/confdefault01", 3, 2, buffer, READ_SIZE);
- x_fail_unless(ret != EPERS_NOT_INITIALIZED);
+ //printf(" --- test_ReadConfDefault => statusHandle/confdefault01: %s => retIst: %d retSoll: %d\n", buffer, ret, strlen("CONF_DEFAULT_01!"));
+ x_fail_unless(ret == strlen("CONF_DEFAULT_01!"));
x_fail_unless(strncmp((char*)buffer,"CONF_DEFAULT_01!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
ret = pclKeyReadData(0xFF, "statusHandle/confdefault02", 3, 2, buffer, READ_SIZE);
- x_fail_unless(ret != EPERS_NOT_INITIALIZED);
+ //printf(" --- test_ReadConfDefault => statusHandle/confdefault02: %s => retIst: %d retSoll: %d\n", buffer, ret, strlen("CONF_DEFAULT_02!"));
+ x_fail_unless(ret == strlen("CONF_DEFAULT_02!"));
x_fail_unless(strncmp((char*)buffer,"CONF_DEFAULT_02!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
#endif
pclDeinitLibrary();
@@ -1050,7 +1069,7 @@ END_TEST
START_TEST(test_NegHandle)
{
- int handle = -1, ret = 0;;
+ int handle = -1, ret = 0;
int negativeHandle = -17;
unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
@@ -1092,6 +1111,16 @@ END_TEST
+START_TEST(test_NodeHealthTest)
+{
+ unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+
+ (void)pclInitLibrary("node-health-monitor", shutdownReg);
+
+ pclDeinitLibrary();
+
+}
+END_TEST
@@ -1102,70 +1131,75 @@ static Suite * persistencyClientLib_suite()
TCase * tc_persGetData = tcase_create("GetData");
tcase_add_test(tc_persGetData, test_GetData);
- tcase_set_timeout(tc_persGetData, 8);
+ tcase_set_timeout(tc_persGetData, 1);
TCase * tc_persSetData = tcase_create("SetData");
tcase_add_test(tc_persSetData, test_SetData);
- tcase_set_timeout(tc_persSetData, 8);
+ tcase_set_timeout(tc_persSetData, 1);
TCase * tc_persSetDataNoPRCT = tcase_create("SetDataNoPRCT");
tcase_add_test(tc_persSetDataNoPRCT, test_SetDataNoPRCT);
- tcase_set_timeout(tc_persSetDataNoPRCT, 8);
+ tcase_set_timeout(tc_persSetDataNoPRCT, 1);
TCase * tc_persGetDataSize = tcase_create("GetDataSize");
tcase_add_test(tc_persGetDataSize, test_GetDataSize);
- tcase_set_timeout(tc_persGetDataSize, 8);
+ tcase_set_timeout(tc_persGetDataSize, 1);
TCase * tc_persDeleteData = tcase_create("DeleteData");
tcase_add_test(tc_persDeleteData, test_DeleteData);
- tcase_set_timeout(tc_persDeleteData, 8);
+ tcase_set_timeout(tc_persDeleteData, 1);
TCase * tc_persGetDataHandle = tcase_create("GetDataHandle");
tcase_add_test(tc_persGetDataHandle, test_GetDataHandle);
- tcase_set_timeout(tc_persGetDataHandle, 8);
+ tcase_set_timeout(tc_persGetDataHandle, 1);
TCase * tc_persDataHandle = tcase_create("DataHandle");
tcase_add_test(tc_persDataHandle, test_DataHandle);
- tcase_set_timeout(tc_persGetData, 8);
+ tcase_set_timeout(tc_persGetData, 1);
TCase * tc_persDataHandleOpen = tcase_create("DataHandleOpen");
tcase_add_test(tc_persDataHandleOpen, test_DataHandleOpen);
- tcase_set_timeout(tc_persDataHandleOpen, 8);
+ tcase_set_timeout(tc_persDataHandleOpen, 1);
TCase * tc_persDataFile = tcase_create("DataFile");
tcase_add_test(tc_persDataFile, test_DataFile);
- tcase_set_timeout(tc_persDataFile, 8);
+ tcase_set_timeout(tc_persDataFile, 1);
TCase * tc_persDataFileRecovery = tcase_create("DataFileRecovery");
tcase_add_test(tc_persDataFileRecovery, test_DataFileRecovery);
- tcase_set_timeout(tc_persDataFileRecovery, 8);
+ tcase_set_timeout(tc_persDataFileRecovery, 1);
TCase * tc_Plugin = tcase_create("Plugin");
tcase_add_test(tc_Plugin, test_Plugin);
- tcase_set_timeout(tc_Plugin, 8);
+ tcase_set_timeout(tc_Plugin, 1);
TCase * tc_ReadDefault = tcase_create("ReadDefault");
tcase_add_test(tc_ReadDefault, test_ReadDefault);
- tcase_set_timeout(tc_ReadDefault, 8);
+ tcase_set_timeout(tc_ReadDefault, 1);
TCase * tc_ReadConfDefault = tcase_create("ReadConfDefault");
tcase_add_test(tc_ReadConfDefault, test_ReadConfDefault);
- tcase_set_timeout(tc_ReadConfDefault, 8);
+ tcase_set_timeout(tc_ReadConfDefault, 1);
TCase * tc_GetPath = tcase_create("GetPath");
tcase_add_test(tc_GetPath, test_GetPath);
- tcase_set_timeout(tc_GetPath, 8);
+ tcase_set_timeout(tc_GetPath, 1);
TCase * tc_InitDeinit = tcase_create("InitDeinit");
tcase_add_test(tc_InitDeinit, test_InitDeinit);
- tcase_set_timeout(tc_InitDeinit, 8);
+ tcase_set_timeout(tc_InitDeinit, 1);
TCase * tc_NegHandle = tcase_create("NegHandle");
tcase_add_test(tc_NegHandle, test_NegHandle);
- tcase_set_timeout(tc_NegHandle, 8);
+ tcase_set_timeout(tc_NegHandle, 1);
+
+
+ TCase * tc_NodeHealthTest = tcase_create("NodeHealthTest");
+ tcase_add_test(tc_NodeHealthTest, test_NodeHealthTest);
suite_add_tcase(s, tc_persSetData);
suite_add_tcase(s, tc_persGetData);
+
suite_add_tcase(s, tc_persSetDataNoPRCT);
suite_add_tcase(s, tc_persGetDataSize);
suite_add_tcase(s, tc_persDeleteData);
@@ -1181,8 +1215,10 @@ static Suite * persistencyClientLib_suite()
suite_add_tcase(s, tc_NegHandle);
suite_add_tcase(s, tc_InitDeinit);
+ suite_add_tcase(s, tc_NodeHealthTest);
+
+ suite_add_tcase(s, tc_Plugin); // activate only if the plugins are available
- //suite_add_tcase(s, tc_Plugin); // activate only if the plugins are available
return s;
}