Skip to content

Useful test scripts

jpf91 edited this page Jun 8, 2011 · 21 revisions

##Detecting a specific segfault ###Bash (Linux/Posix only) Note: This script expects a core dump to be written to a 'core' file. See ulimit for more information.

#!/bin/sh
BINARY="test" #the binary to test
SEGFUNC="_aaDelX" #the function where the segfault occurs (as in the gdb backtrace!)
dmd test.d -of$BINARY 2>/dev/null #Your compile command

echo $(sh -c "./$BINARY" 2>&1) | grep -q "Segmentation fault" #Make sure there was a segfault
if [ $? -eq 0 ]
then
    gdb --batch -ex 'backtrace' $BINARY core 2>&1 | grep -q "#0 .* in $SEGFUNC"
    if [ $? -eq 0 ]
    then
        return 0
    else
        return 1
    fi
else
    return 1
fi

Clone this wiki locally