diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2020-01-21 11:21:08 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2020-01-21 13:39:42 +0000 |
commit | cecbc9a390c6b589e24704e76e0505917e181ed2 (patch) | |
tree | db82f0c90a107d87d7df622b97d7b535de4fc30a | |
parent | 01fbe88c1fc09e17b75b0c54493e31e8a8d5dc2d (diff) |
test: simplify and remove obsolete /proc grokking code.
Change-Id: I482c56dd76067019d83196aa305d14703e25bb44
-rw-r--r-- | test/Makefile.am | 2 | ||||
-rw-r--r-- | test/UnitClient.cpp | 4 | ||||
-rw-r--r-- | test/test.cpp | 129 |
3 files changed, 14 insertions, 121 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index e4b621755..a31e557b6 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -81,7 +81,7 @@ test_base_source = \ DeltaTests.cpp \ $(wsd_sources) -unittest_CPPFLAGS = -I$(top_srcdir) -DBUILDING_TESTS +unittest_CPPFLAGS = -I$(top_srcdir) -DBUILDING_TESTS -DSTANDALONE_CPPUNIT unittest_SOURCES = $(test_base_source) test.cpp unittest_LDADD = $(CPPUNIT_LIBS) diff --git a/test/UnitClient.cpp b/test/UnitClient.cpp index 03682fdc5..bd2378eb3 100644 --- a/test/UnitClient.cpp +++ b/test/UnitClient.cpp @@ -72,7 +72,9 @@ UnitBase *unit_create_wsd(void) } // Allows re-use of UnitClient in test.cpp impls. -#define UNIT_CLIENT_TESTS +#ifdef STANDALONE_CPPUNIT +# error "Should never be compiled this way"; +#endif #include <test.cpp> /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/test/test.cpp b/test/test.cpp index 57a7c8ff9..6613fb9b2 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -30,6 +30,9 @@ #include <Poco/FileStream.h> #include <Poco/StreamCopier.h> +#include <Unit.hpp> +#include <wsd/LOOLWSD.hpp> + #include <Log.hpp> #include "common/Protocol.hpp" @@ -172,16 +175,10 @@ bool runClientTests(bool standalone, bool verbose) if (!envar && failures.size() > 0) { std::cerr << "\nTo reproduce the first test failure use:\n\n"; -#ifndef UNIT_CLIENT_TESTS - 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"; - if (getenv("UNITTEST")) - { - std::cerr << "To debug:\n\n"; - std::cerr << " (cd test; CPPUNIT_TEST_NAME=\"" << (*failures.begin())->failedTestName() << "\" gdb --args " << cmd << ")\n\n"; - } +#ifdef STANDALONE_CPPUNIT // unittest + const char *cmd = "./unittest"; + std::cerr << "To debug:\n\n"; + std::cerr << " (cd test; CPPUNIT_TEST_NAME=\"" << (*failures.begin())->failedTestName() << "\" gdb --args " << cmd << ")\n\n"; #else std::string aLib = UnitBase::get().getUnitLibPath(); size_t lastSlash = aLib.rfind('/'); @@ -195,108 +192,8 @@ bool runClientTests(bool standalone, bool verbose) return result.wasSuccessful(); } -// Versions assuming a single user, on a single machine -#ifndef UNIT_CLIENT_TESTS - -std::vector<int> getProcPids(const char* exec_filename) -{ - std::vector<int> pids; - - // Ensure we're in the same group. - const int grp = getpgrp(); - - // Get all lokit processes. - for (auto it = Poco::DirectoryIterator(std::string("/proc")); it != Poco::DirectoryIterator(); ++it) - { - try - { - const Poco::Path& procEntry = it.path(); - const std::string& fileName = procEntry.getFileName(); - int pid; - std::size_t endPos = 0; - try - { - pid = std::stoi(fileName, &endPos); - } - catch (const std::invalid_argument&) - { - pid = 0; - } - - if (pid > 1 && endPos == fileName.length()) - { - Poco::FileInputStream stat(procEntry.toString() + "/stat"); - std::string statString; - Poco::StreamCopier::copyToString(stat, statString); - std::vector<std::string> tokens(LOOLProtocol::tokenize(statString, ' ')); - if (tokens.size() > 6 && tokens[1].find(exec_filename) == 0) - { - // We could have several make checks running at once. - int kidGrp = std::atoi(tokens[4].c_str()); - // Don't require matching grp for --debugrun invocations. - if (kidGrp != grp && !IsDebugrun) - continue; - - switch (tokens[2].c_str()[0]) - { - // Dead & zombie markers for old and new kernels. - case 'x': - case 'X': - case 'Z': - break; - default: - pids.push_back(pid); - break; - } - } - } - } - catch (const Poco::Exception&) - { - } - } - return pids; -} - -std::vector<int> getSpareKitPids() -{ - return getProcPids("(kit_spare_"); -} - -std::vector<int> getDocKitPids() -{ - return getProcPids("(kitbroker_"); -} - -std::vector<int> getKitPids() -{ - std::vector<int> pids = getSpareKitPids(); - for (int pid : getDocKitPids()) - pids.push_back(pid); - - return pids; -} - -int getLoolKitProcessCount() -{ - return getKitPids().size(); -} - -std::vector<int> getForKitPids() -{ - std::vector<int> pids, pids2; - - pids = getProcPids("(loolforkit)"); - pids2 = getProcPids("(forkit)"); - pids.insert(pids.end(), pids2.begin(), pids2.end()); - - return pids; -} - -#else // UNIT_CLIENT_TESTS - -// Here we are compiled inside UnitClient.cpp and we have -// full access to the WSD process internals. +// Standalone tests don't really use WSD +#ifndef STANDALONE_CPPUNIT std::vector<int> getKitPids() { @@ -317,12 +214,6 @@ int getLoolKitProcessCount() { return getKitPids().size(); } - -int getClientPort() -{ - return LOOLWSD::getClientPortNumber(); -} - -#endif // UNIT_CLIENT_TESTS +#endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |