Loadrunner 场景运行时提示Exception ACCESS_VIOLATION received.
进行下载的压力测试,文件大小为30M。
虚拟用户为10个时没有问题,100个时运行出错,提示如下:
Action.c(52): Error: C interpreter run time error: Action.c (52):Error -- memory violation : Exception ACCESS_VIOLATION received.
感觉要调整:web_set_max_html_param_len("XXXX");这个XXXX单位是多少? 字节吗?如果是字节,为什么设置为1024,30M文件也下载保存成功?
具体脚本如下:
Action()
{
int returncode;
//文件大小
long flen;
long filesize;
//响应数据内容大小
long filedes;
//下载文件时间
long timer;
long stimer;
//下载文件时间
long rate;
//文件名
char filename;
// web_url("csim",
// "URL=http://192.168.1.1:8080/csim",
// "Resource=0",
// "RecContentType=text/html",
// "Referer=",
// "Snapshot=t12.inf",
// "Mode=HTML",
// LAST);
//
// lr_think_time(4);
//
// web_submit_form("login",
// "Snapshot=t13.inf",
// ITEMDATA,
// "Name=uname", "Value={username}", ENDITEM,
// "Name=password", "Value=098f6bcd4621d373cade4e832627b4f6", ENDITEM,
// LAST);
//
// lr_think_time(5);
//设置页面接受最大的字节数,该设置应大于下载文件的大小
web_set_max_html_param_len("1024");
//将响应信息存放到fcontent变量
web_reg_save_param("fcontent",
"LB=",
"RB=",
"Ord=1",
"Search=Body",
LAST);
lr_rendezvous("下载");
lr_start_transaction("test");
web_url("aa_3_test_20170718003616829_v.mp4",
"URL=http://192.168.1.1:8080/patientInfo/aa_11/aa_3_test_20170718003616829_v.mp4",
"Resource=0",
"RecContentType=video/mp4",
"Referer=http://192.168.1.1:8080/csim/jsp/videoplayer/html5player.jsp?vurl=/patientInfo/aa_11/aa_3_test_20170718003616829_v.mp4&patient_name=aa&visit_id=11",
"Snapshot=t18.inf",
"Mode=HTML",
LAST);
lr_end_transaction("test", LR_AUTO);
//获取响应的大小,单位为字节
returncode =web_get_int_property(HTTP_INFO_RETURN_CODE);
flen = web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
timer = web_get_int_property(HTTP_INFO_DOWNLOAD_TIME);
filesize = flen/1024;
stimer = timer/1000;
rate = filesize/stimer;
lr_output_message("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ReturnCode=%d",returncode);
lr_output_message("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$Size of Download was %d kilobytes",filesize); // in kilobytes
lr_output_message("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$Time of Download was %d seconds",stimer); // in seconds
lr_output_message("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$Rate of Download was %d KB/s",rate); // in KB/s
if(returncode = 200)
lr_set_transaction("Download", stimer, LR_PASS);
else
{lr_set_transaction("Download", stimer, LR_FAIL);
return -1;}
//生成随机的文件名称,便于并发
strcpy(filename,"d:\\test\\Video_VuserID");
strcat(filename,lr_eval_string("{VuserID}"));
strcat(filename,"_");
strcat(filename,lr_eval_string("{Num}"));
strcat(filename,".mp4");
lr_output_message("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ %s",filename);
if(flen > 0){
//以写方式打开文件
if((filedes = fopen(filename, "wb")) == NULL){
lr_output_message("Open File Failed!");
return -1;
}
//写入文件内容
fwrite(lr_eval_string("{fcontent}"), flen, 1, filedes);
//关闭文件
fclose(filedes);
}
// lr_think_time(13);
//
// web_url("loginout",
// "URL=http://192.168.1.1:8080/csim/user/loginout",
// "Resource=0",
// "RecContentType=text/html",
// "Referer=http://192.168.1.1:8080/csim/user/login",
// "Snapshot=t21.inf",
// "Mode=HTML",
// LAST);
return 0;
}
运行的时候先看下本机内存占用是多少,在改程序
页:
[1]