Commit Graph

33 Commits (master)

Author SHA1 Message Date
Ashod Nakashian fe3c3bc135 wsd: test: move WebSocketSession under test
WebSocketSession is used exclusively for tests,
so it's best that it is located in the test
directory.

Change-Id: I88333d619902df7991c3f26b94ed309246446ae0
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-03-21 09:08:51 +00:00
Ashod Nakashian 61cf7b9601 wsd: clean up unused header includes
Clang-tidy recommendation driven header
include clean-up.

Change-Id: I30c32866b7798e70df0463ee6bc7a0bcc3de5049
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-08 08:38:48 +01:00
Michael Meeks 7183a3d3de spdx: improve machine and human readability of headers.
Change-Id: Ice934380029bf27054e830fffc07a5d037d1430f
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-11-14 19:36:31 +00:00
Ashod Nakashian 3bbb1761cb wsd: test: improvements to unit-load test
This disables the unreliable reload test.

On a slow box, sometimes the load takes
a little longer than 5 seconds. Waiting
a bit longer doesn't hurt in these cases.

Also, remove duplicate test and give each
test case its own testname.

Change-Id: I556f6da9e49a7fa4cd9917bc9964dd9561b93817
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-09-25 08:58:39 +02:00
Henry Castro d39d2cd798 test: fix unit-load missing 'readonly=1' token
Change-Id: I064dc4017a31ed177439212240c0c1041554fc2b
Signed-off-by: Henry Castro <hcastro@collabora.com>
2023-09-15 10:21:53 -04:00
Ashod Nakashian 4363e2abe0 wsd: test: correct message example in comment
Change-Id: Id7bb0fba2e7233cf3f8167e46af7e4f99901dbaf
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-06-20 03:55:19 -04:00
Ashod Nakashian 31bd6f6308 wsd: test: improved UnitLoad
And re-enable a number of previously
disabled tests. They seem stable.

Change-Id: I6d263708edbf1ca0411500a6876e110be8acb326
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-31 07:40:11 -04:00
Ashod Nakashian 6b3566c4ff wsd: test: header and forward declaration cleanup
Change-Id: I3161c61695a2c1daa505e8276899e0a2d6d26d18
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-14 18:15:39 -05:00
Ashod Nakashian 4e9acddc42 wsd: test: killpoco for UnitLoad
We now use our http::Socket and SocketPoll
instead of Poco.

Change-Id: I30a4dc1b762caba1ecfad8f5784871b2bba583f6
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-07-25 14:02:00 +01:00
Ashod Nakashian c4c05aa20d wsd: test: killpoco for UnitLoad
We now use our http::Socket and SocketPoll
instead of Poco.

Change-Id: I3035ea1d335b05d6ced677a91f32f0233380a5a8
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-07-25 14:02:00 +01:00
Ashod Nakashian 1d96fe827a wsd: test: remove default testname arg from helpers
Change-Id: Iecbc2c1fa2a7568aedeaa0b089c3ca0a584488f5
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-07-25 14:02:00 +01:00
Ashod Nakashian 480fb7b931 wsd: move tokenizer helpers into StringVector
In an attempt to reduce the size of Util.{c,h}pp
which has grown to contain all sorts of unrelated
helpers, we move StringVector helpers into
the StringVector.{c,h}pp files.

This makes the code better organized.

Change-Id: I152f341606807ae66253415b951bc9f89b09df57
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-12 07:39:07 -04:00
Ashod Nakashian 52f2600cf9 wsd: test: embue all tests with a name and unify logs
Now the remaining tests that didn't have a name
get one and the logs are unified between old-
and new-style tests. Mostly.

This makes sure that all logs and assertions
properly log the test name and make test
failures easier to debug and fix.

Change-Id: Id159ffacc81642a6ec594c5143498408adab67cf
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-17 18:52:48 -05:00
Andras Timar f07ff8c7e0 rename: remaining lool->cool changes
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: Ib7d4e804bebe52dead8d53b0e0bbaed0f08bf3d0
2021-11-18 14:14:11 +01:00
Miklos Vajna 656eb310bb Fix Debian 8 / gcc-4.9 warnings
net/HttpRequest.cpp:126:19: error: declaration of 'end' shadows a member of 'this' [-Werror=shadow]

kit/Kit.cpp:163:29: error: missing initializer for member 'statfs::f_bsize' [-Werror=missing-field-initializers]

kit/Kit.cpp:171:14: error: 'OVERLAYFS_SUPER_MAGIC' was not declared in this scope

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: Ibbd35ab5af3adad403ed22a0aeb70917b9e21970
2021-04-30 10:38:09 +02:00
Ashod Nakashian b47c81e7a8 wsd: improved WebSocketSession interface
SocketPoll is captured as weak_ptr into
WebSocketSession and a much better shutdown
support is now available. The new logic
can do async-shutdown after flushing and
will do sync-shutdown if SocketPoll is
no longer around.

Change-Id: Ia206cab58a13f20f7aeb3a6d8c57afee731c8231
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-27 08:09:49 -04:00
Ashod Nakashian 92fa2fd081 wsd: test: improved UnitLoad test
Change-Id: I231b20793f4bb10f7560d0d59e345021062567c0
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-11 18:43:36 -04:00
Ashod Nakashian fecf32d872 wsd: test: use WebSocketSession::create in unit test
Change-Id: Ib4aecd163237220f80ff9e169c4a463ef2c08983
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-11 01:05:20 -04:00
Ashod Nakashian eb2424feb9 wsd: WebSocketSession create helper and shutdown member
Change-Id: I1cdf3f4f763a66972c9c84cec6a80f380ebcc2db
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-11 01:05:20 -04:00
Ashod Nakashian 7b2a0da05b wsd: WebSocketSession handshake and wait for message
With improved test.

Change-Id: I137a35195a81a4d2fbf530be3805e5350cb78644
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-11 01:05:20 -04:00
Ashod Nakashian 4c759357d7 wsd: test: new document-load test with WebSocketSession
Change-Id: I6253091a9fc20fce6b263d0e62a137e5de942671
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-11 01:05:20 -04:00
Ashod Nakashian f791e5bab6 wsd: test: new WebSocket load Test using http::Request
Change-Id: I4a7c854c14d17f87bb319f516d8f428749b137b4
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-11 01:05:20 -04:00
Ashod Nakashian 5c6cd3aaec wsd: test: properly include config.h in the tests
When config.h is not included, the build
configuration is missing from the translation
unit in question. This affects ENABLE_SSL,
for one.

Also, HttpRequest.hpp depends on LOOLWSD_VERSION,
which is defined in config.h.

The config.h header must be included in all
trasnlation-units, and must be the first include.
This is to avoid conflicts and/or mismatching
binaries built with different compile-time values.

We also statically assert if LOOLWSD_VERSION
is not defined, to help the error message.

Change-Id: Ic4b45de879f3360a07e9507fdf04abfa4cec6a71
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-02 12:43:39 -04:00
Ashod Nakashian e6ece7dff6 wsd: add FileUrl tests
Change-Id: I7f9ba86ceb5a31f0133c0d36dee090348386ea95
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-09 10:45:37 -05:00
Ashod Nakashian 96c9e03b88 wsd: test: catch and fail WSD tests when exceptions are thrown
Change-Id: Ifaabb6387d86c5a80e00cd5de34093520a1e9d66
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-28 12:04:53 -04:00
Andras Timar 0002fdfd6c fix license headers
Change-Id: I8623770b32d278a45357dc7f757fabfadd2b4af7
2020-10-01 11:56:43 +02:00
Ashod Nakashian d2d0492245 wsd: move LOOLProtocol::tokenize to Util::tokenize
The tokenizer(s) are more generic than the protocol
logic, and are used from contexts that don't involve
the protocol as such.

Change-Id: Ie8c256bf11a91e466bff794021f41603c9596a7f
2020-06-02 18:03:36 +01:00
Ashod Nakashian 82560d9657 wsd: test assertion macros
Because the new-style tests are intrustive,
the exception that CppUnit throws on assertion
failures is caught and processed with the
application logic, which is far from ideal,
because it's very difficult to find the
cause of failure.

What we'd like is a way to control what happens
when an test assertion fails, such that we can
properly log/print the failure, and even break
in the debugger.

The new macros allow us to control the behavior
at compile-time and have added flexibility.
For now, they log an assertion failure before
invoking the CPPUNIT macro, and support a
compile-time directive to assert, which is
useful for breaking in the debugger.

Change-Id: If464ba246e3ec747f31496a4215cb73ef735dfaf
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/87625
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-03-14 15:45:00 +01:00
Miklos Vajna b8bd1990aa Rework LOOLProtocol::tokenize() to return a StringVector object
The bulk of this commit just changes std::vector<std::string> to
StringVector when we deal with tokens from a websocket message.

The less boring part of it is the new StringVector class, which is a
wrapper around std::vector<std::string>, and provides the same API,
except that operator[] returns a string, not a string&, and this allows
returning an empty string in case that prevents reading past the end of
the underlying array.

This means in case client code forgets to check size() before invoking
operator[], we don't crash. (See the ~3 previous commits which fixed
such crashes.)

Later the ctor could be changed to take a single underlying string to
avoid lots of tiny allocations, that's not yet done in this commit.

Change-Id: I8a6082143a8ac0b65824f574b32104d7889c184f
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89687
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-02-28 16:07:56 +01:00
Miklos Vajna b580a1eaf2 wsd: fix a typo
And disable a test that passes for me locally but fails on Jenkins.

Change-Id: Ifcdcedbac259247d784ce66185f95bfbe634381f
Reviewed-on: https://gerrit.libreoffice.org/84603
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2019-12-06 12:12:43 +01:00
Miklos Vajna b5f78fe73d Convert some Calc tests to a new-style one
So that they are in-process, which means it's easier to debug when they
fail.

Also, in UnitLoad, give up on trying to avoid the sleep after
disconnecting, it seems the old condition was not reliable.

Change-Id: I972a3319887a70eeea2585104ed1e762830ca505
2019-12-06 08:51:51 +01:00
Miklos Vajna 5bf3fc86be test: fix UnitLoad::testConnectNoLoad()
Depending on timing, this failed with the following error:

wsd-14400-14411 [ docbroker_001 ] WRN  Will not load document marked to destroy. DocKey: [/tmp/connectNoLoad_27c61e41_hello.odt].| wsd/DocumentBroker.cpp:520

Make sure we don't try to load the same document again when the cleanup
for the previous session is not done yet.

Change-Id: I354999fa934df665b48dca314d2b77ab95c84ec0
2019-12-05 08:48:32 +01:00
Miklos Vajna 0580f51f85 Convert doc load tests to a new-style one
So that they are in-process, which means it's easier to debug when they
fail.

Change-Id: I2dcef46ec76e1f971172d1c29adf09103cfeaa7b
2019-11-22 09:07:33 +01:00