压力测试参数化—唯一编号取值

发表于:2014-1-09 11:51

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:lanlan    来源:51Testing软件测试网采编

int myfile_w,myfile_r1,myfile_r2;
char *file_w="F:\\test\\w.txt";
char *file_r1="F:\\test\\r1.txt";
char *file_r2="F:\\test\\r2.txt";
long  text[1024];
char booking_no[30]="wjn";
char  *num_no=lr_eval_string("{unit_no}");
char ccl_file[1024]="TARGET_PATH=/ccl/send/";
lr_output_message("num_no: %s",num_no);//打印输出 num_no 的值
strcat(booking_no,num_no);
lr_output_message("booking_no: %s",booking_no); //打印输出 booking_no 的值
//文件 操作 步骤1-读取file_r1内容全新覆盖/写入file_w;  步骤2-将booking_no追加到file_w;
myfile_r1=fopen(file_r1,"r");
myfile_w=fopen(file_w,"w");
while(!feof(myfile_r1))
{
fgets(text,1024,myfile_r1);
fputs(text,myfile_w);
}
fclose(myfile_r1);
fclose(myfile_w);
myfile_w=fopen(file_w,"a");
fprintf(myfile_w,"%s",booking_no);
fclose(myfile_w);
ftp_logon_ex(&ftp_session,"ftp_logon","URL=ftp://usrname:password@192.168.1.11:21",LAST);
strcat(ccl_file,booking_no);
strcat(ccl_file,".txt");
lr_output_message("ccl_f : %s",ccl_file); //打印输出 ccl_file 的值
ftp_put_ex(&ftp_session, "Ftp_Put",
"SOURCE_PATH=F:/test/w.txt",
ccl_file, ENDITEM,            LAST);
ftp_logout_ex(&ftp_session);
return 0;
-------
  其中:  *num_no=lr_eval_string("{unit_no}");
  将 num_no 值进行参数化: unit number , 开始为1, 块大小为1000000 且每次出现发送.
  当控制台 并发 3个用户, 此时输出的 ccl_file文件名按 测试目标正确输出, 但 booking_no 却部分出现数据串的现象.
  结果如下 :
booking_no        ccl_file        说明
2582545531        n1        booking_no 预期为 n1
n300000002wjn2        wjn2        booking_no 预期为 n2
n300000003        n3        booking_no 预期为 n3
2582545531        n100000001        booking_no 预期为 n100000001
n300000002wjn2        n100000002        booking_no 预期为 n100000002
n100000003        n100000003        booking_no 预期为 n100000003
2582545531        n200000001        booking_no 预期为 n200000001
n200000002        n200000002        booking_no 预期为 n200000002
n200000003        n200000003        booking_no 预期为 n200000003
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号