[linux-audio-dev] LADSPA valgrind test wrapper
Steve Harris
S.W.Harris at ecs.soton.ac.uk
Tue Feb 25 09:44:00 UTC 2003
I hacked up a shell script [attached] to valgrind LADSPA .so files. It
will report leaks, bufferoverruns, reads from unitialised variables and
so on, but it doesn't totally exercise the plugin so it may miss some
things.
Obviously it helps if you rebuild with -g on and it works best with gcc3
(better inline debugging).
You can't just "valgrind applyplugin ..." becuase valgrind doesn't chase the
dlloaded objects and applyplugin is full of memory errors and leaks :)
Usage: ladspa-valgrind <plugin.so>+
I dont recommend running it on my current plugin set ;)
Requires gcc and valgrind 1.0+
- Steve
-------------- next part --------------
#!/bin/sh
TMPDIR="/tmp/lv$$"
VALGRIND=`which valgrind`
mkdir -p "$TMPDIR"
if test -x "$VALGRIND"; then
echo "using $VALGRIND"
echo
else
echo "$0: can't find valgrind binary"
exit
fi
cat > "$TMPDIR/testhost.c" <<EOB
#include <stdio.h>
#include <ladspa.h>
int main()
{
const LADSPA_Descriptor *desc;
LADSPA_Handle *handle;
unsigned int i, j;
LADSPA_Data val;
for (i=0; (desc = ladspa_descriptor(i)); i++) {
handle = desc->instantiate(desc, 44100);
if (desc->activate) {
desc->activate(handle);
}
for (j=0; j<desc->PortCount; j++) {
desc->connect_port(handle, j, &val);
}
val = 0.0f;
desc->run(handle, 1);
if (desc->deactivate) {
desc->deactivate(handle);
}
desc->cleanup(handle);
}
return 0;
}
EOB
for i in $*; do
gcc -g -o "$TMPDIR/vtest.bin" "$TMPDIR/testhost.c" $i
$VALGRIND -q --leak-check=yes --show-reachable=yes "$TMPDIR/vtest.bin" 2>&1 | sed 's/^==[0-9]*==//' > "$TMPDIR/test.log"
if test `cat "$TMPDIR/test.log" | wc -l` -gt 2; then
echo fail: `basename $i`
cat "$TMPDIR/test.log"
else
echo ok: `basename $i`
fi
done
rm -f "$TMPDIR/testhost.c" "$TMPDIR/vtest.bin" "$TMPDIR/test.log"
rmdir "$TMPDIR"
More information about the Linux-audio-dev
mailing list