diff mbox series

[PULL,2/5] tests/avocado: Add LoongArch machine start test

Message ID 20230515111908.2606580-3-gaosong@loongson.cn (mailing list archive)
State New, archived
Headers show
Series [PULL,1/5] loongarch: mark loongarch_ipi_iocsr re-entrnacy safe | expand

Commit Message

Song Gao May 15, 2023, 11:19 a.m. UTC
Add a new test in tests/avocado to check LoongArch virt machine start.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Song Gao <gaosong@loongson.cn>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Message-Id: <20230513012744.1885728-1-gaosong@loongson.cn>
---
 MAINTAINERS                        |  1 +
 tests/avocado/machine_loongarch.py | 58 ++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+)
 create mode 100644 tests/avocado/machine_loongarch.py

Comments

Thomas Huth May 29, 2024, 10:31 a.m. UTC | #1
On 15/05/2023 13.19, Song Gao wrote:
> Add a new test in tests/avocado to check LoongArch virt machine start.
> 
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Song Gao <gaosong@loongson.cn>
> Reviewed-by: Cédric Le Goater <clg@redhat.com>
> Message-Id: <20230513012744.1885728-1-gaosong@loongson.cn>
> ---
>   MAINTAINERS                        |  1 +
>   tests/avocado/machine_loongarch.py | 58 ++++++++++++++++++++++++++++++
>   2 files changed, 59 insertions(+)
>   create mode 100644 tests/avocado/machine_loongarch.py
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index ff2aa53bb9..50585117a0 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -245,6 +245,7 @@ M: Xiaojuan Yang <yangxiaojuan@loongson.cn>
>   S: Maintained
>   F: target/loongarch/
>   F: tests/tcg/loongarch64/
> +F: tests/avocado/machine_loongarch.py
>   
>   M68K TCG CPUs
>   M: Laurent Vivier <laurent@vivier.eu>
> diff --git a/tests/avocado/machine_loongarch.py b/tests/avocado/machine_loongarch.py
> new file mode 100644
> index 0000000000..7d8a3c1fa5
> --- /dev/null
> +++ b/tests/avocado/machine_loongarch.py
> @@ -0,0 +1,58 @@
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +#
> +# LoongArch virt test.
> +#
> +# Copyright (c) 2023 Loongson Technology Corporation Limited
> +#
> +
> +from avocado_qemu import QemuSystemTest
> +from avocado_qemu import exec_command_and_wait_for_pattern
> +from avocado_qemu import wait_for_console_pattern
> +
> +class LoongArchMachine(QemuSystemTest):
> +    KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
> +
> +    timeout = 120
> +
> +    def wait_for_console_pattern(self, success_message, vm=None):
> +        wait_for_console_pattern(self, success_message,
> +                                 failure_message='Kernel panic - not syncing',
> +                                 vm=vm)
> +
> +    def test_loongarch64_devices(self):
> +
> +        """
> +        :avocado: tags=arch:loongarch64
> +        :avocado: tags=machine:virt
> +        """
> +
> +        kernel_url = ('https://github.com/yangxiaojuan-loongson/qemu-binary/'
> +                      'releases/download/binary-files/vmlinuz.efi')
> +        kernel_hash = '951b485b16e3788b6db03a3e1793c067009e31a2'
> +        kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
> +
> +        initrd_url = ('https://github.com/yangxiaojuan-loongson/qemu-binary/'
> +                      'releases/download/binary-files/ramdisk')
> +        initrd_hash = 'c67658d9b2a447ce7db2f73ba3d373c9b2b90ab2'
> +        initrd_path = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
> +
> +        bios_url = ('https://github.com/yangxiaojuan-loongson/qemu-binary/'
> +                    'releases/download/binary-files/QEMU_EFI.fd')
> +        bios_hash = ('dfc1bfba4853cd763b9d392d0031827e8addbca8')
> +        bios_path = self.fetch_asset(bios_url, asset_hash=bios_hash)

  Hi!

FYI, the test does not seem to work anymore - apparently the binaries have 
changed and now the hashes do not match anymore. Could you please update it? 
(preferably with some versioned binaries that do not change in the course of 
time?)

  Thank you very much!
   Thomas
Song Gao May 30, 2024, 1 p.m. UTC | #2
在 2024/5/29 下午6:31, Thomas Huth 写道:
> On 15/05/2023 13.19, Song Gao wrote:
>> Add a new test in tests/avocado to check LoongArch virt machine start.
>>
>> Reviewed-by: Thomas Huth <thuth@redhat.com>
>> Signed-off-by: Song Gao <gaosong@loongson.cn>
>> Reviewed-by: Cédric Le Goater <clg@redhat.com>
>> Message-Id: <20230513012744.1885728-1-gaosong@loongson.cn>
>> ---
>>   MAINTAINERS                        |  1 +
>>   tests/avocado/machine_loongarch.py | 58 ++++++++++++++++++++++++++++++
>>   2 files changed, 59 insertions(+)
>>   create mode 100644 tests/avocado/machine_loongarch.py
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index ff2aa53bb9..50585117a0 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -245,6 +245,7 @@ M: Xiaojuan Yang <yangxiaojuan@loongson.cn>
>>   S: Maintained
>>   F: target/loongarch/
>>   F: tests/tcg/loongarch64/
>> +F: tests/avocado/machine_loongarch.py
>>     M68K TCG CPUs
>>   M: Laurent Vivier <laurent@vivier.eu>
>> diff --git a/tests/avocado/machine_loongarch.py 
>> b/tests/avocado/machine_loongarch.py
>> new file mode 100644
>> index 0000000000..7d8a3c1fa5
>> --- /dev/null
>> +++ b/tests/avocado/machine_loongarch.py
>> @@ -0,0 +1,58 @@
>> +# SPDX-License-Identifier: GPL-2.0-or-later
>> +#
>> +# LoongArch virt test.
>> +#
>> +# Copyright (c) 2023 Loongson Technology Corporation Limited
>> +#
>> +
>> +from avocado_qemu import QemuSystemTest
>> +from avocado_qemu import exec_command_and_wait_for_pattern
>> +from avocado_qemu import wait_for_console_pattern
>> +
>> +class LoongArchMachine(QemuSystemTest):
>> +    KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
>> +
>> +    timeout = 120
>> +
>> +    def wait_for_console_pattern(self, success_message, vm=None):
>> +        wait_for_console_pattern(self, success_message,
>> +                                 failure_message='Kernel panic - not 
>> syncing',
>> +                                 vm=vm)
>> +
>> +    def test_loongarch64_devices(self):
>> +
>> +        """
>> +        :avocado: tags=arch:loongarch64
>> +        :avocado: tags=machine:virt
>> +        """
>> +
>> +        kernel_url = 
>> ('https://github.com/yangxiaojuan-loongson/qemu-binary/'
>> + 'releases/download/binary-files/vmlinuz.efi')
>> +        kernel_hash = '951b485b16e3788b6db03a3e1793c067009e31a2'
>> +        kernel_path = self.fetch_asset(kernel_url, 
>> asset_hash=kernel_hash)
>> +
>> +        initrd_url = 
>> ('https://github.com/yangxiaojuan-loongson/qemu-binary/'
>> +                      'releases/download/binary-files/ramdisk')
>> +        initrd_hash = 'c67658d9b2a447ce7db2f73ba3d373c9b2b90ab2'
>> +        initrd_path = self.fetch_asset(initrd_url, 
>> asset_hash=initrd_hash)
>> +
>> +        bios_url = 
>> ('https://github.com/yangxiaojuan-loongson/qemu-binary/'
>> + 'releases/download/binary-files/QEMU_EFI.fd')
>> +        bios_hash = ('dfc1bfba4853cd763b9d392d0031827e8addbca8')
>> +        bios_path = self.fetch_asset(bios_url, asset_hash=bios_hash)
>
>  Hi!
>
> FYI, the test does not seem to work anymore - apparently the binaries 
> have changed and now the hashes do not match anymore. Could you please 
> update it? (preferably with some versioned binaries that do not change 
> in the course of time?)
>
Thank you,  I had send a patch to fix it.

Thanks.
Song Gao
Jiaxun Yang May 30, 2024, 1:16 p.m. UTC | #3
在2024年5月30日五月 下午2:00,gaosong写道:
[...]
>> FYI, the test does not seem to work anymore - apparently the binaries 
>> have changed and now the hashes do not match anymore. Could you please 
>> update it? (preferably with some versioned binaries that do not change 
>> in the course of time?)
>>
> Thank you,  I had send a patch to fix it.

Hi Song,

As LoongArch EDK2 support has been merged long ago, do you to make a clean
build and add it to pc-bios directory?

Thanks
- Jiaxun

>
> Thanks.
> Song Gao
Song Gao May 31, 2024, 1:52 a.m. UTC | #4
在 2024/5/30 下午9:16, Jiaxun Yang 写道:
>
> 在2024年5月30日五月 下午2:00,gaosong写道:
> [...]
>>> FYI, the test does not seem to work anymore - apparently the binaries
>>> have changed and now the hashes do not match anymore. Could you please
>>> update it? (preferably with some versioned binaries that do not change
>>> in the course of time?)
>>>
>> Thank you,  I had send a patch to fix it.
> Hi Song,
>
> As LoongArch EDK2 support has been merged long ago, do you to make a clean
> build and add it to pc-bios directory?
EDK2 LoongArchVirt under OvmfPkg is being committed to upstream.

PR:
https://github.com/tianocore/edk2/pull/5208

Thanks
Song Gao
>
> Thanks
> - Jiaxun
Jiaxun Yang May 31, 2024, 5:34 a.m. UTC | #5
在2024年5月31日五月 上午2:52,gaosong写道:
> 在 2024/5/30 下午9:16, Jiaxun Yang 写道:
>>
>> 在2024年5月30日五月 下午2:00,gaosong写道:
>> [...]
>>>> FYI, the test does not seem to work anymore - apparently the binaries
>>>> have changed and now the hashes do not match anymore. Could you please
>>>> update it? (preferably with some versioned binaries that do not change
>>>> in the course of time?)
>>>>
>>> Thank you,  I had send a patch to fix it.
>> Hi Song,
>>
>> As LoongArch EDK2 support has been merged long ago, do you to make a clean
>> build and add it to pc-bios directory?
> EDK2 LoongArchVirt under OvmfPkg is being committed to upstream.
>
> PR:
> https://github.com/tianocore/edk2/pull/5208

I meant here:

https://gitlab.com/qemu-project/qemu/-/tree/master/pc-bios?ref_type=heads

Thanks
>
> Thanks
> Song Gao
>>
>> Thanks
>> - Jiaxun
Song Gao May 31, 2024, 8:38 a.m. UTC | #6
在 2024/5/31 下午1:34, Jiaxun Yang 写道:
>
> 在2024年5月31日五月 上午2:52,gaosong写道:
>> 在 2024/5/30 下午9:16, Jiaxun Yang 写道:
>>> 在2024年5月30日五月 下午2:00,gaosong写道:
>>> [...]
>>>>> FYI, the test does not seem to work anymore - apparently the binaries
>>>>> have changed and now the hashes do not match anymore. Could you please
>>>>> update it? (preferably with some versioned binaries that do not change
>>>>> in the course of time?)
>>>>>
>>>> Thank you,  I had send a patch to fix it.
>>> Hi Song,
>>>
>>> As LoongArch EDK2 support has been merged long ago, do you to make a clean
>>> build and add it to pc-bios directory?
>> EDK2 LoongArchVirt under OvmfPkg is being committed to upstream.
>>
>> PR:
>> https://github.com/tianocore/edk2/pull/5208
> I meant here:
>
> https://gitlab.com/qemu-project/qemu/-/tree/master/pc-bios?ref_type=heads
Sorry, I didn't explain it well.

We already send a patch[1] to the QEMU community, this patch create a 
submodule 'roms/edk2-platform',
because the LoongArch BIOS code is all in edk2-platform repo. but the 
QEMU community think that
the edk2-platform project is too large. so we plan to move the LoongArch 
BIOS code from edk2-platfrom to the edk2 repo.

The PR[2] is to move edk2-platform to edk2 repo. but not merged in yet.

[1]: 
https://patchew.org/QEMU/260307952ffe5382a55d66a4999034490e04f7df.1691653307.git.lixianglai@loongson.cn/
[2]: https://github.com/tianocore/edk2/pull/5208

Related Discussions :
https://lore.kernel.org/all/1f1d3d9f-c3df-4f29-df66-886410994cc3@xen0n.name/

Thanks.
Song Gao
>>> Thanks
>>> - Jiaxun
diff mbox series

Patch

diff --git a/MAINTAINERS b/MAINTAINERS
index ff2aa53bb9..50585117a0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -245,6 +245,7 @@  M: Xiaojuan Yang <yangxiaojuan@loongson.cn>
 S: Maintained
 F: target/loongarch/
 F: tests/tcg/loongarch64/
+F: tests/avocado/machine_loongarch.py
 
 M68K TCG CPUs
 M: Laurent Vivier <laurent@vivier.eu>
diff --git a/tests/avocado/machine_loongarch.py b/tests/avocado/machine_loongarch.py
new file mode 100644
index 0000000000..7d8a3c1fa5
--- /dev/null
+++ b/tests/avocado/machine_loongarch.py
@@ -0,0 +1,58 @@ 
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# LoongArch virt test.
+#
+# Copyright (c) 2023 Loongson Technology Corporation Limited
+#
+
+from avocado_qemu import QemuSystemTest
+from avocado_qemu import exec_command_and_wait_for_pattern
+from avocado_qemu import wait_for_console_pattern
+
+class LoongArchMachine(QemuSystemTest):
+    KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
+
+    timeout = 120
+
+    def wait_for_console_pattern(self, success_message, vm=None):
+        wait_for_console_pattern(self, success_message,
+                                 failure_message='Kernel panic - not syncing',
+                                 vm=vm)
+
+    def test_loongarch64_devices(self):
+
+        """
+        :avocado: tags=arch:loongarch64
+        :avocado: tags=machine:virt
+        """
+
+        kernel_url = ('https://github.com/yangxiaojuan-loongson/qemu-binary/'
+                      'releases/download/binary-files/vmlinuz.efi')
+        kernel_hash = '951b485b16e3788b6db03a3e1793c067009e31a2'
+        kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
+
+        initrd_url = ('https://github.com/yangxiaojuan-loongson/qemu-binary/'
+                      'releases/download/binary-files/ramdisk')
+        initrd_hash = 'c67658d9b2a447ce7db2f73ba3d373c9b2b90ab2'
+        initrd_path = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
+
+        bios_url = ('https://github.com/yangxiaojuan-loongson/qemu-binary/'
+                    'releases/download/binary-files/QEMU_EFI.fd')
+        bios_hash = ('dfc1bfba4853cd763b9d392d0031827e8addbca8')
+        bios_path = self.fetch_asset(bios_url, asset_hash=bios_hash)
+
+        self.vm.set_console()
+        kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
+                               'root=/dev/ram rdinit=/sbin/init console=ttyS0,115200')
+        self.vm.add_args('-nographic',
+                         '-smp', '4',
+                         '-m', '1024',
+                         '-cpu', 'la464',
+                         '-kernel', kernel_path,
+                         '-initrd', initrd_path,
+                         '-bios', bios_path,
+                         '-append', kernel_command_line)
+        self.vm.launch()
+        self.wait_for_console_pattern('Run /sbin/init as init process')
+        exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
+                                          'processor		: 3')