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 * @ingroup Persistence client library test
14 * @author Ingo Huerner
15 * @brief Test of persistence client library
23 #include <unistd.h> /* exit */
29 #include <dlt/dlt_common.h>
31 #include "persCheck_0.9.9.h"
34 #include "../include/persistence_client_library_file.h"
35 #include "../include/persistence_client_library_key.h"
36 #include "../include/persistence_client_library.h"
39 // protected header, should be used only be persistence components
40 // included here for testing purpose
41 #include "../include_protected/persistence_client_library_db_access.h"
45 #define NUM_OF_FILES 3
46 #define READ_SIZE 1024
49 char gTheAppId[MaxAppNameLen] = {0};
51 // definition of weekday
52 char* dayOfWeek[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
57 * Test the key value interface using different logicalDB id's, users and seats.
58 * Each resource below has an entry in the resource configuration table where the
59 * storage location (cached or write through) and type (e.g. custom) has been configured.
61 START_TEST (test_GetData)
63 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
64 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
65 X_TEST_REPORT_REFERENCE("NONE");
66 X_TEST_REPORT_DESCRIPTION("Test of get data");
67 X_TEST_REPORT_TYPE(GOOD);
70 unsigned int shutdownReg = (PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL);
72 unsigned char buffer[READ_SIZE] = {0};
74 ret = pclInitLibrary(gTheAppId, shutdownReg);
75 fail_unless(ret <= 1, "Failed to init PCL");
79 * Logical DB ID: 0xFF with user 0 and seat 0
80 * ==> local value accessible by all users (user 0, seat 0)
82 ret = pclKeyReadData(0xFF, "pos/last_position", 0, 0, buffer, READ_SIZE);
83 fail_unless(strncmp((char*)buffer, "CACHE_ +48° 10' 38.95\", +8° 44' 39.06\"",
84 strlen((char*)buffer)) == 0, "Buffer not correctly read");
85 fail_unless(ret = strlen("CACHE_ +48° 10' 38.95\", +8° 44' 39.06\""));
87 memset(buffer, 0, READ_SIZE);
90 * Logical DB ID: 0xFF with user 0 and seat 0
91 * ==> local value accessible by all users (user 0, seat 0)
93 ret = pclKeyReadData(0xFF, "language/country_code", 0, 0, buffer, READ_SIZE);
94 fail_unless(strncmp((char*)buffer, "Custom plugin -> plugin_get_data: secure!",
95 strlen((char*)buffer)) == 0, "Buffer not correctly read");
96 fail_unless(ret = strlen("Custom plugin -> plugin_get_data_handle"));
98 memset(buffer, 0, READ_SIZE);
102 * Logical DB ID: 0 with user 3 and seat 0
103 * ==> public shared user value (user 3, seat 0)
105 ret = pclKeyReadData(0, "language/current_language", 3, 0, buffer, READ_SIZE);
106 fail_unless(strncmp((char*)buffer, "CACHE_ Kisuaheli", strlen((char*)buffer)) == 0, "Buffer not correctly read");
108 memset(buffer, 0, READ_SIZE);
111 * Logical DB ID: 0xFF with user 3 and seat 2
112 * ==> local USER value (user 3, seat 2)
114 ret = pclKeyReadData(0xFF, "status/open_document", 3, 2, buffer, READ_SIZE);
115 fail_unless(strncmp((char*)buffer, "WT_ /var/opt/user_manual_climateControl.pdf", strlen((char*)buffer)) == 0, "Buffer not correctly read");
117 memset(buffer, 0, READ_SIZE);
120 * Logical DB ID: 0x20 with user 4 and seat 0
121 * ==> shared user value accessible by a group (user 4 and seat 0)
123 ret = pclKeyReadData(0x20, "address/home_address", 4, 0, buffer, READ_SIZE);
124 fail_unless(strncmp((char*)buffer, "WT_ 55327 Heimatstadt, Wohnstrasse 31", strlen((char*)buffer)) == 0, "Buffer not correctly read");
126 memset(buffer, 0, READ_SIZE);
129 * Logical DB ID: 0xFF with user 0 and seat 0
130 * ==> local value accessible by ALL USERS (user 0, seat 0)
132 ret = pclKeyReadData(0xFF, "pos/last_satellites", 0, 0, buffer, READ_SIZE);
133 fail_unless(strncmp((char*)buffer, "WT_ 17", strlen((char*)buffer)) == 0, "Buffer not correctly read");
135 memset(buffer, 0, READ_SIZE);
138 * Logical DB ID: 0x84 with user 4 and seat 0
139 * ==> shared user value accessible by A GROUP (user 4 and seat 0)
141 ret = pclKeyReadData(0x84, "links/last_link", 2, 0, buffer, READ_SIZE);
142 fail_unless(strncmp((char*)buffer, "CACHE_ /last_exit/brooklyn", strlen((char*)buffer)) == 0, "Buffer not correctly read");
144 memset(buffer, 0, READ_SIZE);
147 * Logical DB ID: 0x84 with user 2 and seat 1
148 * ==> local merge value
150 ret = pclKeyReadData(0x84, "links/last_link", 2, 1, buffer, READ_SIZE);
151 fail_unless(strncmp((char*)buffer, "CACHE_ /last_exit/queens", strlen((char*)buffer)) == 0, "Buffer not correctly read");
160 * Test the key value h a n d l e interface using different logicalDB id's, users and seats
161 * Each resource below has an entry in the resource configuration table where
162 * the storage location (cached or write through) and type (e.g. custom) has bee configured.
164 START_TEST (test_GetDataHandle)
166 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
167 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
168 X_TEST_REPORT_REFERENCE("NONE");
169 X_TEST_REPORT_DESCRIPTION("Test of get data handle");
170 X_TEST_REPORT_TYPE(GOOD);
172 int ret = 0, handle = 0, handle2 = 0, handle3 = 0, handle4 = 0, size = 0;
173 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
175 unsigned char buffer[READ_SIZE] = {0};
178 char sysTimeBuffer[128];
180 ret = pclInitLibrary(gTheAppId, shutdownReg);
181 fail_unless(ret <= 1, "Failed to init PCL");
185 locTime = localtime(&t);
187 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),
188 locTime->tm_hour, locTime->tm_min, locTime->tm_sec);
191 // open handle ---------------------------------------------------
193 * Logical DB ID: 0xFF with user 0 and seat 0
194 * ==> local value accessible by ALL USERS (user 0, seat 0)
196 handle = pclKeyHandleOpen(0xFF, "posHandle/last_position", 0, 0);
197 fail_unless(handle >= 0, "Failed to open handle ==> /posHandle/last_position");
199 ret = pclKeyHandleReadData(handle, buffer, READ_SIZE);
200 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");
202 size = pclKeyHandleGetSize(handle);
203 fail_unless(size == strlen("WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\""));
204 // ---------------------------------------------------------------------------------------------
207 // open handle ---------------------------------------------------
209 * Logical DB ID: 0xFF with user 3 and seat 2
210 * ==> local USER value (user 3, seat 2)
212 handle2 = pclKeyHandleOpen(0xFF, "statusHandle/open_document", 3, 2);
213 fail_unless(handle2 >= 0, "Failed to open handle /statusHandle/open_document");
215 size = pclKeyHandleWriteData(handle2, (unsigned char*)sysTimeBuffer, strlen(sysTimeBuffer));
216 fail_unless(size == strlen(sysTimeBuffer));
218 ret = pclKeyHandleClose(handle2);
219 // ---------------------------------------------------------------------------------------------
222 // open handle ---------------------------------------------------
224 * Logical DB ID: 0xFF with user 0 and seat 0
225 * ==> local value accessible by ALL USERS (user 0, seat 0)
227 #if 0 // plugin test case
228 memset(buffer, 0, READ_SIZE);
229 handle4 = pclKeyHandleOpen(0xFF, "language/country_code", 0, 0);
230 printf("H A N D L E: %d\n", handle4);
231 fail_unless(handle4 >= 0, "Failed to open handle /language/country_code");
233 ret = pclKeyHandleReadData(handle4, buffer, READ_SIZE);
234 fail_unless(strncmp((char*)buffer, "Custom plugin -> plugin_get_data_handle: secure!", -1) == 0, "Buffer not correctly read => 2");
236 size = pclKeyHandleGetSize(handle4);
237 fail_unless(size = strlen("Custom plugin -> plugin_get_data_handle"));
239 ret = pclKeyHandleWriteData(handle4, (unsigned char*)"Only dummy implementation behind custom library", READ_SIZE);
241 // ---------------------------------------------------------------------------------------------
244 // open handle ---------------------------------------------------
246 * Logical DB ID: 0xFF with user 3 and seat 2
247 * ==> local USER value (user 3, seat 2)
249 handle3 = pclKeyHandleOpen(0xFF, "statusHandle/open_document", 3, 2);
250 fail_unless(handle3 >= 0, "Failed to open handle /statusHandle/open_document");
252 ret = pclKeyHandleReadData(handle3, buffer, READ_SIZE);
253 fail_unless(strncmp((char*)buffer, sysTimeBuffer, strlen(sysTimeBuffer)) == 0, "Buffer not correctly read => 3");
255 size = pclKeyHandleGetSize(handle3);
256 fail_unless(size = strlen(sysTimeBuffer));
257 // ---------------------------------------------------------------------------------------------
261 ret = pclKeyHandleClose(handle);
262 ret = pclKeyHandleClose(handle3);
263 ret = pclKeyHandleClose(handle4);
271 * Write data to a key using the key interface.
272 * First write data to different keys and after
273 * read the data for verification.
275 START_TEST(test_SetData)
277 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
278 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
279 X_TEST_REPORT_REFERENCE("NONE");
280 X_TEST_REPORT_DESCRIPTION("Test of set data");
281 X_TEST_REPORT_TYPE(GOOD);
284 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
285 unsigned char buffer[READ_SIZE] = {0};
286 char write1[READ_SIZE] = {0};
287 char write2[READ_SIZE] = {0};
288 char sysTimeBuffer[256];
292 ret = pclInitLibrary(gTheAppId, shutdownReg);
293 fail_unless(ret <= 1, "Failed to init PCL");
297 locTime = localtime(&t);
300 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),
301 locTime->tm_hour, locTime->tm_min, locTime->tm_sec);
304 * Logical DB ID: 0xFF with user 1 and seat 2
305 * ==> local USER value (user 1, seat 2)
309 ret = pclKeyWriteData(0xFF, "69", 1, 2, (unsigned char*)sysTimeBuffer, strlen(sysTimeBuffer));
310 fail_unless(ret == strlen(sysTimeBuffer), "Wrong write size");
312 snprintf(write1, 128, "%s %s", "/70", sysTimeBuffer);
314 * Logical DB ID: 0xFF with user 1 and seat 2
315 * ==> local USER value (user 1, seat 2)
318 ret = pclKeyWriteData(0xFF, "70", 1, 2, (unsigned char*)write1, strlen(write1));
319 fail_unless(ret == strlen(write1), "Wrong write size");
321 snprintf(write2, 128, "%s %s", "/key_70", sysTimeBuffer);
323 * Logical DB ID: 0xFF with user 1 and seat 2
324 * ==> local USER value (user 1, seat 2)
325 * Resource ID: key_70
327 ret = pclKeyWriteData(0xFF, "key_70", 1, 2, (unsigned char*)write2, strlen(write2));
328 fail_unless(ret == strlen(write2), "Wrong write size");
331 /*******************************************************************************************************************************************/
332 /* used for changed notification testing */
333 /*******************************************************************************************************************************************/
335 * Logical DB ID: 0x84 with user 2 and seat 1
336 * ==> shared user value accessible by A GROUP (user 2 and seat 1)
338 * ==> used for shared testing
340 //printf("Write data to trigger change notification\n");
341 ret = pclKeyWriteData(0x84, "links/last_link2", 2, 1, (unsigned char*)"Test notify shared data", strlen("Test notify shared data"));
342 fail_unless(ret == strlen("Test notify shared data"), "Wrong write size");
345 * Logical DB ID: 0x84 with user 2 and seat 1
346 * ==> shared user value accessible by A GROUP (user 2 and seat 1)
348 * ==> used for shared testing
350 //printf("Write data to trigger change notification\n");
351 ret = pclKeyWriteData(0x84, "links/last_link3", 3, 2, (unsigned char*)"Test notify shared data", strlen("Test notify shared data"));
352 fail_unless(ret == strlen("Test notify shared data"), "Wrong write size");
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_link4", 4, 1, (unsigned char*)"Test notify shared data", strlen("Test notify shared data"));
362 fail_unless(ret == strlen("Test notify shared data"), "Wrong write size");
363 /*******************************************************************************************************************************************/
364 /*******************************************************************************************************************************************/
368 * now read the data written in the previous steps to the keys
369 * and verify data has been written correctly.
371 memset(buffer, 0, READ_SIZE);
373 ret = pclKeyReadData(0xFF, "69", 1, 2, buffer, READ_SIZE);
374 fail_unless(strncmp((char*)buffer, sysTimeBuffer, strlen(sysTimeBuffer)) == 0, "Buffer not correctly read");
375 fail_unless(ret == strlen(sysTimeBuffer), "Wrong read size");
377 memset(buffer, 0, READ_SIZE);
379 ret = pclKeyReadData(0xFF, "70", 1, 2, buffer, READ_SIZE);
380 fail_unless(strncmp((char*)buffer, write1, strlen(write1)) == 0, "Buffer not correctly read");
381 fail_unless(ret == strlen(write1), "Wrong read size");
383 memset(buffer, 0, READ_SIZE);
385 ret = pclKeyReadData(0xFF, "key_70", 1, 2, buffer, READ_SIZE);
386 fail_unless(strncmp((char*)buffer, write2, strlen(write2)) == 0, "Buffer not correctly read");
387 fail_unless(ret == strlen(write2), "Wrong read size");
397 * Write data to a key using the key interface.
398 * The key is not in the persistence resource table.
399 * The key sill then be stored to the location local and cached.
401 START_TEST(test_SetDataNoPRCT)
403 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
404 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
405 X_TEST_REPORT_REFERENCE("NONE");
406 X_TEST_REPORT_DESCRIPTION("Test of set data no PRCT");
407 X_TEST_REPORT_TYPE(GOOD);
410 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
411 unsigned char buffer[READ_SIZE] = {0};
414 ret = pclInitLibrary(gTheAppId, shutdownReg);
415 fail_unless(ret <= 1, "Failed to init PCL");
419 char sysTimeBuffer[128];
421 locTime = localtime(&t);
423 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),
424 locTime->tm_hour, locTime->tm_min, locTime->tm_sec);
427 * Logical DB ID: 0xFF with user 1 and seat 2
428 * ==> local USER value (user 1, seat 2)
430 ret = pclKeyWriteData(0xFF, "NoPRCT", 1, 2, (unsigned char*)sysTimeBuffer, strlen(sysTimeBuffer));
431 fail_unless(ret == strlen(sysTimeBuffer), "Wrong write size");
432 //printf("Write Buffer : %s\n", sysTimeBuffer);
434 // read data again and and verify datat has been written correctly
435 memset(buffer, 0, READ_SIZE);
437 ret = pclKeyReadData(0xFF, "NoPRCT", 1, 2, buffer, READ_SIZE);
438 fail_unless(strncmp((char*)buffer, sysTimeBuffer, strlen(sysTimeBuffer)) == 0, "Buffer not correctly read");
439 fail_unless(ret == strlen(sysTimeBuffer), "Wrong read size");
440 //printf("read buffer : %s\n", buffer);
449 * Test the key interface.
450 * Read the size of a key.
452 START_TEST(test_GetDataSize)
454 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
455 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
456 X_TEST_REPORT_REFERENCE("NONE");
457 X_TEST_REPORT_DESCRIPTION("Test of get data size");
458 X_TEST_REPORT_TYPE(GOOD);
460 int size = 0, ret = 0;
462 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
464 ret = pclInitLibrary(gTheAppId, shutdownReg);
465 fail_unless(ret <= 1, "Failed to init PCL");
468 * Logical DB ID: 0xFF with user 3 and seat 2
469 * ==> local USER value (user 3, seat 2)
471 size = pclKeyGetSize(0xFF, "status/open_document", 3, 2);
472 fail_unless(size == strlen("WT_ /var/opt/user_manual_climateControl.pdf"), "Invalid size");
476 * Logical DB ID: 0x84 with user 2 and seat 1
477 * ==> shared user value accessible by A GROUP (user 2 and seat 1)
479 size = pclKeyGetSize(0x84, "links/last_link", 2, 1);
480 fail_unless(size == strlen("CACHE_ /last_exit/queens"), "Invalid size");
488 * Delete a key using the key value interface.
489 * First read a from a key, the delte the key
490 * and then try to read again. The Last read must fail.
492 START_TEST(test_DeleteData)
494 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
495 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
496 X_TEST_REPORT_REFERENCE("NONE");
497 X_TEST_REPORT_DESCRIPTION("Test of delete data");
498 X_TEST_REPORT_TYPE(GOOD);
501 unsigned char buffer[READ_SIZE];
502 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
504 rval = pclInitLibrary(gTheAppId, shutdownReg);
505 fail_unless(rval <= 1, "Failed to init PCL");
507 // read data from key
508 rval = pclKeyReadData(0xFF, "key_70", 1, 2, buffer, READ_SIZE);
509 fail_unless(rval != EPERS_NOKEY, "Read form key key_70 fails");
512 rval = pclKeyDelete(0xFF, "key_70", 1, 2);
513 fail_unless(rval == 0, "Failed to delete key");
515 // after deleting the key, reading from key must fail now!
516 rval = pclKeyReadData(0xFF, "key_70", 1, 2, buffer, READ_SIZE);
517 fail_unless(rval == EPERS_NOKEY, "Read form key key_70 works, but should fail");
521 // read data from key
522 rval = pclKeyReadData(0xFF, "70", 1, 2, buffer, READ_SIZE);
523 fail_unless(rval != EPERS_NOKEY, "Read form key 70 fails");
526 rval = pclKeyDelete(0xFF, "70", 1, 2);
527 fail_unless(rval == 0, "Failed to delete key");
529 // after deleting the key, reading from key must fail now!
530 rval = pclKeyReadData(0xFF, "70", 1, 2, buffer, READ_SIZE);
531 fail_unless(rval == EPERS_NOKEY, "Read form key 70 works, but should fail");
540 * Test the file interface:
547 START_TEST(test_DataFile)
549 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
550 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
551 X_TEST_REPORT_REFERENCE("NONE");
552 X_TEST_REPORT_DESCRIPTION("Test of data file");
553 X_TEST_REPORT_TYPE(GOOD);
555 int fd = 0, i = 0, idx = 0;
556 int size = 0, ret = 0;
557 int writeSize = 16*1024;
558 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
560 unsigned char buffer[READ_SIZE] = {0};
561 const char* refBuffer = "/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media";
563 char* fileMap = NULL;
565 ret = pclInitLibrary(gTheAppId, shutdownReg);
566 fail_unless(ret <= 1, "Failed to init PCL");
568 writeBuffer = malloc(writeSize);
571 // fill buffer a sequence
572 for(i = 0; i<(writeSize/8); i++)
574 writeBuffer[idx++] = 'A';
575 writeBuffer[idx++] = 'B';
576 writeBuffer[idx++] = 'C';
577 writeBuffer[idx++] = ' ';
578 writeBuffer[idx++] = 'D';
579 writeBuffer[idx++] = 'E';
580 writeBuffer[idx++] = 'F';
581 writeBuffer[idx++] = ' ';
584 fd = open("/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDBWrite.db",
585 O_CREAT|O_RDWR|O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
588 // open ------------------------------------------------------------
589 fd = pclFileOpen(0xFF, "media/mediaDB.db", 1, 1);
590 fail_unless(fd != -1, "Could not open file ==> /media/mediaDB.db");
592 size = pclFileGetSize(fd);
593 fail_unless(size == 68, "Wrong file size");
595 size = pclFileReadData(fd, buffer, READ_SIZE);
596 fail_unless(strncmp((char*)buffer, refBuffer, strlen(refBuffer)) == 0, "Buffer not correctly read => media/mediaDB.db");
597 fail_unless(size == (strlen(refBuffer)+1), "Wrong size returned"); // strlen + 1 ==> inlcude cr/lf
600 ret = pclFileClose(fd);
601 fail_unless(ret == 0, "Failed to close file");
603 // open ------------------------------------------------------------
604 fd = pclFileOpen(0xFF, "media/mediaDBWrite.db", 1, 1);
605 fail_unless(fd != -1, "Could not open file ==> /media/mediaDBWrite.db");
607 size = pclFileWriteData(fd, writeBuffer, strlen(writeBuffer));
608 fail_unless(size == strlen(writeBuffer), "Failed to write data");
610 ret = pclFileClose(fd);
611 fail_unless(ret == 0, "Failed to close file");
614 // remove ----------------------------------------------------------
615 ret = pclFileRemove(0xFF, "media/mediaDBWrite.db", 1, 1);
616 fail_unless(ret == 0, "File can't be removed ==> /media/mediaDBWrite.db");
618 fd = open("/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDBWrite.db",O_RDWR);
619 fail_unless(fd == -1, "Failed to remove file, file still exists");
623 // map file --------------------------------------------------------
624 fd = pclFileOpen(0xFF, "media/mediaDB.db", 1, 1);
626 size = pclFileGetSize(fd);
627 pclFileMapData(fileMap, size, 0, fd);
628 fail_unless(fileMap != MAP_FAILED, "Failed to map file");
630 ret = pclFileUnmapData(fileMap, size);
631 fail_unless(ret != -1, "Failed to unmap file");
634 size = pclFileGetSize(1024);
635 fail_unless(ret == 0, "Got size, but should not");
637 ret = pclFileClose(fd);
638 fail_unless(ret == 0, "Failed to close file");
650 START_TEST(test_DataFileRecovery)
652 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
653 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
654 X_TEST_REPORT_REFERENCE("NONE");
655 X_TEST_REPORT_DESCRIPTION("Test of data file recovery");
656 X_TEST_REPORT_TYPE(GOOD);
658 int fd_RW = 0, fd_RO = 0;
660 char* wBuffer = "This is a buffer to write";
661 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
663 ret = pclInitLibrary(gTheAppId, shutdownReg);
664 fail_unless(ret <= 1, "Failed to init PCL");
667 // test backup creation --------------------------------------------
668 fd_RO = pclFileOpen(0xFF, "media/mediaDB_ReadOnly.db", 1, 1);
669 fail_unless(fd_RO != -1, "Could not open file ==> /media/mediaDB_ReadOnly.db");
671 fd_RW = pclFileOpen(0xFF, "media/mediaDB_ReadWrite.db", 1, 1);
672 fail_unless(fd_RW != -1, "Could not open file ==> /media/mediaDB_ReadWrite.db");
673 pclFileWriteData(fd_RW, wBuffer, strlen(wBuffer));
675 ret = pclFileClose(fd_RW);
678 ret = pclFileClose(fd_RO);
687 * The the handle function of the key and file interface.
689 START_TEST(test_DataHandle)
691 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
692 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
693 X_TEST_REPORT_REFERENCE("NONE");
694 X_TEST_REPORT_DESCRIPTION("Test of data handle");
695 X_TEST_REPORT_TYPE(GOOD);
697 int handle1 = 0, handle2 = 0, size = 0;
698 int handleArray[4] = {0};
700 unsigned char buffer[READ_SIZE] = {0};
701 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
703 ret = pclInitLibrary(gTheAppId, shutdownReg);
704 fail_unless(ret <= 1, "Failed to init PCL");
707 handle1 = pclFileOpen(0xFF, "media/mediaDB.db", 1, 1);
708 fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB.db");
710 ret = pclFileClose(handle1);
711 fail_unless(handle1 != -1, "Could not closefile ==> /media/mediaDB.db");
713 ret = pclFileClose(1024);
714 fail_unless(ret == EPERS_MAXHANDLE, "Could close file, but should not!!");
716 ret = pclFileClose(17);
717 fail_unless(ret == -1, "Could close file, but should not!!");
719 // test multiple handles
720 handleArray[0] = pclFileOpen(0xFF, "media/mediaDB_write_01.db", 1, 1);
721 fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_01.db");
723 handleArray[1] = pclFileOpen(0xFF, "media/mediaDB_write_02.db", 1, 1);
724 fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_02.db");
726 handleArray[2] = pclFileOpen(0xFF, "media/mediaDB_write_03.db", 1, 1);
727 fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_03.db");
729 handleArray[3] = pclFileOpen(0xFF, "media/mediaDB_write_04.db", 1, 1);
730 fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_04.db");
732 size = pclFileReadData(handleArray[0], buffer, READ_SIZE);
733 fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_01.db",
734 strlen("/user/1/seat/1/media/mediaDB_write_01.db"))
735 == 0, "Buffer not correctly read => mediaDB_write_01.db");
737 size = pclFileReadData(handleArray[1], buffer, READ_SIZE);
738 fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_02.db",
739 strlen("/user/1/seat/1/media/mediaDB_write_02.db"))
740 == 0, "Buffer not correctly read => mediaDB_write_02.db");
742 size = pclFileReadData(handleArray[2], buffer, READ_SIZE);
743 fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_03.db",
744 strlen("/user/1/seat/1/media/mediaDB_write_03.db"))
745 == 0, "Buffer not correctly read => mediaDB_write_03.db");
747 size = pclFileReadData(handleArray[3], buffer, READ_SIZE);
748 fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_04.db",
749 strlen("/user/1/seat/1/media/mediaDB_write_04.db"))
750 == 0, "Buffer not correctly read => mediaDB_write_04.db");
752 ret = pclKeyHandleClose(handleArray[0]);
753 fail_unless(ret != -1, "Failed to close handle idx \"0\"!!");
755 ret = pclKeyHandleClose(handleArray[1]);
756 fail_unless(ret != -1, "Failed to close handle idx \"1\"!!");
758 ret = pclKeyHandleClose(handleArray[2]);
759 fail_unless(ret != -1, "Failed to close handle idx \"2\"!!");
761 ret = pclKeyHandleClose(handleArray[3]);
762 fail_unless(ret != -1, "Failed to close handle idx \"3\"!!");
765 handle2 = pclKeyHandleOpen(0xFF, "statusHandle/open_document", 3, 2);
766 fail_unless(handle2 >= 0, "Failed to open handle /statusHandle/open_document");
768 ret = pclKeyHandleClose(handle2);
769 fail_unless(ret != -1, "Failed to close handle!!");
771 ret = pclKeyHandleClose(1024);
772 fail_unless(ret == EPERS_MAXHANDLE, "Max handle!!");
781 * Extended key handle test.
782 * Test have been created after a bug in the key handle function occured.
784 START_TEST(test_DataHandleOpen)
786 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
787 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
788 X_TEST_REPORT_REFERENCE("NONE");
789 X_TEST_REPORT_DESCRIPTION("Test of data handle open");
790 X_TEST_REPORT_TYPE(GOOD);
792 int hd1 = -2, hd2 = -2, hd3 = -2, hd4 = -2, hd5 = -2, hd6 = -2, hd7 = -2, hd8 = -2, hd9 = -2, ret = 0;
793 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
795 ret = pclInitLibrary(gTheAppId, shutdownReg);
796 fail_unless(ret <= 1, "Failed to init PCL");
798 // open handles ----------------------------------------------------
799 hd1 = pclKeyHandleOpen(0xFF, "posHandle/last_position1", 0, 0);
800 fail_unless(hd1 == 1, "Failed to open handle ==> /posHandle/last_position1");
802 hd2 = pclKeyHandleOpen(0xFF, "posHandle/last_position2", 0, 0);
803 fail_unless(hd2 == 2, "Failed to open handle ==> /posHandle/last_position2");
805 hd3 = pclKeyHandleOpen(0xFF, "posHandle/last_position3", 0, 0);
806 fail_unless(hd3 == 3, "Failed to open handle ==> /posHandle/last_position3");
808 // close handles ---------------------------------------------------
809 ret = pclKeyHandleClose(hd1);
810 fail_unless(ret != -1, "Failed to close handle!!");
812 ret = pclKeyHandleClose(hd2);
813 fail_unless(ret != -1, "Failed to close handle!!");
815 ret = pclKeyHandleClose(hd3);
816 fail_unless(ret != -1, "Failed to close handle!!");
818 // open handles ----------------------------------------------------
819 hd4 = pclKeyHandleOpen(0xFF, "posHandle/last_position4", 0, 0);
820 fail_unless(hd4 == 3, "Failed to open handle ==> /posHandle/last_position4");
822 hd5 = pclKeyHandleOpen(0xFF, "posHandle/last_position5", 0, 0);
823 fail_unless(hd5 == 2, "Failed to open handle ==> /posHandle/last_position5");
825 hd6 = pclKeyHandleOpen(0xFF, "posHandle/last_position6", 0, 0);
826 fail_unless(hd6 == 1, "Failed to open handle ==> /posHandle/last_position6");
828 hd7 = pclKeyHandleOpen(0xFF, "posHandle/last_position7", 0, 0);
829 fail_unless(hd7 == 4, "Failed to open handle ==> /posHandle/last_position7");
831 hd8 = pclKeyHandleOpen(0xFF, "posHandle/last_position8", 0, 0);
832 fail_unless(hd8 == 5, "Failed to open handle ==> /posHandle/last_position8");
834 hd9 = pclKeyHandleOpen(0xFF, "posHandle/last_position9", 0, 0);
835 fail_unless(hd9 == 6, "Failed to open handle ==> /posHandle/last_position9");
837 // close handles ---------------------------------------------------
838 ret = pclKeyHandleClose(hd4);
839 fail_unless(ret != -1, "Failed to close handle!!");
841 ret = pclKeyHandleClose(hd5);
842 fail_unless(ret != -1, "Failed to close handle!!");
844 ret = pclKeyHandleClose(hd6);
845 fail_unless(ret != -1, "Failed to close handle!!");
847 ret = pclKeyHandleClose(hd7);
848 fail_unless(ret != -1, "Failed to close handle!!");
850 ret = pclKeyHandleClose(hd8);
851 fail_unless(ret != -1, "Failed to close handle!!");
853 ret = pclKeyHandleClose(hd9);
854 fail_unless(ret != -1, "Failed to close handle!!");
863 * Test for i n t e r n a l structures.
864 * Test the cursor functions.
866 START_TEST(test_Cursor)
868 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
869 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
870 X_TEST_REPORT_REFERENCE("NONE");
871 X_TEST_REPORT_DESCRIPTION("Test of cursor");
872 X_TEST_REPORT_TYPE(GOOD);
874 int handle = -1, rval = 0, size = 0, handle1 = 0;
875 char bufferKeySrc[READ_SIZE] = {0};
876 char bufferDataSrc[READ_SIZE] = {0};
877 char bufferKeyDst[READ_SIZE] = {0};
878 char bufferDataDst[READ_SIZE] = {0};
879 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
881 rval = pclInitLibrary(gTheAppId, shutdownReg);
882 fail_unless(rval <= 1, "Failed to init PCL");
885 handle = pers_db_cursor_create("/Data/mnt-c/lt-persistence_client_library_test/cached.itz");
886 fail_unless(handle != -1, "Failed to create cursor!!");
889 handle1 = pers_db_cursor_create("/Data/mnt-wt/lt-persistence_client_library_test/wt.itz");
890 fail_unless(handle1 != -1, "Failed to create cursor!!");
894 memset(bufferKeySrc, 0, READ_SIZE);
895 memset(bufferDataSrc, 0, READ_SIZE);
896 memset(bufferKeyDst, 0, READ_SIZE);
897 memset(bufferDataDst, 0, READ_SIZE);
900 rval = pers_db_cursor_get_key(handle, bufferKeySrc, 256);
901 fail_unless(rval != -1, "Cursor failed to get key!!");
903 rval = pers_db_cursor_get_data(handle, bufferDataSrc, 256);
905 fail_unless(rval != -1, "Cursor failed to get data!!");
907 size = pers_db_cursor_get_data_size(handle);
908 fail_unless(size != -1, "Cursor failed to get size!!");
909 //printf("1. Key: %s | Data: %s » Size: %d \n", bufferKeySrc, bufferDataSrc, size);
912 rval = pers_db_cursor_get_key(handle1, bufferKeyDst, 256);
913 fail_unless(rval != -1, "Cursor failed to get key!!");
915 rval = pers_db_cursor_get_data(handle1, bufferDataDst, 256);
916 fail_unless(rval != -1, "Cursor failed to get data!!");
918 size = pers_db_cursor_get_data_size(handle1);
919 fail_unless(size != -1, "Cursor failed to get size!!");
920 //printf(" 2. Key: %s | Data: %s » Size: %d \n", bufferKeyDst, bufferDataDst, size);
922 while( (pers_db_cursor_next(handle) == 0) && (pers_db_cursor_next(handle1) == 0) ); // next cursor
925 rval = pers_db_cursor_destroy(handle);
926 fail_unless(rval != -1, "Failed to destroy cursor!!");
928 rval = pers_db_cursor_destroy(handle1);
929 fail_unless(rval != -1, "Failed to destroy cursor!!");
937 START_TEST(test_Plugin)
939 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
940 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
941 X_TEST_REPORT_REFERENCE("NONE");
942 X_TEST_REPORT_DESCRIPTION("Test of plugins");
943 X_TEST_REPORT_TYPE(GOOD);
946 unsigned char buffer[READ_SIZE] = {0};
948 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
950 ret = pclInitLibrary(gTheAppId, shutdownReg);
951 fail_unless(ret <= 1, "Failed to init PCL");
953 ret = pclKeyReadData(0xFF, "language/country_code", 0, 0, buffer, READ_SIZE);
954 fail_unless(ret != EPERS_NOT_INITIALIZED);
955 fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: secure!",
956 strlen((char*)buffer)) == 0, "Buffer SECURE not correctly read");
959 ret = pclKeyReadData(0xFF, "language/country_code_early", 0, 0, buffer, READ_SIZE);
960 fail_unless(ret != EPERS_NOT_INITIALIZED);
961 //printf("B U F F E R - early: %s\n", buffer);
962 fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: early!",
963 strlen((char*)buffer)) == 0, "Buffer EARLY not correctly read");
965 ret = pclKeyReadData(0xFF, "language/country_code_emergency", 0, 0, buffer, READ_SIZE);
966 fail_unless(ret != EPERS_NOT_INITIALIZED);
967 //printf("B U F F E R - emergency: %s\n", buffer);
968 fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: emergency!",
969 strlen((char*)buffer)) == 0, "Buffer EMERGENCY not correctly read");
971 ret = pclKeyReadData(0xFF, "language/info", 0, 0, buffer, READ_SIZE);
972 fail_unless(ret != EPERS_NOT_INITIALIZED);
973 //printf("B U F F E R - hwinfo: %s\n", buffer);
974 fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: hwinfo!",
975 strlen((char*)buffer)) == 0, "Buffer HWINFO not correctly read");
977 ret = pclKeyReadData(0xFF, "language/country_code_custom3", 0, 0, buffer, READ_SIZE);
978 fail_unless(ret != EPERS_NOT_INITIALIZED);
979 //printf("B U F F E R - hwinfo: %s\n", buffer);
980 fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: custom3!",
981 strlen((char*)buffer)) == 0, "Buffer CUSTOM 3 not correctly read");
991 START_TEST(test_ReadDefault)
993 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
994 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
995 X_TEST_REPORT_REFERENCE("NONE");
996 X_TEST_REPORT_DESCRIPTION("Test of read default");
997 X_TEST_REPORT_TYPE(GOOD);
1000 unsigned char buffer[READ_SIZE] = {0};
1002 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
1004 ret = pclInitLibrary(gTheAppId, shutdownReg);
1005 fail_unless(ret <= 1, "Failed to init PCL");
1007 ret = pclKeyReadData(0xFF, "statusHandle/default01", 3, 2, buffer, READ_SIZE);
1008 fail_unless(ret != EPERS_NOT_INITIALIZED);
1009 //printf("B U F F E R: %s\n", buffer);
1010 fail_unless(strncmp((char*)buffer,"DEFAULT_01!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
1012 ret = pclKeyReadData(0xFF, "statusHandle/default02", 3, 2, buffer, READ_SIZE);
1013 fail_unless(ret != EPERS_NOT_INITIALIZED);
1014 //printf("B U F F E R: %s\n", buffer);
1015 fail_unless(strncmp((char*)buffer,"DEFAULT_02!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
1023 START_TEST(test_ReadConfDefault)
1025 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
1026 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
1027 X_TEST_REPORT_REFERENCE("NONE");
1028 X_TEST_REPORT_DESCRIPTION("Test of configurable default data");
1029 X_TEST_REPORT_TYPE(GOOD);
1032 unsigned char buffer[READ_SIZE] = {0};
1034 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
1036 ret = pclInitLibrary(gTheAppId, shutdownReg);
1037 fail_unless(ret <= 1, "Failed to init PCL");
1039 ret = pclKeyReadData(0xFF, "statusHandle/confdefault01", 3, 2, buffer, READ_SIZE);
1040 fail_unless(ret != EPERS_NOT_INITIALIZED);
1041 fail_unless(strncmp((char*)buffer,"CONF_DEFAULT_01!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
1043 ret = pclKeyReadData(0xFF, "statusHandle/confdefault02", 3, 2, buffer, READ_SIZE);
1044 fail_unless(ret != EPERS_NOT_INITIALIZED);
1045 fail_unless(strncmp((char*)buffer,"CONF_DEFAULT_02!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
1053 START_TEST(test_GetPath)
1055 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
1056 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
1057 X_TEST_REPORT_REFERENCE("NONE");
1058 X_TEST_REPORT_DESCRIPTION("Test of get path");
1059 X_TEST_REPORT_TYPE(GOOD);
1063 const char* thePath = "/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDB_create.db";
1064 unsigned int pathSize = 0;
1066 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
1068 ret = pclInitLibrary(gTheAppId, shutdownReg);
1069 fail_unless(ret <= 1, "Failed to init PCL");
1071 ret = pclFileCreatePath(0xFF, "media/mediaDB_create.db", 1, 1, &path, &pathSize);
1072 fail_unless(strncmp((char*)path, thePath, strlen((char*)path)) == 0, "Path not correct");
1073 fail_unless(pathSize == strlen((char*)path), "Path size not correct");
1075 pclFileReleasePath(ret);
1082 static Suite * persistencyClientLib_suite()
1084 Suite * s = suite_create("Persistency client library");
1086 TCase * tc_persGetData = tcase_create("GetData");
1087 tcase_add_test(tc_persGetData, test_GetData);
1089 TCase * tc_persSetData = tcase_create("SetData");
1090 tcase_add_test(tc_persSetData, test_SetData);
1092 TCase * tc_persSetDataNoPRCT = tcase_create("SetDataNoPRCT");
1093 tcase_add_test(tc_persSetDataNoPRCT, test_SetDataNoPRCT);
1095 TCase * tc_persGetDataSize = tcase_create("GetDataSize");
1096 tcase_add_test(tc_persGetDataSize, test_GetDataSize);
1098 TCase * tc_persDeleteData = tcase_create("DeleteData");
1099 tcase_add_test(tc_persDeleteData, test_DeleteData);
1101 TCase * tc_persGetDataHandle = tcase_create("GetDataHandle");
1102 tcase_add_test(tc_persGetDataHandle, test_GetDataHandle);
1104 TCase * tc_persDataHandle = tcase_create("DataHandle");
1105 tcase_add_test(tc_persDataHandle, test_DataHandle);
1107 TCase * tc_persDataHandleOpen = tcase_create("DataHandleOpen");
1108 tcase_add_test(tc_persDataHandleOpen, test_DataHandleOpen);
1110 TCase * tc_persDataFile = tcase_create("DataFile");
1111 tcase_add_test(tc_persDataFile, test_DataFile);
1113 TCase * tc_persDataFileRecovery = tcase_create("DataFileRecovery");
1114 tcase_add_test(tc_persDataFileRecovery, test_DataFileRecovery);
1116 TCase * tc_Cursor = tcase_create("Cursor");
1117 tcase_add_test(tc_Cursor, test_Cursor);
1119 TCase * tc_Plugin = tcase_create("Plugin");
1120 tcase_add_test(tc_Plugin, test_Plugin);
1122 TCase * tc_ReadDefault = tcase_create("ReadDefault");
1123 tcase_add_test(tc_ReadDefault, test_ReadDefault);
1125 TCase * tc_ReadConfDefault = tcase_create("ReadConfDefault");
1126 tcase_add_test(tc_ReadConfDefault, test_ReadConfDefault);
1128 TCase * tc_GetPath = tcase_create("GetPath");
1129 tcase_add_test(tc_GetPath, test_GetPath);
1131 suite_add_tcase(s, tc_persSetData);
1132 suite_add_tcase(s, tc_persGetData);
1133 suite_add_tcase(s, tc_persSetDataNoPRCT);
1134 suite_add_tcase(s, tc_persGetDataSize);
1135 suite_add_tcase(s, tc_persDeleteData);
1136 suite_add_tcase(s, tc_persGetDataHandle);
1137 suite_add_tcase(s, tc_persDataHandle);
1138 suite_add_tcase(s, tc_persDataHandleOpen);
1139 suite_add_tcase(s, tc_persDataFile);
1140 suite_add_tcase(s, tc_persDataFileRecovery);
1141 suite_add_tcase(s, tc_Cursor);
1142 suite_add_tcase(s, tc_ReadDefault);
1143 suite_add_tcase(s, tc_ReadConfDefault);
1144 suite_add_tcase(s, tc_GetPath);
1145 //suite_add_tcase(s, tc_Plugin); // activate only if the plugins are available
1150 int main(int argc, char *argv[])
1157 TestResult** tResult;
1159 // assign application name
1160 strncpy(gTheAppId, "lt-persistence_client_library_test", MaxAppNameLen);
1161 gTheAppId[MaxAppNameLen-1] = '\0';
1163 /// debug log and trace (DLT) setup
1164 DLT_REGISTER_APP("test","tests the persistence client library");
1167 Suite * s = persistencyClientLib_suite();
1168 SRunner * sr = srunner_create(s);
1169 srunner_set_xml(sr, "/tmp/persistenceClientLibraryTest.xml");
1170 srunner_set_log(sr, "/tmp/persistenceClientLibraryTest.log");
1171 srunner_run_all(sr, /*CK_NORMAL*/ CK_VERBOSE);
1173 nr_failed = srunner_ntests_failed(sr);
1174 nr_run = srunner_ntests_run(sr);
1176 tResult = srunner_results(sr);
1177 for(i = 0; i< nr_run; i++)
1179 fail = tr_rtype(tResult[i]); // get status of each test
1180 //printf("[%d] Fail: %d \n", i, fail);
1186 // unregister debug log and trace
1187 DLT_UNREGISTER_APP();
1191 return (0==nr_failed)?EXIT_SUCCESS:EXIT_FAILURE;