hyj785 发表于 2017-7-12 15:08:35

socket测试 lrs_save_param parameter issue(Error Code :9005)

我使用 windows sockets 协议 写了一个脚本如下,在脚本编辑器里面运行没有问题,放到场景里面,我就设置了一个虚拟用户也会报 lrs_save_param parameter issue(Error Code :9005), 有人遇到过这个问题吗


Action()
{
    char strTemp[11];
    char strTemp1[11];
    //初始化
    strcpy(strTemp1, "200 OK");
    //创建连接
    lrs_create_socket("socket0", "TCP", "RemoteHost=xxxx:xx",LrsLastArg);
    //客户端发消息
    lrs_send("socket0", "buf0", LrsLastArg);
    lrs_receive("socket0", "buf1", LrsLastArg);
    //保存返回值
    lrs_save_param("socket0", NULL, "param1", 0,10);
    lr_output_message ("param1: %s", lr_eval_string("{param1}"));
    //保存返回报文到数组
    strcpy(strTemp, lr_eval_string("{param1}"));

   //如果报文正确则返回0否则返回-1
    if(memcmp(strTemp,strTemp1) == 0)
    {
         return 0;
    }
    else
    {
         return -1;
    }
    //关闭连接
    lrs_close_socket("socket0");
}


神仙也考试 发表于 2017-7-12 15:32:30

在编辑器运行的时候,参数的打印返回正确吗???
data.ws中是否有包含发送和接受的程序???

hyj785 发表于 2017-7-12 15:43:54

神仙也考试 发表于 2017-7-12 15:32
在编辑器运行的时候,参数的打印返回正确吗???
data.ws中是否有包含发送和接受的程序???

编辑器里面返回的数值是正常的
ws里面的报文是正常的
网上查的有人说是内存冲突
但是 没有解决方案

神仙也考试 发表于 2017-7-12 16:12:10

谷歌了一下,看到有相关的介绍,可以参考一下。

Example: lrs_save_param

In the following example, a user performed a Telnet session. The user used a ps command to determine a process ID (PID), and killed the application based on its PID. Repeating the exact steps during replay will not work—during replay the PID will be different (Linux assigns a new PID). Killing the PID that was recorded in the script will be ineffective. To overcome this problem, lr_save_param saves the value of the PID to a parameter during replay. This parameter is referenced in the Send buffer which contains the kill command.

The following code was recorded. The script would not perform the kill command during replay. To correct this, the following steps were performed:

The recorded value of the PID, 28597 was located along with the socket and buffer descriptors. The offset and length of the data was determined. The buffer shown below, buf47, was received after the ps command. The offset of the PID within the buffer data is 67, and its length is 5.

recv buf47 188 "\r" "\x0" "\r\n""PID TT STAT TIME COMMAND\r\n" "28469 q2 S 0:01 -tcsh (tcsh)\r\n" "28597 q2 T 0:00 vi log1.txt\r\n" "28602 q2 R 0:00 ps\r\n" "tears:/tmp_mnt/u/jay>"

The PID also appeared in the Send buffer, buf48, when the user performed a kill operation to the process.

send buf48 "kill -9 28597"

An lrs_save_param function was placed in the Actions section, before the lrs_send statement, in this instance buffer "buf48". NULL was specified in place of a buffer descriptor, indicating that VuGen should use the last received buffer, "buf47". During each subsequent replay, the PID is saved to a parameter called param1. The parameter was evaluated and printed in the LoadRunner output window or Application Management agent log file using lr_output_message.

            lrs_receive("socket2", "buf47", LrsLastArg);
lrs_save_param("socket2", NULL, "param1", 67, 5);
lr_output_message ("param1: %s", lr_eval_string("<param1>"));
lr_think_time(10);
lrs_send("socket2", "buf48", LrsLastArg);

The parameter was referenced in the Send buffer in place of the original PID constant. In this example angle brackets were used, but you can define the delimiters from VuGen's Option menu.

send buf48 "kill -9 <param1>"

hyj785 发表于 2017-7-13 16:18:57

神仙也考试 发表于 2017-7-12 16:12
谷歌了一下,看到有相关的介绍,可以参考一下。

Example: lrs_save_param


谢了,脚本调试好了,但是lr没破解不支持 50个以上用户,
通过jemter 发2进制tcp包解决了问题。
页: [1]
查看完整版本: socket测试 lrs_save_param parameter issue(Error Code :9005)