[Libreoffice-commits] core.git: sal/cppunittester solenv/gbuild

2015-08-31 Thread Michael Stahl
 sal/cppunittester/cppunittester.cxx |   12 
 solenv/gbuild/CppunitTest.mk|2 +-
 2 files changed, 9 insertions(+), 5 deletions(-)

New commits:
commit d0ebb6e438dc8f7dcb5467ae6f72068cf40dcb7a
Author: Michael Stahl 
Date:   Mon Aug 31 23:09:16 2015 +0200

sal: don't use --target as parameter to cppunittester

CppunitTest_libreofficekit_tiledrendering hangs because the soffice_main
exits due to the unrecognized command line arg --target.

Use a -env:VARIABLE argument instead, which is filtered out by
rtl_getAppCommandArg() so does not reach the soffice_main code.

(regression from 87514b0907dfbb479e2646b5ff951c68babf3417)

Change-Id: I2c801305398dccfb447e4e5c44726f42bf2a72ef

diff --git a/sal/cppunittester/cppunittester.cxx 
b/sal/cppunittester/cppunittester.cxx
index a57ea55..e67c476 100644
--- a/sal/cppunittester/cppunittester.cxx
+++ b/sal/cppunittester/cppunittester.cxx
@@ -361,15 +361,19 @@ SAL_IMPLEMENT_MAIN()
 std::string args;
 std::string testlib;
 sal_uInt32 index = 0;
-while (index < rtl_getAppCommandArgCount())
+while (index < osl_getCommandArgCount())
 {
 rtl::OUString arg = getArgument(index);
-if (arg == "--target")
+if (arg.startsWith("-env:CPPUNITTESTTARGET=", ))
 {
-path = getArgument(++index);
 ++index;
 continue;
 }
+if (arg.startsWith("-env:"))
+{
+++index;
+continue; // ignore it here - will be read later
+}
 if ( arg != "--protector" )
 {
 if (testlib.empty())
@@ -385,7 +389,7 @@ SAL_IMPLEMENT_MAIN()
 ++index;
 continue;
 }
-if (rtl_getAppCommandArgCount() - index < 3) {
+if (osl_getCommandArgCount() - index < 3) {
 usageFailure();
 }
 rtl::OUString lib(getArgument(index + 1));
diff --git a/solenv/gbuild/CppunitTest.mk b/solenv/gbuild/CppunitTest.mk
index bea33eb..f5cc1df 100644
--- a/solenv/gbuild/CppunitTest.mk
+++ b/solenv/gbuild/CppunitTest.mk
@@ -102,7 +102,7 @@ $(call gb_CppunitTest_get_target,%) :| 
$(gb_CppunitTest_RUNTIMEDEPS)
PYTHONDONTWRITEBYTECODE=1) \
$(ICECREAM_RUN) $(gb_CppunitTest_GDBTRACE) 
$(gb_CppunitTest_VALGRINDTOOL) $(gb_CppunitTest_CPPTESTCOMMAND) \
$(call gb_LinkTarget_get_target,$(call 
gb_CppunitTest_get_linktarget,$*)) \
-   $(call gb_CppunitTest__make_args) --target $@ \
+   $(call gb_CppunitTest__make_args) "-env:CPPUNITTESTTARGET=$@" \
$(if $(gb_CppunitTest__interactive),, \
> $@.log 2>&1 \
|| ($(if $(value gb_CppunitTest_postprocess), \
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sal/cppunittester solenv/gbuild

2015-08-30 Thread Markus Mohrhard
 sal/cppunittester/cppunittester.cxx |   50 
 solenv/gbuild/CppunitTest.mk|2 -
 2 files changed, 51 insertions(+), 1 deletion(-)

New commits:
commit 87514b0907dfbb479e2646b5ff951c68babf3417
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Mon Aug 31 01:36:02 2015 +0200

log resource usage of unit tests on UNX platforms

Change-Id: I3788eae60f73bc42488bf2e4961922962f7e505b
Reviewed-on: https://gerrit.libreoffice.org/18155
Reviewed-by: Markus Mohrhard markus.mohrh...@googlemail.com
Tested-by: Markus Mohrhard markus.mohrh...@googlemail.com

diff --git a/sal/cppunittester/cppunittester.cxx 
b/sal/cppunittester/cppunittester.cxx
index 07c9a2b..79ba18d 100644
--- a/sal/cppunittester/cppunittester.cxx
+++ b/sal/cppunittester/cppunittester.cxx
@@ -21,6 +21,11 @@
 #include windows.h
 #endif
 
+#ifdef UNX
+#include sys/time.h
+#include sys/resource.h
+#endif
+
 #include cstdlib
 #include iostream
 #include string
@@ -292,11 +297,48 @@ public:
 }
 };
 
+#ifdef UNX
+
+double get_time(timeval* time)
+{
+double nTime = (double)time-tv_sec;
+nTime += ((double)time-tv_usec)/100.0;
+return nTime;
+}
+
+OString generateTestName(const OUString rPath)
+{
+sal_Int32 nPathSep = rPath.lastIndexOf(/);
+OUString aTestName = rPath.copy(nPathSep+1);
+return OUStringToOString(aTestName, RTL_TEXTENCODING_UTF8);
+}
+
+void reportResourceUsage(const OUString rPath)
+{
+OUString aFullPath = rPath + OUString(.resource.log);
+rusage resource_usage;
+getrusage(RUSAGE_SELF, resource_usage);
+
+OString aPath = OUStringToOString(aFullPath, RTL_TEXTENCODING_UTF8);
+std::ofstream resource_file(aPath.getStr());
+resource_file  Name =   generateTestName(rPath)  std::endl;
+double nUserSpace = get_time(resource_usage.ru_utime);
+double nKernelSpace = get_time(resource_usage.ru_stime);
+resource_file  UserSpace =   nUserSpace  std::endl;
+resource_file  KernelSpace =   nKernelSpace  std::endl;
+}
+#else
+void reportResourceUsage(const OUString /*rPath*/)
+{
+}
+#endif
+
 }
 
 SAL_IMPLEMENT_MAIN()
 {
 bool ok = false;
+OUString path;
 try
 {
 #ifdef WNT
@@ -322,6 +364,12 @@ SAL_IMPLEMENT_MAIN()
 while (index  rtl_getAppCommandArgCount())
 {
 rtl::OUString arg = getArgument(index);
+if (arg == --target)
+{
+path = getArgument(++index);
+++index;
+continue;
+}
 if ( arg != --protector )
 {
 if (testlib.empty())
@@ -383,6 +431,8 @@ SAL_IMPLEMENT_MAIN()
 SAL_WARN(vcl.app, Fatal exception:   e.what());
 }
 
+reportResourceUsage(path);
+
 return ok ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
diff --git a/solenv/gbuild/CppunitTest.mk b/solenv/gbuild/CppunitTest.mk
index 61f17dd..bea33eb 100644
--- a/solenv/gbuild/CppunitTest.mk
+++ b/solenv/gbuild/CppunitTest.mk
@@ -102,7 +102,7 @@ $(call gb_CppunitTest_get_target,%) :| 
$(gb_CppunitTest_RUNTIMEDEPS)
PYTHONDONTWRITEBYTECODE=1) \
$(ICECREAM_RUN) $(gb_CppunitTest_GDBTRACE) 
$(gb_CppunitTest_VALGRINDTOOL) $(gb_CppunitTest_CPPTESTCOMMAND) \
$(call gb_LinkTarget_get_target,$(call 
gb_CppunitTest_get_linktarget,$*)) \
-   $(call gb_CppunitTest__make_args) \
+   $(call gb_CppunitTest__make_args) --target $@ \
$(if $(gb_CppunitTest__interactive),, \
 $@.log 21 \
|| ($(if $(value gb_CppunitTest_postprocess), \
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits