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
- 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
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
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>
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>
This is the SocketPoll used by async
WebSocket clients.
Change-Id: I2ec3c0ff9984a6a0c457fd3189a3d7833061147e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
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>
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>
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>
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>
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>
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>
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>
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
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.
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
Dung out overlapping return enumerations. Move more work into 'move'
callbacks at a safer time, etc.
Change-Id: I62ba5a35f12073b7b9c8de4674be9dae519a8aca