51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 2794|回复: 4
打印 上一主题 下一主题

[求助] socket测试 lrs_save_param parameter issue(Error Code :9005)

[复制链接]
  • TA的每日心情
    郁闷
    2017-3-1 13:43
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]测试小兵

    跳转到指定楼层
    1#
    发表于 2017-7-12 15:08:35 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    我使用 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");
    }


    分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

  • TA的每日心情
    无聊
    2017-11-26 18:46
  • 签到天数: 382 天

    连续签到: 1 天

    [LV.9]测试副司令

    2#
    发表于 2017-7-12 15:32:30 | 只看该作者
    在编辑器运行的时候,参数的打印返回正确吗???
    data.ws中是否有包含发送和接受的程序???

    评分

    参与人数 1测试积点 +10 收起 理由
    lsekfe + 10 积极回复获得测试积点10 赶快去商城换取奖.

    查看全部评分

    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    郁闷
    2017-3-1 13:43
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]测试小兵

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

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

    使用道具 举报

  • TA的每日心情
    无聊
    2017-11-26 18:46
  • 签到天数: 382 天

    连续签到: 1 天

    [LV.9]测试副司令

    4#
    发表于 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>"
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    郁闷
    2017-3-1 13:43
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]测试小兵

    5#
     楼主| 发表于 2017-7-13 16:18:57 | 只看该作者
    神仙也考试 发表于 2017-7-12 16:12
    谷歌了一下,看到有相关的介绍,可以参考一下。

    Example: lrs_save_param

    谢了,脚本调试好了,但是lr没破解不支持 50个以上用户,
    通过jemter 发2进制tcp包解决了问题。
    回复 支持 反对

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-11-22 02:41 , Processed in 0.068932 second(s), 23 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表