annotate libtests/0003/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
rev   line source
mas01cr@487 1 #include "audioDB_API.h"
mas01cr@487 2 #include "test_utils_lib.h"
mas01ik@355 3
mas01cr@489 4 int main(int argc, char **argv) {
mas01cr@489 5 adb_t *adb;
mas01ik@355 6
mas01cr@489 7 clean_remove_db(TESTDB);
mas01cr@489 8 if(!(adb = audiodb_create(TESTDB, 0, 0, 0)))
mas01cr@489 9 return 1;
mas01cr@489 10 if(audiodb_l2norm(adb))
mas01cr@489 11 return 1;
mas01ik@355 12
mas01cr@489 13 adb_datum_t datum = {1, 1, "testfeature", (double[1]) {1}, NULL, NULL};
mas01cr@489 14 if(audiodb_insert_datum(adb, &datum))
mas01cr@489 15 return 1;
mas01ik@355 16
mas01cr@489 17 adb_query_id_t qid = {0};
mas01cr@489 18 qid.datum = &datum;
mas01cr@489 19 qid.sequence_length = 1;
mas01cr@489 20 qid.sequence_start = 0;
mas01cr@489 21 adb_query_parameters_t parms =
mas01cr@489 22 {ADB_ACCUMULATION_DB, ADB_DISTANCE_DOT_PRODUCT, 10, 0};
mas01cr@489 23 adb_query_refine_t refine = {0};
mas01cr@489 24 refine.hopsize = 1;
mas01ik@355 25
mas01cr@489 26 adb_query_spec_t spec;
mas01cr@489 27 spec.qid = qid;
mas01cr@489 28 spec.params = parms;
mas01cr@489 29 spec.refine = refine;
mas01ik@355 30
mas01cr@489 31 adb_query_results_t *results = audiodb_query_spec(adb, &spec);
mas01cr@489 32 if(!results || results->nresults != 1) return 1;
mas01cr@489 33 result_present_or_fail(results, "testfeature", 1, 0, 0);
mas01cr@489 34 audiodb_query_free_results(adb, &spec, results);
mas01ik@355 35
mas01cr@489 36 audiodb_close(adb);
mas01ik@355 37
mas01cr@489 38 return 104;
mas01ik@355 39 }