[PATCH 6/7] tools/python: Improve unit test handling

Andrew Cooper posted 7 patches 2 years, 9 months ago
[PATCH 6/7] tools/python: Improve unit test handling
Posted by Andrew Cooper 2 years, 9 months ago
 * Add X86_{CPUID,MSR}_POLICY_FORMAT checks which were missed previously.
 * Drop test_suite().  It hasn't been necessary since the Py2.3 era.
 * Drop the __main__ logic.  This can't be used without manually adjusting the
   include path, and `make test` knows how to do the right thing.
 * For `make test`, use `-v` to see which tests have been discovered and run.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Wei Liu <wl@xen.org>
CC: Anthony PERARD <anthony.perard@citrix.com>
CC: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
CC: Bernhard Kaindl <bernhard.kaindl@citrix.com>
---
 tools/python/Makefile               |  2 +-
 tools/python/xen/migration/tests.py | 14 ++------------
 2 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/tools/python/Makefile b/tools/python/Makefile
index 511e7deae409..697299bf2802 100644
--- a/tools/python/Makefile
+++ b/tools/python/Makefile
@@ -36,7 +36,7 @@ uninstall:
 
 .PHONY: test
 test:
-	LD_LIBRARY_PATH=$$(readlink -f ../libs/ctrl):$$(readlink -f ../xenstore) $(PYTHON) -m unittest discover
+	LD_LIBRARY_PATH=$$(readlink -f ../libs/ctrl):$$(readlink -f ../xenstore) $(PYTHON) -m unittest discover -v
 
 .PHONY: clean
 clean:
diff --git a/tools/python/xen/migration/tests.py b/tools/python/xen/migration/tests.py
index ff2768946bb5..f22e2c2b7cf0 100644
--- a/tools/python/xen/migration/tests.py
+++ b/tools/python/xen/migration/tests.py
@@ -26,6 +26,8 @@ class TestLibxc(unittest.TestCase):
                          (libxc.X86_TSC_INFO_FORMAT, 24),
                          (libxc.HVM_PARAMS_ENTRY_FORMAT, 16),
                          (libxc.HVM_PARAMS_FORMAT, 8),
+                         (libxc.X86_CPUID_POLICY_FORMAT, 24),
+                         (libxc.X86_MSR_POLICY_FORMAT, 16),
                          ):
             self.assertEqual(calcsize(fmt), sz)
 
@@ -40,15 +42,3 @@ class TestLibxl(unittest.TestCase):
                          (libxl.EMULATOR_HEADER_FORMAT, 8),
                          ):
             self.assertEqual(calcsize(fmt), sz)
-
-
-def test_suite():
-    suite = unittest.TestSuite()
-
-    suite.addTest(unittest.makeSuite(TestLibxc))
-    suite.addTest(unittest.makeSuite(TestLibxl))
-
-    return suite
-
-if __name__ == "__main__":
-    unittest.main()
-- 
2.30.2


Re: [PATCH 6/7] tools/python: Improve unit test handling
Posted by Marek Marczykowski-Górecki 2 years, 9 months ago
On Tue, Mar 14, 2023 at 02:15:19PM +0000, Andrew Cooper wrote:
>  * Add X86_{CPUID,MSR}_POLICY_FORMAT checks which were missed previously.
>  * Drop test_suite().  It hasn't been necessary since the Py2.3 era.
>  * Drop the __main__ logic.  This can't be used without manually adjusting the
>    include path, and `make test` knows how to do the right thing.
>  * For `make test`, use `-v` to see which tests have been discovered and run.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>

> ---
> CC: Wei Liu <wl@xen.org>
> CC: Anthony PERARD <anthony.perard@citrix.com>
> CC: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> CC: Bernhard Kaindl <bernhard.kaindl@citrix.com>
> ---
>  tools/python/Makefile               |  2 +-
>  tools/python/xen/migration/tests.py | 14 ++------------
>  2 files changed, 3 insertions(+), 13 deletions(-)
> 
> diff --git a/tools/python/Makefile b/tools/python/Makefile
> index 511e7deae409..697299bf2802 100644
> --- a/tools/python/Makefile
> +++ b/tools/python/Makefile
> @@ -36,7 +36,7 @@ uninstall:
>  
>  .PHONY: test
>  test:
> -	LD_LIBRARY_PATH=$$(readlink -f ../libs/ctrl):$$(readlink -f ../xenstore) $(PYTHON) -m unittest discover
> +	LD_LIBRARY_PATH=$$(readlink -f ../libs/ctrl):$$(readlink -f ../xenstore) $(PYTHON) -m unittest discover -v
>  
>  .PHONY: clean
>  clean:
> diff --git a/tools/python/xen/migration/tests.py b/tools/python/xen/migration/tests.py
> index ff2768946bb5..f22e2c2b7cf0 100644
> --- a/tools/python/xen/migration/tests.py
> +++ b/tools/python/xen/migration/tests.py
> @@ -26,6 +26,8 @@ class TestLibxc(unittest.TestCase):
>                           (libxc.X86_TSC_INFO_FORMAT, 24),
>                           (libxc.HVM_PARAMS_ENTRY_FORMAT, 16),
>                           (libxc.HVM_PARAMS_FORMAT, 8),
> +                         (libxc.X86_CPUID_POLICY_FORMAT, 24),
> +                         (libxc.X86_MSR_POLICY_FORMAT, 16),
>                           ):
>              self.assertEqual(calcsize(fmt), sz)
>  
> @@ -40,15 +42,3 @@ class TestLibxl(unittest.TestCase):
>                           (libxl.EMULATOR_HEADER_FORMAT, 8),
>                           ):
>              self.assertEqual(calcsize(fmt), sz)
> -
> -
> -def test_suite():
> -    suite = unittest.TestSuite()
> -
> -    suite.addTest(unittest.makeSuite(TestLibxc))
> -    suite.addTest(unittest.makeSuite(TestLibxl))
> -
> -    return suite
> -
> -if __name__ == "__main__":
> -    unittest.main()
> -- 
> 2.30.2
> 

-- 
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab