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