Home > User Support > CoverageMaster winAMS FAQ

CoverageMaster winAMS FAQ

Test Data Settings

014_02: How can I call a static function located in another source file from a dummy function?

Question:

I am testing using dummy functions. However, if the function to be tested is a static function in another source file I cannot call it from a dummy function. How can I test it?

Answer:

A static function cannot be called from a dummy function located in another source file directly. But by using a function pointer, the target static function can be called indirectly and tested.

Static function to be tested example:

static int test_func(int a)
{
    if (a < 0) {
        return -1;
    }

    return a;
}

Dummy function example:

int (*DBG_test_func)(int);
int dbg_in, dbg_out;

void dummy_for_test_func(void)
{
    dbg_out = (*DBG_test_func)(dbg_in);
}

Add the function pointer variable (DBG_test_func) to the INPUT in the CSV. Then specify the target function's symbol name (test.c/test_func) as the test data for the function pointer variable as shown below.


Related Technical Tips Search

Other technical tips in GAIO's web site can be searched for using the links below.

Search key word link: Dummy Function | Static Function
Technical Tips Google Search



Information Links