Mercurial > hg > audiodb
view libtests/run-tests.sh @ 392:78fed0d4c108 api-inversion
Include some necessary information in struct adb.
Now the struct adb contains a database fd, the flags used to open that
fd (so that we can later tell if it was for write or not) and a database
header pointer.
audiodb_open() is now responsible for filling in all of that
information. To do that, it needs to take an open(2) flag; that's good,
because it means that the call to open(2) is no longer invoking
undefined behaviour. (Also, the previous version of audiodb_open()
leaked an fd). Unfortunately, that means we have broken ABI and API
compatibility. (Fortunately, we have fewer than 12 users).
Use audiodb_open() in audioDB::initDBHeader().
We've temporarily(?) put acquire_lock(int, bool) in the API header; that
means we need to include <stdbool.h> and compile C files with -std=c99.
Do so.
Make audiodb_close() free resources allocated by audiodb_open().
Include a struct adb * field in the audioDB C++ object...
... which lets us actually implement memory-correctness, by
audiodb_close()ing the database in audioDB::cleanup().
[ The lock is, I think, correctly disposed of; man fcntl(2) on Linux
says that the locks are released once any file descriptor relating to
the file is closed, and we close the fd in audiodb_close(). ]
author | mas01cr |
---|---|
date | Mon, 24 Nov 2008 15:42:15 +0000 |
parents | cd63493c32a9 |
children | 4cb6c611f812 342822c2d49a |
line wrap: on
line source
#! /bin/bash AUDIODB=../../${EXECUTABLE:-audioDB} export AUDIODB if [ -x ${AUDIODB#../} ]; then : else echo Cannot execute audioDB: ${AUDIODB#../} exit 1 fi if [ "$1" = "--full" ]; then pattern="[0-9][0-9][0-9][0-9]*" else pattern="[0-8][0-9][0-9][0-9]*" fi for file in ${pattern}; do if [ -d ${file} ]; then if [ /bin/true ]; then echo -n Running test ${file} if [ -f ${file}/short-description ]; then awk '{ printf(" (%s)",$0) }' < ${file}/short-description fi echo -n : (cd ${file} && make -f ../libtest.mk >/dev/null 2>&1 && ./test1 > test.out 2> test.err && exit 104) EXIT_STATUS=$? if [ ${EXIT_STATUS} -eq 14 ]; then echo " n/a." elif [ ${EXIT_STATUS} -ne 104 ]; then echo " failed (exit status ${EXIT_STATUS})." FAILED=true else echo " success." fi else echo Skipping test ${file} fi fi done if [ -z "${FAILED}" ]; then exit 0 else exit 1 fi