From 0d61bf4b50d9245b94ab05d9b2ab0d42bb918b99 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Mon, 15 Aug 2016 10:43:53 -0700 Subject: [PATCH] autotest: move NVMe device cleanup to startup Make sure any partition tables or other random data on the disks is cleaned up before running the tests, rather than trying to clean it up on failure when the system is in a potentially bad state. Change-Id: Ia2119485aee6a50243744328dff2314d7a72adad Signed-off-by: Daniel Verkamp --- autotest.sh | 17 +++++++++++++++++ scripts/autotest_common.sh | 15 --------------- test/nvmf/filesystem/filesystem.sh | 2 +- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/autotest.sh b/autotest.sh index ecc0497e8..e5bb5adcd 100755 --- a/autotest.sh +++ b/autotest.sh @@ -39,6 +39,23 @@ if hash lcov; then $LCOV -q -c -i -t "Baseline" -d $src -o cov_base.info fi +# Make sure the disks are clean (no leftover partition tables) +timing_enter cleanup +if [ $(uname -s) = Linux ]; then + # Load the kernel driver + ./scripts/setup.sh reset + + # Let the kernel discover any filesystems or partitions + sleep 10 + + # Delete all partitions on NVMe devices + devs=`lsblk -l -o NAME | grep nvme` + for dev in $devs; do + parted -s /dev/$dev mklabel msdos + done +fi +timing_exit cleanup + # set up huge pages timing_enter afterboot ./scripts/setup.sh diff --git a/scripts/autotest_common.sh b/scripts/autotest_common.sh index 9cc7e0aee..c1685b7a7 100755 --- a/scripts/autotest_common.sh +++ b/scripts/autotest_common.sh @@ -137,21 +137,6 @@ function killprocess() { wait $1 || true } -function nvme_cleanup() -{ - # Load the kernel driver - ./scripts/setup.sh reset - - # Let the kernel discover any filesystems or partitions - sleep 10 - - # Delete all partitions on NVMe devices - devs=`lsblk -l -o NAME | grep nvme` - for dev in $devs; do - parted -s /dev/$dev mklabel msdos - done -} - function iscsicleanup() { echo "Cleaning up iSCSI connection" iscsiadm -m node --logout || true diff --git a/test/nvmf/filesystem/filesystem.sh b/test/nvmf/filesystem/filesystem.sh index e5a379919..1bac9b27f 100755 --- a/test/nvmf/filesystem/filesystem.sh +++ b/test/nvmf/filesystem/filesystem.sh @@ -18,7 +18,7 @@ timing_enter fs_test $rootdir/app/nvmf_tgt/nvmf_tgt -c $testdir/../nvmf.conf & nvmfpid=$! -trap "killprocess $nvmfpid; nvme_cleanup; exit 1" SIGINT SIGTERM EXIT +trap "killprocess $nvmfpid; exit 1" SIGINT SIGTERM EXIT sleep 5