Programming Vuser Actions

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

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. The vuser_init section is only performed once 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. The vuser_end section is only performed once 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