[Libreoffice-commits] online.git: 3 commits - common/Util.cpp test/Makefile.am test/run_unit.sh.in test/test.cpp
Michael Meeks (via logerrit)
logerrit at kemper.freedesktop.org
Thu Sep 5 13:26:59 UTC 2019
common/Util.cpp | 14 +++++++++-----
test/Makefile.am | 2 +-
test/run_unit.sh.in | 10 ++++++----
test/test.cpp | 5 ++++-
4 files changed, 20 insertions(+), 11 deletions(-)
New commits:
commit 6338bf20323cac7ac2b73283b53ebfcffd2d25f5
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Thu Sep 5 14:09:51 2019 +0100
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Thu Sep 5 14:10:20 2019 +0100
test: add --gdb option to run_unit.sh
Change-Id: Iff253d95a1a611536fe5c1244c33471e77c77c81
diff --git a/test/run_unit.sh.in b/test/run_unit.sh.in
index 1b4312824..5af9affd8 100755
--- a/test/run_unit.sh.in
+++ b/test/run_unit.sh.in
@@ -26,6 +26,7 @@ print_help ()
echo ""
echo " --log-file <file> Log output to this file - default /dev/stderr"
echo " --trs-file <file> Records the results of a test for automake (default /dev/stderr)"
+ echo " --gdb Run under gdb if enabled"
echo " --valgrind Run under valgrind if enabled"
echo " --verbose Print out more stuff - if you run out of things to read"
exit 1
@@ -39,7 +40,8 @@ while test $# -gt 0; do
--test-name) tst=$2; shift;;
--log-file) tst_log=$2; shift;;
--trs-file) test_output=$2; shift;;
- --valgrind) valgrind=$valgrind_cmd; shift;;
+ --gdb) trace='gdb --args'; shift;;
+ --valgrind) trace=$valgrind_cmd; shift;;
--verbose) verbose="--verbose";;
--help) print_help ;;
-*) ;; # ignore
@@ -84,7 +86,7 @@ if test "z$tst" == "z"; then
export LOOL_TEST_MASTER_PORT=9985
echo "Executing external tests"
- ${valgrind} \
+ ${trace} \
${abs_top_builddir}/loolwsd --o:sys_template_path="$systemplate_path" \
--o:lo_template_path="$lo_path" \
--o:child_root_path="$jails_path" \
@@ -106,7 +108,7 @@ if test "z$tst" == "z"; then
oldpath=`pwd`
cd "${abs_top_builddir}/test"
- if eval ${valgrind} ./test ${verbose}; then
+ if eval ${trace} ./test ${verbose}; then
echo "Test run_test.sh passed."
echo ":test-result: PASS run_test.sh" >> $oldpath/$test_output
retval=0
@@ -124,7 +126,7 @@ if test "z$tst" == "z"; then
else # newer unit tests.
echo "Running $tst | $tst_log ...";
- if ${valgrind} \
+ if ${trace} \
${abs_top_builddir}/loolwsd --o:sys_template_path="$systemplate_path" \
--o:lo_template_path="$lo_path" \
--o:child_root_path="$jails_path" \
commit 81aa1a07828b9fce03b89fb8470ea950bd2f2ffd
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Thu Sep 5 14:08:02 2019 +0100
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Thu Sep 5 14:10:20 2019 +0100
test: print out the correct way to run all-local test.
Change-Id: I2a9a90beff7b2dc689dc2de7df86404018b514fb
diff --git a/test/Makefile.am b/test/Makefile.am
index 27fc43e99..d5dc5792f 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -161,4 +161,4 @@ all-local: unittest
@echo "Running build-time unit tests. For more thorough testing, please run 'make check'."
@echo
@fc-cache "@LO_PATH@"/share/fonts/truetype
- @${top_builddir}/test/unittest
+ @UNITTEST=1 ${top_builddir}/test/unittest
diff --git a/test/test.cpp b/test/test.cpp
index b04555ac7..621ff6351 100644
--- a/test/test.cpp
+++ b/test/test.cpp
@@ -159,7 +159,10 @@ bool runClientTests(bool standalone, bool verbose)
{
std::cerr << "\nTo reproduce the first test failure use:\n\n";
#ifndef UNIT_CLIENT_TESTS
- std::cerr << "(cd test; CPPUNIT_TEST_NAME=\"" << (*failures.begin())->failedTestName() << "\" ./run_unit.sh --verbose)\n\n";
+ const char *cmd = "./run_unit.sh --verbose";
+ if (getenv("UNITTEST"))
+ cmd = "./unittest";
+ std::cerr << "(cd test; CPPUNIT_TEST_NAME=\"" << (*failures.begin())->failedTestName() << "\" " << cmd << ")\n\n";
#else
std::cerr << "(cd test; CPPUNIT_TEST_NAME=\"" << (*failures.begin())->failedTestName() << "\" make check)\n\n";
#endif
commit 6d1cc6c01d2669c2e3ee265f0ed199c52b0b9c8a
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Thu Sep 5 14:07:21 2019 +0100
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Thu Sep 5 14:10:20 2019 +0100
Avoid using std::get_time to compile on older Linux.
Change-Id: I862e5f342ea485a9b65b413ab0c1bdea4f5fbb8d
diff --git a/common/Util.cpp b/common/Util.cpp
index 80efed440..9df234edd 100644
--- a/common/Util.cpp
+++ b/common/Util.cpp
@@ -25,6 +25,7 @@
#include <sys/types.h>
#include <unistd.h>
#include <dirent.h>
+#include <time.h>
#include <atomic>
#include <cassert>
@@ -816,24 +817,27 @@ namespace Util
std::chrono::system_clock::time_point iso8601ToTimestamp(const std::string& iso8601Time, const std::string& logName)
{
std::chrono::system_clock::time_point timestamp;
- std::tm tm{};
- std::istringstream iss(iso8601Time);
- if (!(iss >> std::get_time(&tm, "%Y-%m-%dT%H:%M:%S")))
+ std::tm tm;
+ const char *cstr = iso8601Time.c_str();
+ const char *trailing;
+ if (!(trailing = strptime(cstr, "%Y-%m-%dT%H:%M:%S", &tm)))
{
LOG_WRN(logName << " [" << iso8601Time << "] is in invalid format."
<< "Returning " << timestamp.time_since_epoch().count());
return timestamp;
}
timestamp += std::chrono::seconds(timegm(&tm));
- if (iss.eof())
+ if (trailing[0] == '\0')
return timestamp;
double us;
- if (iss.peek() != '.' || !(iss >> us))
+ if (trailing[0] != '.')
{
LOG_WRN(logName << " [" << iso8601Time << "] is in invalid format."
<< ". Returning " << timestamp.time_since_epoch().count());
return timestamp;
}
+ char *end = nullptr;
+ us = strtod(trailing, &end);
std::size_t seconds_us = us * std::chrono::system_clock::period::den / std::chrono::system_clock::period::num;
timestamp += std::chrono::system_clock::duration(seconds_us);
More information about the Libreoffice-commits
mailing list