summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Huerner <ingo.huerner@xse.de>2015-03-27 09:42:36 +0100
committerIngo Huerner <ingo.huerner@xse.de>2015-03-27 09:42:36 +0100
commitbd5a8f2d569476f7627128e95f146673bd52e5fd (patch)
tree10515974e783ab581ae2295dbe6fdb271ace3df9
parent944899b3120d81649f0efc800de74935903d2851 (diff)
downloadpersistence-client-library-bd5a8f2d569476f7627128e95f146673bd52e5fd.tar.gz
Increased code coverage; removed obsolete code
-rw-r--r--Makefile.am3
-rw-r--r--config/pclCustomLibConfigFile.cfg7
-rw-r--r--src/persistence_client_library.c24
-rw-r--r--src/persistence_client_library_custom_loader.c2
-rw-r--r--src/persistence_client_library_dbus_service.c55
-rw-r--r--src/persistence_client_library_file.c14
-rw-r--r--src/persistence_client_library_handle.c4
-rw-r--r--src/persistence_client_library_key.c43
-rw-r--r--src/persistence_client_library_pas_interface.c53
-rw-r--r--src/persistence_client_library_pas_interface.h11
-rw-r--r--test/persistence_client_library_test.c165
11 files changed, 219 insertions, 162 deletions
diff --git a/Makefile.am b/Makefile.am
index 879898d..65b2df1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,7 +9,8 @@ endif
sysconfdir = "/etc/"
# Write the config file for customer plugins to the config destination
-sysconf_DATA = config/pclCustomLibConfigFile.cfg
+sysconf_DATA = config/pclCustomLibConfigFile.cfg \
+ config/pclCustomLibConfigFileEmpty.cfg
# Add config file to distribution
EXTRA_DIST = $(sysconf_DATA)
diff --git a/config/pclCustomLibConfigFile.cfg b/config/pclCustomLibConfigFile.cfg
index c9667d1..fe95ea0 100644
--- a/config/pclCustomLibConfigFile.cfg
+++ b/config/pclCustomLibConfigFile.cfg
@@ -1,7 +1,8 @@
hwinfo /usr/lib/libhwinfoperscustom.so init async
-secure /usr/lib/libsecureperscustom.so init sync
-custom3 /usr/lib/libcustom3perscustom.so od sync
+secure /usr/lib/libsecureperscustom.so od sync
+custom3 /usr/lib/libcustom3perscustom.so init sync
default /usr/lib/libpers_common.so.1 init sync
emergency /usr/lib/libemergencyperscustom.so od async
early /usr/lib/libearlyperscustom.so od sync
-custom2 /usr/lib/libcustom2perscustom.so init sync
+anInvalidEntry /wrongPath/wrongLib do cnys
+custom2 /usr/lib/libcustom2perscustom.so init sync \ No newline at end of file
diff --git a/src/persistence_client_library.c b/src/persistence_client_library.c
index ace9d5f..441def3 100644
--- a/src/persistence_client_library.c
+++ b/src/persistence_client_library.c
@@ -60,8 +60,7 @@ static int gAppCheckFlag = -1;
int customAsyncInitClbk(int errcode)
{
- (void)errcode;
- printf("Dummy async init Callback\n");
+ printf("Dummy async init Callback: %d\n", errcode);
return 1;
}
@@ -74,9 +73,10 @@ static int private_pclDeinitLibrary(void);
/* security check for valid application:
if the RCT table exists, the application is proven to be valid (trusted),
otherwise return EPERS_NOPRCTABLE */
+#if USE_APPCHECK
static void doInitAppcheck(const char* appName)
{
-#if USE_APPCHECK
+
char rctFilename[PERS_ORG_MAX_LENGTH_PATH_FILENAME] = {0};
snprintf(rctFilename, PERS_ORG_MAX_LENGTH_PATH_FILENAME, getLocalWtPathKey(), appName, plugin_gResTableCfg);
@@ -90,17 +90,15 @@ static void doInitAppcheck(const char* appName)
gAppCheckFlag = 0; // currently not a "trusted" application
DLT_LOG(gPclDLTContext, DLT_LOG_DEBUG, DLT_STRING("initLibrary - app check: "), DLT_STRING(appName), DLT_STRING("NOT trusted app"));
}
-#else
- (void)appName;
-#endif
}
+#endif
-
+#if USE_APPCHECK
int doAppcheck(void)
{
int trusted = 1;
-#if USE_APPCHECK
+
if(gAppCheckFlag != 1)
{
char rctFilename[PERS_ORG_MAX_LENGTH_PATH_FILENAME] = {0};
@@ -115,10 +113,9 @@ int doAppcheck(void)
trusted = 0;
}
}
-#endif
return trusted;
}
-
+#endif
int pclInitLibrary(const char* appName, int shutdownMode)
@@ -153,7 +150,10 @@ static int private_pclInitLibrary(const char* appName, int shutdownMode)
gShutdownMode = shutdownMode;
+#if USE_APPCHECK
doInitAppcheck(appName); // check if we have a trusted application
+#endif
+
#if USE_FILECACHE
DLT_LOG(gPclDLTContext, DLT_LOG_DEBUG, DLT_STRING("Using the filecache!!!"));
@@ -337,7 +337,7 @@ int pclLifecycleSet(int shutdown)
}
-
+#if 0
void pcl_test_send_shutdown_command()
{
const char* command = {"snmpset -v1 -c public 134.86.58.225 iso.3.6.1.4.1.1909.22.1.1.1.5.1 i 1"};
@@ -347,5 +347,5 @@ void pcl_test_send_shutdown_command()
printf("Failed to send shutdown command!!!!\n");
}
}
-
+#endif
diff --git a/src/persistence_client_library_custom_loader.c b/src/persistence_client_library_custom_loader.c
index 64c62a6..9890a91 100644
--- a/src/persistence_client_library_custom_loader.c
+++ b/src/persistence_client_library_custom_loader.c
@@ -303,7 +303,7 @@ int get_custom_libraries()
}
else
{
- DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("load custom library config file error ==> failed to stat() file"));
+ DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("load custom library config file error ==> failed to stat() file:"), DLT_STRING(filename));
rval = EPERS_COMMON;
}
return rval;
diff --git a/src/persistence_client_library_dbus_service.c b/src/persistence_client_library_dbus_service.c
index c3c2624..eee0561 100644
--- a/src/persistence_client_library_dbus_service.c
+++ b/src/persistence_client_library_dbus_service.c
@@ -106,24 +106,7 @@ static DBusHandlerResult handleObjectPathMessageFallback(DBusConnection * connec
DBusHandlerResult result = DBUS_HANDLER_RESULT_HANDLED;
(void)user_data;
- // org.genivi.persistence.admin S I G N A L
- if((0==strcmp(gDbusPersAdminInterface, dbus_message_get_interface(message))))
- {
- if(dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_SIGNAL)
- {
- if((0==strcmp("PersistenceModeChanged", dbus_message_get_member(message))))
- {
- // to do handle signal
- result = signal_persModeChange(connection, message);
- }
- else
- {
- DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("handleObjPathMsgFback - unknown sig:"), DLT_STRING(dbus_message_get_interface(message)) );
- }
- }
- }
- // org.genivi.persistence.admin S I G N A L
- else if((0==strcmp(gDbusPersAdminConsInterface, dbus_message_get_interface(message))))
+ if((0==strcmp(gDbusPersAdminConsInterface, dbus_message_get_interface(message))))
{
if(dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_SIGNAL)
{
@@ -194,42 +177,6 @@ static DBusHandlerResult handleObjectPathMessageFallback(DBusConnection * connec
}
}
}
- // org.genivi.persistence.admin P R O P E R T Y
- else if((0==strcmp("org.freedesktop.DBus.Properties", dbus_message_get_interface(message))))
- {
- if(dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_SIGNAL)
- {
- if((0==strcmp("EggDBusChanged", dbus_message_get_member(message))))
- {
- DBusMessageIter array;
- DBusMessageIter dict;
- DBusMessageIter variant;
-
- char* dictString = NULL;
- int value = 0;
-
- dbus_message_iter_open_container(&array, DBUS_TYPE_DICT_ENTRY, 0, &dict);
- dbus_message_iter_get_basic(&dict, &dictString);
-
- dbus_message_iter_open_container(&dict,DBUS_TYPE_VARIANT, NULL, &variant);
- dbus_message_iter_get_basic(&dict, &value);
-
- dbus_message_iter_close_container(&dict, &variant);
- dbus_message_iter_close_container(&array, &dict);
-
- // to do handle signal
- result = DBUS_HANDLER_RESULT_HANDLED;
- }
- else
- {
- DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("handleObjPathMsgFback - unknown property:"), DLT_STRING(dbus_message_get_interface(message)) );
- }
- }
- else
- {
- DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("handleObjPathMsgFback - not a signal:"), DLT_STRING(dbus_message_get_member(message)) );
- }
- }
return result;
}
diff --git a/src/persistence_client_library_file.c b/src/persistence_client_library_file.c
index 6f14777..bfe97dd 100644
--- a/src/persistence_client_library_file.c
+++ b/src/persistence_client_library_file.c
@@ -53,7 +53,9 @@ static int pclFileOpenDefaultData(PersistenceInfo_s* dbContext, const char* reso
static int pclFileOpenRegular(PersistenceInfo_s* dbContext, const char* resource_id,
char* dbKey, char* dbPath, int shared_DB, unsigned int user_no, unsigned int seat_no);
+#if USE_APPCHECK
extern int doAppcheck(void);
+#endif
char* get_raw_string(char* dbKey)
@@ -87,8 +89,10 @@ int pclFileClose(int fd)
if(__sync_add_and_fetch(&gPclInitCounter, 0) > 0)
{
+#if USE_APPCHECK
if(doAppcheck() == 1)
{
+#endif
int permission = get_file_permission(fd);
@@ -138,11 +142,13 @@ int pclFileClose(int fd)
{
rval = EPERS_MAXHANDLE;
}
+#if USE_APPCHECK
}
else
{
rval = EPERS_SHUTDOWN_NO_TRUSTED;
}
+#endif
}
return rval;
}
@@ -337,9 +343,7 @@ int pclFileOpenRegular(PersistenceInfo_s* dbContext, const char* resource_id, ch
}
}
}
-
- // requested resource is not in the RCT, so create resource as local/cached.
- else
+ else // requested resource is not in the RCT, so create resource as local/cached.
{
// assemble file string for local cached location
snprintf(dbPath, PERS_ORG_MAX_LENGTH_PATH_FILENAME, getLocalCacheFilePath(), gAppId, user_no, seat_no, resource_id);
@@ -750,9 +754,7 @@ int pclFileCreatePath(unsigned int ldbid, const char* resource_id, unsigned int
}
}
}
-
- // requested resource is not in the RCT, so create resource as local/cached.
- else
+ else // requested resource is not in the RCT, so create resource as local/cached.
{
// assemble file string for local cached location
snprintf(dbPath, PERS_ORG_MAX_LENGTH_PATH_FILENAME, getLocalCacheFilePath(), gAppId, user_no, seat_no, resource_id);
diff --git a/src/persistence_client_library_handle.c b/src/persistence_client_library_handle.c
index d9e1a78..e0c52d9 100644
--- a/src/persistence_client_library_handle.c
+++ b/src/persistence_client_library_handle.c
@@ -923,7 +923,7 @@ char* get_ossfile_checksum_path(int idx)
return charPtr;
}
-
+#if 0
void set_ossfile_backup_status(int idx, int status)
{
if(pthread_mutex_lock(&gOssFileHandleAccessMtx) == 0)
@@ -998,7 +998,7 @@ int get_ossfile_backup_status(int idx)
}
return rval;
}
-
+#endif
int remove_ossfile_handle_data(int idx)
{
diff --git a/src/persistence_client_library_key.c b/src/persistence_client_library_key.c
index 3591f91..5598e85 100644
--- a/src/persistence_client_library_key.c
+++ b/src/persistence_client_library_key.c
@@ -33,8 +33,9 @@ static int handleRegNotifyOnChange(int key_handle, pclChangeNotifyCallback_t cal
static int regNotifyOnChange(unsigned int ldbid, const char* resource_id, unsigned int user_no, unsigned int seat_no,
pclChangeNotifyCallback_t callback, PersNotifyRegPolicy_e regPolicy);
-
+#if USE_APPCHECK
extern int doAppcheck(void);
+#endif
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
@@ -48,8 +49,10 @@ int pclKeyHandleOpen(unsigned int ldbid, const char* resource_id, unsigned int u
if(__sync_add_and_fetch(&gPclInitCounter, 0) > 0)
{
+#if USE_APPCHECK
if(doAppcheck() == 1)
{
+#endif
PersistenceInfo_s dbContext;
char dbKey[PERS_DB_MAX_LENGTH_KEY_NAME] = {0}; // database key
@@ -77,11 +80,13 @@ int pclKeyHandleOpen(unsigned int ldbid, const char* resource_id, unsigned int u
{
DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("keyHandleOpen - no db context or res not a key "));
}
+#if USE_APPCHECK
}
else
{
handle = EPERS_SHUTDOWN_NO_TRUSTED;
}
+#endif
}
return handle;
@@ -95,8 +100,10 @@ int pclKeyHandleClose(int key_handle)
if(__sync_add_and_fetch(&gPclInitCounter, 0) > 0)
{
+#if USE_APPCHECK
if(doAppcheck() == 1)
{
+#endif
PersistenceKeyHandle_s persHandle;
if(get_key_handle_data(key_handle, &persHandle) != -1)
@@ -117,11 +124,13 @@ int pclKeyHandleClose(int key_handle)
{
rval = EPERS_MAXHANDLE;
}
+#if USE_APPCHECK
}
else
{
rval = EPERS_SHUTDOWN_NO_TRUSTED;
}
+#endif
}
return rval;
@@ -135,8 +144,10 @@ int pclKeyHandleGetSize(int key_handle)
if(__sync_add_and_fetch(&gPclInitCounter, 0) > 0)
{
+#if USE_APPCHECK
if(doAppcheck() == 1)
{
+#endif
PersistenceKeyHandle_s persHandle;
if(get_key_handle_data(key_handle, &persHandle) != -1)
@@ -155,11 +166,13 @@ int pclKeyHandleGetSize(int key_handle)
{
size = EPERS_MAXHANDLE;
}
+#if USE_APPCHECK
}
else
{
size = EPERS_SHUTDOWN_NO_TRUSTED;
}
+#endif
}
return size;
@@ -173,8 +186,10 @@ int pclKeyHandleReadData(int key_handle, unsigned char* buffer, int buffer_size)
if(__sync_add_and_fetch(&gPclInitCounter, 0) > 0)
{
+#if USE_APPCHECK
if(doAppcheck() == 1)
{
+#endif
PersistenceKeyHandle_s persHandle;
if(get_key_handle_data(key_handle, &persHandle) != -1)
@@ -194,11 +209,13 @@ int pclKeyHandleReadData(int key_handle, unsigned char* buffer, int buffer_size)
{
size = EPERS_MAXHANDLE;
}
+#if USE_APPCHECK
}
else
{
size = EPERS_SHUTDOWN_NO_TRUSTED;
}
+#endif
}
return size;
@@ -267,8 +284,10 @@ int pclKeyHandleWriteData(int key_handle, unsigned char* buffer, int buffer_size
if(__sync_add_and_fetch(&gPclInitCounter, 0) > 0)
{
+#if USE_APPCHECK
if(doAppcheck() == 1)
{
+#endif
PersistenceKeyHandle_s persHandle;
if(get_key_handle_data(key_handle, &persHandle) != -1)
@@ -287,11 +306,13 @@ int pclKeyHandleWriteData(int key_handle, unsigned char* buffer, int buffer_size
{
size = EPERS_MAXHANDLE;
}
+#if USE_APPCHECK
}
else
{
size = EPERS_SHUTDOWN_NO_TRUSTED;
}
+#endif
}
return size;
@@ -313,8 +334,10 @@ int pclKeyDelete(unsigned int ldbid, const char* resource_id, unsigned int user_
if(__sync_add_and_fetch(&gPclInitCounter, 0) > 0)
{
+#if USE_APPCHECK
if(doAppcheck() == 1)
{
+#endif
if(AccessNoLock != isAccessLocked() ) // check if access to persistent data is locked
{
PersistenceInfo_s dbContext;
@@ -345,11 +368,13 @@ int pclKeyDelete(unsigned int ldbid, const char* resource_id, unsigned int user_
{
rval = EPERS_LOCKFS;
}
+#if USE_APPCHECK
}
else
{
rval = EPERS_SHUTDOWN_NO_TRUSTED;
}
+#endif
}
return rval;
@@ -363,8 +388,10 @@ int pclKeyGetSize(unsigned int ldbid, const char* resource_id, unsigned int user
if(__sync_add_and_fetch(&gPclInitCounter, 0) > 0)
{
+#if USE_APPCHECK
if(doAppcheck() == 1)
{
+#endif
PersistenceInfo_s dbContext;
char dbKey[PERS_DB_MAX_LENGTH_KEY_NAME] = {0}; // database key
@@ -392,11 +419,13 @@ int pclKeyGetSize(unsigned int ldbid, const char* resource_id, unsigned int user
{
data_size = EPERS_BADPOL;
}
+#if USE_APPCHECK
}
else
{
data_size = EPERS_SHUTDOWN_NO_TRUSTED;
}
+#endif
}
return data_size;
@@ -411,8 +440,10 @@ int pclKeyReadData(unsigned int ldbid, const char* resource_id, unsigned int use
if(__sync_add_and_fetch(&gPclInitCounter, 0) > 0)
{
+#if USE_APPCHECK
if(doAppcheck() == 1)
{
+#endif
if(AccessNoLock != isAccessLocked() ) // check if access to persistent data is locked
{
PersistenceInfo_s dbContext;
@@ -448,11 +479,13 @@ int pclKeyReadData(unsigned int ldbid, const char* resource_id, unsigned int use
{
data_size = EPERS_LOCKFS;
}
+#if USE_APPCHECK
}
else
{
data_size = EPERS_SHUTDOWN_NO_TRUSTED;
}
+#endif
}
return data_size;
@@ -467,8 +500,10 @@ int pclKeyWriteData(unsigned int ldbid, const char* resource_id, unsigned int us
if(__sync_add_and_fetch(&gPclInitCounter, 0) > 0)
{
+#if USE_APPCHECK
if(doAppcheck() == 1)
{
+#endif
if(AccessNoLock != isAccessLocked() ) // check if access to persistent data is locked
{
if(buffer_size <= gMaxKeyValDataSize) // check data size
@@ -527,11 +562,13 @@ int pclKeyWriteData(unsigned int ldbid, const char* resource_id, unsigned int us
{
data_size = EPERS_LOCKFS;
}
+#if USE_APPCHECK
}
else
{
data_size = EPERS_SHUTDOWN_NO_TRUSTED;
}
+#endif
}
return data_size;
}
@@ -570,8 +607,10 @@ int regNotifyOnChange(unsigned int ldbid, const char* resource_id, unsigned int
if(__sync_add_and_fetch(&gPclInitCounter, 0) > 0)
{
+#if USE_APPCHECK
if(doAppcheck() == 1)
{
+#endif
PersistenceInfo_s dbContext;
// unsigned int hash_val_data = 0;
@@ -606,11 +645,13 @@ int regNotifyOnChange(unsigned int ldbid, const char* resource_id, unsigned int
DLT_STRING("regNotifyOnChange - Not possible! get_db_context() returned:"),
DLT_INT(rval));
}
+#if USE_APPCHECK
}
else
{
rval = EPERS_SHUTDOWN_NO_TRUSTED;
}
+#endif
}
return rval;
diff --git a/src/persistence_client_library_pas_interface.c b/src/persistence_client_library_pas_interface.c
index b60418b..d40bb56 100644
--- a/src/persistence_client_library_pas_interface.c
+++ b/src/persistence_client_library_pas_interface.c
@@ -145,59 +145,6 @@ DBusHandlerResult msg_persAdminRequest(DBusConnection *connection, DBusMessage *
-int signal_persModeChange(DBusConnection *connection, DBusMessage *message)
-{
- int persistenceMode = 0, errorCode = 0;
-
- DBusMessage *reply;
- DBusError error;
- dbus_error_init (&error);
-
- if (!dbus_message_get_args (message, &error, DBUS_TYPE_INT32 , &persistenceMode,
- DBUS_TYPE_INVALID))
- {
- reply = dbus_message_new_error(message, error.name, error.message);
-
- if(reply == 0)
- {
- DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("sigPersMoChng - DBus No mem"));
- }
-
- if (!dbus_connection_send(connection, reply, 0))
- {
- DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("sigPersMoChng - DBus No mem"));
- }
-
- dbus_message_unref(reply);
-
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- }
-
- reply = dbus_message_new_method_return(message);
-
- if (reply == 0)
- {
- DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("sigPersMoChng - DBus No mem"));
- }
-
- if (!dbus_message_append_args(reply, DBUS_TYPE_INT32, &errorCode, DBUS_TYPE_INVALID))
- {
- DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("sigPersMoChng - DBus No mem"));
- }
-
- if (!dbus_connection_send(connection, reply, 0))
- {
- DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("sigPersMoChng - DBus No mem"));
- }
-
- dbus_connection_flush(connection);
- dbus_message_unref(reply);
-
- return DBUS_HANDLER_RESULT_HANDLED;
-}
-
-
-
DBusHandlerResult checkPersAdminMsg(DBusConnection * connection, DBusMessage * message, void * user_data)
{
DBusHandlerResult result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
diff --git a/src/persistence_client_library_pas_interface.h b/src/persistence_client_library_pas_interface.h
index 9a76a35..617ca79 100644
--- a/src/persistence_client_library_pas_interface.h
+++ b/src/persistence_client_library_pas_interface.h
@@ -35,17 +35,6 @@
DBusHandlerResult checkPersAdminMsg(DBusConnection * connection, DBusMessage * message, void * user_data);
-/**
- * @brief Check if the persMode changed signal has been received
- *
- * @param connection the debus connection
- * @param message the dbus message
- *
- * @return DBUS_HANDLER_RESULT_HANDLED or DBUS_HANDLER_RESULT_NOT_YET_HANDLED
- */
-int signal_persModeChange(DBusConnection *connection, DBusMessage *message);
-
-
/// lock access to persistence data
void pers_lock_access(void);
diff --git a/test/persistence_client_library_test.c b/test/persistence_client_library_test.c
index 6a32a19..b92aed4 100644
--- a/test/persistence_client_library_test.c
+++ b/test/persistence_client_library_test.c
@@ -24,7 +24,7 @@
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
-
+#include <dbus/dbus.h>
#include <dlt/dlt.h>
#include <dlt/dlt_common.h>
@@ -70,6 +70,14 @@ void data_setup_browser(void)
}
+void data_setup_norct(void)
+{
+ unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+
+ (void)pclInitLibrary("norct", shutdownReg);
+}
+
+
void data_teardown(void)
{
pclDeinitLibrary();
@@ -180,6 +188,8 @@ START_TEST(test_GetData)
fail_unless(ret == strlen("CACHE_ /last_exit/queens"));
memset(buffer, 0, READ_SIZE);
+
+
#endif
}
@@ -758,6 +768,12 @@ START_TEST(test_DataFile)
pclFileClose(fdArray[i]);
}
+ // write to file not in RCT
+ fd = pclFileOpen(PCL_LDBID_LOCAL, "nonRCT/aNonRctFile.db", 1, 1);
+ size = pclFileGetSize(fd);
+ size = pclFileWriteData(fd, "nonRCT/mediaDB.db", strlen("nonRCT/mediaDB.db"));
+
+
free(writeBuffer);
#endif
}
@@ -1421,6 +1437,9 @@ START_TEST(test_NegHandle)
ret = pclKeyHandleRegisterNotifyOnChange(negativeHandle, &myChangeCallback);
fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleRegisterNotifyOnChange => negative handle not detected");
+ ret = pclKeyHandleUnRegisterNotifyOnChange(negativeHandle, &myChangeCallback);
+ fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleUnRegisterNotifyOnChange => negative handle not detected");
+
ret = pclKeyHandleWriteData(negativeHandle, (unsigned char*)"Whatever", strlen("Whatever"));
fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleWriteData => negative handle not detected");
@@ -1555,21 +1574,74 @@ END_TEST
-START_TEST(test_DbusInterface)
+
+START_TEST(test_PAS_DbusInterface)
{
- /* X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
- X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
- X_TEST_REPORT_REFERENCE("NONE");
- X_TEST_REPORT_DESCRIPTION("Test dbus interface");
- X_TEST_REPORT_TYPE(GOOD); */
+ // let the administration servis generate a message to the PCL
+ if(system("/usr/local/bin/persadmin_tool export /tmp/myBackup 0") == -1)
+ {
+ printf("Failed to execute command -> admin service!!\n");
+ }
+}
+END_TEST
+
+
- // This test just keeps the PCL "alive" as long as the dbus is beeing tested by sending
- // signals from external to test the dbus interface
+START_TEST(test_LC_DbusInterface)
+{
+
+// send the following dbus command
+//
+ printf("\n\n*******************************************************\n");
+ printf("Past and execute NOW the following command to a console: \"dbus-send --system --print-reply --dest=org.genivi.NodeStateManager /org/genivi/NodeStateManager/LifecycleControl org.genivi.NodeStateManager.LifecycleControl.SetNodeState int32:6\"\n");
+ printf("*******************************************************\n\n");
- // run the following test commands:
- // - /home/ihuerner/development/GENIVI/persistence-administrator/test/persadmin_tool/persadmin_tool export /home/ihuerner/tmp/myBackup 0
+#if 0
+#if 0
+ const char* theDbusCommand =
+ "dbus-send --system --print-reply \
+ --dest=org.genivi.NodeStateManager \
+ /org/genivi/NodeStateManager/LifecycleControl \
+ \"org.genivi.NodeStateManager.LifecycleControl.SetNodeState\" \
+ int32:6";
+
+ // notify the NSM to shutdown the system
+ if(system(theDbusCommand) == -1)
+ {
+ printf("Failed to execute command -> NSM!!\n");
+ }
+#else
+ int nodeState = 6; // shutdown state
+ DBusConnection* conn = NULL;
+ DBusError err;
+
+ dbus_error_init(&err);
+ conn = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err);
+
+ DBusMessage* message = dbus_message_new_method_call("org.genivi.NodeStateManager", // destination
+ "/org/genivi/NodeStateManager/LifecycleControl", // path
+ "org.genivi.NodeStateManager.LifecycleControl", // interface
+ "SetNodeState"); // method
+
+ dbus_message_append_args(message, DBUS_TYPE_INT32, &nodeState, DBUS_TYPE_INVALID);
+
+ printf("*************************** ==> Send message and block\n");
+ if(!dbus_connection_send_with_reply_and_block(conn, message, 5000, &err))
+ {
+ printf("connection send: - Access denied: %s\n", err.message);
+ }
+ dbus_connection_flush(conn);
+ dbus_message_unref(message);
+ printf("*************************** <== \n");
+
+ dbus_connection_close(conn);
+ dbus_connection_unref(conn);
+#endif
+#else
- sleep(5);
+ sleep(6);
+
+#endif
}
END_TEST
@@ -1811,6 +1883,44 @@ END_TEST
+START_TEST(test_NoRct)
+{
+ int ret = 0;
+ const char writeBuffer[] = "This is a test string";
+
+ ret = pclKeyWriteData(PCL_LDBID_LOCAL, "someResourceId", 0, 0, (unsigned char*)writeBuffer, strlen(writeBuffer));
+ fail_unless(ret == EPERS_NOPRCTABLE, "RCT available, but should not");
+}
+END_TEST
+
+
+
+START_TEST(test_InvalidPluginfConf)
+{
+ unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+ const char* envVariable = "PERS_CLIENT_LIB_CUSTOM_LOAD";
+
+ // change to an invalid plugin configuration file using environment variable
+ setenv(envVariable, "/tmp/whatever/pclCustomLibConfigFile.cfg", 1);
+
+ (void)pclInitLibrary(gTheAppId, shutdownReg); // use the app id, the resource is registered for
+
+ pclDeinitLibrary();
+
+
+ // change to an empty plugin configuration file using environment variable
+ setenv(envVariable, "/etc/pclCustomLibConfigFileEmpty.cfg", 1);
+
+ (void)pclInitLibrary(gTheAppId, shutdownReg); // use the app id, the resource is registered for
+
+ pclDeinitLibrary();
+
+
+
+ (void)unsetenv(envVariable);
+}
+END_TEST
+
static Suite * persistencyClientLib_suite()
{
const char* testSuiteName = "Persistency_client_library";
@@ -1909,8 +2019,11 @@ static Suite * persistencyClientLib_suite()
tcase_set_timeout(tc_ValidApplication, 2);
#endif
- TCase * tc_DbusInterface = tcase_create("DbusInterface");
- tcase_add_test(tc_DbusInterface, test_DbusInterface);
+ TCase * tc_PAS_DbusInterface = tcase_create("PAS_DbusInterface");
+ tcase_add_test(tc_PAS_DbusInterface, test_PAS_DbusInterface);
+
+ TCase * tc_LC_DbusInterface = tcase_create("LC_DbusInterface");
+ tcase_add_test(tc_LC_DbusInterface, test_LC_DbusInterface);
TCase * tc_VerifyROnly = tcase_create("VerifyROnly");
tcase_add_test(tc_VerifyROnly, test_VerifyROnly);
@@ -1927,6 +2040,11 @@ static Suite * persistencyClientLib_suite()
tcase_add_test(tc_FileTest, test_FileTest);
tcase_set_timeout(tc_FileTest, 2);
+ TCase * tc_NoRct = tcase_create("NoRct");
+ tcase_add_test(tc_NoRct, test_NoRct);
+
+ TCase * tc_InvalidPluginfConf = tcase_create("InvalidPluginfConf");
+ tcase_add_test(tc_InvalidPluginfConf, test_InvalidPluginfConf);
suite_add_tcase(s, tc_persSetData);
tcase_add_checked_fixture(tc_persSetData, data_setup, data_teardown);
@@ -1998,15 +2116,26 @@ static Suite * persistencyClientLib_suite()
tcase_add_checked_fixture(tc_FileTest, data_setup_browser, data_teardown);
+
+ suite_add_tcase(s, tc_InvalidPluginfConf);
+
+ suite_add_tcase(s, tc_InitDeinit);
+
#if USE_APPCHECK
suite_add_tcase(s, tc_ValidApplication);
+#else
+ suite_add_tcase(s, tc_NoRct);
+ tcase_add_checked_fixture(tc_NoRct, data_setup_norct, data_teardown);
#endif
- suite_add_tcase(s, tc_InitDeinit);
+
+ suite_add_tcase(s, tc_PAS_DbusInterface);
+ tcase_add_checked_fixture(tc_PAS_DbusInterface, data_setup, data_teardown);
+ tcase_set_timeout(tc_PAS_DbusInterface, 10);
#if 0
- suite_add_tcase(s, tc_DbusInterface);
- tcase_add_checked_fixture(tc_DbusInterface, data_setup, data_teardown);
- tcase_set_timeout(tc_DbusInterface, 10);
+ suite_add_tcase(s, tc_LC_DbusInterface);
+ tcase_add_checked_fixture(tc_LC_DbusInterface, data_setup, data_teardown);
+ tcase_set_timeout(tc_LC_DbusInterface, 8);
#endif
return s;