summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Huerner <ingo.huerner@xse.de>2014-07-09 15:32:59 +0200
committerIngo Huerner <ingo.huerner@xse.de>2014-07-09 15:32:59 +0200
commitc2b8dbd1a8cc3b7a2edd57beb8f548e5f890dc5b (patch)
tree889bbb42b9b0243c352883af5e28c563d3ff7236
parent4680fad3bd70ee363838ceb74c0259e5718be3fa (diff)
downloadpersistence-client-library-c2b8dbd1a8cc3b7a2edd57beb8f548e5f890dc5b.tar.gz
Fixed a problem with getting the size of the default data; extended tests to increase code coverage
-rw-r--r--README80
-rw-r--r--src/Makefile.am3
-rw-r--r--src/persistence_client_library_db_access.c19
-rw-r--r--src/persistence_client_library_db_access.h5
-rw-r--r--src/persistence_client_library_key.c11
-rw-r--r--src/rbtree.c81
-rw-r--r--src/rbtree.h18
-rw-r--r--test/Makefile.am3
-rw-r--r--test/data/PAS_data.tar.gzbin5843 -> 5918 bytes
-rw-r--r--test/persistence_client_library_test.c125
-rw-r--r--test/persistence_test_customlib.c10
11 files changed, 194 insertions, 161 deletions
diff --git a/README b/README
index e9f7675..3dbac83 100644
--- a/README
+++ b/README
@@ -1,83 +1,13 @@
----------------------------
-Environment
-----------------------------
-The Persistence Client Library has been developed using Ubuntu 11.10
-Required packages
-
-- automotive-dlt: available via GENIVI projects
-- Itzam/C: download from http://www.coyotegulch.com/products/itzam/c/index.html
- In order to work with the PCL package config replace in the Itzam/C configure.ac GENERIC_LIBRARY_NAME=libitzam with GENERIC_LIBRARY_NAME=itzam
- copy itzam package confiuration file libitzam.pc into folder /usr/local/lib/pkgconfig
- There is an error like: "aclocal: couldn't open directory `m4': No such file or directory" just create the 'm4' directory
- Autotools will also complain that COPYING, NEWS, README and AUTHORS file is missing, just create also these files
--dbus-1: install via Synaptic Package Manger or use apt-get
-- autotools: install via Synaptic Package Manger or use apt-get
-- libtool: install via Synaptic Package Manger or use apt-get
-- GNU c compiler: install via Synaptic Package Manger or use apt-get
-
-----------------------------
Documentation
----------------------------
-http://projects.genivi.org/persistence-client-library/documentation
-
-----------------------------
-How to compile
-----------------------------
-For the Persistence Client Library autotools will be used to generate makefiles.
-To build the client library perform the following steps:
-
- "autoreconf -vi"
- "./configure --enable-test"
- --enable-test will be needed to enable the building of the test code
- "make"
-
-
-----------------------------
-How to run
-----------------------------
-
-- Simulation of required dbus interfaces
-The PCL requires to communicate with the lifcycle and the persistence administration service dbus interface.
-As this components may not yet available on you platform the PCL brings to mockup applications simulation this two interfaces.
-The two applications are located in the test folder:
-
- persistence_lifeCycle_mockup
- persistence_admin_service_mockup
-
-You need to register the admin service and the lifecycle dbus interface.
-for this just copy the service files (org.genivi.NodeStateManager.conf and org.genivi.persistence.admin.conf) into /ets/dbus-1/system.d/ folder.
-
-The Lifecycle service file can be found in the NodeStateManager gir repo the folder /NodeStateManager/config/.
-For the Pers Admin Service the following service file can be used.
-
-- Run the test application
-After building the client library and the test code the test data needs to be copied to the appropriate place.
-The test data is located in the test subdirectory test/data/Data.tar.gz and needs be extracted to the root/Data folder.
-The data structure must look like similar like this, section Data organization.
-
-
-Now run the test application ./persistence_client_library_test.
-The output should look like the following:
-100%: Checks: 10, Failures: 0, Errors: 0
-persistence_client_library_test.c:85:P:GetData:test_GetData:0: Passed
-persistence_client_library_test.c:206:P:SetData:test_SetData:0: Passed
-persistence_client_library_test.c:236:P:SetDataNoPRCT:test_SetDataNoPRCT:0: Passed
-persistence_client_library_test.c:252:P:GetDataSize:test_GetDataSize:0: Passed
-persistence_client_library_test.c:274:P:DeleteData:test_DeleteData:0: Passed
-persistence_client_library_test.c:148:P:GetDataHandle:test_GetDataHandle:0: Passed
-persistence_client_library_test.c:396:P:DataHandle:test_DataHandle:0: Passed
-persistence_client_library_test.c:462:P:DataHandleOpen:test_DataHandleOpen:0: Passed
-persistence_client_library_test.c:360:P:DataFile:test_DataFile:0: Passed
-persistence_client_library_test.c:528:P:Cursor:test_Cursor:0: Passed
-
+For details about the Persistence Client Library, please refer to to following documents:
-If there are also some error messages like:
-process 19908: arguments to dbus_message_get_args() were incorrect, assertion "message != NULL" failed in file ../../dbus/dbus-message.c line 1848.
-This is normally a bug in some application using the D-Bus library.
+- Persistence Client Library Architecture Documentation:
+ http://docs.projects.genivi.org/persistence-client-library/1.0/GENIVI_Persistence_ArchitectureDocumentation.pdf
-This is OK unless lifecycle management and the persistence administration service are not running.
-The persistence client library registers to lifecycle management and the persistence administration service.
-If the components are not available and do not respond to the dbus register message, the error message above will be created.
+- Persistence Client Library User Manual:
+ http://docs.projects.genivi.org/persistence-client-library/1.0/GENIVI_Persistence_Client_Library_UserManual.pdf
----------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 7a2248a..26248f0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,8 +2,7 @@ AUTOMAKE_OPTIONS = foreign
if DEBUG
-AM_CFLAGS = $(DEPS_CFLAGS) -g -I../include \
- -Idbus-1.0
+AM_CFLAGS = -fprofile-arcs -ftest-coverage $(DEPS_CFLAGS) -g -I../include -Idbus-1.0
else
AM_CFLAGS = $(DEPS_CFLAGS) -I../include -Idbus-1.0
#AM_CFLAGS = -fprofile-arcs -ftest-coverage $(DEPS_CFLAGS) -I../include -Idbus-1.0
diff --git a/src/persistence_client_library_db_access.c b/src/persistence_client_library_db_access.c
index 2749882..cad0e5d 100644
--- a/src/persistence_client_library_db_access.c
+++ b/src/persistence_client_library_db_access.c
@@ -43,6 +43,7 @@ static int gHandlesDBCreated[DbTableSize][PersistencePolicy_LastEntry] = { {0} }
int pers_send_Notification_Signal(const char* key, PersistenceDbContext_s* context, unsigned int reason);
+#if 0
char* pers_get_raw_key(char *key)
{
char *temp = NULL;
@@ -57,7 +58,7 @@ char* pers_get_raw_key(char *key)
return rawKey;
}
-
+#endif
int pers_db_open_default(const char* dbPath, PersDefaultType_e DefaultType)
{
@@ -229,7 +230,7 @@ static int database_get(PersistenceInfo_s* info, const char* dbPath)
return handleDB;
}
-
+#if 0
void database_close(PersistenceInfo_s* info)
{
int arrayIdx = info->configKey.storage + info->context.ldbid;
@@ -251,7 +252,7 @@ void database_close(PersistenceInfo_s* info)
DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("database_close ==> invalid storage type"), DLT_INT(info->context.ldbid ));
}
}
-
+#endif
void database_close_all()
{
int i = 0;
@@ -378,9 +379,8 @@ int persistence_get_data(char* dbPath, char* key, const char* resourceID, Persis
info->configKey.policy = PersistencePolicy_wc; /* Set the policy */
info->configKey.type = PersistenceResourceType_key; /* Set the type */
(void)get_db_path_and_key(info, key, NULL, dbPath);
- DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("Plugin data not available. Try to get default data of key:"),
- DLT_STRING(key));
- ret_defaults = pers_get_defaults(dbPath, key, buffer, buffer_size, PersGetDefault_Data);
+ DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("Plugin data not available. Try to get default data of key:"), DLT_STRING(key));
+ ret_defaults = pers_get_defaults(dbPath, (char*)resourceID, buffer, buffer_size, PersGetDefault_Data);
if (0 < ret_defaults)
{
read_size = ret_defaults;
@@ -508,7 +508,7 @@ int persistence_set_data(char* dbPath, char* key, PersistenceInfo_s* info, unsig
-int persistence_get_data_size(char* dbPath, char* key, PersistenceInfo_s* info)
+int persistence_get_data_size(char* dbPath, char* key, const char* resourceID, PersistenceInfo_s* info)
{
int read_size = -1;
int ret_defaults = -1;
@@ -519,10 +519,11 @@ int persistence_get_data_size(char* dbPath, char* key, PersistenceInfo_s* info)
int handleDB = database_get(info, dbPath);
if(handleDB >= 0)
{
+
read_size = persComDbGetKeySize(handleDB, key);
if(read_size < 0)
{
- read_size = pers_get_defaults(dbPath, key, NULL, 0, PersGetDefault_Size);
+ read_size = pers_get_defaults( dbPath, (char*)resourceID, NULL, 0, PersGetDefault_Size);
}
}
}
@@ -595,7 +596,7 @@ int persistence_get_data_size(char* dbPath, char* key, PersistenceInfo_s* info)
(void)get_db_path_and_key(info, key, NULL, dbPath);
DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("Plugin data not available. Try to get size of default data for key:"),
DLT_STRING(key));
- ret_defaults = pers_get_defaults(dbPath, key, NULL, 0, PersGetDefault_Size);
+ ret_defaults = pers_get_defaults(dbPath, (char*)resourceID, NULL, 0, PersGetDefault_Size);
if (0 < ret_defaults)
{
read_size = ret_defaults;
diff --git a/src/persistence_client_library_db_access.h b/src/persistence_client_library_db_access.h
index dc80496..3f3e6b7 100644
--- a/src/persistence_client_library_db_access.h
+++ b/src/persistence_client_library_db_access.h
@@ -115,12 +115,13 @@ int persistence_get_data(char* dbPath, char* key, const char* resourceID, Persis
*
* @param dbPath the path to the database where the key is in
* @param key the database key
+ * @param resourceID the resource id
* @param info persistence information
*
* @return size of data in bytes read from the key or on error a negative value with the following error codes:
* EPERS_NOPRCTABLE or EPERS_NOKEY
*/
-int persistence_get_data_size(char* dbPath, char* key, PersistenceInfo_s* info);
+int persistence_get_data_size(char* dbPath, char* key, const char* resourceID, PersistenceInfo_s* info);
@@ -143,7 +144,7 @@ int persistence_delete_data(char* dbPath, char* key, PersistenceInfo_s* info);
*
* @param info persistence information
*/
-void database_close(PersistenceInfo_s* info);
+//void database_close(PersistenceInfo_s* info);
diff --git a/src/persistence_client_library_key.c b/src/persistence_client_library_key.c
index 3540251..c73cf4c 100644
--- a/src/persistence_client_library_key.c
+++ b/src/persistence_client_library_key.c
@@ -49,7 +49,7 @@ int pclKeyHandleOpen(unsigned int ldbid, const char* resource_id, unsigned int u
{
PersistenceInfo_s dbContext;
- char dbKey[DbKeyMaxLen] = {0}; // database key
+ char dbKey[DbKeyMaxLen] = {0}; // database key
char dbPath[DbPathMaxLen] = {0}; // database location
dbContext.context.ldbid = ldbid;
@@ -338,7 +338,7 @@ int pclKeyGetSize(unsigned int ldbid, const char* resource_id, unsigned int user
{
if( dbContext.configKey.storage < PersistenceStorage_LastEntry) // check if store policy is valid
{
- data_size = persistence_get_data_size(dbPath, dbKey, &dbContext);
+ data_size = persistence_get_data_size(dbPath, dbKey, resource_id, &dbContext);
}
else
{
@@ -529,11 +529,8 @@ int regNotifyOnChange(unsigned int ldbid, const char* resource_id, unsigned int
}
else
{
- DLT_LOG(gPclDLTContext, DLT_LOG_ERROR,
- DLT_STRING("regNotifyOnChange: Not allowed! Resource is local or it is a file:"),
- DLT_STRING(resource_id),
- DLT_STRING("LDBID:"),
- DLT_UINT(ldbid));
+ DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("regNotifyOnChange: Not allowed! Resource is local or it is a file:"),
+ DLT_STRING(resource_id), DLT_STRING("LDBID:"), DLT_UINT(ldbid));
rval = EPERS_NOTIFY_NOT_ALLOWED;
}
}
diff --git a/src/rbtree.c b/src/rbtree.c
index a1439f8..7107979 100644
--- a/src/rbtree.c
+++ b/src/rbtree.c
@@ -193,44 +193,6 @@ jsw_rbtree_t *jsw_rbnew ( cmp_f cmp, dup_f dup, rel_f rel )
return rt;
}
-/**
- <summary>
- Releases a valid red black tree
- <summary>
- <param name="tree">The tree to release</param>
- <remarks>
- The tree must have been created using jsw_rbnew
- </remarks>
-*/
-void jsw_rbdelete ( jsw_rbtree_t *tree )
-{
- jsw_rbnode_t *it = tree->root;
- jsw_rbnode_t *save;
-
- /*
- Rotate away the left links so that
- we can treat this like the destruction
- of a linked list
- */
- while ( it != NULL ) {
- if ( it->link[0] == NULL ) {
- /* No left links, just kill the node and move on */
- save = it->link[1];
- tree->rel ( it->data );
- free ( it );
- }
- else {
- /* Rotate away the left link and check again */
- save = it->link[0];
- it->link[0] = save->link[1];
- save->link[1] = it;
- }
-
- it = save;
- }
-
- free ( tree );
-}
/**
<summary>
@@ -363,6 +325,47 @@ int jsw_rbinsert ( jsw_rbtree_t *tree, void *data )
return 1;
}
+#if 0
+/**
+ <summary>
+ Releases a valid red black tree
+ <summary>
+ <param name="tree">The tree to release</param>
+ <remarks>
+ The tree must have been created using jsw_rbnew
+ </remarks>
+*/
+void jsw_rbdelete ( jsw_rbtree_t *tree )
+{
+ jsw_rbnode_t *it = tree->root;
+ jsw_rbnode_t *save;
+
+ /*
+ Rotate away the left links so that
+ we can treat this like the destruction
+ of a linked list
+ */
+ while ( it != NULL ) {
+ if ( it->link[0] == NULL ) {
+ /* No left links, just kill the node and move on */
+ save = it->link[1];
+ tree->rel ( it->data );
+ free ( it );
+ }
+ else {
+ /* Rotate away the left link and check again */
+ save = it->link[0];
+ it->link[0] = save->link[1];
+ save->link[1] = it;
+ }
+
+ it = save;
+ }
+
+ free ( tree );
+}
+
+
/**
<summary>
Remove a node from a red black tree
@@ -632,4 +635,4 @@ void *jsw_rbtprev ( jsw_rbtrav_t *trav )
}
-
+#endif
diff --git a/src/rbtree.h b/src/rbtree.h
index 81d8ed0..429be29 100644
--- a/src/rbtree.h
+++ b/src/rbtree.h
@@ -77,19 +77,19 @@ typedef void (*rel_f) ( void *p );
/* Red Black tree functions */
jsw_rbtree_t *jsw_rbnew ( cmp_f cmp, dup_f dup, rel_f rel );
-void jsw_rbdelete ( jsw_rbtree_t *tree );
+//void jsw_rbdelete ( jsw_rbtree_t *tree );
void *jsw_rbfind ( jsw_rbtree_t *tree, void *data );
int jsw_rbinsert ( jsw_rbtree_t *tree, void *data );
-int jsw_rberase ( jsw_rbtree_t *tree, void *data );
-size_t jsw_rbsize ( jsw_rbtree_t *tree );
+//int jsw_rberase ( jsw_rbtree_t *tree, void *data );
+//size_t jsw_rbsize ( jsw_rbtree_t *tree );
/* Traversal functions */
-jsw_rbtrav_t *jsw_rbtnew ( void );
-void jsw_rbtdelete ( jsw_rbtrav_t *trav );
-void *jsw_rbtfirst ( jsw_rbtrav_t *trav, jsw_rbtree_t *tree );
-void *jsw_rbtlast ( jsw_rbtrav_t *trav, jsw_rbtree_t *tree );
-void *jsw_rbtnext ( jsw_rbtrav_t *trav );
-void *jsw_rbtprev ( jsw_rbtrav_t *trav );
+//jsw_rbtrav_t *jsw_rbtnew ( void );
+//void jsw_rbtdelete ( jsw_rbtrav_t *trav );
+//void *jsw_rbtfirst ( jsw_rbtrav_t *trav, jsw_rbtree_t *tree );
+//void *jsw_rbtlast ( jsw_rbtrav_t *trav, jsw_rbtree_t *tree );
+//void *jsw_rbtnext ( jsw_rbtrav_t *trav );
+//void *jsw_rbtprev ( jsw_rbtrav_t *trav );
#ifdef __cplusplus
}
diff --git a/test/Makefile.am b/test/Makefile.am
index b9a33d3..627b149 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,7 +1,8 @@
AUTOMAKE_OPTIONS = foreign
if DEBUG
-AM_CFLAGS =$(DEPS_CFLAGS) $(CHECK_CFLAGS) -g
+AM_CFLAGS = $(DEPS_CFLAGS) $(CHECK_CFLAGS) -g
+#AM_CFLAGS = -fprofile-arcs -ftest-coverage $(DEPS_CFLAGS) $(CHECK_CFLAGS) -g
else
AM_CFLAGS = $(DEPS_CFLAGS) $(CHECK_CFLAGS)
#AM_CFLAGS = -fprofile-arcs -ftest-coverage $(DEPS_CFLAGS) $(CHECK_CFLAGS)
diff --git a/test/data/PAS_data.tar.gz b/test/data/PAS_data.tar.gz
index b3c9879..6fc9000 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 be5bbe9..cb9cf21 100644
--- a/test/persistence_client_library_test.c
+++ b/test/persistence_client_library_test.c
@@ -598,13 +598,16 @@ char gBackupInfo[] = {
if(access(backupBlacklist, F_OK) == -1)
{
+ int ret = 0;
int handle = open(backupBlacklist, O_CREAT|O_RDWR|O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
- write(handle, gBackupInfo, strlen(gBackupInfo));
+ ret = write(handle, gBackupInfo, strlen(gBackupInfo));
+ if(ret != strlen(gBackupInfo))
+ {
+ printf("data_setupBlacklist => Wrong size written: %d", ret);
+ }
close(handle);
}
-
- printf("Finished: ==> data_setupBlacklist\n");
}
@@ -636,7 +639,6 @@ START_TEST(test_DataFile)
char* writeBuffer;
char* fileMap = NULL;
- printf("test_DataFile ==> S T A R T\n");
ret = pclInitLibrary(gTheAppId, shutdownReg);
x_fail_unless(ret <= 1, "Failed to init PCL");
#if 1
@@ -704,9 +706,16 @@ START_TEST(test_DataFile)
ret = pclFileUnmapData(fileMap, size);
x_fail_unless(ret != -1, "Failed to unmap file");
+ // file seek
+ ret = pclFileSeek(fd, 0, SEEK_CUR);
+ x_fail_unless(ret == 0, "Failed to seek file - pos 0");
+
+ ret = pclFileSeek(fd, 8, SEEK_CUR);
+ x_fail_unless(ret == 8, "Failed to seek file - pos 8");
+
// negative test
size = pclFileGetSize(1024);
- x_fail_unless(ret == 0, "Got size, but should not");
+ x_fail_unless(size == EPERS_NOKEYDATA, "Got size, but should not");
ret = pclFileClose(fd);
x_fail_unless(ret == 0, "Failed to close file");
@@ -833,7 +842,6 @@ START_TEST(test_DataFileBackupCreation)
// verify the backup creation:
handle = open(path, O_RDWR);
- printf("Path: %s | handle: %d\n", path, handle);
x_fail_unless(handle != -1, "Could not open file ==> failed to access backup file");
rval = read(handle, rBuffer, 1024);
@@ -1169,6 +1177,17 @@ START_TEST(test_Plugin)
strlen((char*)buffer)) == 0, "Buffer CUSTOM 3 not correctly read");
memset(buffer, 0, READ_SIZE);
+ ret = pclKeyWriteData(0xFF, "custom3", 0, 0, (unsigned char*)"This is a message to write", READ_SIZE);
+ x_fail_unless(ret == 321456, "Failed to write custom data"); // plugin should return 321456
+
+
+ ret = pclKeyGetSize(0xFF, "custom3", 0, 0);
+ x_fail_unless(ret == 44332211, "Failed query custom data size"); // plugin should return 44332211
+
+
+ ret = pclKeyDelete(0xFF, "custom3", 0, 0);
+ x_fail_unless(ret == 13579, "Failed query custom data size"); // plugin should return 13579
+
#endif
pclDeinitLibrary();
}
@@ -1203,6 +1222,10 @@ START_TEST(test_ReadDefault)
//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");
+
+ ret = pclKeyGetSize(0xFF, "statusHandle/default01", 3, 2);
+ x_fail_unless(ret == strlen("DEFAULT_01!"), "Invalid size");
+
#endif
pclDeinitLibrary();
}
@@ -1235,6 +1258,10 @@ START_TEST(test_ReadConfDefault)
//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");
+
+ ret = pclKeyGetSize(0xFF, "statusHandle/confdefault02", 3, 2);
+ x_fail_unless(ret == strlen("CONF_DEFAULT_02!"), "Invalid size");
+
#endif
pclDeinitLibrary();
}
@@ -1275,7 +1302,7 @@ END_TEST
START_TEST(test_InitDeinit)
{
- int i = 0;
+ int i = 0, rval = -1;
unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
for(i=1; i<20; i++)
@@ -1295,6 +1322,38 @@ START_TEST(test_InitDeinit)
pclDeinitLibrary();
}
+
+ // test multiple init/deinit
+ pclInitLibrary(gTheAppId, shutdownReg);
+ pclInitLibrary(gTheAppId, shutdownReg);
+
+ pclDeinitLibrary();
+ pclDeinitLibrary();
+ pclDeinitLibrary();
+
+ // test lifecycle set
+ pclInitLibrary(gTheAppId, shutdownReg);
+ rval = pclLifecycleSet(PCL_SHUTDOWN);
+ x_fail_unless(rval == EPERS_SHUTDOWN_NO_PERMIT, "Lifecycle set allowed, but should not");
+ pclDeinitLibrary();
+
+
+ pclInitLibrary(gTheAppId, PCL_SHUTDOWN_TYPE_NONE);
+
+ rval = pclLifecycleSet(PCL_SHUTDOWN);
+ x_fail_unless(rval != EPERS_SHUTDOWN_NO_PERMIT, "Lifecycle set NOT allowed, but should");
+
+
+ rval = pclLifecycleSet(PCL_SHUTDOWN_CANEL);
+ rval = pclLifecycleSet(PCL_SHUTDOWN_CANEL);
+ rval = pclLifecycleSet(PCL_SHUTDOWN_CANEL);
+ rval = pclLifecycleSet(PCL_SHUTDOWN_CANEL);
+ rval = pclLifecycleSet(PCL_SHUTDOWN_CANEL);
+ rval = pclLifecycleSet(PCL_SHUTDOWN_CANEL);
+ //EPERS_COMMON
+
+ pclDeinitLibrary();
+
}
END_TEST
@@ -1313,8 +1372,6 @@ START_TEST(test_NegHandle)
handle = pclKeyHandleOpen(0xFF, "posHandle/last_position", 0, 0);
x_fail_unless(handle >= 0, "Failed to open handle ==> /posHandle/last_position");
-
-
ret = pclKeyHandleReadData(negativeHandle, buffer, READ_SIZE);
x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleReadData => negative handle not detected");
@@ -1343,6 +1400,43 @@ END_TEST
+START_TEST(test_utf8_string)
+{
+ int ret = 0, size = 0;
+ unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+ const char* utf8StringBuffer = "String °^° Ñ text";
+ unsigned char buffer[128] = {0};
+
+ (void)pclInitLibrary(gTheAppId, shutdownReg);
+
+ ret = pclKeyReadData(0xFF, "utf8String", 3, 2, buffer, READ_SIZE);
+ x_fail_unless(ret == strlen(utf8StringBuffer), "Wrong write size");
+ x_fail_unless(strncmp((char*)buffer, utf8StringBuffer, ret-1) == 0, "Buffer not correctly read => 1");
+
+ size = pclKeyGetSize(0xFF, "utf8String", 3, 2);
+ x_fail_unless(size == strlen(utf8StringBuffer), "Invalid size");
+
+ pclDeinitLibrary();
+}
+END_TEST
+
+
+
+START_TEST(test_Notifications)
+{
+ unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+
+ (void)pclInitLibrary(gTheAppId, shutdownReg);
+
+ pclKeyRegisterNotifyOnChange(0x20, "address/home_address", 1, 1, myChangeCallback);
+ pclKeyUnRegisterNotifyOnChange(0x20, "address/home_address", 1, 1, myChangeCallback);
+
+ pclDeinitLibrary();
+}
+END_TEST
+
+
+
static Suite * persistencyClientLib_suite()
{
Suite * s = suite_create("Persistency client library");
@@ -1415,9 +1509,16 @@ static Suite * persistencyClientLib_suite()
tcase_add_test(tc_NegHandle, test_NegHandle);
tcase_set_timeout(tc_NegHandle, 1);
+ TCase * tc_utf8_string = tcase_create("UTF-8");
+ tcase_add_test(tc_utf8_string, test_utf8_string);
+ tcase_set_timeout(tc_utf8_string, 1);
+
+ TCase * tc_Notifications = tcase_create("Notifications");
+ tcase_add_test(tc_Notifications, test_Notifications);
+ tcase_set_timeout(tc_Notifications, 1);
+
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);
@@ -1437,10 +1538,10 @@ static Suite * persistencyClientLib_suite()
tcase_add_checked_fixture(tc_persDataFileRecovery, data_setupRecovery, data_teardown);
suite_add_tcase(s, tc_GetPath);
-
suite_add_tcase(s, tc_NegHandle);
suite_add_tcase(s, tc_InitDeinit);
-
+ suite_add_tcase(s, tc_utf8_string);
+ suite_add_tcase(s, tc_Notifications);
suite_add_tcase(s, tc_Plugin);
return s;
diff --git a/test/persistence_test_customlib.c b/test/persistence_test_customlib.c
index 581dbe7..5a5803a 100644
--- a/test/persistence_test_customlib.c
+++ b/test/persistence_test_customlib.c
@@ -64,7 +64,7 @@ int plugin_handle_close(int handle)
// OK
int plugin_delete_data(const char* path)
{
- int rval = 99;
+ int rval = 13579;
//printf("* * * * * plugin_delete_data - path: %s!\n", path);
@@ -184,7 +184,7 @@ int plugin_handle_open(const char* path, int flag, int mode)
// OK
int plugin_handle_set_data(int handle, char* buffer, int size)
{
- int rval = 99;
+ int rval = 123654;
//printf("* * * * * plugin_handle_set_data: %s!\n", LIBIDENT);
@@ -201,7 +201,7 @@ int plugin_handle_set_data(int handle, char* buffer, int size)
// OK
int plugin_set_data(const char* path, char* buffer, int size)
{
- int rval = 99;
+ int rval = 321456;
//printf("* * * * * plugin_set_data: %s!\n", LIBIDENT);
@@ -237,7 +237,7 @@ int plugin_get_status_notification_clbk(plugin_callback_t pFunct)
int plugin_handle_get_size(int handle)
{
- int rval = 99;
+ int rval = 11223344;
//printf("* * * * * plugin_get_size_handle: %d | %s!\n", handle, LIBIDENT);
@@ -247,7 +247,7 @@ int plugin_handle_get_size(int handle)
// OK
int plugin_get_size(const char* path)
{
- int rval = 99;
+ int rval = 44332211;
//printf("* * * * * plugin_get_size: %s | %s!\n", path, LIBIDENT);