Commit graph

95 commits

Author SHA1 Message Date
Ashod Nakashian
3a91ff3e4e wsd: test: exit on failure to load unit-test lib
We now exit immediately with error code when
we are given --unitlib argument but fail to
load the given library.

Change-Id: I4eb5f3a37b9838ecf83bdceef4d09f888afcca83
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-09-25 08:58:39 +02:00
Michael Meeks
85152bf953 Typos: wake-up.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I8ae12c8c8390997bbde7af1e203e9075dfa4ea25
2023-07-17 11:35:25 +02:00
Ashod Nakashian
1cac1f1698 wsd: test: do not advance to next test on failure
Change-Id: I2831c90e088064f5a254ef8a9809796e8320ed04
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-07-08 04:19:00 -04:00
Ashod Nakashian
d50b4e4b1c wsd: test: dump state on test failure
Seems a useful thing to capture the internal
state when a test fails, as it might help
understand what was going on.

Change-Id: I591a88662ab86ab4dc7f39dafcc4d7d279a4d9c4
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-07-08 04:19:00 -04:00
Ashod Nakashian
e5f274c65c wsd: test: better test timeout thread management
Change-Id: I156d3563c13bd303e628d5a76fc2a48e6141bcf2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-06-14 07:04:26 -04:00
Ashod Nakashian
cec4cf087a wsd: test: initialize logs before unit-tests
Make sure that the logging subsystem is
already initialized before starting
unit-tests.

Change-Id: I2ce3ffdb2d3b0094ae7ed496d7cacfc02af89c21
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-31 07:40:11 -04:00
Ashod Nakashian
d0ed6cd3d2 wsd: test: do not start the next test if test is not finished
Change-Id: Ibdcf66f9a037f6b4e2e575cb61fe1459c912e44f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-03-10 07:45:12 -05:00
Tor Lillqvist
31135177e4 Fix compiler warnings when building for WASM.
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I0fd4fe36cece9caaeb076a0e91894890186706d0
2023-02-12 15:55:24 +01:00
Ashod Nakashian
92c36dadd9 wsd: test: start next test only after destroying the current
Change-Id: I6924ff288fddd1ad5315b2bf19345d541682bc92
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-01-30 07:52:08 -05:00
Ashod Nakashian
7569f2bcd2 wsd: test: wrap DocBroker destroy callback
This prepares to start the next test
when the DocBroker of the current one
is destroyed.

Change-Id: I3a9672d8d03ad497f15a9bca262dfe1d4f197e41
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-01-30 07:52:08 -05:00
Ashod Nakashian
8003833a84 wsd: test: better UnitWOPIAsyncUpload_Modify
We now upload 3 times to succeed.

This simulates a user modifying and saving
twice before giving up and closing the
document, which succeeds in uploading.

Change-Id: Ida40f79a76fc94436c0d4b4fc1ad3e7b7acc997b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-01-23 11:07:55 -04:00
Ashod Nakashian
db50626aff wsd: test: refactor BaseUnit self-test
The BaseUnit test didn't belong to UnitTimeout
and, more important, it needed access to
private members to both validate their state
and to reset them (since the test is artificially
initializing both WSD and Kit tests and cannot
uninitialize them, lest we unload ourselves).

As such, the self-test is now internal to
BaseUnit, with the added bonus that it
is called on all tests and not just UnitTimeout.

Also, more assertions have been added.

Change-Id: Ieaf60594f39e978a7250407262bd8bbc9b642c43
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-01-23 11:07:55 -04:00
Ashod Nakashian
13b1534f16 wsd: test: cleanup exitTest logs
There is no reason to print the test name
explicitly when each log entry is already
prefixed by the test name.

Change-Id: I72c0a0f2989a65f477902b97e6be816446fba5c3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-12 08:00:05 -05:00
Ashod Nakashian
798712301f wsd: test: support keepgoing option
Change-Id: I397e9225972e5b50b5b9c91b44ba75bc829bfb04
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-12 08:00:05 -05:00
Ashod Nakashian
8051543a51 wsd: test: proper test options
Change-Id: Icfe5125b8fcf1ec902fff19c594cd1ffa598de71
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-12 08:00:05 -05:00
Ashod Nakashian
0146f65c7c wsd: test: minor cleanup in UnitBase
Change-Id: I2e857456895e8070ec9d2479e526186d411191b2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-12 08:00:05 -05:00
Ashod Nakashian
49aec68f11 wsd: test: logging
Change-Id: I820e3ddbdb38cdde2ee34c144c08866ab6720495
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-30 05:14:55 -05:00
Ashod Nakashian
42ce410ff2 wsd: test: fix rare deadlock on stopping
Since UnitBase (and children) are invoked from
different threads, UnitBase::exitTest could
have a race. This ultimately results in
invoking std:🧵:join() concurrently,
which is unsafe. This can result in the
following deadlock.

In this case websrv_poll had invoked
UnitBase::exitTest concurrently and
evidently finished, leaving the main
coolwsd thread deadlocked.

	(gdb) info thread
	  Id   Target Id                                     Frame
	* 1    Thread 0x7f67528f0840 (LWP 4058508) "coolwsd" __futex_abstimed_wait_common64 (private=128, cancel=true, abstime=0x0, op=265, expected=4058510, futex_word=0x7f675285c910)
		at ./nptl/futex-internal.c:57
	(gdb) t a a bt

	Thread 1 (Thread 0x7f67528f0840 (LWP 4058508) "coolwsd"):
	#0  __futex_abstimed_wait_common64 (private=128, cancel=true, abstime=0x0, op=265, expected=4058510, futex_word=0x7f675285c910) at ./nptl/futex-internal.c:57
	#1  __futex_abstimed_wait_common (cancel=true, private=128, abstime=0x0, clockid=0, expected=4058510, futex_word=0x7f675285c910) at ./nptl/futex-internal.c:87
	#2  __GI___futex_abstimed_wait_cancelable64 (futex_word=futex_word@entry=0x7f675285c910, expected=4058510, clockid=clockid@entry=0, abstime=abstime@entry=0x0, private=private@entry=128) at ./nptl/futex-internal.c:139
	#3  0x00007f67529cd6a4 in __pthread_clockjoin_ex (threadid=140081742857792, thread_return=0x0, clockid=0, abstime=0x0, block=<optimized out>) at ./nptl/pthread_join_common.c:105
	#4  0x00007f6752d42337 in std:🧵:join() () from /lib/x86_64-linux-gnu/libstdc++.so.6
	#5  0x000055775c5fa8e0 in SocketPoll::joinThread (this=0x55775cc9b090) at net/Socket.cpp:282
	#6  0x000055775c5c8121 in UnitBase::endTest (this=this@entry=0x55775cc0fe80, reason="") at common/Unit.cpp:545
	#7  0x00007f67528df61f in UnitWSDClient::endTest (this=0x55775cc0fe80, reason="") at ./UnitWSDClient.hpp:118
	#8  0x000055775c5cc4d1 in UnitBase::exitTest (this=0x55775cc0fe80, result=result@entry=UnitBase::TestResult::Ok, reason="") at common/Unit.cpp:486
	#9  0x00007f67528d1fa3 in UnitWOPIFileUrl::invokeWSDTest (this=0x55775cc0fe80) at UnitWOPIFileUrl.cpp:269
	#10 0x000055775c4accdb in UnitWSD::invokeTest (this=0x55775cc0fe80) at ./common/Unit.hpp:318
	#11 0x000055775c4a38cd in COOLWSD::innerMain (this=0x7ffd34248650) at wsd/COOLWSD.cpp:5459
	#12 0x000055775c4a59db in COOLWSD::main (this=<optimized out>) at wsd/COOLWSD.cpp:5706
	#13 0x00007f6753ab0877 in Poco::Util::Application::run() () from /lib/libPocoUtil.so.80
	#14 0x000055775c48316c in main (argc=14, argv=0x7ffd34248898) at wsd/COOLWSD.cpp:5845

Change-Id: If6162690462719f14a35241604f8a59b38a806c0
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-30 05:14:55 -05:00
Ashod Nakashian
ed6254ac36 wsd: test: capture the original test result
Change-Id: I7818bdac0350a1afce81266093cce32d9796bba8
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-30 05:14:55 -05:00
Ashod Nakashian
6c697b0cfd wsd: test: convert TestResult to STATE_ENUM
Change-Id: Ic1a7a24e35edd7a403fabe6be040b7e28b12eb79
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-30 05:14:55 -05:00
Ashod Nakashian
397d41a00b wsd: test: remove returnValue overrides
These only served to delete the Unit singletons,
but since we have GlobalArray, deleting them
isn't needed.

Change-Id: Ia2e53a1e3b43707196f45c06c38c6bb664c18e29
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-30 05:14:55 -05:00
Ashod Nakashian
f6301194ae wsd: test: add endTest to clean-up tests
Change-Id: I6d97471a5ab60682da8f01675cddbd766a2c0ba9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-30 05:14:55 -05:00
Ashod Nakashian
92ccdcdeb8 wsd: test: wakeup world when starting a new test
This is needed so we stop the DocBroker of
the old test, which is now finished.

Change-Id: I05df85fbbeca254928cd9a140198e7f4ae89fec8
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-30 05:14:55 -05:00
Ashod Nakashian
cccf7aa0be wsd: test: filter subsequent tests
Apply the test filter on all tests,
not just the first.

Change-Id: Ib34e90e883f5de2ddcf04c710f433cb54677575d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-21 08:45:17 -05:00
Ashod Nakashian
5b45b2807f wsd: test: invoke configure for each test
Now that we may have multiple tests in a
single unit-test module, we should call
UnitWSD::configure for each one, not just
once at the start. Each test can modify
the configuration settings to meet its
test conditions.

Change-Id: I08de2d998edee5b4cbade08f2496196b596a8600
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-21 08:45:17 -05:00
Ashod Nakashian
dad2b5e92a wsd: test: capture the reason in exitTest
When invoking exitTest it's useful to know
something about the reason. Whether it's
because the test passed or timed out,
it's useful to log this information.

Change-Id: I8e8ae525b7c2ef1de2e394d08107341cdc87c008
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-21 08:45:17 -05:00
Ashod Nakashian
672c958b89 wsd: test: log all test names before running
Now that multiple tests and filtering are
supported, it's useful to know what tests
exist in each unit-test module.

Change-Id: Ifaa7eccabab6b23a57edf2786c0cd726ab0265db
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-21 08:45:17 -05:00
Ashod Nakashian
57456f7ff6 wsd: test: filter tests using COOL_TEST_OPTIONS
Using the envar COOL_TEST_OPTIONS, which is
provisioned to support other options than
just filtering, it is now possible to
only run the tests with names partially
matching the filter's case-insensitive
string.

Change-Id: I6168887677fd0fddd72bac2538837615b10b9fae
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-21 08:45:17 -05:00
Ashod Nakashian
e969859ef3 wsd: test: log test start and finish visibly
Change-Id: Ie374f5d617db188faa24066d494c91f4f5d49c60
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-21 08:45:17 -05:00
Ashod Nakashian
c652757724 wsd: test: return the correct type from hooks multi
Change-Id: I057c90e9b4d5f749ff0dda74a5aa20f3afc3b24f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-21 08:45:17 -05:00
Ashod Nakashian
956f37c7a7 wsd: test: merge the results of all tests
Since we can have multiple tests in a single
unit-test .so, we need to merge the results
of each test into a single result that is
used when we exit the process and flag for
failure or success.

Change-Id: Ia49f5542efd6dd998b61c17965fd3fe3245159ba
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-15 07:04:58 -05:00
Ashod Nakashian
a4dbd25d4e wsd: test: rename setHandle to initialize
Since we no longer need to set the handle,
this function is an initialization of the
given test, before running it.

Change-Id: Ia6fb16b06dd548977fcfcc35a81ac37d979be29d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-15 07:04:58 -05:00
Ashod Nakashian
370f60a8ed wsd: test: support multitests
This adds support for multiple tests
within a single unit-test .so.

We did have many, many tests within
the converted "old style" tests already.
Except, they couldn't support the proper
event-driven tests, nor were they running
as fast as possible. They also blocked the
main thread in COOLWSD.

With this support, we can now avoid
creating a new .so for each test case.
This will reduce the effort to add new
tests and the build time. In addition,
the execution of each unit-test is
dominated by the initialization, which
takes in the order of 5 seconds. Running
multiple tests after this high load time
reduces the per-test average time.

Later we will support listing tests,
running particular tests (i.e. filtering)
and other debugging and troubleshooting
facilities.

Change-Id: I7be43994265ebabdb5d379f7726bb9bd7f78795a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-15 07:04:58 -05:00
Ashod Nakashian
cc222a708c wsd: test: make dlhandle static and properly cleanup
We now properly cleanup unit-tests .so libs.

This helps having multiple tests by making
the dlhandle an independent variable of
all the tests.

Change-Id: Ifc8db400aebfe8ea41dcc4df2d11856c25b36074
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-15 07:04:58 -05:00
Ashod Nakashian
0b2afe2bfd wsd: test: use a global array to support multiple tests
This adds support to having multiple tests in
a single unit-test .so.

Change-Id: I37526484e8a692b25393f659dedd846eedc22733
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-15 07:04:58 -05:00
Ashod Nakashian
fc3514f74f wsd: test: log multiple exitTest cases with different results
Normally, we should exit a test with a single result:
either a success or a failure. It is, however,
possible to have an early success that forgoes
proper cleanups and cause subsequent failures.

Here, we at least log these cases, because it
could unintentionally hide real failures.

Change-Id: I17e6365bd54b3f7336976fb51437776811733eb8
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-12 18:45:35 -05:00
Szymon Kłos
7043365475 masterpage: get & set optional mode parameter for tiles (server side)
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I756e3d515c86a635cfa9db81106848ee3dcf684a
2022-09-19 15:18:23 +02:00
Ashod Nakashian
d6cf1f0532 wsd: minor code-coverage improvements
Change-Id: If9d16bdb37944220635c27d98595c2ebcb19a51d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-02 14:45:12 -04:00
Ashod Nakashian
71ce1a4f54 wsd: test: support filtering Kit messages
Change-Id: Ic747f805689ad9d639857f0ea8af1529433b5f11
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-06-27 14:07:08 +01:00
Ashod Nakashian
ae71f8be82 wsd: test: filterSendMessage -> filterSendWebSocketMessage
Change-Id: I0254c05e12cde676de8fde99e16f7eface09dceb
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-06-27 14:07:08 +01:00
Ashod Nakashian
ecda47edd9 wsd: test: handle save notifications in tests
Change-Id: Ic6b0abcd2ad2f2a895ff81acaf875147d9990c8b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-06-10 13:14:35 +01:00
Michael Meeks
8eebe1e345 Tile-deltas, expose TileData to unit tests.
Change-Id: I5f33a56009927187b460775129f0818f47843368
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-10 09:35:47 +01:00
Ashod Nakashian
c6561a99d8 wsd: test: correctly stop SocketPoll in UnitTimeout
Change-Id: I97317e8155e5c65d12e985cc837f07bfcf6a56d6
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-05-06 14:45:34 +01:00
Ashod Nakashian
9a69adf766 wsd: test: always set the test name
Change-Id: Ibce5cf049ad1a1df7b11412ed7160d280ece60f3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-05-06 14:45:34 +01:00
Ashod Nakashian
97a6d1cd98 wsd: support experimental features
This adds a new config option to enable/disable
experimental features and behavior. The default
value can be controlled at build time by
--enable-experimental.

Change-Id: Iffcb4c71d9e0933a646251b63033b6dadcd3b809
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-17 18:46:46 -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
Ashod Nakashian
17ef1a4b80 wsd: test: more consistent test logging
And some include cleanup.

Change-Id: I3807553bf2abe6d36c5cc521bc82e5b089ae91ea
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-17 18:52:48 -05:00
Ashod Nakashian
4369d14c14 wsd: test: terminate promptly when tests finish
No need to wait for a 'clean' shutdown when
a test finishes, regardless of the results.

Change-Id: Ie242d716ad681506a1272c8dd2e8cf1a2b91e69c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-17 18:52:48 -05:00
Ashod Nakashian
44796fc6c9 wsd: test: improvements
Change-Id: I2ed744f8d1a8a472645e5db46789226d6d3ba04a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-17 18:52:48 -05:00
Ashod Nakashian
aad22ee83c wsd: test: better logging
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit ec3613ba2df43cffe6baafafa41e5337a43070aa)

Change-Id: I5e245d0ac5c185943586d6aec651f606f8e23bb8
2022-01-11 09:28:03 +01:00