All of lore.kernel.org
 help / color / mirror / Atom feed
From: ckulkarnilinux@gmail.com (chaitany kulkarni)
Subject: [PATCH blktests 3/3] nvme: add test for resetting the loopback controller
Date: Thu, 3 May 2018 12:03:15 -0700	[thread overview]
Message-ID: <CAK0tqikbAzX79tPuoTmB-n=3+8=9ExN43k1jTsqY0E-47TN2UA@mail.gmail.com> (raw)
In-Reply-To: <20180503150054.14022-3-jthumshirn@suse.de>

Hi Johannes,

Thanks for submitting the test.

I was wondering if we can move the generic setup and clean up
functionality to the helpers for reference:-

+pre()
+{
+      # Clean up all stale modules
+       modprobe -r nvme-loop
+       modprobe -r nvme-core
+       modprobe -r nvmet
+
}

+post()
+{
+       modprobe -r nvme-loop
+       modprobe -r nvme-core
+       modprobe -r nvmet
+
+}

+test() {
+       echo "Running ${TEST_NAME}"
+
+       pre
+
+       modprobe nvme-core multipath=1
+       modprobe nvmet
+       modprobe nvme-loop
+
+       local port
+       port=$(_create_nvmet_port "loop")
+
+       truncate -s 1G "$TMPDIR/img"
+
+       local loop_dev
+       loop_dev="$(losetup -f --show "$TMPDIR/img")"
+
+       _create_nvmet_subsystem "blktests-subsystem-1" "${loop_dev}" \
+               "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+       _add_nvmet_subsys_to_port "${port}" "blktests-subsystem-1"
+
+       nvme connect -t loop -n blktests-subsystem-1
+
+       local nvmedev
+       nvmedev="$(_find_nvme_loop_dev)"
+
+       udevadm settle
+
+       echo 1 > "/sys/class/nvme/${nvmedev}/reset_controller"
+
+       nvme disconnect -d "${nvmedev}"
+       _remove_nvmet_subsystem_from_port "${port}" "blktests-subsystem-1"
+       _remove_nvmet_port "${port}"
+
+       _remove_nvmet_subsystem "blktests-subsystem-1"
+       losetup -d "$loop_dev"
+       rm "$TMPDIR/img"
+
+       post
+
+       echo "Test complete"
+}

In this way, we can move generic pre and post to the nvme/lib so that
all other tests can also use that?


On Thu, May 3, 2018@8:00 AM, Johannes Thumshirn <jthumshirn@suse.de> wrote:
> Signed-off-by: Johannes Thumshirn <jthumshirn at suse.de>
> ---
>  tests/nvme/005     | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/nvme/005.out |  2 ++
>  2 files changed, 79 insertions(+)
>  create mode 100755 tests/nvme/005
>  create mode 100644 tests/nvme/005.out
>
> diff --git a/tests/nvme/005 b/tests/nvme/005
> new file mode 100755
> index 000000000000..77f843fed692
> --- /dev/null
> +++ b/tests/nvme/005
> @@ -0,0 +1,77 @@
> +#!/bin/bash
> +#
> +# Regression test for patch "nvmet: switch loopback target state to connecting
> +# when resetting"
> +#
> +# Copyright (C) 2018 Johannes Thumshirn
> +#
> +# This program is free software: you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation, either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +DESCRIPTION="reset local loopback target"
> +
> +QUICK=1
> +
> +requires() {
> +       _have_module nvme-loop && _have_module nvmet && _have_module loop && \
> +               _have_configfs && _have_module nvme-core && \
> +               _have_module_param nvme-core multipath
> +}
> +
> +test() {
> +       echo "Running ${TEST_NAME}"
> +
> +       # Clean up all stale modules
> +       modprobe -r nvme-loop
> +       modprobe -r nvme-core
> +       modprobe -r nvmet
> +
> +       modprobe nvme-core multipath=1
> +       modprobe nvmet
> +       modprobe nvme-loop
> +
> +       local port
> +       port=$(_create_nvmet_port "loop")
> +
> +       truncate -s 1G "$TMPDIR/img"
> +
> +       local loop_dev
> +       loop_dev="$(losetup -f --show "$TMPDIR/img")"
> +
> +       _create_nvmet_subsystem "blktests-subsystem-1" "${loop_dev}" \
> +               "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
> +       _add_nvmet_subsys_to_port "${port}" "blktests-subsystem-1"
> +
> +       nvme connect -t loop -n blktests-subsystem-1
> +
> +       local nvmedev
> +       nvmedev="$(_find_nvme_loop_dev)"
> +
> +       udevadm settle
> +
> +       echo 1 > "/sys/class/nvme/${nvmedev}/reset_controller"
> +
> +       nvme disconnect -d "${nvmedev}"
> +       _remove_nvmet_subsystem_from_port "${port}" "blktests-subsystem-1"
> +       _remove_nvmet_port "${port}"
> +
> +       _remove_nvmet_subsystem "blktests-subsystem-1"
> +       losetup -d "$loop_dev"
> +       rm "$TMPDIR/img"
> +
> +       modprobe -r nvme-loop
> +       modprobe -r nvme-core
> +       modprobe -r nvmet
> +
> +       echo "Test complete"
> +}
> diff --git a/tests/nvme/005.out b/tests/nvme/005.out
> new file mode 100644
> index 000000000000..6146a7b8b1a7
> --- /dev/null
> +++ b/tests/nvme/005.out
> @@ -0,0 +1,2 @@
> +Running nvme/005
> +Test complete
> --
> 2.16.3
>
>
> _______________________________________________
> Linux-nvme mailing list
> Linux-nvme at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-nvme

  reply	other threads:[~2018-05-03 19:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-03 15:00 [PATCH blktests 1/3] nvme: move _find_nvme_loop_dev to common code Johannes Thumshirn
2018-05-03 15:00 ` [PATCH blktests 2/3] nvme: fix counting the target port Johannes Thumshirn
2018-05-03 15:00 ` [PATCH blktests 3/3] nvme: add test for resetting the loopback controller Johannes Thumshirn
2018-05-03 19:03   ` chaitany kulkarni [this message]
2018-05-04  7:34     ` Johannes Thumshirn
2018-05-14 20:02 ` [PATCH blktests 1/3] nvme: move _find_nvme_loop_dev to common code Omar Sandoval
2018-05-15  6:50   ` Johannes Thumshirn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAK0tqikbAzX79tPuoTmB-n=3+8=9ExN43k1jTsqY0E-47TN2UA@mail.gmail.com' \
    --to=ckulkarnilinux@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.