test/nvmf: add a test for bad discovery ctrlr.
Make sure we don't crash or do any other bad memory accesses when we fail to connect to a discovery controller. Change-Id: I7c3e25899bc78f4beff9ad017612bacf286d52c7 Signed-off-by: Seth Howell <seth.howell@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/474153 Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
08d5d8474b
commit
c4d4800a46
@ -1088,19 +1088,19 @@ int main(int argc, char **argv)
|
||||
}
|
||||
if (spdk_env_init(&opts) < 0) {
|
||||
fprintf(stderr, "Unable to initialize SPDK env\n");
|
||||
rc = -1;
|
||||
rc = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
g_tsc_rate = spdk_get_ticks_hz();
|
||||
|
||||
if (register_workers() != 0) {
|
||||
rc = -1;
|
||||
rc = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (register_controllers() != 0) {
|
||||
rc = -1;
|
||||
rc = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -1120,7 +1120,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (associate_workers_with_ns() != 0) {
|
||||
rc = -1;
|
||||
rc = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -1156,6 +1156,13 @@ cleanup:
|
||||
|
||||
if (rc != 0) {
|
||||
fprintf(stderr, "%s: errors occured\n", argv[0]);
|
||||
/*
|
||||
* return a generic error to the caller. This allows us to
|
||||
* distinguish between a failure in the script and something
|
||||
* like a segfault or an invalid access which causes the program
|
||||
* to crash.
|
||||
*/
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
@ -36,6 +36,19 @@ timing_enter target_disconnect
|
||||
|
||||
nvmftestinit
|
||||
|
||||
# Test to make sure we don't segfault or access null pointers when we try to connect to
|
||||
# a discovery controller that doesn't exist yet.
|
||||
set +e
|
||||
$rootdir/examples/nvme/reconnect/reconnect -q 32 -o 4096 -w randrw -M 50 -t 10 -c 0xF \
|
||||
-r "trtype:$TEST_TRANSPORT adrfam:IPv4 traddr:$NVMF_FIRST_TARGET_IP trsvcid:$NVMF_PORT"
|
||||
# If the program crashes, the high bit of $? will be set so we will get a value in the hundreds.
|
||||
# But if the reconnect code detects errors and exits normally it will return 1.
|
||||
if [ $? != 1 ]; then
|
||||
set -e
|
||||
exit 1
|
||||
fi
|
||||
set -e
|
||||
|
||||
disconnect_init $NVMF_FIRST_TARGET_IP
|
||||
|
||||
# If perf doesn't shut down, this test will time out.
|
||||
|
Loading…
Reference in New Issue
Block a user