annotate libtests/0001/prog1.c @ 369:6564be3109c5
gcc-4.3-cleanups
gcc-4.3 warning cleanups for lshlib.cpp
(I do not believe that any of these changes contain significant
copyrightable "intellectual property". However, to the extent that they
do, the changes are hereby released into the Public Domain, and may be
therefore be used by anyone for any purpose without need for
consideration of any kind.)
author |
mas01cr |
date |
Wed, 12 Nov 2008 15:23:32 +0000 |
parents |
94c18f128ce8 |
children |
78fed0d4c108 342822c2d49a |
rev |
line source |
mas01ik@355
|
1 #include <stdio.h>
|
mas01ik@355
|
2 #include <stdlib.h>
|
mas01ik@355
|
3 #include <string.h>
|
mas01ik@355
|
4 #include <sysexits.h>
|
mas01ik@355
|
5 #include <fcntl.h>
|
mas01ik@355
|
6 #include <dirent.h>
|
mas01ik@355
|
7 #include <unistd.h>
|
mas01ik@355
|
8 #include <sys/stat.h>
|
mas01ik@355
|
9 #include <errno.h>
|
mas01ik@355
|
10 /*
|
mas01ik@355
|
11 * * #define NDEBUG
|
mas01ik@355
|
12 * * */
|
mas01ik@355
|
13 #include <assert.h>
|
mas01ik@355
|
14
|
mas01ik@355
|
15 #include "../../audioDB_API.h"
|
mas01ik@355
|
16 #include "../test_utils_lib.h"
|
mas01ik@355
|
17
|
mas01ik@355
|
18
|
mas01ik@355
|
19 int main(int argc, char **argv){
|
mas01ik@355
|
20
|
mas01ik@355
|
21 int returnval=0;
|
mas01ik@355
|
22 adb_ptr mydbp={0};
|
mas01ik@355
|
23 adb_ptr mydbp2={0};
|
mas01ik@355
|
24 struct stat statbuf;
|
mas01ik@355
|
25 int statval=0;
|
mas01ik@355
|
26
|
mas01ik@355
|
27 char * databasename="testdb";
|
mas01ik@355
|
28
|
mas01ik@355
|
29 //if [ -f testdb ]; then rm -f testdb; fi
|
mas01ik@355
|
30 /* remove old directory */
|
mas01ik@355
|
31 clean_remove_db(databasename);
|
mas01ik@355
|
32
|
mas01ik@355
|
33 /* create new db */
|
mas01ik@355
|
34 //# creation
|
mas01ik@355
|
35 //${AUDIODB} -N -d testdb
|
mas01ik@355
|
36 mydbp=audiodb_open(databasename);
|
mas01ik@355
|
37
|
mas01ik@355
|
38
|
mas01ik@355
|
39 /* open should fail (return NULL), so create a new db */
|
mas01ik@355
|
40 if (!mydbp){
|
mas01ik@355
|
41 mydbp=audiodb_create(databasename,0,0,0);
|
mas01ik@355
|
42 }
|
mas01ik@355
|
43
|
mas01ik@355
|
44
|
mas01ik@355
|
45
|
mas01ik@355
|
46 if (!mydbp){
|
mas01ik@355
|
47 printf("fail\n");
|
mas01ik@355
|
48 returnval=-1;
|
mas01ik@355
|
49 }
|
mas01ik@355
|
50
|
mas01ik@355
|
51
|
mas01ik@355
|
52 /* stat testdb - let's make sure that it is there */
|
mas01ik@355
|
53 //stat testdb
|
mas01ik@355
|
54 statval=stat(databasename, &statbuf);
|
mas01ik@355
|
55
|
mas01ik@355
|
56 if (statval){
|
mas01ik@355
|
57 returnval=-1;
|
mas01ik@355
|
58 }
|
mas01ik@355
|
59
|
mas01ik@355
|
60 audiodb_close(mydbp);
|
mas01ik@355
|
61
|
mas01ik@355
|
62 /* try to create should fail, because db exists now */
|
mas01ik@355
|
63 mydbp2=audiodb_create(databasename,0,0,0);
|
mas01ik@355
|
64
|
mas01ik@355
|
65 if (mydbp2){
|
mas01ik@355
|
66 returnval=-1;
|
mas01ik@355
|
67 }
|
mas01ik@355
|
68
|
mas01ik@355
|
69
|
mas01ik@355
|
70 /* should pass now - db exists */
|
mas01ik@355
|
71 //expect_clean_error_exit ${AUDIODB} -N -d testdb
|
mas01ik@355
|
72 mydbp2=audiodb_open(databasename);
|
mas01ik@355
|
73 if (!mydbp2){
|
mas01ik@355
|
74 returnval=-1;
|
mas01ik@355
|
75 }
|
mas01ik@355
|
76
|
mas01ik@355
|
77 //this test would fail at compile time because of the API interface
|
mas01ik@355
|
78 //# should fail (no db given)
|
mas01ik@355
|
79 //expect_clean_error_exit ${AUDIODB} -N
|
mas01ik@355
|
80
|
mas01ik@355
|
81
|
mas01ik@355
|
82 audiodb_close(mydbp2);
|
mas01ik@355
|
83
|
mas01ik@355
|
84 // printf("returnval:%d\n",returnval);
|
mas01ik@355
|
85
|
mas01ik@355
|
86 return(returnval);
|
mas01ik@355
|
87 }
|
mas01ik@355
|
88
|