Project

General

Profile

Cetbuildtools user guide - Cetbuildtools cmake modules - Defining products in the CET build environment - Using the example - Buildtool script

Unit tests

Every package needs unit tests for code validation.
Cetbuildtools has defined macros which extend the cmake ctest facility.

include(CetTest)

Include this in your test/CMakeLists.txt file

cet_test( <test_name> )

Use this in your test/CMakeLists.txt file.
Builds and runs a test named <test_name> from <test_name>.cc.

Usage: cet_test(<test_name> [<options>] [<args>] [<data-files>])
Options:
  • HANDBUILT
  • -- Do not build the target -- it will be provided.
  • -- This option is mutually exclusive with the PREBUILT option.
  • PREBUILT
  • -- Do not build the target -- pick it up from the source dir (eg scripts).
  • -- This option is mutually exclusive with the HANDBUILT option.
  • NO_AUTO
  • -- Do not add the target to the auto test list.
  • USE_BOOST_UNIT
  • -- This test uses the Boost Unit Test Framework.
  • INSTALL_EXAMPLE
  • -- Install this test and all its data files into the examples area of the product.
  • INSTALL_SOURCE
  • -- Install this test's source in the source area of the product.
Args:
  • DATAFILES
  • -- Input and/or references files to be copied to the test area in the build tree for use by the test.
  • -- The DATAFILES keyword is optional provided the placement of the files in the argument list is unambiguous.
  • DEPENDENCIES
  • -- List of top-level dependencies to consider for a PREBUILT target.
  • -- Top-level implies a target (not file) created with ADD_EXECUTABLE, ADD_LIBRARY or ADD_CUSTOM_TARGET.
  • LIBRARIES
  • -- Extra libraries with which to link this target.
  • SOURCES
  • -- Sources to use to build the target (default is ${target}.cc).
  • TEST_ARGS
  • -- Any arguments to the test to be run.
  • TEST_EXEC
  • -- The exec to run (if not the target).
  • -- The HANDBUILT option must be specified in conjunction with this option.
  • TEST_PROPERTIES
  • -- Properties to be added to the test.
  • -- See documentation of the cmake command, "set_tests_properties."