Program Vuser actions

The Vuser script files, test.c, test.usr, and test.cfg, can be customized for your Vuser.

Vuser script sections

You program the actual Vuser actions into the test.c file. This file has the required structure for a programmed Vuser script. The Vuser script contains three sections: vuser_init, Actions, and vuser_end.

Note that the template defines extern C for users of C++. This definition is required for all C++ users, to make sure that none of the exported functions are modified inadvertently.

Example: 
#include "lrun.h"
#if defined(__cplusplus) || defined(cplusplus) extern "C"
{
#endif
int LR_FUNC vuser_init(LR_PARAM p) 
{

lr_message("vuser_init done\n");

return 0;

} int Actions(LR_PARAM p) {

lr_message("Actions done\n");

return 0;

} int vuser_end(LR_PARAM p) {

lr_message("vuser_end done\n");

return 0;

} #if defined(__cplusplus) || defined(cplusplus)} #endif

You program Vuser actions directly into the empty script, before the lr_message function of each section.

The vuser_init section is executed first, during initialization. In this section, include the connection information and the logon procedure. This section is performed once only, each time you run the script.

The Actions section is executed after the initialization. In this section, include the actual operations performed by the Vuser. You can set up the Vuser to repeat the Actions section (in the test.cfg file).

The vuser_end section is executed last, after the all of the Vuser's actions. In this section, include the clean-up and logoff procedures. This section is performed once only, each time you run the script.

Note: Load generators control Vusers by sending SIGHUP, SIGUSR1, and SIGUSR2 Linux signals. Do not use these signals in your Vuser scripts.

Back to top

Define transaction and insert rendezvous points

When programming a Vuser script without VuGen, you must manually configure the Vuser file in order to enable transactions and rendezvous. The configuration settings are listed in the test.usr file.

Each transaction and rendezvous must be defined in the usr file. Add the transaction name to the Transactions section (followed by an "="). Add each rendezvous name to the Rendezvous section (followed by an "="). If the sections are not present, add them to the file, as shown below.

[General]
Type=any
DefaultCfg=Test.cfg
BinVuser=libtest.libsuffix
RunType=Binary
[Actions]
vuser_init=
Actions=
vuser_end=
[Transactions]
transaction1=
[Rendezvous]
Meeting=

Back to top

See also: