diff options
-rw-r--r-- | include/test/callgrind.hxx | 21 | ||||
-rw-r--r-- | solenv/gbuild/CppunitTest.mk | 25 | ||||
-rw-r--r-- | solenv/gbuild/extensions/post_SpeedUpTargets.mk | 2 | ||||
-rw-r--r-- | test/Library_test.mk | 2 | ||||
-rw-r--r-- | test/source/callgrind.cxx | 33 |
5 files changed, 64 insertions, 19 deletions
diff --git a/include/test/callgrind.hxx b/include/test/callgrind.hxx new file mode 100644 index 000000000000..6a16fa8319db --- /dev/null +++ b/include/test/callgrind.hxx @@ -0,0 +1,21 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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/. + */ + +#ifndef INCLUDED_TEST_CALLGRIND_HXX +#define INCLUDED_TEST_CALLGRIND_HXX + +#include <sal/config.h> +#include <test/testdllapi.hxx> + +void OOO_DLLPUBLIC_TEST callgrindStart(); +void OOO_DLLPUBLIC_TEST callgrindDump(const char* name); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/solenv/gbuild/CppunitTest.mk b/solenv/gbuild/CppunitTest.mk index aa259e35797b..4f00f819864c 100644 --- a/solenv/gbuild/CppunitTest.mk +++ b/solenv/gbuild/CppunitTest.mk @@ -34,6 +34,11 @@ GLIBCXX_FORCE_NEW := 1 endif endif +ifneq (,$(filter perfcheck,$(MAKECMDGOALS))) +$(if $(ENABLE_VALGRIND),,$(call gb_Output_error,Running performance tests with empty $$(ENABLE_VALGRIND) does not make sense)) +gb_CppunitTest_VALGRINDTOOL := valgrind --tool=callgrind --dump-instr=yes --instr-atstart=no +endif + # defined by platform # gb_CppunitTest_TARGETTYPE # gb_CppunitTest_get_filename @@ -94,10 +99,7 @@ $(call gb_CppunitTest_get_target,%) :| $(gb_CppunitTest_CPPTESTDEPS) || ($(if $(value gb_CppunitTest_postprocess), \ RET=$$?; \ $(call gb_CppunitTest_postprocess,$(gb_CppunitTest_CPPTESTCOMMAND),$@.core,$$RET) >> $@.log 2>&1;) \ - cat $@.log; $(SRCDIR)/solenv/bin/unittest-failed.sh Cppunit $*))) \ - $(if $(PERFTEST), && VAL=$$(grep '^==.*== Collected : ' $@.log | sed "s/==.*== Collected : //") && \ - $(if $(filter 0,$(PERFTEST)), expr "$$VAL" "*" "101" "/" "100", test $$VAL -le $(PERFTEST) || (echo "Unit test is slow! $$VAL instructions detected (expected $(PERFTEST))." && false))) \ - ) + cat $@.log; $(SRCDIR)/solenv/bin/unittest-failed.sh Cppunit $*)))) define gb_CppunitTest_CppunitTest $(call gb_CppunitTest__CppunitTest_impl,$(1),$(call gb_CppunitTest_get_linktarget,$(1))) @@ -147,21 +149,6 @@ $(call gb_CppunitTest_get_target,$(1)) : ARGS += $(2) endef -# Run this unit test with callgrind tool to measure performance. If you are -# creating a new test, first set the number to 0, run the test, and it will -# print an number for you to use as a second parameter here. The test will -# fail if reported number of instructions will be bigger than this parameter. -# -# call gb_CppunitTest_set_performance_test,name,instructions_number -define gb_CppunitTest_set_performance_test -$(if $(ENABLE_VALGRIND),,$(call gb_Output_error,gb_CppunitTest_set_performance_test used with empty $$(ENABLE_VALGRIND))) - -$(call gb_CppunitTest_get_target,$(1)) : PERFTEST := $(2) -$(call gb_CppunitTest_get_target,$(1)) : gb_CppunitTest_VALGRINDTOOL := valgrind --tool=callgrind --dump-instr=yes --instr-atstart=no -$(call gb_CppunitTest_use_external,$(1),valgrind) - -endef - define gb_CppunitTest_use_ure $(call gb_CppunitTest_use_rdb,$(1),ure/services) $(call gb_CppunitTest_get_target,$(1)) : URE := $(true) diff --git a/solenv/gbuild/extensions/post_SpeedUpTargets.mk b/solenv/gbuild/extensions/post_SpeedUpTargets.mk index 8f3280f3c5aa..a13392a29cf7 100644 --- a/solenv/gbuild/extensions/post_SpeedUpTargets.mk +++ b/solenv/gbuild/extensions/post_SpeedUpTargets.mk @@ -22,6 +22,8 @@ endif ifeq (,$(filter perfcheck,$(MAKECMDGOALS))) gb_Module_SKIPTARGETS += perfcheck +else +gb_Module_SKIPTARGETS += check slowcheck subsequentcheck endif ifneq ($(strip $(MAKECMDGOALS)),) diff --git a/test/Library_test.mk b/test/Library_test.mk index 2c8d854417a2..df7bfd210a0a 100644 --- a/test/Library_test.mk +++ b/test/Library_test.mk @@ -19,6 +19,7 @@ $(eval $(call gb_Library_use_externals,test,\ boost_headers \ cppunit \ libxml2 \ + valgrind \ )) $(eval $(call gb_Library_use_libraries,test,\ @@ -40,6 +41,7 @@ $(eval $(call gb_Library_use_libraries,test,\ $(eval $(call gb_Library_add_exception_objects,test,\ test/source/bootstrapfixture \ test/source/diff/diff \ + test/source/callgrind \ test/source/xmltesttools \ test/source/htmltesttools \ test/source/mtfxmldump \ diff --git a/test/source/callgrind.cxx b/test/source/callgrind.cxx new file mode 100644 index 000000000000..d5e864aa8e39 --- /dev/null +++ b/test/source/callgrind.cxx @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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/. + */ + +#include <test/callgrind.hxx> + +#ifdef HAVE_VALGRIND_HEADERS +#include <valgrind/callgrind.h> +#else +#define CALLGRIND_START_INSTRUMENTATION +#define CALLGRIND_ZERO_STATS +#define CALLGRIND_STOP_INSTRUMENTATION +#define CALLGRIND_DUMP_STATS_AT(name) (void)name; +#endif + +void callgrindStart() +{ + CALLGRIND_ZERO_STATS; + CALLGRIND_START_INSTRUMENTATION; +}; + +void callgrindDump(const char* name) +{ + CALLGRIND_STOP_INSTRUMENTATION; + CALLGRIND_DUMP_STATS_AT(name); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |