Commit graph

55 commits

Author SHA1 Message Date
Ashod Nakashian
05dc8a0f84 test: improved state-machine helpers
Change-Id: I10c561ae4cf5e4471f1f9eafc9ffbb77badc7284
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-04 10:26:49 -05:00
Ashod Nakashian
f95ff8205a wsd: test: fail when modified docs are unsaved
Change-Id: I444948ce96ff512491fe72f55a7b5abfcf1dab4e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 11dad9c87a979eee0fac9c85ea3387174da61760)
2022-01-11 09:28:03 +01:00
Ashod Nakashian
65d5a4f1a5 wsd: test: add slow save and upload test
Change-Id: I5c7e706a1ded7774c9da4545218ba9fa29fc9d81
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 29c26c9afee593c20bc72a668ba0c3d5634aa35b)
2022-01-11 09:28:03 +01:00
Ashod Nakashian
cdccf4d820 wsd: test: improved test state machine
This adds a better automatic test state
enum, with support for transitions.

It is intended to be used only in tests,
to simplify the writing of tests around
a state-machine.

Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit bf5e8a2d9f3b2fe99f5b46bcbd4c9e3e28853af5)

Change-Id: I8805dad57ca3c71c26cc30236d4832710e1717f9
2022-01-11 09:28:03 +01: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
Michael Meeks
b043b6213d Move LOOLWebSocket into test/ - where it can be slowly removed.
Change-Id: I388690261d323377648a1502b927e73f862ad802
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-10-11 13:40:20 +01:00
Szymon Kłos
78f68fa7ef Cleanup in Unit* subclasses
- we cannot get rid of UnitBase::get() which returns the last
  set Unit class because we use it for example in WebSocketHandler
  where we don't know which kind of test we run

- free memory correctly and reset global variables for subclasses

- setup _type member variable on construction

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: Ic61b88785bff7de63b11ce2046eecc993c3ddeaf
2021-09-22 20:31:35 +02:00
Szymon Kłos
029d4195ad android fix: use correct instance for Unit classes getter
On android we had issue with not working release builds
(worked when optimization flag -O0 was used for Unit.cpp).

Global which stored instance of UnitBase subtype was returned
after cast to a choosen subtype. Unfortunately in case when
android didn't work UnitWSD was returned in UnitKit::get() !

Thich patch makes us sure we don't cast to not-correct type.

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I98e91d8fa82a8e81a8f7cee2fe3109b67c4f64f7
2021-09-22 20:31:35 +02:00
Michael Meeks
ebc0d0aaf4 Unit: add new 'Tool' type of unit test handler.
Dummy, but useful for eg. fuzzing.

Change-Id: I9819cda898a7bf1c0fba3d1fccbb63b16955f01d
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-08-17 11:07:21 +01:00
Ashod Nakashian
f6da8d664c wsd: create the unittest SocketPoll thread only when testing
Change-Id: I901ef4722182dd44406c35528c7642414f680814
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-05-06 22:14:51 -04:00
Ashod Nakashian
5c84542c7d wsd: test: log poco exceptions
While Poco::Exception inherits from std::exception,
it's what() member returns simply the name of the
exception, which is hardly useful without the message.
Therefore, we are forced to log it's displayText()
member for the full error message.

Change-Id: I650614a9b4b3bb1b2e31841c37250a2a069e6b77
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-05-02 22:35:39 -04:00
Ashod Nakashian
858a4aa398 wsd: test: UnitBase takes the test name from derived classes
Change-Id: Id3c7b35ee03cbade44effffeedfbdd65c015612d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 714ae5d0314a60a498d5d4800882ed704988dfb8)
2021-05-02 22:35:39 -04: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
04640009f4 wsd: test: move SocketPoll to UnitBase
This is the SocketPoll used by async
WebSocket clients.

Change-Id: I2ec3c0ff9984a6a0c457fd3189a3d7833061147e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-27 08:09:49 -04:00
Ashod Nakashian
a7b2f14074 wsd: test: single UnitBase ctor with default name
We always want to have some default name so
we can log something relevant. Having
two constructors isn't very helpful,
especially because we must initialize all
members in only one initialization list
(since we call the default-ctor from the
overloaded one).

Having a single constructor with a default
parameter is one of few cases where default
parameters are justified.

Change-Id: Ia2d390be46ea7ad5486248d7ede7a7c95c4352e3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-27 08:09:49 -04:00
Ashod Nakashian
0f94eb261c wsd: test: killpoco in UnitCopyPaste
Change-Id: I2657a095e0a9d79b678c826db46b9c69d9aac056
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-27 08:09:49 -04:00
Ashod Nakashian
15b6ddccd0 wsd: test: move inherited filterSendMessage to onFilterSendMessage
This allows the UnitBase class to handle the messages
and dispatch to convenient handlers. This simplifies
the implementation of unit-tests and makes the
parsing more centralized than it is now.

Change-Id: Ice8f169ecfd12d49ee7cbd4fb9021a163b14f4ba
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-13 08:07:06 -05:00
Ashod Nakashian
1fb968ac08 wsd: test: remove redundant wakeupWorld and log the exit status
And introduce passTest and failTest to log a reason
and be more informative when reading logs.

Change-Id: I5090793b802a29135de8ea3783a457e189cc7df3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-13 08:07:06 -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
Ashod Nakashian
3b4add03ef wsd: test: store the current test name in UnitBase
Change-Id: Iaf521f6a99dcd6e6465769aed7f3757332e04f7d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-28 12:04:53 -04:00
Ashod Nakashian
13d7d23cbe wsd: use chrono for readability and conversion safety
Change-Id: If5d478605fef0199b331d91310673a460e70d48e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-22 11:24:13 -05:00
Ashod Nakashian
cb4beaca34 wsd: avoid the using keyword and use C++ size_t
size_t in C and in C++ are not necessarily the same
type. The C++ size_t is in the std namespace. Since
we do include many C headers, and indeed some C++
runtime headers do define size_t for backwards
compatibility, it's easy to mix and match the two
types.

Also, 'using std::size_t;' isn't a great practice,
so removed.

This is not exhaustive, just some low-hanging cases.

Change-Id: I85a36b6fd1acd204274b1869de9bcb94c8b3cf13
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-15 15:41:41 -05:00
Andras Timar
0002fdfd6c fix license headers
Change-Id: I8623770b32d278a45357dc7f757fabfadd2b4af7
2020-10-01 11:56:43 +02:00
Ashod Nakashian
e68be80496 wsd: add http-headers unit-test
This is to defend the sneaking of extra http-headers
in the access_header URI param that was recently fixed.

Change-Id: Ic28cf58854847ac278bed8043f398b107f7992b3
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96862
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
2020-07-01 07:37:10 +02:00
Tor Lillqvist
4eb598711c Use #pragma once
LibreOffice core uses that, too, and we support an even more
restricted set of compilers.

Change-Id: I0d0e2c8608e323eb5ef0f35ee8c46d02ab49a745
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92467
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
2020-04-18 15:00:18 +02:00
Michael Meeks
7eea5b85ab Remove unused filterHandleRequest unit test hook.
Change-Id: Id1ff6005e28bf02eb9cad3c1609f9a8079640689
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90155
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-03-07 14:26:42 +01:00
Miklos Vajna
d8e6fa411c fuzzer: fix this up so it works again
After fixing this single assertion failure, the

./loolwsd_fuzzer --config-file=loolwsd.xml --o:storage.filesystem[@allow]=true --o:logging.level=fatal

invocation works. (It does not really fuzz anything, but it's a single
unpriviliged process at least.)

Change-Id: I45f877e5eb023e3ddfc96a7373c6300e4bb77962
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89115
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-02-20 18:03:10 +01:00
Michael Meeks
9dfac6dab1 test: switch to parallel tests based on Unit framework.
Increase a few timeouts, bin old-style standalone unit tests,
fix a number of bugs.

Change-Id: Ia3d59466ecb9a9443807ba3445d04dd5f77e3dba
2020-01-21 15:07:54 +00:00
Jan Holesovsky
f0ea9701d8 killpoco: Use std::thread instead of Poco::Thread.
Change-Id: I533429412f269cff8714407f3b99aef0ff133abf
Reviewed-on: https://gerrit.libreoffice.org/82199
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
2019-11-07 12:24:01 +01:00
Tor Lillqvist
98dab7d74f Avoid assertion failure in the iOS app
There is just one process, and the UnitBase::Global is dummy, its type
is irrelevant.

Change-Id: I73fd0c32e50dd698161f25dbc3f4c8655776286a
2019-08-12 13:20:52 +03:00
Michael Meeks
4a9de331ed Unit testing - add more hooks and helpers.
Change-Id: Ieb12699e3b012606eaa0be3cc94d6f9b58adc441
2019-08-05 21:08:01 -04:00
Michael Meeks
36e9d5b376 TileCache: re-factor API to work in terms of vectors, not file references.
Change-Id: Ia9d48773121ab965b79ddb16b55b5d3fdcd7fd5c
2019-02-14 21:46:39 +01:00
Michael Meeks
fa74404019 Add a time limit for badly behaved / huge document load / conversions.
Also improve debug printing of load times in dumpstate.

Change-Id: Ib3fd70dffb57588cd90bd928c4be9890cee8bc65
2018-11-08 01:27:40 +00:00
Tor Lillqvist
95eb849217 Still more iOS app and related Online C++ code hacking
Re-think the plumbing between the different parts of the C++ Online
code. Do try to have it work more like in real Online on all but the
lowest socket level. Except that we don't have multiple processes, but
threads inside the same process. And instead of using actual system
sockets for WebSocket traffic between the threads, we use our own
FakeSocket things, with no WebSocket framing of messages.

Reduce the amount of #ifdef MOBILEAPP a bit also by compiling in the
UnitFoo things. Hardcode that so that no unit testing is ever
attempted, though. We don't try to dlopen any library.

Corresponding changes in the app Objective-C code. Plus fixes and
functionality improvements.

Now it gets so far that the JavaScript code thinks it has the document
tiles presented, and doesn't crash. But it hangs occasionally. And all
tiles show up blank.

Anyway, progress.

Change-Id: I769497c9a46ddb74984bc7af36d132b7b43895d4
2018-09-19 11:31:18 +03:00
Tor Lillqvist
75438baa70 More mobile app stuff, very much early state of work in progress
Re-think Linux vs mobile ifdefs a bit. Use #ifdef __linux only to
surround code that actually is Linux-specific. Use #ifdef MOBILEAPP
for code that is for a mobile version (with no separste wsd, forkit,
and kit processes, and with no WebSocket protocol used).

Bypass UnitFoo for mobile. Possibly we do want the UnitFoo stuff after
all on mobile, to run in some special testing mode? Hard to say, let's
skipt it for now.
2018-09-10 15:13:43 +03:00
Pranav Kant
39f11ab4f7 document conflict: unit test
Change-Id: I4ea310fe5adb198bc7b5e083f6bd4b0431c0cdef
2018-02-09 00:22:57 +05:30
Jan Holesovsky
343c5bc690 tdf#99744 SaveAs: Extend test to check that the Save As result was sent.
Change-Id: I3788b87d2599c01000af97f496ee2b840c0cae3e
2017-10-26 11:11:38 +02:00
Jan Holesovsky
7f49b1eba6 PutFile ext: X-LOOL-WOPI-IsAutosave header to indicate autosave + unit test.
Change-Id: I65ed711dae5100467fe6ed9902bd7bad8c7f8d68
Reviewed-on: https://gerrit.libreoffice.org/43074
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
2017-10-03 12:04:18 +02:00
Jan Holesovsky
cef217ea24 wsd: Fix the OAuth unit test.
Trying to combine the Poco's http server together with our polling loop leads
only to problem; so instead let's introduce a hook where we can do the WOPI
serving directly in the unit test.

Change-Id: Id3fec6ff93c3ad652aa4e0fc6309c5b7639728cb
2017-08-09 22:27:49 +02:00
Michael Meeks
7ea5f71a7b Units: allow filtering of user alerts.
Catch things that kill tests like disk-full earlier.

Change-Id: Ib50b516063305f2fc93b662ec3ad9ab6c52c6c92
2017-06-16 20:25:23 +01:00
Michael Meeks
9e45fb30d7 SocketDisposition: push it down the stack, and cleanup around that.
Dung out overlapping return enumerations. Move more work into 'move'
callbacks at a safer time, etc.

Change-Id: I62ba5a35f12073b7b9c8de4674be9dae519a8aca
2017-05-05 18:37:26 +01:00
Michael Meeks
2bca560feb Add hook for disk space check. 2017-03-31 17:18:41 +01:00
Michael Meeks
bb3fa00631 UnitPrefork - restore most of the functionality.
No need for the memory reporting bits now that Admin gets this right.
2017-03-16 19:13:14 +00:00
Michael Meeks
ab67d605e6 Unit tests: use WSD's main socket-poll for test timeouts. 2017-03-16 18:52:49 +00:00
Michael Meeks
8749f4f2e3 Cleanup unit test hooks. 2017-03-16 18:32:12 +00:00
Tor Lillqvist
79e08f3de2 Drop parameter that always was defaulted anyway
Change-Id: I6eee99db120e8a4aeb0e27586390bdc1bad9e219
2017-01-16 12:59:03 +02:00
Tor Lillqvist
11ae90cfcb No Hungarian notation please
Change-Id: Ia624de45a792db7e39f2245aaea7d940b30b0db2
2017-01-13 14:52:08 +02:00
Noel Grandin
05f88bf9a5 loplugin:redundantcast
Change-Id: I14945f34d3ab6d3c148b40e95069159bf40bd99e
Reviewed-on: https://gerrit.libreoffice.org/32370
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-12-27 10:45:42 +00:00
Tor Lillqvist
6a9e733118 Indentation fix
Change-Id: I7ac537049995356dc33377311ef82e9916dbd98a
2016-12-27 12:35:21 +02:00
Noel Grandin
6c0022fb10 loplugin:staticmethods
Change-Id: Idf9596cfbbd6eef77e6271a1108d64dae864ed27
Reviewed-on: https://gerrit.libreoffice.org/32366
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-12-27 10:34:20 +00:00