summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Huerner <ingo.huerner@xse.de>2014-04-29 09:42:54 +0200
committerIngo Huerner <ingo.huerner@xse.de>2014-04-29 09:42:54 +0200
commit4f776e714b27f65dff76decda160a4f50ddfa64c (patch)
tree79b14301636a9135dac67258175ff20c2f5e1851
parent7a40679af6e3c6e1093f49139d92081f619228a9 (diff)
downloadpersistence-client-library-4f776e714b27f65dff76decda160a4f50ddfa64c.tar.gz
Added use of default data for files; added test data that can be used by PAS installation process; started to implement persclient_tools; updates after interface review
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac1
-rw-r--r--include/persistence_client_library.h29
-rw-r--r--include/persistence_client_library_error_def.h11
-rw-r--r--include/persistence_client_library_file.h2
-rw-r--r--include/persistence_client_library_key.h5
-rw-r--r--persclient_tool/Makefile.am14
-rw-r--r--persclient_tool/persistence_client_tool.c94
-rw-r--r--src/persistence_client_library.c10
-rw-r--r--src/persistence_client_library_data_organization.c9
-rw-r--r--src/persistence_client_library_data_organization.h14
-rw-r--r--src/persistence_client_library_db_access.c16
-rw-r--r--src/persistence_client_library_dbus_cmd.c22
-rw-r--r--src/persistence_client_library_file.c39
-rw-r--r--src/persistence_client_library_prct_access.c7
-rw-r--r--test/data/Data.tar.gzbin58780 -> 37294 bytes
-rw-r--r--test/data/PAS_data.tar.gzbin0 -> 4615 bytes
-rw-r--r--test/persistence_client_library_test.c70
18 files changed, 251 insertions, 94 deletions
diff --git a/Makefile.am b/Makefile.am
index c36060a..6435d05 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS=src
+SUBDIRS=src persclient_tool
if WANT_TESTS
SUBDIRS+=test
diff --git a/configure.ac b/configure.ac
index 3e68985..92a4483 100644
--- a/configure.ac
+++ b/configure.ac
@@ -154,6 +154,7 @@ AM_CONDITIONAL(DEBUG, test x"$debug" = x"true")
AC_CONFIG_FILES([Makefile
persistence_client_library.pc
src/Makefile
+ persclient_tool/Makefile
test/Makefile])
AC_OUTPUT
diff --git a/include/persistence_client_library.h b/include/persistence_client_library.h
index 29bbcb1..1e6b085 100644
--- a/include/persistence_client_library.h
+++ b/include/persistence_client_library.h
@@ -20,11 +20,11 @@
* \par change history
* Date Author Version
* 25/06/13 Ingo Hürner 1.0.0 - Rework of Init functions
- * 04/11/13 Ingo Hürner 2.0.0 - Added define for shutdown type none
+ * 04/11/13 Ingo Hürner 1.3.0 - Added define for shutdown type none
*
*/
/** \ingroup GEN_PERS */
-/** \defgroup PERS_CLIENT Client: initialisation access
+/** \defgroup PERS_CLIENT Client: initialization access
* \{
*/
/** \defgroup PERS_CLIENT_INTERFACE API document
@@ -44,21 +44,29 @@ extern "C" {
/** \} */
-/** \defgroup PCL_OVERALL functions for Library Initialisation
- * The following functions have to be called to allow intialisation of the internal interfaces.
+/** \defgroup SHUTDOWN_TYPE notifications type definitions
+ * according to Node State Manager Component
* \{
*/
-#define PCL_SHUTDOWN 1 /// trigger shutdown
-#define PCL_SHUTDOWN_CANEL 0 // cancel shutdown
-
#define PCL_SHUTDOWN_TYPE_FAST 2 /// Client registered for fast lifecycle shutdown
#define PCL_SHUTDOWN_TYPE_NORMAL 1 /// Client registered for normal lifecycle shutdown
#define PCL_SHUTDOWN_TYPE_NONE 0 /// Client does not register to lifecycle shutdown
+/** \} */
+
+
+/** \defgroup PCL_OVERALL functions for Library initialization
+ * The following functions have to be called for library initialization
+ * \{
+ */
+
+
+#define PCL_SHUTDOWN 1 /// trigger shutdown
+#define PCL_SHUTDOWN_CANEL 0 /// cancel shutdown
/**
- * @brief initalize client library.
+ * @brief initialize client library.
* This function will be called by the process using the PCL during startup phase.
*
* @attention This function is currently N O T part of the GENIVI compliance specification
@@ -96,6 +104,11 @@ int pclDeinitLibrary(void);
* @attention This function is currently N O T part of the GENIVI compliance specification
* @attention In order to prevent misuse of this function the cancel shutdown request
* can only be called 3 times per lifecycle.
+ * If this function has been called by an application more then 3 times the application
+ * will not be able to store it's data anymore during the current lifecycle.
+ * The application isn't fully operable in this lifecycle anymore.
+ * In the next lifecycle the application can store data again until the limit above
+ * has been reached.
*
* @parm PCL_SHUTDOWN for write back data when shutdown is requested,
* and PCL_SHUTDOWN_CANEL when shutdown cancel request has been received.
diff --git a/include/persistence_client_library_error_def.h b/include/persistence_client_library_error_def.h
index d8de109..e88efa5 100644
--- a/include/persistence_client_library_error_def.h
+++ b/include/persistence_client_library_error_def.h
@@ -16,8 +16,13 @@
* @ingroup Persistence client library
* @author Ingo Huerner
* @brief Error definition header
- * @see
+ *
+ * @par change history
+ * Date Author Version
+ * 29/04/14 Ingo Huerner 1.0.0 - Added cancel shutdown errors
+ *
*/
+
/** \ingroup GEN_PERS */
/** \defgroup PERS_GEN_ERROR Client Library: Generic errors
* \{
@@ -108,9 +113,9 @@ extern "C" {
/// write to requested resource failed, read only resource
#define EPERS_RESOURCE_READ_ONLY (-39)
/// max numbers of cancel shutdown exceeded
-#define EPERS_SHTDWN_MAX_CANCEL (-40)
+#define EPERS_SHUTDOWN_MAX_CANCEL (-40)
/// not permitted to use this function
-#define EPERS_SHTDWN_NO_PERMIT (-42)
+#define EPERS_SHUTDOWN_NO_PERMIT (-42)
#ifdef __cplusplus
}
diff --git a/include/persistence_client_library_file.h b/include/persistence_client_library_file.h
index 2cdbccd..e116dd6 100644
--- a/include/persistence_client_library_file.h
+++ b/include/persistence_client_library_file.h
@@ -216,7 +216,7 @@ int pclFileCreatePath(unsigned int ldbid, const char* resource_id, unsigned int
* ::EPERS_LOCKFS or ::EPERS_COMMON
* If ::EPERS_COMMON will be returned errno will be set.
*/
-int pclFileReleasePath(int pathPandle);
+int pclFileReleasePath(int pathHandle);
/** \} */
diff --git a/include/persistence_client_library_key.h b/include/persistence_client_library_key.h
index 52e4aa6..46d0e8c 100644
--- a/include/persistence_client_library_key.h
+++ b/include/persistence_client_library_key.h
@@ -71,15 +71,10 @@ typedef struct _pclNotification_s
unsigned int seat_no; /// seat id
} pclNotification_s;
-/** \defgroup SHUTDOWN_TYPE shutdown notification type definitions
- * according to Node State Manager component
- * \{
- */
/** \} */
-/** \} */
/** definition of the change callback
*
diff --git a/persclient_tool/Makefile.am b/persclient_tool/Makefile.am
new file mode 100644
index 0000000..43de4a7
--- /dev/null
+++ b/persclient_tool/Makefile.am
@@ -0,0 +1,14 @@
+AUTOMAKE_OPTIONS = foreign
+
+if DEBUG
+AM_CFLAGS =$(DEPS_CFLAGS) $(CHECK_CFLAGS) -g
+else
+AM_CFLAGS = $(DEPS_CFLAGS) $(CHECK_CFLAGS)
+#AM_CFLAGS = -fprofile-arcs -ftest-coverage $(DEPS_CFLAGS) $(CHECK_CFLAGS)
+endif
+
+noinst_PROGRAMS = persistence_client_tool
+
+persistence_client_tool_SOURCES = persistence_client_tool.c
+persistence_client_tool_LDADD = $(DEPS_LIBS)
+
diff --git a/persclient_tool/persistence_client_tool.c b/persclient_tool/persistence_client_tool.c
new file mode 100644
index 0000000..7e35113
--- /dev/null
+++ b/persclient_tool/persistence_client_tool.c
@@ -0,0 +1,94 @@
+/******************************************************************************
+ * Project Persistency
+ * (c) copyright 2012
+ * Company XS Embedded GmbH
+ *****************************************************************************/
+/******************************************************************************
+ * This Source Code Form is subject to the terms of the
+ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
+ * with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+******************************************************************************/
+ /**
+ * @file persistence_client_tool.c
+ * @ingroup Persistence client library test tool
+ * @author Ingo Huerner
+ * @brief Persistence Client Library Test Tool
+ * @see
+ */
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+
+#define PCLT_VERSION "0.1"
+
+
+void printHelp();
+
+
+
+int main(int argc, char *argv[])
+{
+ int opt;
+
+ while ((opt = getopt(argc, argv, "hv")) != -1)
+ {
+ switch (opt) {
+ case 'h':
+ printHelp();
+ break;
+ case 'v':
+ printf("Version: %s\n", PCLT_VERSION);
+ break;
+ default: /* '?' */
+ fprintf(stderr, "Usage: %s [-t nsecs] [-n] name\n", argv[0]);
+ printHelp();
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ return 0;
+}
+
+
+
+void printHelp()
+{
+ printf("Usage: persclient_tool [-o <action to do>] [-a <application name>] [-r <resource id>] [-l <logical db id>]\n");
+ printf(" [-u <user no>] [-s <seat no>] [-f <file>] [-p <payload>] [-H] [-h] [-v]\n");
+
+ printf("\n");
+ printf("-o, --option=<action to do> The possible actions are:\n");
+ printf(" readkey - read out the given key\n");
+ printf(" writekey - write something to a key\n");
+ printf(" deletekey - delete a key\n");
+ printf(" getkeysize - get the size of a key\n");
+ printf("-a, --appname=<application name> The Application Name used for the initialization of the PCL\n");
+ printf("-f, --file=<filename> The file for data import or export\n");
+ printf("-p, --payload=<payload> The data to be written to a key if no file is specified as source.\n");
+ printf("-r, --resource_id=<resource id> The resource ID is the name of the key to process\n");
+ printf("-l, --ldbid=<logical db id> Logical Database ID in hex notation! e.g. 0xFF. If not specified the default value '0xFF' is used\n");
+ printf("-u, --user_no=<user no> The user number. If not specified the default value '0' is used\n");
+ printf("-s, --seat_no=<seat no> The seat number. If not specified the default value '0' is used\n");
+ printf("-H, --forcehexdump Force print out a HexDump of the written/read data\n");
+ printf("-h, --help Print help message\n");
+ printf("-V, --version Print program version\n");
+
+ printf("\n");
+ printf("Examples:\n");
+ printf("1.) Read a Key and show value as HexDump:\n");
+ printf(" persclient_tool -o readkey -a MyApplication -r MyKey optional parameters: [-l 0xFF -u 0 -s 0]\n");
+ printf("2.) Read a Key into a file:\n");
+ printf(" persclient_tool -o readkey -a MyApplication -r MyKey -f outfile.bin optional parameters: [-l 0xFF -u 0 -s 0 -H]\n");
+ printf("3.) Write a Key and use the <payload> as the data source.:\n");
+ printf(" persclient_tool -o writekey -a MyApplication -r MyKey -p 'Hello World' optional parameters: [-l 0xFF -u 0 -s 0 -H]\n");
+ printf("4.) Write a Key and use a file as the data source.:\n");
+ printf(" persclient_tool -o writekey -a MyApplication -r MyKey -f infile.bin optional parameters: [-l 0xFF -u 0 -s 0 -H]\n");
+ printf("5.) Get the size of a key [bytes]:\n");
+ printf(" persclient_tool -o getkeysize -a MyApplication -r MyKey optional parameters: [-l 0xFF -u 0 -s 0]\n");
+ printf("6.) Delete a key:\n");
+ printf(" persclient_tool -o deletekey -a MyApplication -r MyKey optional parameters: [-l 0xFF -u 0 -s 0]\n");
+}
+
diff --git a/src/persistence_client_library.c b/src/persistence_client_library.c
index dead553..46e6722 100644
--- a/src/persistence_client_library.c
+++ b/src/persistence_client_library.c
@@ -225,7 +225,7 @@ int pclDeinitLibrary(void)
}
}
- process_prepare_shutdown(Shutdown_Full); // close all db and fd's and block access
+ process_prepare_shutdown(Shutdown_Full); // close all db's and fd's and block access
// end dbus library
bContinue = 0;
@@ -266,7 +266,7 @@ int pclLifecycleSet(int shutdown)
{
if(PCL_SHUTDOWN)
{
- process_prepare_shutdown(Shutdown_Partial); // close all db and fd's and block access
+ process_prepare_shutdown(Shutdown_Partial); // close all db's and fd's and block access
}
else if(PCL_SHUTDOWN_CANEL)
{
@@ -276,7 +276,7 @@ int pclLifecycleSet(int shutdown)
}
else
{
- rval = EPERS_SHTDWN_MAX_CANCEL;
+ rval = EPERS_SHUTDOWN_MAX_CANCEL;
}
}
else
@@ -286,10 +286,10 @@ int pclLifecycleSet(int shutdown)
}
else
{
- rval = EPERS_SHTDWN_NO_PERMIT;
+ rval = EPERS_SHUTDOWN_NO_PERMIT;
}
-return rval;
+ return rval;
}
diff --git a/src/persistence_client_library_data_organization.c b/src/persistence_client_library_data_organization.c
index 4ea78db..81d7d6d 100644
--- a/src/persistence_client_library_data_organization.c
+++ b/src/persistence_client_library_data_organization.c
@@ -37,13 +37,14 @@ const char* gWt = "/wt.itz";
const char* gCached = "/cached.itz";
-/// directory structure node name defintion
+/// directory structure node name definition
const char* gNode = "/node";
-/// directory structure user name defintion
+/// directory structure user name definition
const char* gUser = "/user/";
-/// directory structure seat name defintion
+/// directory structure seat name definition
const char* gSeat = "/seat/";
-
+/// default data folder name definition
+const char* gDefDataFolder = "/defaultData/";
/// cached path location
#define CACHEPREFIX "/Data/mnt-c/"
diff --git a/src/persistence_client_library_data_organization.h b/src/persistence_client_library_data_organization.h
index 22852b5..f6c8144 100644
--- a/src/persistence_client_library_data_organization.h
+++ b/src/persistence_client_library_data_organization.h
@@ -105,7 +105,7 @@ enum _PersistenceConstantDef
Shutdown_MaxCount = 3, /// max number of shutdown cancel calls
NsmShutdownNormal = 1, /// lifecycle shutdown normal
- NsmErrorStatus_OK = 1, /// lifecycle return OK idicator
+ NsmErrorStatus_OK = 1, /// lifecycle return OK indicator
NsmErrorStatus_Fail = -1, /// lifecycle return failed indicator
ChecksumBufSize = 64, /// max checksum size
@@ -163,16 +163,22 @@ extern const char* gCached;
extern const char* gWt;
-/// directory structure node name defintion
+/// directory structure node name definition
extern const char* gNode;
-/// directory structure user name defintion
+/// directory structure user name definition
extern const char* gUser;
-/// directory structure seat name defintion
+/// directory structure seat name definition
extern const char* gSeat;
+/// default data folder name definition
+extern const char* gDefDataFolder;
+
+/// path for the backup location
extern const char* gBackupPrefix;
+/// size of cached prefix string
extern const int gCPathPrefixSize;
+/// size of write through prefix string
extern const int gWTPathPrefixSize;
/// path prefix for local cached database: /Data/mnt_c/<appId>/<database_name>
diff --git a/src/persistence_client_library_db_access.c b/src/persistence_client_library_db_access.c
index 5ecbfac..a102607 100644
--- a/src/persistence_client_library_db_access.c
+++ b/src/persistence_client_library_db_access.c
@@ -619,16 +619,20 @@ int pers_send_Notification_Signal(const char* key, PersistenceDbContext_s* conte
void pers_rct_close_all()
{
- int i = 0, rval = 0;
+ int i = 0;
// close open persistence resource configuration table
for(i=0; i< PrctDbTableSize; i++)
{
- rval = persComRctClose(i);
- if (rval != 0)
- {
- DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("process_prepare_shutdown => failed to close db:"), DLT_INT(rval));
- }
+ if(gResource_table[i] != 0)
+ {
+ if(persComRctClose(i) != 0)
+ {
+ DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("process_prepare_shutdown => failed to close db => index:"), DLT_INT(i));
+ }
+
+ gResource_table[i] = 0;
+ }
}
}
diff --git a/src/persistence_client_library_dbus_cmd.c b/src/persistence_client_library_dbus_cmd.c
index 56ca999..f410e75 100644
--- a/src/persistence_client_library_dbus_cmd.c
+++ b/src/persistence_client_library_dbus_cmd.c
@@ -179,17 +179,27 @@ void process_prepare_shutdown(int complete)
// flush open files to disk
for(i=0; i<MaxPersHandle; i++)
{
- int tmp = i;
- if(gOpenFdArray[tmp] == FileOpen)
+ if(gOpenFdArray[i] == FileOpen)
{
- fsync(tmp);
+ fsync(i);
#if USE_FILECACHE
- rval = pfcCloseFile(tmp);
+ if(complete == Shutdown_Full)
+ {
+ rval = pfcCloseFile(i);
+ }
+ else if(complete == Shutdown_Partial)
+ {
+ pfcWriteBackAndSync(i);
+ }
#else
- if(complete > 0)
+ if(complete == Shutdown_Full)
+ {
+ rval = close(i);
+ }
+ else if(complete == Shutdown_Partial)
{
- rval = close(tmp);
+ fsync(i);
}
#endif
if(rval == -1)
diff --git a/src/persistence_client_library_file.c b/src/persistence_client_library_file.c
index 2bf14bf..8d433b1 100644
--- a/src/persistence_client_library_file.c
+++ b/src/persistence_client_library_file.c
@@ -212,10 +212,47 @@ int pclFileOpen(unsigned int ldbid, const char* resource_id, unsigned int user_n
if(handle == -1 && errno == ENOENT) // file does not exist, create file and folder
{
- if( (handle = pclCreateFile(dbPath)) == -1)
+
+ if((handle = pclCreateFile(dbPath)) == -1)
{
DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("pclFileOpen: error => failed to create file: "), DLT_STRING(dbPath));
}
+ else
+ {
+ // check if there is default data available
+ char pathPrefix[DbPathMaxLen] = {0};
+ char defaultPath[DbPathMaxLen] = {0};
+ int defaultHandle = -1;
+
+ // create path to default data
+ if(dbContext.configKey.policy == PersistencePolicy_wc)
+ {
+ snprintf(pathPrefix, DbPathMaxLen, gLocalCachePath, gAppId);
+ }
+ else if(dbContext.configKey.policy == PersistencePolicy_wt)
+ {
+ snprintf(pathPrefix, DbPathMaxLen, gLocalWtPath, gAppId);
+ }
+
+ snprintf(defaultPath, DbPathMaxLen, "%s%s%s", pathPrefix, gDefDataFolder, resource_id);
+ printf("=> => => => defaultPath: %s => resourceID: %s\n", defaultPath, resource_id);
+
+ defaultHandle = open(defaultPath, O_RDONLY);
+ if(defaultHandle != -1) // check if default data is available
+ {
+ // copy default data
+ struct stat buf;
+ memset(&buf, 0, sizeof(buf));
+
+ fstat(defaultHandle, &buf);
+ sendfile(handle, defaultHandle, 0, buf.st_size);
+ close(defaultHandle);
+ }
+ else
+ {
+ printf(" = = = = Failed to open file: %d => %s\n", defaultHandle, strerror(errno));
+ }
+ }
}
if(handle < MaxPersHandle && handle > 0 )
diff --git a/src/persistence_client_library_prct_access.c b/src/persistence_client_library_prct_access.c
index 5fffc3c..d8a0671 100644
--- a/src/persistence_client_library_prct_access.c
+++ b/src/persistence_client_library_prct_access.c
@@ -119,11 +119,13 @@ int get_resource_cfg_table(PersistenceRCT_e rct, int group)
break;
}
+ gResource_table[arrayIdx] = persComRctOpen(filename, 0x00);
+ DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("get_resource_cfg_table => filename: "), DLT_STRING(filename), DLT_INT(arrayIdx));
- gResource_table[arrayIdx] = persComRctOpen(filename, 0x00) ;
if(gResource_table[arrayIdx] < 0)
{
- DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("get_resource_cfg_table => RCT problem"));
+ gResourceOpen[arrayIdx] = 0;
+ DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("get_resource_cfg_table => RCT problem"), DLT_INT(gResource_table[arrayIdx] ));
}
else
{
@@ -187,6 +189,7 @@ int get_db_context(PersistenceInfo_s* dbContext, const char* resource_id, unsign
if(resourceFound == 0)
{
+ DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("get_db_context => resource in rct table not found: "), DLT_STRING(resource_id) );
//
// resource NOT found in resource table ==> default is local cached key
//
diff --git a/test/data/Data.tar.gz b/test/data/Data.tar.gz
index 121ec26..0e5e7c9 100644
--- a/test/data/Data.tar.gz
+++ b/test/data/Data.tar.gz
Binary files differ
diff --git a/test/data/PAS_data.tar.gz b/test/data/PAS_data.tar.gz
new file mode 100644
index 0000000..baea65f
--- /dev/null
+++ 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 56d4646..76141f4 100644
--- a/test/persistence_client_library_test.c
+++ b/test/persistence_client_library_test.c
@@ -201,6 +201,7 @@ 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);
@@ -217,7 +218,6 @@ START_TEST (test_GetDataHandle)
x_fail_unless(handle2 >= 0, "Failed to open handle /statusHandle/open_document");
size = pclKeyHandleWriteData(handle2, (unsigned char*)sysTimeBuffer, strlen(sysTimeBuffer));
- printf("pclKeyHandleWriteData: Soll: %d | ist:%d\n", strlen(sysTimeBuffer), size);
x_fail_unless(size == strlen(sysTimeBuffer));
// close
ret = pclKeyHandleClose(handle2);
@@ -296,6 +296,23 @@ START_TEST(test_SetData)
ret = pclInitLibrary(gTheAppId, shutdownReg);
x_fail_unless(ret <= 1, "Failed to init PCL");
+
+#if 1
+ /**
+ * Logical DB ID: 0xFF with user 3 and seat 2
+ * ==> local USER value (user 3, seat 2)
+ */
+ ret = pclKeyWriteData(0xFF, "status/open_document", 3, 2, "WT_ /var/opt/user_manual_climateControl.pdf", strlen("WT_ /var/opt/user_manual_climateControl.pdf"));
+ x_fail_unless(ret == strlen("WT_ /var/opt/user_manual_climateControl.pdf"), "Wrong write size");
+
+
+ ret = pclKeyWriteData(0x84, "links/last_link", 2, 1, "CACHE_ /last_exit/queens", strlen("CACHE_ /last_exit/queens"));
+ x_fail_unless(ret == strlen("CACHE_ /last_exit/queens"), "Wrong write size");
+
+ ret = pclKeyWriteData(0xFF, "posHandle/last_position", 0, 0, "WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\"", strlen("WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\""));
+ x_fail_unless(ret == strlen("WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\""), "Wrong write size");
+#endif
+
#if 1
time_t t = time(0);
@@ -481,7 +498,6 @@ START_TEST(test_GetDataSize)
* ==> shared user value accessible by A GROUP (user 2 and seat 1)
*/
size = pclKeyGetSize(0x84, "links/last_link", 2, 1);
- printf("=>=>=>=> soll: %d | ist: %d\n", strlen("CACHE_ /last_exit/queens"), size);
x_fail_unless(size == strlen("CACHE_ /last_exit/queens"), "Invalid size");
#endif
pclDeinitLibrary();
@@ -731,17 +747,18 @@ START_TEST(test_DataHandle)
handleArray[3] = pclFileOpen(0xFF, "media/mediaDB_write_04.db", 1, 1);
x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_04.db");
- (void)pclFileReadData(handleArray[0], buffer, READ_SIZE);
+ ret = pclFileReadData(handleArray[0], buffer, READ_SIZE);
+ x_fail_unless(ret >= 0, "Failed to read handle idx \"0\"!!");
x_fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_01.db",
strlen("/user/1/seat/1/media/mediaDB_write_01.db"))
== 0, "Buffer not correctly read => mediaDB_write_01.db");
- (void)pclFileReadData(handleArray[1], buffer, READ_SIZE);
+ ret = pclFileReadData(handleArray[1], buffer, READ_SIZE);
x_fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_02.db",
strlen("/user/1/seat/1/media/mediaDB_write_02.db"))
== 0, "Buffer not correctly read => mediaDB_write_02.db");
- (void)pclFileReadData(handleArray[2], buffer, READ_SIZE);
+ ret = pclFileReadData(handleArray[2], buffer, READ_SIZE);
x_fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_03.db",
strlen("/user/1/seat/1/media/mediaDB_write_03.db"))
== 0, "Buffer not correctly read => mediaDB_write_03.db");
@@ -1079,45 +1096,6 @@ END_TEST
-START_TEST(test_FileOpenCreate)
-{
- int handle = -1, ret = 0;
- unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
- char buffer[128] = {0};
- char* writeBuffer = "test_FileOpenCreate: write some data to the file!";
-
- (void)pclInitLibrary(gTheAppId, shutdownReg);
-
- // remove file
- remove("/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDBWrite.db");
-
- handle = pclFileOpen(0xFF, "media/mediaDBWrite.db", 1, 1);
- x_fail_unless(handle != -1, "Could not open file ==> /media/mediaDBWrite.db");
-
-
- ret = pclFileWriteData(handle, writeBuffer, strlen(writeBuffer));
- x_fail_unless(ret == strlen(writeBuffer), "pclKeyHandleWriteData => error writing data");
-
- /*
- ret = pclFileSeek(handle, 0, SEEK_SET);
- x_fail_unless(ret <= 0, "pclFileSeek => failed to position fd");
-
-
- ret = pclFileReadData(handle, buffer, 128);
- x_fail_unless(ret == strlen(writeBuffer), "pclKeyHandleReadData => error read data");
- x_fail_unless(strncmp(buffer, writeBuffer, strlen(writeBuffer)) == 0, "pclKeyHandleReadData => Buffer not correctly read");
-
- ret = pclFileClose(handle);
- x_fail_unless(ret <= 0, "pclKeyHandleClose => failed to close");
- */
-
-
- // remove file
- remove("/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDBWrite.db");
-
- pclDeinitLibrary();
-}
-END_TEST
@@ -1173,9 +1151,6 @@ static Suite * persistencyClientLib_suite()
TCase * tc_NegHandle = tcase_create("NegHandle");
tcase_add_test(tc_NegHandle, test_NegHandle);
- TCase * tc_FileOpenCreate = tcase_create("FileOpenCreate");
- tcase_add_test(tc_FileOpenCreate, test_FileOpenCreate);
-
suite_add_tcase(s, tc_persSetData);
suite_add_tcase(s, tc_persGetData);
suite_add_tcase(s, tc_persSetDataNoPRCT);
@@ -1191,7 +1166,6 @@ static Suite * persistencyClientLib_suite()
suite_add_tcase(s, tc_GetPath);
suite_add_tcase(s, tc_InitDeinit);
suite_add_tcase(s, tc_NegHandle);
- suite_add_tcase(s, tc_FileOpenCreate);
//suite_add_tcase(s, tc_Plugin); // activate only if the plugins are available