annotate tests/0040/run-test.sh @ 400:8c7453fb5bd9 api-inversion

Invert audioDB::power_flag / audiodb_power() Here the exciting discovery is that the mmap(), memcpy(), munmap() sequence is in fact not safe. In principle an msync() call should be inserted before unmapping for in-core changes to mmap()ed files to be flushed to disk. In this case we work around the problem entirely, by not mmap()ing anything and doing everything with file descriptors. Amusingly, that's probably not desperately safe either, this time because we have to move the file descriptor position (which is also a shared resource). dup() doesn't save us, as the duplicate file descriptor shares a file position. This applies also to the filling of data_buffer in the query loop, and in fact basically any call to lseek(), which is why I'm not fixing it now. Solution: if you have multiple threads all acting at once on a single database, do one audiodb_open() per thread, for now at least.
author mas01cr
date Thu, 27 Nov 2008 16:22:52 +0000
parents a0493f861531
children
rev   line source
mas01mc@327 1 #! /bin/bash
mas01mc@327 2
mas01mc@327 3 . ../test-utils.sh
mas01mc@327 4
mas01mc@327 5 if [ -f testdb ]; then rm -f testdb; fi
mas01mc@327 6
mas01mc@327 7 ${AUDIODB} -d testdb -N
mas01mc@327 8
mas01mc@327 9 intstring 2 > testfeature
mas01mc@327 10 floatstring 0 1 >> testfeature
mas01mc@327 11 floatstring 1 0 >> testfeature
mas01mc@327 12 floatstring 1 0 >> testfeature
mas01mc@327 13 floatstring 0 1 >> testfeature
mas01mc@327 14
mas01mc@327 15 intstring 1 > testpower
mas01mc@327 16 floatstring -0.5 >> testpower
mas01mc@327 17 floatstring -1 >> testpower
mas01mc@327 18 floatstring -1 >> testpower
mas01mc@327 19 floatstring -0.5 >> testpower
mas01mc@327 20
mas01mc@327 21 expect_clean_error_exit ${AUDIODB} -d testdb -I -f testfeature -w testpower
mas01mc@327 22 ${AUDIODB} -d testdb -P
mas01mc@327 23 expect_clean_error_exit ${AUDIODB} -d testdb -I -f testfeature
mas01mc@327 24 ${AUDIODB} -d testdb -I -f testfeature -w testpower
mas01mc@327 25
mas01mc@327 26 # sequence queries require L2NORM
mas01mc@327 27 ${AUDIODB} -d testdb -L
mas01mc@327 28
mas01mc@327 29 echo "query points (0.0,0.5),(0.0,0.5),(0.5,0.0)"
mas01mc@327 30 intstring 2 > testquery
mas01mc@327 31 floatstring 0 0.5 >> testquery
mas01mc@327 32 floatstring 0 0.5 >> testquery
mas01mc@327 33 floatstring 0.5 0 >> testquery
mas01mc@327 34
mas01mc@327 35 # LSH Indexing tests
mas01mc@327 36
mas01mc@327 37 # Indexing requires a radius (-R)
mas01mc@327 38 expect_clean_error_exit ${AUDIODB} -d testdb -X -l 1
mas01mc@327 39
mas01mc@327 40 # Index with default LSH params
mas01mc@327 41 ${AUDIODB} -d testdb -X -l 1 -R 1
mas01mc@327 42
mas01mc@327 43 # Query using the index
mas01mc@332 44
mas01mc@327 45 ${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -w testpower -R 1 > testoutput
mas01mc@327 46 echo testfeature 1 > test-expected-output
mas01mc@327 47 cmp testoutput test-expected-output
mas01mc@327 48
mas01mc@327 49 ${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -w testpower -p 0 -R 1 > testoutput
mas01mc@327 50 echo testfeature 1 > test-expected-output
mas01mc@327 51 cmp testoutput test-expected-output
mas01mc@327 52
mas01mc@327 53 ${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -w testpower -p 1 -R 1 > testoutput
mas01mc@327 54 echo testfeature 1 > test-expected-output
mas01mc@327 55 cmp testoutput test-expected-output
mas01mc@327 56
mas01mc@332 57 ${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -w testpower -e -R 1 > testoutput
mas01mc@332 58 echo testfeature 3 > test-expected-output
mas01mc@332 59 cmp testoutput test-expected-output
mas01mc@332 60
mas01mc@332 61 ${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -w testpower -e -R 1 --lsh_exact > testoutput
mas01mc@332 62 echo testfeature 3 > test-expected-output
mas01mc@332 63 cmp testoutput test-expected-output
mas01mc@332 64
mas01mc@327 65 # make index, sequenceLength=2
mas01mc@327 66 ${AUDIODB} -d testdb -X -l 2 -R 1
mas01mc@327 67
mas01mc@327 68 # query, sequenceLength=2
mas01mc@327 69 ${AUDIODB} -d testdb -Q sequence -l 2 -f testquery -w testpower -p 0 -R 1 > testoutput
mas01mc@327 70 echo testfeature 1 > test-expected-output
mas01mc@327 71 cmp testoutput test-expected-output
mas01mc@327 72
mas01mc@327 73 exit 104