Difference between revisions of "Doc:latest/taeguide/testintg"

m (1 revision)
(Stub)
 
(5 intermediate revisions by one user not shown)
Line 29: Line 29:
 
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 :  
 
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 =====
+
===== The "C" Code =====
In the global context of the file clCompAppMain.c, you need to add following code with BEGIN/END block :
+
Define all your tests inside a function that can be called in a thread:
 
<pre>
 
<pre>
/*
+
void* MyTest(void* param)
* ---BEGIN_APPLICATION_CODE---
+
*/
+
 
+
int
+
clTestBitmapRun(ClTcParamListT *param_list)
+
 
{
 
{
    clTestBitmapMain();
+
  clTestGroupInitialize(("container test group"));
    return 0;
+
  //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;
 
}
 
}
 
void*
 
clTcRunThread(void *param)
 
{
 
    clTcRun();
 
    return NULL;
 
}
 
 
/*
 
* ---END_APPLICATION_CODE---
 
*/
 
 
</pre>
 
</pre>
  
*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 =====
+
Now in clCompAppAMFCSISet(), start a thread that runs this test function.
In main() function, TC initialize should be done in following way :
+
<pre>
+
    /*
+
    * 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---
+
    */
+
</pre>
+
 
+
===== 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.
+
 
+
<pre>
+
    /*
+
    * ---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
+
    */
+
</pre>
+
 
+
===== Stub4 =====
+
In clCompAppTerminate() finalize the TC in following way :
+
 
+
<pre>
+
    /*
+
    * ---BEGIN_APPLICATION_CODE---
+
    */
+
    clTcFinalize();
+
   
+
    /*
+
    * ---END_APPLICATION_CODE---
+
    */
+
</pre>
+
 
+
===== Stub5 =====
+
In clCompAppAMFCSISet(), call TC activate in SA_AMF_HA_ACTIVE context :
+
  
 
<pre>
 
<pre>
 +
  ...
 
   switch ( haState )
 
   switch ( haState )
 
     {
 
     {
Line 126: Line 56:
 
             * for the CSI.
 
             * for the CSI.
 
             */
 
             */
 
            /*
 
            * ---BEGIN_APPLICATION_CODE---
 
            */
 
            clTcActivate((ClAmsCSIDescriptorT*)&csiDescriptor, haState);
 
 
   
 
   
            /*
+
        /* Spawn a thread that runs your test.
            * ---END_APPLICATION_CODE---
+
            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);
 +
    ...
 +
 
</pre>
 
</pre>

Latest revision as of 18:13, 13 March 2013

Contents

[edit] 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.

[edit] 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.

[edit] 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 :

[edit] 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);
    ...