From 4c42b933c9248919067d0ded7ce91113e20e92b5 Mon Sep 17 00:00:00 2001 From: Alexey Marchuk Date: Tue, 12 Nov 2019 20:12:00 +0300 Subject: [PATCH] app: Add cli options to print SPDK version Change verbose mode parameter of fuzz test app from -v to -V to avoid collisions with app framework parameters Change-Id: Ibe562fa82408366aa487a19fad9a99e1e692b48c Signed-off-by: Alexey Marchuk Signed-off-by: Sasha Kotchubievsky Signed-off-by: Evgeniy Kochetov Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/474005 Reviewed-by: Shuhei Matsumoto Reviewed-by: Jim Harris Reviewed-by: Ben Walker Reviewed-by: Tomasz Zawadzki Tested-by: SPDK CI Jenkins --- include/spdk/event.h | 6 +++--- lib/event/app.c | 12 ++++++++++-- test/app/fuzz/nvme_fuzz/README.md | 2 +- test/app/fuzz/nvme_fuzz/nvme_fuzz.c | 10 +++++----- test/app/fuzz/vhost_fuzz/README.md | 4 ++-- test/app/fuzz/vhost_fuzz/vhost_fuzz.c | 10 +++++----- 6 files changed, 26 insertions(+), 18 deletions(-) diff --git a/include/spdk/event.h b/include/spdk/event.h index 35eaedef1..90adf07c6 100644 --- a/include/spdk/event.h +++ b/include/spdk/event.h @@ -1,8 +1,8 @@ /*- * BSD LICENSE * - * Copyright (c) Intel Corporation. - * All rights reserved. + * Copyright (c) Intel Corporation. All rights reserved. + * Copyright (c) 2019 Mellanox Technologies LTD. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -228,7 +228,7 @@ int spdk_app_parse_core_mask(const char *mask, struct spdk_cpuset *cpumask); */ struct spdk_cpuset *spdk_app_get_core_mask(void); -#define SPDK_APP_GETOPT_STRING "c:de:ghi:m:n:p:r:s:uB:L:RW:" +#define SPDK_APP_GETOPT_STRING "c:de:ghi:m:n:p:r:s:uvB:L:RW:" enum spdk_app_parse_args_rvals { SPDK_APP_PARSE_ARGS_HELP = 0, diff --git a/lib/event/app.c b/lib/event/app.c index 3c80cb83a..e04c6f188 100644 --- a/lib/event/app.c +++ b/lib/event/app.c @@ -1,8 +1,8 @@ /*- * BSD LICENSE * - * Copyright (c) Intel Corporation. - * All rights reserved. + * Copyright (c) Intel Corporation. All rights reserved. + * Copyright (c) 2019 Mellanox Technologies LTD. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -32,6 +32,7 @@ */ #include "spdk/stdinc.h" +#include "spdk/version.h" #include "spdk_internal/event.h" @@ -105,6 +106,8 @@ static const struct option g_cmdline_options[] = { {"mem-size", required_argument, NULL, MEM_SIZE_OPT_IDX}, #define NO_PCI_OPT_IDX 'u' {"no-pci", no_argument, NULL, NO_PCI_OPT_IDX}, +#define VERSION_OPT_IDX 'v' + {"version", no_argument, NULL, VERSION_OPT_IDX}, #define PCI_BLACKLIST_OPT_IDX 'B' {"pci-blacklist", required_argument, NULL, PCI_BLACKLIST_OPT_IDX}, #define LOGFLAG_OPT_IDX 'L' @@ -758,6 +761,7 @@ usage(void (*app_usage)(void)) printf(" -B, --pci-blacklist \n"); printf(" pci addr to blacklist (can be used more than once)\n"); printf(" -R, --huge-unlink unlink huge files after initialization\n"); + printf(" -v, --version print SPDK version\n"); printf(" -W, --pci-whitelist \n"); printf(" pci addr to whitelist (-B and -W cannot be used at the same time)\n"); printf(" --huge-dir use a specific hugetlbfs mount to reserve memory from\n"); @@ -989,6 +993,10 @@ spdk_app_parse_args(int argc, char **argv, struct spdk_app_opts *opts, fprintf(stderr, "Deprecation warning: The maximum allowed latency parameter is no longer supported.\n"); break; + case VERSION_OPT_IDX: + printf(SPDK_VERSION_STRING"\n"); + retval = SPDK_APP_PARSE_ARGS_HELP; + goto out; case '?': /* * In the event getopt() above detects an option diff --git a/test/app/fuzz/nvme_fuzz/README.md b/test/app/fuzz/nvme_fuzz/README.md index 30d4a2e0f..8c5910c10 100644 --- a/test/app/fuzz/nvme_fuzz/README.md +++ b/test/app/fuzz/nvme_fuzz/README.md @@ -19,7 +19,7 @@ By default, the fuzzer will print commands that: Commands are dumped as named objects in json format which can then be supplied back to the script for targeted debugging on a subsequent run. See `Debugging` below. By default no output is generated when a specific command is returned with a failed status. -This can be overridden with the -v flag. if -v is specified, each command will be dumped as +This can be overridden with the -V flag. if -V is specified, each command will be dumped as it is completed in the JSON format specified above. At the end of each test run, a summary is printed for each namespace in the following format: diff --git a/test/app/fuzz/nvme_fuzz/nvme_fuzz.c b/test/app/fuzz/nvme_fuzz/nvme_fuzz.c index 7634ce680..f0e6c5ed5 100644 --- a/test/app/fuzz/nvme_fuzz/nvme_fuzz.c +++ b/test/app/fuzz/nvme_fuzz/nvme_fuzz.c @@ -1,8 +1,8 @@ /*- * BSD LICENSE * - * Copyright (c) Intel Corporation. - * All rights reserved. + * Copyright (c) Intel Corporation. All rights reserved. + * Copyright (c) 2019 Mellanox Technologies LTD. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -846,7 +846,7 @@ This helps dig deeper into other errors besides invalid namespace.\n"); fprintf(stderr, " -S Seed value for test.\n"); fprintf(stderr, " -t Time in seconds to run the fuzz test. Only valid if -j is not specified.\n"); - fprintf(stderr, " -v Enable logging of each submitted command.\n"); + fprintf(stderr, " -V Enable logging of each submitted command.\n"); } static int @@ -883,7 +883,7 @@ nvme_fuzz_parse(int ch, char *arg) return -1; } break; - case 'v': + case 'V': g_verbose_mode = true; break; case '?': @@ -905,7 +905,7 @@ main(int argc, char **argv) g_runtime = DEFAULT_RUNTIME; g_run = true; - if ((rc = spdk_app_parse_args(argc, argv, &opts, "aC:j:NS:t:v", NULL, nvme_fuzz_parse, + if ((rc = spdk_app_parse_args(argc, argv, &opts, "aC:j:NS:t:V", NULL, nvme_fuzz_parse, nvme_fuzz_usage) != SPDK_APP_PARSE_ARGS_SUCCESS)) { return rc; } diff --git a/test/app/fuzz/vhost_fuzz/README.md b/test/app/fuzz/vhost_fuzz/README.md index 9637171e8..129febad9 100644 --- a/test/app/fuzz/vhost_fuzz/README.md +++ b/test/app/fuzz/vhost_fuzz/README.md @@ -39,7 +39,7 @@ always be started with the --wait-for-rpc argument. Please see below for an exam ~~~ ./test/app/fuzz/vhost_fuzz/vhost_fuzz -t 30 --wait-for-rpc & -./scripts/rpc.py fuzz_vhost_create_dev -s ./Vhost.1 -b -v -./scripts/rpc.py fuzz_vhost_create_dev -s ./naa.VhostScsi0.1 -l -v +./scripts/rpc.py fuzz_vhost_create_dev -s ./Vhost.1 -b -V +./scripts/rpc.py fuzz_vhost_create_dev -s ./naa.VhostScsi0.1 -l -V ./scripts/rpc.py framework_start_init ~~~ diff --git a/test/app/fuzz/vhost_fuzz/vhost_fuzz.c b/test/app/fuzz/vhost_fuzz/vhost_fuzz.c index 23ae07dd2..2cc453100 100644 --- a/test/app/fuzz/vhost_fuzz/vhost_fuzz.c +++ b/test/app/fuzz/vhost_fuzz/vhost_fuzz.c @@ -1,8 +1,8 @@ /*- * BSD LICENSE * - * Copyright (c) Intel Corporation. - * All rights reserved. + * Copyright (c) Intel Corporation. All rights reserved. + * Copyright (c) 2019 Mellanox Technologies LTD. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -1066,7 +1066,7 @@ fuzz_vhost_usage(void) " -k Keep the iov pointer addresses from the json file. only valid with -j.\n"); fprintf(stderr, " -S Seed value for test.\n"); fprintf(stderr, " -t Time in seconds to run the fuzz test.\n"); - fprintf(stderr, " -v Enable logging of each submitted command.\n"); + fprintf(stderr, " -V Enable logging of each submitted command.\n"); } static int @@ -1097,7 +1097,7 @@ fuzz_vhost_parse(int ch, char *arg) return -1; } break; - case 'v': + case 'V': g_verbose_mode = true; break; case '?': @@ -1117,7 +1117,7 @@ main(int argc, char **argv) opts.name = "vhost_fuzz"; g_runtime = DEFAULT_RUNTIME; - rc = spdk_app_parse_args(argc, argv, &opts, "j:kS:t:v", NULL, fuzz_vhost_parse, fuzz_vhost_usage); + rc = spdk_app_parse_args(argc, argv, &opts, "j:kS:t:V", NULL, fuzz_vhost_parse, fuzz_vhost_usage); if (rc != SPDK_APP_PARSE_ARGS_SUCCESS) { fprintf(stderr, "Unable to parse the application arguments.\n"); return -1;