xref: /spdk/test/spdkcli/tcp.sh (revision c680e3a05b1a903c18bf3f75b732765607126f45)
1#!/usr/bin/env bash
2#  SPDX-License-Identifier: BSD-3-Clause
3#  Copyright (C) 2019 Intel Corporation
4#  All rights reserved.
5#
6testdir=$(readlink -f $(dirname $0))
7rootdir=$(readlink -f $testdir/../..)
8source $rootdir/test/common/autotest_common.sh
9source $rootdir/test/spdkcli/common.sh
10
11function err_cleanup() {
12	if [ -n "$socat_pid" ]; then
13		killprocess $socat_pid || true
14	fi
15	killprocess $spdk_tgt_pid
16}
17
18IP_ADDRESS="127.0.0.1"
19PORT="9998"
20
21trap 'err_cleanup; exit 1' SIGINT SIGTERM EXIT
22
23timing_enter run_spdk_tgt_tcp
24$SPDK_BIN_DIR/spdk_tgt -m 0x3 -p 0 &
25spdk_tgt_pid=$!
26
27waitforlisten $spdk_tgt_pid
28
29# socat will terminate automatically after the connection is closed
30socat TCP-LISTEN:$PORT UNIX-CONNECT:$DEFAULT_RPC_ADDR &
31socat_pid=$!
32
33$rootdir/scripts/rpc.py -r 100 -t 2 -s $IP_ADDRESS -p $PORT rpc_get_methods
34
35timing_exit run_spdk_tgt_tcp
36
37trap - SIGINT SIGTERM EXIT
38killprocess $spdk_tgt_pid
39