diff mbox series

[v2,3/7] tests/functional: remove all class level fields

Message ID 20250228102738.3064045-4-berrange@redhat.com (mailing list archive)
State New, archived
Headers show
Series tests/functional: a few misc cleanups and fixes | expand

Commit Message

Daniel P. Berrangé Feb. 28, 2025, 10:27 a.m. UTC
A number of fields are set at the class level on QemuBaseTest, even
though the exact same named field is then set at the object level
later in most cases.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 tests/functional/qemu_test/testcase.py | 6 ------
 1 file changed, 6 deletions(-)

Comments

Richard Henderson Feb. 28, 2025, 4:53 p.m. UTC | #1
On 2/28/25 02:27, Daniel P. Berrangé wrote:
> A number of fields are set at the class level on QemuBaseTest, even
> though the exact same named field is then set at the object level
> later in most cases.
> 
> Reviewed-by: Thomas Huth<thuth@redhat.com>
> Signed-off-by: Daniel P. Berrangé<berrange@redhat.com>
> ---
>   tests/functional/qemu_test/testcase.py | 6 ------
>   1 file changed, 6 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
Thomas Huth March 5, 2025, 11:51 a.m. UTC | #2
On 28/02/2025 11.27, Daniel P. Berrangé wrote:
> A number of fields are set at the class level on QemuBaseTest, even
> though the exact same named field is then set at the object level
> later in most cases.
> 
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>   tests/functional/qemu_test/testcase.py | 6 ------
>   1 file changed, 6 deletions(-)
> 
> diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu_test/testcase.py
> index 058bf270ec..5b18416bed 100644
> --- a/tests/functional/qemu_test/testcase.py
> +++ b/tests/functional/qemu_test/testcase.py
> @@ -33,12 +33,6 @@
>   
>   class QemuBaseTest(unittest.TestCase):
>   
> -    arch = None
> -
> -    workdir = None
> -    log = None
> -    logdir = None

This seems to break the ACPI test:

https://gitlab.com/thuth/qemu/-/jobs/9316861224#L164

  Thomas
Daniel P. Berrangé March 5, 2025, 11:55 a.m. UTC | #3
On Wed, Mar 05, 2025 at 12:51:16PM +0100, Thomas Huth wrote:
> On 28/02/2025 11.27, Daniel P. Berrangé wrote:
> > A number of fields are set at the class level on QemuBaseTest, even
> > though the exact same named field is then set at the object level
> > later in most cases.
> > 
> > Reviewed-by: Thomas Huth <thuth@redhat.com>
> > Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> > ---
> >   tests/functional/qemu_test/testcase.py | 6 ------
> >   1 file changed, 6 deletions(-)
> > 
> > diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu_test/testcase.py
> > index 058bf270ec..5b18416bed 100644
> > --- a/tests/functional/qemu_test/testcase.py
> > +++ b/tests/functional/qemu_test/testcase.py
> > @@ -33,12 +33,6 @@
> >   class QemuBaseTest(unittest.TestCase):
> > -    arch = None
> > -
> > -    workdir = None
> > -    log = None
> > -    logdir = None
> 
> This seems to break the ACPI test:
> 
> https://gitlab.com/thuth/qemu/-/jobs/9316861224#L164

Our current code initializes  self.log in the setUp() method.

The ACPI bits code references self.log in the __init__() method.

So historically it has been referencing the class level 'log'
property which has always been None. This means if it were
to ever trigger codepaths calling self._print_log it will
crash on referncing None. So this patch has exposed a preexisting
flaw that was dormant.

I think the fix is to move ACPI bits logic out of __init__ and
into its own setUp() method.

With regards,
Daniel
diff mbox series

Patch

diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu_test/testcase.py
index 058bf270ec..5b18416bed 100644
--- a/tests/functional/qemu_test/testcase.py
+++ b/tests/functional/qemu_test/testcase.py
@@ -33,12 +33,6 @@ 
 
 class QemuBaseTest(unittest.TestCase):
 
-    arch = None
-
-    workdir = None
-    log = None
-    logdir = None
-
     '''
     @params compressed: filename, Asset, or file-like object to uncompress
     @params format: optional compression format (gzip, lzma)