comparison libtests/0001/prog1.c @ 489:4cb6c611f812 api-inversion

Begin removing uses of audiodb_query() audiodb_query() is actually an unsupportable interface. It requires access to the filesystem, does not (and cannot) actually support whole swathes of functionality, is only implementable using code that is no longer part of the core of audioDB (reporter.h), is in the way of fixing memory leaks in the SOAP server, and is horrible to use to boot. So, begin converting the libtests uses of audiodb_query() to audio_query_spec(). In the process, go through the test code and remove useless comments, pointless variables, and commented-out bits of shell scripts.
author mas01cr
date Sat, 10 Jan 2009 15:32:53 +0000
parents e072aa1611f5
children
comparison
equal deleted inserted replaced
488:f4dc8e47ee37 489:4cb6c611f812
1 #include "audioDB_API.h" 1 #include "audioDB_API.h"
2 #include "test_utils_lib.h" 2 #include "test_utils_lib.h"
3 3
4 int main(int argc, char **argv) {
5 adb_t *adb;
6 struct stat st;
4 7
5 int main(int argc, char **argv){ 8 clean_remove_db(TESTDB);
6 9
7 int returnval=0; 10 adb = audiodb_open(TESTDB, O_RDWR);
8 adb_ptr mydbp={0}; 11 if(adb)
9 adb_ptr mydbp2={0}; 12 return 1;
10 struct stat statbuf;
11 int statval=0;
12 13
13 char * databasename="testdb"; 14 adb = audiodb_create(TESTDB, 0, 0, 0);
15 if (!adb)
16 return 1;
14 17
15 //if [ -f testdb ]; then rm -f testdb; fi 18 if(stat(TESTDB, &st))
16 /* remove old directory */ 19 return 1;
17 clean_remove_db(databasename);
18 20
19 /* create new db */ 21 audiodb_close(adb);
20 //# creation
21 //${AUDIODB} -N -d testdb
22 mydbp=audiodb_open(databasename,O_RDWR);
23 22
23 adb = audiodb_create(TESTDB, 0, 0, 0);
24 if(adb)
25 return 1;
24 26
25 /* open should fail (return NULL), so create a new db */ 27 adb = audiodb_open(TESTDB, O_RDONLY);
26 if (!mydbp){ 28 if (!adb)
27 mydbp=audiodb_create(databasename,0,0,0); 29 return 1;
28 }
29 30
31 audiodb_close(adb);
30 32
31 33 return 104;
32 if (!mydbp){
33 printf("fail\n");
34 returnval=-1;
35 }
36
37
38 /* stat testdb - let's make sure that it is there */
39 //stat testdb
40 statval=stat(databasename, &statbuf);
41
42 if (statval){
43 returnval=-1;
44 }
45
46 audiodb_close(mydbp);
47
48 /* try to create should fail, because db exists now */
49 mydbp2=audiodb_create(databasename,0,0,0);
50
51 if (mydbp2){
52 returnval=-1;
53 }
54
55
56 /* should pass now - db exists */
57 //expect_clean_error_exit ${AUDIODB} -N -d testdb
58 mydbp2=audiodb_open(databasename, O_RDONLY);
59 if (!mydbp2){
60 returnval=-1;
61 }
62
63 //this test would fail at compile time because of the API interface
64 //# should fail (no db given)
65 //expect_clean_error_exit ${AUDIODB} -N
66
67
68 audiodb_close(mydbp2);
69
70 // printf("returnval:%d\n",returnval);
71
72 return(returnval);
73 } 34 }
74