diff mbox

[ndctl] ndctl, tests: firmware-update.sh post-test cleanup

Message ID 20180223213827.24808-1-ross.zwisler@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ross Zwisler Feb. 23, 2018, 9:38 p.m. UTC
When firmware-update.sh is run multiple times by itself, all runs but the
first fail with this:

+ ../ndctl/ndctl update-firmware -d nmem1 -f update-fw.img
  Error: START FIRMWARE UPDATE failed: 0x9

  Error: Another firmware upload in progress or finished.

Fix this by having the test properly clean up and disable all the nfit_test
regions and unloading the nfit_test module, as we do in test/pmem-errors.sh
et al.

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
---
 test/firmware-update.sh | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Dan Williams Feb. 23, 2018, 9:47 p.m. UTC | #1
On Fri, Feb 23, 2018 at 1:38 PM, Ross Zwisler
<ross.zwisler@linux.intel.com> wrote:
> When firmware-update.sh is run multiple times by itself, all runs but the
> first fail with this:
>
> + ../ndctl/ndctl update-firmware -d nmem1 -f update-fw.img
>   Error: START FIRMWARE UPDATE failed: 0x9
>
>   Error: Another firmware upload in progress or finished.
>
> Fix this by having the test properly clean up and disable all the nfit_test
> regions and unloading the nfit_test module, as we do in test/pmem-errors.sh
> et al.

Looks good to me:

Reviewed-by: Dan Williams <dan.j.williams@intel.com>
diff mbox

Patch

diff --git a/test/firmware-update.sh b/test/firmware-update.sh
index 1736472..44c1412 100755
--- a/test/firmware-update.sh
+++ b/test/firmware-update.sh
@@ -6,6 +6,7 @@ 
 [ -f "./ndctl/ndctl" ] && [ -x "./ndctl/ndctl" ] && ndctl="./ndctl/ndctl"
 [ -z "$ndctl" ] && echo "Couldn't find an ndctl binary" && exit 1
 bus="nfit_test.0"
+bus1="nfit_test.1"
 json2var="s/[{}\",]//g; s/:/=/g"
 rc=77
 dev=""
@@ -41,6 +42,13 @@  reset()
 	fi
 }
 
+cleanup()
+{
+	$ndctl disable-region -b "$bus" all
+	$ndctl disable-region -b "$bus1" all
+	modprobe -r nfit_test
+}
+
 detect()
 {
 	dev=$($ndctl list -b "$bus" -D | jq .[0].dev | tr -d '"')
@@ -59,6 +67,5 @@  rc=1
 reset
 detect
 do_tests
-reset
+cleanup
 exit 0
-