Doc:latest/taeguide/testintg

Revision as of 05:07, 27 August 2010 by Senthilk (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Contents

Integration

After you have created the model using IDE and generated the source, add a "test" directory just below the model's root (as a peer to "app") and make subdirectories below "test" for your major functional blocks.

Python TAE Interface

The python testcase files should be present in "<model>/src/test" directory. Since you are probably already programming your test cases in Python using our testcase framework, nothing further need be done.

C TAE Interface

The Python "layer" for an exclusively "C" implementation is simple :

import openclovis.test.testcase as testcase
                
class test(testcase.TestGroup):

    def test_sg006(self):
        r"""
        \testcase   BIC-UTL-BIT.TG001
        \brief      Test group based on SG "tcSg005Bitmap"
        """
        # List of service groups to unlock, Maximum time (in seconds) that the test takes to run
        self.run_sg_based_test(['tcSg005Bitmap'], 60)
        
        

This python file should be present in "<model>/src/test" directory.

You also need to add some test initialization code in clCompAppMain.c of the component. Here is an example of what all you need to initialize/register :

Stub1

In the global context of the file clCompAppMain.c, you need to add following code with BEGIN/END block :

/*
 * ---BEGIN_APPLICATION_CODE---
 */

int
clTestBitmapRun(ClTcParamListT *param_list)
{
    clTestBitmapMain();
    return 0;
}

void*
clTcRunThread(void *param)
{
    clTcRun();
    return NULL;
}

/*
 * ---END_APPLICATION_CODE---
 */
  • Where, clTestBitmapMain() is the main test function (where all the test cases will start their execution). The example code for this function is present in "Testcase Implementation" section.
Stub2

In main() function, TC initialize should be done in following way :

    /*
     * Do the application specific initialization here.
     */

    /*
     * ---BEGIN_APPLICATION_CODE---
     */
    rc = clTcInitialize("Bitmap Utility", "BIT", clTestBitmapRun);
    if(CL_OK != rc)
    {
        clprintf(CL_LOG_SEV_ERROR, "clTcInitialize() failed, rc : 0x%x", rc);
        return rc;
    }
    
    /*
     * ---END_APPLICATION_CODE---
     */
Stub3

Before blocking on AMF file descriptor for callbacks, in main() function a thread should be created to run the test in the thread context. Alternatively, you can block on the AMF file descriptor in another thread and let the test run in main thread.

    /*
     * ---BEGIN_APPLICATION_CODE---
     */
    rc = clOsalTaskCreateDetached(NULL, CL_OSAL_SCHED_OTHER,
                                  CL_OSAL_THREAD_PRI_NOT_APPLICABLE,
                                  CL_OSAL_MIN_STACK_SIZE,
                                  clTcRunThread, NULL);
    
    /*
     * ---END_APPLICATION_CODE---
     */

    /*
     * Block on AMF dispatch file descriptor for callbacks
     */
Stub4

In clCompAppTerminate() finalize the TC in following way :

    /*
     * ---BEGIN_APPLICATION_CODE--- 
     */
    clTcFinalize();
    
    /*
     * ---END_APPLICATION_CODE---
     */
Stub5

In clCompAppAMFCSISet(), call TC activate in SA_AMF_HA_ACTIVE context :

   switch ( haState )
    {
        case SA_AMF_HA_ACTIVE:
        {
            /*
             * AMF has requested application to take the active HA state 
             * for the CSI.
             */

            /*
             * ---BEGIN_APPLICATION_CODE---
             */
            clTcActivate((ClAmsCSIDescriptorT*)&csiDescriptor, haState);
 
            /*
             * ---END_APPLICATION_CODE---
             */