diff mbox series

[v2,2/2] tests/avocado: Add test accessing NVMe on big-endian MIPS target

Message ID 20230118095751.49728-3-philmd@linaro.org (mailing list archive)
State New, archived
Headers show
Series hw/pci-host/gt64120: Fix regression on big-endian targets | expand

Commit Message

Philippe Mathieu-Daudé Jan. 18, 2023, 9:57 a.m. UTC
Add a Linux-boot test accessing PCI NVMe drive on big-endian MIPS:

$ avocado --show=app,console run -t device:nvme tests/avocado/
   (1/1) tests/avocado/boot_linux_console.py:BootLinuxConsole.test_mips64_malta_I6400_nvme:
  console: Linux version 6.2.0-rc4 (kbj@butter) (mips64-buildroot-linux-gnu-gcc.br_real (Buildroot 2022.11) 11.3.0, GNU ld (GNU Binutils) 2.38) #6 Tue Jan 17 18:48:25 CET 2023
  console: CPU0 revision is: 0001a900 (MIPS I6400)
  console: FPU revision is: 20f30300
  console: MIPS: machine is mti,malta
  ...
  console: PCI host bridge to bus 0000:00
  console: pci_bus 0000:00: root bus resource [mem 0x10000000-0x17ffffff]
  console: pci_bus 0000:00: root bus resource [io  0x1000-0x1fffff]
  console: pci_bus 0000:00: No busn resource found for root bus, will use [bus 00-ff]
  console: pci 0000:00:0a.0: [8086:7110] type 00 class 0x060100
  console: pci 0000:00:0a.1: [8086:7111] type 00 class 0x010180
  console: pci 0000:00:0a.1: reg 0x20: [io  0x0000-0x000f]
  console: pci 0000:00:0a.1: legacy IDE quirk: reg 0x10: [io  0x01f0-0x01f7]
  console: pci 0000:00:0a.1: legacy IDE quirk: reg 0x14: [io  0x03f6]
  console: pci 0000:00:0a.1: legacy IDE quirk: reg 0x18: [io  0x0170-0x0177]
  console: pci 0000:00:0a.1: legacy IDE quirk: reg 0x1c: [io  0x0376]
  console: pci 0000:00:0a.2: [8086:7112] type 00 class 0x0c0300
  console: pci 0000:00:12.0: [1b36:0010] type 00 class 0x010802
  console: pci 0000:00:12.0: reg 0x10: [mem 0x00000000-0x00003fff 64bit]
  console: pci_bus 0000:00: busn_res: [bus 00-ff] end is updated to 00
  console: pci 0000:00:12.0: BAR 0: assigned [mem 0x10040000-0x10043fff 64bit]
  console: pci 0000:00:0a.1: BAR 4: assigned [io  0x1080-0x108f]
  ...
  console: ata_piix 0000:00:0a.1: enabling device (0000 -> 0001)
  console: nvme nvme0: pci function 0000:00:12.0
  console: nvme 0000:00:12.0: enabling device (0000 -> 0002)
  console: nvme nvme0: 1/0/0 default/read/poll queues
  console: nvme nvme0: Ignoring bogus Namespace Identifiers
  ...
  console: Run /sbin/init as init process
  console: EXT4-fs (nvme0n1): re-mounted bf659b11-5a77-4ab5-a337-3d71ced26114. Quota mode: disabled.
  ...
  console: Welcome to Buildroot
  console: buildroot login: root
  ...
  console: # reboot
  ...
  console: umount: devtmpfs busy - remounted read-only
  console: EXT4-fs (nvme0n1): re-mounted bf659b11-5a77-4ab5-a337-3d71ced26114. Quota mode: disabled.
  console: The system is going down NOW!
  console: Requesting system reboot
  console: reboot: Restarting system
  PASS (11.17 s)
  JOB TIME   : 11.91 s

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 tests/avocado/boot_linux_console.py | 44 +++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

Comments

Klaus Jensen Jan. 19, 2023, 9:39 a.m. UTC | #1
On Jan 18 10:57, Philippe Mathieu-Daudé wrote:
> Add a Linux-boot test accessing PCI NVMe drive on big-endian MIPS:
> 
> $ avocado --show=app,console run -t device:nvme tests/avocado/
>    (1/1) tests/avocado/boot_linux_console.py:BootLinuxConsole.test_mips64_malta_I6400_nvme:
>   console: Linux version 6.2.0-rc4 (kbj@butter) (mips64-buildroot-linux-gnu-gcc.br_real (Buildroot 2022.11) 11.3.0, GNU ld (GNU Binutils) 2.38) #6 Tue Jan 17 18:48:25 CET 2023
>   console: CPU0 revision is: 0001a900 (MIPS I6400)
>   console: FPU revision is: 20f30300
>   console: MIPS: machine is mti,malta
>   ...
>   console: PCI host bridge to bus 0000:00
>   console: pci_bus 0000:00: root bus resource [mem 0x10000000-0x17ffffff]
>   console: pci_bus 0000:00: root bus resource [io  0x1000-0x1fffff]
>   console: pci_bus 0000:00: No busn resource found for root bus, will use [bus 00-ff]
>   console: pci 0000:00:0a.0: [8086:7110] type 00 class 0x060100
>   console: pci 0000:00:0a.1: [8086:7111] type 00 class 0x010180
>   console: pci 0000:00:0a.1: reg 0x20: [io  0x0000-0x000f]
>   console: pci 0000:00:0a.1: legacy IDE quirk: reg 0x10: [io  0x01f0-0x01f7]
>   console: pci 0000:00:0a.1: legacy IDE quirk: reg 0x14: [io  0x03f6]
>   console: pci 0000:00:0a.1: legacy IDE quirk: reg 0x18: [io  0x0170-0x0177]
>   console: pci 0000:00:0a.1: legacy IDE quirk: reg 0x1c: [io  0x0376]
>   console: pci 0000:00:0a.2: [8086:7112] type 00 class 0x0c0300
>   console: pci 0000:00:12.0: [1b36:0010] type 00 class 0x010802
>   console: pci 0000:00:12.0: reg 0x10: [mem 0x00000000-0x00003fff 64bit]
>   console: pci_bus 0000:00: busn_res: [bus 00-ff] end is updated to 00
>   console: pci 0000:00:12.0: BAR 0: assigned [mem 0x10040000-0x10043fff 64bit]
>   console: pci 0000:00:0a.1: BAR 4: assigned [io  0x1080-0x108f]
>   ...
>   console: ata_piix 0000:00:0a.1: enabling device (0000 -> 0001)
>   console: nvme nvme0: pci function 0000:00:12.0
>   console: nvme 0000:00:12.0: enabling device (0000 -> 0002)
>   console: nvme nvme0: 1/0/0 default/read/poll queues
>   console: nvme nvme0: Ignoring bogus Namespace Identifiers
>   ...
>   console: Run /sbin/init as init process
>   console: EXT4-fs (nvme0n1): re-mounted bf659b11-5a77-4ab5-a337-3d71ced26114. Quota mode: disabled.
>   ...
>   console: Welcome to Buildroot
>   console: buildroot login: root
>   ...
>   console: # reboot
>   ...
>   console: umount: devtmpfs busy - remounted read-only
>   console: EXT4-fs (nvme0n1): re-mounted bf659b11-5a77-4ab5-a337-3d71ced26114. Quota mode: disabled.
>   console: The system is going down NOW!
>   console: Requesting system reboot
>   console: reboot: Restarting system
>   PASS (11.17 s)
>   JOB TIME   : 11.91 s
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  tests/avocado/boot_linux_console.py | 44 +++++++++++++++++++++++++++++
>  1 file changed, 44 insertions(+)
> 
> diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py
> index 8c1d981586..176793482e 100644
> --- a/tests/avocado/boot_linux_console.py
> +++ b/tests/avocado/boot_linux_console.py
> @@ -12,6 +12,7 @@
>  import lzma
>  import gzip
>  import shutil
> +import time
>  
>  from avocado import skip
>  from avocado import skipUnless
> @@ -269,6 +270,49 @@ def test_mips64el_malta_5KEc_cpio(self):
>          # Wait for VM to shut down gracefully
>          self.vm.wait()
>  
> +    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
> +    def test_mips64_malta_I6400_nvme(self):
> +        """
> +        :avocado: tags=arch:mips64
> +        :avocado: tags=machine:malta
> +        :avocado: tags=endian:big
> +        :avocado: tags=cpu:I6400
> +        :avocado: tags=device:nvme
> +        """
> +        kernel_url = ('https://github.com/birkelund/qemu-nvme-boot/'
> +                      'raw/main/mips64/images/vmlinux')
> +        kernel_hash = '665662d7f7b17dc261ffb0e0ff4a1a7da91de948'
> +        kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
> +        rootfs_url = ('https://github.com/birkelund/qemu-nvme-boot/'
> +                      'raw/main/mips64/images/rootfs.ext2.gz')
> +        rootfs_hash = '66f5ca4ef20ab983ec424c3ed8462bab305bbb73'
> +        rootfs_path_gz = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash)
> +        rootfs_path = os.path.join(self.workdir, "rootfs.ext2")
> +        archive.gzip_uncompress(rootfs_path_gz, rootfs_path)
> +
> +        self.vm.set_console()
> +        kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
> +                               + 'console=ttyS0,115200 '
> +                               + 'root=/dev/nvme0n1 '
> +                               + 'rdinit=/sbin/init noreboot')
> +        self.vm.add_args('-kernel', kernel_path,
> +                         '-append', kernel_command_line,
> +                         '-drive',
> +                                f'file={rootfs_path},format=raw,if=none,id=d0',
> +                         '-device', 'nvme,serial=default,drive=d0',
> +                         '-nic', 'user,model=pcnet',
> +                         '-no-reboot', '-snapshot', '-nodefaults')
> +        self.vm.launch()
> +        wait_for_console_pattern(self, 'Welcome to Buildroot')
> +        time.sleep(0.1)
> +        exec_command(self, 'root')
> +        time.sleep(0.1)
> +
> +        exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
> +                                                'MIPS I6400')
> +        exec_command_and_wait_for_pattern(self, 'reboot',
> +                                                'reboot: Restarting system')
> +
>      def do_test_mips_malta32el_nanomips(self, kernel_url, kernel_hash):
>          kernel_path_xz = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
>          kernel_path = self.workdir + "kernel"
> -- 
> 2.38.1
> 

Hi Philippe,

I didn't expect to store images in that repo, but can you change the
above to fetch it from

https://github.com/birkelund/qemu-issues/tree/main/20230117-mips-boot-nvme-pci/images

instead? Then I'll keep that archived and available.
diff mbox series

Patch

diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py
index 8c1d981586..176793482e 100644
--- a/tests/avocado/boot_linux_console.py
+++ b/tests/avocado/boot_linux_console.py
@@ -12,6 +12,7 @@ 
 import lzma
 import gzip
 import shutil
+import time
 
 from avocado import skip
 from avocado import skipUnless
@@ -269,6 +270,49 @@  def test_mips64el_malta_5KEc_cpio(self):
         # Wait for VM to shut down gracefully
         self.vm.wait()
 
+    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+    def test_mips64_malta_I6400_nvme(self):
+        """
+        :avocado: tags=arch:mips64
+        :avocado: tags=machine:malta
+        :avocado: tags=endian:big
+        :avocado: tags=cpu:I6400
+        :avocado: tags=device:nvme
+        """
+        kernel_url = ('https://github.com/birkelund/qemu-nvme-boot/'
+                      'raw/main/mips64/images/vmlinux')
+        kernel_hash = '665662d7f7b17dc261ffb0e0ff4a1a7da91de948'
+        kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
+        rootfs_url = ('https://github.com/birkelund/qemu-nvme-boot/'
+                      'raw/main/mips64/images/rootfs.ext2.gz')
+        rootfs_hash = '66f5ca4ef20ab983ec424c3ed8462bab305bbb73'
+        rootfs_path_gz = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash)
+        rootfs_path = os.path.join(self.workdir, "rootfs.ext2")
+        archive.gzip_uncompress(rootfs_path_gz, rootfs_path)
+
+        self.vm.set_console()
+        kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
+                               + 'console=ttyS0,115200 '
+                               + 'root=/dev/nvme0n1 '
+                               + 'rdinit=/sbin/init noreboot')
+        self.vm.add_args('-kernel', kernel_path,
+                         '-append', kernel_command_line,
+                         '-drive',
+                                f'file={rootfs_path},format=raw,if=none,id=d0',
+                         '-device', 'nvme,serial=default,drive=d0',
+                         '-nic', 'user,model=pcnet',
+                         '-no-reboot', '-snapshot', '-nodefaults')
+        self.vm.launch()
+        wait_for_console_pattern(self, 'Welcome to Buildroot')
+        time.sleep(0.1)
+        exec_command(self, 'root')
+        time.sleep(0.1)
+
+        exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
+                                                'MIPS I6400')
+        exec_command_and_wait_for_pattern(self, 'reboot',
+                                                'reboot: Restarting system')
+
     def do_test_mips_malta32el_nanomips(self, kernel_url, kernel_hash):
         kernel_path_xz = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
         kernel_path = self.workdir + "kernel"