mirror of
https://github.com/gnustep/tools-make.git
synced 2025-04-23 22:33:28 +00:00
Make debugging tests easy
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/tools/make/trunk@32281 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4da85e8786
commit
9e82abe4db
4 changed files with 41 additions and 22 deletions
|
@ -1,8 +1,10 @@
|
|||
2011-01-22 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* TestFramework/gnustep-tests:
|
||||
* TestFramework/Testing.h:
|
||||
* TestFramework/README:
|
||||
Make it easy to break at the start of a particular failed test.
|
||||
Add --debug option to automatically launch gdb to debug a test.
|
||||
|
||||
2011-01-21 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
|
|
|
@ -113,13 +113,17 @@ executable of the failed test will be available (unless the test file
|
|||
failed to even compile of course). In this case, any core dump file will
|
||||
also be left available.
|
||||
|
||||
As a convenience for debugging, the tests use a start() function in which
|
||||
As a convenience for debugging, the tests use a testStart() function in which
|
||||
they set the line number of the test, so you can stop in that function and
|
||||
upon stepping out of it the debugger will be examining the specified test.
|
||||
eg.
|
||||
(gdb) break start if line == 42
|
||||
(gdb) break testStart if line == 42
|
||||
(gdb) run
|
||||
|
||||
You can use the --debug command line option in conjunction with the --failfast
|
||||
option to have testing stopped at the first failure and the gdb debugger
|
||||
automatically launched to debug the failed testcase with a breakpoint set
|
||||
in the testStart() fucntion for that testcase.
|
||||
|
||||
Writing Tests
|
||||
-------------
|
||||
|
|
|
@ -107,15 +107,15 @@ static void pass(int testPassed, const char *format, ...)
|
|||
#endif
|
||||
}
|
||||
|
||||
/* The start() function is used by the PASS macros to record the line number
|
||||
/* The testStart() function is used by the PASS macros to record the line number
|
||||
* in the source code at which the test occurs. This value is then available
|
||||
* in the testLineNumber variable.
|
||||
* This is also useful when debugging ... you can set a breakpoint in the
|
||||
* start() function for the line number reported in a test failure and
|
||||
* testStart() function for the line number reported in a test failure and
|
||||
* have the debugger stop in just the right place.
|
||||
*/
|
||||
static void start(unsigned line) __attribute__((unused));
|
||||
static void start(unsigned line)
|
||||
static void testStart(unsigned line) __attribute__((unused));
|
||||
static void testStart(unsigned line)
|
||||
{
|
||||
testLineNumber = line;
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ static void unsupported(const char *format, ...)
|
|||
int _cond; \
|
||||
id _tmp = testRaised; testRaised = nil; [_tmp release]; \
|
||||
[[NSGarbageCollector defaultCollector] collectExhaustively]; \
|
||||
start(__LINE__); \
|
||||
testStart(__LINE__); \
|
||||
_cond = (int)(expression); \
|
||||
[[NSGarbageCollector defaultCollector] collectExhaustively]; \
|
||||
pass(_cond, "%s:%d ... " format, __FILE__, __LINE__, ## __VA_ARGS__); \
|
||||
|
@ -205,7 +205,7 @@ static void unsupported(const char *format, ...)
|
|||
id _exp; \
|
||||
id _tmp = testRaised; testRaised = nil; [_tmp release]; \
|
||||
[[NSGarbageCollector defaultCollector] collectExhaustively]; \
|
||||
start(__LINE__); \
|
||||
testStart(__LINE__); \
|
||||
_obj = (id)(expression);\
|
||||
_exp = (id)(expect);\
|
||||
_cond = _obj == _exp || [_obj isEqual: _exp]; \
|
||||
|
@ -249,7 +249,7 @@ static void unsupported(const char *format, ...)
|
|||
NS_DURING \
|
||||
id _tmp = testRaised; testRaised = nil; [_tmp release]; \
|
||||
{ \
|
||||
start(__LINE__); \
|
||||
testStart(__LINE__); \
|
||||
code; \
|
||||
} \
|
||||
pass(0, "%s:%d ... " format, __FILE__, __LINE__, ## __VA_ARGS__); \
|
||||
|
@ -275,7 +275,7 @@ static void unsupported(const char *format, ...)
|
|||
NS_DURING \
|
||||
id _tmp = testRaised; testRaised = nil; [_tmp release]; \
|
||||
{ \
|
||||
start(__LINE__); \
|
||||
testStart(__LINE__); \
|
||||
code; \
|
||||
} \
|
||||
pass(1, "%s:%d ... " format, __FILE__, __LINE__, ## __VA_ARGS__); \
|
||||
|
|
|
@ -43,6 +43,8 @@ fi
|
|||
|
||||
GSTESTTOP="$GNUSTEP_MAKEFILES/TestFramework"
|
||||
export GSTESTTOP
|
||||
GSTESTDIR=`pwd`
|
||||
export GSTESTDIR
|
||||
|
||||
GSTESTMODE=normal
|
||||
|
||||
|
@ -54,6 +56,9 @@ do
|
|||
--clean)
|
||||
GSTESTMODE=clean
|
||||
;;
|
||||
--debug)
|
||||
GSTESTDBG="$GSTESTDIR/gdb.cmds"
|
||||
;;
|
||||
--documentation)
|
||||
echo
|
||||
echo "$0: Script to run the GNUstep testsuite"
|
||||
|
@ -75,8 +80,9 @@ do
|
|||
echo "Runs the specified tests, or any in subdirectories of the"
|
||||
echo "current directory if no arguments are given."
|
||||
echo "Use 'gnustep-tests --documentation' for full details."
|
||||
echo "Use 'gnustep-tests --failfast' to stop at the first failure."
|
||||
echo "Use 'gnustep-tests --clean' to remove old logs and leftover files."
|
||||
echo "Use 'gnustep-tests --failfast' to stop after the first failure."
|
||||
echo "Use 'gnustep-tests --failfast --debug' to debug the first failure."
|
||||
echo
|
||||
echo "Interpreting the output"
|
||||
echo "-----------------------"
|
||||
|
@ -88,8 +94,6 @@ do
|
|||
echo
|
||||
exit 0
|
||||
;;
|
||||
--debug | -d) # ignore for backward compatibility.
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
|
@ -98,8 +102,6 @@ do
|
|||
done
|
||||
|
||||
export GSTESTMODE
|
||||
GSTESTDIR=`pwd`
|
||||
export GSTESTDIR
|
||||
GSTESTLOG=$GSTESTDIR/tests.log
|
||||
export GSTESTLOG
|
||||
GSTESTSUM=$GSTESTDIR/tests.sum
|
||||
|
@ -222,7 +224,7 @@ build_and_run ()
|
|||
mkdir ./obj
|
||||
BUILD_CMD="$CC -o ./obj/$TESTNAME $TESTFILE $GSTESTFLAGS $GSTESTLIBS"
|
||||
CLEAN_CMD=echo
|
||||
RUN_CMD=./obj/$TESTNAME
|
||||
RUN_CMD="./obj/$TESTNAME"
|
||||
else
|
||||
BUILD_CMD="$MAKE_CMD $MAKEFLAGS debug=yes"
|
||||
CLEAN_CMD="$MAKE_CMD clean"
|
||||
|
@ -233,9 +235,9 @@ build_and_run ()
|
|||
rm -f GNUmakefile
|
||||
if test "$GSTESTMODE" = "failfast"
|
||||
then
|
||||
sed -e "s/@TESTNAME@/$TESTNAME/;s/@FILENAME@/$TESTFILE/;s/@FAILFAST@/-DFAILFAST=1/;s^@INCLUDEDIR@^$GSTESTTOP^" < $TEMPLATE > GNUmakefile
|
||||
sed -e "s/@TESTNAME@/$TESTNAME/;s/@FILENAME@/$TESTFILE/;s/@FAILFAST@/-DFAILFAST=1/;s^@INCLUDEDIR@^$GSTESTTOP^" < "$TEMPLATE" > GNUmakefile
|
||||
else
|
||||
sed -e "s/@TESTNAME@/$TESTNAME/;s/@FILENAME@/$TESTFILE/;s/@FAILFAST@//;s^@INCLUDEDIR@^$GSTESTTOP^" < $TEMPLATE > GNUmakefile
|
||||
sed -e "s/@TESTNAME@/$TESTNAME/;s/@FILENAME@/$TESTFILE/;s/@FAILFAST@//;s^@INCLUDEDIR@^$GSTESTTOP^" < "$TEMPLATE" > GNUmakefile
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -243,7 +245,7 @@ build_and_run ()
|
|||
then
|
||||
$CLEAN_CMD >/dev/null 2>&1
|
||||
rm -f GNUmakefile
|
||||
rm -rf obj core
|
||||
rm -rf obj core gdb.cmds
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
@ -288,7 +290,7 @@ build_and_run ()
|
|||
echo "Failed file: $TESTFILE aborted without running all tests!" >&2
|
||||
if test "$GSTESTMODE" = "failfast"
|
||||
then
|
||||
return 1
|
||||
return 2
|
||||
fi
|
||||
fi
|
||||
else
|
||||
|
@ -332,6 +334,17 @@ run_test_file ()
|
|||
echo $TESTFILE:
|
||||
extract $GSTESTSUM.tmp "^Failed build:" "^Failed file:" "^Failed set:" "^Failed test:"
|
||||
fi
|
||||
|
||||
if test "$RUNEXIT" = "2" -a x"$GSTESTDBG" != x
|
||||
then
|
||||
echo checking
|
||||
line=`grep '^Failed test:' "$GSTESTLOG.tmp" | sed -e 's/^Failed test:[^:]*:\([0-9][0-9]*\).*/\1/'`
|
||||
echo got $line
|
||||
echo "break start if line==$line" > "$GSTESTDBG"
|
||||
gdb "./obj/$TESTNAME" -x "$GSTESTDBG"
|
||||
rm -f "$GSTESTDBG"
|
||||
fi
|
||||
|
||||
return $RUNEXIT
|
||||
fi
|
||||
}
|
||||
|
@ -429,7 +442,7 @@ do
|
|||
|
||||
if test "$GSTESTMODE" = "clean"
|
||||
then
|
||||
rm -rf core obj GNUmakefile
|
||||
rm -rf core obj GNUmakefile gdb.cmds
|
||||
rm -f tests.tmp tests.sum.tmp tests.log.tmp
|
||||
rm -f tests.log tests.sum
|
||||
rm -f oldtests.log oldtests.sum
|
||||
|
@ -459,7 +472,7 @@ done
|
|||
|
||||
if test "$GSTESTMODE" = "clean"
|
||||
then
|
||||
rm -rf core obj GNUmakefile.tmp
|
||||
rm -rf core obj GNUmakefile.tmp gdb.cmds
|
||||
rm -f tests.tmp tests.sum.tmp tests.log.tmp
|
||||
rm -f tests.log tests.sum
|
||||
rm -f oldtests.log oldtests.sum
|
||||
|
|
Loading…
Reference in a new issue