annotate tests/test-utils.sh @ 548:e18843dc0aea

Implement a rudimentary API for audioDB::liszt The API is rudimentary because we've dropped support for the incremental retrieval of tracks and their number of vectors (at the API level; the SOAP and command-line support is still there -- no changes should be visible). This is potentially bad for the large-scale databases, of course; one million tracks will take of the order of 16MB of RAM, more if I'm unlucky about how std::string.c_str() is implemented. Both this liszt operation and querying (and sampling, forthcoming...) would benefit from a `cursor-like' interface to retrieval results: for an API like that, instead of getting a struct with the data there, you get a cookie with which you can ask the database for successive results. This would be neat for all sorts of reasons. In the meantime, at least this change fixes SOAP memory leaks related to liszt. Make liszt.o part of LIBOBJS rather than ordinary OBJS, so that the liszt functionality is actually compiled into the library. Add a test for this library functionality; also modify the command-line test file to run the SOAP server on its own port.
author mas01cr
date Wed, 11 Feb 2009 12:38:03 +0000
parents e21cc48ddf4d
children d5ada9532a40
rev   line source
mas01cr@48 1 # no shebang line: this file should be sourced by run-test.sh files
mas01cr@48 2
mas01cr@101 3 set -E
mas01cr@101 4
mas01cr@48 5 trap "exit 1" ERR
mas01cr@48 6
mas01cr@198 7 if [ -z "${AUDIODB}" ]; then
mas01cr@48 8 AUDIODB=../../audioDB
mas01cr@48 9 fi
mas01cr@48 10
mas01cr@48 11 # FIXME: maybe generalize to multiple arguments? Also, implement it
mas01cr@48 12 # properly, rather than just for a few floats that we know how to
mas01cr@48 13 # encode. This might involve writing some C code, as Bash doesn't do
mas01cr@48 14 # Floating Point. (scanf() is probably enough).
mas01cr@48 15
mas01cr@54 16 expect_clean_error_exit() {
mas01cr@54 17 trap - ERR
mas01cr@54 18 "$@"
mas01cr@54 19 exit_code=$?
mas01cr@54 20 trap "exit 1" ERR
mas01cr@54 21 if [ $exit_code -eq 0 ]; then
mas01cr@54 22 exit 1
mas01cr@54 23 elif [ $exit_code -ge 126 ]; then
mas01cr@54 24 exit 1
mas01cr@54 25 fi
mas01cr@54 26 }
mas01cr@54 27
mas01cr@48 28 floatstring() {
mas01cr@48 29 for arg in "$@"; do
mas01cr@48 30 case ${arg} in
mas01cr@48 31 0)
mas01cr@48 32 printf "\x00\x00\x00\x00\x00\x00\x00\x00";;
mas01cr@193 33 -0.5)
mas01cr@193 34 printf "\x00\x00\x00\x00\x00\x00\xe0\xbf";;
mas01cr@48 35 0.5)
mas01cr@48 36 printf "\x00\x00\x00\x00\x00\x00\xe0\x3f";;
mas01cr@193 37 -1)
mas01cr@193 38 printf "\x00\x00\x00\x00\x00\x00\xf0\xbf";;
mas01cr@48 39 1)
mas01cr@48 40 printf "\x00\x00\x00\x00\x00\x00\xf0\x3f";;
mas01cr@48 41 *)
mas01cr@48 42 echo "bad arg to floatstring(): ${arg}"
mas01cr@48 43 exit 1;;
mas01cr@48 44 esac
mas01cr@48 45 done
mas01cr@48 46 }
mas01cr@48 47
mas01cr@48 48 # FIXME: likewise. And endianness issues (which are a reflection of
mas01cr@48 49 # the endianness of audioDB as of 2007-09-18, unfortunately).
mas01cr@48 50
mas01cr@48 51 intstring() {
mas01cr@48 52 # works up to 9 for now
mas01cr@48 53 if [ $1 -ge 10 ]; then echo "intstring() arg too large: ${1}"; exit 1; fi
mas01cr@48 54 printf "%b\x00\x00\x00" "\\x${1}"
mas01cr@48 55 }
mas01cr@87 56
mas01cr@87 57 # Web services utilities
mas01cr@87 58 start_server() {
mas01cr@87 59 $1 -s $2 &
mas01cr@87 60 # HACK: deal with race on process creation
mas01cr@87 61 sleep 1
mas01cr@101 62 trap 'kill $!; exit 1' ERR
mas01cr@87 63 }
mas01cr@87 64
mas01cr@87 65 stop_server() {
mas01cr@198 66 grep "${AUDIODB}" /proc/$1/cmdline > /dev/null
mas01cr@87 67 kill $1
mas01cr@87 68 # HACK: deal with race on process exit
mas01cr@87 69 sleep 1
mas01cr@87 70 expect_clean_error_exit grep ${AUDIODB} /proc/$1/cmdline
mas01cr@87 71 }
mas01cr@87 72
mas01cr@87 73 check_server() {
mas01cr@198 74 grep "${AUDIODB}" /proc/$1/cmdline > /dev/null
mas01cr@87 75 }
mas01cr@94 76
mas01cr@95 77 expect_client_failure() {
mas01cr@94 78 # FIXME: work out whether and how the client should report server
mas01cr@94 79 # errors. At present, the client exits with a zero exit code.
mas01cr@94 80 "$@"
mas01cr@94 81 }