#!/bin/bash
# SPDX-License-Identifier: GPL-3.0+
# Copyright (C) 2019 Logan Gunthorpe
# Copyright (C) 2019 Eideticom Communications Inc.
#
# Test that we can remove a subsystem that has not been enabled by
# passthru or any ns. Do the same for ports while we are at it.
#
# This was an issue in the original passthru patches and is
# not commonly tested. So this test will ensure we don't regress this.
#
. tests/nvme/rc

DESCRIPTION="test deletion of NVMeOF subsystem without enabling"
QUICK=1

requires() {
	_nvme_requires
}

set_conditions() {
	_set_nvme_trtype "$@"
}

test() {
	echo "Running ${TEST_NAME}"

	_setup_nvmet

	local subsys_path="${NVMET_CFS}/subsystems/${def_subsysnqn}"
	local port

	mkdir -p "${subsys_path}"
	rmdir "${subsys_path}"

	port="$(_create_nvmet_port)"
	_remove_nvmet_port "${port}"

	echo "Test complete"
}
