test/Makefile.am | 6 ++++-- test/TileCacheTests.cpp | 6 ++++-- test/httpcrashtest.cpp | 1 + test/run_unit.sh.in | 8 +++++--- test/test.cpp | 16 ++++++++++++++++ test/test.hpp | 21 +++++++++++++++++++++ 6 files changed, 51 insertions(+), 7 deletions(-)
New commits: commit 097cc58d530e4e40482a4b981306200151088562 Author: Michael Meeks <michael.me...@collabora.com> Date: Fri May 12 03:08:20 2017 +0100 Run old-style unit tests as a new-style unit test. This moves the code into the same process, for easier logging & debugging. Disabled initially. Change-Id: Id48b5649ba14deb0a2159ca59e321c7d0ae66dad diff --git a/test/Makefile.am b/test/Makefile.am index 754f0f12..50629277 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -14,7 +14,7 @@ AM_CXXFLAGS = $(CPPUNIT_CFLAGS) -DTDOC=\"$(top_srcdir)/test/data\" \ noinst_LTLIBRARIES = \ unit-timeout.la unit-prefork.la \ - unit-storage.la \ + unit-storage.la unit-client.la \ unit-admin.la unit-tilecache.la \ unit-fuzz.la unit-oob.la @@ -56,6 +56,8 @@ unit_oob_la_SOURCES = UnitOOB.cpp unit_fuzz_la_SOURCES = UnitFuzz.cpp unit_admin_la_SOURCES = UnitAdmin.cpp unit_admin_la_LIBADD = $(CPPUNIT_LIBS) +unit_client_la_SOURCES = UnitClient.cpp ${test_SOURCES} +unit_client_la_LIBADD = $(CPPUNIT_LIBS) unit_timeout_la_SOURCES = UnitTimeout.cpp unit_prefork_la_SOURCES = UnitPrefork.cpp unit_storage_la_SOURCES = UnitStorage.cpp @@ -73,7 +75,7 @@ check-local: ./run_unit.sh --log-file test.log --trs-file test.trs # FIXME 2: unit-oob.la fails with symbol undefined: # UnitWSD::testHandleRequest(UnitWSD::TestRequest, UnitHTTPServerRequest&, UnitHTTPServerResponse&) , -TESTS = unit-prefork.la unit-tilecache.la unit-timeout.la # unit-storage.la # unit-admin.la +TESTS = unit-prefork.la unit-tilecache.la unit-timeout.la # unit-client.la - enable to run unit-tests in wsd ... else TESTS = ${top_builddir}/test/test endif diff --git a/test/TileCacheTests.cpp b/test/TileCacheTests.cpp index 16577b3f..cac39144 100644 --- a/test/TileCacheTests.cpp +++ b/test/TileCacheTests.cpp @@ -26,6 +26,7 @@ #include "countloolkits.hpp" #include "helpers.hpp" +#include "test.hpp" using namespace helpers; @@ -153,9 +154,10 @@ public: void TileCacheTests::testSimple() { - if (!UnitWSD::init(UnitWSD::UnitType::Wsd, "")) + if (isStandalone()) { - throw std::runtime_error("Failed to load wsd unit test library."); + if (!UnitWSD::init(UnitWSD::UnitType::Wsd, "")) + throw std::runtime_error("Failed to load wsd unit test library."); } // Create TileCache and pretend the file was modified as recently as diff --git a/test/httpcrashtest.cpp b/test/httpcrashtest.cpp index b6230d5a..72720734 100644 --- a/test/httpcrashtest.cpp +++ b/test/httpcrashtest.cpp @@ -208,6 +208,7 @@ void HTTPCrashTest::testCrashForkit() std::cerr << "Killing forkit." << std::endl; killLoKitProcesses("(loolforkit)"); + killLoKitProcesses("(forkit)"); // on new kernels: prctrl does that. std::cerr << "Communicating after kill." << std::endl; sendTextFrame(socket, "status", testname); diff --git a/test/run_unit.sh.in b/test/run_unit.sh.in index 4ac7fb30..95a8e17f 100755 --- a/test/run_unit.sh.in +++ b/test/run_unit.sh.in @@ -101,7 +101,7 @@ if test "z$tst" == "z"; then else # newer unit tests. echo "Running $tst | $tst_log ..."; - if ${valgrind} \ + if ${valgrind} \ ${abs_top_builddir}/loolwsd --o:sys_template_path="$systemplate_path" \ --o:lo_template_path="$lo_path" \ --o:child_root_path="$jails_path" \ @@ -111,11 +111,11 @@ else # newer unit tests. --o:ssl.cert_file_path="${abs_top_builddir}/etc/cert.pem" \ --o:ssl.ca_file_path="${abs_top_builddir}/etc/ca-chain.cert.pem" \ --o:admin_console.username=admin --o:admin_console.password=admin \ - --unitlib=".libs/$tst.so" > "$tst_log" 2>&1; then + --unitlib=".libs/$tst.so" 2> "$tst_log"; then echo "Test $tst passed." echo ":test-result: PASS $tst" >> $test_output else - cat "$tst_log" + cat $tst_log echo "=============================================================" echo "Test failed on unit: $tst re-run with:" echo " $ gdb --args ${abs_top_builddir}/loolwsd --o:sys_template_path=\"$systemplate_path\" \\" @@ -128,6 +128,8 @@ else # newer unit tests. echo " --o:ssl.ca_file_path=\"${abs_top_builddir}/etc/ca-chain.cert.pem\" \\" echo " --o:admin_console.username=admin --o:admin_console.password=admin \\" echo " --unitlib=\".libs/$tst.so\"" + echo "" + echo " $ less $tst_log # for detailed failure log files" echo "=============================================================" echo ":test-result: FAIL $tst" >> $test_output fi diff --git a/test/test.cpp b/test/test.cpp index 4d6fc505..b506b20c 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -24,6 +24,8 @@ #include <Log.hpp> +#include "test.hpp" + class HTTPGetTest; bool filterTests(CPPUNIT_NS::TestRunner& runner, CPPUNIT_NS::Test* testRegistry, const std::string testName) @@ -63,6 +65,20 @@ int main(int argc, char** argv) Log::initialize("tst", loglevel, true, false, {}); + runClientTests(true, verbose); +} + +static bool IsStandalone = false; + +bool isStandalone() +{ + return IsStandalone; +} + +bool runClientTests(bool standalone, bool verbose) +{ + IsStandalone = standalone; + CPPUNIT_NS::TestResult controller; CPPUNIT_NS::TestResultCollector result; controller.addListener(&result); diff --git a/test/test.hpp b/test/test.hpp new file mode 100644 index 00000000..953cd1af --- /dev/null +++ b/test/test.hpp @@ -0,0 +1,21 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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_HPP +#define INCLUDED_TEST_HPP + +/// Are we running inside WSD or by ourselves. +bool isStandalone(); + +/// Run the set of client tests we have +bool runClientTests(bool standalone, bool verbose); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits