Scenario: To vary the execution of testcases depending on the flag definition in the test script.
The two common scenarios that one could think of are:
For example, the below STUB has to be selected only when “Target1” macro defined in preprocessor section of rtp configuration setting.
Otherwise this STUB has to be ignored.
But this STUB is still selected when “Target1” macro is not defined in preprocessor section of rtp.
##if defined (Target1)
Including the below code in .otd file, will not work for the requirement
However you will find that both the above scenarios will not vary the execution flow. That is because .stb, .otd, .dcl are not C++ file and so ##if directive are not taken into account at code generation time, but only written into the generated code as is. So the .stb file generate code, but also generate behavior in the test driver and those behavior won't be affected by the ##if written into the stub code part.
If you want to have different behavior with and without STUB, the unique possibility is to write your Test Cases into separate files and INCLUDE them into your OTDs. Write multiple OTD including common TestCases files:
So you should have one node with stub and another without STUB with simple OTD file, that include the same TestCase file.
Note that Test Case execution without STUB should not have CHECK STUB statement for non-existing stubs.