Skip to contentSkip to conversation

iotests: trivial cleanups

PATCH Superseded Cleber Rosa 4 participants 15 messages Sep 27, 2019 – Oct 9, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover iotests: trivial cleanups

The most trivial set of cleanups to iotests common libraries and the 044 test.

Cleber Rosa (4):
qemu-iotests: remove bash shebang from library files
qemu-iotests: remove forceful execution success from library files
qemu-iotests: 044: pass is actually a noop, so remove it
qemu-iotests: 044: remove inaccurate docstring class description

 tests/qemu-iotests/044            | 4 ----
 tests/qemu-iotests/common.config  | 5 -----
 tests/qemu-iotests/common.filter  | 5 -----
 tests/qemu-iotests/common.nbd     | 1 -
 tests/qemu-iotests/common.pattern | 2 --
 tests/qemu-iotests/common.qemu    | 2 --
 tests/qemu-iotests/common.rc      | 5 -----
 tests/qemu-iotests/common.tls     | 2 --
 8 files changed, 26 deletions(-)
Signature · 1 line
2.21.0
#1 lore raw

PATCH 1/4 qemu-iotests: remove bash shebang from library files

Due to not being able to find a reason to have shebangs on files that are not executable.

---
 tests/qemu-iotests/common.config  | 2 --
 tests/qemu-iotests/common.filter  | 2 --
 tests/qemu-iotests/common.nbd     | 1 -
 tests/qemu-iotests/common.pattern | 2 --
 tests/qemu-iotests/common.qemu    | 2 --
 tests/qemu-iotests/common.rc      | 2 --
 tests/qemu-iotests/common.tls     | 2 --
 7 files changed, 13 deletions(-)
tests/qemu-iotests/common.config +0 -2
index 9bd1a5a6fc..6956d38d4c 100644
@@ -1,5 +1,3 @@
-#!/usr/bin/env bash
-#
 # Copyright (C) 2009 Red Hat, Inc.
 # Copyright (c) 2000-2003,2006 Silicon Graphics, Inc.  All Rights Reserved.
 #
tests/qemu-iotests/common.filter +0 -2
index 445a1c23e0..043c62c10c 100644
@@ -1,5 +1,3 @@
-#!/usr/bin/env bash
-#
 # Copyright (C) 2009 Red Hat, Inc.
 # Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
 #
tests/qemu-iotests/common.nbd +0 -1
index 24b01b60aa..5a9991b7ef 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env bash
 # -*- shell-script-mode -*-
 #
 # Helpers for NBD server related config
tests/qemu-iotests/common.pattern +0 -2
index 4f5e5bcea0..e8d97dd2bb 100644
@@ -1,5 +1,3 @@
-#!/usr/bin/env bash
-#
 # Copyright (C) 2009 Red Hat, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
tests/qemu-iotests/common.qemu +0 -2
index 8d2021a7eb..5bdfde890d 100644
@@ -1,5 +1,3 @@
-#!/usr/bin/env bash
-#
 # This allows for launching of multiple QEMU instances, with independent
 # communication possible to each instance.
 #
tests/qemu-iotests/common.rc +0 -2
index e45cdfa66b..19bddacf11 100644
@@ -1,5 +1,3 @@
-#!/usr/bin/env bash
-#
 # Copyright (C) 2009 Red Hat, Inc.
 # Copyright (c) 2000-2006 Silicon Graphics, Inc.  All Rights Reserved.
 #
tests/qemu-iotests/common.tls +0 -2
index 54c331d7a5..61f8ef6037 100644
@@ -1,5 +1,3 @@
-#!/usr/bin/env bash
-#
 # Helpers for TLS related config
 #
 # Copyright (C) 2018 Red Hat, Inc.
Signature · 1 line
2.21.0
#2 lore raw

Re: [PATCH 1/4] qemu-iotests: remove bash shebang from library files

Quoted 4 lines · Cleber Rosa

Due to not being able to find a reason to have shebangs on files that are not executable.

Quoted 10 lines
---
  tests/qemu-iotests/common.config  | 2 --
  tests/qemu-iotests/common.filter  | 2 --
  tests/qemu-iotests/common.nbd     | 1 -
  tests/qemu-iotests/common.pattern | 2 --
  tests/qemu-iotests/common.qemu    | 2 --
  tests/qemu-iotests/common.rc      | 2 --
  tests/qemu-iotests/common.tls     | 2 --
  7 files changed, 13 deletions(-)

Loss of the shebang changes the mode in which emacs opens the files (from Shell-script[bash] to Conf[space] in my case). I agree that a #! comment is not appropriate for a file that is not executable as a standalone file, but it becomes harder to edit the file correctly unless we replace it with some other way of letting editors realize that the contents of each file is still meant to be consumed by bash.

Something like this would work:

# hey emacs, this file will be sourced by bash: -*- sh -*-
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#3 lore raw

Re: [PATCH 1/4] qemu-iotests: remove bash shebang from library files

Quoted 23 lines · Eric Blake
Quoted 4 lines · Cleber Rosa

Due to not being able to find a reason to have shebangs on files that are not executable.

Quoted 10 lines
---
  tests/qemu-iotests/common.config  | 2 --
  tests/qemu-iotests/common.filter  | 2 --
  tests/qemu-iotests/common.nbd     | 1 -
  tests/qemu-iotests/common.pattern | 2 --
  tests/qemu-iotests/common.qemu    | 2 --
  tests/qemu-iotests/common.rc      | 2 --
  tests/qemu-iotests/common.tls     | 2 --
  7 files changed, 13 deletions(-)

Loss of the shebang changes the mode in which emacs opens the files (from Shell-script[bash] to Conf[space] in my case). I agree that a #! comment is not appropriate for a file that is not executable as a standalone file, but it becomes harder to edit the file correctly unless we replace it with some other way of letting editors realize that the contents of each file is still meant to be consumed by bash.

Quoted 4 lines

Something like this would work:

# hey emacs, this file will be sourced by bash: -*- sh -*-

Yes, good point. Will send that on a v2.

- Cleber.

Quoted 4 lines
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#4 lore raw

Re: [PATCH 1/4] qemu-iotests: remove bash shebang from library files

Quoted 24 lines · Cleber Rosa
Quoted 23 lines · Eric Blake
Quoted 4 lines · Cleber Rosa

Due to not being able to find a reason to have shebangs on files that are not executable.

Quoted 10 lines
---
  tests/qemu-iotests/common.config  | 2 --
  tests/qemu-iotests/common.filter  | 2 --
  tests/qemu-iotests/common.nbd     | 1 -
  tests/qemu-iotests/common.pattern | 2 --
  tests/qemu-iotests/common.qemu    | 2 --
  tests/qemu-iotests/common.rc      | 2 --
  tests/qemu-iotests/common.tls     | 2 --
  7 files changed, 13 deletions(-)

Loss of the shebang changes the mode in which emacs opens the files (from Shell-script[bash] to Conf[space] in my case). I agree that a #! comment is not appropriate for a file that is not executable as a standalone file, but it becomes harder to edit the file correctly unless we replace it with some other way of letting editors realize that the contents of each file is still meant to be consumed by bash.

Quoted 7 lines
Quoted 4 lines

Something like this would work:

# hey emacs, this file will be sourced by bash: -*- sh -*-

Yes, good point. Will send that on a v2.

BTW, in addition to that, we may add to .editorconfig something like:

[tests/qemu-iotests/common.*]
indent_style = space
indent_size = 4
file_type_emacs = sh

Although I was expecting editorconfig to provide a mode hint for other editors, which doesn't seem to be the case.

Cheers,
- Cleber.

Quoted 6 lines

- Cleber.

Quoted 4 lines
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#5 lore raw

PATCH 2/4 qemu-iotests: remove forceful execution success from library files

In reply to Cleber Rosa

Should not be necessary on files that are not executed standalone.

---
 tests/qemu-iotests/common.config | 3 ---
 tests/qemu-iotests/common.filter | 3 ---
 tests/qemu-iotests/common.rc     | 3 ---
 3 files changed, 9 deletions(-)
tests/qemu-iotests/common.config +0 -3
index 6956d38d4c..0a24d960ff 100644
@@ -34,6 +34,3 @@ _optstr_add()
         echo "$2"
     fi
 }
-
-# make sure this script returns success
-true
tests/qemu-iotests/common.filter +0 -3
index 043c62c10c..55db15865a 100644
@@ -221,6 +221,3 @@ _filter_qmp_empty_return()
 {
     grep -v '{"return": {}}'
 }
-
-# make sure this script returns success
-true
tests/qemu-iotests/common.rc +0 -3
index 19bddacf11..d7e6456086 100644
@@ -600,6 +600,3 @@ _require_drivers()
         fi
     done
 }
-
-# make sure this script returns success
-true
Signature · 1 line
2.21.0
Reviewed-by on v1 2/4
#6 lore raw

Re: [PATCH 2/4] qemu-iotests: remove forceful execution success from library files

Quoted 14 lines · Cleber Rosa

Should not be necessary on files that are not executed standalone.

---
  tests/qemu-iotests/common.config | 3 ---
  tests/qemu-iotests/common.filter | 3 ---
  tests/qemu-iotests/common.rc     | 3 ---
  3 files changed, 9 deletions(-)
tests/qemu-iotests/common.config +0 -0
index 6956d38d4c..0a24d960ff 100644

tests/qemu-iotests/common.config _optstr_add() · line 39

Quoted 6 lines
tests/qemu-iotests/common.config +0 -3
@@ -34,6 +34,3 @@ _optstr_add()
          echo "$2"
      fi
  }
-
-# make sure this script returns success
-true

The exit status of the source command in the caller depends on the last command executed here.

However, you also have the point that if you delete this line, the last command executed is a function definition which is successful (for all 3 files touched). So there is no behavior change in dropping this line.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#7 lore raw

PATCH 3/4 qemu-iotests: 044: pass is actually a noop, so remove it

In reply to Cleber Rosa
---
 tests/qemu-iotests/044 | 3 ---
 1 file changed, 3 deletions(-)
tests/qemu-iotests/044 +0 -3
index 05ea1f49c5..eb42df0fe1 100755
@@ -105,17 +105,14 @@ class TestRefcountTableGrowth(iotests.QMPTestCase):
     def setUp(self):
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'cluster_size=512', test_img, '16G')
         self.preallocate(test_img)
-        pass
 
 
     def tearDown(self):
         os.remove(test_img)
-        pass
 
     def test_grow_refcount_table(self):
         qemu_io('-c', 'write 3800M 1M', test_img)
         qemu_img_verbose('check' , test_img)
-        pass
 
 if __name__ == '__main__':
     iotests.main(supported_fmts=['qcow2'],
Signature · 1 line
2.21.0
Reviewed-by on v1 3/4
#8 lore raw

Re: [PATCH 3/4] qemu-iotests: 044: pass is actually a noop, so remove it

Quoted 4 lines · Cleber Rosa
---
  tests/qemu-iotests/044 | 3 ---
  1 file changed, 3 deletions(-)

It's useful when there is nothing else, but here we definitely have something else.

Quoted 24 lines
tests/qemu-iotests/044 +0 -3
index 05ea1f49c5..eb42df0fe1 100755
@@ -105,17 +105,14 @@ class TestRefcountTableGrowth(iotests.QMPTestCase):
      def setUp(self):
          qemu_img('create', '-f', iotests.imgfmt, '-o', 'cluster_size=512', test_img, '16G')
          self.preallocate(test_img)
-        pass
 
 
      def tearDown(self):
          os.remove(test_img)
-        pass
 
      def test_grow_refcount_table(self):
          qemu_io('-c', 'write 3800M 1M', test_img)
          qemu_img_verbose('check' , test_img)
-        pass
 
  if __name__ == '__main__':
      iotests.main(supported_fmts=['qcow2'],
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#10 lore raw

PATCH 4/4 qemu-iotests: 044: remove inaccurate docstring class description

In reply to Cleber Rosa
---
 tests/qemu-iotests/044 | 1 -
 1 file changed, 1 deletion(-)
tests/qemu-iotests/044 +0 -1
index eb42df0fe1..0ca4bcfc6d 100755
@@ -34,7 +34,6 @@ if sys.version_info.major == 2:
 test_img = os.path.join(iotests.test_dir, 'test.img')
 
 class TestRefcountTableGrowth(iotests.QMPTestCase):
-    '''Abstract base class for image mirroring test cases'''
 
     def preallocate(self, name):
         fd = open(name, "r+b")
Signature · 1 line
2.21.0
Reviewed-by on v1 4/4
#11 lore raw

Re: [PATCH 4/4] qemu-iotests: 044: remove inaccurate docstring class description

Quoted 10 lines · Cleber Rosa
---
  tests/qemu-iotests/044 | 1 -
  1 file changed, 1 deletion(-)
tests/qemu-iotests/044 +0 -0
index eb42df0fe1..0ca4bcfc6d 100755

tests/qemu-iotests/044 if sys.version_info.major == 2: · line 37

Quoted 5 lines
tests/qemu-iotests/044 +0 -1
@@ -34,7 +34,6 @@ if sys.version_info.major == 2:
  test_img = os.path.join(iotests.test_dir, 'test.img')
 
  class TestRefcountTableGrowth(iotests.QMPTestCase):
-    '''Abstract base class for image mirroring test cases'''
 

Should we replace it with something useful? But this isn't meant to be reused outside this test, so it doesn't hurt to have no documentation.

Quoted 3 lines
tests/qemu-iotests/044 +0 -0
      def preallocate(self, name):
          fd = open(name, "r+b")
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
Reviewed-by on v1 4/4
#12 lore raw

Re: [PATCH 4/4] qemu-iotests: 044: remove inaccurate docstring class description

In reply to Cleber Rosa
Quoted 11 lines · Cleber Rosa
---
 tests/qemu-iotests/044 | 1 -
 1 file changed, 1 deletion(-)
tests/qemu-iotests/044 +0 -0
index eb42df0fe1..0ca4bcfc6d 100755

tests/qemu-iotests/044 if sys.version_info.major == 2: · line 39

Quoted 7 lines
tests/qemu-iotests/044 +0 -1
@@ -34,7 +34,6 @@ if sys.version_info.major == 2:
 test_img = os.path.join(iotests.test_dir, 'test.img')
 
 class TestRefcountTableGrowth(iotests.QMPTestCase):
-    '''Abstract base class for image mirroring test cases'''
 
     def preallocate(self, name):
         fd = open(name, "r+b")
#13 lore raw
In reply to Cleber Rosa
Quoted 9 lines · Cleber Rosa

The most trivial set of cleanups to iotests common libraries and the 044 test.

Cleber Rosa (4):
qemu-iotests: remove bash shebang from library files
qemu-iotests: remove forceful execution success from library files
qemu-iotests: 044: pass is actually a noop, so remove it
qemu-iotests: 044: remove inaccurate docstring class description

Quoted 9 lines
 tests/qemu-iotests/044            | 4 ----
 tests/qemu-iotests/common.config  | 5 -----
 tests/qemu-iotests/common.filter  | 5 -----
 tests/qemu-iotests/common.nbd     | 1 -
 tests/qemu-iotests/common.pattern | 2 --
 tests/qemu-iotests/common.qemu    | 2 --
 tests/qemu-iotests/common.rc      | 5 -----
 tests/qemu-iotests/common.tls     | 2 --
 8 files changed, 26 deletions(-)

Looks OK to me, but I’d like to know what you think about Eric’s concern on patch 1.

Max

#14 lore raw
Quoted 20 lines · Max Reitz
Quoted 9 lines · Cleber Rosa

The most trivial set of cleanups to iotests common libraries and the 044 test.

Cleber Rosa (4):
qemu-iotests: remove bash shebang from library files
qemu-iotests: remove forceful execution success from library files
qemu-iotests: 044: pass is actually a noop, so remove it
qemu-iotests: 044: remove inaccurate docstring class description

Quoted 9 lines
 tests/qemu-iotests/044            | 4 ----
 tests/qemu-iotests/common.config  | 5 -----
 tests/qemu-iotests/common.filter  | 5 -----
 tests/qemu-iotests/common.nbd     | 1 -
 tests/qemu-iotests/common.pattern | 2 --
 tests/qemu-iotests/common.qemu    | 2 --
 tests/qemu-iotests/common.rc      | 5 -----
 tests/qemu-iotests/common.tls     | 2 --
 8 files changed, 26 deletions(-)
Quoted 5 lines

Looks OK to me, but I’d like to know what you think about Eric’s concern on patch 1.

Max

Yep, I agree with Eric's point. Will send a v2 shortly.

Thanks,
- Cleber.