[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
make check and C++ exceptions
From: |
Steve Hutton |
Subject: |
make check and C++ exceptions |
Date: |
Tue, 2 Sep 2003 19:24:06 -0400 |
User-agent: |
KMail/1.5.1 |
Make check succeeds (as expected) when my test program
returns 0, but it fails (not what I expected) when the same
test program has thrown and caught a C++ exception.
For example, only the first of the following two programs
passes make check, but a simple bash script verifies that
both programs exit with status 0
$ more return0nothrow.cpp
int main()
{
return 0;
}
$ more return0throw.cpp
#include <stdexcept>
#include <iostream>
void throwError()
{
throw std::runtime_error("hello");
}
int main()
{
try
{
throwError();
}
catch(std::exception& e)
{
std::cout<<"cought: "<<e.what()<<std::endl;
}
return 0;
}
$ make check
make return0nothrow return0throw
make[1]: Entering directory `/home/shutton/dev/make_check'
if g++ -DPACKAGE_NAME=\"thrownothrow\" -DPACKAGE_TARNAME=\"thrownothrow\"
-DPACKAGE_VERSION=\"0.1\" -DPACKAGE_STRING=\"thrownothrow\ 0.1\"
-DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"thrownothrow\" -DVERSION=\"0.1\"
-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1
-DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1
-DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -I. -I. -g -O2 -MT
return0nothrow.o -MD -MP -MF ".deps/return0nothrow.Tpo" \
-c -o return0nothrow.o `test -f 'return0nothrow.cpp' || echo
'./'`return0nothrow.cpp; \
then mv -f ".deps/return0nothrow.Tpo" ".deps/return0nothrow.Po"; \
else rm -f ".deps/return0nothrow.Tpo"; exit 1; \
fi
/bin/sh ./libtool --mode=link g++ -g -O2 -o return0nothrow
return0nothrow.o
mkdir .libs
g++ -g -O2 -o return0nothrow return0nothrow.o
if g++ -DPACKAGE_NAME=\"thrownothrow\" -DPACKAGE_TARNAME=\"thrownothrow\"
-DPACKAGE_VERSION=\"0.1\" -DPACKAGE_STRING=\"thrownothrow\ 0.1\"
-DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"thrownothrow\" -DVERSION=\"0.1\"
-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1
-DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1
-DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -I. -I. -g -O2 -MT
return0throw.o -MD -MP -MF ".deps/return0throw.Tpo" \
-c -o return0throw.o `test -f 'return0throw.cpp' || echo
'./'`return0throw.cpp; \
then mv -f ".deps/return0throw.Tpo" ".deps/return0throw.Po"; \
else rm -f ".deps/return0throw.Tpo"; exit 1; \
fi
/bin/sh ./libtool --mode=link g++ -g -O2 -o return0throw return0throw.o
g++ -g -O2 -o return0throw return0throw.o
make[1]: Leaving directory `/home/shutton/dev/make_check'
make check-TESTS
make[1]: Entering directory `/home/shutton/dev/make_check'
PASS: return0nothrow
FAIL: return0throw
===================
1 of 2 tests failed
===================
make[1]: *** [check-TESTS] Error 1
make[1]: Leaving directory `/home/shutton/dev/make_check'
make: *** [check-am] Error 2
$ more Makefile.am
check_PROGRAMS = return0nothrow return0throw
TESTS = $(check_PROGRAMS)
return0throw_SOURCES = return0throw.cpp
return0nothrow_SOURCES = return0nothrow.cpp
$ more test.sh
#!/bin/sh
./return0nothrow
echo "return0nothrow returned $?"
./return0throw
echo "return0throw returned $?"
$ ./test.sh
return0nothrow returned 0
cought: hello
return0throw returned 0
Any ideas what may be going wrong here? Here is the
make check target as it exists in my Makefile:
check-TESTS: $(TESTS)
@failed=0; all=0; xfail=0; xpass=0; skip=0; \
srcdir=$(srcdir); export srcdir; \
list='$(TESTS)'; \
if test -n "$$list"; then \
for tst in $$list; do \
if test -f ./$$tst; then dir=./; \
elif test -f $$tst; then dir=; \
else dir="$(srcdir)/"; fi; \
if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
all=`expr $$all + 1`; \
case " $(XFAIL_TESTS) " in \
*" $$tst "*) \
xpass=`expr $$xpass + 1`; \
failed=`expr $$failed + 1`; \
echo "XPASS: $$tst"; \
;; \
*) \
echo "PASS: $$tst"; \
;; \
esac; \
elif test $$? -ne 77; then \
all=`expr $$all + 1`; \
case " $(XFAIL_TESTS) " in \
*" $$tst "*) \
xfail=`expr $$xfail + 1`; \
echo "XFAIL: $$tst"; \
;; \
*) \
failed=`expr $$failed + 1`; \
echo "FAIL: $$tst"; \
;; \
esac; \
else \
skip=`expr $$skip + 1`; \
echo "SKIP: $$tst"; \
fi; \
done; \
if test "$$failed" -eq 0; then \
if test "$$xfail" -eq 0; then \
banner="All $$all tests passed"; \
else \
banner="All $$all tests behaved as expected ($$xfail expected
failures)"; \
fi; \
else \
if test "$$xpass" -eq 0; then \
banner="$$failed of $$all tests failed"; \
else \
banner="$$failed of $$all tests did not behave as expected
($$xpass
unexpected passes)"; \
fi; \
fi; \
dashes="$$banner"; \
skipped=""; \
if test "$$skip" -ne 0; then \
skipped="($$skip tests were not run)"; \
test `echo "$$skipped" | wc -c` -gt `echo "$$banner" | wc -c` && \
dashes="$$skipped"; \
fi; \
report=""; \
if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
report="Please report to $(PACKAGE_BUGREPORT)"; \
test `echo "$$report" | wc -c` -gt `echo "$$banner" | wc -c` && \
dashes="$$report"; \
fi; \
dashes=`echo "$$dashes" | sed s/./=/g`; \
echo "$$dashes"; \
echo "$$banner"; \
test -n "$$skipped" && echo "$$skipped"; \
test -n "$$report" && echo "$$report"; \
echo "$$dashes"; \
test "$$failed" -eq 0; \
else :; fi
Thanks,
Steve