Commit graph

5 commits

Author SHA1 Message Date
Patrick Ohly ca0b2db58c testing: help scan-tool by adding noreturn annotations
When an assert triggers, the following code does not get executed.
clang's scan-tool could not detect that because CppUnit's templates
are not annotated with the "noreturn" attribute. We already use
wrappers around CppUnit, so we can fairly easily add a fake "noreturn"
call to exit() to the assertion failure path.

While at it, avoid unnecessary inlining and update the macros to
handle parameters with commans (the necessary brackets were missing).

With this and the preceeding changes, a build with most SyncEvolution features
enabled passes scan-build without errors. There are still errors in
libsynthesis, though. See https://bugs.freedesktop.org/show_bug.cgi?id=73393
2014-01-17 16:15:16 +01:00
Patrick Ohly 4f8615ee8b Logging: eliminate _instance from SE_LOG* macros
With the _instance parameter always being NULL thanks to the previous
patch, it can be removed completely.
2013-05-06 16:28:13 +02:00
Patrick Ohly 74d6638ae1 testing: extended assert macros to include text message for each call location
The text is inserted into the call stack if the assertion
fails. Useful for tests which repeat the same line in a loop: the loop
index and associated information can be embedded in the error.
2011-11-17 08:56:31 +01:00
Patrick Ohly 2f39cb1f7a testing: log source files with only the base name
Much shorter. Currently only done for ClientTest.cpp anyway, which has
a unique name.
2011-11-09 10:37:05 +00:00
Patrick Ohly 14416b8deb testing: improved logging + CLIENT_TEST_SOURCE_DELAY
Exceptions reported by CppUnit only contained one file+line pair. If
that location was called multiple times inside a larger test, then it
was impossible to tell where it was called. The new assertion macros
and in particular CT_ASSERT_NO_THROW() solve this problem by catching
exceptions, adding the current file+line information and then
rethrowing an extended exception. When CppUnit finally logs the
problem, it will contain a complete call stack.

For this to work, every single line which might throw an exception
must be wrapped in a macro. Entering and leaving the line is logged
together with the wrapped expression as part of the test .log file.

doSync() is handled as a special case and gets the file+line info of
its caller via parameters.

New logging macros are introduced and used in LocalTests::testChanges:
instead of writing comments, call the logging macros and the string
will appear also in the .log file of the test.

Further areas for improvements:
- use CLIENT_TEST_LOG() everywhere
- reduce file names to just the base name is logged
- convert .log file into HTML with links into session logs and
  ClientTest.cpp source file
2011-11-09 10:37:05 +00:00