|
刚开始学习loadrunner11,简单编了个脚本,具体内容如下:
vuser_init()
{
lrs_startup(257);
return 0;
}
Action()
{
int rc=0;
rc = lrs_create_socket("socket0","TCP","LocalHost=0","RemoteHost=20.13.0.216:5555", LrsLastArg);//建立到服务端的连接
if (rc==0)
lr_output_message("Socket was successfully created ");
else
lr_output_message("An error occurred while creating the socket, Error Code: %d", rc);
lrs_send("socket0", "buf0", LrsLastArg); //往"socket0"发送"buf0"中的数据
lrs_receive("socket0", "buf1", LrsLastArg);//将"socke0"中返回的数据存放到"buf1"中
return 0;
}
vuser_end()
{
lrs_close_socket("socket0");
lrs_cleanup();
return 0;
}
data.ws内容如下:
;WSRData 2 1
send buf0 6
"123456"
recv buf1 6
-1
被测试程序可以成功接收到报文内容“123456”,返回的报文不能成功接收,从loadrunner的日志中显示0 bytes were received;被测试程序逻辑很简单,就是接收到的报文原样返回。各位大侠请帮忙看看?
脚本执行后的日志如下:
Virtual User Script started at : 2013-08-07 20:56:59
Starting action vuser_init.
vuser_init.c(11): lrs_startup(257)
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Starting action Action.
Action.c(7): lrs_create_socket(socket0, TCP, ...)
Action.c(7): callSocket: name: 40351244, socket type: 1
Action.c(7): callBind: socket: socket0 (860), local host: (null), local port: 0
Action.c(7): callConnect: socket: socket0 (860), remote host: 20.13.0.216 remote port: 5555
Action.c(7): callConnect: getting host address from the host name (20.13.0.216).
Action.c(7): callConnect: Wed Aug 07 20:56:59.912: Waiting for writable socket 10 secs, 0 usecs
Action.c(10): Socket was successfully created
Action.c(18): lrs_send(socket0, buf0)
Action.c(18): callSend: socket: socket0 (860), buffer: buf0
Action.c(18): callSend: Wed Aug 07 20:56:59.942: reading buffer buf0
Action.c(18): callSend: Wed Aug 07 20:56:59.952: calling parameterization routines
Action.c(18): callSend: Wed Aug 07 20:56:59.962: translate buffer to binary
Action.c(18): callSend: Wed Aug 07 20:56:59.962: Translate data for printing
=================================SENT BUFFER=================================
"123456"
===============================================================================
Action.c(18): callSend: Wed Aug 07 20:57:00.004: About to send 6 bytes to socket0 (860)
Action.c(18): callSend: Wed Aug 07 20:57:00.014: Waiting for writable socket 10 secs, 0 usecs
Action.c(18): callSend: Wed Aug 07 20:57:00.044: Trying to send 6 bytes
Action.c(18): callSend: Wed Aug 07 20:57:00.054: Sent in this iteration 6 bytes (total in all iterations 6 bytes)
Action.c(24): lrs_receive(socket0, buf1)
Action.c(24): fiInitRecv: socket: socket0 (860), buffer: buf1, expected size: 6
Action.c(24): callRecv: Wed Aug 07 20:57:00.094: About to read 6 bytes from socket0 (860)
Action.c(24): fiPerformReceive: Wed Aug 07 20:57:00.104: Waiting for readable socket 10 secs, 0 usecs
Action.c(24): fiPerformReceive: Wed Aug 07 20:57:10.120: Select timed out
Action.c(24): Mismatch in buffer's length (expected 6 bytes, 0 bytes actually received, difference in 6 bytes)
Action.c(24): fiCheckRecvMismatch: Wed Aug 07 20:57:10.130: reading buffer buf1
Action.c(24): fiCheckRecvMismatch: Wed Aug 07 20:57:10.140: calling parameterization routines
================================EXPECTED BUFFER================================
===============================================================================
Action.c(24): getAsciiReceivedBuffer: Wed Aug 07 20:57:10.150: Translate data for printing
Action.c(24): getAsciiReceivedBuffer: Wed Aug 07 20:57:10.150: Binary to ascii
================================RECEIVED BUFFER================================
===============================================================================
Action.c(24): callRecv:0 bytes were received
Ending action Action.
Ending iteration 1.
Ending Vuser...
Starting action vuser_end.
vuser_end.c(5): lrs_close_socket(socket0)
vuser_end.c(5): callCloseSocket: socket: socket0 (860)
vuser_end.c(6): lrs_cleanup()
Ending action vuser_end.
Vuser Terminated. |
|