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 printf("* * * * * => => => B U F F E R : \"%s\"\n", buffer);
205 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");
207 size = pclKeyHandleGetSize(handle);
208 x_fail_unless(size == strlen("WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\""));
209 // ---------------------------------------------------------------------------------------------
212 // open handle ---------------------------------------------------
214 * Logical DB ID: 0xFF with user 3 and seat 2
215 * ==> local USER value (user 3, seat 2)
217 handle2 = pclKeyHandleOpen(0xFF, "statusHandle/open_document", 3, 2);
218 x_fail_unless(handle2 >= 0, "Failed to open handle /statusHandle/open_document");
220 size = pclKeyHandleWriteData(handle2, (unsigned char*)sysTimeBuffer, strlen(sysTimeBuffer));
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 * Logical DB ID: 0xFF with user 3 and seat 2
303 * ==> local USER value (user 3, seat 2)
305 ret = pclKeyWriteData(0xFF, "status/open_document", 3, 2, "WT_ /var/opt/user_manual_climateControl.pdf", strlen("WT_ /var/opt/user_manual_climateControl.pdf"));
306 x_fail_unless(ret == strlen("WT_ /var/opt/user_manual_climateControl.pdf"), "Wrong write size");
309 ret = pclKeyWriteData(0x84, "links/last_link", 2, 1, "CACHE_ /last_exit/queens", strlen("CACHE_ /last_exit/queens"));
310 x_fail_unless(ret == strlen("CACHE_ /last_exit/queens"), "Wrong write size");
312 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\""));
313 x_fail_unless(ret == strlen("WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\""), "Wrong write size");
319 locTime = localtime(&t);
322 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),
323 locTime->tm_hour, locTime->tm_min, locTime->tm_sec);
326 * Logical DB ID: 0xFF with user 1 and seat 2
327 * ==> local USER value (user 1, seat 2)
330 ret = pclKeyWriteData(0xFF, "69", 1, 2, (unsigned char*)sysTimeBuffer, strlen(sysTimeBuffer));
331 x_fail_unless(ret == strlen(sysTimeBuffer), "Wrong write size");
333 snprintf(write1, 128, "%s %s", "/70", sysTimeBuffer);
335 * Logical DB ID: 0xFF with user 1 and seat 2
336 * ==> local USER value (user 1, seat 2)
339 ret = pclKeyWriteData(0xFF, "70", 1, 2, (unsigned char*)write1, strlen(write1));
340 x_fail_unless(ret == strlen(write1), "Wrong write size");
342 snprintf(write2, 128, "%s %s", "/key_70", sysTimeBuffer);
344 * Logical DB ID: 0xFF with user 1 and seat 2
345 * ==> local USER value (user 1, seat 2)
346 * Resource ID: key_70
348 ret = pclKeyWriteData(0xFF, "key_70", 1, 2, (unsigned char*)write2, strlen(write2));
349 x_fail_unless(ret == strlen(write2), "Wrong write size");
352 /*******************************************************************************************************************************************/
353 /* used for changed notification testing */
354 /*******************************************************************************************************************************************/
356 * Logical DB ID: 0x84 with user 2 and seat 1
357 * ==> shared user value accessible by A GROUP (user 2 and seat 1)
359 * ==> used for shared testing
361 //printf("Write data to trigger change notification\n");
362 ret = pclKeyWriteData(0x84, "links/last_link2", 2, 1, (unsigned char*)"Test notify shared data", strlen("Test notify shared data"));
363 x_fail_unless(ret == strlen("Test notify shared data"), "Wrong write size");
366 * Logical DB ID: 0x84 with user 2 and seat 1
367 * ==> shared user value accessible by A GROUP (user 2 and seat 1)
369 * ==> used for shared testing
371 //printf("Write data to trigger change notification\n");
372 ret = pclKeyWriteData(0x84, "links/last_link3", 3, 2, (unsigned char*)"Test notify shared data", strlen("Test notify shared data"));
373 x_fail_unless(ret == strlen("Test notify shared data"), "Wrong write size");
376 * Logical DB ID: 0x84 with user 2 and seat 1
377 * ==> shared user value accessible by A GROUP (user 2 and seat 1)
379 * ==> used for shared testing
381 //printf("Write data to trigger change notification\n");
382 ret = pclKeyWriteData(0x84, "links/last_link4", 4, 1, (unsigned char*)"Test notify shared data", strlen("Test notify shared data"));
383 x_fail_unless(ret == strlen("Test notify shared data"), "Wrong write size");
384 /*******************************************************************************************************************************************/
385 /*******************************************************************************************************************************************/
389 * now read the data written in the previous steps to the keys
390 * and verify data has been written correctly.
392 memset(buffer, 0, READ_SIZE);
394 ret = pclKeyReadData(0xFF, "69", 1, 2, buffer, READ_SIZE);
395 x_fail_unless(strncmp((char*)buffer, sysTimeBuffer, strlen(sysTimeBuffer)) == 0, "Buffer not correctly read");
396 x_fail_unless(ret == strlen(sysTimeBuffer), "Wrong read size");
398 memset(buffer, 0, READ_SIZE);
400 ret = pclKeyReadData(0xFF, "70", 1, 2, buffer, READ_SIZE);
401 x_fail_unless(strncmp((char*)buffer, write1, strlen(write1)) == 0, "Buffer not correctly read");
402 x_fail_unless(ret == strlen(write1), "Wrong read size");
404 memset(buffer, 0, READ_SIZE);
406 ret = pclKeyReadData(0xFF, "key_70", 1, 2, buffer, READ_SIZE);
407 x_fail_unless(strncmp((char*)buffer, write2, strlen(write2)) == 0, "Buffer not correctly read");
408 x_fail_unless(ret == strlen(write2), "Wrong read size");
418 * Write data to a key using the key interface.
419 * The key is not in the persistence resource table.
420 * The key sill then be stored to the location local and cached.
422 START_TEST(test_SetDataNoPRCT)
424 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
425 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
426 X_TEST_REPORT_REFERENCE("NONE");
427 X_TEST_REPORT_DESCRIPTION("Test of set data no PRCT");
428 X_TEST_REPORT_TYPE(GOOD);
431 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
432 unsigned char buffer[READ_SIZE] = {0};
435 ret = pclInitLibrary(gTheAppId, shutdownReg);
436 x_fail_unless(ret <= 1, "Failed to init PCL");
440 char sysTimeBuffer[128];
442 locTime = localtime(&t);
444 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),
445 locTime->tm_hour, locTime->tm_min, locTime->tm_sec);
448 * Logical DB ID: 0xFF with user 1 and seat 2
449 * ==> local USER value (user 1, seat 2)
451 ret = pclKeyWriteData(0xFF, "NoPRCT", 1, 2, (unsigned char*)sysTimeBuffer, strlen(sysTimeBuffer));
452 x_fail_unless(ret == strlen(sysTimeBuffer), "Wrong write size");
453 //printf("Write Buffer : %s\n", sysTimeBuffer);
455 // read data again and and verify datat has been written correctly
456 memset(buffer, 0, READ_SIZE);
458 ret = pclKeyReadData(0xFF, "NoPRCT", 1, 2, buffer, READ_SIZE);
459 x_fail_unless(strncmp((char*)buffer, sysTimeBuffer, strlen(sysTimeBuffer)) == 0, "Buffer not correctly read");
460 x_fail_unless(ret == strlen(sysTimeBuffer), "Wrong read size");
461 //printf("read buffer : %s\n", buffer);
470 * Test the key interface.
471 * Read the size of a key.
473 START_TEST(test_GetDataSize)
475 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
476 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
477 X_TEST_REPORT_REFERENCE("NONE");
478 X_TEST_REPORT_DESCRIPTION("Test of get data size");
479 X_TEST_REPORT_TYPE(GOOD);
481 int size = 0, ret = 0;
483 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
485 ret = pclInitLibrary(gTheAppId, shutdownReg);
486 x_fail_unless(ret <= 1, "Failed to init PCL");
489 * Logical DB ID: 0xFF with user 3 and seat 2
490 * ==> local USER value (user 3, seat 2)
492 size = pclKeyGetSize(0xFF, "status/open_document", 3, 2);
493 x_fail_unless(size == strlen("WT_ /var/opt/user_manual_climateControl.pdf"), "Invalid size");
497 * Logical DB ID: 0x84 with user 2 and seat 1
498 * ==> shared user value accessible by A GROUP (user 2 and seat 1)
500 size = pclKeyGetSize(0x84, "links/last_link", 2, 1);
501 x_fail_unless(size == strlen("CACHE_ /last_exit/queens"), "Invalid size");
509 * Delete a key using the key value interface.
510 * First read a from a key, the delte the key
511 * and then try to read again. The Last read must fail.
513 START_TEST(test_DeleteData)
515 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
516 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
517 X_TEST_REPORT_REFERENCE("NONE");
518 X_TEST_REPORT_DESCRIPTION("Test of delete data");
519 X_TEST_REPORT_TYPE(GOOD);
522 unsigned char buffer[READ_SIZE];
523 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
525 rval = pclInitLibrary(gTheAppId, shutdownReg);
526 x_fail_unless(rval <= 1, "Failed to init PCL");
528 // read data from key
529 rval = pclKeyReadData(0xFF, "key_70", 1, 2, buffer, READ_SIZE);
530 x_fail_unless(rval != EPERS_NOKEY, "Read form key key_70 fails");
533 rval = pclKeyDelete(0xFF, "key_70", 1, 2);
534 x_fail_unless(rval >= 0, "Failed to delete key");
536 // after deleting the key, reading from key must fail now!
537 rval = pclKeyReadData(0xFF, "key_70", 1, 2, buffer, READ_SIZE);
538 x_fail_unless(rval == EPERS_NOKEY, "Read form key key_70 works, but should fail");
542 // read data from key
543 rval = pclKeyReadData(0xFF, "70", 1, 2, buffer, READ_SIZE);
544 x_fail_unless(rval != EPERS_NOKEY, "Read form key 70 fails");
547 rval = pclKeyDelete(0xFF, "70", 1, 2);
548 x_fail_unless(rval >= 0, "Failed to delete key");
550 // after deleting the key, reading from key must fail now!
551 rval = pclKeyReadData(0xFF, "70", 1, 2, buffer, READ_SIZE);
552 x_fail_unless(rval == EPERS_NOKEY, "Read form key 70 works, but should fail");
561 * Test the file interface:
568 START_TEST(test_DataFile)
570 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
571 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
572 X_TEST_REPORT_REFERENCE("NONE");
573 X_TEST_REPORT_DESCRIPTION("Test of data file");
574 X_TEST_REPORT_TYPE(GOOD);
576 int fd = 0, i = 0, idx = 0;
577 int size = 0, ret = 0;
578 int writeSize = 16*1024;
579 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
581 unsigned char buffer[READ_SIZE] = {0};
582 const char* refBuffer = "/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media";
584 char* fileMap = NULL;
586 ret = pclInitLibrary(gTheAppId, shutdownReg);
587 x_fail_unless(ret <= 1, "Failed to init PCL");
589 writeBuffer = malloc(writeSize);
592 // fill buffer a sequence
593 for(i = 0; i<(writeSize/8); i++)
595 writeBuffer[idx++] = 'A';
596 writeBuffer[idx++] = 'B';
597 writeBuffer[idx++] = 'C';
598 writeBuffer[idx++] = ' ';
599 writeBuffer[idx++] = 'D';
600 writeBuffer[idx++] = 'E';
601 writeBuffer[idx++] = 'F';
602 writeBuffer[idx++] = ' ';
605 fd = open("/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDBWrite.db",
606 O_CREAT|O_RDWR|O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
609 // open ------------------------------------------------------------
610 fd = pclFileOpen(0xFF, "media/mediaDB.db", 1, 1);
611 x_fail_unless(fd != -1, "Could not open file ==> /media/mediaDB.db");
613 size = pclFileGetSize(fd);
614 x_fail_unless(size == 68, "Wrong file size");
616 size = pclFileReadData(fd, buffer, READ_SIZE);
617 x_fail_unless(strncmp((char*)buffer, refBuffer, strlen(refBuffer)) == 0, "Buffer not correctly read => media/mediaDB.db");
618 x_fail_unless(size == (strlen(refBuffer)+1), "Wrong size returned"); // strlen + 1 ==> inlcude cr/lf
620 ret = pclFileClose(fd);
621 x_fail_unless(ret == 0, "Failed to close file");
623 // open ------------------------------------------------------------
624 fd = pclFileOpen(0xFF, "media/mediaDBWrite.db", 1, 1);
625 x_fail_unless(fd != -1, "Could not open file ==> /media/mediaDBWrite.db");
627 size = pclFileWriteData(fd, writeBuffer, strlen(writeBuffer));
628 x_fail_unless(size == strlen(writeBuffer), "Failed to write data");
629 ret = pclFileClose(fd);
630 x_fail_unless(ret == 0, "Failed to close file");
632 // remove ----------------------------------------------------------
633 ret = pclFileRemove(0xFF, "media/mediaDBWrite.db", 1, 1);
634 x_fail_unless(ret == 0, "File can't be removed ==> /media/mediaDBWrite.db");
636 fd = open("/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDBWrite.db",O_RDWR);
637 x_fail_unless(fd == -1, "Failed to remove file, file still exists");
640 // map file --------------------------------------------------------
642 fd = pclFileOpen(0xFF, "media/mediaDB.db", 1, 1);
644 size = pclFileGetSize(fd);
645 pclFileMapData(fileMap, size, 0, fd);
646 x_fail_unless(fileMap != MAP_FAILED, "Failed to map file");
648 ret = pclFileUnmapData(fileMap, size);
649 x_fail_unless(ret != -1, "Failed to unmap file");
652 size = pclFileGetSize(1024);
653 x_fail_unless(ret == 0, "Got size, but should not");
655 ret = pclFileClose(fd);
656 x_fail_unless(ret == 0, "Failed to close file");
668 START_TEST(test_DataFileRecovery)
670 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
671 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
672 X_TEST_REPORT_REFERENCE("NONE");
673 X_TEST_REPORT_DESCRIPTION("Test of data file recovery");
674 X_TEST_REPORT_TYPE(GOOD);
676 int fd_RW = 0, fd_RO = 0;
678 char* wBuffer = "This is a buffer to write";
679 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
681 ret = pclInitLibrary(gTheAppId, shutdownReg);
682 x_fail_unless(ret <= 1, "Failed to init PCL");
685 // test backup creation --------------------------------------------
686 fd_RO = pclFileOpen(0xFF, "media/mediaDB_ReadOnly.db", 1, 1);
687 x_fail_unless(fd_RO != -1, "Could not open file ==> /media/mediaDB_ReadOnly.db");
689 fd_RW = pclFileOpen(0xFF, "media/mediaDB_ReadWrite.db", 1, 1);
690 x_fail_unless(fd_RW != -1, "Could not open file ==> /media/mediaDB_ReadWrite.db");
691 pclFileWriteData(fd_RW, wBuffer, strlen(wBuffer));
693 ret = pclFileClose(fd_RW);
696 ret = pclFileClose(fd_RO);
705 * The the handle function of the key and file interface.
707 START_TEST(test_DataHandle)
709 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
710 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
711 X_TEST_REPORT_REFERENCE("NONE");
712 X_TEST_REPORT_DESCRIPTION("Test of data handle");
713 X_TEST_REPORT_TYPE(GOOD);
715 int handle1 = 0, handle2 = 0;
716 int handleArray[4] = {0};
718 unsigned char buffer[READ_SIZE] = {0};
719 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
721 ret = pclInitLibrary(gTheAppId, shutdownReg);
722 x_fail_unless(ret <= 1, "Failed to init PCL");
725 handle1 = pclFileOpen(0xFF, "media/mediaDB.db", 1, 1);
726 x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB.db");
728 ret = pclFileClose(handle1);
729 x_fail_unless(handle1 != -1, "Could not closefile ==> /media/mediaDB.db");
731 ret = pclFileClose(1024);
732 x_fail_unless(ret == EPERS_MAXHANDLE, "Could close file, but should not!!");
734 ret = pclFileClose(17);
735 x_fail_unless(ret == -1, "Could close file, but should not!!");
737 // test multiple handles
738 handleArray[0] = pclFileOpen(0xFF, "media/mediaDB_write_01.db", 1, 1);
739 x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_01.db");
741 handleArray[1] = pclFileOpen(0xFF, "media/mediaDB_write_02.db", 1, 1);
742 x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_02.db");
744 handleArray[2] = pclFileOpen(0xFF, "media/mediaDB_write_03.db", 1, 1);
745 x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_03.db");
747 handleArray[3] = pclFileOpen(0xFF, "media/mediaDB_write_04.db", 1, 1);
748 x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_04.db");
750 ret = pclFileReadData(handleArray[0], buffer, READ_SIZE);
751 x_fail_unless(ret >= 0, "Failed to read handle idx \"0\"!!");
752 x_fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_01.db",
753 strlen("/user/1/seat/1/media/mediaDB_write_01.db"))
754 == 0, "Buffer not correctly read => mediaDB_write_01.db");
756 ret = pclFileReadData(handleArray[1], buffer, READ_SIZE);
757 x_fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_02.db",
758 strlen("/user/1/seat/1/media/mediaDB_write_02.db"))
759 == 0, "Buffer not correctly read => mediaDB_write_02.db");
761 ret = pclFileReadData(handleArray[2], buffer, READ_SIZE);
762 x_fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_03.db",
763 strlen("/user/1/seat/1/media/mediaDB_write_03.db"))
764 == 0, "Buffer not correctly read => mediaDB_write_03.db");
766 (void)pclFileReadData(handleArray[3], buffer, READ_SIZE);
767 x_fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_04.db",
768 strlen("/user/1/seat/1/media/mediaDB_write_04.db"))
769 == 0, "Buffer not correctly read => mediaDB_write_04.db");
771 ret = pclKeyHandleClose(handleArray[0]);
772 x_fail_unless(ret != -1, "Failed to close handle idx \"0\"!!");
774 ret = pclKeyHandleClose(handleArray[1]);
775 x_fail_unless(ret != -1, "Failed to close handle idx \"1\"!!");
777 ret = pclKeyHandleClose(handleArray[2]);
778 x_fail_unless(ret != -1, "Failed to close handle idx \"2\"!!");
780 ret = pclKeyHandleClose(handleArray[3]);
781 x_fail_unless(ret != -1, "Failed to close handle idx \"3\"!!");
784 handle2 = pclKeyHandleOpen(0xFF, "statusHandle/open_document", 3, 2);
785 x_fail_unless(handle2 >= 0, "Failed to open handle /statusHandle/open_document");
787 ret = pclKeyHandleClose(handle2);
788 x_fail_unless(ret != -1, "Failed to close handle!!");
790 ret = pclKeyHandleClose(1024);
791 x_fail_unless(ret == EPERS_MAXHANDLE, "Max handle!!");
800 * Extended key handle test.
801 * Test have been created after a bug in the key handle function occured.
803 START_TEST(test_DataHandleOpen)
805 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
806 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
807 X_TEST_REPORT_REFERENCE("NONE");
808 X_TEST_REPORT_DESCRIPTION("Test of data handle open");
809 X_TEST_REPORT_TYPE(GOOD);
811 int hd1 = -2, hd2 = -2, hd3 = -2, hd4 = -2, hd5 = -2, hd6 = -2, hd7 = -2, hd8 = -2, hd9 = -2, ret = 0;
812 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
814 ret = pclInitLibrary(gTheAppId, shutdownReg);
815 x_fail_unless(ret <= 1, "Failed to init PCL");
817 // open handles ----------------------------------------------------
818 hd1 = pclKeyHandleOpen(0xFF, "posHandle/last_position1", 0, 0);
819 x_fail_unless(hd1 == 1, "Failed to open handle ==> /posHandle/last_position1");
821 hd2 = pclKeyHandleOpen(0xFF, "posHandle/last_position2", 0, 0);
822 x_fail_unless(hd2 == 2, "Failed to open handle ==> /posHandle/last_position2");
824 hd3 = pclKeyHandleOpen(0xFF, "posHandle/last_position3", 0, 0);
825 x_fail_unless(hd3 == 3, "Failed to open handle ==> /posHandle/last_position3");
827 // close handles ---------------------------------------------------
828 ret = pclKeyHandleClose(hd1);
829 x_fail_unless(ret != -1, "Failed to close handle!!");
831 ret = pclKeyHandleClose(hd2);
832 x_fail_unless(ret != -1, "Failed to close handle!!");
834 ret = pclKeyHandleClose(hd3);
835 x_fail_unless(ret != -1, "Failed to close handle!!");
837 // open handles ----------------------------------------------------
838 hd4 = pclKeyHandleOpen(0xFF, "posHandle/last_position4", 0, 0);
839 x_fail_unless(hd4 == 3, "Failed to open handle ==> /posHandle/last_position4");
841 hd5 = pclKeyHandleOpen(0xFF, "posHandle/last_position5", 0, 0);
842 x_fail_unless(hd5 == 2, "Failed to open handle ==> /posHandle/last_position5");
844 hd6 = pclKeyHandleOpen(0xFF, "posHandle/last_position6", 0, 0);
845 x_fail_unless(hd6 == 1, "Failed to open handle ==> /posHandle/last_position6");
847 hd7 = pclKeyHandleOpen(0xFF, "posHandle/last_position7", 0, 0);
848 x_fail_unless(hd7 == 4, "Failed to open handle ==> /posHandle/last_position7");
850 hd8 = pclKeyHandleOpen(0xFF, "posHandle/last_position8", 0, 0);
851 x_fail_unless(hd8 == 5, "Failed to open handle ==> /posHandle/last_position8");
853 hd9 = pclKeyHandleOpen(0xFF, "posHandle/last_position9", 0, 0);
854 x_fail_unless(hd9 == 6, "Failed to open handle ==> /posHandle/last_position9");
856 // close handles ---------------------------------------------------
857 ret = pclKeyHandleClose(hd4);
858 x_fail_unless(ret != -1, "Failed to close handle!!");
860 ret = pclKeyHandleClose(hd5);
861 x_fail_unless(ret != -1, "Failed to close handle!!");
863 ret = pclKeyHandleClose(hd6);
864 x_fail_unless(ret != -1, "Failed to close handle!!");
866 ret = pclKeyHandleClose(hd7);
867 x_fail_unless(ret != -1, "Failed to close handle!!");
869 ret = pclKeyHandleClose(hd8);
870 x_fail_unless(ret != -1, "Failed to close handle!!");
872 ret = pclKeyHandleClose(hd9);
873 x_fail_unless(ret != -1, "Failed to close handle!!");
881 START_TEST(test_Plugin)
883 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
884 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
885 X_TEST_REPORT_REFERENCE("NONE");
886 X_TEST_REPORT_DESCRIPTION("Test of plugins");
887 X_TEST_REPORT_TYPE(GOOD);
890 unsigned char buffer[READ_SIZE] = {0};
892 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
894 ret = pclInitLibrary(gTheAppId, shutdownReg);
895 x_fail_unless(ret <= 1, "Failed to init PCL");
897 ret = pclKeyReadData(0xFF, "language/country_code", 0, 0, buffer, READ_SIZE);
898 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
899 x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: secure!",
900 strlen((char*)buffer)) == 0, "Buffer SECURE not correctly read");
903 ret = pclKeyReadData(0xFF, "language/country_code_early", 0, 0, buffer, READ_SIZE);
904 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
905 //printf("B U F F E R - early: %s\n", buffer);
906 x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: early!",
907 strlen((char*)buffer)) == 0, "Buffer EARLY not correctly read");
909 ret = pclKeyReadData(0xFF, "language/country_code_emergency", 0, 0, buffer, READ_SIZE);
910 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
911 //printf("B U F F E R - emergency: %s\n", buffer);
912 x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: emergency!",
913 strlen((char*)buffer)) == 0, "Buffer EMERGENCY not correctly read");
915 ret = pclKeyReadData(0xFF, "language/info", 0, 0, buffer, READ_SIZE);
916 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
917 //printf("B U F F E R - hwinfo: %s\n", buffer);
918 x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: hwinfo!",
919 strlen((char*)buffer)) == 0, "Buffer HWINFO not correctly read");
921 ret = pclKeyReadData(0xFF, "language/country_code_custom3", 0, 0, buffer, READ_SIZE);
922 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
923 //printf("B U F F E R - hwinfo: %s\n", buffer);
924 x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: custom3!",
925 strlen((char*)buffer)) == 0, "Buffer CUSTOM 3 not correctly read");
935 START_TEST(test_ReadDefault)
937 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
938 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
939 X_TEST_REPORT_REFERENCE("NONE");
940 X_TEST_REPORT_DESCRIPTION("Test of read default");
941 X_TEST_REPORT_TYPE(GOOD);
944 unsigned char buffer[READ_SIZE] = {0};
946 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
948 ret = pclInitLibrary(gTheAppId, shutdownReg);
949 x_fail_unless(ret <= 1, "Failed to init PCL");
951 ret = pclKeyReadData(0xFF, "statusHandle/default01", 3, 2, buffer, READ_SIZE);
952 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
953 //printf("B U F F E R: %s\n", buffer);
954 x_fail_unless(strncmp((char*)buffer,"DEFAULT_01!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
956 ret = pclKeyReadData(0xFF, "statusHandle/default02", 3, 2, buffer, READ_SIZE);
957 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
958 //printf("B U F F E R: %s\n", buffer);
959 x_fail_unless(strncmp((char*)buffer,"DEFAULT_02!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
967 START_TEST(test_ReadConfDefault)
969 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
970 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
971 X_TEST_REPORT_REFERENCE("NONE");
972 X_TEST_REPORT_DESCRIPTION("Test of configurable default data");
973 X_TEST_REPORT_TYPE(GOOD);
976 unsigned char buffer[READ_SIZE] = {0};
978 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
980 ret = pclInitLibrary(gTheAppId, shutdownReg);
981 x_fail_unless(ret <= 1, "Failed to init PCL");
983 ret = pclKeyReadData(0xFF, "statusHandle/confdefault01", 3, 2, buffer, READ_SIZE);
984 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
985 x_fail_unless(strncmp((char*)buffer,"CONF_DEFAULT_01!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
987 ret = pclKeyReadData(0xFF, "statusHandle/confdefault02", 3, 2, buffer, READ_SIZE);
988 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
989 x_fail_unless(strncmp((char*)buffer,"CONF_DEFAULT_02!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
997 START_TEST(test_GetPath)
999 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
1000 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
1001 X_TEST_REPORT_REFERENCE("NONE");
1002 X_TEST_REPORT_DESCRIPTION("Test of get path");
1003 X_TEST_REPORT_TYPE(GOOD);
1007 const char* thePath = "/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDB_create.db";
1008 unsigned int pathSize = 0;
1010 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
1012 ret = pclInitLibrary(gTheAppId, shutdownReg);
1013 x_fail_unless(ret <= 1, "Failed to init PCL");
1015 ret = pclFileCreatePath(0xFF, "media/mediaDB_create.db", 1, 1, &path, &pathSize);
1017 x_fail_unless(strncmp((char*)path, thePath, strlen((char*)path)) == 0, "Path not correct");
1018 x_fail_unless(pathSize == strlen((char*)path), "Path size not correct");
1020 pclFileReleasePath(ret);
1028 START_TEST(test_InitDeinit)
1031 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
1035 // initialize and deinitialize 1. time
1036 (void)pclInitLibrary(gTheAppId, shutdownReg);
1040 // initialize and deinitialize 2. time
1041 (void)pclInitLibrary(gTheAppId, shutdownReg);
1045 // initialize and deinitialize 3. time
1046 (void)pclInitLibrary(gTheAppId, shutdownReg);
1054 START_TEST(test_NegHandle)
1056 int handle = -1, ret = 0;;
1057 int negativeHandle = -17;
1058 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
1060 unsigned char buffer[128] = {0};
1062 (void)pclInitLibrary(gTheAppId, shutdownReg);
1064 handle = pclKeyHandleOpen(0xFF, "posHandle/last_position", 0, 0);
1065 x_fail_unless(handle >= 0, "Failed to open handle ==> /posHandle/last_position");
1069 ret = pclKeyHandleReadData(negativeHandle, buffer, READ_SIZE);
1070 x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleReadData => negative handle not detected");
1072 ret = pclKeyHandleClose(negativeHandle);
1073 x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleClose => negative handle not detected");
1075 ret = pclKeyHandleGetSize(negativeHandle);
1076 x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleGetSize => negative handle not detected");
1078 ret = pclKeyHandleReadData(negativeHandle, buffer, 128);
1079 x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleReadData => negative handle not detected");
1081 ret = pclKeyHandleRegisterNotifyOnChange(negativeHandle, &myChangeCallback);
1082 x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleRegisterNotifyOnChange => negative handle not detected");
1084 ret = pclKeyHandleWriteData(negativeHandle, (unsigned char*)"Whatever", strlen("Whatever"));
1085 x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleWriteData => negative handle not detected");
1089 ret = pclKeyHandleClose(handle);
1102 static Suite * persistencyClientLib_suite()
1104 Suite * s = suite_create("Persistency client library");
1106 TCase * tc_persGetData = tcase_create("GetData");
1107 tcase_add_test(tc_persGetData, test_GetData);
1109 TCase * tc_persSetData = tcase_create("SetData");
1110 tcase_add_test(tc_persSetData, test_SetData);
1112 TCase * tc_persSetDataNoPRCT = tcase_create("SetDataNoPRCT");
1113 tcase_add_test(tc_persSetDataNoPRCT, test_SetDataNoPRCT);
1115 TCase * tc_persGetDataSize = tcase_create("GetDataSize");
1116 tcase_add_test(tc_persGetDataSize, test_GetDataSize);
1118 TCase * tc_persDeleteData = tcase_create("DeleteData");
1119 tcase_add_test(tc_persDeleteData, test_DeleteData);
1121 TCase * tc_persGetDataHandle = tcase_create("GetDataHandle");
1122 tcase_add_test(tc_persGetDataHandle, test_GetDataHandle);
1124 TCase * tc_persDataHandle = tcase_create("DataHandle");
1125 tcase_add_test(tc_persDataHandle, test_DataHandle);
1127 TCase * tc_persDataHandleOpen = tcase_create("DataHandleOpen");
1128 tcase_add_test(tc_persDataHandleOpen, test_DataHandleOpen);
1130 TCase * tc_persDataFile = tcase_create("DataFile");
1131 tcase_add_test(tc_persDataFile, test_DataFile);
1133 TCase * tc_persDataFileRecovery = tcase_create("DataFileRecovery");
1134 tcase_add_test(tc_persDataFileRecovery, test_DataFileRecovery);
1136 TCase * tc_Plugin = tcase_create("Plugin");
1137 tcase_add_test(tc_Plugin, test_Plugin);
1139 TCase * tc_ReadDefault = tcase_create("ReadDefault");
1140 tcase_add_test(tc_ReadDefault, test_ReadDefault);
1142 TCase * tc_ReadConfDefault = tcase_create("ReadConfDefault");
1143 tcase_add_test(tc_ReadConfDefault, test_ReadConfDefault);
1145 TCase * tc_GetPath = tcase_create("GetPath");
1146 tcase_add_test(tc_GetPath, test_GetPath);
1148 TCase * tc_InitDeinit = tcase_create("InitDeinit");
1149 tcase_add_test(tc_InitDeinit, test_InitDeinit);
1151 TCase * tc_NegHandle = tcase_create("NegHandle");
1152 tcase_add_test(tc_NegHandle, test_NegHandle);
1154 suite_add_tcase(s, tc_persSetData);
1155 suite_add_tcase(s, tc_persGetData);
1156 suite_add_tcase(s, tc_persSetDataNoPRCT);
1157 suite_add_tcase(s, tc_persGetDataSize);
1158 suite_add_tcase(s, tc_persDeleteData);
1159 suite_add_tcase(s, tc_persGetDataHandle);
1160 suite_add_tcase(s, tc_persDataHandle);
1161 suite_add_tcase(s, tc_persDataHandleOpen);
1162 suite_add_tcase(s, tc_persDataFile);
1163 suite_add_tcase(s, tc_persDataFileRecovery);
1164 suite_add_tcase(s, tc_ReadDefault);
1165 suite_add_tcase(s, tc_ReadConfDefault);
1166 suite_add_tcase(s, tc_GetPath);
1167 suite_add_tcase(s, tc_InitDeinit);
1168 suite_add_tcase(s, tc_NegHandle);
1170 //suite_add_tcase(s, tc_Plugin); // activate only if the plugins are available
1176 int main(int argc, char *argv[])
1183 TestResult** tResult;
1185 // assign application name
1186 strncpy(gTheAppId, "lt-persistence_client_library_test", MaxAppNameLen);
1187 gTheAppId[MaxAppNameLen-1] = '\0';
1189 /// debug log and trace (DLT) setup
1190 DLT_REGISTER_APP("PCLt","tests the persistence client library");
1193 Suite * s = persistencyClientLib_suite();
1194 SRunner * sr = srunner_create(s);
1195 srunner_set_xml(sr, "/tmp/persistenceClientLibraryTest.xml");
1196 srunner_set_log(sr, "/tmp/persistenceClientLibraryTest.log");
1197 srunner_run_all(sr, /*CK_NORMAL*/ CK_VERBOSE);
1199 nr_failed = srunner_ntests_failed(sr);
1200 nr_run = srunner_ntests_run(sr);
1202 tResult = srunner_results(sr);
1203 for(i = 0; i< nr_run; i++)
1205 (void)tr_rtype(tResult[i]); // get status of each test
1206 //fail = tr_rtype(tResult[i]); // get status of each test
1207 //printf("[%d] Fail: %d \n", i, fail);
1213 // unregister debug log and trace
1214 DLT_UNREGISTER_APP();
1218 return (0==nr_failed)?EXIT_SUCCESS:EXIT_FAILURE;