diff 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
line wrap: on
line diff
--- a/libtests/0001/prog1.c	Sat Jan 10 15:32:49 2009 +0000
+++ b/libtests/0001/prog1.c	Sat Jan 10 15:32:53 2009 +0000
@@ -1,74 +1,34 @@
 #include "audioDB_API.h"
 #include "test_utils_lib.h"
 
+int main(int argc, char **argv) {
+  adb_t *adb;
+  struct stat st;
 
-int main(int argc, char **argv){
+  clean_remove_db(TESTDB);
 
-    int returnval=0;
-    adb_ptr mydbp={0};
-    adb_ptr mydbp2={0};
-    struct stat statbuf;
-    int statval=0;
+  adb = audiodb_open(TESTDB, O_RDWR);
+  if(adb)
+    return 1;
 
-    char * databasename="testdb";
+  adb = audiodb_create(TESTDB, 0, 0, 0);
+  if (!adb)
+    return 1;
 
-    //if [ -f testdb ]; then rm -f testdb; fi
-    /* remove old directory */
-    clean_remove_db(databasename);
+  if(stat(TESTDB, &st))
+    return 1;
 
-    /* create new db */
-    //# creation
-    //${AUDIODB} -N -d testdb
-    mydbp=audiodb_open(databasename,O_RDWR);
+  audiodb_close(adb);
 
+  adb = audiodb_create(TESTDB, 0, 0, 0);
+  if(adb)
+    return 1;
 
-    /* open should fail (return NULL), so create a new db */
-    if (!mydbp){
-        mydbp=audiodb_create(databasename,0,0,0);
-    }
+  adb = audiodb_open(TESTDB, O_RDONLY);
+  if (!adb)
+    return 1;
 
+  audiodb_close(adb);
 
-
-    if (!mydbp){
-        printf("fail\n");
-        returnval=-1;
-    }
-    
-
-    /* stat testdb - let's make sure that it is there */
-    //stat testdb
-    statval=stat(databasename, &statbuf);
-
-    if (statval){
-       returnval=-1;
-    }
-    
-    audiodb_close(mydbp);
-
-    /* try to create should fail, because db exists now */
-    mydbp2=audiodb_create(databasename,0,0,0);
-
-    if (mydbp2){
-        returnval=-1;
-    }
-
-
-/* should pass now - db exists */ 
-//expect_clean_error_exit ${AUDIODB} -N -d testdb
-    mydbp2=audiodb_open(databasename, O_RDONLY);
-    if (!mydbp2){
-       returnval=-1;
-    }
-
-//this test would fail at compile time because of the API interface
-//# should fail (no db given)
-//expect_clean_error_exit ${AUDIODB} -N
-
-
-    audiodb_close(mydbp2);
-
-//    printf("returnval:%d\n",returnval);
-
-    return(returnval);
+  return 104;
 }
-