Mercurial > hg > audiodb
annotate tests/test-utils.sh @ 48:a7aad4c50cb9
Factor out some common utilities and setup code into test-utils.sh, and
source that file within each run-test file.
author | mas01cr |
---|---|
date | Tue, 18 Sep 2007 09:24:52 +0000 |
parents | |
children | f258a0258755 |
rev | line source |
---|---|
mas01cr@48 | 1 # no shebang line: this file should be sourced by run-test.sh files |
mas01cr@48 | 2 |
mas01cr@48 | 3 trap "exit 1" ERR |
mas01cr@48 | 4 |
mas01cr@48 | 5 if [ -z ${AUDIODB} ]; then |
mas01cr@48 | 6 AUDIODB=../../audioDB |
mas01cr@48 | 7 fi |
mas01cr@48 | 8 |
mas01cr@48 | 9 # FIXME: maybe generalize to multiple arguments? Also, implement it |
mas01cr@48 | 10 # properly, rather than just for a few floats that we know how to |
mas01cr@48 | 11 # encode. This might involve writing some C code, as Bash doesn't do |
mas01cr@48 | 12 # Floating Point. (scanf() is probably enough). |
mas01cr@48 | 13 |
mas01cr@48 | 14 floatstring() { |
mas01cr@48 | 15 for arg in "$@"; do |
mas01cr@48 | 16 case ${arg} in |
mas01cr@48 | 17 0) |
mas01cr@48 | 18 printf "\x00\x00\x00\x00\x00\x00\x00\x00";; |
mas01cr@48 | 19 0.5) |
mas01cr@48 | 20 printf "\x00\x00\x00\x00\x00\x00\xe0\x3f";; |
mas01cr@48 | 21 1) |
mas01cr@48 | 22 printf "\x00\x00\x00\x00\x00\x00\xf0\x3f";; |
mas01cr@48 | 23 *) |
mas01cr@48 | 24 echo "bad arg to floatstring(): ${arg}" |
mas01cr@48 | 25 exit 1;; |
mas01cr@48 | 26 esac |
mas01cr@48 | 27 done |
mas01cr@48 | 28 } |
mas01cr@48 | 29 |
mas01cr@48 | 30 # FIXME: likewise. And endianness issues (which are a reflection of |
mas01cr@48 | 31 # the endianness of audioDB as of 2007-09-18, unfortunately). |
mas01cr@48 | 32 |
mas01cr@48 | 33 intstring() { |
mas01cr@48 | 34 # works up to 9 for now |
mas01cr@48 | 35 if [ $1 -ge 10 ]; then echo "intstring() arg too large: ${1}"; exit 1; fi |
mas01cr@48 | 36 printf "%b\x00\x00\x00" "\\x${1}" |
mas01cr@48 | 37 } |