Fixed PCL bugs: 137, 138, 141
[profile/ivi/persistence-client-library.git] / test / persistence_client_library_test.c
1 /******************************************************************************
2  * Project         Persistency
3  * (c) copyright   2012
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 ******************************************************************************/
11  /**
12  * @file           persistence_client_library_test.c
13  * @ingroup        Persistence client library test
14  * @author         Ingo Huerner
15  * @brief          Test of persistence client library
16  * @see            
17  */
18
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include <errno.h>
23 #include <unistd.h>     /* exit */
24 #include <check.h>
25 #include <time.h>
26 #include <fcntl.h>
27 #include <sys/mman.h>
28
29 #include <dlt/dlt.h>
30 #include <dlt/dlt_common.h>
31
32 #include "../include/persistence_client_library_file.h"
33 #include "../include/persistence_client_library_key.h"
34 #include "../include/persistence_client_library.h"
35
36
37 // protected header, should be used only be persistence components
38 // included here for testing purpose
39 #include "../include_protected/persistence_client_library_db_access.h"
40
41
42 #define BUF_SIZE     64
43 #define NUM_OF_FILES 3
44 #define READ_SIZE    1024
45
46 /// application id
47 char gTheAppId[MaxAppNameLen] = {0};
48
49 // definition of weekday
50 char* dayOfWeek[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
51
52
53
54 /**
55  * Test the key value interface using different logicalDB id's, users and seats.
56  * Each resource below has an entry in the resource configuration table where the
57  * storage location (cached or write through) and type (e.g. custom) has been configured.
58  */
59 START_TEST (test_GetData)
60 {
61    int ret = 0;
62    unsigned int shutdownReg = (PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL);
63
64    unsigned char buffer[READ_SIZE] = {0};
65
66    ret = pclInitLibrary(gTheAppId, shutdownReg);
67    fail_unless(ret <= 1, "Failed to init PCL");
68
69 #if 1
70    /**
71     * Logical DB ID: 0xFF with user 0 and seat 0
72     *       ==> local value accessible by all users (user 0, seat 0)
73     */
74    ret = pclKeyReadData(0xFF, "pos/last_position",         0, 0, buffer, READ_SIZE);
75    fail_unless(strncmp((char*)buffer, "CACHE_ +48° 10' 38.95\", +8° 44' 39.06\"",
76                strlen((char*)buffer)) == 0, "Buffer not correctly read");
77    fail_unless(ret = strlen("CACHE_ +48° 10' 38.95\", +8° 44' 39.06\""));
78
79    memset(buffer, 0, READ_SIZE);
80
81    /**
82     * Logical DB ID: 0xFF with user 0 and seat 0
83     *       ==> local value accessible by all users (user 0, seat 0)
84     */
85    ret = pclKeyReadData(0xFF, "language/country_code",         0, 0, buffer, READ_SIZE);
86    fail_unless(strncmp((char*)buffer, "Custom plugin -> plugin_get_data: secure!",
87                strlen((char*)buffer)) == 0, "Buffer not correctly read");
88    fail_unless(ret = strlen("Custom plugin -> plugin_get_data_handle"));
89
90    memset(buffer, 0, READ_SIZE);
91
92
93    /**
94     * Logical DB ID: 0 with user 3 and seat 0
95     *       ==> public shared user value (user 3, seat 0)
96     */
97    ret = pclKeyReadData(0,    "language/current_language", 3, 0, buffer, READ_SIZE);
98    fail_unless(strncmp((char*)buffer, "CACHE_ Kisuaheli", strlen((char*)buffer)) == 0, "Buffer not correctly read");
99
100    memset(buffer, 0, READ_SIZE);
101
102    /**
103     * Logical DB ID: 0xFF with user 3 and seat 2
104     *       ==> local USER value (user 3, seat 2)
105     */
106    ret = pclKeyReadData(0xFF, "status/open_document",      3, 2, buffer, READ_SIZE);
107    fail_unless(strncmp((char*)buffer, "WT_ /var/opt/user_manual_climateControl.pdf", strlen((char*)buffer)) == 0, "Buffer not correctly read");
108
109    memset(buffer, 0, READ_SIZE);
110
111    /**
112     * Logical DB ID: 0x20 with user 4 and seat 0
113     *       ==> shared user value accessible by a group (user 4 and seat 0)
114     */
115    ret = pclKeyReadData(0x20, "address/home_address",      4, 0, buffer, READ_SIZE);
116    fail_unless(strncmp((char*)buffer, "WT_ 55327 Heimatstadt, Wohnstrasse 31", strlen((char*)buffer)) == 0, "Buffer not correctly read");
117
118    memset(buffer, 0, READ_SIZE);
119
120    /**
121     * Logical DB ID: 0xFF with user 0 and seat 0
122     *       ==> local value accessible by ALL USERS (user 0, seat 0)
123     */
124    ret = pclKeyReadData(0xFF, "pos/last_satellites",       0, 0, buffer, READ_SIZE);
125    fail_unless(strncmp((char*)buffer, "WT_ 17", strlen((char*)buffer)) == 0, "Buffer not correctly read");
126
127    memset(buffer, 0, READ_SIZE);
128
129    /**
130     * Logical DB ID: 0x84 with user 4 and seat 0
131     *       ==> shared user value accessible by A GROUP (user 4 and seat 0)
132     */
133    ret = pclKeyReadData(0x84, "links/last_link",           2, 0, buffer, READ_SIZE);
134    fail_unless(strncmp((char*)buffer, "CACHE_ /last_exit/brooklyn", strlen((char*)buffer)) == 0, "Buffer not correctly read");
135
136    memset(buffer, 0, READ_SIZE);
137
138    /**
139     * Logical DB ID: 0x84 with user 2 and seat 1
140     *       ==> local merge value
141     */
142    ret = pclKeyReadData(0x84, "links/last_link",           2, 1, buffer, READ_SIZE);
143    fail_unless(strncmp((char*)buffer, "CACHE_ /last_exit/queens", strlen((char*)buffer)) == 0, "Buffer not correctly read");
144 #endif
145    pclDeinitLibrary();
146 }
147 END_TEST
148
149
150
151 /**
152  * Test the key value  h a n d l e  interface using different logicalDB id's, users and seats
153  * Each resource below has an entry in the resource configuration table where
154  * the storage location (cached or write through) and type (e.g. custom) has bee configured.
155  */
156 START_TEST (test_GetDataHandle)
157 {
158    int ret = 0, handle = 0, handle2 = 0, handle3 = 0, handle4 = 0, size = 0;
159    unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
160
161    unsigned char buffer[READ_SIZE] = {0};
162    struct tm *locTime;
163
164    char sysTimeBuffer[128];
165
166    ret = pclInitLibrary(gTheAppId, shutdownReg);
167    fail_unless(ret <= 1, "Failed to init PCL");
168 #if 1
169    time_t t = time(0);
170
171    locTime = localtime(&t);
172
173    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),
174                                                                   locTime->tm_hour, locTime->tm_min, locTime->tm_sec);
175
176
177    // open handle ---------------------------------------------------
178    /**
179     * Logical DB ID: 0xFF with user 0 and seat 0
180     *       ==> local value accessible by ALL USERS (user 0, seat 0)
181     */
182    handle = pclKeyHandleOpen(0xFF, "posHandle/last_position", 0, 0);
183    fail_unless(handle >= 0, "Failed to open handle ==> /posHandle/last_position");
184
185    ret = pclKeyHandleReadData(handle, buffer, READ_SIZE);
186    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");
187
188    size = pclKeyHandleGetSize(handle);
189    fail_unless(size == strlen("WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\""));
190    // ---------------------------------------------------------------------------------------------
191
192
193    // open handle ---------------------------------------------------
194    /**
195     * Logical DB ID: 0xFF with user 3 and seat 2
196     *       ==> local USER value (user 3, seat 2)
197     */
198    handle2 = pclKeyHandleOpen(0xFF, "statusHandle/open_document", 3, 2);
199    fail_unless(handle2 >= 0, "Failed to open handle /statusHandle/open_document");
200
201    size = pclKeyHandleWriteData(handle2, (unsigned char*)sysTimeBuffer, strlen(sysTimeBuffer));
202    fail_unless(size == strlen(sysTimeBuffer));
203    // close
204    ret = pclKeyHandleClose(handle2);
205    // ---------------------------------------------------------------------------------------------
206
207
208    // open handle ---------------------------------------------------
209    /**
210     * Logical DB ID: 0xFF with user 0 and seat 0
211     *       ==> local value accessible by ALL USERS (user 0, seat 0)
212     */
213 #if 0 // plugin test case
214    memset(buffer, 0, READ_SIZE);
215    handle4 = pclKeyHandleOpen(0xFF, "language/country_code", 0, 0);
216    printf("H A N D L E: %d\n", handle4);
217    fail_unless(handle4 >= 0, "Failed to open handle /language/country_code");
218
219    ret = pclKeyHandleReadData(handle4, buffer, READ_SIZE);
220    fail_unless(strncmp((char*)buffer, "Custom plugin -> plugin_get_data_handle: secure!", -1) == 0, "Buffer not correctly read => 2");
221
222    size = pclKeyHandleGetSize(handle4);
223    fail_unless(size = strlen("Custom plugin -> plugin_get_data_handle"));
224
225    ret = pclKeyHandleWriteData(handle4, (unsigned char*)"Only dummy implementation behind custom library", READ_SIZE);
226 #endif
227    // ---------------------------------------------------------------------------------------------
228
229
230    // open handle ---------------------------------------------------
231    /**
232     * Logical DB ID: 0xFF with user 3 and seat 2
233     *       ==> local USER value (user 3, seat 2)
234     */
235    handle3 = pclKeyHandleOpen(0xFF, "statusHandle/open_document", 3, 2);
236    fail_unless(handle3 >= 0, "Failed to open handle /statusHandle/open_document");
237
238    ret = pclKeyHandleReadData(handle3, buffer, READ_SIZE);
239    fail_unless(strncmp((char*)buffer, sysTimeBuffer, strlen(sysTimeBuffer)) == 0, "Buffer not correctly read => 3");
240
241    size = pclKeyHandleGetSize(handle3);
242    fail_unless(size = strlen(sysTimeBuffer));
243    // ---------------------------------------------------------------------------------------------
244
245
246    // close handle
247    ret = pclKeyHandleClose(handle);
248    ret = pclKeyHandleClose(handle3);
249    ret = pclKeyHandleClose(handle4);
250 #endif
251    pclDeinitLibrary();
252 }
253 END_TEST
254
255
256 /*
257  * Write data to a key using the key interface.
258  * First write data to different keys and after
259  * read the data for verification.
260  */
261 START_TEST(test_SetData)
262 {
263    int ret = 0;
264    unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
265    unsigned char buffer[READ_SIZE]  = {0};
266    char write1[READ_SIZE] = {0};
267    char write2[READ_SIZE] = {0};
268    char sysTimeBuffer[256];
269
270    struct tm *locTime;
271
272    ret = pclInitLibrary(gTheAppId, shutdownReg);
273    fail_unless(ret <= 1, "Failed to init PCL");
274 #if 1
275    time_t t = time(0);
276
277    locTime = localtime(&t);
278
279    // write data
280    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),
281                                                                  locTime->tm_hour, locTime->tm_min, locTime->tm_sec);
282
283    /**
284     * Logical DB ID: 0xFF with user 1 and seat 2
285     *       ==> local USER value (user 1, seat 2)
286     * Resource ID: 69
287     */
288
289    ret = pclKeyWriteData(0xFF, "69", 1, 2, (unsigned char*)sysTimeBuffer, strlen(sysTimeBuffer));
290    fail_unless(ret == strlen(sysTimeBuffer), "Wrong write size");
291 #if 1
292    snprintf(write1, 128, "%s %s", "/70",  sysTimeBuffer);
293    /**
294     * Logical DB ID: 0xFF with user 1 and seat 2
295     *       ==> local USER value (user 1, seat 2)
296     * Resource ID: 70
297     */
298    ret = pclKeyWriteData(0xFF, "70", 1, 2, (unsigned char*)write1, strlen(write1));
299    fail_unless(ret == strlen(write1), "Wrong write size");
300
301    snprintf(write2, 128, "%s %s", "/key_70",  sysTimeBuffer);
302    /**
303     * Logical DB ID: 0xFF with user 1 and seat 2
304     *       ==> local USER value (user 1, seat 2)
305     * Resource ID: key_70
306     */
307    ret = pclKeyWriteData(0xFF, "key_70", 1, 2, (unsigned char*)write2, strlen(write2));
308    fail_unless(ret == strlen(write2), "Wrong write size");
309
310
311    /*******************************************************************************************************************************************/
312    /* used for changed notification testing */
313    /*******************************************************************************************************************************************/
314    /**
315     * Logical DB ID: 0x84 with user 2 and seat 1
316     *       ==> shared user value accessible by A GROUP (user 2 and seat 1)
317     *
318     *       ==> used for shared testing
319     */
320    //printf("Write data to trigger change notification\n");
321    ret = pclKeyWriteData(0x84, "links/last_link2",  2, 1, (unsigned char*)"Test notify shared data", strlen("Test notify shared data"));
322    fail_unless(ret == strlen("Test notify shared data"), "Wrong write size");
323
324    /**
325     * Logical DB ID: 0x84 with user 2 and seat 1
326     *       ==> shared user value accessible by A GROUP (user 2 and seat 1)
327     *
328     *       ==> used for shared testing
329     */
330    //printf("Write data to trigger change notification\n");
331    ret = pclKeyWriteData(0x84, "links/last_link3",  3, 2, (unsigned char*)"Test notify shared data", strlen("Test notify shared data"));
332    fail_unless(ret == strlen("Test notify shared data"), "Wrong write size");
333
334    /**
335     * Logical DB ID: 0x84 with user 2 and seat 1
336     *       ==> shared user value accessible by A GROUP (user 2 and seat 1)
337     *
338     *       ==> used for shared testing
339     */
340    //printf("Write data to trigger change notification\n");
341    ret = pclKeyWriteData(0x84, "links/last_link4",  4, 1, (unsigned char*)"Test notify shared data", strlen("Test notify shared data"));
342    fail_unless(ret == strlen("Test notify shared data"), "Wrong write size");
343    /*******************************************************************************************************************************************/
344    /*******************************************************************************************************************************************/
345
346
347    /*
348     * now read the data written in the previous steps to the keys
349     * and verify data has been written correctly.
350     */
351    memset(buffer, 0, READ_SIZE);
352
353    ret = pclKeyReadData(0xFF, "69", 1, 2, buffer, READ_SIZE);
354    fail_unless(strncmp((char*)buffer, sysTimeBuffer, strlen(sysTimeBuffer)) == 0, "Buffer not correctly read");
355    fail_unless(ret == strlen(sysTimeBuffer), "Wrong read size");
356
357    memset(buffer, 0, READ_SIZE);
358
359    ret = pclKeyReadData(0xFF, "70", 1, 2, buffer, READ_SIZE);
360    fail_unless(strncmp((char*)buffer, write1, strlen(write1)) == 0, "Buffer not correctly read");
361    fail_unless(ret == strlen(write1), "Wrong read size");
362
363    memset(buffer, 0, READ_SIZE);
364
365    ret = pclKeyReadData(0xFF, "key_70", 1, 2, buffer, READ_SIZE);
366    fail_unless(strncmp((char*)buffer, write2, strlen(write2)) == 0, "Buffer not correctly read");
367    fail_unless(ret == strlen(write2), "Wrong read size");
368 #endif
369 #endif
370    pclDeinitLibrary();
371 }
372 END_TEST
373
374
375
376 /**
377  * Write data to a key using the key interface.
378  * The key is not in the persistence resource table.
379  * The key sill then be stored to the location local and cached.
380  */
381 START_TEST(test_SetDataNoPRCT)
382 {
383    int ret = 0;
384    unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
385    unsigned char buffer[READ_SIZE] = {0};
386    struct tm *locTime;
387
388    ret = pclInitLibrary(gTheAppId, shutdownReg);
389    fail_unless(ret <= 1, "Failed to init PCL");
390 #if 1
391    time_t t = time(0);
392
393    char sysTimeBuffer[128];
394
395    locTime = localtime(&t);
396
397    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),
398                                                                   locTime->tm_hour, locTime->tm_min, locTime->tm_sec);
399
400    /**
401     * Logical DB ID: 0xFF with user 1 and seat 2
402     *       ==> local USER value (user 1, seat 2)
403     */
404    ret = pclKeyWriteData(0xFF, "NoPRCT", 1, 2, (unsigned char*)sysTimeBuffer, strlen(sysTimeBuffer));
405    fail_unless(ret == strlen(sysTimeBuffer), "Wrong write size");
406    //printf("Write Buffer : %s\n", sysTimeBuffer);
407
408    // read data again and and verify datat has been written correctly
409    memset(buffer, 0, READ_SIZE);
410
411    ret = pclKeyReadData(0xFF, "NoPRCT", 1, 2, buffer, READ_SIZE);
412    fail_unless(strncmp((char*)buffer, sysTimeBuffer, strlen(sysTimeBuffer)) == 0, "Buffer not correctly read");
413    fail_unless(ret == strlen(sysTimeBuffer), "Wrong read size");
414    //printf("read buffer  : %s\n", buffer);
415 #endif
416    pclDeinitLibrary();
417 }
418 END_TEST
419
420
421
422 /*
423  * Test the key interface.
424  * Read the size of a key.
425  */
426 START_TEST(test_GetDataSize)
427 {
428    int size = 0, ret = 0;
429
430    unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
431
432    ret = pclInitLibrary(gTheAppId, shutdownReg);
433    fail_unless(ret <= 1, "Failed to init PCL");
434 #if 1
435    /**
436     * Logical DB ID: 0xFF with user 3 and seat 2
437     *       ==> local USER value (user 3, seat 2)
438     */
439    size = pclKeyGetSize(0xFF, "status/open_document", 3, 2);
440    fail_unless(size == strlen("WT_ /var/opt/user_manual_climateControl.pdf"), "Invalid size");
441
442
443    /**
444     * Logical DB ID: 0x84 with user 2 and seat 1
445     *       ==> shared user value accessible by A GROUP (user 2 and seat 1)
446     */
447    size = pclKeyGetSize(0x84, "links/last_link", 2, 1);
448    fail_unless(size == strlen("CACHE_ /last_exit/queens"), "Invalid size");
449 #endif
450    pclDeinitLibrary();
451 }
452 END_TEST
453
454
455 /*
456  * Delete a key using the key value interface.
457  * First read a from a key, the delte the key
458  * and then try to read again. The Last read must fail.
459  */
460 START_TEST(test_DeleteData)
461 {
462    int rval = 0;
463    unsigned char buffer[READ_SIZE];
464    unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
465
466    rval = pclInitLibrary(gTheAppId, shutdownReg);
467    fail_unless(rval <= 1, "Failed to init PCL");
468 #if 1
469    // read data from key
470    rval = pclKeyReadData(0xFF, "key_70", 1, 2, buffer, READ_SIZE);
471    fail_unless(rval != EPERS_NOKEY, "Read form key key_70 fails");
472
473    // delete key
474    rval = pclKeyDelete(0xFF, "key_70", 1, 2);
475    fail_unless(rval == 0, "Failed to delete key");
476
477    // after deleting the key, reading from key must fail now!
478    rval = pclKeyReadData(0xFF, "key_70", 1, 2, buffer, READ_SIZE);
479    fail_unless(rval == EPERS_NOKEY, "Read form key key_70 works, but should fail");
480
481
482
483    // read data from key
484    rval = pclKeyReadData(0xFF, "70", 1, 2, buffer, READ_SIZE);
485    fail_unless(rval != EPERS_NOKEY, "Read form key 70 fails");
486
487    // delete key
488    rval = pclKeyDelete(0xFF, "70", 1, 2);
489    fail_unless(rval == 0, "Failed to delete key");
490
491    // after deleting the key, reading from key must fail now!
492    rval = pclKeyReadData(0xFF, "70", 1, 2, buffer, READ_SIZE);
493    fail_unless(rval == EPERS_NOKEY, "Read form key 70 works, but should fail");
494 #endif
495    pclDeinitLibrary();
496 }
497 END_TEST
498
499
500
501 /*
502  * Test the file interface:
503  * - open file
504  * - read / write
505  * - remove file
506  * - map file
507  * - get size
508  */
509 START_TEST(test_DataFile)
510 {
511    int fd = 0, i = 0, idx = 0;
512    int size = 0, ret = 0;
513    int writeSize = 16*1024;
514    unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
515
516    unsigned char buffer[READ_SIZE] = {0};
517    const char* refBuffer = "/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media";
518    char* writeBuffer;
519    char* fileMap = NULL;
520
521    ret = pclInitLibrary(gTheAppId, shutdownReg);
522    fail_unless(ret <= 1, "Failed to init PCL");
523 #if 1
524    writeBuffer = malloc(writeSize);
525
526
527    // fill buffer a sequence
528    for(i = 0; i<(writeSize/8); i++)
529    {
530       writeBuffer[idx++] = 'A';
531       writeBuffer[idx++] = 'B';
532       writeBuffer[idx++] = 'C';
533       writeBuffer[idx++] = ' ';
534       writeBuffer[idx++] = 'D';
535       writeBuffer[idx++] = 'E';
536       writeBuffer[idx++] = 'F';
537       writeBuffer[idx++] = ' ';
538    }
539    // create file
540    fd = open("/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDBWrite.db",
541              O_CREAT|O_RDWR|O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
542    close(fd);
543
544    // open ------------------------------------------------------------
545    fd = pclFileOpen(0xFF, "media/mediaDB.db", 1, 1);
546    fail_unless(fd != -1, "Could not open file ==> /media/mediaDB.db");
547
548    size = pclFileGetSize(fd);
549    fail_unless(size == 68, "Wrong file size");
550
551    size = pclFileReadData(fd, buffer, READ_SIZE);
552    fail_unless(strncmp((char*)buffer, refBuffer, strlen(refBuffer)) == 0, "Buffer not correctly read => media/mediaDB.db");
553    fail_unless(size == (strlen(refBuffer)+1), "Wrong size returned");      // strlen + 1 ==> inlcude cr/lf
554
555
556    ret = pclFileClose(fd);
557    fail_unless(ret == 0, "Failed to close file");
558
559    // open ------------------------------------------------------------
560    fd = pclFileOpen(0xFF, "media/mediaDBWrite.db", 1, 1);
561    fail_unless(fd != -1, "Could not open file ==> /media/mediaDBWrite.db");
562
563    size = pclFileWriteData(fd, writeBuffer, strlen(writeBuffer));
564    fail_unless(size == strlen(writeBuffer), "Failed to write data");
565
566    ret = pclFileClose(fd);
567    fail_unless(ret == 0, "Failed to close file");
568
569
570    // remove ----------------------------------------------------------
571    ret = pclFileRemove(0xFF, "media/mediaDBWrite.db", 1, 1);
572    fail_unless(ret == 0, "File can't be removed ==> /media/mediaDBWrite.db");
573
574    fd = open("/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDBWrite.db",O_RDWR);
575    fail_unless(fd == -1, "Failed to remove file, file still exists");
576    close(fd);
577
578
579    // map file --------------------------------------------------------
580    fd = pclFileOpen(0xFF, "media/mediaDB.db", 1, 1);
581
582    size = pclFileGetSize(fd);
583    pclFileMapData(fileMap, size, 0, fd);
584    fail_unless(fileMap != MAP_FAILED, "Failed to map file");
585
586    ret = pclFileUnmapData(fileMap, size);
587    fail_unless(ret != -1, "Failed to unmap file");
588
589    // negative test
590    size = pclFileGetSize(1024);
591    fail_unless(ret == 0, "Got size, but should not");
592
593    ret = pclFileClose(fd);
594    fail_unless(ret == 0, "Failed to close file");
595
596    free(writeBuffer);
597 #endif
598    pclDeinitLibrary();
599 }
600 END_TEST
601
602
603
604
605
606 START_TEST(test_DataFileRecovery)
607 {
608    int fd_RW = 0, fd_RO = 0;
609    int ret = 0;
610    char* wBuffer = "This is a buffer to write";
611    unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
612
613    ret = pclInitLibrary(gTheAppId, shutdownReg);
614    fail_unless(ret <= 1, "Failed to init PCL");
615 #if 1
616    // test backup creation --------------------------------------------
617    fd_RO = pclFileOpen(0xFF, "media/mediaDB_ReadOnly.db", 1, 1);
618    fail_unless(fd_RO != -1, "Could not open file ==> /media/mediaDB_ReadOnly.db");
619
620    fd_RW = pclFileOpen(0xFF, "media/mediaDB_ReadWrite.db", 1, 1);
621    fail_unless(fd_RW != -1, "Could not open file ==> /media/mediaDB_ReadWrite.db");
622    pclFileWriteData(fd_RW, wBuffer, strlen(wBuffer));
623
624    ret = pclFileClose(fd_RW);
625    if(ret == -1)
626
627    ret = pclFileClose(fd_RO);
628    if(ret == -1)
629
630 #endif
631    pclDeinitLibrary();
632 }
633 END_TEST
634
635 /*
636  * The the handle function of the key and file interface.
637  */
638 START_TEST(test_DataHandle)
639 {
640    int handle1 = 0, handle2 = 0, size = 0;
641    int handleArray[4] = {0};
642    int ret = 0;
643    unsigned char buffer[READ_SIZE] = {0};
644    unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
645
646    ret = pclInitLibrary(gTheAppId, shutdownReg);
647    fail_unless(ret <= 1, "Failed to init PCL");
648 #if 1
649    // test file handles
650    handle1 = pclFileOpen(0xFF, "media/mediaDB.db", 1, 1);
651    fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB.db");
652
653    ret = pclFileClose(handle1);
654    fail_unless(handle1 != -1, "Could not closefile ==> /media/mediaDB.db");
655
656    ret = pclFileClose(1024);
657    fail_unless(ret == EPERS_MAXHANDLE, "Could close file, but should not!!");
658
659    ret = pclFileClose(17);
660    fail_unless(ret == -1, "Could close file, but should not!!");
661
662    // test multiple handles
663    handleArray[0] = pclFileOpen(0xFF, "media/mediaDB_write_01.db", 1, 1);
664    fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_01.db");
665
666    handleArray[1] = pclFileOpen(0xFF, "media/mediaDB_write_02.db", 1, 1);
667    fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_02.db");
668
669    handleArray[2] = pclFileOpen(0xFF, "media/mediaDB_write_03.db", 1, 1);
670    fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_03.db");
671
672    handleArray[3] = pclFileOpen(0xFF, "media/mediaDB_write_04.db", 1, 1);
673    fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_04.db");
674
675    size = pclFileReadData(handleArray[0], buffer, READ_SIZE);
676    fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_01.db",
677          strlen("/user/1/seat/1/media/mediaDB_write_01.db"))
678          == 0, "Buffer not correctly read => mediaDB_write_01.db");
679
680    size = pclFileReadData(handleArray[1], buffer, READ_SIZE);
681    fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_02.db",
682          strlen("/user/1/seat/1/media/mediaDB_write_02.db"))
683          == 0, "Buffer not correctly read => mediaDB_write_02.db");
684
685    size = pclFileReadData(handleArray[2], buffer, READ_SIZE);
686    fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_03.db",
687          strlen("/user/1/seat/1/media/mediaDB_write_03.db"))
688          == 0, "Buffer not correctly read => mediaDB_write_03.db");
689
690    size = pclFileReadData(handleArray[3], buffer, READ_SIZE);
691    fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_04.db",
692          strlen("/user/1/seat/1/media/mediaDB_write_04.db"))
693          == 0, "Buffer not correctly read => mediaDB_write_04.db");
694
695    ret = pclKeyHandleClose(handleArray[0]);
696    fail_unless(ret != -1, "Failed to close handle idx \"0\"!!");
697
698    ret = pclKeyHandleClose(handleArray[1]);
699    fail_unless(ret != -1, "Failed to close handle idx \"1\"!!");
700
701    ret = pclKeyHandleClose(handleArray[2]);
702    fail_unless(ret != -1, "Failed to close handle idx \"2\"!!");
703
704    ret = pclKeyHandleClose(handleArray[3]);
705    fail_unless(ret != -1, "Failed to close handle idx \"3\"!!");
706
707    // test key handles
708    handle2 = pclKeyHandleOpen(0xFF, "statusHandle/open_document", 3, 2);
709    fail_unless(handle2 >= 0, "Failed to open handle /statusHandle/open_document");
710
711    ret = pclKeyHandleClose(handle2);
712    fail_unless(ret != -1, "Failed to close handle!!");
713
714    ret = pclKeyHandleClose(1024);
715    fail_unless(ret == EPERS_MAXHANDLE, "Max handle!!");
716 #endif
717    pclDeinitLibrary();
718 }
719 END_TEST
720
721
722
723 /*
724  * Extended key handle test.
725  * Test have been created after a bug in the key handle function occured.
726  */
727 START_TEST(test_DataHandleOpen)
728 {
729    int hd1 = -2, hd2 = -2, hd3 = -2, hd4 = -2, hd5 = -2, hd6 = -2, hd7 = -2, hd8 = -2, hd9 = -2, ret = 0;
730    unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
731
732    ret = pclInitLibrary(gTheAppId, shutdownReg);
733    fail_unless(ret <= 1, "Failed to init PCL");
734 #if 1
735    // open handles ----------------------------------------------------
736    hd1 = pclKeyHandleOpen(0xFF, "posHandle/last_position1", 0, 0);
737    fail_unless(hd1 == 1, "Failed to open handle ==> /posHandle/last_position1");
738
739    hd2 = pclKeyHandleOpen(0xFF, "posHandle/last_position2", 0, 0);
740    fail_unless(hd2 == 2, "Failed to open handle ==> /posHandle/last_position2");
741
742    hd3 = pclKeyHandleOpen(0xFF, "posHandle/last_position3", 0, 0);
743    fail_unless(hd3 == 3, "Failed to open handle ==> /posHandle/last_position3");
744
745    // close handles ---------------------------------------------------
746    ret = pclKeyHandleClose(hd1);
747    fail_unless(ret != -1, "Failed to close handle!!");
748
749    ret = pclKeyHandleClose(hd2);
750    fail_unless(ret != -1, "Failed to close handle!!");
751
752    ret = pclKeyHandleClose(hd3);
753    fail_unless(ret != -1, "Failed to close handle!!");
754
755    // open handles ----------------------------------------------------
756    hd4 = pclKeyHandleOpen(0xFF, "posHandle/last_position4", 0, 0);
757    fail_unless(hd4 == 3, "Failed to open handle ==> /posHandle/last_position4");
758
759    hd5 = pclKeyHandleOpen(0xFF, "posHandle/last_position5", 0, 0);
760    fail_unless(hd5 == 2, "Failed to open handle ==> /posHandle/last_position5");
761
762    hd6 = pclKeyHandleOpen(0xFF, "posHandle/last_position6", 0, 0);
763    fail_unless(hd6 == 1, "Failed to open handle ==> /posHandle/last_position6");
764
765    hd7 = pclKeyHandleOpen(0xFF, "posHandle/last_position7", 0, 0);
766    fail_unless(hd7 == 4, "Failed to open handle ==> /posHandle/last_position7");
767
768    hd8 = pclKeyHandleOpen(0xFF, "posHandle/last_position8", 0, 0);
769    fail_unless(hd8 == 5, "Failed to open handle ==> /posHandle/last_position8");
770
771    hd9 = pclKeyHandleOpen(0xFF, "posHandle/last_position9", 0, 0);
772    fail_unless(hd9 == 6, "Failed to open handle ==> /posHandle/last_position9");
773
774    // close handles ---------------------------------------------------
775    ret = pclKeyHandleClose(hd4);
776    fail_unless(ret != -1, "Failed to close handle!!");
777
778    ret = pclKeyHandleClose(hd5);
779    fail_unless(ret != -1, "Failed to close handle!!");
780
781    ret = pclKeyHandleClose(hd6);
782    fail_unless(ret != -1, "Failed to close handle!!");
783
784    ret = pclKeyHandleClose(hd7);
785    fail_unless(ret != -1, "Failed to close handle!!");
786
787    ret = pclKeyHandleClose(hd8);
788    fail_unless(ret != -1, "Failed to close handle!!");
789
790    ret = pclKeyHandleClose(hd9);
791    fail_unless(ret != -1, "Failed to close handle!!");
792 #endif
793    pclDeinitLibrary();
794 }
795 END_TEST
796
797
798
799 /**
800  * Test for  i n t e r n a l  structures.
801  * Test the cursor functions.
802  */
803 START_TEST(test_Cursor)
804 {
805    int handle = -1, rval = 0, size = 0, handle1 = 0;
806    char bufferKeySrc[READ_SIZE]  = {0};
807    char bufferDataSrc[READ_SIZE] = {0};
808    char bufferKeyDst[READ_SIZE]  = {0};
809    char bufferDataDst[READ_SIZE] = {0};
810    unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
811
812    rval = pclInitLibrary(gTheAppId, shutdownReg);
813    fail_unless(rval <= 1, "Failed to init PCL");
814 #if 1
815    // create cursor
816    handle = pers_db_cursor_create("/Data/mnt-c/lt-persistence_client_library_test/cached.itz");
817    fail_unless(handle != -1, "Failed to create cursor!!");
818
819    // create cursor
820    handle1 = pers_db_cursor_create("/Data/mnt-wt/lt-persistence_client_library_test/wt.itz");
821    fail_unless(handle1 != -1, "Failed to create cursor!!");
822
823    do
824    {
825       memset(bufferKeySrc, 0, READ_SIZE);
826       memset(bufferDataSrc, 0, READ_SIZE);
827       memset(bufferKeyDst, 0, READ_SIZE);
828       memset(bufferDataDst, 0, READ_SIZE);
829
830       // get key
831       rval = pers_db_cursor_get_key(handle, bufferKeySrc, 128);
832       fail_unless(rval != -1, "Cursor failed to get key!!");
833       // get data
834       rval = pers_db_cursor_get_data(handle, bufferDataSrc, 128);
835       fail_unless(rval != -1, "Cursor failed to get data!!");
836       // get size
837       size = pers_db_cursor_get_data_size(handle);
838       fail_unless(size != -1, "Cursor failed to get size!!");
839       //printf("1. Key: %s | Data: %s » Size: %d \n", bufferKeySrc, bufferDataSrc, size);
840
841       // get key
842       rval = pers_db_cursor_get_key(handle1, bufferKeyDst, 128);
843       fail_unless(rval != -1, "Cursor failed to get key!!");
844       // get data
845       rval = pers_db_cursor_get_data(handle1, bufferDataDst, 128);
846       fail_unless(rval != -1, "Cursor failed to get data!!");
847       // get size
848       size = pers_db_cursor_get_data_size(handle1);
849       fail_unless(size != -1, "Cursor failed to get size!!");
850       //printf("  2. Key: %s | Data: %s » Size: %d \n", bufferKeyDst, bufferDataDst, size);
851    }
852    while( (pers_db_cursor_next(handle) == 0) && (pers_db_cursor_next(handle1) == 0) ); // next cursor
853
854    // destory cursor
855    rval = pers_db_cursor_destroy(handle);
856    fail_unless(rval != -1, "Failed to destroy cursor!!");
857
858    rval = pers_db_cursor_destroy(handle1);
859    fail_unless(rval != -1, "Failed to destroy cursor!!");
860 #endif
861    pclDeinitLibrary();
862 }
863 END_TEST
864
865
866
867 START_TEST(test_Plugin)
868 {
869         int ret = 0;
870         unsigned char buffer[READ_SIZE]  = {0};
871
872         unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
873
874    ret = pclInitLibrary(gTheAppId, shutdownReg);
875    fail_unless(ret <= 1, "Failed to init PCL");
876 #if 1
877         ret = pclKeyReadData(0xFF, "language/country_code",           0, 0, buffer, READ_SIZE);
878         fail_unless(ret != EPERS_NOT_INITIALIZED);
879    fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: secure!",
880                strlen((char*)buffer)) == 0, "Buffer SECURE not correctly read");
881
882
883         ret = pclKeyReadData(0xFF, "language/country_code_early",     0, 0, buffer, READ_SIZE);
884         fail_unless(ret != EPERS_NOT_INITIALIZED);
885         //printf("B U F F E R - early: %s\n", buffer);
886    fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: early!",
887                strlen((char*)buffer)) == 0, "Buffer EARLY not correctly read");
888
889         ret = pclKeyReadData(0xFF, "language/country_code_emergency", 0, 0, buffer, READ_SIZE);
890         fail_unless(ret != EPERS_NOT_INITIALIZED);
891         //printf("B U F F E R - emergency: %s\n", buffer);
892    fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: emergency!",
893                strlen((char*)buffer)) == 0, "Buffer EMERGENCY not correctly read");
894
895         ret = pclKeyReadData(0xFF, "language/info",                   0, 0, buffer, READ_SIZE);
896         fail_unless(ret != EPERS_NOT_INITIALIZED);
897         //printf("B U F F E R - hwinfo: %s\n", buffer);
898    fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: hwinfo!",
899                strlen((char*)buffer)) == 0, "Buffer HWINFO not correctly read");
900
901    ret = pclKeyReadData(0xFF, "language/country_code_custom3",   0, 0, buffer, READ_SIZE);
902    fail_unless(ret != EPERS_NOT_INITIALIZED);
903    //printf("B U F F E R - hwinfo: %s\n", buffer);
904    fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: custom3!",
905                strlen((char*)buffer)) == 0, "Buffer CUSTOM 3 not correctly read");
906 #endif
907         pclDeinitLibrary();
908 }
909 END_TEST
910
911
912
913
914
915 START_TEST(test_ReadDefault)
916 {
917    int ret = 0;
918    unsigned char buffer[READ_SIZE]  = {0};
919
920    unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
921
922    ret = pclInitLibrary(gTheAppId, shutdownReg);
923    fail_unless(ret <= 1, "Failed to init PCL");
924 #if 1
925    ret = pclKeyReadData(0xFF, "statusHandle/default01", 3, 2, buffer, READ_SIZE);
926    fail_unless(ret != EPERS_NOT_INITIALIZED);
927    //printf("B U F F E R: %s\n", buffer);
928    fail_unless(strncmp((char*)buffer,"DEFAULT_01!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
929
930    ret = pclKeyReadData(0xFF, "statusHandle/default02", 3, 2, buffer, READ_SIZE);
931    fail_unless(ret != EPERS_NOT_INITIALIZED);
932    //printf("B U F F E R: %s\n", buffer);
933    fail_unless(strncmp((char*)buffer,"DEFAULT_02!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
934 #endif
935    pclDeinitLibrary();
936 }
937 END_TEST
938
939
940
941 START_TEST(test_ReadConfDefault)
942 {
943    int ret = 0;
944    unsigned char buffer[READ_SIZE]  = {0};
945
946    unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
947
948    ret = pclInitLibrary(gTheAppId, shutdownReg);
949    fail_unless(ret <= 1, "Failed to init PCL");
950 #if 1
951    ret = pclKeyReadData(0xFF, "statusHandle/confdefault01",     3, 2, buffer, READ_SIZE);
952    fail_unless(ret != EPERS_NOT_INITIALIZED);
953    fail_unless(strncmp((char*)buffer,"CONF_DEFAULT_01!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
954
955    ret = pclKeyReadData(0xFF, "statusHandle/confdefault02",     3, 2, buffer, READ_SIZE);
956    fail_unless(ret != EPERS_NOT_INITIALIZED);
957    fail_unless(strncmp((char*)buffer,"CONF_DEFAULT_02!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
958 #endif
959    pclDeinitLibrary();
960 }
961 END_TEST
962
963
964
965 START_TEST(test_GetPath)
966 {
967    int ret = 0;
968    char* path = NULL;
969    const char* thePath = "/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDB_create.db";
970    unsigned int pathSize = 0;
971
972    unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
973
974    ret = pclInitLibrary(gTheAppId, shutdownReg);
975    fail_unless(ret <= 1, "Failed to init PCL");
976 #if 1
977    ret = pclFileCreatePath(0xFF, "media/mediaDB_create.db", 1, 1, &path, &pathSize);
978    fail_unless(strncmp((char*)path, thePath, strlen((char*)path)) == 0, "Path not correct");
979    fail_unless(pathSize == strlen((char*)path), "Path size not correct");
980
981    pclFileReleasePath(ret);
982 #endif
983    pclDeinitLibrary();
984 }
985 END_TEST
986
987
988 static Suite * persistencyClientLib_suite()
989 {
990    Suite * s  = suite_create("Persistency client library");
991
992    TCase * tc_persGetData = tcase_create("GetData");
993    tcase_add_test(tc_persGetData, test_GetData);
994
995    TCase * tc_persSetData = tcase_create("SetData");
996    tcase_add_test(tc_persSetData, test_SetData);
997
998    TCase * tc_persSetDataNoPRCT = tcase_create("SetDataNoPRCT");
999    tcase_add_test(tc_persSetDataNoPRCT, test_SetDataNoPRCT);
1000
1001    TCase * tc_persGetDataSize = tcase_create("GetDataSize");
1002    tcase_add_test(tc_persGetDataSize, test_GetDataSize);
1003
1004    TCase * tc_persDeleteData = tcase_create("DeleteData");
1005    tcase_add_test(tc_persDeleteData, test_DeleteData);
1006
1007    TCase * tc_persGetDataHandle = tcase_create("GetDataHandle");
1008    tcase_add_test(tc_persGetDataHandle, test_GetDataHandle);
1009
1010    TCase * tc_persDataHandle = tcase_create("DataHandle");
1011    tcase_add_test(tc_persDataHandle, test_DataHandle);
1012
1013    TCase * tc_persDataHandleOpen = tcase_create("DataHandleOpen");
1014    tcase_add_test(tc_persDataHandleOpen, test_DataHandleOpen);
1015
1016    TCase * tc_persDataFile = tcase_create("DataFile");
1017    tcase_add_test(tc_persDataFile, test_DataFile);
1018
1019    TCase * tc_persDataFileRecovery = tcase_create("DataFileRecovery");
1020    tcase_add_test(tc_persDataFileRecovery, test_DataFileRecovery);
1021
1022    TCase * tc_Cursor = tcase_create("Cursor");
1023    tcase_add_test(tc_Cursor, test_Cursor);
1024
1025    TCase * tc_Plugin = tcase_create("Plugin");
1026    tcase_add_test(tc_Plugin, test_Plugin);
1027
1028    TCase * tc_ReadDefault = tcase_create("ReadDefault");
1029    tcase_add_test(tc_ReadDefault, test_ReadDefault);
1030
1031    TCase * tc_ReadConfDefault = tcase_create("ReadConfDefault");
1032    tcase_add_test(tc_ReadConfDefault, test_ReadConfDefault);
1033
1034    TCase * tc_GetPath = tcase_create("GetPath");
1035    tcase_add_test(tc_GetPath, test_GetPath);
1036
1037    suite_add_tcase(s, tc_persSetData);
1038
1039 #if 1
1040    suite_add_tcase(s, tc_persGetData);
1041    suite_add_tcase(s, tc_persSetDataNoPRCT);
1042    suite_add_tcase(s, tc_persGetDataSize);
1043    suite_add_tcase(s, tc_persDeleteData);
1044    suite_add_tcase(s, tc_persGetDataHandle);
1045    suite_add_tcase(s, tc_persDataHandle);
1046    suite_add_tcase(s, tc_persDataHandleOpen);
1047    suite_add_tcase(s, tc_persDataFile);
1048    suite_add_tcase(s, tc_persDataFileRecovery);
1049    suite_add_tcase(s, tc_Cursor);
1050    suite_add_tcase(s, tc_ReadDefault);
1051    suite_add_tcase(s, tc_ReadConfDefault);
1052    suite_add_tcase(s, tc_GetPath);
1053 #endif
1054    //suite_add_tcase(s, tc_Plugin); // activate only if the plugins are available
1055    return s;
1056 }
1057
1058
1059 int main(int argc, char *argv[])
1060 {
1061    int nr_failed = 0;
1062
1063    // assign application name
1064    strncpy(gTheAppId, "lt-persistence_client_library_test", MaxAppNameLen);
1065    gTheAppId[MaxAppNameLen-1] = '\0';
1066
1067    /// debug log and trace (DLT) setup
1068    DLT_REGISTER_APP("test","tests the persistence client library");
1069
1070 #if 1
1071    Suite * s = persistencyClientLib_suite();
1072    SRunner * sr = srunner_create(s);
1073    srunner_run_all(sr, CK_VERBOSE);
1074    nr_failed = srunner_ntests_failed(sr);
1075
1076    srunner_free(sr);
1077 #endif
1078
1079    // unregister debug log and trace
1080    DLT_UNREGISTER_APP();
1081
1082    dlt_free();
1083
1084    return (0==nr_failed)?EXIT_SUCCESS:EXIT_FAILURE;
1085
1086 }
1087