Launching virtual tester threads

System Testing for C

In a multi-threaded environment, there are two methods of starting the virtual tester threads:

  • From a specially designed thread launcher program that you must write to include in your project.

  • From a TDP thread launcher if available.

TDP thread launcher from TDP

Some TDPs can launch the virtual tester threads without needing a special program. If your TDP supports this method, the only requirement is to specify this in the Configuration settings of the System Testing test node.

To use the TDP thread launcher:

  1. In the Project Explorer, click the Settings button.

  2. Select a System Testing test node in the Project Explorer pane.

  3. In the Configuration Settings list, expand System Testing and select Test Script Compiler.

  4. Set the Use thread launcher from TDP setting to Yes.

  5. When you have finished, click OK to validate the changes.

TDP thread launcher program

If the TDP does not contain a TDP thread launcher, the only way to start Virtual Tester threads is to write a program, specifying:

  • The name of the execution trace file

  • The name of the instance to be started

To do this, use the ATL_T_ARG structure, defined in the ats.h header file of the Target Deployment Port.

Example

The following example is a sample program for launching virtual tester threads.

#include <stdio.h>

#include <sched.h>

#include <pthread.h>

#include <errno.h>

#include "TP.h"

extern ATL_T_THREAD_RETURN *start(ATL_PT_ARG);

int main(int argc, char *argv[])

{

pthread_t thrTester_1,thr_Tester_2;

pthread_attr_t pthread_attr_default;

ATL_T_ARG arg_Tester_1, arg_Tester_2;

int status;

arg_Tester_1.atl_riofilename = "Tester_1.rio";

arg_Tester_1.atl_filters = "";

arg_Tester_1.atl_instance = "Tester_1";

arg_Tester_1.atl_occid = 0;

arg_Tester_2.atl_riofilename = "Tester_2.rio";

arg_Tester_2.atl_filters = "";

arg_Tester_2.atl_instance = "Tester_2";

arg_Tester_2.atl_occid = 0;

pthread_attr_init(&pthread_attr_default);

/* Start Thread Tester 1 */

pthread_create(&thrTester_1,&pthread_attr_default,start,&arg_Tester_1);

/* Start Thread Tester 2 */

pthread_create(&thrTester_2,&pthread_attr_default,start,&arg_Tester_2);

/* Both Testers are running */

/* Wait for the end of Thread Tester 1 */

pthread_join(thrTester_1, (void *)&status);

/* Wait for the end of Thread Tester 2 */

pthread_join(thrTester_2, (void *)&status);

return(0);

}

An example demonstrating how to use System Testing for C on multi-threaded applications is provided in the Broadcast Server example project. See Example projects for more information.

Related Topics

About Virtual Testers | System Testing in a Multi-Threaded or RTOS Environment