IBM Support

How to stub macros in Rational Test RealTime

Question & Answer


Question

How do you stub macros in IBM Rational Test RealTime?

Cause

Macros cannot be stubbed. You can only stub C functions and C++ methods.

Answer

The macros that you stub needs to be converted to a C function or C++ method call .

Below is a sample on how to convert a C macro to a function call and stub it.

Example : You have the following macro defined in the file calc.h.

#define doAdd(x,y) (x + y)

Then it can be redefined to a C function call as below:

function call:

#ifndef doAdd
#define doAdd(x,y) (x + y)
#endif

Now in the DCL file you can write

#{
#define doAdd(x,y) stubAdd(x,y)
extern int stubAdd(int x, int y);
#include "calc.h"
#include "calc.cpp"
}#



Note: For code under test to be included, such that the new macro definition takes affect in the code, you need to modify the .STB file

STUB stubAdd : int stubAdd(int x, int y)
{
PRINT ("In stubAdd");
...
#return (x + y);
}



Attached is the sample snippet of the code.

Disclaimer

All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.


StubCPP.zipStubCPP.zip

[{"Product":{"code":"SSSHUF","label":"Rational Test RealTime"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Component Testing","Platform":[{"code":"PF033","label":"Windows"},{"code":"PF027","label":"Solaris"},{"code":"PF016","label":"Linux"},{"code":"PF010","label":"HP-UX"},{"code":"PF002","label":"AIX"}],"Version":"7.5;8.0;8.0.0.1;8.0.0.2;8.0.0.3","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
16 June 2018

UID

swg21622389