SOCKET 自动返回错误信息脚本

2010-03-11  陈晓义 

2010-03-11号
马上就周末了.在外面出差还没完呢..
今天讨论到了 软件的性能问题.
看了看以前写的脚本.
自己回顾一下,免得自己忘记了...
Action()
{
  int stricmpvalue,qiandaovalue,chaxunvalue;
    //  double wastetime;
     char responsecode[10];
  char qiandaoresponse[10];
  char chaxunresponse[10];
  char codee[10]="0001";
  lr_rendezvous("allstar");
//下面是签到的代码
  lr_start_transaction("qiandao0010");
 lrs_create_socket("socket0", "TCP", "LocalHost=0", "RemoteHost=192.168.0.127:89", LrsLastArg);
 lrs_send("socket0", "buf0", LrsLastArg);
 lrs_receive("socket0", "buf1", LrsLastArg);
 //lrs_save_param();
 lrs_save_searched_string("socket0",NULL,"sessioncode",NULL,NULL,-1,36,8);
 lrs_save_param("socket0",NULL,"qiandaoresponse",4,4);
 lr_output_message("The responsecode's value  is # %s " ,lr_eval_string("<qiandaoresponse>"));
 lr_output_message("The session of the return value is  %s",lr_eval_string("<sessioncode>"));

 strcpy(qiandaoresponse,lr_eval_string("<qiandaoresponse>"));
 qiandaovalue = stricmp(qiandaoresponse,codee);lr_output_message("value is  %d",qiandaovalue);
 if(qiandaovalue >0){lr_output_message("the response is bigerthan 0001 "); lr_end_transaction("qiandao0010",LR_FAIL);}
 else  if(qiandaovalue <0 ) {lr_output_message("the response is small than  0001");
 lr_end_transaction("qiandao0010",LR_FAIL);}
 else {
    lr_output_message("The response  of the socket is equals the 0001");

   /*   wastetime=lr_get_transaction_wasted_time("qiandao0010");
       lr_output_message("The transaction wastetime is %lf ",lr_get_transaction_wasted_time("qiandao0010"));
   lr_output_message("The wastetime  is %lf  ",wastetime);

      lr_wasted_time(wastetime);
     */
  lr_end_transaction("qiandao0010",LR_PASS);
        }
 lrs_close_socket("socket0");
//下面是缴费的代码
     lr_start_transaction("xiaozhang0003");
 lrs_create_socket("socket1", "TCP", "LocalHost=0", "RemoteHost=192.168.0.127:89", LrsLastArg);
 lrs_send("socket1", "buf3", LrsLastArg);
  
 lrs_receive("socket1", "buf4", LrsLastArg);
 //     lr_output_message("The buf1 is ","buf1");
 //     lrs_save_searched_string("socket0","buf1","responsecode",NULL,NULL,-1,4,4);
 lrs_save_param("socket1",NULL,"responsecode",4,4);
 lr_output_message("The responsecode's value  is # %s " ,lr_eval_string("<responsecode>"));
    strcpy(responsecode,lr_eval_string("<responsecode>"));
     
 lr_output_message("copy the responsecode from the buf1,the code is  %s",lr_eval_string(responsecode));
    stricmpvalue = stricmp(responsecode,codee);lr_output_message("value is  %d",stricmpvalue);
 if(stricmpvalue >0){lr_output_message("the response is biger,The code is biger than 0001 "); lr_end_transaction("xiaozhang0003",LR_FAIL);}
 else  if(stricmpvalue <0 ) {lr_output_message("the response is small than  0001");
 lr_end_transaction("xiaozhang0003",LR_FAIL);}
 else {
       lr_output_message("The result of the socket is equals the 0001");
  lr_end_transaction("xiaozhang0003",LR_PASS);}
 
 
 lrs_close_socket("socket1");
//下面是查询费用的代码
 lr_start_transaction("chaxun0015");
 lrs_create_socket("socket3", "TCP", "LocalHost=0", "RemoteHost=192.168.0.127:89", LrsLastArg);
 lrs_send("socket3", "buf5", LrsLastArg);
 lrs_receive("socket3", "buf6", LrsLastArg);
 lrs_save_param("socket3",NULL,"chaxunresponse",4,4);
 lr_output_message("The responsecode's value  is # %s " ,lr_eval_string("<chaxunresponse>"));
//下面是打印SESSION的参数
 lr_output_message("The session of the return value is  %s",lr_eval_string("<sessioncode>"));
 strcpy(chaxunresponse,lr_eval_string("<chaxunresponse>"));
 chaxunvalue = stricmp(chaxunresponse,codee);lr_output_message("value is  %d",chaxunvalue);
 if(chaxunvalue >0){lr_output_message("the response is bigerthan 0001 "); lr_end_transaction("chaxun0015",LR_FAIL);}
 else  if(chaxunvalue <0 ) {lr_output_message("the response is small than  0001");
 lr_end_transaction("chaxun0015",LR_FAIL);}
 else {
    lr_output_message("The response  of the socket is equals the 0001");
  lr_end_transaction("chaxun0015",LR_PASS);}
 lrs_close_socket("socket3");
 return 0;
}
285°/2841 人阅读/1 条评论 发表评论

陈晓义  2010-03-11

本来校验码也应该由测试工具生成的,但是 用C语言 生成校验还是好麻烦的..那天有空 写写...


登录 后发表评论