Doc:latest/taeguide/testintg

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 :

The "C" Code

Define all your tests inside a function that can be called in a thread:

void* MyTest(void* param)
{
  clTestGroupInitialize(("container test group"));
  //Call list of test cases like following
  clTestCase(("BIC-CNT-CRT.TC001 Container Create test"), clTestContainerCreate());
  clTestCase(("BIC-CNT-DEL.TC002 Container Delete test"), clTestContainerDelete());
  (void) clTestGroupFinalize();
  return 0;
}


Now in clCompAppAMFCSISet(), start a thread that runs this test function.

   ...
   switch ( haState )
    {
        case SA_AMF_HA_ACTIVE:
        {
            /*
             * AMF has requested application to take the active HA state 
             * for the CSI.
             */
 
         /* Spawn a thread that runs your test.
            you may choose to use the Posix compliant pthread_create function.
            Here we are using the equivalent SAFplus function 
            (interoperability wrapper)  */
           rc = clOsalTaskCreateDetached(NULL, CL_OSAL_SCHED_OTHER,
                                  CL_OSAL_THREAD_PRI_NOT_APPLICABLE,
                                  CL_OSAL_MIN_STACK_SIZE,
                                  MyTest, NULL);
    ...