Commit graph

40 commits

Author SHA1 Message Date
Patrick Ohly
b99e3bea06 testing: run one test per client-test instance
When client-test starts, it determines all tests that would get
run, then runs all of them one-by-one in new instances. A single
test gets run directly.

The output changes slightly: the CppUnit summary with number of
failures or errors is no longer available and there are additional
blank lines between tests.

The advantage is that each single test is properly isolated from the
other, which is closer to how real syncs run. It also helps when
running under valgrind, because a leak can be attributed exactly to
one test and because it avoids permanently growing memory consumption
in long-running client-test runs (seen in the nightly testing even
when there were no leaks, perhaps because of memory fragmentation).

A potential downside of this change is that unexpected and undesirable
side effects of modules might no longer show up in testing, only when
combining them in real syncs. This should still be covered by
Client::Sync tests involving multiple modules.
2014-10-10 03:17:47 -07:00
Patrick Ohly
5fed9ef3e6 testing: avoid unitialized members after constructor
cppcheck warned about this. This wasn't actually a problem (one member
was not used at all, the other was set later), but for the sake of
clean cppcheck scans let's fix it.
2014-01-17 16:15:15 +01:00
Patrick Ohly
649837c2c2 Logging: thread-safe
Logging must be thread-safe, because the glib log callback may be
called from arbitrary threads. This becomes more important with EDS
3.8, because it shifts the execution of synchronous calls into
threads.

Thread-safe logging will also be required for running the Synthesis
engine multithreaded, to overlap SyncML client communication with
preparing the sources.

To achieve this, the core Logging module protects its global data with
a recursive mutex. A recursive mutes is used because logging calls
themselves may be recursive, so ensuring single-lock semantic would be
hard.

Ref-counted boost pointers are used to track usage of Logger
instances.  This allows removal of an instance from the logging stack
while it may still be in use. Destruction then will be delayed until
the last user of the instance drops it. The instance itself must be
prepared to handle this.

The Logging mutex is available to users of the Logging module. Code
which holds the logging mutex should not lock any other mutex, to
avoid deadlocks. The new code is a bit fuzzy on that, because it calls
other modules (glib, Synthesis engine) while holding the mutex. If
that becomes a problem, then the mutex can be unlocked, at the risk of
leading to reordered log messages in different channels (see
ServerLogger).

Making all loggers follow the new rules uses different
approaches.

Loggers like the one in the local transport child which use a parent
logger and an additional ref-counted class like the D-Bus helper keep
a weak reference to the helper and lock it before use. If it is gone
already, the second logging part is skipped. This is the recommended
approach.

In cases where introducing ref-counting for the second class would
have been too intrusive (Server and SessionHelper), a fake
boost::shared_ptr without a destructor is used as an intermediate step
towards the recommended approach. To avoid race conditions while the
instance these fake pointers refer to destructs, an explicit
"remove()" method is necessary which must hold the Logging
mutex. Using the potentially removed pointer must do the same. Such
fake ref-counted Loggers cannot be used as parent logger of other
loggers, because then remove() would not be able to drop the last
reference to the fake boost::shared_ptr.

Loggers with fake boost::shared_ptr must keep a strong reference,
because no-one else does. The goal is to turn this into weak
references eventually.

LogDir must protect concurrent access to m_report and the Synthesis
engine.

The LogRedirectLogger assumes that it is still the active logger while
disabling itself. The remove() callback method will always be invoked
before removing a logger from the stack.
2013-05-06 16:28:13 +02:00
Patrick Ohly
2f6f880910 Logging: merge Logger and LoggerBase
Having two separate classes had little (no?!) benefit and just
caused confusion.
2013-05-06 16:28:13 +02: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
6130b46b72 testing: ignored failures could lead to false overall success
The code which marked a failure as "ignored" unintentionally
cleared the overall error flag, causing client-test runs
with ignored and real failures to return 0 = success.
2012-06-26 08:25:21 +00:00
Patrick Ohly
5eab589a26 testing: moved code into client-test main()
The SyncContext::initMain() must be called in main(), to give
all global instances a chance to influence the operation (like
registering platform init code). This failed for KDE when
the order of global instance instantiation happened to be wrong.

Setting signal handlers there also makes more sense.

The reason for doing process initialization in src/client-test-app.cpp
was that the rest of the code was meant to be SyncEvolution and Unix
independent. That's less of a concern today.
2012-05-24 08:41:37 +00:00
Patrick Ohly
f42f009a89 testing: minimize shell calls from client-test
Running additional commands from client-test becomes more
expensive when client-test runs under valgrind with tracing
of children (as needed for local sync testing). It also create
additional output (at least a valgrind header+footer per command).

Avoid calling additional commands as much as possible. Specifically:
- fork/exec synccompare in the simple case (avoids one /bin/sh call)
- avoid setting PATH via env before searching for synccompare (expected
  to be in the PATH when client-test is called)
- use that simple case for all servers (appending the synccompare
  output again at the end of a test log via CLIENT_TEST_COMPARE_LOG
  isn't that useful and was missing from some servers anyway)
- copy files with some C code instead of invoking cp or cat
- do the translation of logs to html in runtests.py
2012-04-26 11:36:36 +00:00
Patrick Ohly
5589ac6117 testing: allow regex in CLIENT_TEST_SKIP/FAILURES
Both comma separated lists may now contain regular expressions, which
is very useful to ignore or skip one test for all data categories, for
example.

Because tests names did not have special characters in them, previous
values still work as before for a literal match against just one test.
2011-11-28 10:18:19 +01:00
Patrick Ohly
37f360d33d testing: generate HTML version of .log files and ClientTest.cpp
The HTML version of the .log files links to ClientTest.cpp.html,
colorizes important parts and links to the sync session
directories.

Because it is much more useful than the plain text version, the
nightly.html now links to these .html files.

ClientTest.cpp.html is built with Python pygments if installed,
otherwise some builtin fallback code is used.
2011-11-09 10:37:05 +00:00
Patrick Ohly
ad4710fa2f testing: log final error as ERROR
Useful in combination with syntax highlighting of the .log file.
2011-11-09 10:37:05 +00:00
Salvatore Iovene
09a09a89ed test/{ClientTest,client-test-main}.cpp: fix warnings.
The return value of 'system' should not be ignored.
2011-06-07 16:07:45 +02:00
Patrick Ohly
fed4e6b3b9 client-test: redirect synccompare output
The stdout of synccompare was no longer redirected into
the .log file of the test it belonged to. Enabled that
again by redirecting both stderr and stdout.
2011-05-05 20:16:10 +08:00
Patrick Ohly
6ea0886317 LogRedirect: fixed "glib" test
The test failed only because the test's own introduction text on
stdout ended up being redirected. Flushing it before running the
test avoids that.

The flushing was added to both the client runner (because some other
tests also accidentally redirected the output, and it should be
made visible right away) and to the "glib" test (because it shouldn't
depend on flushing in the runner).
2011-02-04 16:14:13 +01:00
Patrick Ohly
70d515871f client-test: stderr redirection was broken
The LogRedirect instance created in main() was not flushed often
enough because the LoggerStdout instance pushed into the stack after
it intercepted all output, so the LogRedirect instance was never
invoked during a test.

This patch solves that by replacing the LoggerStdout with a
LogRedirect instance. This instance is then called by the LogDir
logger.
2011-01-27 16:10:43 +01:00
Patrick Ohly
41fc547730 client-test: enabled stderr output redirection
client-test ran without redirection stderr, which produces a lot of
output in the console in particular with the mKCal backend. This patch enables
stderr redirection (as usual, only if SYNCEVOLUTION_DEBUG is not set).
All normal output now goes to stdout/std::cout.
2010-12-10 13:16:30 +01:00
Patrick Ohly
61d7733774 client-test: SYNCEVOLUTION_DEBUG disables creation of .log files
Running client-test with SYNCEVOLUTION_DEBUG set now prints all debug
messages to the console directly instead of writing them into per-test
.log files. This is useful when running tests like Client::Local which
do not involve the Synthesis engine. Whe using the Synthesis engine,
the normal HTML .log files are easier to read.
2010-12-01 12:32:48 +01:00
Patrick Ohly
0e5e4979cc client-test: increase log level when SYNCEVOLUTION_DEBUG is set
Same change as for command line - let SYNCEVOLUTION_DEBUG increase
the log level to DEBUG.
2010-12-01 12:32:43 +01:00
Patrick Ohly
19f703588f nightly testing: avoid shutdown issues due to caching Evolution sources (BMC #5864)
Destroying ORBit based Evolution backends at the very end of the
process life time caused assertions in ORBit. Added explicit cleanup
code which is called before triggering the normal library shutdown by
leaving main().
2010-09-01 18:01:19 +02:00
Patrick Ohly
c7aa99e5b2 stdout: never write to std::cout directly (MB #5041)
Cmdline and SyncContext standard output should always go
through a variable that can be pointed towards the actual
output channel.

Cmdline already had m_out for that, but it wasn't used
everywhere. Fixed.

SyncContext now has setOutput()/getOutput() and that is
used in SyncContext.cpp. It is not set anywhere yet.

To catch incorrect use of cout or cerr inside SyncEvolution,
the SyncEvo namespace defines its own cout and cerr which cannot
be used like std::cout/cerr, thus triggering compiler
errors. Use "std::cout/cerr" when necessary.
2010-03-29 11:01:35 +02:00
Patrick Ohly
71fbf32c94 files and classes renamed, include statements cleaned up
The intention is to get rid of the historic and inconsistent
naming of some classes and their corresponding files:
* EvolutionSyncClient = class derived from Funambol's SyncClient,
* SyncEvolutionConfig = SyncEvolution's config

With the strict 'namespace SyncEvo' and the syncevo/ path prefix for
most header files it is no longer necessary to have "SyncEvolution" or
"Evolution" in the names. This patch thus renames as follows:
  EvolutionSyncClient => SyncContext
  EvolutionSmartPtr => SmartPtr
  SyncEvolutionCmdline => Cmdline
  SyncEvolutionConfig => SyncConfig
  SyncEvolutionUtil => util

The former EvolutionSyncClient always had a role that went beyond just
running a sync, for example it also provided config access. With the
upcoming server support it also won't be just a client. Thus the new
name "SyncContext".

The 'syncevo/' prefix is used throughout the code now.

removed whenever the prefix made it clear that the file belongs
to SyncEvolution. This helps finding incorrect include paths.

Quotes should be used exclusively for SyncEvolution files which don't
have a specific prefix yet (test.h, config.h) to help identifying
them.
2009-10-05 14:49:32 +02:00
Patrick Ohly
f87ffd682d introduced "namespace SyncEvo" consistently
Added syncevo/declarations.h, which has

This is now used for all SyncEvolution source files, except
for the GTK UI, which is written in plain C. In the library
it helps to avoid name clashes.

The reason for using defines instead of spelling out "namespace SyncEvo"
is twofold:
1. if that should ever become necessary, it is easier to
   rename the namespace via configure options by changing
   the define
2. editors don't indent the whole file content
2009-10-02 17:27:45 +02:00
Patrick Ohly
2f94b34c86 Testing: keep synccompare error output (____compare.log) around
Instead of calling rm, simply keep the file. This might be useful
when running a single test. When running multiple tests, tee will
overwrite the old one.
2009-07-30 11:04:10 +02:00
Chen Congwu
6cb4728543 Testing: let synccompare error output go to corresponding case log file.
Set CLIENT_TEST_COMPARE_LOG to let syncompare result goto log fle as well
as showing on the stdout.
2009-07-30 10:10:51 +02:00
Patrick Ohly
3217ac8630 license: merged LGPL v2.1 -> LGPL v2.1 + v3 change
Followed the license change applied to the upstream content
and applied the same LGPL v2.1 + v3 license to content
created at Intel.
2009-04-30 18:35:56 +02:00
Patrick Ohly
82debf7326 license: changed to LGPL v2.1 + v3
As with the previous change from AGPLv3 to LGPL v2.1, this is covered
by copyright ownership and/or the Funambol contributor agreement.

The motivation for adding v3 is greater flexibility regarding
reusing the code in other places and relicensing it.
2009-04-30 18:26:27 +02:00
Patrick Ohly
25a8502a4b copyright updated
update-copyright.sh can be used to add copyright remarks for the current
year. It finds the authors who made a change in each file and adds/updates
their copyright remark. Intel employees are grouped under "Intel Corporation".
2009-03-25 15:21:04 +01:00
Patrick Ohly
dae1b8854d testing: relicensed as LGPL v2.1, like the rest of the code
This is permitted by the Funambol contributor agreement (copy
is in doc/Sync4jContribution.pdf). It reduces the license mix
and allows distributing synccompare without special precautions.
2009-03-25 14:43:54 +01:00
Patrick Ohly
642585610b testing: print CPPUnit failures directly after each failed test 2009-03-25 14:43:47 +01:00
Patrick Ohly
9c38b5c034 compiler warnings: check result of log writing 2009-03-25 14:43:47 +01:00
Patrick Ohly
8e9512cd20 testing: fixed log handling during Client::Sync
The logdir is now overridden so that all files (client.log, message
dumps, Synthesis logs) are written in a subdirectory names after
the current test. A <test>.log file captures all output written
outside of the sync itself.
2009-03-25 14:43:37 +01:00
Patrick Ohly
52ed0258d3 testing: one log file is created per test
The file is named after the current test, with : replaced by underscores.
This gets all log message outside of sync sessions. Those are still written into
separate files whose name needs to be adapted.
2009-03-25 14:43:36 +01:00
Patrick Ohly
41aaec7eb2 testing: compiles and runs again, but output redirection is not working yet 2009-03-25 14:43:36 +01:00
Patrick Ohly
1170ba8b38 ClientTest: better infrastructure for data file comparisons
File names now only contain a single underscore instead of
multiple ones. The compare functions can be called so that they
return the result instead of throwing an assertion (useful for
doing multiple comparisons and then checking the result).
The synccompare Perl script is told to print the file names
that it is comparing.
2009-03-25 14:43:31 +01:00
Patrick Ohly
953db52a5b fixed invalid parameters for CPPUNIT macro in the 'timed out' error situation
git-svn-id: https://core.forge.funambol.org/svn/core/top-level/branches/b_v65/3x/client-api/native@21452 e8e8ed6c-164c-0410-afcf-9e9a7c7d8c10
2009-03-25 14:43:26 +01:00
Andrea Toccalini
90eb9f7132 updated license to AGPL
git-svn-id: https://core.forge.funambol.org/svn/core/top-level/branches/b_v65/3x/client-api/native@21417 e8e8ed6c-164c-0410-afcf-9e9a7c7d8c10
2009-03-25 14:43:25 +01:00
Matteo Vitolo
66e4de9766 copyright updated
git-svn-id: https://core.forge.funambol.org/svn/core/top-level/trunk/3x/client-api/native@17292 e8e8ed6c-164c-0410-afcf-9e9a7c7d8c10
2009-03-25 14:43:23 +01:00
Patrick Ohly
02333c6b39 first draft of API documentation via Doxygen
git-svn-id: https://core.forge.funambol.org/svn/core/top-level/trunk/3x/client-api/native@15371 e8e8ed6c-164c-0410-afcf-9e9a7c7d8c10
2009-03-25 14:43:19 +01:00
Patrick Ohly
b76e2dcd31 fixed incorrect copyright
git-svn-id: https://core.forge.funambol.org/svn/core/top-level/trunk/3x/client-api/native@12091 e8e8ed6c-164c-0410-afcf-9e9a7c7d8c10
2009-03-25 14:43:16 +01:00
Patrick Ohly
768464c846 added a C++ client test framework, moved test runner to new 'test' directory
git-svn-id: https://core.forge.funambol.org/svn/core/top-level/trunk/3x/client-api/native@11726 e8e8ed6c-164c-0410-afcf-9e9a7c7d8c10
2009-03-25 14:43:15 +01:00