Show backtraces for core files from CppunitTests, too
Change-Id: Idff2831913b6fb6e5b522ae36fffeb345e3a1140
This commit is contained in:
@@ -28,39 +28,34 @@
|
|||||||
# instead of those above.
|
# instead of those above.
|
||||||
#
|
#
|
||||||
|
|
||||||
# we expect our work directory to be where soffice had been started
|
EXECUTABLE=${1}
|
||||||
# $(1) should be the path to the executable
|
COREDIR=${2}
|
||||||
|
|
||||||
OFFICEFILE=${1}
|
if test -n "$(which gdb)"
|
||||||
WORKDIR=${2}
|
|
||||||
|
|
||||||
if test -n "`which gdb`"
|
|
||||||
then
|
then
|
||||||
if test `ls "${WORKDIR}"/core* 2>/dev/null | wc -l` -eq 1
|
if test "$(ls "$COREDIR"/core* 2>/dev/null | wc -l)" -eq 1
|
||||||
then
|
then
|
||||||
COREFILE=`ls "${WORKDIR}"/core*`
|
COREFILE=$(ls "$COREDIR"/core*)
|
||||||
echo
|
echo
|
||||||
echo "It seems like soffice.bin crashed during the test excution!"
|
echo "It looks like ${EXECUTABLE} generated a core file at ${COREFILE}"
|
||||||
echo "Found a core dump at ${COREFILE}"
|
echo "Backtraces:"
|
||||||
echo "Stacktrace:"
|
|
||||||
GDBCOMMANDFILE=`mktemp`
|
GDBCOMMANDFILE=`mktemp`
|
||||||
echo "thread apply all bt" > ${GDBCOMMANDFILE}
|
echo "thread apply all backtrace" > "$GDBCOMMANDFILE"
|
||||||
gdb -x $GDBCOMMANDFILE --batch ${OFFICEFILE}.bin ${COREFILE}
|
gdb -x "$GDBCOMMANDFILE" --batch "$EXECUTABLE" "$COREFILE"
|
||||||
rm ${GDBCOMMANDFILE}
|
rm "$GDBCOMMANDFILE"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 0
|
||||||
else
|
else
|
||||||
echo
|
echo
|
||||||
echo "No core dump at ${WORKDIR}, to create core dumps (and stack traces)"
|
echo "No core file identified in directory ${COREDIR}"
|
||||||
echo "for crashed soffice instances, enable core dumps with:"
|
echo "To show backtraces for crashes during test execution,"
|
||||||
|
echo "enable core files with:"
|
||||||
echo
|
echo
|
||||||
echo " ulimit -c unlimited"
|
echo " ulimit -c unlimited"
|
||||||
echo
|
echo
|
||||||
exit 0
|
exit 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "You need gdb in your path to generate stacktraces."
|
echo "You need gdb in your path to show backtraces"
|
||||||
exit 0
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# vim: set et sw=4 sts=4:
|
|
@@ -83,6 +83,9 @@ $(call gb_CppunitTest_get_target,%) :| $(gb_CppunitTest_CPPTESTDEPS)
|
|||||||
$(call gb_Output_announce,$*,$(true),CUT,2)
|
$(call gb_Output_announce,$*,$(true),CUT,2)
|
||||||
$(call gb_Helper_abbreviate_dirs,\
|
$(call gb_Helper_abbreviate_dirs,\
|
||||||
mkdir -p $(dir $@) && \
|
mkdir -p $(dir $@) && \
|
||||||
|
$(if $(gb_CppunitTest__interactive),, \
|
||||||
|
$(if $(value gb_CppunitTest_postprocess), \
|
||||||
|
rm -fr $@.core && mkdir $@.core && cd $@.core &&)) \
|
||||||
($(gb_CppunitTest_CPPTESTPRECOMMAND) \
|
($(gb_CppunitTest_CPPTESTPRECOMMAND) \
|
||||||
$(if $(G_SLICE),G_SLICE=$(G_SLICE)) \
|
$(if $(G_SLICE),G_SLICE=$(G_SLICE)) \
|
||||||
$(if $(GLIBCXX_FORCE_NEW),GLIBCXX_FORCE_NEW=$(GLIBCXX_FORCE_NEW)) \
|
$(if $(GLIBCXX_FORCE_NEW),GLIBCXX_FORCE_NEW=$(GLIBCXX_FORCE_NEW)) \
|
||||||
@@ -92,7 +95,12 @@ $(call gb_CppunitTest_get_target,%) :| $(gb_CppunitTest_CPPTESTDEPS)
|
|||||||
$(ICECREAM_RUN) $(gb_CppunitTest_GDBTRACE) $(gb_CppunitTest_VALGRINDTOOL) $(gb_CppunitTest_CPPTESTCOMMAND) \
|
$(ICECREAM_RUN) $(gb_CppunitTest_GDBTRACE) $(gb_CppunitTest_VALGRINDTOOL) $(gb_CppunitTest_CPPTESTCOMMAND) \
|
||||||
$(call gb_LinkTarget_get_target,CppunitTest/$(call gb_CppunitTest_get_libfilename,$*)) \
|
$(call gb_LinkTarget_get_target,CppunitTest/$(call gb_CppunitTest_get_libfilename,$*)) \
|
||||||
$(call gb_CppunitTest__make_args) \
|
$(call gb_CppunitTest__make_args) \
|
||||||
$(if $(gb_CppunitTest__interactive),,> $@.log 2>&1 || (cat $@.log && $(UNIT_FAILED_MSG) && false))))
|
$(if $(gb_CppunitTest__interactive),, \
|
||||||
|
> $@.log 2>&1 \
|
||||||
|
|| (cat $@.log && $(UNIT_FAILED_MSG) \
|
||||||
|
$(if $(value gb_CppunitTest_postprocess), \
|
||||||
|
&& $(call gb_CppunitTest_postprocess,$(gb_CppunitTest_CPPTESTCOMMAND),$@.core)) \
|
||||||
|
&& false))))
|
||||||
|
|
||||||
define gb_CppunitTest_CppunitTest
|
define gb_CppunitTest_CppunitTest
|
||||||
$(call gb_CppunitTest__CppunitTest_impl,$(1),$(call gb_CppunitTest__get_linktargetname,$(1)))
|
$(call gb_CppunitTest__CppunitTest_impl,$(1),$(call gb_CppunitTest__get_linktargetname,$(1)))
|
||||||
|
@@ -303,8 +303,7 @@ define gb_UnoApiHeadersTarget__command
|
|||||||
RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),100,\
|
RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),100,\
|
||||||
$(UNOAPI_DEPS)) && \
|
$(UNOAPI_DEPS)) && \
|
||||||
$(gb_UnoApiHeadersTarget_CPPUMAKERCOMMAND) \
|
$(gb_UnoApiHeadersTarget_CPPUMAKERCOMMAND) \
|
||||||
-Gc $(4) -BUCR \
|
-Gc $(4) -O$(3) $(call gb_UnoApiTarget_get_target,$(2)) \
|
||||||
-O$(3) $(call gb_UnoApiTarget_get_target,$(2)) \
|
|
||||||
@$${RESPONSEFILE} && \
|
@$${RESPONSEFILE} && \
|
||||||
rm -f $${RESPONSEFILE} && \
|
rm -f $${RESPONSEFILE} && \
|
||||||
touch $(1)
|
touch $(1)
|
||||||
|
@@ -333,6 +333,10 @@ $(call gb_LinkTarget_get_target,$(2)) : RPATH :=
|
|||||||
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
define gb_CppunitTest_postprocess
|
||||||
|
$(SRCDIR)/solenv/bin/gdb-core-bt.sh $(1) $(2)
|
||||||
|
endef
|
||||||
|
|
||||||
# JunitTest class
|
# JunitTest class
|
||||||
|
|
||||||
ifneq ($(OOO_TEST_SOFFICE),)
|
ifneq ($(OOO_TEST_SOFFICE),)
|
||||||
@@ -350,7 +354,7 @@ $(call gb_JunitTest_get_target,$(1)) : DEFS := \
|
|||||||
-Dorg.openoffice.test.arg.env=$(gb_Helper_LIBRARY_PATH_VAR)"$$$${$(gb_Helper_LIBRARY_PATH_VAR)+=$$$$$(gb_Helper_LIBRARY_PATH_VAR)}" \
|
-Dorg.openoffice.test.arg.env=$(gb_Helper_LIBRARY_PATH_VAR)"$$$${$(gb_Helper_LIBRARY_PATH_VAR)+=$$$$$(gb_Helper_LIBRARY_PATH_VAR)}" \
|
||||||
-Dorg.openoffice.test.arg.user=$(call gb_Helper_make_url,$(call gb_JunitTest_get_userdir,$(1))) \
|
-Dorg.openoffice.test.arg.user=$(call gb_Helper_make_url,$(call gb_JunitTest_get_userdir,$(1))) \
|
||||||
-Dorg.openoffice.test.arg.workdir=$(call gb_JunitTest_get_userdir,$(1)) \
|
-Dorg.openoffice.test.arg.workdir=$(call gb_JunitTest_get_userdir,$(1)) \
|
||||||
-Dorg.openoffice.test.arg.postprocesscommand=$(GBUILDDIR)/platform/unxgcc_gdbforjunit.sh \
|
-Dorg.openoffice.test.arg.postprocesscommand=$(SRCDIR)/solenv/bin/gdb-core-bt.sh \
|
||||||
-Dorg.openoffice.test.arg.soffice="$(gb_JunitTest_SOFFICEARG)" \
|
-Dorg.openoffice.test.arg.soffice="$(gb_JunitTest_SOFFICEARG)" \
|
||||||
|
|
||||||
endef
|
endef
|
||||||
|
@@ -329,6 +329,10 @@ $(call gb_LinkTarget_get_target,$(2)) : RPATH :=
|
|||||||
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
define gb_CppunitTest_postprocess
|
||||||
|
$(SRCDIR)/solenv/bin/gdb-core-bt.sh $(1) $(2)
|
||||||
|
endef
|
||||||
|
|
||||||
# JunitTest class
|
# JunitTest class
|
||||||
|
|
||||||
ifneq ($(OOO_TEST_SOFFICE),)
|
ifneq ($(OOO_TEST_SOFFICE),)
|
||||||
@@ -346,7 +350,7 @@ $(call gb_JunitTest_get_target,$(1)) : DEFS := \
|
|||||||
-Dorg.openoffice.test.arg.env=$(gb_Helper_LIBRARY_PATH_VAR)"$$$${$(gb_Helper_LIBRARY_PATH_VAR)+=$$$$$(gb_Helper_LIBRARY_PATH_VAR)}" \
|
-Dorg.openoffice.test.arg.env=$(gb_Helper_LIBRARY_PATH_VAR)"$$$${$(gb_Helper_LIBRARY_PATH_VAR)+=$$$$$(gb_Helper_LIBRARY_PATH_VAR)}" \
|
||||||
-Dorg.openoffice.test.arg.user=$(call gb_Helper_make_url,$(call gb_JunitTest_get_userdir,$(1))) \
|
-Dorg.openoffice.test.arg.user=$(call gb_Helper_make_url,$(call gb_JunitTest_get_userdir,$(1))) \
|
||||||
-Dorg.openoffice.test.arg.workdir=$(call gb_JunitTest_get_userdir,$(1)) \
|
-Dorg.openoffice.test.arg.workdir=$(call gb_JunitTest_get_userdir,$(1)) \
|
||||||
-Dorg.openoffice.test.arg.postprocesscommand=$(GBUILDDIR)/platform/unxgcc_gdbforjunit.sh \
|
-Dorg.openoffice.test.arg.postprocesscommand=$(SRCDIR)/solenv/bin/gdb-core-bt.sh \
|
||||||
-Dorg.openoffice.test.arg.soffice="$(gb_JunitTest_SOFFICEARG)" \
|
-Dorg.openoffice.test.arg.soffice="$(gb_JunitTest_SOFFICEARG)" \
|
||||||
|
|
||||||
endef
|
endef
|
||||||
|
@@ -43,11 +43,6 @@ import static org.junit.Assert.*;
|
|||||||
|
|
||||||
|
|
||||||
public final class OfficeConnection {
|
public final class OfficeConnection {
|
||||||
private final class PostprocessFailedException extends java.lang.RuntimeException {
|
|
||||||
PostprocessFailedException() {
|
|
||||||
super("This likely means that soffice crashed during the test.");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
/** Start up an OOo instance.
|
/** Start up an OOo instance.
|
||||||
*/
|
*/
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
@@ -108,6 +103,7 @@ public final class OfficeConnection {
|
|||||||
public void tearDown()
|
public void tearDown()
|
||||||
throws InterruptedException, com.sun.star.uno.Exception
|
throws InterruptedException, com.sun.star.uno.Exception
|
||||||
{
|
{
|
||||||
|
boolean cleanTermination = false;
|
||||||
try {
|
try {
|
||||||
boolean desktopTerminated = true;
|
boolean desktopTerminated = true;
|
||||||
if (process != null) {
|
if (process != null) {
|
||||||
@@ -148,38 +144,45 @@ public final class OfficeConnection {
|
|||||||
if (process != null) {
|
if (process != null) {
|
||||||
code = process.waitFor();
|
code = process.waitFor();
|
||||||
}
|
}
|
||||||
boolean outTerminated = outForward == null || outForward.terminated();
|
boolean outTerminated = outForward == null
|
||||||
boolean errTerminated = errForward == null || errForward.terminated();
|
|| outForward.terminated();
|
||||||
|
boolean errTerminated = errForward == null
|
||||||
|
|| errForward.terminated();
|
||||||
assertEquals(0, code);
|
assertEquals(0, code);
|
||||||
|
cleanTermination = true;
|
||||||
assertTrue(outTerminated);
|
assertTrue(outTerminated);
|
||||||
assertTrue(errTerminated);
|
assertTrue(errTerminated);
|
||||||
} finally {
|
} finally {
|
||||||
|
if (!cleanTermination) {
|
||||||
try {
|
try {
|
||||||
String sofficeArg = Argument.get("soffice");
|
String sofficeArg = Argument.get("soffice");
|
||||||
String workdir = Argument.get("workdir");
|
String workdir = Argument.get("workdir");
|
||||||
String postprocesscommand = Argument.get("postprocesscommand");
|
String postprocesscommand = Argument.get(
|
||||||
if(sofficeArg.startsWith("path:") && workdir != null && postprocesscommand != null) {
|
"postprocesscommand");
|
||||||
|
if (sofficeArg.startsWith("path:") && workdir != null
|
||||||
|
&& postprocesscommand != null)
|
||||||
|
{
|
||||||
ProcessBuilder pb = new ProcessBuilder(
|
ProcessBuilder pb = new ProcessBuilder(
|
||||||
postprocesscommand,
|
postprocesscommand,
|
||||||
sofficeArg.substring("path:".length()),
|
sofficeArg.substring("path:".length()) + ".bin",
|
||||||
workdir);
|
workdir);
|
||||||
Process postprocess = pb.start();
|
Process postprocess = pb.start();
|
||||||
Forward ppoutForward = new Forward(postprocess.getInputStream(), System.out);
|
Forward ppoutForward = new Forward(
|
||||||
|
postprocess.getInputStream(), System.out);
|
||||||
ppoutForward.start();
|
ppoutForward.start();
|
||||||
Forward pperrForward = new Forward(postprocess.getErrorStream(), System.err);
|
Forward pperrForward = new Forward(
|
||||||
|
postprocess.getErrorStream(), System.err);
|
||||||
pperrForward.start();
|
pperrForward.start();
|
||||||
postprocess.waitFor();
|
int code = postprocess.waitFor();
|
||||||
if(postprocess.exitValue() != 0)
|
if (code != 0) {
|
||||||
{
|
throw new PostprocessFailedException(code);
|
||||||
// no ugly long java stacktrace needed here
|
|
||||||
PostprocessFailedException e = new PostprocessFailedException();
|
|
||||||
StackTraceElement[] newStackTrace = new StackTraceElement[0];
|
|
||||||
e.setStackTrace(newStackTrace);
|
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(IOException e) {}
|
catch (IOException e) {
|
||||||
|
throw new PostprocessFailedException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,6 +265,18 @@ public final class OfficeConnection {
|
|||||||
private boolean done = false;
|
private boolean done = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final class PostprocessFailedException
|
||||||
|
extends RuntimeException
|
||||||
|
{
|
||||||
|
PostprocessFailedException(int exitCode) {
|
||||||
|
super("postprocessing failed with exit code " + exitCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
PostprocessFailedException(IOException cause) {
|
||||||
|
super("postprocessing failed with IOException " + cause, cause);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
private Process process = null;
|
private Process process = null;
|
||||||
private Forward outForward = null;
|
private Forward outForward = null;
|
||||||
|
Reference in New Issue
Block a user