d7ba78e9c7
...for (Linux) systems that don't store core.* files in the current working directory. When enabled, this wraps test execution in `systemd-run --scope --user --unit=...` with unit values unique per individual test invocation, so that solenv/bin/gdb-core-bt.sh can query coredumpctl for matching core dumps. (See the mailing list thread starting at <https://lists.freedesktop.org/archives/systemd-devel/2023-March/048884.html> "[systemd-devel] coredumpctl: matching by e.g. env var?" for further details.) The used --unit=... scheme is a best effort to produce system-wide unique values, combining the target location path of the given test with a second-granularity date/time and the current PID. (In case there would be multiple invocations of the same test per second, which then hopefully wouldn't reuse the same PID. The date/time and PID could be replaced with a high-resolution system-wide monotonic clock/counter if one were easily available. The advantage of the current scheme is that it only uses Posix features.) The overall length of the unit value (incl. the appended ".scope" suffix) must not exceed 256 characters, or else systemd-run would fail with "Failed to mangle scope name: Invalid argument". It might look more natural to pass the unit value into gdb-core-bt.sh as a fourth positional argument rather than via a new LIBO_TEST_UNIT env var. But for one, the unit value is most easily computed from within the recipe shell command lines, where an env var is the most natural fit. And for another, this avoids having to tunnel yet another value through the tearDown method in unotest/source/java/org/openoffice/test/OfficeConnection.java to the given postprocesscommand. Change-Id: Idcb20cd1e1141d8ec7f10947e5edc70aa2aa7d32 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149690 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
132 lines
4.9 KiB
Makefile
132 lines
4.9 KiB
Makefile
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
|
|
#
|
|
# This file is part of the LibreOffice project.
|
|
#
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
#
|
|
|
|
# PythonTest class
|
|
|
|
# (gb_PythonTest_GDBTRACE et al are defined alongside gb_CppunitTest_GDBTRACE in CppunitTest.mk)
|
|
|
|
gb_PythonTest_UNITTESTFAILED ?= $(GBUILDDIR)/platform/unittest-failed-default.sh
|
|
|
|
ifeq ($(SYSTEM_PYTHON),)
|
|
gb_PythonTest_EXECUTABLE := $(gb_Python_INSTALLED_EXECUTABLE)
|
|
gb_PythonTest_EXECUTABLE_GDB := $(gb_Python_INSTALLED_EXECUTABLE_GDB)
|
|
gb_PythonTest_DEPS ?= $(call gb_Package_get_target,python3) $(call gb_Package_get_target,python_shell)
|
|
else
|
|
gb_PythonTest_EXECUTABLE := $(PYTHON_FOR_BUILD)
|
|
gb_PythonTest_EXECUTABLE_GDB := $(PYTHON_FOR_BUILD)
|
|
gb_PythonTest_DEPS :=
|
|
endif
|
|
|
|
gb_PythonTest_COMMAND := $(gb_PythonTest_EXECUTABLE) -m org.libreoffice.unittest
|
|
|
|
.PHONY : $(call gb_PythonTest_get_clean_target,%)
|
|
$(call gb_PythonTest_get_clean_target,%) :
|
|
$(call gb_Helper_abbreviate_dirs,\
|
|
rm -fr $(WORKDIR)/PythonTest/$*)
|
|
|
|
ifneq ($(DISABLE_PYTHON),TRUE)
|
|
|
|
.PHONY : $(call gb_PythonTest_get_target,%)
|
|
$(call gb_PythonTest_get_target,%) :\
|
|
$(call gb_Library_get_target,pyuno) \
|
|
$(if $(filter-out WNT,$(OS)),$(call gb_Library_get_target,pyuno_wrapper)) \
|
|
| $(gb_PythonTest_DEPS)
|
|
ifneq ($(gb_SUPPRESS_TESTS),)
|
|
@true
|
|
else
|
|
$(call gb_Output_announce,$*,$(true),PYT,2)
|
|
$(call gb_Trace_StartRange,$*,PYT)
|
|
$(call gb_Helper_abbreviate_dirs,\
|
|
rm -rf $(dir $(call gb_PythonTest_get_target,$*)) && \
|
|
mkdir -p $(dir $(call gb_PythonTest_get_target,$*))user/user/autotext && \
|
|
$(if $(gb_CppunitTest__interactive),, \
|
|
$(if $(value gb_CppunitTest_postprocess), \
|
|
rm -fr $@.core && mkdir $@.core && cd $@.core &&)) \
|
|
$(call gb_CppunitTest_coredumpctl_setup,$@) \
|
|
{ \
|
|
$(if $(filter gdb,$(gb_PythonTest_GDBTRACE)),,$(gb_PythonTest_PRECOMMAND)) \
|
|
$(if $(G_SLICE),G_SLICE=$(G_SLICE)) \
|
|
$(if $(GLIBCXX_FORCE_NEW),GLIBCXX_FORCE_NEW=$(GLIBCXX_FORCE_NEW)) \
|
|
$(DEFS) \
|
|
TEST_LIB=$(call gb_Library_get_target,test) \
|
|
URE_BOOTSTRAP=vnd.sun.star.pathname:$(call gb_Helper_get_rcfile,$(INSTROOT)/$(LIBO_ETC_FOLDER)/fundamental) \
|
|
PYTHONPATH="$(PYPATH)" \
|
|
UserInstallation=$(call gb_Helper_make_url,$(dir $(call gb_PythonTest_get_target,$*))user) \
|
|
TestUserDir="$(call gb_Helper_make_url,$(dir $(call gb_PythonTest_get_target,$*)))" \
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
|
$(gb_TEST_ENV_VARS) \
|
|
$(if $(filter gdb,$(CPPUNITTRACE)),\
|
|
PYTHONWARNINGS=default) \
|
|
$(ICECREAM_RUN) $(gb_CppunitTest_coredumpctl_run) $(gb_PythonTest_GDBTRACE) $(gb_CppunitTest_VALGRINDTOOL) $(gb_CppunitTest_RR) \
|
|
$(gb_PythonTest_COMMAND) \
|
|
$(if $(PYTHON_TEST_NAME),$(PYTHON_TEST_NAME),$(MODULES)) \
|
|
; } \
|
|
$(if $(gb_CppunitTest__interactive),, \
|
|
> $@.log 2>&1 \
|
|
|| ($(if $(value gb_CppunitTest_postprocess), \
|
|
RET=$$?; \
|
|
$(call gb_CppunitTest_postprocess,$(gb_PythonTest_EXECUTABLE_GDB),$@.core,$$RET) >> $@.log 2>&1;) \
|
|
cat $@.log; $(gb_PythonTest_UNITTESTFAILED) Python $*)))
|
|
$(call gb_Trace_EndRange,$*,PYT)
|
|
endif
|
|
|
|
# always use udkapi and URE services
|
|
define gb_PythonTest_PythonTest
|
|
$(call gb_PythonTest_get_target,$(1)) : PYPATH := $(SRCDIR)/unotest/source/python$$(gb_CLASSPATHSEP)$(INSTROOT)/$(LIBO_LIB_PYUNO_FOLDER)$(if $(filter-out $(LIBO_LIB_PYUNO_FOLDER),$(LIBO_LIB_FOLDER)),$(gb_CLASSPATHSEP)$(INSTROOT)/$(LIBO_LIB_FOLDER))
|
|
$(call gb_PythonTest_get_target,$(1)) : MODULES :=
|
|
|
|
$(eval $(call gb_Module_register_target,$(call gb_PythonTest_get_target,$(1)),$(call gb_PythonTest_get_clean_target,$(1))))
|
|
$(call gb_Helper_make_userfriendly_targets,$(1),PythonTest)
|
|
|
|
endef
|
|
|
|
define gb_PythonTest_set_defs
|
|
$(call gb_PythonTest_get_target,$(1)) : DEFS := $(2)
|
|
|
|
endef
|
|
|
|
# put the directory on the PYTHONPATH because the "unittest" loader
|
|
# mysteriously fails to load modules given as absolute path unless the $PWD is
|
|
# a prefix of the absolute path, which it is not when we go into a certain
|
|
# dir to get a core dump there
|
|
#
|
|
# gb_PythonTest_add_modules directory module(s)
|
|
define gb_PythonTest_add_modules
|
|
$(call gb_PythonTest_get_target,$(1)) : PYPATH := $$(PYPATH)$$(gb_CLASSPATHSEP)$(2)
|
|
$(call gb_PythonTest_get_target,$(1)) : MODULES += $(3)
|
|
|
|
endef
|
|
|
|
define gb_PythonTest_use_customtarget
|
|
$(call gb_PythonTest_get_target,$(1)) : $(call gb_CustomTarget_get_workdir,$(2))
|
|
|
|
endef
|
|
|
|
|
|
else # DISABLE_PYTHON
|
|
|
|
.PHONY : $(call gb_PythonTest_get_target,$(1))
|
|
$(call gb_PythonTest_get_target,%) :
|
|
ifeq ($(gb_SUPPRESS_TESTS),)
|
|
$(call gb_Output_announce,$* (skipped - no PythonTest),$(true),PYT,2)
|
|
endif
|
|
@true
|
|
|
|
define gb_PythonTest_PythonTest
|
|
$(eval $(call gb_Module_register_target,$(call gb_PythonTest_get_target,$(1)),$(call gb_PythonTest_get_clean_target,$(1))))
|
|
$(call gb_Helper_make_userfriendly_targets,$(1),PythonTest)
|
|
|
|
endef
|
|
|
|
gb_PythonTest_set_defs :=
|
|
gb_PythonTest_add_modules :=
|
|
gb_PythonTest_use_customtarget :=
|
|
|
|
endif # DISABLE_PYTHON
|
|
# vim: set noet sw=4:
|