Mercurial > hg > audiodb
comparison libtests/0001/prog1.c @ 355:94c18f128ce8
First version of the API, committed to the main trunk. Thanks Christophe, for all the help!
author | mas01ik |
---|---|
date | Wed, 12 Nov 2008 10:21:06 +0000 |
parents | |
children | 78fed0d4c108 342822c2d49a |
comparison
equal
deleted
inserted
replaced
354:4871a3ed9e36 | 355:94c18f128ce8 |
---|---|
1 #include <stdio.h> | |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 #include <sysexits.h> | |
5 #include <fcntl.h> | |
6 #include <dirent.h> | |
7 #include <unistd.h> | |
8 #include <sys/stat.h> | |
9 #include <errno.h> | |
10 /* | |
11 * * #define NDEBUG | |
12 * * */ | |
13 #include <assert.h> | |
14 | |
15 #include "../../audioDB_API.h" | |
16 #include "../test_utils_lib.h" | |
17 | |
18 | |
19 int main(int argc, char **argv){ | |
20 | |
21 int returnval=0; | |
22 adb_ptr mydbp={0}; | |
23 adb_ptr mydbp2={0}; | |
24 struct stat statbuf; | |
25 int statval=0; | |
26 | |
27 char * databasename="testdb"; | |
28 | |
29 //if [ -f testdb ]; then rm -f testdb; fi | |
30 /* remove old directory */ | |
31 clean_remove_db(databasename); | |
32 | |
33 /* create new db */ | |
34 //# creation | |
35 //${AUDIODB} -N -d testdb | |
36 mydbp=audiodb_open(databasename); | |
37 | |
38 | |
39 /* open should fail (return NULL), so create a new db */ | |
40 if (!mydbp){ | |
41 mydbp=audiodb_create(databasename,0,0,0); | |
42 } | |
43 | |
44 | |
45 | |
46 if (!mydbp){ | |
47 printf("fail\n"); | |
48 returnval=-1; | |
49 } | |
50 | |
51 | |
52 /* stat testdb - let's make sure that it is there */ | |
53 //stat testdb | |
54 statval=stat(databasename, &statbuf); | |
55 | |
56 if (statval){ | |
57 returnval=-1; | |
58 } | |
59 | |
60 audiodb_close(mydbp); | |
61 | |
62 /* try to create should fail, because db exists now */ | |
63 mydbp2=audiodb_create(databasename,0,0,0); | |
64 | |
65 if (mydbp2){ | |
66 returnval=-1; | |
67 } | |
68 | |
69 | |
70 /* should pass now - db exists */ | |
71 //expect_clean_error_exit ${AUDIODB} -N -d testdb | |
72 mydbp2=audiodb_open(databasename); | |
73 if (!mydbp2){ | |
74 returnval=-1; | |
75 } | |
76 | |
77 //this test would fail at compile time because of the API interface | |
78 //# should fail (no db given) | |
79 //expect_clean_error_exit ${AUDIODB} -N | |
80 | |
81 | |
82 audiodb_close(mydbp2); | |
83 | |
84 // printf("returnval:%d\n",returnval); | |
85 | |
86 return(returnval); | |
87 } | |
88 |