Topic
  • 5 replies
  • Latest Post - ‏2013-01-24T07:45:33Z by SystemAdmin
SystemAdmin
SystemAdmin
2260 Posts

Pinned topic Control Macro function in my Test case

‏2012-12-04T05:13:54Z |
Hi All,
I am working on windows xp with RTRT 7.5.0.4.
i have a code like this: "#define CLAMP() (0u)" in my *.h file which is called from source file.
And I need the control to modify the macro function CLAMP()used in my code to do testing of a specific functionality.
I tried using undef define ifdef ifndef but no luck. I cant modify the code hence i have to control this macro function from the ptu. And i want a variable to control this macro function so that i can use it in different test cases body.
If somebody can provide some solution for the same it will be of great help.

thanks in advance.
Updated on 2013-01-24T07:45:33Z at 2013-01-24T07:45:33Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    2260 Posts

    Re: Control Macro function in my Test case

    ‏2012-12-06T06:28:50Z  
    Hi Richard,
    Could you please help me regarding this!
  • richard.france
    richard.france
    846 Posts

    Re: Control Macro function in my Test case

    ‏2012-12-06T07:55:09Z  
    Hi Richard,
    Could you please help me regarding this!
    TestRT unit test is a C code generator.
    If you cannot do it using C code that means you cannot do it using TestRT.
    I assume the header file (.h) is included by the source code (.c)
    you have a solution only If your header file is protected against multiple inclusion like

    #ifndef myHeader_H
    #define myHeader_H
    ....
    #endif
    If not then try to see if you can made the modification because this is a standard coding rule to protect header file like this.
  • SystemAdmin
    SystemAdmin
    2260 Posts

    Re: Control Macro function in my Test case

    ‏2012-12-18T09:14:08Z  
    Thanks for your help.

    i have tried one more solution for my problem n its working fine for my project.
    I used the below command in my ptu

    ##include "D:\PU_1_RTRT\SW\abc.h" /* Original header file*/
    ##undef CLAMP /* Undefining Macro function*/
    #uint8 value; /* User defined new variable*/
    #define CLAMP() value /* Defining new value*/
    ##include "D:\ PU_1_RTRT\SW\abc.c" /* Original Source file*/

    Let me know if we can do the same in some other way.

    Thanks again Richard.
  • richard.france
    richard.france
    846 Posts

    Re: Control Macro function in my Test case

    ‏2012-12-18T10:35:10Z  
    Thanks for your help.

    i have tried one more solution for my problem n its working fine for my project.
    I used the below command in my ptu

    ##include "D:\PU_1_RTRT\SW\abc.h" /* Original header file*/
    ##undef CLAMP /* Undefining Macro function*/
    #uint8 value; /* User defined new variable*/
    #define CLAMP() value /* Defining new value*/
    ##include "D:\ PU_1_RTRT\SW\abc.c" /* Original Source file*/

    Let me know if we can do the same in some other way.

    Thanks again Richard.
    I do not know any other way to do it
    and, as I said, It only works if your header is protected against multiple inclusion.
  • SystemAdmin
    SystemAdmin
    2260 Posts

    Re: Control Macro function in my Test case

    ‏2013-01-24T07:45:33Z  
    I do not know any other way to do it
    and, as I said, It only works if your header is protected against multiple inclusion.
    yes,in my code,the header was protected against multiple inclusion,then i did like
    ##include "......./.h"
    ##undef xxxx
    #u8 aaa;
    ##define xxxx aaa
    ##include "......./.c"
    is OK