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>
32 #include "persCheck.h"
35 #include "../include/persistence_client_library_file.h"
36 #include "../include/persistence_client_library_key.h"
37 #include "../include/persistence_client_library.h"
40 // protected header, should be used only be persistence components
41 // included here for testing purpose
42 #include "../include_protected/persistence_client_library_db_access.h"
46 #define NUM_OF_FILES 3
47 #define READ_SIZE 1024
50 char gTheAppId[MaxAppNameLen] = {0};
52 // definition of weekday
53 char* dayOfWeek[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
58 * Test the key value interface using different logicalDB id's, users and seats.
59 * Each resource below has an entry in the resource configuration table where the
60 * storage location (cached or write through) and type (e.g. custom) has been configured.
62 START_TEST (test_GetData)
64 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
65 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
66 X_TEST_REPORT_REFERENCE("NONE");
67 X_TEST_REPORT_DESCRIPTION("Test of get data");
68 X_TEST_REPORT_TYPE(GOOD);
71 unsigned int shutdownReg = (PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL);
73 unsigned char buffer[READ_SIZE] = {0};
75 ret = pclInitLibrary(gTheAppId, shutdownReg);
76 x_fail_unless(ret <= 1, "Failed to init PCL");
80 * Logical DB ID: 0xFF with user 0 and seat 0
81 * ==> local value accessible by all users (user 0, seat 0)
83 ret = pclKeyReadData(0xFF, "pos/last_position", 0, 0, buffer, READ_SIZE);
84 x_fail_unless(strncmp((char*)buffer, "CACHE_ +48° 10' 38.95\", +8° 44' 39.06\"",
85 strlen((char*)buffer)) == 0, "Buffer not correctly read");
86 x_fail_unless(ret = strlen("CACHE_ +48° 10' 38.95\", +8° 44' 39.06\""));
88 memset(buffer, 0, READ_SIZE);
91 * Logical DB ID: 0xFF with user 0 and seat 0
92 * ==> local value accessible by all users (user 0, seat 0)
94 ret = pclKeyReadData(0xFF, "language/country_code", 0, 0, buffer, READ_SIZE);
95 x_fail_unless(strncmp((char*)buffer, "Custom plugin -> plugin_get_data: secure!",
96 strlen((char*)buffer)) == 0, "Buffer not correctly read");
97 x_fail_unless(ret = strlen("Custom plugin -> plugin_get_data_handle"));
99 memset(buffer, 0, READ_SIZE);
103 * Logical DB ID: 0 with user 3 and seat 0
104 * ==> public shared user value (user 3, seat 0)
106 ret = pclKeyReadData(0, "language/current_language", 3, 0, buffer, READ_SIZE);
107 x_fail_unless(strncmp((char*)buffer, "CACHE_ Kisuaheli", strlen((char*)buffer)) == 0, "Buffer not correctly read");
109 memset(buffer, 0, READ_SIZE);
112 * Logical DB ID: 0xFF with user 3 and seat 2
113 * ==> local USER value (user 3, seat 2)
115 ret = pclKeyReadData(0xFF, "status/open_document", 3, 2, buffer, READ_SIZE);
116 x_fail_unless(strncmp((char*)buffer, "WT_ /var/opt/user_manual_climateControl.pdf", strlen((char*)buffer)) == 0, "Buffer not correctly read");
118 memset(buffer, 0, READ_SIZE);
121 * Logical DB ID: 0x20 with user 4 and seat 0
122 * ==> shared user value accessible by a group (user 4 and seat 0)
124 ret = pclKeyReadData(0x20, "address/home_address", 4, 0, buffer, READ_SIZE);
125 x_fail_unless(strncmp((char*)buffer, "WT_ 55327 Heimatstadt, Wohnstrasse 31", strlen((char*)buffer)) == 0, "Buffer not correctly read");
127 memset(buffer, 0, READ_SIZE);
130 * Logical DB ID: 0xFF with user 0 and seat 0
131 * ==> local value accessible by ALL USERS (user 0, seat 0)
133 ret = pclKeyReadData(0xFF, "pos/last_satellites", 0, 0, buffer, READ_SIZE);
134 x_fail_unless(strncmp((char*)buffer, "WT_ 17", strlen((char*)buffer)) == 0, "Buffer not correctly read");
136 memset(buffer, 0, READ_SIZE);
139 * Logical DB ID: 0x84 with user 4 and seat 0
140 * ==> shared user value accessible by A GROUP (user 4 and seat 0)
142 ret = pclKeyReadData(0x84, "links/last_link", 2, 0, buffer, READ_SIZE);
143 x_fail_unless(strncmp((char*)buffer, "CACHE_ /last_exit/brooklyn", strlen((char*)buffer)) == 0, "Buffer not correctly read");
145 memset(buffer, 0, READ_SIZE);
148 * Logical DB ID: 0x84 with user 2 and seat 1
149 * ==> local merge value
151 ret = pclKeyReadData(0x84, "links/last_link", 2, 1, buffer, READ_SIZE);
152 x_fail_unless(strncmp((char*)buffer, "CACHE_ /last_exit/queens", strlen((char*)buffer)) == 0, "Buffer not correctly read");
161 * Test the key value h a n d l e interface using different logicalDB id's, users and seats
162 * Each resource below has an entry in the resource configuration table where
163 * the storage location (cached or write through) and type (e.g. custom) has bee configured.
165 START_TEST (test_GetDataHandle)
167 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
168 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
169 X_TEST_REPORT_REFERENCE("NONE");
170 X_TEST_REPORT_DESCRIPTION("Test of get data handle");
171 X_TEST_REPORT_TYPE(GOOD);
173 int ret = 0, handle = 0, handle2 = 0, handle3 = 0, handle4 = 0, size = 0;
174 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
176 unsigned char buffer[READ_SIZE] = {0};
179 char sysTimeBuffer[128];
181 ret = pclInitLibrary(gTheAppId, shutdownReg);
182 x_fail_unless(ret <= 1, "Failed to init PCL");
186 locTime = localtime(&t);
188 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),
189 locTime->tm_hour, locTime->tm_min, locTime->tm_sec);
192 // open handle ---------------------------------------------------
194 * Logical DB ID: 0xFF with user 0 and seat 0
195 * ==> local value accessible by ALL USERS (user 0, seat 0)
197 handle = pclKeyHandleOpen(0xFF, "posHandle/last_position", 0, 0);
198 x_fail_unless(handle >= 0, "Failed to open handle ==> /posHandle/last_position");
200 ret = pclKeyHandleReadData(handle, buffer, READ_SIZE);
201 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");
203 size = pclKeyHandleGetSize(handle);
204 x_fail_unless(size == strlen("WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\""));
205 // ---------------------------------------------------------------------------------------------
208 // open handle ---------------------------------------------------
210 * Logical DB ID: 0xFF with user 3 and seat 2
211 * ==> local USER value (user 3, seat 2)
213 handle2 = pclKeyHandleOpen(0xFF, "statusHandle/open_document", 3, 2);
214 x_fail_unless(handle2 >= 0, "Failed to open handle /statusHandle/open_document");
216 size = pclKeyHandleWriteData(handle2, (unsigned char*)sysTimeBuffer, strlen(sysTimeBuffer));
217 x_fail_unless(size == strlen(sysTimeBuffer));
219 ret = pclKeyHandleClose(handle2);
220 // ---------------------------------------------------------------------------------------------
223 // open handle ---------------------------------------------------
225 * Logical DB ID: 0xFF with user 0 and seat 0
226 * ==> local value accessible by ALL USERS (user 0, seat 0)
228 #if 0 // plugin test case
229 memset(buffer, 0, READ_SIZE);
230 handle4 = pclKeyHandleOpen(0xFF, "language/country_code", 0, 0);
231 printf("H A N D L E: %d\n", handle4);
232 x_fail_unless(handle4 >= 0, "Failed to open handle /language/country_code");
234 ret = pclKeyHandleReadData(handle4, buffer, READ_SIZE);
235 x_fail_unless(strncmp((char*)buffer, "Custom plugin -> plugin_get_data_handle: secure!", -1) == 0, "Buffer not correctly read => 2");
237 size = pclKeyHandleGetSize(handle4);
238 x_fail_unless(size = strlen("Custom plugin -> plugin_get_data_handle"));
240 ret = pclKeyHandleWriteData(handle4, (unsigned char*)"Only dummy implementation behind custom library", READ_SIZE);
242 // ---------------------------------------------------------------------------------------------
245 // open handle ---------------------------------------------------
247 * Logical DB ID: 0xFF with user 3 and seat 2
248 * ==> local USER value (user 3, seat 2)
250 handle3 = pclKeyHandleOpen(0xFF, "statusHandle/open_document", 3, 2);
251 x_fail_unless(handle3 >= 0, "Failed to open handle /statusHandle/open_document");
253 ret = pclKeyHandleReadData(handle3, buffer, READ_SIZE);
254 x_fail_unless(strncmp((char*)buffer, sysTimeBuffer, strlen(sysTimeBuffer)) == 0, "Buffer not correctly read => 3");
256 size = pclKeyHandleGetSize(handle3);
257 x_fail_unless(size = strlen(sysTimeBuffer));
258 // ---------------------------------------------------------------------------------------------
262 ret = pclKeyHandleClose(handle);
263 ret = pclKeyHandleClose(handle3);
264 ret = pclKeyHandleClose(handle4);
272 * Write data to a key using the key interface.
273 * First write data to different keys and after
274 * read the data for verification.
276 START_TEST(test_SetData)
278 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
279 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
280 X_TEST_REPORT_REFERENCE("NONE");
281 X_TEST_REPORT_DESCRIPTION("Test of set data");
282 X_TEST_REPORT_TYPE(GOOD);
285 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
286 unsigned char buffer[READ_SIZE] = {0};
287 char write1[READ_SIZE] = {0};
288 char write2[READ_SIZE] = {0};
289 char sysTimeBuffer[256];
293 ret = pclInitLibrary(gTheAppId, shutdownReg);
294 x_fail_unless(ret <= 1, "Failed to init PCL");
298 locTime = localtime(&t);
301 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),
302 locTime->tm_hour, locTime->tm_min, locTime->tm_sec);
305 * Logical DB ID: 0xFF with user 1 and seat 2
306 * ==> local USER value (user 1, seat 2)
310 ret = pclKeyWriteData(0xFF, "69", 1, 2, (unsigned char*)sysTimeBuffer, strlen(sysTimeBuffer));
311 x_fail_unless(ret == strlen(sysTimeBuffer), "Wrong write size");
313 snprintf(write1, 128, "%s %s", "/70", sysTimeBuffer);
315 * Logical DB ID: 0xFF with user 1 and seat 2
316 * ==> local USER value (user 1, seat 2)
319 ret = pclKeyWriteData(0xFF, "70", 1, 2, (unsigned char*)write1, strlen(write1));
320 x_fail_unless(ret == strlen(write1), "Wrong write size");
322 snprintf(write2, 128, "%s %s", "/key_70", sysTimeBuffer);
324 * Logical DB ID: 0xFF with user 1 and seat 2
325 * ==> local USER value (user 1, seat 2)
326 * Resource ID: key_70
328 ret = pclKeyWriteData(0xFF, "key_70", 1, 2, (unsigned char*)write2, strlen(write2));
329 x_fail_unless(ret == strlen(write2), "Wrong write size");
332 /*******************************************************************************************************************************************/
333 /* used for changed notification testing */
334 /*******************************************************************************************************************************************/
336 * Logical DB ID: 0x84 with user 2 and seat 1
337 * ==> shared user value accessible by A GROUP (user 2 and seat 1)
339 * ==> used for shared testing
341 //printf("Write data to trigger change notification\n");
342 ret = pclKeyWriteData(0x84, "links/last_link2", 2, 1, (unsigned char*)"Test notify shared data", strlen("Test notify shared data"));
343 x_fail_unless(ret == strlen("Test notify shared data"), "Wrong write size");
346 * Logical DB ID: 0x84 with user 2 and seat 1
347 * ==> shared user value accessible by A GROUP (user 2 and seat 1)
349 * ==> used for shared testing
351 //printf("Write data to trigger change notification\n");
352 ret = pclKeyWriteData(0x84, "links/last_link3", 3, 2, (unsigned char*)"Test notify shared data", strlen("Test notify shared data"));
353 x_fail_unless(ret == strlen("Test notify shared data"), "Wrong write size");
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_link4", 4, 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");
364 /*******************************************************************************************************************************************/
365 /*******************************************************************************************************************************************/
369 * now read the data written in the previous steps to the keys
370 * and verify data has been written correctly.
372 memset(buffer, 0, READ_SIZE);
374 ret = pclKeyReadData(0xFF, "69", 1, 2, buffer, READ_SIZE);
375 x_fail_unless(strncmp((char*)buffer, sysTimeBuffer, strlen(sysTimeBuffer)) == 0, "Buffer not correctly read");
376 x_fail_unless(ret == strlen(sysTimeBuffer), "Wrong read size");
378 memset(buffer, 0, READ_SIZE);
380 ret = pclKeyReadData(0xFF, "70", 1, 2, buffer, READ_SIZE);
381 x_fail_unless(strncmp((char*)buffer, write1, strlen(write1)) == 0, "Buffer not correctly read");
382 x_fail_unless(ret == strlen(write1), "Wrong read size");
384 memset(buffer, 0, READ_SIZE);
386 ret = pclKeyReadData(0xFF, "key_70", 1, 2, buffer, READ_SIZE);
387 x_fail_unless(strncmp((char*)buffer, write2, strlen(write2)) == 0, "Buffer not correctly read");
388 x_fail_unless(ret == strlen(write2), "Wrong read size");
398 * Write data to a key using the key interface.
399 * The key is not in the persistence resource table.
400 * The key sill then be stored to the location local and cached.
402 START_TEST(test_SetDataNoPRCT)
404 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
405 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
406 X_TEST_REPORT_REFERENCE("NONE");
407 X_TEST_REPORT_DESCRIPTION("Test of set data no PRCT");
408 X_TEST_REPORT_TYPE(GOOD);
411 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
412 unsigned char buffer[READ_SIZE] = {0};
415 ret = pclInitLibrary(gTheAppId, shutdownReg);
416 x_fail_unless(ret <= 1, "Failed to init PCL");
420 char sysTimeBuffer[128];
422 locTime = localtime(&t);
424 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),
425 locTime->tm_hour, locTime->tm_min, locTime->tm_sec);
428 * Logical DB ID: 0xFF with user 1 and seat 2
429 * ==> local USER value (user 1, seat 2)
431 ret = pclKeyWriteData(0xFF, "NoPRCT", 1, 2, (unsigned char*)sysTimeBuffer, strlen(sysTimeBuffer));
432 x_fail_unless(ret == strlen(sysTimeBuffer), "Wrong write size");
433 //printf("Write Buffer : %s\n", sysTimeBuffer);
435 // read data again and and verify datat has been written correctly
436 memset(buffer, 0, READ_SIZE);
438 ret = pclKeyReadData(0xFF, "NoPRCT", 1, 2, buffer, READ_SIZE);
439 x_fail_unless(strncmp((char*)buffer, sysTimeBuffer, strlen(sysTimeBuffer)) == 0, "Buffer not correctly read");
440 x_fail_unless(ret == strlen(sysTimeBuffer), "Wrong read size");
441 //printf("read buffer : %s\n", buffer);
450 * Test the key interface.
451 * Read the size of a key.
453 START_TEST(test_GetDataSize)
455 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
456 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
457 X_TEST_REPORT_REFERENCE("NONE");
458 X_TEST_REPORT_DESCRIPTION("Test of get data size");
459 X_TEST_REPORT_TYPE(GOOD);
461 int size = 0, ret = 0;
463 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
465 ret = pclInitLibrary(gTheAppId, shutdownReg);
466 x_fail_unless(ret <= 1, "Failed to init PCL");
469 * Logical DB ID: 0xFF with user 3 and seat 2
470 * ==> local USER value (user 3, seat 2)
472 size = pclKeyGetSize(0xFF, "status/open_document", 3, 2);
473 x_fail_unless(size == strlen("WT_ /var/opt/user_manual_climateControl.pdf"), "Invalid size");
477 * Logical DB ID: 0x84 with user 2 and seat 1
478 * ==> shared user value accessible by A GROUP (user 2 and seat 1)
480 size = pclKeyGetSize(0x84, "links/last_link", 2, 1);
481 x_fail_unless(size == strlen("CACHE_ /last_exit/queens"), "Invalid size");
489 * Delete a key using the key value interface.
490 * First read a from a key, the delte the key
491 * and then try to read again. The Last read must fail.
493 START_TEST(test_DeleteData)
495 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
496 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
497 X_TEST_REPORT_REFERENCE("NONE");
498 X_TEST_REPORT_DESCRIPTION("Test of delete data");
499 X_TEST_REPORT_TYPE(GOOD);
502 unsigned char buffer[READ_SIZE];
503 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
505 rval = pclInitLibrary(gTheAppId, shutdownReg);
506 x_fail_unless(rval <= 1, "Failed to init PCL");
508 // read data from key
509 rval = pclKeyReadData(0xFF, "key_70", 1, 2, buffer, READ_SIZE);
510 x_fail_unless(rval != EPERS_NOKEY, "Read form key key_70 fails");
513 rval = pclKeyDelete(0xFF, "key_70", 1, 2);
514 x_fail_unless(rval == 0, "Failed to delete key");
516 // after deleting the key, reading from key must fail now!
517 rval = pclKeyReadData(0xFF, "key_70", 1, 2, buffer, READ_SIZE);
518 x_fail_unless(rval == EPERS_NOKEY, "Read form key key_70 works, but should fail");
522 // read data from key
523 rval = pclKeyReadData(0xFF, "70", 1, 2, buffer, READ_SIZE);
524 x_fail_unless(rval != EPERS_NOKEY, "Read form key 70 fails");
527 rval = pclKeyDelete(0xFF, "70", 1, 2);
528 x_fail_unless(rval == 0, "Failed to delete key");
530 // after deleting the key, reading from key must fail now!
531 rval = pclKeyReadData(0xFF, "70", 1, 2, buffer, READ_SIZE);
532 x_fail_unless(rval == EPERS_NOKEY, "Read form key 70 works, but should fail");
541 * Test the file interface:
548 START_TEST(test_DataFile)
550 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
551 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
552 X_TEST_REPORT_REFERENCE("NONE");
553 X_TEST_REPORT_DESCRIPTION("Test of data file");
554 X_TEST_REPORT_TYPE(GOOD);
556 int fd = 0, i = 0, idx = 0;
557 int size = 0, ret = 0;
558 int writeSize = 16*1024;
559 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
561 unsigned char buffer[READ_SIZE] = {0};
562 const char* refBuffer = "/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media";
564 char* fileMap = NULL;
566 ret = pclInitLibrary(gTheAppId, shutdownReg);
567 x_fail_unless(ret <= 1, "Failed to init PCL");
569 writeBuffer = malloc(writeSize);
572 // fill buffer a sequence
573 for(i = 0; i<(writeSize/8); i++)
575 writeBuffer[idx++] = 'A';
576 writeBuffer[idx++] = 'B';
577 writeBuffer[idx++] = 'C';
578 writeBuffer[idx++] = ' ';
579 writeBuffer[idx++] = 'D';
580 writeBuffer[idx++] = 'E';
581 writeBuffer[idx++] = 'F';
582 writeBuffer[idx++] = ' ';
585 fd = open("/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDBWrite.db",
586 O_CREAT|O_RDWR|O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
589 // open ------------------------------------------------------------
590 fd = pclFileOpen(0xFF, "media/mediaDB.db", 1, 1);
591 x_fail_unless(fd != -1, "Could not open file ==> /media/mediaDB.db");
593 size = pclFileGetSize(fd);
594 x_fail_unless(size == 68, "Wrong file size");
596 size = pclFileReadData(fd, buffer, READ_SIZE);
597 x_fail_unless(strncmp((char*)buffer, refBuffer, strlen(refBuffer)) == 0, "Buffer not correctly read => media/mediaDB.db");
598 x_fail_unless(size == (strlen(refBuffer)+1), "Wrong size returned"); // strlen + 1 ==> inlcude cr/lf
601 ret = pclFileClose(fd);
602 x_fail_unless(ret == 0, "Failed to close file");
604 // open ------------------------------------------------------------
605 fd = pclFileOpen(0xFF, "media/mediaDBWrite.db", 1, 1);
606 x_fail_unless(fd != -1, "Could not open file ==> /media/mediaDBWrite.db");
608 size = pclFileWriteData(fd, writeBuffer, strlen(writeBuffer));
609 x_fail_unless(size == strlen(writeBuffer), "Failed to write data");
611 ret = pclFileClose(fd);
612 x_fail_unless(ret == 0, "Failed to close file");
615 // remove ----------------------------------------------------------
616 ret = pclFileRemove(0xFF, "media/mediaDBWrite.db", 1, 1);
617 x_fail_unless(ret == 0, "File can't be removed ==> /media/mediaDBWrite.db");
619 fd = open("/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDBWrite.db",O_RDWR);
620 x_fail_unless(fd == -1, "Failed to remove file, file still exists");
624 // map file --------------------------------------------------------
625 fd = pclFileOpen(0xFF, "media/mediaDB.db", 1, 1);
627 size = pclFileGetSize(fd);
628 pclFileMapData(fileMap, size, 0, fd);
629 x_fail_unless(fileMap != MAP_FAILED, "Failed to map file");
631 ret = pclFileUnmapData(fileMap, size);
632 x_fail_unless(ret != -1, "Failed to unmap file");
635 size = pclFileGetSize(1024);
636 x_fail_unless(ret == 0, "Got size, but should not");
638 ret = pclFileClose(fd);
639 x_fail_unless(ret == 0, "Failed to close file");
651 START_TEST(test_DataFileRecovery)
653 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
654 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
655 X_TEST_REPORT_REFERENCE("NONE");
656 X_TEST_REPORT_DESCRIPTION("Test of data file recovery");
657 X_TEST_REPORT_TYPE(GOOD);
659 int fd_RW = 0, fd_RO = 0;
661 char* wBuffer = "This is a buffer to write";
662 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
664 ret = pclInitLibrary(gTheAppId, shutdownReg);
665 x_fail_unless(ret <= 1, "Failed to init PCL");
668 // test backup creation --------------------------------------------
669 fd_RO = pclFileOpen(0xFF, "media/mediaDB_ReadOnly.db", 1, 1);
670 x_fail_unless(fd_RO != -1, "Could not open file ==> /media/mediaDB_ReadOnly.db");
672 fd_RW = pclFileOpen(0xFF, "media/mediaDB_ReadWrite.db", 1, 1);
673 x_fail_unless(fd_RW != -1, "Could not open file ==> /media/mediaDB_ReadWrite.db");
674 pclFileWriteData(fd_RW, wBuffer, strlen(wBuffer));
676 ret = pclFileClose(fd_RW);
679 ret = pclFileClose(fd_RO);
688 * The the handle function of the key and file interface.
690 START_TEST(test_DataHandle)
692 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
693 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
694 X_TEST_REPORT_REFERENCE("NONE");
695 X_TEST_REPORT_DESCRIPTION("Test of data handle");
696 X_TEST_REPORT_TYPE(GOOD);
698 int handle1 = 0, handle2 = 0, size = 0;
699 int handleArray[4] = {0};
701 unsigned char buffer[READ_SIZE] = {0};
702 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
704 ret = pclInitLibrary(gTheAppId, shutdownReg);
705 x_fail_unless(ret <= 1, "Failed to init PCL");
708 handle1 = pclFileOpen(0xFF, "media/mediaDB.db", 1, 1);
709 x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB.db");
711 ret = pclFileClose(handle1);
712 x_fail_unless(handle1 != -1, "Could not closefile ==> /media/mediaDB.db");
714 ret = pclFileClose(1024);
715 x_fail_unless(ret == EPERS_MAXHANDLE, "Could close file, but should not!!");
717 ret = pclFileClose(17);
718 x_fail_unless(ret == -1, "Could close file, but should not!!");
720 // test multiple handles
721 handleArray[0] = pclFileOpen(0xFF, "media/mediaDB_write_01.db", 1, 1);
722 x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_01.db");
724 handleArray[1] = pclFileOpen(0xFF, "media/mediaDB_write_02.db", 1, 1);
725 x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_02.db");
727 handleArray[2] = pclFileOpen(0xFF, "media/mediaDB_write_03.db", 1, 1);
728 x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_03.db");
730 handleArray[3] = pclFileOpen(0xFF, "media/mediaDB_write_04.db", 1, 1);
731 x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_04.db");
733 size = pclFileReadData(handleArray[0], buffer, READ_SIZE);
734 x_fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_01.db",
735 strlen("/user/1/seat/1/media/mediaDB_write_01.db"))
736 == 0, "Buffer not correctly read => mediaDB_write_01.db");
738 size = pclFileReadData(handleArray[1], buffer, READ_SIZE);
739 x_fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_02.db",
740 strlen("/user/1/seat/1/media/mediaDB_write_02.db"))
741 == 0, "Buffer not correctly read => mediaDB_write_02.db");
743 size = pclFileReadData(handleArray[2], buffer, READ_SIZE);
744 x_fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_03.db",
745 strlen("/user/1/seat/1/media/mediaDB_write_03.db"))
746 == 0, "Buffer not correctly read => mediaDB_write_03.db");
748 size = pclFileReadData(handleArray[3], buffer, READ_SIZE);
749 x_fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_04.db",
750 strlen("/user/1/seat/1/media/mediaDB_write_04.db"))
751 == 0, "Buffer not correctly read => mediaDB_write_04.db");
753 ret = pclKeyHandleClose(handleArray[0]);
754 x_fail_unless(ret != -1, "Failed to close handle idx \"0\"!!");
756 ret = pclKeyHandleClose(handleArray[1]);
757 x_fail_unless(ret != -1, "Failed to close handle idx \"1\"!!");
759 ret = pclKeyHandleClose(handleArray[2]);
760 x_fail_unless(ret != -1, "Failed to close handle idx \"2\"!!");
762 ret = pclKeyHandleClose(handleArray[3]);
763 x_fail_unless(ret != -1, "Failed to close handle idx \"3\"!!");
766 handle2 = pclKeyHandleOpen(0xFF, "statusHandle/open_document", 3, 2);
767 x_fail_unless(handle2 >= 0, "Failed to open handle /statusHandle/open_document");
769 ret = pclKeyHandleClose(handle2);
770 x_fail_unless(ret != -1, "Failed to close handle!!");
772 ret = pclKeyHandleClose(1024);
773 x_fail_unless(ret == EPERS_MAXHANDLE, "Max handle!!");
782 * Extended key handle test.
783 * Test have been created after a bug in the key handle function occured.
785 START_TEST(test_DataHandleOpen)
787 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
788 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
789 X_TEST_REPORT_REFERENCE("NONE");
790 X_TEST_REPORT_DESCRIPTION("Test of data handle open");
791 X_TEST_REPORT_TYPE(GOOD);
793 int hd1 = -2, hd2 = -2, hd3 = -2, hd4 = -2, hd5 = -2, hd6 = -2, hd7 = -2, hd8 = -2, hd9 = -2, ret = 0;
794 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
796 ret = pclInitLibrary(gTheAppId, shutdownReg);
797 x_fail_unless(ret <= 1, "Failed to init PCL");
799 // open handles ----------------------------------------------------
800 hd1 = pclKeyHandleOpen(0xFF, "posHandle/last_position1", 0, 0);
801 x_fail_unless(hd1 == 1, "Failed to open handle ==> /posHandle/last_position1");
803 hd2 = pclKeyHandleOpen(0xFF, "posHandle/last_position2", 0, 0);
804 x_fail_unless(hd2 == 2, "Failed to open handle ==> /posHandle/last_position2");
806 hd3 = pclKeyHandleOpen(0xFF, "posHandle/last_position3", 0, 0);
807 x_fail_unless(hd3 == 3, "Failed to open handle ==> /posHandle/last_position3");
809 // close handles ---------------------------------------------------
810 ret = pclKeyHandleClose(hd1);
811 x_fail_unless(ret != -1, "Failed to close handle!!");
813 ret = pclKeyHandleClose(hd2);
814 x_fail_unless(ret != -1, "Failed to close handle!!");
816 ret = pclKeyHandleClose(hd3);
817 x_fail_unless(ret != -1, "Failed to close handle!!");
819 // open handles ----------------------------------------------------
820 hd4 = pclKeyHandleOpen(0xFF, "posHandle/last_position4", 0, 0);
821 x_fail_unless(hd4 == 3, "Failed to open handle ==> /posHandle/last_position4");
823 hd5 = pclKeyHandleOpen(0xFF, "posHandle/last_position5", 0, 0);
824 x_fail_unless(hd5 == 2, "Failed to open handle ==> /posHandle/last_position5");
826 hd6 = pclKeyHandleOpen(0xFF, "posHandle/last_position6", 0, 0);
827 x_fail_unless(hd6 == 1, "Failed to open handle ==> /posHandle/last_position6");
829 hd7 = pclKeyHandleOpen(0xFF, "posHandle/last_position7", 0, 0);
830 x_fail_unless(hd7 == 4, "Failed to open handle ==> /posHandle/last_position7");
832 hd8 = pclKeyHandleOpen(0xFF, "posHandle/last_position8", 0, 0);
833 x_fail_unless(hd8 == 5, "Failed to open handle ==> /posHandle/last_position8");
835 hd9 = pclKeyHandleOpen(0xFF, "posHandle/last_position9", 0, 0);
836 x_fail_unless(hd9 == 6, "Failed to open handle ==> /posHandle/last_position9");
838 // close handles ---------------------------------------------------
839 ret = pclKeyHandleClose(hd4);
840 x_fail_unless(ret != -1, "Failed to close handle!!");
842 ret = pclKeyHandleClose(hd5);
843 x_fail_unless(ret != -1, "Failed to close handle!!");
845 ret = pclKeyHandleClose(hd6);
846 x_fail_unless(ret != -1, "Failed to close handle!!");
848 ret = pclKeyHandleClose(hd7);
849 x_fail_unless(ret != -1, "Failed to close handle!!");
851 ret = pclKeyHandleClose(hd8);
852 x_fail_unless(ret != -1, "Failed to close handle!!");
854 ret = pclKeyHandleClose(hd9);
855 x_fail_unless(ret != -1, "Failed to close handle!!");
864 * Test for i n t e r n a l structures.
865 * Test the cursor functions.
867 START_TEST(test_Cursor)
869 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
870 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
871 X_TEST_REPORT_REFERENCE("NONE");
872 X_TEST_REPORT_DESCRIPTION("Test of cursor");
873 X_TEST_REPORT_TYPE(GOOD);
875 int handle = -1, rval = 0, size = 0, handle1 = 0;
876 char bufferKeySrc[READ_SIZE] = {0};
877 char bufferDataSrc[READ_SIZE] = {0};
878 char bufferKeyDst[READ_SIZE] = {0};
879 char bufferDataDst[READ_SIZE] = {0};
880 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
882 rval = pclInitLibrary(gTheAppId, shutdownReg);
883 x_fail_unless(rval <= 1, "Failed to init PCL");
886 handle = pers_db_cursor_create("/Data/mnt-c/lt-persistence_client_library_test/cached.itz");
887 x_fail_unless(handle != -1, "Failed to create cursor!!");
890 handle1 = pers_db_cursor_create("/Data/mnt-wt/lt-persistence_client_library_test/wt.itz");
891 x_fail_unless(handle1 != -1, "Failed to create cursor!!");
895 memset(bufferKeySrc, 0, READ_SIZE);
896 memset(bufferDataSrc, 0, READ_SIZE);
897 memset(bufferKeyDst, 0, READ_SIZE);
898 memset(bufferDataDst, 0, READ_SIZE);
901 rval = pers_db_cursor_get_key(handle, bufferKeySrc, 256);
902 x_fail_unless(rval != -1, "Cursor failed to get key!!");
904 rval = pers_db_cursor_get_data(handle, bufferDataSrc, 256);
906 x_fail_unless(rval != -1, "Cursor failed to get data!!");
908 size = pers_db_cursor_get_data_size(handle);
909 x_fail_unless(size != -1, "Cursor failed to get size!!");
910 //printf("1. Key: %s | Data: %s » Size: %d \n", bufferKeySrc, bufferDataSrc, size);
913 rval = pers_db_cursor_get_key(handle1, bufferKeyDst, 256);
914 x_fail_unless(rval != -1, "Cursor failed to get key!!");
916 rval = pers_db_cursor_get_data(handle1, bufferDataDst, 256);
917 x_fail_unless(rval != -1, "Cursor failed to get data!!");
919 size = pers_db_cursor_get_data_size(handle1);
920 x_fail_unless(size != -1, "Cursor failed to get size!!");
921 //printf(" 2. Key: %s | Data: %s » Size: %d \n", bufferKeyDst, bufferDataDst, size);
923 while( (pers_db_cursor_next(handle) == 0) && (pers_db_cursor_next(handle1) == 0) ); // next cursor
926 rval = pers_db_cursor_destroy(handle);
927 x_fail_unless(rval != -1, "Failed to destroy cursor!!");
929 rval = pers_db_cursor_destroy(handle1);
930 x_fail_unless(rval != -1, "Failed to destroy cursor!!");
938 START_TEST(test_Plugin)
940 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
941 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
942 X_TEST_REPORT_REFERENCE("NONE");
943 X_TEST_REPORT_DESCRIPTION("Test of plugins");
944 X_TEST_REPORT_TYPE(GOOD);
947 unsigned char buffer[READ_SIZE] = {0};
949 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
951 ret = pclInitLibrary(gTheAppId, shutdownReg);
952 x_fail_unless(ret <= 1, "Failed to init PCL");
954 ret = pclKeyReadData(0xFF, "language/country_code", 0, 0, buffer, READ_SIZE);
955 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
956 x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: secure!",
957 strlen((char*)buffer)) == 0, "Buffer SECURE not correctly read");
960 ret = pclKeyReadData(0xFF, "language/country_code_early", 0, 0, buffer, READ_SIZE);
961 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
962 //printf("B U F F E R - early: %s\n", buffer);
963 x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: early!",
964 strlen((char*)buffer)) == 0, "Buffer EARLY not correctly read");
966 ret = pclKeyReadData(0xFF, "language/country_code_emergency", 0, 0, buffer, READ_SIZE);
967 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
968 //printf("B U F F E R - emergency: %s\n", buffer);
969 x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: emergency!",
970 strlen((char*)buffer)) == 0, "Buffer EMERGENCY not correctly read");
972 ret = pclKeyReadData(0xFF, "language/info", 0, 0, buffer, READ_SIZE);
973 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
974 //printf("B U F F E R - hwinfo: %s\n", buffer);
975 x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: hwinfo!",
976 strlen((char*)buffer)) == 0, "Buffer HWINFO not correctly read");
978 ret = pclKeyReadData(0xFF, "language/country_code_custom3", 0, 0, buffer, READ_SIZE);
979 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
980 //printf("B U F F E R - hwinfo: %s\n", buffer);
981 x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: custom3!",
982 strlen((char*)buffer)) == 0, "Buffer CUSTOM 3 not correctly read");
992 START_TEST(test_ReadDefault)
994 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
995 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
996 X_TEST_REPORT_REFERENCE("NONE");
997 X_TEST_REPORT_DESCRIPTION("Test of read default");
998 X_TEST_REPORT_TYPE(GOOD);
1001 unsigned char buffer[READ_SIZE] = {0};
1003 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
1005 ret = pclInitLibrary(gTheAppId, shutdownReg);
1006 x_fail_unless(ret <= 1, "Failed to init PCL");
1008 ret = pclKeyReadData(0xFF, "statusHandle/default01", 3, 2, buffer, READ_SIZE);
1009 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
1010 //printf("B U F F E R: %s\n", buffer);
1011 x_fail_unless(strncmp((char*)buffer,"DEFAULT_01!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
1013 ret = pclKeyReadData(0xFF, "statusHandle/default02", 3, 2, buffer, READ_SIZE);
1014 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
1015 //printf("B U F F E R: %s\n", buffer);
1016 x_fail_unless(strncmp((char*)buffer,"DEFAULT_02!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
1024 START_TEST(test_ReadConfDefault)
1026 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
1027 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
1028 X_TEST_REPORT_REFERENCE("NONE");
1029 X_TEST_REPORT_DESCRIPTION("Test of configurable default data");
1030 X_TEST_REPORT_TYPE(GOOD);
1033 unsigned char buffer[READ_SIZE] = {0};
1035 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
1037 ret = pclInitLibrary(gTheAppId, shutdownReg);
1038 x_fail_unless(ret <= 1, "Failed to init PCL");
1040 ret = pclKeyReadData(0xFF, "statusHandle/confdefault01", 3, 2, buffer, READ_SIZE);
1041 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
1042 x_fail_unless(strncmp((char*)buffer,"CONF_DEFAULT_01!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
1044 ret = pclKeyReadData(0xFF, "statusHandle/confdefault02", 3, 2, buffer, READ_SIZE);
1045 x_fail_unless(ret != EPERS_NOT_INITIALIZED);
1046 x_fail_unless(strncmp((char*)buffer,"CONF_DEFAULT_02!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
1054 START_TEST(test_GetPath)
1056 X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
1057 X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
1058 X_TEST_REPORT_REFERENCE("NONE");
1059 X_TEST_REPORT_DESCRIPTION("Test of get path");
1060 X_TEST_REPORT_TYPE(GOOD);
1064 const char* thePath = "/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDB_create.db";
1065 unsigned int pathSize = 0;
1067 unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
1069 ret = pclInitLibrary(gTheAppId, shutdownReg);
1070 x_fail_unless(ret <= 1, "Failed to init PCL");
1072 ret = pclFileCreatePath(0xFF, "media/mediaDB_create.db", 1, 1, &path, &pathSize);
1073 x_fail_unless(strncmp((char*)path, thePath, strlen((char*)path)) == 0, "Path not correct");
1074 x_fail_unless(pathSize == strlen((char*)path), "Path size not correct");
1076 pclFileReleasePath(ret);
1083 static Suite * persistencyClientLib_suite()
1085 Suite * s = suite_create("Persistency client library");
1087 TCase * tc_persGetData = tcase_create("GetData");
1088 tcase_add_test(tc_persGetData, test_GetData);
1090 TCase * tc_persSetData = tcase_create("SetData");
1091 tcase_add_test(tc_persSetData, test_SetData);
1093 TCase * tc_persSetDataNoPRCT = tcase_create("SetDataNoPRCT");
1094 tcase_add_test(tc_persSetDataNoPRCT, test_SetDataNoPRCT);
1096 TCase * tc_persGetDataSize = tcase_create("GetDataSize");
1097 tcase_add_test(tc_persGetDataSize, test_GetDataSize);
1099 TCase * tc_persDeleteData = tcase_create("DeleteData");
1100 tcase_add_test(tc_persDeleteData, test_DeleteData);
1102 TCase * tc_persGetDataHandle = tcase_create("GetDataHandle");
1103 tcase_add_test(tc_persGetDataHandle, test_GetDataHandle);
1105 TCase * tc_persDataHandle = tcase_create("DataHandle");
1106 tcase_add_test(tc_persDataHandle, test_DataHandle);
1108 TCase * tc_persDataHandleOpen = tcase_create("DataHandleOpen");
1109 tcase_add_test(tc_persDataHandleOpen, test_DataHandleOpen);
1111 TCase * tc_persDataFile = tcase_create("DataFile");
1112 tcase_add_test(tc_persDataFile, test_DataFile);
1114 TCase * tc_persDataFileRecovery = tcase_create("DataFileRecovery");
1115 tcase_add_test(tc_persDataFileRecovery, test_DataFileRecovery);
1117 TCase * tc_Cursor = tcase_create("Cursor");
1118 tcase_add_test(tc_Cursor, test_Cursor);
1120 TCase * tc_Plugin = tcase_create("Plugin");
1121 tcase_add_test(tc_Plugin, test_Plugin);
1123 TCase * tc_ReadDefault = tcase_create("ReadDefault");
1124 tcase_add_test(tc_ReadDefault, test_ReadDefault);
1126 TCase * tc_ReadConfDefault = tcase_create("ReadConfDefault");
1127 tcase_add_test(tc_ReadConfDefault, test_ReadConfDefault);
1129 TCase * tc_GetPath = tcase_create("GetPath");
1130 tcase_add_test(tc_GetPath, test_GetPath);
1132 suite_add_tcase(s, tc_persSetData);
1133 suite_add_tcase(s, tc_persGetData);
1134 suite_add_tcase(s, tc_persSetDataNoPRCT);
1135 suite_add_tcase(s, tc_persGetDataSize);
1136 suite_add_tcase(s, tc_persDeleteData);
1137 suite_add_tcase(s, tc_persGetDataHandle);
1138 suite_add_tcase(s, tc_persDataHandle);
1139 suite_add_tcase(s, tc_persDataHandleOpen);
1140 suite_add_tcase(s, tc_persDataFile);
1141 suite_add_tcase(s, tc_persDataFileRecovery);
1142 suite_add_tcase(s, tc_Cursor);
1143 suite_add_tcase(s, tc_ReadDefault);
1144 suite_add_tcase(s, tc_ReadConfDefault);
1145 suite_add_tcase(s, tc_GetPath);
1146 //suite_add_tcase(s, tc_Plugin); // activate only if the plugins are available
1151 int main(int argc, char *argv[])
1158 TestResult** tResult;
1160 // assign application name
1161 strncpy(gTheAppId, "lt-persistence_client_library_test", MaxAppNameLen);
1162 gTheAppId[MaxAppNameLen-1] = '\0';
1164 /// debug log and trace (DLT) setup
1165 DLT_REGISTER_APP("test","tests the persistence client library");
1168 Suite * s = persistencyClientLib_suite();
1169 SRunner * sr = srunner_create(s);
1170 srunner_set_xml(sr, "/tmp/persistenceClientLibraryTest.xml");
1171 srunner_set_log(sr, "/tmp/persistenceClientLibraryTest.log");
1172 srunner_run_all(sr, /*CK_NORMAL*/ CK_VERBOSE);
1174 nr_failed = srunner_ntests_failed(sr);
1175 nr_run = srunner_ntests_run(sr);
1177 tResult = srunner_results(sr);
1178 for(i = 0; i< nr_run; i++)
1180 fail = tr_rtype(tResult[i]); // get status of each test
1181 //printf("[%d] Fail: %d \n", i, fail);
1187 // unregister debug log and trace
1188 DLT_UNREGISTER_APP();
1192 return (0==nr_failed)?EXIT_SUCCESS:EXIT_FAILURE;