[PATCH 2/4] tests/functional: Test both microblaze s3adsp1800 endianness variants

Thomas Huth posted 4 patches 7 months ago
Maintainers: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Alistair Francis <alistair@alistair23.me>, Peter Maydell <peter.maydell@linaro.org>
[PATCH 2/4] tests/functional: Test both microblaze s3adsp1800 endianness variants
Posted by Thomas Huth 7 months ago
From: Thomas Huth <thuth@redhat.com>

Now that the endianness of the petalogix-s3adsp1800 can be configured,
we should test that the cross-endianness also works as expected, thus
test the big endian variant on the little endian target and vice versa.
(based on an original idea from Philippe Mathieu-Daudé)

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/functional/test_microblaze_s3adsp1800.py  | 17 ++++++++++++-----
 .../functional/test_microblazeel_s3adsp1800.py  |  5 ++++-
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/tests/functional/test_microblaze_s3adsp1800.py b/tests/functional/test_microblaze_s3adsp1800.py
index c93fa14232b..c5e60b555c6 100755
--- a/tests/functional/test_microblaze_s3adsp1800.py
+++ b/tests/functional/test_microblaze_s3adsp1800.py
@@ -25,12 +25,14 @@ class MicroblazeMachine(QemuSystemTest):
         ('http://www.qemu-advent-calendar.org/2023/download/day13.tar.gz'),
         'b9b3d43c5dd79db88ada495cc6e0d1f591153fe41355e925d791fbf44de50c22')
 
-    def do_ballerina_be_test(self, machine):
-        self.set_machine(machine)
+    def do_ballerina_be_test(self, force_endianness=False):
+        self.set_machine('petalogix-s3adsp1800')
         self.archive_extract(self.ASSET_IMAGE_BE)
         self.vm.set_console()
         self.vm.add_args('-kernel',
                          self.scratch_file('day17', 'ballerina.bin'))
+        if force_endianness:
+            self.vm.add_args('-M', 'endianness=big')
         self.vm.launch()
         wait_for_console_pattern(self, 'This architecture does not have '
                                        'kernel memory protection')
@@ -39,12 +41,14 @@ def do_ballerina_be_test(self, machine):
         # message, that's why we don't test for a later string here. This
         # needs some investigation by a microblaze wizard one day...
 
-    def do_xmaton_le_test(self, machine):
+    def do_xmaton_le_test(self, force_endianness=False):
         self.require_netdev('user')
-        self.set_machine(machine)
+        self.set_machine('petalogix-s3adsp1800')
         self.archive_extract(self.ASSET_IMAGE_LE)
         self.vm.set_console()
         self.vm.add_args('-kernel', self.scratch_file('day13', 'xmaton.bin'))
+        if force_endianness:
+            self.vm.add_args('-M', 'endianness=little')
         tftproot = self.scratch_file('day13')
         self.vm.add_args('-nic', f'user,tftp={tftproot}')
         self.vm.launch()
@@ -61,7 +65,10 @@ class MicroblazeBigEndianMachine(MicroblazeMachine):
     ASSET_IMAGE_BE = MicroblazeMachine.ASSET_IMAGE_BE
 
     def test_microblaze_s3adsp1800_legacy_be(self):
-        self.do_ballerina_be_test('petalogix-s3adsp1800')
+        self.do_ballerina_be_test()
+
+    def test_microblaze_s3adsp1800_legacy_le(self):
+        self.do_xmaton_le_test(force_endianness=True)
 
 
 if __name__ == '__main__':
diff --git a/tests/functional/test_microblazeel_s3adsp1800.py b/tests/functional/test_microblazeel_s3adsp1800.py
index ab59941d57a..9de27d09b75 100755
--- a/tests/functional/test_microblazeel_s3adsp1800.py
+++ b/tests/functional/test_microblazeel_s3adsp1800.py
@@ -15,7 +15,10 @@ class MicroblazeLittleEndianMachine(MicroblazeMachine):
     ASSET_IMAGE_LE = MicroblazeMachine.ASSET_IMAGE_LE
 
     def test_microblaze_s3adsp1800_legacy_le(self):
-        self.do_xmaton_le_test('petalogix-s3adsp1800')
+        self.do_xmaton_le_test()
+
+    def test_microblaze_s3adsp1800_legacy_be(self):
+        self.do_ballerina_be_test(force_endianness=True)
 
 
 if __name__ == '__main__':
-- 
2.49.0


Re: [PATCH 2/4] tests/functional: Test both microblaze s3adsp1800 endianness variants
Posted by Philippe Mathieu-Daudé 6 months, 3 weeks ago
On 15/5/25 15:20, Thomas Huth wrote:
> From: Thomas Huth <thuth@redhat.com>
> 
> Now that the endianness of the petalogix-s3adsp1800 can be configured,
> we should test that the cross-endianness also works as expected, thus
> test the big endian variant on the little endian target and vice versa.
> (based on an original idea from Philippe Mathieu-Daudé)
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>   tests/functional/test_microblaze_s3adsp1800.py  | 17 ++++++++++++-----
>   .../functional/test_microblazeel_s3adsp1800.py  |  5 ++++-
>   2 files changed, 16 insertions(+), 6 deletions(-)
> 
> diff --git a/tests/functional/test_microblaze_s3adsp1800.py b/tests/functional/test_microblaze_s3adsp1800.py
> index c93fa14232b..c5e60b555c6 100755
> --- a/tests/functional/test_microblaze_s3adsp1800.py
> +++ b/tests/functional/test_microblaze_s3adsp1800.py
> @@ -25,12 +25,14 @@ class MicroblazeMachine(QemuSystemTest):
>           ('http://www.qemu-advent-calendar.org/2023/download/day13.tar.gz'),
>           'b9b3d43c5dd79db88ada495cc6e0d1f591153fe41355e925d791fbf44de50c22')
>   
> -    def do_ballerina_be_test(self, machine):
> -        self.set_machine(machine)
> +    def do_ballerina_be_test(self, force_endianness=False):
> +        self.set_machine('petalogix-s3adsp1800')
>           self.archive_extract(self.ASSET_IMAGE_BE)
>           self.vm.set_console()
>           self.vm.add_args('-kernel',
>                            self.scratch_file('day17', 'ballerina.bin'))
> +        if force_endianness:
> +            self.vm.add_args('-M', 'endianness=big')

This 'force_endianness' is a bit confusing, I'd simply always set
the endianness, anyhow:

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>