]>
git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/test/iscsi_tgt/sock/sock.sh
3 testdir
=$
(readlink
-f $
(dirname $0))
4 rootdir
=$
(readlink
-f $testdir/..
/..
/..
)
5 source $rootdir/test
/common
/autotest_common.sh
6 source $rootdir/test
/iscsi_tgt
/common.sh
8 # $1 = "iso" - triggers isolation mode (setting up required environment).
9 # $2 = test type posix or vpp. defaults to posix.
12 HELLO_SOCK_APP
="$TARGET_NS_CMD $rootdir/examples/sock/hello_world/hello_sock"
18 timing_enter sock_client
19 echo "Testing client path"
21 # start echo server using socat
22 $SOCAT_APP tcp-l
:$ISCSI_PORT,fork
,bind=$INITIATOR_IP exec:'/bin/cat' & server_pid
=$
!
23 trap "killprocess $server_pid;iscsitestfini $1 $2; exit 1" SIGINT SIGTERM EXIT
25 waitforlisten
$server_pid $INITIATOR_IP:$ISCSI_PORT
27 # send message using hello_sock client
28 message
="**MESSAGE:This is a test message from the client**"
29 response
=$
( echo $message |
$HELLO_SOCK_APP -H $INITIATOR_IP -P $ISCSI_PORT )
31 if ! echo "$response" |
grep -q "$message"; then
35 trap '-' SIGINT SIGTERM EXIT
36 # NOTE: socat returns code 143 on SIGINT
37 killprocess
$server_pid || true
39 report_test_completion
"sock_client"
40 timing_exit sock_client
46 timing_enter sock_server
48 # start echo server using hello_sock echo server
49 $HELLO_SOCK_APP -H $TARGET_IP -P $ISCSI_PORT -S & server_pid
=$
!
50 trap "killprocess $server_pid; iscsitestfini $1 $2; exit 1" SIGINT SIGTERM EXIT
51 waitforlisten
$server_pid
53 # send message to server using socat
54 message
="**MESSAGE:This is a test message to the server**"
55 response
=$
( echo $message |
$SOCAT_APP - tcp
:$TARGET_IP:$ISCSI_PORT 2>/dev
/null
)
57 if [ "$message" != "$response" ]; then
61 trap - SIGINT SIGTERM EXIT
63 killprocess
$server_pid
66 report_test_completion
"sock_server"
67 timing_exit sock_server