common/FileUtil.cpp | 10 ++++++++-- common/FileUtil.hpp | 3 +++ test/TileCacheTests.cpp | 33 ++++++++++++++++++--------------- test/helpers.hpp | 5 +++-- test/httpwserror.cpp | 4 ++-- 5 files changed, 34 insertions(+), 21 deletions(-)
New commits: commit 4580ed4e275b0d0889c7a73a129be758e41b150b Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Thu Jan 5 22:46:00 2017 -0500 wsd: prefix the test docs with the test name This makes debugging much easier as one can readily match WSD logs with a given test. Change-Id: I8f2c83d67189038699af3f24dee205bc7efb5c28 Reviewed-on: https://gerrit.libreoffice.org/32860 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/common/FileUtil.cpp b/common/FileUtil.cpp index 0127c1a..8973d72 100644 --- a/common/FileUtil.cpp +++ b/common/FileUtil.cpp @@ -44,15 +44,21 @@ namespace FileUtil return name; } - std::string getTempFilePath(const std::string& srcDir, const std::string& srcFilename) + std::string getTempFilePath(const std::string& srcDir, const std::string& srcFilename, const std::string& dstFilenamePrefix) { const std::string srcPath = srcDir + '/' + srcFilename; - const std::string dstPath = Poco::Path::temp() + Util::encodeId(Util::rng::getNext()) + '_' + srcFilename; + const std::string dstFilename = dstFilenamePrefix + Util::encodeId(Util::rng::getNext()) + '_' + srcFilename; + const std::string dstPath = Poco::Path(Poco::Path::temp(), dstFilename).toString(); Poco::File(srcPath).copyTo(dstPath); Poco::TemporaryFile::registerForDeletion(dstPath); return dstPath; } + std::string getTempFilePath(const std::string& srcDir, const std::string& srcFilename) + { + return getTempFilePath(srcDir, srcFilename, ""); + } + bool saveDataToFileSafely(const std::string& fileName, const char *data, size_t size) { const auto tempFileName = fileName + ".temp"; diff --git a/common/FileUtil.hpp b/common/FileUtil.hpp index e018691..c8e7a3f 100644 --- a/common/FileUtil.hpp +++ b/common/FileUtil.hpp @@ -86,6 +86,9 @@ namespace FileUtil /// Returns the created file path. std::string getTempFilePath(const std::string& srcDir, const std::string& srcFilename); + /// Make a temp copy of a file, and prepend it with a prefix. + std::string getTempFilePath(const std::string& srcDir, const std::string& srcFilename, const std::string& dstFilenamePrefix); + } // end namespace FileUtil #endif diff --git a/test/TileCacheTests.cpp b/test/TileCacheTests.cpp index 17bf6da..935a8c4 100644 --- a/test/TileCacheTests.cpp +++ b/test/TileCacheTests.cpp @@ -179,8 +179,9 @@ void TileCacheTests::testSimple() void TileCacheTests::testSimpleCombine() { + const auto testname = "simpleCombine "; std::string documentPath, documentURL; - getDocumentPathAndURL("hello.odt", documentPath, documentURL); + getDocumentPathAndURL("hello.odt", documentPath, documentURL, testname); // First. auto socket1 = loadDocAndGetSocket(_uri, documentURL, "simpleCombine-1 "); @@ -265,7 +266,7 @@ void TileCacheTests::testCancelTiles() void TileCacheTests::testCancelTilesMultiView() { std::string documentPath, documentURL; - getDocumentPathAndURL("setclientpart.ods", documentPath, documentURL); + getDocumentPathAndURL("setclientpart.ods", documentPath, documentURL, "cancelTilesMultiView "); // The tile response can race past the canceltiles, // so be forgiving to avoid spurious failures. @@ -313,7 +314,7 @@ void TileCacheTests::testCancelTilesMultiView() void TileCacheTests::testUnresponsiveClient() { std::string documentPath, documentURL; - getDocumentPathAndURL("hello.odt", documentPath, documentURL); + getDocumentPathAndURL("hello.odt", documentPath, documentURL, "unresponsiveClient "); std::cerr << "Connecting first client." << std::endl; auto socket1 = loadDocAndGetSocket(_uri, documentURL, "unresponsiveClient-1 "); @@ -473,7 +474,7 @@ void TileCacheTests::testTilesRenderedJustOnceMultiClient() const auto testname4 = testname + "-4 "; std::string documentPath, documentURL; - getDocumentPathAndURL("with_comment.odt", documentPath, documentURL); + getDocumentPathAndURL("with_comment.odt", documentPath, documentURL, testname); std::cerr << "Connecting first client." << std::endl; auto socket = loadDocAndGetSocket(_uri, documentURL, testname1); @@ -563,7 +564,7 @@ void TileCacheTests::testTilesRenderedJustOnceMultiClient() void TileCacheTests::testSimultaneousTilesRenderedJustOnce() { std::string documentPath, documentURL; - getDocumentPathAndURL("hello.odt", documentPath, documentURL); + getDocumentPathAndURL("hello.odt", documentPath, documentURL, "simultaneousTilesrenderedJustOnce "); std::cerr << "Connecting first client." << std::endl; auto socket1 = loadDocAndGetSocket(_uri, documentURL, "simultaneousTilesRenderdJustOnce-1 "); @@ -678,31 +679,32 @@ void TileCacheTests::checkBlackTiles(std::shared_ptr<LOOLWebSocket>& socket, con void TileCacheTests::testTileInvalidateWriter() { + const auto testname = "tileInvalidateWriter "; std::string documentPath, documentURL; - getDocumentPathAndURL("empty.odt", documentPath, documentURL); + getDocumentPathAndURL("empty.odt", documentPath, documentURL, testname); Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL); - auto socket = loadDocAndGetSocket(_uri, documentURL); + auto socket = loadDocAndGetSocket(_uri, documentURL, testname); std::string text = "Test. Now go 3 \"Enters\":\n\n\nNow after the enters, goes this text"; for (char ch : text) { sendChar(socket, ch); // Send ordinary characters and wait for response -> one tile invalidation for each - assertResponseString(socket, "invalidatetiles:"); + assertResponseString(socket, "invalidatetiles:", testname); } text = "\n\n\n"; for (char ch : text) { sendChar(socket, ch, skCtrl); // Send 3 Ctrl+Enter -> 3 new pages - assertResponseString(socket, "invalidatetiles:"); + assertResponseString(socket, "invalidatetiles:", testname); } text = "abcde"; for (char ch : text) { sendChar(socket, ch); - assertResponseString(socket, "invalidatetiles:"); + assertResponseString(socket, "invalidatetiles:", testname); } // While extra invalidates are not desirable, they are inevitable at the moment. @@ -716,7 +718,7 @@ void TileCacheTests::testTileInvalidateWriterPage() const auto testname = "tileInvalidateWriterPage "; std::string documentPath, documentURL; - getDocumentPathAndURL("empty.odt", documentPath, documentURL); + getDocumentPathAndURL("empty.odt", documentPath, documentURL, testname); Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL); auto socket = loadDocAndGetSocket(_uri, documentURL, testname); @@ -736,11 +738,12 @@ void TileCacheTests::testTileInvalidateWriterPage() // This isn't yet used void TileCacheTests::testWriterAnyKey() { + const auto testname = "writerAnyKey "; std::string documentPath, documentURL; - getDocumentPathAndURL("empty.odt", documentPath, documentURL); + getDocumentPathAndURL("empty.odt", documentPath, documentURL, testname); Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL); - auto socket = loadDocAndGetSocket(_uri, documentURL); + auto socket = loadDocAndGetSocket(_uri, documentURL, testname); // Now test "usual" keycodes (TODO: whole 32-bit range) for (int i=0; i<0x1000; ++i) @@ -851,8 +854,8 @@ void TileCacheTests::tileInvalidatePart(const std::string& filename, const std:: const std::string testname2 = testname + "-2 "; std::string documentPath, documentURL; - getDocumentPathAndURL(filename, documentPath, documentURL); - auto socket1 = loadDocAndGetSocket(_uri, documentURL); + getDocumentPathAndURL(filename, documentPath, documentURL, testname); + auto socket1 = loadDocAndGetSocket(_uri, documentURL, testname1); sendTextFrame(socket1, "setclientpart part=2", testname1); assertResponseString(socket1, "setpart:", testname1); diff --git a/test/helpers.hpp b/test/helpers.hpp index 4c9d191..fce1cfd 100644 --- a/test/helpers.hpp +++ b/test/helpers.hpp @@ -112,9 +112,10 @@ std::vector<char> readDataFromFile(std::unique_ptr<std::fstream>& file) } inline -void getDocumentPathAndURL(const std::string& docFilename, std::string& documentPath, std::string& documentURL) +void getDocumentPathAndURL(const std::string& docFilename, std::string& documentPath, std::string& documentURL, std::string prefix="") { - documentPath = FileUtil::getTempFilePath(TDOC, docFilename); + std::replace(prefix.begin(), prefix.end(), ' ', '_'); + documentPath = FileUtil::getTempFilePath(TDOC, docFilename, prefix); std::string encodedUri; Poco::URI::encode("file://" + Poco::Path(documentPath).makeAbsolute().toString(), ":/?", encodedUri); documentURL = "lool/" + encodedUri + "/ws"; diff --git a/test/httpwserror.cpp b/test/httpwserror.cpp index 30eae2b..cc6bd0f 100644 --- a/test/httpwserror.cpp +++ b/test/httpwserror.cpp @@ -123,7 +123,7 @@ void HTTPWSError::testMaxDocuments() // try to open MAX_DOCUMENTS + 1 std::string docPath; std::string docURL; - getDocumentPathAndURL("empty.odt", docPath, docURL); + getDocumentPathAndURL("empty.odt", docPath, docURL, testname); Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, docURL); std::unique_ptr<Poco::Net::HTTPClientSession> session(createSession(_uri)); auto socket = std::make_shared<LOOLWebSocket>(*session, request, _response); @@ -165,7 +165,7 @@ void HTTPWSError::testMaxConnections() std::string docPath; std::string docURL; - getDocumentPathAndURL("empty.odt", docPath, docURL); + getDocumentPathAndURL("empty.odt", docPath, docURL, testname); Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, docURL); auto socket = loadDocAndGetSocket(_uri, docURL, testname); std::cerr << "Opened connect #1 of " << MAX_CONNECTIONS << std::endl; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits