Difference between revisions of "Test Cleanup"

From Apache OpenOffice Wiki
Jump to: navigation, search
(subsequenttests)
(Helpers)
Line 54: Line 54:
  
 
To build and execute ''all'' these test directories, the tool <code>subsequenttests</code> (in <code>solenv/bin</code>) exists. It scans the <code>build.lst</code> files of all modules for <code>makefile.mk</code>s that mention <code>OOO_SUBSEQUENT_TESTS</code> and simply executes <code>dmake</code> in all those directories, with <code>OOO_SUBSEQUENT_TESTS</code> set. It supports a <code>-P<var>n</var></code> switch to build <var>n</var> directories in parallel.
 
To build and execute ''all'' these test directories, the tool <code>subsequenttests</code> (in <code>solenv/bin</code>) exists. It scans the <code>build.lst</code> files of all modules for <code>makefile.mk</code>s that mention <code>OOO_SUBSEQUENT_TESTS</code> and simply executes <code>dmake</code> in all those directories, with <code>OOO_SUBSEQUENT_TESTS</code> set. It supports a <code>-P<var>n</var></code> switch to build <var>n</var> directories in parallel.
 +
 +
=== Helpers ===
 +
 +
A new module <code>test</code> shall collect reusable code snippets for C++ and Java tests.
 +
 +
For now, it concentrates on letting a test connect to an OOo instance via remote UNO: A C++ test class can hold a <code>test::OfficeConnection</code> as class member and, in its CppUnit <code>setUp</code> and <code>tearDown</code> functions, call <code>OfficeConnection::setUp</code> and <code>OfficeConnection::tearDown</code>, respectively.  Tests obtain access to the OOo instance via <code>OfficeConnection::getFactory</code>.  Similarly, a Java test class can use an <code>org.openoffice.test.OfficeConnection</code> instance, offering the same functionality as its C++ counterpart.
 +
 +
For this to work, three additional steps are necessary:
 +
* First, in <code>instsetoo_native</code>, building an installation set for the <code>openoffice</code> product in the default language (<code>en-US</code>) in any package format now takes care to always also build an archive package format (<code>tar.gz</code> resp. <code>zip</code>) of that product.
 +
* Second, building <code>smoketestoo_native</code> permanently installs that archive into the solver.  (Except on Windows, where problems with resulting long pathnames prevent this; there, as a workaround, each test individually unzips the archive to some local temporary directory.)
 +
* Third, a test that requires an OOo instance includes <code>installationtest.mk</code> in its <code>makefile.mk</code>. That file makes sure to call the CppUnit and JUnit test runners with the information necessary for the helper classes to start the correct OOo instance with a fresh <code>UserInstallation</code> and set up an URP pipe connection. The information is tunneled into the test runner executables as UNO bootstrap parameters.
 +
 +
=== <code>unoapi</code> Tests ===
  
 
== Details ==
 
== Details ==

Revision as of 07:37, 6 April 2010

Test Cleanup Project

See the mission statement mail.

User Interface

CppUnit

For tests in C++, plain CppUnit (at least version 1.12.1) is available. (OOo bundles CppUnit 1.12.1 as an external module; alternatively, you can configure --with-system-cppunit.)

Implement the test code as a dynamic library, following CppUnit conventions (i.e., using CPPUNIT_TEST_SUITE_REGISTRATION and CPPUNIT_PLUGIN_IMPLEMENT macros). The following settings are needed in the makefile.mk:

  • ENABLE_EXCEPTIONS = TRUE
  • CFLAGSCXX += $(CPPUNIT_CFLAGS)
  • SHLnRPATH = NONE
  • SHLnSTDLIBS += $(CPPUNITLIB)
  • SHLnVERSIONMAP = version.map, where that file must contain the following (see details below for improving this):
 UDK_3_0_0 {
   global:
     cppunitTestPlugIn;
   local:
     *;
 };

To run tests, sal/cppunittester delivers a cppunittester executable that has some advantages over the plain CppUnit DllPlugInTester:

  • It uses SAL_IMPLEMENT_MAIN to properly set up the per-process settings required by URE. Test code as well as tested code based on URE will expect this and would fail in a process that is not set up in this way.
  • Getting CppUnit to build as an external module within the Windows OOo build is a non-trivial task. The less parts of it that need to be built, the better.

Something like the following in makefile.mk will execute the tests:

 ALLTAR : test
 test .PHONY : $(SHL1TARGETN)
   $(CPPUNITTESTER) $(SHL1TARGETN)

$(CPPUNITTESTER) internally uses $(AUGMENT_LIBRARY_PATH_LOCAL) to favor library instances in the local output tree over ones in solver. Alternatively to the above, .INCLUDE: _cppunit.mk calls $(CPPUNITTESTER) on each of $(SHL1TARGETN), …, $(SHL10TARGETN) that is defined.

JUnit

For tests in Java, plain JUnit (at least version 4) is available. (OOo requires JUnit as a prerequisite, see junit.org for downloads; you can configure --with-junit= if it is not automatically found; alternatively, you can configure --without-junit, disabling JUnit-based tests.)

subsequenttests

Some tests have build and/or run time dependencies on modules further up in the hierarchy, or modules that the rest of the module in question does not have dependencies on (and which are thus not listed in the module's build.lst). The extreme case are tests that need a complete OOo installation as their test environment.

For such tests, the whole makefile.mk should be wrapped in:

 .IF "$(OOO_SUBSEQUENT_TESTS)" == ""
 nothing .PHONY :
 .ELSE
 ...
 .END

(and the directory included in the module's build.lst).

The idea is to do a complete OOo build first (cd smoketestoo_native && build --all) and then build and execute those tests either selectively or wholesale.

Selectively building a specific such test directory can be done with cd && OOO_SUBSEQUENT_TESTS=TRUE dmake.

To build and execute all these test directories, the tool subsequenttests (in solenv/bin) exists. It scans the build.lst files of all modules for makefile.mks that mention OOO_SUBSEQUENT_TESTS and simply executes dmake in all those directories, with OOO_SUBSEQUENT_TESTS set. It supports a -Pn switch to build n directories in parallel.

Helpers

A new module test shall collect reusable code snippets for C++ and Java tests.

For now, it concentrates on letting a test connect to an OOo instance via remote UNO: A C++ test class can hold a test::OfficeConnection as class member and, in its CppUnit setUp and tearDown functions, call OfficeConnection::setUp and OfficeConnection::tearDown, respectively. Tests obtain access to the OOo instance via OfficeConnection::getFactory. Similarly, a Java test class can use an org.openoffice.test.OfficeConnection instance, offering the same functionality as its C++ counterpart.

For this to work, three additional steps are necessary:

  • First, in instsetoo_native, building an installation set for the openoffice product in the default language (en-US) in any package format now takes care to always also build an archive package format (tar.gz resp. zip) of that product.
  • Second, building smoketestoo_native permanently installs that archive into the solver. (Except on Windows, where problems with resulting long pathnames prevent this; there, as a workaround, each test individually unzips the archive to some local temporary directory.)
  • Third, a test that requires an OOo instance includes installationtest.mk in its makefile.mk. That file makes sure to call the CppUnit and JUnit test runners with the information necessary for the helper classes to start the correct OOo instance with a fresh UserInstallation and set up an URP pipe connection. The information is tunneled into the test runner executables as UNO bootstrap parameters.

unoapi Tests

Details

Working on CWS sb118  , CWS sb120  .

CppUnit 1.12.1

  • Replace existing cppunit and testshl2 combo with latest CppUnit 1.12.1.
  • OOo configure --with-system-cppunit (for now only if also --with-system-stl!); minimal required version for now arbitrarily 1.12.1.
  • TODO: Upstream PATCH_FILES (windows.patch?!?).
  • TODO: RPATH in generated libraries and executables.
  • TODO: Improve CPPUNIT_PLUGIN_EXPORT and get rid of version maps (GCC exception problems?).
  • TODO: cppunit/makefile.mk MY_LIBS = -lm Solaris hack.
  • TODO: In general OOo build environment, no longer set CFLAGS etc. as environment variables; have package-specific OOO_package_CFLAGS etc. and combine those into CFLAGS etc. where necessary (see OOO_STLPORT_CXXFLAGS etc. in cppunit/makefile.mk).
  • TODO: Why use cppunittester instead of DllPlugInTester? (Remove building/delivering DllPlugInTester.)
  • TODO: Make CppUnit::assertion_traits<rtl::OUString> from smoketestoo_native/smoketest.cxx generally available.

testshl2

Unit Tests

  • OOO_SUBSEQUENT_TESTS (build.lst lists local dependencies of those directories, so that modifying a module and then calling “OOO_SUBSEQUENT_TESTS=x build” rebuilds the module and executes the tests).
  • TODO: If Build Environment 2.0 would build directly to solver (instead of local output tree/deliver), that would simplify tests that currently need to take care to test local libraries instead of solver ones (see, for example, OOO_TEST_PREFIX in the services.rdb of stoc/test/uriproc/makefile.mk).
  • TODO: Constructs like “-env:UNO_=$(my_file)” would fail for problematic characters (spaces!) in paths.

Smoke Test

Pre-Installed OOo

unoapi Tests

Personal tools