test/hello_sock: Refactor the program and add -N option
This option is used to make hello_sock can use the designated sock implementations. We need this patch since we will provide another uring implementation. So better to pass the name. Otherwise if the users have many different implementations, VPP implementation could not be the highest priority for test. Change-Id: Ibb3862e9e6588743ec9c01074904ed4f7c9c06a5 Signed-off-by: Ziye Yang <ziye.yang@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/478 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
01f2a6e0b1
commit
17cdadf5a9
@ -49,6 +49,7 @@
|
||||
static bool g_is_running;
|
||||
|
||||
static char *g_host;
|
||||
static char *g_sock_impl_name;
|
||||
static int g_port;
|
||||
static bool g_is_server;
|
||||
static bool g_verbose;
|
||||
@ -60,6 +61,7 @@ static bool g_verbose;
|
||||
struct hello_context_t {
|
||||
bool is_server;
|
||||
char *host;
|
||||
char *sock_impl_name;
|
||||
int port;
|
||||
|
||||
bool verbose;
|
||||
@ -84,6 +86,7 @@ hello_sock_usage(void)
|
||||
{
|
||||
printf(" -H host_addr host address\n");
|
||||
printf(" -P port port number\n");
|
||||
printf(" -N sock_impl socket implementation, e.g., -N posix or -N vpp\n");
|
||||
printf(" -S start in server mode\n");
|
||||
printf(" -V print out additional informations");
|
||||
}
|
||||
@ -97,6 +100,9 @@ static int hello_sock_parse_arg(int ch, char *arg)
|
||||
case 'H':
|
||||
g_host = arg;
|
||||
break;
|
||||
case 'N':
|
||||
g_sock_impl_name = arg;
|
||||
break;
|
||||
case 'P':
|
||||
g_port = spdk_strtol(arg, 10);
|
||||
if (g_port < 0) {
|
||||
@ -211,9 +217,10 @@ hello_sock_connect(struct hello_context_t *ctx)
|
||||
char saddr[ADDR_STR_LEN], caddr[ADDR_STR_LEN];
|
||||
uint16_t cport, sport;
|
||||
|
||||
SPDK_NOTICELOG("Connecting to the server on %s:%d\n", ctx->host, ctx->port);
|
||||
SPDK_NOTICELOG("Connecting to the server on %s:%d with sock_impl(%s)\n", ctx->host, ctx->port,
|
||||
ctx->sock_impl_name);
|
||||
|
||||
ctx->sock = spdk_sock_connect(ctx->host, ctx->port, NULL);
|
||||
ctx->sock = spdk_sock_connect(ctx->host, ctx->port, ctx->sock_impl_name);
|
||||
if (ctx->sock == NULL) {
|
||||
SPDK_ERRLOG("connect error(%d): %s\n", errno, spdk_strerror(errno));
|
||||
return -1;
|
||||
@ -340,13 +347,14 @@ hello_sock_group_poll(void *arg)
|
||||
static int
|
||||
hello_sock_listen(struct hello_context_t *ctx)
|
||||
{
|
||||
ctx->sock = spdk_sock_listen(ctx->host, ctx->port, NULL);
|
||||
ctx->sock = spdk_sock_listen(ctx->host, ctx->port, ctx->sock_impl_name);
|
||||
if (ctx->sock == NULL) {
|
||||
SPDK_ERRLOG("Cannot create server socket\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
SPDK_NOTICELOG("Listening connection on %s:%d\n", ctx->host, ctx->port);
|
||||
SPDK_NOTICELOG("Listening connection on %s:%d with sock_impl(%s)\n", ctx->host, ctx->port,
|
||||
ctx->sock_impl_name);
|
||||
|
||||
/*
|
||||
* Create sock group for server socket
|
||||
@ -406,12 +414,13 @@ main(int argc, char **argv)
|
||||
opts.name = "hello_sock";
|
||||
opts.shutdown_cb = hello_sock_shutdown_cb;
|
||||
|
||||
if ((rc = spdk_app_parse_args(argc, argv, &opts, "H:P:SV", NULL, hello_sock_parse_arg,
|
||||
if ((rc = spdk_app_parse_args(argc, argv, &opts, "H:N:P:SV", NULL, hello_sock_parse_arg,
|
||||
hello_sock_usage)) != SPDK_APP_PARSE_ARGS_SUCCESS) {
|
||||
exit(rc);
|
||||
}
|
||||
hello_context.is_server = g_is_server;
|
||||
hello_context.host = g_host;
|
||||
hello_context.sock_impl_name = g_sock_impl_name;
|
||||
hello_context.port = g_port;
|
||||
hello_context.verbose = g_verbose;
|
||||
|
||||
|
@ -66,6 +66,21 @@ function waitfortcp() {
|
||||
# $2 = test type posix or vpp. defaults to posix.
|
||||
iscsitestinit $1 $2
|
||||
|
||||
if [ "$1" == "iso" ]; then
|
||||
TEST_TYPE=$2
|
||||
else
|
||||
TEST_TYPE=$1
|
||||
fi
|
||||
|
||||
if [ -z "$TEST_TYPE" ]; then
|
||||
TEST_TYPE="posix"
|
||||
fi
|
||||
|
||||
if [ "$TEST_TYPE" != "posix" ] && [ "$TEST_TYPE" != "vpp" ]; then
|
||||
echo "No correct sock implmentation specified"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
HELLO_SOCK_APP="$TARGET_NS_CMD $rootdir/examples/sock/hello_world/hello_sock"
|
||||
if [ $SPDK_TEST_VPP -eq 1 ]; then
|
||||
HELLO_SOCK_APP+=" -L sock_vpp"
|
||||
@ -86,7 +101,7 @@ waitfortcp $server_pid $INITIATOR_IP:$ISCSI_PORT
|
||||
|
||||
# send message using hello_sock client
|
||||
message="**MESSAGE:This is a test message from the client**"
|
||||
response=$( echo $message | $HELLO_SOCK_APP -H $INITIATOR_IP -P $ISCSI_PORT )
|
||||
response=$( echo $message | $HELLO_SOCK_APP -H $INITIATOR_IP -P $ISCSI_PORT -N $TEST_TYPE)
|
||||
|
||||
if ! echo "$response" | grep -q "$message"; then
|
||||
exit 1
|
||||
@ -105,7 +120,7 @@ timing_exit sock_client
|
||||
timing_enter sock_server
|
||||
|
||||
# start echo server using hello_sock echo server
|
||||
$HELLO_SOCK_APP -H $TARGET_IP -P $ISCSI_PORT -S & server_pid=$!
|
||||
$HELLO_SOCK_APP -H $TARGET_IP -P $ISCSI_PORT -S -N $TEST_TYPE & server_pid=$!
|
||||
trap 'killprocess $server_pid; iscsitestfini $1 $2; exit 1' SIGINT SIGTERM EXIT
|
||||
waitforlisten $server_pid
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user