libzypp
13.10.6
|
ZYpp has a suite of tests located in under test/ directory of the source tree.
Right now, tests are grouped into
Tests are written using boost test library.
The file should be in one of the described groups, and by general rule it is named ClassName_test.cc where ClassName is the name of the class or module the test covers.
Data and fixtures are stored in data/ directories in each test group. However groups may use and reference data from other test groups. The macro TESTS_SRC_DIR is defined as the tests/ directory located in libzypp source directory. You can build the paths to the data/fixtures using that macro.
A simple testcase:
$ cd build $ cmake -DCMAKE_INSTALL_PREFIX=/prefix .. $ cd tests $ make
$ zypp/Date_test Running 1 test case... *** No errors detected
$ ctest .
- added tests/data/openSUSE-11.1 containing raw susetags metadata. Keeping .solv files in svn is somewhat inconvenient, as you must rebuild them if something in libsolv changes.
- added tests/include as location for includes that might be used in multiple testcases.
- added tests/include/TestSetup.h to ease building a test environment below some tempdir. Currently supports easy setup of Target, RepoManager and loading data (raw metadata and .solv files) into the pool. That's how it currently looks like: #include "TestSetup.h" BOOST_AUTO_TEST_CASE(WhatProvides) { TestSetup test( Arch_x86_64 ); // use x86_64 as system arch test.loadTarget(); // initialize and load target test.loadRepo( TESTS_SRC_DIR"/data/openSUSE-11.1" ); This is all you need to setup Target, RepoManager below some temp directory and load the raw metadata into the pool. In case you want to setup the system below some fix directory, use: TestSetup test( "/tmp/mydir", Arch_x86_64 ); You directory is used as it is and not removed at the end.
- Added support for loading helix files e.g. from testcases. This is what you need to load all repos from a solver testcase into the pool: #include "TestSetup.h" BOOST_AUTO_TEST_CASE(test) { TestSetup test( Arch_x86_64 ); test.loadTestcaseRepos( "/suse/ma/BUGS/153548/YaST2/solverTestcase" );