1 /******************************************************************************
4 * Company XS Embedded GmbH
5 *****************************************************************************/
6 /******************************************************************************
7 * This Source Code Form is subject to the terms of the
8 * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
9 * with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 ******************************************************************************/
12 * @file persistence_client_library_test.c
13 * @author Ingo Huerner
14 * @brief Test of persistence client library
22 #include <unistd.h> /* exit */
28 #include <dlt/dlt_common.h>
30 #include "persCheck.h"
33 #include "../include/persistence_client_library_file.h"
34 #include "../include/persistence_client_library_key.h"
35 #include "../include/persistence_client_library.h"
36 #include "../include/persistence_client_library_error_def.h"
41 #define NUM_OF_FILES 3
42 #define READ_SIZE 1024
43 #define MaxAppNameLen 256
46 char gTheAppId[MaxAppNameLen] = {0};
48 // definition of weekday
49 char* dayOfWeek[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
51 int myChangeCallback(pclNotification_s * notifyStruct)
53 printf(" ==> * - * myChangeCallback * - *\n");
58 * Test the key value interface using different logicalDB id's, users and seats.
59 * Each resource below has an entry in the resource configuration table where the
60 * storage location (cached or write through) and type (e.g. custom) has been configured.
62 START_TEST(test_GetData)
64 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
65 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
66 X_TEST_REPORT_REFERENCE("NONE");
67 X_TEST_REPORT_DESCRIPTION("Test of get data");
68 X_TEST_REPORT_TYPE(GOOD);
71 unsigned int shutdownReg = (PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL);
73 unsigned char buffer[READ_SIZE] = {0};
75 ret = pclInitLibrary(gTheAppId, shutdownReg);
76 x_fail_unless(ret <= 1, "Failed to init PCL");
80 * Logical DB ID: 0xFF with user 0 and seat 0
81 * ==> local value accessible by all users (user 0, seat 0)
83 ret = pclKeyReadData(0xFF, "pos/last_position", 0, 0, buffer, READ_SIZE);
84 x_fail_unless(strncmp((char*)buffer, "CACHE_ +48° 10' 38.95\", +8° 44' 39.06\"",
85 strlen((char*)buffer)) == 0, "Buffer not correctly read");
86 x_fail_unless(ret = strlen("CACHE_ +48° 10' 38.95\", +8° 44' 39.06\""));
88 memset(buffer, 0, READ_SIZE);
91 * Logical DB ID: 0xFF with user 0 and seat 0
92 * ==> local value accessible by all users (user 0, seat 0)
95 ret = pclKeyReadData(0xFF, "language/country_code", 0, 0, buffer, READ_SIZE);
96 x_fail_unless(strncmp((char*)buffer, "Custom plugin -> plugin_get_data: secure!",
97 strlen((char*)buffer)) == 0, "Buffer not correctly read");
98 x_fail_unless(ret = strlen("Custom plugin -> plugin_get_data_handle"));
100 memset(buffer, 0, READ_SIZE);
105 * Logical DB ID: 0 with user 3 and seat 0
106 * ==> public shared user value (user 3, seat 0)
108 ret = pclKeyReadData(0, "language/current_language", 3, 0, buffer, READ_SIZE);
109 x_fail_unless(strncmp((char*)buffer, "CACHE_ Kisuaheli", strlen((char*)buffer)) == 0, "Buffer not correctly read");
111 memset(buffer, 0, READ_SIZE);
114 * Logical DB ID: 0xFF with user 3 and seat 2
115 * ==> local USER value (user 3, seat 2)
117 ret = pclKeyReadData(0xFF, "status/open_document", 3, 2, buffer, READ_SIZE);
118 x_fail_unless(strncmp((char*)buffer, "WT_ /var/opt/user_manual_climateControl.pdf", strlen((char*)buffer)) == 0, "Buffer not correctly read");
120 memset(buffer, 0, READ_SIZE);
123 * Logical DB ID: 0x20 with user 4 and seat 0
124 * ==> shared user value accessible by a group (user 4 and seat 0)
126 ret = pclKeyReadData(0x20, "address/home_address", 4, 0, buffer, READ_SIZE);
127 x_fail_unless(strncmp((char*)buffer, "WT_ 55327 Heimatstadt, Wohnstrasse 31", strlen((char*)buffer)) == 0, "Buffer not correctly read");
129 memset(buffer, 0, READ_SIZE);
132 * Logical DB ID: 0xFF with user 0 and seat 0
133 * ==> local value accessible by ALL USERS (user 0, seat 0)
135 ret = pclKeyReadData(0xFF, "pos/last_satellites", 0, 0, buffer, READ_SIZE);
136 x_fail_unless(strncmp((char*)buffer, "WT_ 17", strlen((char*)buffer)) == 0, "Buffer not correctly read");
138 memset(buffer, 0, READ_SIZE);
141 * Logical DB ID: 0x84 with user 4 and seat 0
142 * ==> shared user value accessible by A GROUP (user 4 and seat 0)
144 ret = pclKeyReadData(0x84, "links/last_link", 2, 0, buffer, READ_SIZE);
145 x_fail_unless(strncmp((char*)buffer, "CACHE_ /last_exit/brooklyn", strlen((char*)buffer)) == 0, "Buffer not correctly read");
147 memset(buffer, 0, READ_SIZE);
150 * Logical DB ID: 0x84 with user 2 and seat 1
151 * ==> local merge value
153 ret = pclKeyReadData(0x84, "links/last_link", 2, 1, buffer, READ_SIZE);
154 x_fail_unless(strncmp((char*)buffer, "CACHE_ /last_exit/queens", strlen((char*)buffer)) == 0, "Buffer not correctly read");
163 * Test the key value h a n d l e interface using different logicalDB id's, users and seats
164 * Each resource below has an entry in the resource configuration table where
165 * the storage location (cached or write through) and type (e.g. custom) has bee configured.
167 START_TEST (test_GetDataHandle)
169 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
170 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
171 X_TEST_REPORT_REFERENCE("NONE");
172 X_TEST_REPORT_DESCRIPTION("Test of get data handle");
173 X_TEST_REPORT_TYPE(GOOD);
175 int ret = 0, handle = 0, handle2 = 0, handle3 = 0, handle4 = 0, size = 0;
176 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
178 unsigned char buffer[READ_SIZE] = {0};
181 char sysTimeBuffer[128];
183 ret = pclInitLibrary(gTheAppId, shutdownReg);
184 x_fail_unless(ret <= 1, "Failed to init PCL");
188 locTime = localtime(&t);
190 snprintf(sysTimeBuffer, 128, "TimeAndData: \"%s %d.%d.%d - %d:%.2d:%.2d Uhr\"", dayOfWeek[locTime->tm_wday], locTime->tm_mday, locTime->tm_mon, (locTime->tm_year+1900),
191 locTime->tm_hour, locTime->tm_min, locTime->tm_sec);
194 // open handle ---------------------------------------------------
196 * Logical DB ID: 0xFF with user 0 and seat 0
197 * ==> local value accessible by ALL USERS (user 0, seat 0)
199 handle = pclKeyHandleOpen(0xFF, "posHandle/last_position", 0, 0);
200 x_fail_unless(handle >= 0, "Failed to open handle ==> /posHandle/last_position");
202 ret = pclKeyHandleReadData(handle, buffer, READ_SIZE);
203 printf("* * * * * => => => B U F F E R : \"%s\"\n", buffer);
204 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");
206 size = pclKeyHandleGetSize(handle);
207 x_fail_unless(size == strlen("WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\""));
208 // ---------------------------------------------------------------------------------------------
211 // open handle ---------------------------------------------------
213 * Logical DB ID: 0xFF with user 3 and seat 2
214 * ==> local USER value (user 3, seat 2)
216 handle2 = pclKeyHandleOpen(0xFF, "statusHandle/open_document", 3, 2);
217 x_fail_unless(handle2 >= 0, "Failed to open handle /statusHandle/open_document");
219 size = pclKeyHandleWriteData(handle2, (unsigned char*)sysTimeBuffer, strlen(sysTimeBuffer));
220 x_fail_unless(size == strlen(sysTimeBuffer));
222 ret = pclKeyHandleClose(handle2);
223 // ---------------------------------------------------------------------------------------------
226 // open handle ---------------------------------------------------
228 * Logical DB ID: 0xFF with user 0 and seat 0
229 * ==> local value accessible by ALL USERS (user 0, seat 0)
231 #if 0 // plugin test case
232 memset(buffer, 0, READ_SIZE);
233 handle4 = pclKeyHandleOpen(0xFF, "language/country_code", 0, 0);
234 printf("H A N D L E: %d\n", handle4);
235 x_fail_unless(handle4 >= 0, "Failed to open handle /language/country_code");
237 ret = pclKeyHandleReadData(handle4, buffer, READ_SIZE);
238 x_fail_unless(strncmp((char*)buffer, "Custom plugin -> plugin_get_data_handle: secure!", -1) == 0, "Buffer not correctly read => 2");
240 size = pclKeyHandleGetSize(handle4);
241 x_fail_unless(size = strlen("Custom plugin -> plugin_get_data_handle"));
243 ret = pclKeyHandleWriteData(handle4, (unsigned char*)"Only dummy implementation behind custom library", READ_SIZE);
245 // ---------------------------------------------------------------------------------------------
248 // open handle ---------------------------------------------------
250 * Logical DB ID: 0xFF with user 3 and seat 2
251 * ==> local USER value (user 3, seat 2)
253 handle3 = pclKeyHandleOpen(0xFF, "statusHandle/open_document", 3, 2);
254 x_fail_unless(handle3 >= 0, "Failed to open handle /statusHandle/open_document");
256 ret = pclKeyHandleReadData(handle3, buffer, READ_SIZE);
257 x_fail_unless(strncmp((char*)buffer, sysTimeBuffer, strlen(sysTimeBuffer)) == 0, "Buffer not correctly read => 3");
259 size = pclKeyHandleGetSize(handle3);
260 x_fail_unless(size = strlen(sysTimeBuffer));
261 // ---------------------------------------------------------------------------------------------
265 ret = pclKeyHandleClose(handle);
266 ret = pclKeyHandleClose(handle3);
267 ret = pclKeyHandleClose(handle4);
275 * Write data to a key using the key interface.
276 * First write data to different keys and after
277 * read the data for verification.
279 START_TEST(test_SetData)
281 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
282 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
283 X_TEST_REPORT_REFERENCE("NONE");
284 X_TEST_REPORT_DESCRIPTION("Test of set data");
285 X_TEST_REPORT_TYPE(GOOD);
288 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
289 unsigned char buffer[READ_SIZE] = {0};
290 char write1[READ_SIZE] = {0};
291 char write2[READ_SIZE] = {0};
292 char sysTimeBuffer[256];
296 ret = pclInitLibrary(gTheAppId, shutdownReg);
297 x_fail_unless(ret <= 1, "Failed to init PCL");
301 * Logical DB ID: 0xFF with user 3 and seat 2
302 * ==> local USER value (user 3, seat 2)
304 ret = pclKeyWriteData(0xFF, "status/open_document", 3, 2, "WT_ /var/opt/user_manual_climateControl.pdf", strlen("WT_ /var/opt/user_manual_climateControl.pdf"));
305 x_fail_unless(ret == strlen("WT_ /var/opt/user_manual_climateControl.pdf"), "Wrong write size");
308 ret = pclKeyWriteData(0x84, "links/last_link", 2, 1, "CACHE_ /last_exit/queens", strlen("CACHE_ /last_exit/queens"));
309 x_fail_unless(ret == strlen("CACHE_ /last_exit/queens"), "Wrong write size");
311 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\""));
312 x_fail_unless(ret == strlen("WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\""), "Wrong write size");
318 locTime = localtime(&t);
321 snprintf(sysTimeBuffer, 128, "\"%s %d.%d.%d - %d:%.2d:%.2d Uhr\"", dayOfWeek[locTime->tm_wday], locTime->tm_mday, locTime->tm_mon, (locTime->tm_year+1900),
322 locTime->tm_hour, locTime->tm_min, locTime->tm_sec);
325 * Logical DB ID: 0xFF with user 1 and seat 2
326 * ==> local USER value (user 1, seat 2)
329 ret = pclKeyWriteData(0xFF, "69", 1, 2, (unsigned char*)sysTimeBuffer, strlen(sysTimeBuffer));
330 x_fail_unless(ret == strlen(sysTimeBuffer), "Wrong write size");
332 snprintf(write1, 128, "%s %s", "/70", sysTimeBuffer);
334 * Logical DB ID: 0xFF with user 1 and seat 2
335 * ==> local USER value (user 1, seat 2)
338 ret = pclKeyWriteData(0xFF, "70", 1, 2, (unsigned char*)write1, strlen(write1));
339 x_fail_unless(ret == strlen(write1), "Wrong write size");
341 snprintf(write2, 128, "%s %s", "/key_70", sysTimeBuffer);
343 * Logical DB ID: 0xFF with user 1 and seat 2
344 * ==> local USER value (user 1, seat 2)
345 * Resource ID: key_70
347 ret = pclKeyWriteData(0xFF, "key_70", 1, 2, (unsigned char*)write2, strlen(write2));
348 x_fail_unless(ret == strlen(write2), "Wrong write size");
351 /*******************************************************************************************************************************************/
352 /* used for changed notification testing */
353 /*******************************************************************************************************************************************/
355 * Logical DB ID: 0x84 with user 2 and seat 1
356 * ==> shared user value accessible by A GROUP (user 2 and seat 1)
358 * ==> used for shared testing
360 //printf("Write data to trigger change notification\n");
361 ret = pclKeyWriteData(0x84, "links/last_link2", 2, 1, (unsigned char*)"Test notify shared data", strlen("Test notify shared data"));
362 x_fail_unless(ret == strlen("Test notify shared data"), "Wrong write size");
365 * Logical DB ID: 0x84 with user 2 and seat 1
366 * ==> shared user value accessible by A GROUP (user 2 and seat 1)
368 * ==> used for shared testing
370 //printf("Write data to trigger change notification\n");
371 ret = pclKeyWriteData(0x84, "links/last_link3", 3, 2, (unsigned char*)"Test notify shared data", strlen("Test notify shared data"));
372 x_fail_unless(ret == strlen("Test notify shared data"), "Wrong write size");
375 * Logical DB ID: 0x84 with user 2 and seat 1
376 * ==> shared user value accessible by A GROUP (user 2 and seat 1)
378 * ==> used for shared testing
380 //printf("Write data to trigger change notification\n");
381 ret = pclKeyWriteData(0x84, "links/last_link4", 4, 1, (unsigned char*)"Test notify shared data", strlen("Test notify shared data"));
382 x_fail_unless(ret == strlen("Test notify shared data"), "Wrong write size");
383 /*******************************************************************************************************************************************/
384 /*******************************************************************************************************************************************/
388 * now read the data written in the previous steps to the keys
389 * and verify data has been written correctly.
391 memset(buffer, 0, READ_SIZE);
393 ret = pclKeyReadData(0xFF, "69", 1, 2, buffer, READ_SIZE);
394 x_fail_unless(strncmp((char*)buffer, sysTimeBuffer, strlen(sysTimeBuffer)) == 0, "Buffer not correctly read");
395 x_fail_unless(ret == strlen(sysTimeBuffer), "Wrong read size");
397 memset(buffer, 0, READ_SIZE);
399 ret = pclKeyReadData(0xFF, "70", 1, 2, buffer, READ_SIZE);
400 x_fail_unless(strncmp((char*)buffer, write1, strlen(write1)) == 0, "Buffer not correctly read");
401 x_fail_unless(ret == strlen(write1), "Wrong read size");
403 memset(buffer, 0, READ_SIZE);
405 ret = pclKeyReadData(0xFF, "key_70", 1, 2, buffer, READ_SIZE);
406 x_fail_unless(strncmp((char*)buffer, write2, strlen(write2)) == 0, "Buffer not correctly read");
407 x_fail_unless(ret == strlen(write2), "Wrong read size");
417 * Write data to a key using the key interface.
418 * The key is not in the persistence resource table.
419 * The key sill then be stored to the location local and cached.
421 START_TEST(test_SetDataNoPRCT)
423 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
424 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
425 X_TEST_REPORT_REFERENCE("NONE");
426 X_TEST_REPORT_DESCRIPTION("Test of set data no PRCT");
427 X_TEST_REPORT_TYPE(GOOD);
430 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
431 unsigned char buffer[READ_SIZE] = {0};
434 ret = pclInitLibrary(gTheAppId, shutdownReg);
435 x_fail_unless(ret <= 1, "Failed to init PCL");
439 char sysTimeBuffer[128];
441 locTime = localtime(&t);
443 snprintf(sysTimeBuffer, 128, "TimeAndData: \"%s %d.%d.%d - %d:%.2d:%.2d Uhr\"", dayOfWeek[locTime->tm_wday], locTime->tm_mday, locTime->tm_mon, (locTime->tm_year+1900),
444 locTime->tm_hour, locTime->tm_min, locTime->tm_sec);
447 * Logical DB ID: 0xFF with user 1 and seat 2
448 * ==> local USER value (user 1, seat 2)
450 ret = pclKeyWriteData(0xFF, "NoPRCT", 1, 2, (unsigned char*)sysTimeBuffer, strlen(sysTimeBuffer));
451 x_fail_unless(ret == strlen(sysTimeBuffer), "Wrong write size");
452 //printf("Write Buffer : %s\n", sysTimeBuffer);
454 // read data again and and verify datat has been written correctly
455 memset(buffer, 0, READ_SIZE);
457 ret = pclKeyReadData(0xFF, "NoPRCT", 1, 2, buffer, READ_SIZE);
458 x_fail_unless(strncmp((char*)buffer, sysTimeBuffer, strlen(sysTimeBuffer)) == 0, "Buffer not correctly read");
459 x_fail_unless(ret == strlen(sysTimeBuffer), "Wrong read size");
460 //printf("read buffer : %s\n", buffer);
469 * Test the key interface.
470 * Read the size of a key.
472 START_TEST(test_GetDataSize)
474 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
475 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
476 X_TEST_REPORT_REFERENCE("NONE");
477 X_TEST_REPORT_DESCRIPTION("Test of get data size");
478 X_TEST_REPORT_TYPE(GOOD);
480 int size = 0, ret = 0;
482 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
484 ret = pclInitLibrary(gTheAppId, shutdownReg);
485 x_fail_unless(ret <= 1, "Failed to init PCL");
488 * Logical DB ID: 0xFF with user 3 and seat 2
489 * ==> local USER value (user 3, seat 2)
491 size = pclKeyGetSize(0xFF, "status/open_document", 3, 2);
492 x_fail_unless(size == strlen("WT_ /var/opt/user_manual_climateControl.pdf"), "Invalid size");
496 * Logical DB ID: 0x84 with user 2 and seat 1
497 * ==> shared user value accessible by A GROUP (user 2 and seat 1)
499 size = pclKeyGetSize(0x84, "links/last_link", 2, 1);
500 x_fail_unless(size == strlen("CACHE_ /last_exit/queens"), "Invalid size");
508 * Delete a key using the key value interface.
509 * First read a from a key, the delte the key
510 * and then try to read again. The Last read must fail.
512 START_TEST(test_DeleteData)
514 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
515 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
516 X_TEST_REPORT_REFERENCE("NONE");
517 X_TEST_REPORT_DESCRIPTION("Test of delete data");
518 X_TEST_REPORT_TYPE(GOOD);
521 unsigned char buffer[READ_SIZE];
522 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
524 rval = pclInitLibrary(gTheAppId, shutdownReg);
525 x_fail_unless(rval <= 1, "Failed to init PCL");
527 // read data from key
528 rval = pclKeyReadData(0xFF, "key_70", 1, 2, buffer, READ_SIZE);
529 x_fail_unless(rval != EPERS_NOKEY, "Read form key key_70 fails");
532 rval = pclKeyDelete(0xFF, "key_70", 1, 2);
533 x_fail_unless(rval >= 0, "Failed to delete key");
535 // after deleting the key, reading from key must fail now!
536 rval = pclKeyReadData(0xFF, "key_70", 1, 2, buffer, READ_SIZE);
537 x_fail_unless(rval == EPERS_NOKEY, "Read form key key_70 works, but should fail");
541 // read data from key
542 rval = pclKeyReadData(0xFF, "70", 1, 2, buffer, READ_SIZE);
543 x_fail_unless(rval != EPERS_NOKEY, "Read form key 70 fails");
546 rval = pclKeyDelete(0xFF, "70", 1, 2);
547 x_fail_unless(rval >= 0, "Failed to delete key");
549 // after deleting the key, reading from key must fail now!
550 rval = pclKeyReadData(0xFF, "70", 1, 2, buffer, READ_SIZE);
551 x_fail_unless(rval == EPERS_NOKEY, "Read form key 70 works, but should fail");
560 * Test the file interface:
567 START_TEST(test_DataFile)
569 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
570 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
571 X_TEST_REPORT_REFERENCE("NONE");
572 X_TEST_REPORT_DESCRIPTION("Test of data file");
573 X_TEST_REPORT_TYPE(GOOD);
575 int fd = 0, i = 0, idx = 0;
576 int size = 0, ret = 0;
577 int writeSize = 16*1024;
578 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
580 unsigned char buffer[READ_SIZE] = {0};
581 const char* refBuffer = "/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media";
583 char* fileMap = NULL;
585 ret = pclInitLibrary(gTheAppId, shutdownReg);
586 x_fail_unless(ret <= 1, "Failed to init PCL");
588 writeBuffer = malloc(writeSize);
591 // fill buffer a sequence
592 for(i = 0; i<(writeSize/8); i++)
594 writeBuffer[idx++] = 'A';
595 writeBuffer[idx++] = 'B';
596 writeBuffer[idx++] = 'C';
597 writeBuffer[idx++] = ' ';
598 writeBuffer[idx++] = 'D';
599 writeBuffer[idx++] = 'E';
600 writeBuffer[idx++] = 'F';
601 writeBuffer[idx++] = ' ';
604 fd = open("/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDBWrite.db",
605 O_CREAT|O_RDWR|O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
608 // open ------------------------------------------------------------
609 fd = pclFileOpen(0xFF, "media/mediaDB.db", 1, 1);
610 x_fail_unless(fd != -1, "Could not open file ==> /media/mediaDB.db");
612 size = pclFileGetSize(fd);
613 x_fail_unless(size == 68, "Wrong file size");
615 size = pclFileReadData(fd, buffer, READ_SIZE);
616 x_fail_unless(strncmp((char*)buffer, refBuffer, strlen(refBuffer)) == 0, "Buffer not correctly read => media/mediaDB.db");
617 x_fail_unless(size == (strlen(refBuffer)+1), "Wrong size returned"); // strlen + 1 ==> inlcude cr/lf
619 ret = pclFileClose(fd);
620 x_fail_unless(ret == 0, "Failed to close file");
622 // open ------------------------------------------------------------
623 fd = pclFileOpen(0xFF, "media/mediaDBWrite.db", 1, 1);
624 x_fail_unless(fd != -1, "Could not open file ==> /media/mediaDBWrite.db");
626 size = pclFileWriteData(fd, writeBuffer, strlen(writeBuffer));
627 x_fail_unless(size == strlen(writeBuffer), "Failed to write data");
628 ret = pclFileClose(fd);
629 x_fail_unless(ret == 0, "Failed to close file");
631 // remove ----------------------------------------------------------
632 ret = pclFileRemove(0xFF, "media/mediaDBWrite.db", 1, 1);
633 x_fail_unless(ret == 0, "File can't be removed ==> /media/mediaDBWrite.db");
635 fd = open("/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDBWrite.db",O_RDWR);
636 x_fail_unless(fd == -1, "Failed to remove file, file still exists");
639 // map file --------------------------------------------------------
641 fd = pclFileOpen(0xFF, "media/mediaDB.db", 1, 1);
643 size = pclFileGetSize(fd);
644 pclFileMapData(fileMap, size, 0, fd);
645 x_fail_unless(fileMap != MAP_FAILED, "Failed to map file");
647 ret = pclFileUnmapData(fileMap, size);
648 x_fail_unless(ret != -1, "Failed to unmap file");
651 size = pclFileGetSize(1024);
652 x_fail_unless(ret == 0, "Got size, but should not");
654 ret = pclFileClose(fd);
655 x_fail_unless(ret == 0, "Failed to close file");
667 START_TEST(test_DataFileRecovery)
669 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
670 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
671 X_TEST_REPORT_REFERENCE("NONE");
672 X_TEST_REPORT_DESCRIPTION("Test of data file recovery");
673 X_TEST_REPORT_TYPE(GOOD);
675 int fd_RW = 0, fd_RO = 0;
677 char* wBuffer = "This is a buffer to write";
678 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
680 ret = pclInitLibrary(gTheAppId, shutdownReg);
681 x_fail_unless(ret <= 1, "Failed to init PCL");
684 // test backup creation --------------------------------------------
685 fd_RO = pclFileOpen(0xFF, "media/mediaDB_ReadOnly.db", 1, 1);
686 x_fail_unless(fd_RO != -1, "Could not open file ==> /media/mediaDB_ReadOnly.db");
688 fd_RW = pclFileOpen(0xFF, "media/mediaDB_ReadWrite.db", 1, 1);
689 x_fail_unless(fd_RW != -1, "Could not open file ==> /media/mediaDB_ReadWrite.db");
690 pclFileWriteData(fd_RW, wBuffer, strlen(wBuffer));
692 ret = pclFileClose(fd_RW);
695 ret = pclFileClose(fd_RO);
704 * The the handle function of the key and file interface.
706 START_TEST(test_DataHandle)
708 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
709 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
710 X_TEST_REPORT_REFERENCE("NONE");
711 X_TEST_REPORT_DESCRIPTION("Test of data handle");
712 X_TEST_REPORT_TYPE(GOOD);
714 int handle1 = 0, handle2 = 0;
715 int handleArray[4] = {0};
717 unsigned char buffer[READ_SIZE] = {0};
718 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
720 ret = pclInitLibrary(gTheAppId, shutdownReg);
721 x_fail_unless(ret <= 1, "Failed to init PCL");
724 handle1 = pclFileOpen(0xFF, "media/mediaDB.db", 1, 1);
725 x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB.db");
727 ret = pclFileClose(handle1);
728 x_fail_unless(handle1 != -1, "Could not closefile ==> /media/mediaDB.db");
730 ret = pclFileClose(1024);
731 x_fail_unless(ret == EPERS_MAXHANDLE, "Could close file, but should not!!");
733 ret = pclFileClose(17);
734 x_fail_unless(ret == -1, "Could close file, but should not!!");
736 // test multiple handles
737 handleArray[0] = pclFileOpen(0xFF, "media/mediaDB_write_01.db", 1, 1);
738 x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_01.db");
740 handleArray[1] = pclFileOpen(0xFF, "media/mediaDB_write_02.db", 1, 1);
741 x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_02.db");
743 handleArray[2] = pclFileOpen(0xFF, "media/mediaDB_write_03.db", 1, 1);
744 x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_03.db");
746 handleArray[3] = pclFileOpen(0xFF, "media/mediaDB_write_04.db", 1, 1);
747 x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_04.db");
749 ret = pclFileReadData(handleArray[0], buffer, READ_SIZE);
750 x_fail_unless(ret >= 0, "Failed to read handle idx \"0\"!!");
751 x_fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_01.db",
752 strlen("/user/1/seat/1/media/mediaDB_write_01.db"))
753 == 0, "Buffer not correctly read => mediaDB_write_01.db");
755 ret = pclFileReadData(handleArray[1], buffer, READ_SIZE);
756 x_fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_02.db",
757 strlen("/user/1/seat/1/media/mediaDB_write_02.db"))
758 == 0, "Buffer not correctly read => mediaDB_write_02.db");
760 ret = pclFileReadData(handleArray[2], buffer, READ_SIZE);
761 x_fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_03.db",
762 strlen("/user/1/seat/1/media/mediaDB_write_03.db"))
763 == 0, "Buffer not correctly read => mediaDB_write_03.db");
765 (void)pclFileReadData(handleArray[3], buffer, READ_SIZE);
766 x_fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_04.db",
767 strlen("/user/1/seat/1/media/mediaDB_write_04.db"))
768 == 0, "Buffer not correctly read => mediaDB_write_04.db");
770 ret = pclKeyHandleClose(handleArray[0]);
771 x_fail_unless(ret != -1, "Failed to close handle idx \"0\"!!");
773 ret = pclKeyHandleClose(handleArray[1]);
774 x_fail_unless(ret != -1, "Failed to close handle idx \"1\"!!");
776 ret = pclKeyHandleClose(handleArray[2]);
777 x_fail_unless(ret != -1, "Failed to close handle idx \"2\"!!");
779 ret = pclKeyHandleClose(handleArray[3]);
780 x_fail_unless(ret != -1, "Failed to close handle idx \"3\"!!");
783 handle2 = pclKeyHandleOpen(0xFF, "statusHandle/open_document", 3, 2);
784 x_fail_unless(handle2 >= 0, "Failed to open handle /statusHandle/open_document");
786 ret = pclKeyHandleClose(handle2);
787 x_fail_unless(ret != -1, "Failed to close handle!!");
789 ret = pclKeyHandleClose(1024);
790 x_fail_unless(ret == EPERS_MAXHANDLE, "Max handle!!");
799 * Extended key handle test.
800 * Test have been created after a bug in the key handle function occured.
802 START_TEST(test_DataHandleOpen)
804 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
805 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
806 X_TEST_REPORT_REFERENCE("NONE");
807 X_TEST_REPORT_DESCRIPTION("Test of data handle open");
808 X_TEST_REPORT_TYPE(GOOD);
810 int hd1 = -2, hd2 = -2, hd3 = -2, hd4 = -2, hd5 = -2, hd6 = -2, hd7 = -2, hd8 = -2, hd9 = -2, ret = 0;
811 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
813 ret = pclInitLibrary(gTheAppId, shutdownReg);
814 x_fail_unless(ret <= 1, "Failed to init PCL");
816 // open handles ----------------------------------------------------
817 hd1 = pclKeyHandleOpen(0xFF, "posHandle/last_position1", 0, 0);
818 x_fail_unless(hd1 == 1, "Failed to open handle ==> /posHandle/last_position1");
820 hd2 = pclKeyHandleOpen(0xFF, "posHandle/last_position2", 0, 0);
821 x_fail_unless(hd2 == 2, "Failed to open handle ==> /posHandle/last_position2");
823 hd3 = pclKeyHandleOpen(0xFF, "posHandle/last_position3", 0, 0);
824 x_fail_unless(hd3 == 3, "Failed to open handle ==> /posHandle/last_position3");
826 // close handles ---------------------------------------------------
827 ret = pclKeyHandleClose(hd1);
828 x_fail_unless(ret != -1, "Failed to close handle!!");
830 ret = pclKeyHandleClose(hd2);
831 x_fail_unless(ret != -1, "Failed to close handle!!");
833 ret = pclKeyHandleClose(hd3);
834 x_fail_unless(ret != -1, "Failed to close handle!!");
836 // open handles ----------------------------------------------------
837 hd4 = pclKeyHandleOpen(0xFF, "posHandle/last_position4", 0, 0);
838 x_fail_unless(hd4 == 3, "Failed to open handle ==> /posHandle/last_position4");
840 hd5 = pclKeyHandleOpen(0xFF, "posHandle/last_position5", 0, 0);
841 x_fail_unless(hd5 == 2, "Failed to open handle ==> /posHandle/last_position5");
843 hd6 = pclKeyHandleOpen(0xFF, "posHandle/last_position6", 0, 0);
844 x_fail_unless(hd6 == 1, "Failed to open handle ==> /posHandle/last_position6");
846 hd7 = pclKeyHandleOpen(0xFF, "posHandle/last_position7", 0, 0);
847 x_fail_unless(hd7 == 4, "Failed to open handle ==> /posHandle/last_position7");
849 hd8 = pclKeyHandleOpen(0xFF, "posHandle/last_position8", 0, 0);
850 x_fail_unless(hd8 == 5, "Failed to open handle ==> /posHandle/last_position8");
852 hd9 = pclKeyHandleOpen(0xFF, "posHandle/last_position9", 0, 0);
853 x_fail_unless(hd9 == 6, "Failed to open handle ==> /posHandle/last_position9");
855 // close handles ---------------------------------------------------
856 ret = pclKeyHandleClose(hd4);
857 x_fail_unless(ret != -1, "Failed to close handle!!");
859 ret = pclKeyHandleClose(hd5);
860 x_fail_unless(ret != -1, "Failed to close handle!!");
862 ret = pclKeyHandleClose(hd6);
863 x_fail_unless(ret != -1, "Failed to close handle!!");
865 ret = pclKeyHandleClose(hd7);
866 x_fail_unless(ret != -1, "Failed to close handle!!");
868 ret = pclKeyHandleClose(hd8);
869 x_fail_unless(ret != -1, "Failed to close handle!!");
871 ret = pclKeyHandleClose(hd9);
872 x_fail_unless(ret != -1, "Failed to close handle!!");
880 START_TEST(test_Plugin)
882 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
883 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
884 X_TEST_REPORT_REFERENCE("NONE");
885 X_TEST_REPORT_DESCRIPTION("Test of plugins");
886 X_TEST_REPORT_TYPE(GOOD);
889 unsigned char buffer[READ_SIZE] = {0};
891 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
893 ret = pclInitLibrary(gTheAppId, shutdownReg);
894 x_fail_unless(ret <= 1, "Failed to init PCL");
896 ret = pclKeyReadData(0xFF, "language/country_code", 0, 0, buffer, READ_SIZE);
897 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
898 x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: secure!",
899 strlen((char*)buffer)) == 0, "Buffer SECURE not correctly read");
902 ret = pclKeyReadData(0xFF, "language/country_code_early", 0, 0, buffer, READ_SIZE);
903 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
904 //printf("B U F F E R - early: %s\n", buffer);
905 x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: early!",
906 strlen((char*)buffer)) == 0, "Buffer EARLY not correctly read");
908 ret = pclKeyReadData(0xFF, "language/country_code_emergency", 0, 0, buffer, READ_SIZE);
909 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
910 //printf("B U F F E R - emergency: %s\n", buffer);
911 x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: emergency!",
912 strlen((char*)buffer)) == 0, "Buffer EMERGENCY not correctly read");
914 ret = pclKeyReadData(0xFF, "language/info", 0, 0, buffer, READ_SIZE);
915 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
916 //printf("B U F F E R - hwinfo: %s\n", buffer);
917 x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: hwinfo!",
918 strlen((char*)buffer)) == 0, "Buffer HWINFO not correctly read");
920 ret = pclKeyReadData(0xFF, "language/country_code_custom3", 0, 0, buffer, READ_SIZE);
921 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
922 //printf("B U F F E R - hwinfo: %s\n", buffer);
923 x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: custom3!",
924 strlen((char*)buffer)) == 0, "Buffer CUSTOM 3 not correctly read");
934 START_TEST(test_ReadDefault)
936 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
937 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
938 X_TEST_REPORT_REFERENCE("NONE");
939 X_TEST_REPORT_DESCRIPTION("Test of read default");
940 X_TEST_REPORT_TYPE(GOOD);
943 unsigned char buffer[READ_SIZE] = {0};
945 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
947 ret = pclInitLibrary(gTheAppId, shutdownReg);
948 x_fail_unless(ret <= 1, "Failed to init PCL");
950 ret = pclKeyReadData(0xFF, "statusHandle/default01", 3, 2, buffer, READ_SIZE);
951 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
952 //printf("B U F F E R: %s\n", buffer);
953 x_fail_unless(strncmp((char*)buffer,"DEFAULT_01!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
955 ret = pclKeyReadData(0xFF, "statusHandle/default02", 3, 2, buffer, READ_SIZE);
956 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
957 //printf("B U F F E R: %s\n", buffer);
958 x_fail_unless(strncmp((char*)buffer,"DEFAULT_02!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
966 START_TEST(test_ReadConfDefault)
968 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
969 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
970 X_TEST_REPORT_REFERENCE("NONE");
971 X_TEST_REPORT_DESCRIPTION("Test of configurable default data");
972 X_TEST_REPORT_TYPE(GOOD);
975 unsigned char buffer[READ_SIZE] = {0};
977 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
979 ret = pclInitLibrary(gTheAppId, shutdownReg);
980 x_fail_unless(ret <= 1, "Failed to init PCL");
982 ret = pclKeyReadData(0xFF, "statusHandle/confdefault01", 3, 2, buffer, READ_SIZE);
983 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
984 x_fail_unless(strncmp((char*)buffer,"CONF_DEFAULT_01!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
986 ret = pclKeyReadData(0xFF, "statusHandle/confdefault02", 3, 2, buffer, READ_SIZE);
987 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
988 x_fail_unless(strncmp((char*)buffer,"CONF_DEFAULT_02!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
996 START_TEST(test_GetPath)
998 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
999 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
1000 X_TEST_REPORT_REFERENCE("NONE");
1001 X_TEST_REPORT_DESCRIPTION("Test of get path");
1002 X_TEST_REPORT_TYPE(GOOD);
1006 const char* thePath = "/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDB_create.db";
1007 unsigned int pathSize = 0;
1009 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
1011 ret = pclInitLibrary(gTheAppId, shutdownReg);
1012 x_fail_unless(ret <= 1, "Failed to init PCL");
1014 ret = pclFileCreatePath(0xFF, "media/mediaDB_create.db", 1, 1, &path, &pathSize);
1016 x_fail_unless(strncmp((char*)path, thePath, strlen((char*)path)) == 0, "Path not correct");
1017 x_fail_unless(pathSize == strlen((char*)path), "Path size not correct");
1019 pclFileReleasePath(ret);
1027 START_TEST(test_InitDeinit)
1030 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
1034 // initialize and deinitialize 1. time
1035 (void)pclInitLibrary(gTheAppId, shutdownReg);
1039 // initialize and deinitialize 2. time
1040 (void)pclInitLibrary(gTheAppId, shutdownReg);
1044 // initialize and deinitialize 3. time
1045 (void)pclInitLibrary(gTheAppId, shutdownReg);
1053 START_TEST(test_NegHandle)
1055 int handle = -1, ret = 0;;
1056 int negativeHandle = -17;
1057 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
1059 unsigned char buffer[128] = {0};
1061 (void)pclInitLibrary(gTheAppId, shutdownReg);
1063 handle = pclKeyHandleOpen(0xFF, "posHandle/last_position", 0, 0);
1064 x_fail_unless(handle >= 0, "Failed to open handle ==> /posHandle/last_position");
1068 ret = pclKeyHandleReadData(negativeHandle, buffer, READ_SIZE);
1069 x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleReadData => negative handle not detected");
1071 ret = pclKeyHandleClose(negativeHandle);
1072 x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleClose => negative handle not detected");
1074 ret = pclKeyHandleGetSize(negativeHandle);
1075 x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleGetSize => negative handle not detected");
1077 ret = pclKeyHandleReadData(negativeHandle, buffer, 128);
1078 x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleReadData => negative handle not detected");
1080 ret = pclKeyHandleRegisterNotifyOnChange(negativeHandle, &myChangeCallback);
1081 x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleRegisterNotifyOnChange => negative handle not detected");
1083 ret = pclKeyHandleWriteData(negativeHandle, (unsigned char*)"Whatever", strlen("Whatever"));
1084 x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleWriteData => negative handle not detected");
1088 ret = pclKeyHandleClose(handle);
1101 static Suite * persistencyClientLib_suite()
1103 Suite * s = suite_create("Persistency client library");
1105 TCase * tc_persGetData = tcase_create("GetData");
1106 tcase_add_test(tc_persGetData, test_GetData);
1108 TCase * tc_persSetData = tcase_create("SetData");
1109 tcase_add_test(tc_persSetData, test_SetData);
1111 TCase * tc_persSetDataNoPRCT = tcase_create("SetDataNoPRCT");
1112 tcase_add_test(tc_persSetDataNoPRCT, test_SetDataNoPRCT);
1114 TCase * tc_persGetDataSize = tcase_create("GetDataSize");
1115 tcase_add_test(tc_persGetDataSize, test_GetDataSize);
1117 TCase * tc_persDeleteData = tcase_create("DeleteData");
1118 tcase_add_test(tc_persDeleteData, test_DeleteData);
1122 TCase * tc_persGetDataHandle = tcase_create("GetDataHandle");
1123 tcase_add_test(tc_persGetDataHandle, test_GetDataHandle);
1125 TCase * tc_persDataHandle = tcase_create("DataHandle");
1126 tcase_add_test(tc_persDataHandle, test_DataHandle);
1128 TCase * tc_persDataHandleOpen = tcase_create("DataHandleOpen");
1129 tcase_add_test(tc_persDataHandleOpen, test_DataHandleOpen);
1131 TCase * tc_persDataFile = tcase_create("DataFile");
1132 tcase_add_test(tc_persDataFile, test_DataFile);
1134 TCase * tc_persDataFileRecovery = tcase_create("DataFileRecovery");
1135 tcase_add_test(tc_persDataFileRecovery, test_DataFileRecovery);
1137 TCase * tc_Plugin = tcase_create("Plugin");
1138 tcase_add_test(tc_Plugin, test_Plugin);
1140 TCase * tc_ReadDefault = tcase_create("ReadDefault");
1141 tcase_add_test(tc_ReadDefault, test_ReadDefault);
1143 TCase * tc_ReadConfDefault = tcase_create("ReadConfDefault");
1144 tcase_add_test(tc_ReadConfDefault, test_ReadConfDefault);
1146 TCase * tc_GetPath = tcase_create("GetPath");
1147 tcase_add_test(tc_GetPath, test_GetPath);
1149 TCase * tc_InitDeinit = tcase_create("InitDeinit");
1150 tcase_add_test(tc_InitDeinit, test_InitDeinit);
1152 TCase * tc_NegHandle = tcase_create("NegHandle");
1153 tcase_add_test(tc_NegHandle, test_NegHandle);
1155 suite_add_tcase(s, tc_persSetData);
1156 suite_add_tcase(s, tc_persGetData);
1157 suite_add_tcase(s, tc_persSetDataNoPRCT);
1158 suite_add_tcase(s, tc_persGetDataSize);
1159 suite_add_tcase(s, tc_persDeleteData);
1160 suite_add_tcase(s, tc_persGetDataHandle);
1161 suite_add_tcase(s, tc_persDataHandle);
1162 suite_add_tcase(s, tc_persDataHandleOpen);
1163 suite_add_tcase(s, tc_persDataFile);
1164 suite_add_tcase(s, tc_persDataFileRecovery);
1165 suite_add_tcase(s, tc_ReadDefault);
1166 suite_add_tcase(s, tc_ReadConfDefault);
1167 suite_add_tcase(s, tc_GetPath);
1168 suite_add_tcase(s, tc_InitDeinit);
1169 suite_add_tcase(s, tc_NegHandle);
1171 //suite_add_tcase(s, tc_Plugin); // activate only if the plugins are available
1177 int main(int argc, char *argv[])
1184 TestResult** tResult;
1186 // assign application name
1187 strncpy(gTheAppId, "lt-persistence_client_library_test", MaxAppNameLen);
1188 gTheAppId[MaxAppNameLen-1] = '\0';
1190 /// debug log and trace (DLT) setup
1191 DLT_REGISTER_APP("PCLt","tests the persistence client library");
1194 Suite * s = persistencyClientLib_suite();
1195 SRunner * sr = srunner_create(s);
1196 srunner_set_xml(sr, "/tmp/persistenceClientLibraryTest.xml");
1197 srunner_set_log(sr, "/tmp/persistenceClientLibraryTest.log");
1198 srunner_run_all(sr, CK_VERBOSE /*CK_NORMAL CK_VERBOSE*/);
1200 nr_failed = srunner_ntests_failed(sr);
1201 nr_run = srunner_ntests_run(sr);
1203 tResult = srunner_results(sr);
1204 for(i = 0; i< nr_run; i++)
1206 (void)tr_rtype(tResult[i]); // get status of each test
1207 //fail = tr_rtype(tResult[i]); // get status of each test
1208 //printf("[%d] Fail: %d \n", i, fail);
1214 // unregister debug log and trace
1215 DLT_UNREGISTER_APP();
1219 return (0==nr_failed)?EXIT_SUCCESS:EXIT_FAILURE;