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"};
52 int myChangeCallback(pclNotification_s * notifyStruct)
54 printf(" ==> * - * myChangeCallback * - *\n");
59 * Test the key value interface using different logicalDB id's, users and seats.
60 * Each resource below has an entry in the resource configuration table where the
61 * storage location (cached or write through) and type (e.g. custom) has been configured.
63 START_TEST(test_GetData)
65 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
66 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
67 X_TEST_REPORT_REFERENCE("NONE");
68 X_TEST_REPORT_DESCRIPTION("Test of get data");
69 X_TEST_REPORT_TYPE(GOOD);
72 unsigned int shutdownReg = (PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL);
74 unsigned char buffer[READ_SIZE] = {0};
76 ret = pclInitLibrary(gTheAppId, shutdownReg);
77 x_fail_unless(ret <= 1, "Failed to init PCL");
81 * Logical DB ID: 0xFF with user 0 and seat 0
82 * ==> local value accessible by all users (user 0, seat 0)
84 ret = pclKeyReadData(0xFF, "pos/last_position", 0, 0, buffer, READ_SIZE);
85 x_fail_unless(strncmp((char*)buffer, "CACHE_ +48° 10' 38.95\", +8° 44' 39.06\"",
86 strlen((char*)buffer)) == 0, "Buffer not correctly read");
87 x_fail_unless(ret = strlen("CACHE_ +48° 10' 38.95\", +8° 44' 39.06\""));
89 memset(buffer, 0, READ_SIZE);
92 * Logical DB ID: 0xFF with user 0 and seat 0
93 * ==> local value accessible by all users (user 0, seat 0)
96 ret = pclKeyReadData(0xFF, "language/country_code", 0, 0, buffer, READ_SIZE);
97 x_fail_unless(strncmp((char*)buffer, "Custom plugin -> plugin_get_data: secure!",
98 strlen((char*)buffer)) == 0, "Buffer not correctly read");
99 x_fail_unless(ret = strlen("Custom plugin -> plugin_get_data_handle"));
101 memset(buffer, 0, READ_SIZE);
106 * Logical DB ID: 0 with user 3 and seat 0
107 * ==> public shared user value (user 3, seat 0)
109 ret = pclKeyReadData(0, "language/current_language", 3, 0, buffer, READ_SIZE);
110 x_fail_unless(strncmp((char*)buffer, "CACHE_ Kisuaheli", strlen((char*)buffer)) == 0, "Buffer not correctly read");
112 memset(buffer, 0, READ_SIZE);
115 * Logical DB ID: 0xFF with user 3 and seat 2
116 * ==> local USER value (user 3, seat 2)
118 ret = pclKeyReadData(0xFF, "status/open_document", 3, 2, buffer, READ_SIZE);
119 x_fail_unless(strncmp((char*)buffer, "WT_ /var/opt/user_manual_climateControl.pdf", strlen((char*)buffer)) == 0, "Buffer not correctly read");
121 memset(buffer, 0, READ_SIZE);
124 * Logical DB ID: 0x20 with user 4 and seat 0
125 * ==> shared user value accessible by a group (user 4 and seat 0)
127 ret = pclKeyReadData(0x20, "address/home_address", 4, 0, buffer, READ_SIZE);
128 x_fail_unless(strncmp((char*)buffer, "WT_ 55327 Heimatstadt, Wohnstrasse 31", strlen((char*)buffer)) == 0, "Buffer not correctly read");
130 memset(buffer, 0, READ_SIZE);
133 * Logical DB ID: 0xFF with user 0 and seat 0
134 * ==> local value accessible by ALL USERS (user 0, seat 0)
136 ret = pclKeyReadData(0xFF, "pos/last_satellites", 0, 0, buffer, READ_SIZE);
137 x_fail_unless(strncmp((char*)buffer, "WT_ 17", strlen((char*)buffer)) == 0, "Buffer not correctly read");
139 memset(buffer, 0, READ_SIZE);
142 * Logical DB ID: 0x84 with user 4 and seat 0
143 * ==> shared user value accessible by A GROUP (user 4 and seat 0)
145 ret = pclKeyReadData(0x84, "links/last_link", 2, 0, buffer, READ_SIZE);
146 x_fail_unless(strncmp((char*)buffer, "CACHE_ /last_exit/brooklyn", strlen((char*)buffer)) == 0, "Buffer not correctly read");
148 memset(buffer, 0, READ_SIZE);
151 * Logical DB ID: 0x84 with user 2 and seat 1
152 * ==> local merge value
154 ret = pclKeyReadData(0x84, "links/last_link", 2, 1, buffer, READ_SIZE);
155 x_fail_unless(strncmp((char*)buffer, "CACHE_ /last_exit/queens", strlen((char*)buffer)) == 0, "Buffer not correctly read");
164 * Test the key value h a n d l e interface using different logicalDB id's, users and seats
165 * Each resource below has an entry in the resource configuration table where
166 * the storage location (cached or write through) and type (e.g. custom) has bee configured.
168 START_TEST (test_GetDataHandle)
170 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
171 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
172 X_TEST_REPORT_REFERENCE("NONE");
173 X_TEST_REPORT_DESCRIPTION("Test of get data handle");
174 X_TEST_REPORT_TYPE(GOOD);
176 int ret = 0, handle = 0, handle2 = 0, handle3 = 0, handle4 = 0, size = 0;
177 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
179 unsigned char buffer[READ_SIZE] = {0};
182 char sysTimeBuffer[128];
184 ret = pclInitLibrary(gTheAppId, shutdownReg);
185 x_fail_unless(ret <= 1, "Failed to init PCL");
189 locTime = localtime(&t);
191 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),
192 locTime->tm_hour, locTime->tm_min, locTime->tm_sec);
195 // open handle ---------------------------------------------------
197 * Logical DB ID: 0xFF with user 0 and seat 0
198 * ==> local value accessible by ALL USERS (user 0, seat 0)
200 handle = pclKeyHandleOpen(0xFF, "posHandle/last_position", 0, 0);
201 x_fail_unless(handle >= 0, "Failed to open handle ==> /posHandle/last_position");
203 ret = pclKeyHandleReadData(handle, buffer, READ_SIZE);
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 printf("pclKeyHandleWriteData: Soll: %d | ist:%d\n", strlen(sysTimeBuffer), size);
221 x_fail_unless(size == strlen(sysTimeBuffer));
223 ret = pclKeyHandleClose(handle2);
224 // ---------------------------------------------------------------------------------------------
227 // open handle ---------------------------------------------------
229 * Logical DB ID: 0xFF with user 0 and seat 0
230 * ==> local value accessible by ALL USERS (user 0, seat 0)
232 #if 0 // plugin test case
233 memset(buffer, 0, READ_SIZE);
234 handle4 = pclKeyHandleOpen(0xFF, "language/country_code", 0, 0);
235 printf("H A N D L E: %d\n", handle4);
236 x_fail_unless(handle4 >= 0, "Failed to open handle /language/country_code");
238 ret = pclKeyHandleReadData(handle4, buffer, READ_SIZE);
239 x_fail_unless(strncmp((char*)buffer, "Custom plugin -> plugin_get_data_handle: secure!", -1) == 0, "Buffer not correctly read => 2");
241 size = pclKeyHandleGetSize(handle4);
242 x_fail_unless(size = strlen("Custom plugin -> plugin_get_data_handle"));
244 ret = pclKeyHandleWriteData(handle4, (unsigned char*)"Only dummy implementation behind custom library", READ_SIZE);
246 // ---------------------------------------------------------------------------------------------
249 // open handle ---------------------------------------------------
251 * Logical DB ID: 0xFF with user 3 and seat 2
252 * ==> local USER value (user 3, seat 2)
254 handle3 = pclKeyHandleOpen(0xFF, "statusHandle/open_document", 3, 2);
255 x_fail_unless(handle3 >= 0, "Failed to open handle /statusHandle/open_document");
257 ret = pclKeyHandleReadData(handle3, buffer, READ_SIZE);
258 x_fail_unless(strncmp((char*)buffer, sysTimeBuffer, strlen(sysTimeBuffer)) == 0, "Buffer not correctly read => 3");
260 size = pclKeyHandleGetSize(handle3);
261 x_fail_unless(size = strlen(sysTimeBuffer));
262 // ---------------------------------------------------------------------------------------------
266 ret = pclKeyHandleClose(handle);
267 ret = pclKeyHandleClose(handle3);
268 ret = pclKeyHandleClose(handle4);
276 * Write data to a key using the key interface.
277 * First write data to different keys and after
278 * read the data for verification.
280 START_TEST(test_SetData)
282 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
283 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
284 X_TEST_REPORT_REFERENCE("NONE");
285 X_TEST_REPORT_DESCRIPTION("Test of set data");
286 X_TEST_REPORT_TYPE(GOOD);
289 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
290 unsigned char buffer[READ_SIZE] = {0};
291 char write1[READ_SIZE] = {0};
292 char write2[READ_SIZE] = {0};
293 char sysTimeBuffer[256];
297 ret = pclInitLibrary(gTheAppId, shutdownReg);
298 x_fail_unless(ret <= 1, "Failed to init PCL");
302 locTime = localtime(&t);
305 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),
306 locTime->tm_hour, locTime->tm_min, locTime->tm_sec);
309 * Logical DB ID: 0xFF with user 1 and seat 2
310 * ==> local USER value (user 1, seat 2)
313 ret = pclKeyWriteData(0xFF, "69", 1, 2, (unsigned char*)sysTimeBuffer, strlen(sysTimeBuffer));
314 x_fail_unless(ret == strlen(sysTimeBuffer), "Wrong write size");
316 snprintf(write1, 128, "%s %s", "/70", sysTimeBuffer);
318 * Logical DB ID: 0xFF with user 1 and seat 2
319 * ==> local USER value (user 1, seat 2)
322 ret = pclKeyWriteData(0xFF, "70", 1, 2, (unsigned char*)write1, strlen(write1));
323 x_fail_unless(ret == strlen(write1), "Wrong write size");
325 snprintf(write2, 128, "%s %s", "/key_70", sysTimeBuffer);
327 * Logical DB ID: 0xFF with user 1 and seat 2
328 * ==> local USER value (user 1, seat 2)
329 * Resource ID: key_70
331 ret = pclKeyWriteData(0xFF, "key_70", 1, 2, (unsigned char*)write2, strlen(write2));
332 x_fail_unless(ret == strlen(write2), "Wrong write size");
335 /*******************************************************************************************************************************************/
336 /* used for changed notification testing */
337 /*******************************************************************************************************************************************/
339 * Logical DB ID: 0x84 with user 2 and seat 1
340 * ==> shared user value accessible by A GROUP (user 2 and seat 1)
342 * ==> used for shared testing
344 //printf("Write data to trigger change notification\n");
345 ret = pclKeyWriteData(0x84, "links/last_link2", 2, 1, (unsigned char*)"Test notify shared data", strlen("Test notify shared data"));
346 x_fail_unless(ret == strlen("Test notify shared data"), "Wrong write size");
349 * Logical DB ID: 0x84 with user 2 and seat 1
350 * ==> shared user value accessible by A GROUP (user 2 and seat 1)
352 * ==> used for shared testing
354 //printf("Write data to trigger change notification\n");
355 ret = pclKeyWriteData(0x84, "links/last_link3", 3, 2, (unsigned char*)"Test notify shared data", strlen("Test notify shared data"));
356 x_fail_unless(ret == strlen("Test notify shared data"), "Wrong write size");
359 * Logical DB ID: 0x84 with user 2 and seat 1
360 * ==> shared user value accessible by A GROUP (user 2 and seat 1)
362 * ==> used for shared testing
364 //printf("Write data to trigger change notification\n");
365 ret = pclKeyWriteData(0x84, "links/last_link4", 4, 1, (unsigned char*)"Test notify shared data", strlen("Test notify shared data"));
366 x_fail_unless(ret == strlen("Test notify shared data"), "Wrong write size");
367 /*******************************************************************************************************************************************/
368 /*******************************************************************************************************************************************/
372 * now read the data written in the previous steps to the keys
373 * and verify data has been written correctly.
375 memset(buffer, 0, READ_SIZE);
377 ret = pclKeyReadData(0xFF, "69", 1, 2, buffer, READ_SIZE);
378 x_fail_unless(strncmp((char*)buffer, sysTimeBuffer, strlen(sysTimeBuffer)) == 0, "Buffer not correctly read");
379 x_fail_unless(ret == strlen(sysTimeBuffer), "Wrong read size");
381 memset(buffer, 0, READ_SIZE);
383 ret = pclKeyReadData(0xFF, "70", 1, 2, buffer, READ_SIZE);
384 x_fail_unless(strncmp((char*)buffer, write1, strlen(write1)) == 0, "Buffer not correctly read");
385 x_fail_unless(ret == strlen(write1), "Wrong read size");
387 memset(buffer, 0, READ_SIZE);
389 ret = pclKeyReadData(0xFF, "key_70", 1, 2, buffer, READ_SIZE);
390 x_fail_unless(strncmp((char*)buffer, write2, strlen(write2)) == 0, "Buffer not correctly read");
391 x_fail_unless(ret == strlen(write2), "Wrong read size");
401 * Write data to a key using the key interface.
402 * The key is not in the persistence resource table.
403 * The key sill then be stored to the location local and cached.
405 START_TEST(test_SetDataNoPRCT)
407 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
408 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
409 X_TEST_REPORT_REFERENCE("NONE");
410 X_TEST_REPORT_DESCRIPTION("Test of set data no PRCT");
411 X_TEST_REPORT_TYPE(GOOD);
414 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
415 unsigned char buffer[READ_SIZE] = {0};
418 ret = pclInitLibrary(gTheAppId, shutdownReg);
419 x_fail_unless(ret <= 1, "Failed to init PCL");
423 char sysTimeBuffer[128];
425 locTime = localtime(&t);
427 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),
428 locTime->tm_hour, locTime->tm_min, locTime->tm_sec);
431 * Logical DB ID: 0xFF with user 1 and seat 2
432 * ==> local USER value (user 1, seat 2)
434 ret = pclKeyWriteData(0xFF, "NoPRCT", 1, 2, (unsigned char*)sysTimeBuffer, strlen(sysTimeBuffer));
435 x_fail_unless(ret == strlen(sysTimeBuffer), "Wrong write size");
436 //printf("Write Buffer : %s\n", sysTimeBuffer);
438 // read data again and and verify datat has been written correctly
439 memset(buffer, 0, READ_SIZE);
441 ret = pclKeyReadData(0xFF, "NoPRCT", 1, 2, buffer, READ_SIZE);
442 x_fail_unless(strncmp((char*)buffer, sysTimeBuffer, strlen(sysTimeBuffer)) == 0, "Buffer not correctly read");
443 x_fail_unless(ret == strlen(sysTimeBuffer), "Wrong read size");
444 //printf("read buffer : %s\n", buffer);
453 * Test the key interface.
454 * Read the size of a key.
456 START_TEST(test_GetDataSize)
458 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
459 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
460 X_TEST_REPORT_REFERENCE("NONE");
461 X_TEST_REPORT_DESCRIPTION("Test of get data size");
462 X_TEST_REPORT_TYPE(GOOD);
464 int size = 0, ret = 0;
466 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
468 ret = pclInitLibrary(gTheAppId, shutdownReg);
469 x_fail_unless(ret <= 1, "Failed to init PCL");
472 * Logical DB ID: 0xFF with user 3 and seat 2
473 * ==> local USER value (user 3, seat 2)
475 size = pclKeyGetSize(0xFF, "status/open_document", 3, 2);
476 x_fail_unless(size == strlen("WT_ /var/opt/user_manual_climateControl.pdf"), "Invalid size");
480 * Logical DB ID: 0x84 with user 2 and seat 1
481 * ==> shared user value accessible by A GROUP (user 2 and seat 1)
483 size = pclKeyGetSize(0x84, "links/last_link", 2, 1);
484 printf("=>=>=>=> soll: %d | ist: %d\n", strlen("CACHE_ /last_exit/queens"), size);
485 x_fail_unless(size == strlen("CACHE_ /last_exit/queens"), "Invalid size");
493 * Delete a key using the key value interface.
494 * First read a from a key, the delte the key
495 * and then try to read again. The Last read must fail.
497 START_TEST(test_DeleteData)
499 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
500 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
501 X_TEST_REPORT_REFERENCE("NONE");
502 X_TEST_REPORT_DESCRIPTION("Test of delete data");
503 X_TEST_REPORT_TYPE(GOOD);
506 unsigned char buffer[READ_SIZE];
507 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
509 rval = pclInitLibrary(gTheAppId, shutdownReg);
510 x_fail_unless(rval <= 1, "Failed to init PCL");
512 // read data from key
513 rval = pclKeyReadData(0xFF, "key_70", 1, 2, buffer, READ_SIZE);
514 x_fail_unless(rval != EPERS_NOKEY, "Read form key key_70 fails");
517 rval = pclKeyDelete(0xFF, "key_70", 1, 2);
518 x_fail_unless(rval >= 0, "Failed to delete key");
520 // after deleting the key, reading from key must fail now!
521 rval = pclKeyReadData(0xFF, "key_70", 1, 2, buffer, READ_SIZE);
522 x_fail_unless(rval == EPERS_NOKEY, "Read form key key_70 works, but should fail");
526 // read data from key
527 rval = pclKeyReadData(0xFF, "70", 1, 2, buffer, READ_SIZE);
528 x_fail_unless(rval != EPERS_NOKEY, "Read form key 70 fails");
531 rval = pclKeyDelete(0xFF, "70", 1, 2);
532 x_fail_unless(rval >= 0, "Failed to delete key");
534 // after deleting the key, reading from key must fail now!
535 rval = pclKeyReadData(0xFF, "70", 1, 2, buffer, READ_SIZE);
536 x_fail_unless(rval == EPERS_NOKEY, "Read form key 70 works, but should fail");
545 * Test the file interface:
552 START_TEST(test_DataFile)
554 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
555 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
556 X_TEST_REPORT_REFERENCE("NONE");
557 X_TEST_REPORT_DESCRIPTION("Test of data file");
558 X_TEST_REPORT_TYPE(GOOD);
560 int fd = 0, i = 0, idx = 0;
561 int size = 0, ret = 0;
562 int writeSize = 16*1024;
563 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
565 unsigned char buffer[READ_SIZE] = {0};
566 const char* refBuffer = "/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media";
568 char* fileMap = NULL;
570 ret = pclInitLibrary(gTheAppId, shutdownReg);
571 x_fail_unless(ret <= 1, "Failed to init PCL");
573 writeBuffer = malloc(writeSize);
576 // fill buffer a sequence
577 for(i = 0; i<(writeSize/8); i++)
579 writeBuffer[idx++] = 'A';
580 writeBuffer[idx++] = 'B';
581 writeBuffer[idx++] = 'C';
582 writeBuffer[idx++] = ' ';
583 writeBuffer[idx++] = 'D';
584 writeBuffer[idx++] = 'E';
585 writeBuffer[idx++] = 'F';
586 writeBuffer[idx++] = ' ';
589 fd = open("/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDBWrite.db",
590 O_CREAT|O_RDWR|O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
593 // open ------------------------------------------------------------
594 fd = pclFileOpen(0xFF, "media/mediaDB.db", 1, 1);
595 x_fail_unless(fd != -1, "Could not open file ==> /media/mediaDB.db");
597 size = pclFileGetSize(fd);
598 x_fail_unless(size == 68, "Wrong file size");
600 size = pclFileReadData(fd, buffer, READ_SIZE);
601 x_fail_unless(strncmp((char*)buffer, refBuffer, strlen(refBuffer)) == 0, "Buffer not correctly read => media/mediaDB.db");
602 x_fail_unless(size == (strlen(refBuffer)+1), "Wrong size returned"); // strlen + 1 ==> inlcude cr/lf
604 ret = pclFileClose(fd);
605 x_fail_unless(ret == 0, "Failed to close file");
607 // open ------------------------------------------------------------
608 fd = pclFileOpen(0xFF, "media/mediaDBWrite.db", 1, 1);
609 x_fail_unless(fd != -1, "Could not open file ==> /media/mediaDBWrite.db");
611 size = pclFileWriteData(fd, writeBuffer, strlen(writeBuffer));
612 x_fail_unless(size == strlen(writeBuffer), "Failed to write data");
613 ret = pclFileClose(fd);
614 x_fail_unless(ret == 0, "Failed to close file");
616 // remove ----------------------------------------------------------
617 ret = pclFileRemove(0xFF, "media/mediaDBWrite.db", 1, 1);
618 x_fail_unless(ret == 0, "File can't be removed ==> /media/mediaDBWrite.db");
620 fd = open("/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDBWrite.db",O_RDWR);
621 x_fail_unless(fd == -1, "Failed to remove file, file still exists");
624 // map file --------------------------------------------------------
626 fd = pclFileOpen(0xFF, "media/mediaDB.db", 1, 1);
628 size = pclFileGetSize(fd);
629 pclFileMapData(fileMap, size, 0, fd);
630 x_fail_unless(fileMap != MAP_FAILED, "Failed to map file");
632 ret = pclFileUnmapData(fileMap, size);
633 x_fail_unless(ret != -1, "Failed to unmap file");
636 size = pclFileGetSize(1024);
637 x_fail_unless(ret == 0, "Got size, but should not");
639 ret = pclFileClose(fd);
640 x_fail_unless(ret == 0, "Failed to close file");
652 START_TEST(test_DataFileRecovery)
654 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
655 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
656 X_TEST_REPORT_REFERENCE("NONE");
657 X_TEST_REPORT_DESCRIPTION("Test of data file recovery");
658 X_TEST_REPORT_TYPE(GOOD);
660 int fd_RW = 0, fd_RO = 0;
662 char* wBuffer = "This is a buffer to write";
663 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
665 ret = pclInitLibrary(gTheAppId, shutdownReg);
666 x_fail_unless(ret <= 1, "Failed to init PCL");
669 // test backup creation --------------------------------------------
670 fd_RO = pclFileOpen(0xFF, "media/mediaDB_ReadOnly.db", 1, 1);
671 x_fail_unless(fd_RO != -1, "Could not open file ==> /media/mediaDB_ReadOnly.db");
673 fd_RW = pclFileOpen(0xFF, "media/mediaDB_ReadWrite.db", 1, 1);
674 x_fail_unless(fd_RW != -1, "Could not open file ==> /media/mediaDB_ReadWrite.db");
675 pclFileWriteData(fd_RW, wBuffer, strlen(wBuffer));
677 ret = pclFileClose(fd_RW);
680 ret = pclFileClose(fd_RO);
689 * The the handle function of the key and file interface.
691 START_TEST(test_DataHandle)
693 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
694 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
695 X_TEST_REPORT_REFERENCE("NONE");
696 X_TEST_REPORT_DESCRIPTION("Test of data handle");
697 X_TEST_REPORT_TYPE(GOOD);
699 int handle1 = 0, handle2 = 0;
700 int handleArray[4] = {0};
702 unsigned char buffer[READ_SIZE] = {0};
703 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
705 ret = pclInitLibrary(gTheAppId, shutdownReg);
706 x_fail_unless(ret <= 1, "Failed to init PCL");
709 handle1 = pclFileOpen(0xFF, "media/mediaDB.db", 1, 1);
710 x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB.db");
712 ret = pclFileClose(handle1);
713 x_fail_unless(handle1 != -1, "Could not closefile ==> /media/mediaDB.db");
715 ret = pclFileClose(1024);
716 x_fail_unless(ret == EPERS_MAXHANDLE, "Could close file, but should not!!");
718 ret = pclFileClose(17);
719 x_fail_unless(ret == -1, "Could close file, but should not!!");
721 // test multiple handles
722 handleArray[0] = pclFileOpen(0xFF, "media/mediaDB_write_01.db", 1, 1);
723 x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_01.db");
725 handleArray[1] = pclFileOpen(0xFF, "media/mediaDB_write_02.db", 1, 1);
726 x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_02.db");
728 handleArray[2] = pclFileOpen(0xFF, "media/mediaDB_write_03.db", 1, 1);
729 x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_03.db");
731 handleArray[3] = pclFileOpen(0xFF, "media/mediaDB_write_04.db", 1, 1);
732 x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_04.db");
734 (void)pclFileReadData(handleArray[0], buffer, READ_SIZE);
735 x_fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_01.db",
736 strlen("/user/1/seat/1/media/mediaDB_write_01.db"))
737 == 0, "Buffer not correctly read => mediaDB_write_01.db");
739 (void)pclFileReadData(handleArray[1], buffer, READ_SIZE);
740 x_fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_02.db",
741 strlen("/user/1/seat/1/media/mediaDB_write_02.db"))
742 == 0, "Buffer not correctly read => mediaDB_write_02.db");
744 (void)pclFileReadData(handleArray[2], buffer, READ_SIZE);
745 x_fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_03.db",
746 strlen("/user/1/seat/1/media/mediaDB_write_03.db"))
747 == 0, "Buffer not correctly read => mediaDB_write_03.db");
749 (void)pclFileReadData(handleArray[3], buffer, READ_SIZE);
750 x_fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_04.db",
751 strlen("/user/1/seat/1/media/mediaDB_write_04.db"))
752 == 0, "Buffer not correctly read => mediaDB_write_04.db");
754 ret = pclKeyHandleClose(handleArray[0]);
755 x_fail_unless(ret != -1, "Failed to close handle idx \"0\"!!");
757 ret = pclKeyHandleClose(handleArray[1]);
758 x_fail_unless(ret != -1, "Failed to close handle idx \"1\"!!");
760 ret = pclKeyHandleClose(handleArray[2]);
761 x_fail_unless(ret != -1, "Failed to close handle idx \"2\"!!");
763 ret = pclKeyHandleClose(handleArray[3]);
764 x_fail_unless(ret != -1, "Failed to close handle idx \"3\"!!");
767 handle2 = pclKeyHandleOpen(0xFF, "statusHandle/open_document", 3, 2);
768 x_fail_unless(handle2 >= 0, "Failed to open handle /statusHandle/open_document");
770 ret = pclKeyHandleClose(handle2);
771 x_fail_unless(ret != -1, "Failed to close handle!!");
773 ret = pclKeyHandleClose(1024);
774 x_fail_unless(ret == EPERS_MAXHANDLE, "Max handle!!");
783 * Extended key handle test.
784 * Test have been created after a bug in the key handle function occured.
786 START_TEST(test_DataHandleOpen)
788 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
789 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
790 X_TEST_REPORT_REFERENCE("NONE");
791 X_TEST_REPORT_DESCRIPTION("Test of data handle open");
792 X_TEST_REPORT_TYPE(GOOD);
794 int hd1 = -2, hd2 = -2, hd3 = -2, hd4 = -2, hd5 = -2, hd6 = -2, hd7 = -2, hd8 = -2, hd9 = -2, ret = 0;
795 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
797 ret = pclInitLibrary(gTheAppId, shutdownReg);
798 x_fail_unless(ret <= 1, "Failed to init PCL");
800 // open handles ----------------------------------------------------
801 hd1 = pclKeyHandleOpen(0xFF, "posHandle/last_position1", 0, 0);
802 x_fail_unless(hd1 == 1, "Failed to open handle ==> /posHandle/last_position1");
804 hd2 = pclKeyHandleOpen(0xFF, "posHandle/last_position2", 0, 0);
805 x_fail_unless(hd2 == 2, "Failed to open handle ==> /posHandle/last_position2");
807 hd3 = pclKeyHandleOpen(0xFF, "posHandle/last_position3", 0, 0);
808 x_fail_unless(hd3 == 3, "Failed to open handle ==> /posHandle/last_position3");
810 // close handles ---------------------------------------------------
811 ret = pclKeyHandleClose(hd1);
812 x_fail_unless(ret != -1, "Failed to close handle!!");
814 ret = pclKeyHandleClose(hd2);
815 x_fail_unless(ret != -1, "Failed to close handle!!");
817 ret = pclKeyHandleClose(hd3);
818 x_fail_unless(ret != -1, "Failed to close handle!!");
820 // open handles ----------------------------------------------------
821 hd4 = pclKeyHandleOpen(0xFF, "posHandle/last_position4", 0, 0);
822 x_fail_unless(hd4 == 3, "Failed to open handle ==> /posHandle/last_position4");
824 hd5 = pclKeyHandleOpen(0xFF, "posHandle/last_position5", 0, 0);
825 x_fail_unless(hd5 == 2, "Failed to open handle ==> /posHandle/last_position5");
827 hd6 = pclKeyHandleOpen(0xFF, "posHandle/last_position6", 0, 0);
828 x_fail_unless(hd6 == 1, "Failed to open handle ==> /posHandle/last_position6");
830 hd7 = pclKeyHandleOpen(0xFF, "posHandle/last_position7", 0, 0);
831 x_fail_unless(hd7 == 4, "Failed to open handle ==> /posHandle/last_position7");
833 hd8 = pclKeyHandleOpen(0xFF, "posHandle/last_position8", 0, 0);
834 x_fail_unless(hd8 == 5, "Failed to open handle ==> /posHandle/last_position8");
836 hd9 = pclKeyHandleOpen(0xFF, "posHandle/last_position9", 0, 0);
837 x_fail_unless(hd9 == 6, "Failed to open handle ==> /posHandle/last_position9");
839 // close handles ---------------------------------------------------
840 ret = pclKeyHandleClose(hd4);
841 x_fail_unless(ret != -1, "Failed to close handle!!");
843 ret = pclKeyHandleClose(hd5);
844 x_fail_unless(ret != -1, "Failed to close handle!!");
846 ret = pclKeyHandleClose(hd6);
847 x_fail_unless(ret != -1, "Failed to close handle!!");
849 ret = pclKeyHandleClose(hd7);
850 x_fail_unless(ret != -1, "Failed to close handle!!");
852 ret = pclKeyHandleClose(hd8);
853 x_fail_unless(ret != -1, "Failed to close handle!!");
855 ret = pclKeyHandleClose(hd9);
856 x_fail_unless(ret != -1, "Failed to close handle!!");
864 START_TEST(test_Plugin)
866 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
867 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
868 X_TEST_REPORT_REFERENCE("NONE");
869 X_TEST_REPORT_DESCRIPTION("Test of plugins");
870 X_TEST_REPORT_TYPE(GOOD);
873 unsigned char buffer[READ_SIZE] = {0};
875 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
877 ret = pclInitLibrary(gTheAppId, shutdownReg);
878 x_fail_unless(ret <= 1, "Failed to init PCL");
880 ret = pclKeyReadData(0xFF, "language/country_code", 0, 0, buffer, READ_SIZE);
881 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
882 x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: secure!",
883 strlen((char*)buffer)) == 0, "Buffer SECURE not correctly read");
886 ret = pclKeyReadData(0xFF, "language/country_code_early", 0, 0, buffer, READ_SIZE);
887 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
888 //printf("B U F F E R - early: %s\n", buffer);
889 x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: early!",
890 strlen((char*)buffer)) == 0, "Buffer EARLY not correctly read");
892 ret = pclKeyReadData(0xFF, "language/country_code_emergency", 0, 0, buffer, READ_SIZE);
893 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
894 //printf("B U F F E R - emergency: %s\n", buffer);
895 x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: emergency!",
896 strlen((char*)buffer)) == 0, "Buffer EMERGENCY not correctly read");
898 ret = pclKeyReadData(0xFF, "language/info", 0, 0, buffer, READ_SIZE);
899 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
900 //printf("B U F F E R - hwinfo: %s\n", buffer);
901 x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: hwinfo!",
902 strlen((char*)buffer)) == 0, "Buffer HWINFO not correctly read");
904 ret = pclKeyReadData(0xFF, "language/country_code_custom3", 0, 0, buffer, READ_SIZE);
905 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
906 //printf("B U F F E R - hwinfo: %s\n", buffer);
907 x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: custom3!",
908 strlen((char*)buffer)) == 0, "Buffer CUSTOM 3 not correctly read");
918 START_TEST(test_ReadDefault)
920 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
921 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
922 X_TEST_REPORT_REFERENCE("NONE");
923 X_TEST_REPORT_DESCRIPTION("Test of read default");
924 X_TEST_REPORT_TYPE(GOOD);
927 unsigned char buffer[READ_SIZE] = {0};
929 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
931 ret = pclInitLibrary(gTheAppId, shutdownReg);
932 x_fail_unless(ret <= 1, "Failed to init PCL");
934 ret = pclKeyReadData(0xFF, "statusHandle/default01", 3, 2, buffer, READ_SIZE);
935 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
936 //printf("B U F F E R: %s\n", buffer);
937 x_fail_unless(strncmp((char*)buffer,"DEFAULT_01!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
939 ret = pclKeyReadData(0xFF, "statusHandle/default02", 3, 2, buffer, READ_SIZE);
940 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
941 //printf("B U F F E R: %s\n", buffer);
942 x_fail_unless(strncmp((char*)buffer,"DEFAULT_02!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
950 START_TEST(test_ReadConfDefault)
952 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
953 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
954 X_TEST_REPORT_REFERENCE("NONE");
955 X_TEST_REPORT_DESCRIPTION("Test of configurable default data");
956 X_TEST_REPORT_TYPE(GOOD);
959 unsigned char buffer[READ_SIZE] = {0};
961 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
963 ret = pclInitLibrary(gTheAppId, shutdownReg);
964 x_fail_unless(ret <= 1, "Failed to init PCL");
966 ret = pclKeyReadData(0xFF, "statusHandle/confdefault01", 3, 2, buffer, READ_SIZE);
967 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
968 x_fail_unless(strncmp((char*)buffer,"CONF_DEFAULT_01!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
970 ret = pclKeyReadData(0xFF, "statusHandle/confdefault02", 3, 2, buffer, READ_SIZE);
971 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
972 x_fail_unless(strncmp((char*)buffer,"CONF_DEFAULT_02!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
980 START_TEST(test_GetPath)
982 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
983 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
984 X_TEST_REPORT_REFERENCE("NONE");
985 X_TEST_REPORT_DESCRIPTION("Test of get path");
986 X_TEST_REPORT_TYPE(GOOD);
990 const char* thePath = "/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDB_create.db";
991 unsigned int pathSize = 0;
993 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
995 ret = pclInitLibrary(gTheAppId, shutdownReg);
996 x_fail_unless(ret <= 1, "Failed to init PCL");
998 ret = pclFileCreatePath(0xFF, "media/mediaDB_create.db", 1, 1, &path, &pathSize);
1000 x_fail_unless(strncmp((char*)path, thePath, strlen((char*)path)) == 0, "Path not correct");
1001 x_fail_unless(pathSize == strlen((char*)path), "Path size not correct");
1003 pclFileReleasePath(ret);
1011 START_TEST(test_InitDeinit)
1014 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
1018 // initialize and deinitialize 1. time
1019 (void)pclInitLibrary(gTheAppId, shutdownReg);
1023 // initialize and deinitialize 2. time
1024 (void)pclInitLibrary(gTheAppId, shutdownReg);
1028 // initialize and deinitialize 3. time
1029 (void)pclInitLibrary(gTheAppId, shutdownReg);
1037 START_TEST(test_NegHandle)
1039 int handle = -1, ret = 0;;
1040 int negativeHandle = -17;
1041 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
1043 unsigned char buffer[128] = {0};
1045 (void)pclInitLibrary(gTheAppId, shutdownReg);
1047 handle = pclKeyHandleOpen(0xFF, "posHandle/last_position", 0, 0);
1048 x_fail_unless(handle >= 0, "Failed to open handle ==> /posHandle/last_position");
1052 ret = pclKeyHandleReadData(negativeHandle, buffer, READ_SIZE);
1053 x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleReadData => negative handle not detected");
1055 ret = pclKeyHandleClose(negativeHandle);
1056 x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleClose => negative handle not detected");
1058 ret = pclKeyHandleGetSize(negativeHandle);
1059 x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleGetSize => negative handle not detected");
1061 ret = pclKeyHandleReadData(negativeHandle, buffer, 128);
1062 x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleReadData => negative handle not detected");
1064 ret = pclKeyHandleRegisterNotifyOnChange(negativeHandle, &myChangeCallback);
1065 x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleRegisterNotifyOnChange => negative handle not detected");
1067 ret = pclKeyHandleWriteData(negativeHandle, (unsigned char*)"Whatever", strlen("Whatever"));
1068 x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleWriteData => negative handle not detected");
1072 ret = pclKeyHandleClose(handle);
1082 START_TEST(test_FileOpenCreate)
1084 int handle = -1, ret = 0;
1085 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
1086 char buffer[128] = {0};
1087 char* writeBuffer = "test_FileOpenCreate: write some data to the file!";
1089 (void)pclInitLibrary(gTheAppId, shutdownReg);
1092 remove("/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDBWrite.db");
1094 handle = pclFileOpen(0xFF, "media/mediaDBWrite.db", 1, 1);
1095 x_fail_unless(handle != -1, "Could not open file ==> /media/mediaDBWrite.db");
1098 ret = pclFileWriteData(handle, writeBuffer, strlen(writeBuffer));
1099 x_fail_unless(ret == strlen(writeBuffer), "pclKeyHandleWriteData => error writing data");
1102 ret = pclFileSeek(handle, 0, SEEK_SET);
1103 x_fail_unless(ret <= 0, "pclFileSeek => failed to position fd");
1106 ret = pclFileReadData(handle, buffer, 128);
1107 x_fail_unless(ret == strlen(writeBuffer), "pclKeyHandleReadData => error read data");
1108 x_fail_unless(strncmp(buffer, writeBuffer, strlen(writeBuffer)) == 0, "pclKeyHandleReadData => Buffer not correctly read");
1110 ret = pclFileClose(handle);
1111 x_fail_unless(ret <= 0, "pclKeyHandleClose => failed to close");
1116 remove("/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDBWrite.db");
1124 static Suite * persistencyClientLib_suite()
1126 Suite * s = suite_create("Persistency client library");
1128 TCase * tc_persGetData = tcase_create("GetData");
1129 tcase_add_test(tc_persGetData, test_GetData);
1131 TCase * tc_persSetData = tcase_create("SetData");
1132 tcase_add_test(tc_persSetData, test_SetData);
1134 TCase * tc_persSetDataNoPRCT = tcase_create("SetDataNoPRCT");
1135 tcase_add_test(tc_persSetDataNoPRCT, test_SetDataNoPRCT);
1137 TCase * tc_persGetDataSize = tcase_create("GetDataSize");
1138 tcase_add_test(tc_persGetDataSize, test_GetDataSize);
1140 TCase * tc_persDeleteData = tcase_create("DeleteData");
1141 tcase_add_test(tc_persDeleteData, test_DeleteData);
1143 TCase * tc_persGetDataHandle = tcase_create("GetDataHandle");
1144 tcase_add_test(tc_persGetDataHandle, test_GetDataHandle);
1146 TCase * tc_persDataHandle = tcase_create("DataHandle");
1147 tcase_add_test(tc_persDataHandle, test_DataHandle);
1149 TCase * tc_persDataHandleOpen = tcase_create("DataHandleOpen");
1150 tcase_add_test(tc_persDataHandleOpen, test_DataHandleOpen);
1152 TCase * tc_persDataFile = tcase_create("DataFile");
1153 tcase_add_test(tc_persDataFile, test_DataFile);
1155 TCase * tc_persDataFileRecovery = tcase_create("DataFileRecovery");
1156 tcase_add_test(tc_persDataFileRecovery, test_DataFileRecovery);
1158 TCase * tc_Plugin = tcase_create("Plugin");
1159 tcase_add_test(tc_Plugin, test_Plugin);
1161 TCase * tc_ReadDefault = tcase_create("ReadDefault");
1162 tcase_add_test(tc_ReadDefault, test_ReadDefault);
1164 TCase * tc_ReadConfDefault = tcase_create("ReadConfDefault");
1165 tcase_add_test(tc_ReadConfDefault, test_ReadConfDefault);
1167 TCase * tc_GetPath = tcase_create("GetPath");
1168 tcase_add_test(tc_GetPath, test_GetPath);
1170 TCase * tc_InitDeinit = tcase_create("InitDeinit");
1171 tcase_add_test(tc_InitDeinit, test_InitDeinit);
1173 TCase * tc_NegHandle = tcase_create("NegHandle");
1174 tcase_add_test(tc_NegHandle, test_NegHandle);
1176 TCase * tc_FileOpenCreate = tcase_create("FileOpenCreate");
1177 tcase_add_test(tc_FileOpenCreate, test_FileOpenCreate);
1179 suite_add_tcase(s, tc_persSetData);
1180 suite_add_tcase(s, tc_persGetData);
1181 suite_add_tcase(s, tc_persSetDataNoPRCT);
1182 suite_add_tcase(s, tc_persGetDataSize);
1183 suite_add_tcase(s, tc_persDeleteData);
1184 suite_add_tcase(s, tc_persGetDataHandle);
1185 suite_add_tcase(s, tc_persDataHandle);
1186 suite_add_tcase(s, tc_persDataHandleOpen);
1187 suite_add_tcase(s, tc_persDataFile);
1188 suite_add_tcase(s, tc_persDataFileRecovery);
1189 suite_add_tcase(s, tc_ReadDefault);
1190 suite_add_tcase(s, tc_ReadConfDefault);
1191 suite_add_tcase(s, tc_GetPath);
1192 suite_add_tcase(s, tc_InitDeinit);
1193 suite_add_tcase(s, tc_NegHandle);
1194 suite_add_tcase(s, tc_FileOpenCreate);
1196 //suite_add_tcase(s, tc_Plugin); // activate only if the plugins are available
1202 int main(int argc, char *argv[])
1209 TestResult** tResult;
1211 // assign application name
1212 strncpy(gTheAppId, "lt-persistence_client_library_test", MaxAppNameLen);
1213 gTheAppId[MaxAppNameLen-1] = '\0';
1215 /// debug log and trace (DLT) setup
1216 DLT_REGISTER_APP("PCLt","tests the persistence client library");
1219 Suite * s = persistencyClientLib_suite();
1220 SRunner * sr = srunner_create(s);
1221 srunner_set_xml(sr, "/tmp/persistenceClientLibraryTest.xml");
1222 srunner_set_log(sr, "/tmp/persistenceClientLibraryTest.log");
1223 srunner_run_all(sr, /*CK_NORMAL*/ CK_VERBOSE);
1225 nr_failed = srunner_ntests_failed(sr);
1226 nr_run = srunner_ntests_run(sr);
1228 tResult = srunner_results(sr);
1229 for(i = 0; i< nr_run; i++)
1231 (void)tr_rtype(tResult[i]); // get status of each test
1232 //fail = tr_rtype(tResult[i]); // get status of each test
1233 //printf("[%d] Fail: %d \n", i, fail);
1239 // unregister debug log and trace
1240 DLT_UNREGISTER_APP();
1244 return (0==nr_failed)?EXIT_SUCCESS:EXIT_FAILURE;