ADTF
3.18.5
|
Implements basic functionality to test whether compile process fails (or succeeds) More...
Classes | |
struct | platform_specific |
platform specific settings More... | |
struct | platform_specific< 0 > |
struct | platform_specific< 1 > |
struct | to_generator |
"stringify" the cmake generator More... | |
struct | to_generator< cCompileTimeTest::CCT_GENERATOR_DEFAULT > |
struct | to_generator< cCompileTimeTest::CCT_GENERATOR_PLATFORM_DEFAULT > |
struct | to_generator< cCompileTimeTest::CCT_GENERATOR_UNIX_MAKEFILES > |
struct | to_generator< cCompileTimeTest::CCT_GENERATOR_VS14_WIN64 > |
struct | to_generator< cCompileTimeTest::CCT_GENERATOR_VS15_WIN64 > |
Public Types | |
enum | eCCTCMakeGenerators { CCT_GENERATOR_DEFAULT = 0 , CCT_GENERATOR_PLATFORM_DEFAULT = 1 , CCT_GENERATOR_UNIX_MAKEFILES = 2 , CCT_GENERATOR_VS14_WIN64 = 3 , CCT_GENERATOR_VS15_WIN64 = 4 } |
All currently supported CMake generators. Usable in tBool cCompileTimeTest::SetUp() More... | |
Public Member Functions | |
cCompileTimeTest (A_UTILS_NS::cFilename &&i_strProjectPath, A_UTILS_NS::cFilename &&i_strCmakeCommand=CMAKE_DEFAULT_COMMAND_SET) | |
Constructor. More... | |
~cCompileTimeTest () | |
Destructor. | |
template<tInt Generator = CCT_GENERATOR_DEFAULT> | |
tBool | SetUp (A_UTILS_NS::cString &&i_strTargetName) |
Generate build files and initially build a target. More... | |
tBool | BuildTarget (A_UTILS_NS::cString &&i_strTargetName) |
Build a target from the cmake project. More... | |
const A_UTILS_NS::cString & | GetOutput () const |
Get the console output of the last executed command. More... | |
Private Member Functions | |
tBool | SetUp (A_UTILS_NS::cString &&i_strTargetName, A_UTILS_NS::cString &&i_strGenerator) |
Generate build files and initially build a target. More... | |
tBool | TearDown () |
Deletes the entire build directory (automatically called on destruction). More... | |
A_UTILS_NS::cString | GetBuildDir () const |
Get the current build directory. More... | |
A_UTILS_NS::cString | GetAdtfDir () const |
Get directory to ADTF installation which is under test in the current test bench. More... | |
Private Attributes | |
const A_UTILS_NS::cFilename | m_strProjectPath |
path to project containing targets to build | |
const A_UTILS_NS::cFilename | m_strCmakeCommand |
path to cmake executable to use | |
A_UTILS_NS::cString | m_strConsoleOut |
Contains output of the last executed command. | |
Implements basic functionality to test whether compile process fails (or succeeds)
This class may be used inside the ordinary ADTF test functions to check whether a (cmake) project can be compiled. This is especially useful if for a test to succeed, the compilation process of a target must fail. A "project under test" must be set up the following way:
As an example, we have two targets to build (one compiles successfully, one fails to compile). In this example, the project directory contains three files:
With CMakeLists.txt containing:
The path to the ADTF installation dir is evaluated using ${ADTF_DIR}
which is perfectly fine to use, as it is passed to cmake from inside the test call (as command line argument ADTF_DIR:PATH = "path/to/adtf/"
. As a result it is also perfectly fine to add include directives to ADTF includes in the source files to test.
After the project is created and ready to be tested, cCompileTimeTest
comes into play. An object of cCompileTimeTest
is created with the path to the cmake project, which is the path to the directory containing the CMakeLists.txt file. To initially generate the project, cCompileTimeTest::SetUp()
is called which does two things:
The latter case is to prevent further compile executions to fail for the wrong reasons. For example, the target compile_fail should fail as a result to some invalid code snippet, but might unintentionally fail due to changes in the include hierarchy which would also yield a compilation error (which is not the intended error we hoped for).
To finally check whether compilation succeeds or fails, call cCompileTimeTest::BuildTarget()
on as many targets as you like.
An example on how to use this inside a functional tester is given below.
Definition at line 95 of file compile_test.h.
enum eCCTCMakeGenerators |
All currently supported CMake generators. Usable in tBool cCompileTimeTest::SetUp()
Definition at line 110 of file compile_test.h.
cCompileTimeTest | ( | A_UTILS_NS::cFilename && | i_strProjectPath, |
A_UTILS_NS::cFilename && | i_strCmakeCommand = CMAKE_DEFAULT_COMMAND_SET |
||
) |
Constructor.
[in] | i_strProjectPath | Path to the cmake project |
[in] | i_strCmakeCommand | Path to the CMake executable to use. |
tBool BuildTarget | ( | A_UTILS_NS::cString && | i_strTargetName | ) |
Build a target from the cmake project.
[in] | i_strTargetName | Name of the target to compile. |
|
private |
Get directory to ADTF installation which is under test in the current test bench.
|
private |
Get the current build directory.
const A_UTILS_NS::cString& GetOutput | ( | ) | const |
Get the console output of the last executed command.
|
inline |
Generate build files and initially build a target.
Currently the build directory is created in the systems $TEMPDIR$.
[in] | i_strTargetName | Name of the target to test the initial build on. |
Generator | See eCCTCMakeGenerators for current supported generator types. |
Definition at line 140 of file compile_test.h.
|
private |
Generate build files and initially build a target.
[in] | i_strTargetName | Name of the target to test the initial build on. |
[in] | i_strGenerator | The generator name, see eCCTCMakeGenerators . |
|
private |
Deletes the entire build directory (automatically called on destruction).