脚本实例来验证参数化的取值(执行场景时将取到的参数值和对应的VuserID保存到一个文件中)
vuser_init脚本如下:
long fileopen;
vuser_init()
{
char *filename = "F:\\test\\params.log"; //需要打印字段输出
if ((fileopen = fopen(filename,"a+")) == NULL)
{
lr_error_message ("file isn't open,path=%s",filename);
return 0;
}
return 0;
}
vuser_action脚本
Action() { int id,scid; char *vuser_group; long t; char *a = "{aaa}"; char *b = "{bbb}"; lr_whoami(&id, &vuser_group, &scid); //lr_whoami 将有关 Vuser 脚本的信息返回给 Vuser 脚本 fprintf(fileopen,"%d,%s,%s,%s",id,lr_string (a),lr_string (b),ctime(&t)); return 0; } //lr_whoami(&id, &vuser_group, &scid); ///lr_whoami(int *vuser id,char *sgroup,int *scid)
vuser_end脚本
vuser_end() { fclose(fileopen); return 0; }