54b7009f1e57d90a9eab8ed3ffb0084a270f6761
[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    Permission is hereby granted, free of charge, to any person obtaining 
8    a copy of this software and associated documentation files (the "Software"), 
9    to deal in the Software without restriction, including without limitation 
10    the rights to use, copy, modify, merge, publish, distribute, sublicense, 
11    and/or sell copies of the Software, and to permit persons to whom the 
12    Software is furnished to do so, subject to the following conditions:
13
14    The above copyright notice and this permission notice shall be included 
15    in all copies or substantial portions of the Software.
16
17    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
18    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
19    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
20    IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
21    DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
22    TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
23    OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 ******************************************************************************/
25  /**
26  * @file           persistence_client_library_test.c
27  * @ingroup        Persistence client library test
28  * @author         Ingo Huerner
29  * @brief          Test of persistence client library
30  * @see            
31  */
32
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #include <errno.h>
37 #include <unistd.h>     /* exit */
38 #include <check.h>
39 #include <time.h>
40 #include <fcntl.h>
41 #include <sys/mman.h>
42
43 #include "../include/persistence_client_library_key.h"
44 #include "../include/persistence_client_library_file.h"
45 #include "../include/persistence_client_library_error_def.h"
46
47 // internal header, should normally not included in any application
48 // only for testing the cursor functionality
49 #include "../src/persistence_client_library_data_access.h"
50
51
52 #define BUF_SIZE     64
53 #define NUM_OF_FILES 3
54 #define READ_SIZE    1024
55
56
57 char* dayOfWeek[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
58
59
60
61 START_TEST (test_GetData)
62 {
63    int ret = 0;
64    unsigned char buffer[READ_SIZE];
65
66    memset(buffer, 0, READ_SIZE);
67    ret = key_read_data(0xFF, "language/country_code",         0, 0, buffer, READ_SIZE);
68    fail_unless(strncmp((char*)buffer, "Custom plugin -> plugin_get_data_handle",
69                strlen((char*)buffer)) == 0, "Buffer not correctly read");
70    fail_unless(ret = strlen("Custom plugin -> plugin_get_data_handle"));
71
72    memset(buffer, 0, READ_SIZE);
73    ret = key_read_data(0xFF, "pos/last_position",         0, 0, buffer, READ_SIZE);
74    fail_unless(strncmp((char*)buffer, "CACHE_ +48° 10' 38.95\", +8° 44' 39.06\"",
75                strlen((char*)buffer)) == 0, "Buffer not correctly read");
76    fail_unless(ret = strlen("CACHE_ +48° 10' 38.95\", +8° 44' 39.06\""));
77
78    memset(buffer, 0, READ_SIZE);
79    ret = key_read_data(0,    "language/current_language", 3, 0, buffer, READ_SIZE);
80    printf("Buffer: %s \n", buffer);
81    fail_unless(strncmp((char*)buffer, "CACHE_ Kisuaheli", strlen((char*)buffer)) == 0, "Buffer not correctly read");
82
83    memset(buffer, 0, READ_SIZE);
84    ret = key_read_data(0xFF, "status/open_document",      3, 2, buffer, READ_SIZE);
85    fail_unless(strncmp((char*)buffer, "WT_ /var/opt/user_manual_climateControl.pdf", strlen((char*)buffer)) == 0, "Buffer not correctly read");
86
87    memset(buffer, 0, READ_SIZE);
88    ret = key_read_data(0x20, "address/home_address",      4, 0, buffer, READ_SIZE);
89    fail_unless(strncmp((char*)buffer, "WT_ 55327 Heimatstadt, Wohnstrasse 31", strlen((char*)buffer)) == 0, "Buffer not correctly read");
90
91    memset(buffer, 0, READ_SIZE);
92    ret = key_read_data(0xFF, "pos/last_satellites",       0, 0, buffer, READ_SIZE);
93    fail_unless(strncmp((char*)buffer, "WT_ 17", strlen((char*)buffer)) == 0, "Buffer not correctly read");
94
95    memset(buffer, 0, READ_SIZE);
96    ret = key_read_data(0x84, "links/last_link",           2, 0, buffer, READ_SIZE);
97    fail_unless(strncmp((char*)buffer, "CACHE_ /last_exit/brooklyn", strlen((char*)buffer)) == 0, "Buffer not correctly read");
98
99    memset(buffer, 0, READ_SIZE);
100    ret = key_read_data(0x84, "links/last_link",           2, 1, buffer, READ_SIZE);
101    fail_unless(strncmp((char*)buffer, "CACHE_ /last_exit/queens", strlen((char*)buffer)) == 0, "Buffer not correctly read");
102 }
103 END_TEST
104
105
106
107 START_TEST (test_GetDataHandle)
108 {
109    int ret = 0, handle = 0, handle2 = 0, handle3 = 0, handle4 = 0, size = 0;
110    unsigned char buffer[READ_SIZE];
111    struct tm *locTime;
112    time_t t = time(0);
113
114    char sysTimeBuffer[128];
115    memset(buffer, 0, READ_SIZE);
116
117    locTime = localtime(&t);
118
119    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),
120                                                                   locTime->tm_hour, locTime->tm_min, locTime->tm_sec);
121    // open handle ---------------------------------------------------
122    handle = key_handle_open(0xFF, "posHandle/last_position", 0, 0);
123    fail_unless(handle >= 0, "Failed to open handle ==> /posHandle/last position");
124
125    ret = key_handle_read_data(handle, buffer, READ_SIZE);
126    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");
127
128    size = key_handle_get_size(handle);
129    fail_unless(size = strlen("WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\""));
130
131
132    // open handle ---------------------------------------------------
133    handle2 = key_handle_open(0xFF, "statusHandle/open_document", 3, 2);
134    fail_unless(handle2 >= 0, "Failed to open handle /statusHandle/open_document");
135
136    size = key_handle_write_data(handle2, (unsigned char*)sysTimeBuffer, strlen(sysTimeBuffer));
137    fail_unless(size = strlen(sysTimeBuffer));
138    // close
139    ret = key_handle_close(handle2);
140
141
142    // open handle ---------------------------------------------------
143    memset(buffer, 0, READ_SIZE);
144    handle4 = key_handle_open(0xFF, "language/country_code", 0, 0);
145    fail_unless(handle4 >= 0, "Failed to open handle /language/country_code");
146
147    ret = key_handle_read_data(handle4, buffer, READ_SIZE);
148    fail_unless(strncmp((char*)buffer, "Custom plugin -> plugin_get_data_handle", -1) == 0, "Buffer not correctly read");
149
150    size = key_handle_get_size(handle4);
151    fail_unless(size = strlen("Custom plugin -> plugin_get_data_handle"));
152
153    ret = key_handle_write_data(handle4, (unsigned char*)"Only dummy implementation behind custom library", READ_SIZE);
154
155
156    // open handle ---------------------------------------------------
157    handle3 = key_handle_open(0xFF, "statusHandle/open_document", 3, 2);
158    fail_unless(handle3 >= 0, "Failed to open handle /statusHandle/open_document");
159
160    ret = key_handle_read_data(handle3, buffer, READ_SIZE);
161    fail_unless(strncmp((char*)buffer, sysTimeBuffer, strlen(sysTimeBuffer)) == 0, "Buffer not correctly read");
162
163    size = key_handle_get_size(handle3);
164    fail_unless(size = strlen(sysTimeBuffer));
165
166    // close handle
167    ret = key_handle_close(handle);
168    ret = key_handle_close(handle3);
169    ret = key_handle_close(handle4);
170
171
172 }
173 END_TEST
174
175
176
177 START_TEST(test_SetData)
178 {
179    int ret = 0;
180    unsigned char buffer[READ_SIZE];
181    char write1[READ_SIZE];
182    char write2[READ_SIZE];
183    char sysTimeBuffer[256];
184
185    struct tm *locTime;
186    time_t t = time(0);
187
188    locTime = localtime(&t);
189    memset(buffer, 0, READ_SIZE);
190    memset(write1, 0, READ_SIZE);
191    memset(write2, 0, READ_SIZE);
192
193    // write data
194    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),
195                                                                  locTime->tm_hour, locTime->tm_min, locTime->tm_sec);
196    ret = key_write_data(0xFF, "69", 1, 2, (unsigned char*)sysTimeBuffer, strlen(sysTimeBuffer));
197    fail_unless(ret == strlen(sysTimeBuffer), "Wrong write size");
198
199    snprintf(write1, 128, "%s %s", "/70",  sysTimeBuffer);
200    ret = key_write_data(0xFF, "70", 1, 2, (unsigned char*)write1, strlen(write1));
201    fail_unless(ret == strlen(write1), "Wrong write size");
202
203    snprintf(write2, 128, "%s %s", "/key_70",  sysTimeBuffer);
204    ret = key_write_data(0xFF, "key_70", 1, 2, (unsigned char*)write2, strlen(write2));
205    fail_unless(ret == strlen(write2), "Wrong write size");
206
207    // read data again and and verify datat has been written correctly
208    memset(buffer, 0, READ_SIZE);
209    ret = key_read_data(0xFF, "69", 1, 2, buffer, READ_SIZE);
210    fail_unless(strncmp((char*)buffer, sysTimeBuffer, strlen(sysTimeBuffer)) == 0, "Buffer not correctly read");
211    fail_unless(ret == strlen(sysTimeBuffer), "Wrong read size");
212
213    memset(buffer, 0, READ_SIZE);
214    ret = key_read_data(0xFF, "70", 1, 2, buffer, READ_SIZE);
215    fail_unless(strncmp((char*)buffer, write1, strlen(write1)) == 0, "Buffer not correctly read");
216    fail_unless(ret == strlen(write1), "Wrong read size");
217
218    memset(buffer, 0, READ_SIZE);
219    ret = key_read_data(0xFF, "key_70", 1, 2, buffer, READ_SIZE);
220    fail_unless(strncmp((char*)buffer, write2, strlen(write2)) == 0, "Buffer not correctly read");
221    fail_unless(ret == strlen(write2), "Wrong read size");
222
223 }
224 END_TEST
225
226
227
228 START_TEST(test_GetDataSize)
229 {
230    int size = 0;
231
232    size = key_get_size(0xFF, "status/open_document", 3, 2);
233    fail_unless(size == strlen("WT_ /var/opt/user_manual_climateControl.pdf"), "Invalid size");
234
235    size = key_get_size(0x84, "links/last_link", 2, 1);
236    fail_unless(size == strlen("CACHE_ /last_exit/queens"), "Invalid size");
237 }
238 END_TEST
239
240
241
242 START_TEST(test_DeleteData)
243 {
244    int rval = 0;
245    unsigned char buffer[READ_SIZE];
246
247    // delete key
248    rval = key_delete(0xFF, "key_70", 1, 2);
249    fail_unless(rval == 0, "Failed to delete key");
250    // reading from key must fail now
251    rval = key_read_data(0xFF, "key_70", 1, 2, buffer, READ_SIZE);
252    fail_unless(rval == EPERS_NOKEY, "Read form key key_70 works, but should fail");
253
254
255    rval = key_delete(0xFF, "70", 1, 2);
256    fail_unless(rval == 0, "Failed to delete key");
257    rval = key_read_data(0xFF, "70", 1, 2, buffer, READ_SIZE);
258    fail_unless(rval == EPERS_NOKEY, "Read form key 70 works, but should fail");
259 }
260 END_TEST
261
262
263
264 START_TEST(test_DataFile)
265 {
266    int fd = 0, i = 0, idx = 0;
267    int size = 0, ret = 0;
268    int writeSize = 16*1024;
269    unsigned char buffer[READ_SIZE];
270    const char* refBuffer = "/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media";
271    char* writeBuffer;
272    char* fileMap = NULL;
273    writeBuffer = malloc(writeSize);
274
275
276    // fill buffer a sequence
277    for(i = 0; i<(writeSize/8); i++)
278    {
279       writeBuffer[idx++] = 'A';
280       writeBuffer[idx++] = 'B';
281       writeBuffer[idx++] = 'C';
282       writeBuffer[idx++] = ' ';
283       writeBuffer[idx++] = 'D';
284       writeBuffer[idx++] = 'E';
285       writeBuffer[idx++] = 'F';
286       writeBuffer[idx++] = ' ';
287    }
288    memset(buffer, 0, READ_SIZE);
289
290    // create file
291    fd = open("/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDBWrite.db",
292              O_CREAT|O_RDWR|O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
293    close(fd);
294
295    // open ----------------------------------------------------------
296    fd = file_open(0xFF, "media/mediaDB.db", 1, 1);
297    fail_unless(fd != -1, "Could not open file ==> /media/mediaDB.db");
298
299    size = file_get_size(fd);
300    fail_unless(size == 68, "Wrong file size");
301
302    size = file_read_data(fd, buffer, READ_SIZE);
303    fail_unless(strncmp((char*)buffer, refBuffer, strlen(refBuffer)) == 0, "Buffer not correctly read");
304    fail_unless(size == (strlen(refBuffer)+1), "Wrong size returned");      // strlen + 1 ==> inlcude cr/lf
305
306    ret = file_close(fd);
307    fail_unless(ret == 0, "Failed to close file");
308
309
310    // open ----------------------------------------------------------
311    fd = file_open(0xFF, "media/mediaDBWrite.db", 1, 1);
312    fail_unless(fd != -1, "Could not open file ==> /media/mediaDBWrite.db");
313
314    size = file_write_data(fd, writeBuffer, strlen(writeBuffer));
315    fail_unless(size == strlen(writeBuffer), "Failed to write data");
316
317    ret = file_close(fd);
318    fail_unless(ret == 0, "Failed to close file");
319
320
321    // remove ----------------------------------------------------------
322    ret = file_remove(0xFF, "media/mediaDBWrite.db", 1, 1);
323    fail_unless(ret == 0, "File can't be removed ==> /media/mediaDBWrite.db");
324
325    fd = file_open(0xFF, "media/mediaDBWrite.db", 1, 1);
326    fail_unless(fd == -1, "File can be opend, but should not ==> /media/mediaDBWrite.db");
327
328
329    // map file ------------------------------------------------------
330    fd = file_open(0xFF, "media/mediaDB.db", 1, 1);
331
332    size = file_get_size(fd);
333    file_map_data(fileMap, size, 0, fd);
334    fail_unless(fileMap != MAP_FAILED, "Failed to map file");
335
336    ret = file_unmap_data(fileMap, size);
337    fail_unless(ret != -1, "Failed to unmap file");
338
339    // negative test
340    size = file_get_size(1024);
341    fail_unless(ret == 0, "Got size, but should not");
342
343
344    free(writeBuffer);
345 }
346 END_TEST
347
348
349
350 START_TEST(test_DataHandle)
351 {
352    int handle1 = 0, handle2 = 0;
353    int ret = 0;
354
355    // test file handles
356    handle1 = file_open(0xFF, "media/mediaDB.db", 1, 1);
357    fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB.db");
358
359    ret = file_close(handle1);
360    fail_unless(handle1 != -1, "Could not closefile ==> /media/mediaDB.db");
361
362    ret = file_close(1024);
363    fail_unless(ret == -1, "Could close file, but should not!!");
364
365    ret = file_close(17);
366    fail_unless(ret == -1, "Could close file, but should not!!");
367
368
369    // test key handles
370    handle2 = key_handle_open(0xFF, "statusHandle/open_document", 3, 2);
371    fail_unless(handle2 >= 0, "Failed to open handle /statusHandle/open_document");
372
373    ret = key_handle_close(handle2);
374    fail_unless(ret != -1, "Failed to close handle!!");
375
376    ret = key_handle_close(1024);
377    fail_unless(ret == -1, "Could close, but should not!!");
378 }
379 END_TEST
380
381
382
383 START_TEST(test_DataHandleOpen)
384 {
385    int hd1 = -2, hd2 = -2, hd3 = -2, hd4 = -2, hd5 = -2, hd6 = -2, hd7 = -2, hd8 = -2, hd9 = -2, ret = 0;
386
387    // open handles ----------------------------------------------------
388    hd1 = key_handle_open(0xFF, "posHandle/last_position1", 0, 0);
389    fail_unless(hd1 == 1, "Failed to open handle ==> /posHandle/last_position1");
390
391    hd2 = key_handle_open(0xFF, "posHandle/last_position2", 0, 0);
392    fail_unless(hd2 == 2, "Failed to open handle ==> /posHandle/last_position2");
393
394    hd3 = key_handle_open(0xFF, "posHandle/last_position3", 0, 0);
395    fail_unless(hd3 == 3, "Failed to open handle ==> /posHandle/last_position3");
396
397    // close handles ---------------------------------------------------
398    ret = key_handle_close(hd1);
399    fail_unless(ret != -1, "Failed to close handle!!");
400
401    ret = key_handle_close(hd2);
402    fail_unless(ret != -1, "Failed to close handle!!");
403
404    ret = key_handle_close(hd3);
405    fail_unless(ret != -1, "Failed to close handle!!");
406
407    // open handles ----------------------------------------------------
408    hd4 = key_handle_open(0xFF, "posHandle/last_position4", 0, 0);
409    fail_unless(hd4 == 3, "Failed to open handle ==> /posHandle/last_position4");
410
411    hd5 = key_handle_open(0xFF, "posHandle/last_position5", 0, 0);
412    fail_unless(hd5 == 2, "Failed to open handle ==> /posHandle/last_position5");
413
414    hd6 = key_handle_open(0xFF, "posHandle/last_position6", 0, 0);
415    fail_unless(hd6 == 1, "Failed to open handle ==> /posHandle/last_position6");
416
417    hd7 = key_handle_open(0xFF, "posHandle/last_position7", 0, 0);
418    fail_unless(hd7 == 4, "Failed to open handle ==> /posHandle/last_position7");
419
420    hd8 = key_handle_open(0xFF, "posHandle/last_position8", 0, 0);
421    fail_unless(hd8 == 5, "Failed to open handle ==> /posHandle/last_position8");
422
423    hd9 = key_handle_open(0xFF, "posHandle/last_position9", 0, 0);
424    fail_unless(hd9 == 6, "Failed to open handle ==> /posHandle/last_position9");
425
426    // close handles ---------------------------------------------------
427    ret = key_handle_close(hd4);
428    fail_unless(ret != -1, "Failed to close handle!!");
429
430    ret = key_handle_close(hd5);
431    fail_unless(ret != -1, "Failed to close handle!!");
432
433    ret = key_handle_close(hd6);
434    fail_unless(ret != -1, "Failed to close handle!!");
435
436    ret = key_handle_close(hd7);
437    fail_unless(ret != -1, "Failed to close handle!!");
438
439    ret = key_handle_close(hd8);
440    fail_unless(ret != -1, "Failed to close handle!!");
441
442    ret = key_handle_close(hd9);
443    fail_unless(ret != -1, "Failed to close handle!!");
444 }
445 END_TEST
446
447
448
449 START_TEST(test_Cursor)
450 {
451    int handle = -1, rval = 0, size = 0, handle1 = 0;
452    char bufferKeySrc[READ_SIZE];
453    char bufferDataSrc[READ_SIZE];
454    char bufferKeyDst[READ_SIZE];
455    char bufferDataDst[READ_SIZE];
456
457    memset(bufferKeySrc, 0, READ_SIZE);
458    memset(bufferDataSrc, 0, READ_SIZE);
459
460    memset(bufferKeyDst, 0, READ_SIZE);
461    memset(bufferDataDst, 0, READ_SIZE);
462
463    // create cursor
464    handle = persistence_db_cursor_create("/Data/mnt-c/lt-persistence_client_library_test/cached.itz",
465                                           PersistenceStorage_local, PersistencePolicy_wc);
466    printf("Handle  : %d \n", handle);
467    fail_unless(handle != -1, "Failed to create cursor!!");
468
469    // create cursor
470    handle1 = persistence_db_cursor_create("/Data/mnt-c/lt-persistence_client_library_test/wt.itz",
471                                            PersistenceStorage_local, PersistencePolicy_wt);
472    printf("Handle1 : %d \n", handle1);
473    fail_unless(handle1 != -1, "Failed to create cursor!!");
474
475    do
476    {
477       memset(bufferKeySrc, 0, READ_SIZE);
478       memset(bufferDataSrc, 0, READ_SIZE);
479       memset(bufferKeyDst, 0, READ_SIZE);
480       memset(bufferDataDst, 0, READ_SIZE);
481
482       // get key
483       rval = persistence_db_cursor_get_key(handle, bufferKeySrc, 128);
484       fail_unless(rval != -1, "Cursor failed to get key!!");
485       // get data
486       rval = persistence_db_cursor_get_data(handle, bufferDataSrc, 128);
487       fail_unless(rval != -1, "Cursor failed to get data!!");
488       // get size
489       size = persistence_db_cursor_get_data_size(handle);
490       fail_unless(size != -1, "Cursor failed to get size!!");
491       //printf("1. Key: %s | Data: %s » Size: %d \n", bufferKeySrc, bufferDataSrc, size);
492
493       // get key
494       rval = persistence_db_cursor_get_key(handle1, bufferKeyDst, 128);
495       fail_unless(rval != -1, "Cursor failed to get key!!");
496       // get data
497       rval = persistence_db_cursor_get_data(handle1, bufferDataDst, 128);
498       fail_unless(rval != -1, "Cursor failed to get data!!");
499       // get size
500       size = persistence_db_cursor_get_data_size(handle1);
501       fail_unless(size != -1, "Cursor failed to get size!!");
502       //printf("  2. Key: %s | Data: %s » Size: %d \n", bufferKeyDst, bufferDataDst, size);
503    }
504    while( (persistence_db_cursor_next(handle) == 0) && (persistence_db_cursor_next(handle1) == 0) ); // next cursor
505
506    // destory cursor
507    rval = persistence_db_cursor_destroy(handle);
508    fail_unless(rval != -1, "Failed to destroy cursor!!");
509
510    rval = persistence_db_cursor_destroy(handle1);
511    fail_unless(rval != -1, "Failed to destroy cursor!!");
512 }
513 END_TEST
514
515
516
517 static Suite * persistencyClientLib_suite()
518 {
519    Suite * s  = suite_create("Persistency client library");
520
521    TCase * tc_persGetData = tcase_create("GetData");
522    tcase_add_test(tc_persGetData, test_GetData);
523
524    TCase * tc_persSetData = tcase_create("SetData");
525    tcase_add_test(tc_persSetData, test_SetData);
526
527    TCase * tc_persGetDataSize = tcase_create("GetDataSize");
528    tcase_add_test(tc_persGetDataSize, test_GetDataSize);
529
530    TCase * tc_persDeleteData = tcase_create("DeleteData");
531    tcase_add_test(tc_persDeleteData, test_DeleteData);
532
533    TCase * tc_persGetDataHandle = tcase_create("GetDataHandle");
534    tcase_add_test(tc_persGetDataHandle, test_GetDataHandle);
535
536    TCase * tc_persDataHandle = tcase_create("DataHandle");
537    tcase_add_test(tc_persDataHandle, test_DataHandle);
538
539    TCase * tc_persDataHandleOpen = tcase_create("DataHandleOpen");
540    tcase_add_test(tc_persDataHandleOpen, test_DataHandleOpen);
541
542    TCase * tc_persDataFile = tcase_create("DataFile");
543    tcase_add_test(tc_persDataFile, test_DataFile);
544
545    TCase * tc_Cursor = tcase_create("Cursor");
546    tcase_add_test(tc_Cursor, test_Cursor);
547
548    suite_add_tcase(s, tc_persGetData);
549    suite_add_tcase(s, tc_persSetData);
550    suite_add_tcase(s, tc_persGetDataSize);
551    suite_add_tcase(s, tc_persDeleteData);
552    suite_add_tcase(s, tc_persGetDataHandle);
553    suite_add_tcase(s, tc_persDataHandle);
554    suite_add_tcase(s, tc_persDataHandleOpen);
555    suite_add_tcase(s, tc_persDataFile);
556    suite_add_tcase(s, tc_Cursor);
557
558    return s;
559 }
560
561
562
563
564 int main(int argc, char *argv[])
565 {
566    int nr_failed = 0;
567
568    Suite * s = persistencyClientLib_suite();
569    SRunner * sr = srunner_create(s);
570    srunner_run_all(sr, CK_VERBOSE);
571    nr_failed = srunner_ntests_failed(sr);
572
573    srunner_free(sr);
574    return (0==nr_failed)?EXIT_SUCCESS:EXIT_FAILURE;
575
576 }
577