annotate libtests/0031/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 e072aa1611f5 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 /*
mas01ik@355 10 * * #define NDEBUG
mas01ik@355 11 * * */
mas01ik@355 12 #include <assert.h>
mas01ik@355 13
mas01ik@355 14 #include "../../audioDB_API.h"
mas01ik@355 15 #include "../test_utils_lib.h"
mas01ik@355 16
mas01ik@355 17
mas01ik@355 18 int main(int argc, char **argv){
mas01ik@355 19
mas01ik@355 20 int returnval=0;
mas01ik@355 21 adb_ptr mydbp={0};
mas01ik@355 22 int ivals[10];
mas01ik@355 23 double dvals[10];
mas01ik@355 24 adb_insert_t myinsert={0};
mas01ik@355 25 char * databasename="testdb";
mas01ik@355 26 adb_query_t myadbquery={0};
mas01ik@355 27 adb_queryresult_t myadbqueryresult={0};
mas01ik@355 28 int size=0;
mas01ik@355 29
mas01ik@355 30
mas01ik@355 31 /* remove old directory */
mas01ik@355 32 //if [ -f testdb ]; then rm -f testdb; fi
mas01ik@355 33 clean_remove_db(databasename);
mas01ik@355 34
mas01ik@355 35 /* create new db */
mas01ik@355 36 //${AUDIODB} -d testdb -N
mas01ik@355 37 mydbp=audiodb_create(databasename,0,0,0);
mas01ik@355 38
mas01ik@355 39 ///intstring 2 > testfeature01
mas01ik@355 40 ///floatstring 0 1 >> testfeature01
mas01ik@355 41 ///intstring 2 > testfeature10
mas01ik@355 42 ///floatstring 1 0 >> testfeature10
mas01ik@355 43 ivals[0]=2;
mas01ik@355 44 dvals[0]=0; dvals[1]=1;
mas01ik@355 45 maketestfile("testfeature01",ivals,dvals,2);
mas01ik@355 46 ivals[0]=2;
mas01ik@355 47 dvals[0]=1; dvals[1]=0;
mas01ik@355 48 maketestfile("testfeature10",ivals,dvals,2);
mas01ik@355 49
mas01ik@355 50 ///${AUDIODB} -d testdb -I -f testfeature01
mas01ik@355 51 ///${AUDIODB} -d testdb -I -f testfeature10
mas01ik@355 52
mas01ik@355 53 myinsert.features="testfeature01";
mas01ik@355 54 if (audiodb_insert(mydbp,&myinsert)){ returnval=-1; }
mas01ik@355 55
mas01ik@355 56 myinsert.features="testfeature10";
mas01ik@355 57 if (audiodb_insert(mydbp,&myinsert)){ returnval=-1; }
mas01ik@355 58
mas01ik@355 59 ///# sequence queries require L2NORM
mas01ik@355 60 ///${AUDIODB} -d testdb -L
mas01ik@355 61 if(audiodb_l2norm(mydbp)){ returnval=-1; };
mas01ik@355 62
mas01ik@355 63 ///echo "query point (0.0,0.5)"
mas01ik@355 64 ///intstring 2 > testquery
mas01ik@355 65 ///floatstring 0 0.5 >> testquery
mas01ik@355 66 ivals[0]=2;
mas01ik@355 67 dvals[0]=0; dvals[1]=0.5;
mas01ik@355 68 maketestfile("testquery",ivals,dvals,2);
mas01ik@355 69
mas01ik@355 70 ///${AUDIODB} -d testdb -Q sequence -l 1 -f testquery > testoutput
mas01ik@355 71 ///echo testfeature01 0 0 0 > test-expected-output
mas01ik@355 72 ///echo testfeature10 2 0 0 >> test-expected-output
mas01ik@355 73 ///cmp testoutput test-expected-output
mas01ik@355 74 myadbquery.querytype="sequence";
mas01ik@355 75 myadbquery.feature="testquery";
mas01ik@355 76 myadbquery.sequencelength="1";
mas01ik@355 77 audiodb_query(mydbp,&myadbquery,&myadbqueryresult);
mas01ik@355 78 size=myadbqueryresult.sizeRlist;
mas01ik@355 79
mas01ik@355 80 /* check the test values */
mas01ik@355 81 if (size != 2) {returnval = -1;};
mas01ik@355 82 if (testoneresult(&myadbqueryresult,0,"testfeature01",0,0,0)) {returnval = -1;};
mas01ik@355 83 if (testoneresult(&myadbqueryresult,1,"testfeature10",2,0,0)) {returnval = -1;};
mas01ik@355 84
mas01ik@355 85 //${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -K /dev/null > testoutput
mas01ik@355 86 //cat /dev/null > test-expected-output
mas01ik@355 87 //cmp testoutput test-expected-output
mas01ik@355 88 myadbquery.querytype="sequence";
mas01ik@355 89 myadbquery.feature="testquery";
mas01ik@355 90 myadbquery.keylist="/dev/null";
mas01ik@355 91 myadbquery.sequencelength="1";
mas01ik@355 92 audiodb_query(mydbp,&myadbquery,&myadbqueryresult);
mas01ik@355 93 size=myadbqueryresult.sizeRlist;
mas01ik@355 94 //dump_query(&myadbquery,&myadbqueryresult);
mas01ik@355 95
mas01ik@355 96 /* check the test values */
mas01ik@355 97 if (size != 0) {returnval = -1;};
mas01ik@355 98
mas01ik@355 99 ///echo testfeature01 > testkl.txt
mas01ik@355 100 makekeylistfile("testkl.txt","testfeature01");
mas01ik@355 101
mas01ik@355 102 ///${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -K testkl.txt > testoutput
mas01ik@355 103 ///echo testfeature01 0 0 0 > test-expected-output
mas01ik@355 104 ///cmp testoutput test-expected-output
mas01ik@355 105 myadbquery.querytype="sequence";
mas01ik@355 106 myadbquery.feature="testquery";
mas01ik@355 107 myadbquery.keylist="testkl.txt";
mas01ik@355 108 myadbquery.sequencelength="1";
mas01ik@355 109 audiodb_query(mydbp,&myadbquery,&myadbqueryresult);
mas01ik@355 110
mas01ik@355 111 size=myadbqueryresult.sizeRlist;
mas01ik@355 112 //dump_query(&myadbquery,&myadbqueryresult);
mas01ik@355 113
mas01ik@355 114 /* check the test values */
mas01ik@355 115 if (size != 1) {returnval = -1;};
mas01ik@355 116 if (testoneresult(&myadbqueryresult,0,"testfeature01",0,0,0)) {returnval = -1;};
mas01ik@355 117
mas01ik@355 118 ///echo testfeature10 > testkl.txt
mas01ik@355 119 makekeylistfile("testkl.txt","testfeature10");
mas01ik@355 120
mas01ik@355 121 ///${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -K testkl.txt > testoutput
mas01ik@355 122 ///echo testfeature10 2 0 0 > test-expected-output
mas01ik@355 123 ///cmp testoutput test-expected-output
mas01ik@355 124 myadbquery.querytype="sequence";
mas01ik@355 125 myadbquery.feature="testquery";
mas01ik@355 126 myadbquery.keylist="testkl.txt";
mas01ik@355 127 myadbquery.sequencelength="1";
mas01ik@355 128 audiodb_query(mydbp,&myadbquery,&myadbqueryresult);
mas01ik@355 129
mas01ik@355 130 size=myadbqueryresult.sizeRlist;
mas01ik@355 131 //dump_query(&myadbquery,&myadbqueryresult);
mas01ik@355 132
mas01ik@355 133 /* check the test values */
mas01ik@355 134 if (size != 1) {returnval = -1;};
mas01ik@355 135 if (testoneresult(&myadbqueryresult,0,"testfeature10",2,0,0)) {returnval = -1;};
mas01ik@355 136
mas01ik@355 137 ///echo testfeature10 > testkl.txt
mas01ik@355 138 makekeylistfile("testkl.txt","testfeature10");
mas01ik@355 139
mas01ik@355 140 ///${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -K testkl.txt -r 1 > testoutput
mas01ik@355 141 ///echo testfeature10 2 0 0 > test-expected-output
mas01ik@355 142 ///cmp testoutput test-expected-output
mas01ik@355 143 myadbquery.querytype="sequence";
mas01ik@355 144 myadbquery.feature="testquery";
mas01ik@355 145 myadbquery.keylist="testkl.txt";
mas01ik@355 146 myadbquery.sequencelength="1";
mas01ik@355 147 myadbquery.resultlength="1";
mas01ik@355 148 audiodb_query(mydbp,&myadbquery,&myadbqueryresult);
mas01ik@355 149
mas01ik@355 150 size=myadbqueryresult.sizeRlist;
mas01ik@355 151 //dump_query(&myadbquery,&myadbqueryresult);
mas01ik@355 152
mas01ik@355 153 /* check the test values */
mas01ik@355 154 if (size != 1) {returnval = -1;};
mas01ik@355 155 if (testoneresult(&myadbqueryresult,0,"testfeature10",2,0,0)) {returnval = -1;};
mas01ik@355 156
mas01ik@355 157 ///echo "query point (0.5,0.0)"
mas01ik@355 158 ///intstring 2 > testquery
mas01ik@355 159 ///floatstring 0.5 0 >> testquery
mas01ik@355 160 ivals[0]=2;
mas01ik@355 161 dvals[0]=0.5; dvals[1]=0.0;
mas01ik@355 162 maketestfile("testquery",ivals,dvals,2);
mas01ik@355 163
mas01ik@355 164 ///${AUDIODB} -d testdb -Q sequence -l 1 -f testquery > testoutput
mas01ik@355 165 ///echo testfeature10 0 0 0 > test-expected-output
mas01ik@355 166 ///echo testfeature01 2 0 0 >> test-expected-output
mas01ik@355 167 ///cmp testoutput test-expected-output
mas01ik@355 168 myadbquery.querytype="sequence";
mas01ik@355 169 myadbquery.feature="testquery";
mas01ik@355 170 myadbquery.keylist=NULL;
mas01ik@355 171 myadbquery.sequencelength="1";
mas01ik@355 172 myadbquery.resultlength=NULL;
mas01ik@355 173 audiodb_query(mydbp,&myadbquery,&myadbqueryresult);
mas01ik@355 174
mas01ik@355 175 size=myadbqueryresult.sizeRlist;
mas01ik@355 176 //dump_query(&myadbquery,&myadbqueryresult);
mas01ik@355 177
mas01ik@355 178 /* check the test values */
mas01ik@355 179 if (size != 2) {returnval = -1;};
mas01ik@355 180 if (testoneresult(&myadbqueryresult,0,"testfeature10",0,0,0)) {returnval = -1;};
mas01ik@355 181 if (testoneresult(&myadbqueryresult,1,"testfeature01",2,0,0)) {returnval = -1;};
mas01ik@355 182
mas01ik@355 183 ///${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -K /dev/null > testoutput
mas01ik@355 184 ///cat /dev/null > test-expected-output
mas01ik@355 185 ///cmp testoutput test-expected-output
mas01ik@355 186 myadbquery.querytype="sequence";
mas01ik@355 187 myadbquery.feature="testquery";
mas01ik@355 188 myadbquery.keylist="/dev/null";
mas01ik@355 189 myadbquery.sequencelength="1";
mas01ik@355 190 myadbquery.resultlength=NULL;
mas01ik@355 191 audiodb_query(mydbp,&myadbquery,&myadbqueryresult);
mas01ik@355 192
mas01ik@355 193 size=myadbqueryresult.sizeRlist;
mas01ik@355 194 //dump_query(&myadbquery,&myadbqueryresult);
mas01ik@355 195
mas01ik@355 196 /* check the test values */
mas01ik@355 197 if (size != 0) {returnval = -1;};
mas01ik@355 198
mas01ik@355 199 ///echo testfeature10 > testkl.txt
mas01ik@355 200 makekeylistfile("testkl.txt","testfeature10");
mas01ik@355 201
mas01ik@355 202 ///${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -K testkl.txt > testoutput
mas01ik@355 203 ///echo testfeature10 0 0 0 > test-expected-output
mas01ik@355 204 //cmp testoutput test-expected-output
mas01ik@355 205 myadbquery.querytype="sequence";
mas01ik@355 206 myadbquery.feature="testquery";
mas01ik@355 207 myadbquery.keylist="testkl.txt";
mas01ik@355 208 myadbquery.sequencelength="1";
mas01ik@355 209 myadbquery.resultlength=NULL;
mas01ik@355 210 audiodb_query(mydbp,&myadbquery,&myadbqueryresult);
mas01ik@355 211
mas01ik@355 212 size=myadbqueryresult.sizeRlist;
mas01ik@355 213 //dump_query(&myadbquery,&myadbqueryresult);
mas01ik@355 214
mas01ik@355 215 /* check the test values */
mas01ik@355 216 if (size != 1) {returnval = -1;};
mas01ik@355 217 if (testoneresult(&myadbqueryresult,0,"testfeature10",0,0,0)) {returnval = -1;};
mas01ik@355 218
mas01ik@355 219
mas01ik@355 220 ///echo testfeature01 > testkl.txt
mas01ik@355 221 makekeylistfile("testkl.txt","testfeature01");
mas01ik@355 222
mas01ik@355 223 ///${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -K testkl.txt > testoutput
mas01ik@355 224 ///echo testfeature01 2 0 0 > test-expected-output
mas01ik@355 225 ///cmp testoutput test-expected-output
mas01ik@355 226 myadbquery.querytype="sequence";
mas01ik@355 227 myadbquery.feature="testquery";
mas01ik@355 228 myadbquery.keylist="testkl.txt";
mas01ik@355 229 myadbquery.sequencelength="1";
mas01ik@355 230 myadbquery.resultlength=NULL;
mas01ik@355 231 audiodb_query(mydbp,&myadbquery,&myadbqueryresult);
mas01ik@355 232
mas01ik@355 233 size=myadbqueryresult.sizeRlist;
mas01ik@355 234 //dump_query(&myadbquery,&myadbqueryresult);
mas01ik@355 235
mas01ik@355 236 /* check the test values */
mas01ik@355 237 if (size != 1) {returnval = -1;};
mas01ik@355 238 if (testoneresult(&myadbqueryresult,0,"testfeature01",2,0,0)) {returnval = -1;};
mas01ik@355 239
mas01ik@355 240 ///echo testfeature01 > testkl.txt
mas01ik@355 241 makekeylistfile("testkl.txt","testfeature01");
mas01ik@355 242
mas01ik@355 243 ///${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -K testkl.txt -r 1 > testoutput
mas01ik@355 244 ///echo testfeature01 2 0 0 > test-expected-output
mas01ik@355 245 ///cmp testoutput test-expected-output
mas01ik@355 246 myadbquery.querytype="sequence";
mas01ik@355 247 myadbquery.feature="testquery";
mas01ik@355 248 myadbquery.keylist="testkl.txt";
mas01ik@355 249 myadbquery.sequencelength="1";
mas01ik@355 250 myadbquery.resultlength="1";
mas01ik@355 251 audiodb_query(mydbp,&myadbquery,&myadbqueryresult);
mas01ik@355 252
mas01ik@355 253 size=myadbqueryresult.sizeRlist;
mas01ik@355 254 //dump_query(&myadbquery,&myadbqueryresult);
mas01ik@355 255
mas01ik@355 256 /* check the test values */
mas01ik@355 257 if (size != 1) {returnval = -1;};
mas01ik@355 258 if (testoneresult(&myadbqueryresult,0,"testfeature01",2,0,0)) {returnval = -1;};
mas01ik@355 259
mas01ik@355 260
mas01ik@355 261
mas01ik@355 262 //printf("returnval:%d\n",returnval);
mas01ik@355 263
mas01ik@355 264 return(returnval);
mas01ik@355 265 }
mas01ik@355 266