diff mbox series

[RFC,v2,3/3] acceptance tests: Add EDK2 ArmVirtQemu boot and console checking test

Message ID 20181003183036.6716-4-philmd@redhat.com
State New
Headers show
Series acceptance tests: Test firmware checking debug console output | expand

Commit Message

Philippe Mathieu-Daudé Oct. 3, 2018, 6:30 p.m. UTC
This test boots EDK2 ArmVirtQemu and check the debug console (PL011) reports enough
information on the initialized devices.

$ avocado run -p qemu_bin=aarch64-softmmu/qemu-system-aarch64 tests/acceptance/boot_firmware.py
JOB ID     : cb1c5bd9e0312483eabeffbb37885a5273ef23bf
JOB LOG    : /home/phil/avocado/job-results/job-2018-10-03T19.39-cb1c5bd/job.log
 (1/1) tests/acceptance/boot_firmware.py:BootFirmware.test_ovmf_virt: PASS (5.02 s)
RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB TIME   : 5.30 s

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
The '-p' option requires Avocado >= 65.0
---
 tests/acceptance/boot_firmware.py | 36 +++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

Comments

Laszlo Ersek Oct. 4, 2018, 3:07 p.m. UTC | #1
On 10/03/18 20:30, Philippe Mathieu-Daudé wrote:
> This test boots EDK2 ArmVirtQemu and check the debug console (PL011) reports enough
> information on the initialized devices.
> 
> $ avocado run -p qemu_bin=aarch64-softmmu/qemu-system-aarch64 tests/acceptance/boot_firmware.py
> JOB ID     : cb1c5bd9e0312483eabeffbb37885a5273ef23bf
> JOB LOG    : /home/phil/avocado/job-results/job-2018-10-03T19.39-cb1c5bd/job.log
>  (1/1) tests/acceptance/boot_firmware.py:BootFirmware.test_ovmf_virt: PASS (5.02 s)
> RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
> JOB TIME   : 5.30 s
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> The '-p' option requires Avocado >= 65.0
> ---
>  tests/acceptance/boot_firmware.py | 36 +++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
> 
> diff --git a/tests/acceptance/boot_firmware.py b/tests/acceptance/boot_firmware.py
> index 2053b1a4b6..42f0672963 100644
> --- a/tests/acceptance/boot_firmware.py
> +++ b/tests/acceptance/boot_firmware.py
> @@ -121,3 +121,39 @@ class BootFirmware(Test):
>                  debugcon_logger.debug(line.strip())
>              for exp in expected:
>                  self.assertIn(exp + '\r\n', content)
> +
> +    def test_ovmf_virt(self):
> +        """
> +        Boots OVMF on the default virt machine, checks the debug console
> +
> +        :avocado: tags=arch:aarch64
> +        :avocado: tags=maxtime:20s
> +        """
> +        image_url = ('http://snapshots.linaro.org/components/kernel/'
> +                    'leg-virt-tianocore-edk2-upstream/latest/'
> +                    'QEMU-AARCH64/DEBUG_GCC5/QEMU_EFI.img.gz')
> +        image_path_gz = self.fetch_asset(image_url)
> +        image_path = os.path.join(self.workdir, 'flash.img')
> +
> +        # kludge until Avocado support gzip files
> +        import gzip, shutil
> +        with gzip.open(image_path_gz) as gz, open(image_path, 'wb') as img:
> +            shutil.copyfileobj(gz, img)
> +
> +        serial_path = os.path.join(self.workdir, 'serial.log')
> +        self.vm.set_machine('virt')
> +        self.vm.add_args('-nographic',
> +                         '-cpu', 'cortex-a57',
> +                         '-m', '1G', # 1GB min to boot fw?
> +                         '-drive', 'file=%s,format=raw,if=pflash' % image_path,
> +                         '-chardev', 'file,path=%s,id=console' % serial_path,
> +                         '-serial', 'chardev:console')
> +        self.vm.launch()
> +        serial_logger = logging.getLogger('serial')
> +
> +        # serial console checks
> +        if not wait_for(read_console_for_string, timeout=15, step=0,
> +                        args=(open(serial_path),
> +                              'Start PXE over IPv4',
> +                              serial_logger)):
> +            self.fail("OVMF failed to boot")
> 

I suggest replacing "OVMF" with "ArmVirtQemu" in comments and strings as
well.

I'd also suggest renaming the method test_ovmf_virt() to
test_armvirtqemu_virt().

If that seems baroque, then I suggest "test_uefi_<machtype>" in both
patches #2 and #3.

(Sorry about my obsession with these names; just trying to capture the
existing "vernacular".)

Thanks
Laszlo
Philippe Mathieu-Daudé Oct. 4, 2018, 3:15 p.m. UTC | #2
On 04/10/2018 17:07, Laszlo Ersek wrote:
> On 10/03/18 20:30, Philippe Mathieu-Daudé wrote:
>> This test boots EDK2 ArmVirtQemu and check the debug console (PL011) reports enough
>> information on the initialized devices.
>>
>> $ avocado run -p qemu_bin=aarch64-softmmu/qemu-system-aarch64 tests/acceptance/boot_firmware.py
>> JOB ID     : cb1c5bd9e0312483eabeffbb37885a5273ef23bf
>> JOB LOG    : /home/phil/avocado/job-results/job-2018-10-03T19.39-cb1c5bd/job.log
>>  (1/1) tests/acceptance/boot_firmware.py:BootFirmware.test_ovmf_virt: PASS (5.02 s)
>> RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
>> JOB TIME   : 5.30 s
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>> The '-p' option requires Avocado >= 65.0
>> ---
>>  tests/acceptance/boot_firmware.py | 36 +++++++++++++++++++++++++++++++
>>  1 file changed, 36 insertions(+)
>>
>> diff --git a/tests/acceptance/boot_firmware.py b/tests/acceptance/boot_firmware.py
>> index 2053b1a4b6..42f0672963 100644
>> --- a/tests/acceptance/boot_firmware.py
>> +++ b/tests/acceptance/boot_firmware.py
>> @@ -121,3 +121,39 @@ class BootFirmware(Test):
>>                  debugcon_logger.debug(line.strip())
>>              for exp in expected:
>>                  self.assertIn(exp + '\r\n', content)
>> +
>> +    def test_ovmf_virt(self):
>> +        """
>> +        Boots OVMF on the default virt machine, checks the debug console
>> +
>> +        :avocado: tags=arch:aarch64
>> +        :avocado: tags=maxtime:20s
>> +        """
>> +        image_url = ('http://snapshots.linaro.org/components/kernel/'
>> +                    'leg-virt-tianocore-edk2-upstream/latest/'
>> +                    'QEMU-AARCH64/DEBUG_GCC5/QEMU_EFI.img.gz')
>> +        image_path_gz = self.fetch_asset(image_url)
>> +        image_path = os.path.join(self.workdir, 'flash.img')
>> +
>> +        # kludge until Avocado support gzip files
>> +        import gzip, shutil
>> +        with gzip.open(image_path_gz) as gz, open(image_path, 'wb') as img:
>> +            shutil.copyfileobj(gz, img)
>> +
>> +        serial_path = os.path.join(self.workdir, 'serial.log')
>> +        self.vm.set_machine('virt')
>> +        self.vm.add_args('-nographic',
>> +                         '-cpu', 'cortex-a57',
>> +                         '-m', '1G', # 1GB min to boot fw?
>> +                         '-drive', 'file=%s,format=raw,if=pflash' % image_path,
>> +                         '-chardev', 'file,path=%s,id=console' % serial_path,
>> +                         '-serial', 'chardev:console')
>> +        self.vm.launch()
>> +        serial_logger = logging.getLogger('serial')
>> +
>> +        # serial console checks
>> +        if not wait_for(read_console_for_string, timeout=15, step=0,
>> +                        args=(open(serial_path),
>> +                              'Start PXE over IPv4',
>> +                              serial_logger)):
>> +            self.fail("OVMF failed to boot")
>>
> 
> I suggest replacing "OVMF" with "ArmVirtQemu" in comments and strings as
> well.

Oops OK.

> 
> I'd also suggest renaming the method test_ovmf_virt() to
> test_armvirtqemu_virt().
> 
> If that seems baroque, then I suggest "test_uefi_<machtype>" in both
> patches #2 and #3.

What about this?

- test_bios_seabios_x86_64_pc()
- test_uefi_ovmf_x86_64_pc()
- test_uefi_armvirtqemu_aarch64_virt()

> 
> (Sorry about my obsession with these names; just trying to capture the
> existing "vernacular".)
> 
> Thanks
> Laszlo
>
Laszlo Ersek Oct. 4, 2018, 4:19 p.m. UTC | #3
On 10/04/18 17:15, Philippe Mathieu-Daudé wrote:
> On 04/10/2018 17:07, Laszlo Ersek wrote:
>> On 10/03/18 20:30, Philippe Mathieu-Daudé wrote:
>>> This test boots EDK2 ArmVirtQemu and check the debug console (PL011) reports enough
>>> information on the initialized devices.
>>>
>>> $ avocado run -p qemu_bin=aarch64-softmmu/qemu-system-aarch64 tests/acceptance/boot_firmware.py
>>> JOB ID     : cb1c5bd9e0312483eabeffbb37885a5273ef23bf
>>> JOB LOG    : /home/phil/avocado/job-results/job-2018-10-03T19.39-cb1c5bd/job.log
>>>  (1/1) tests/acceptance/boot_firmware.py:BootFirmware.test_ovmf_virt: PASS (5.02 s)
>>> RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
>>> JOB TIME   : 5.30 s
>>>
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>> ---
>>> The '-p' option requires Avocado >= 65.0
>>> ---
>>>  tests/acceptance/boot_firmware.py | 36 +++++++++++++++++++++++++++++++
>>>  1 file changed, 36 insertions(+)
>>>
>>> diff --git a/tests/acceptance/boot_firmware.py b/tests/acceptance/boot_firmware.py
>>> index 2053b1a4b6..42f0672963 100644
>>> --- a/tests/acceptance/boot_firmware.py
>>> +++ b/tests/acceptance/boot_firmware.py
>>> @@ -121,3 +121,39 @@ class BootFirmware(Test):
>>>                  debugcon_logger.debug(line.strip())
>>>              for exp in expected:
>>>                  self.assertIn(exp + '\r\n', content)
>>> +
>>> +    def test_ovmf_virt(self):
>>> +        """
>>> +        Boots OVMF on the default virt machine, checks the debug console
>>> +
>>> +        :avocado: tags=arch:aarch64
>>> +        :avocado: tags=maxtime:20s
>>> +        """
>>> +        image_url = ('http://snapshots.linaro.org/components/kernel/'
>>> +                    'leg-virt-tianocore-edk2-upstream/latest/'
>>> +                    'QEMU-AARCH64/DEBUG_GCC5/QEMU_EFI.img.gz')
>>> +        image_path_gz = self.fetch_asset(image_url)
>>> +        image_path = os.path.join(self.workdir, 'flash.img')
>>> +
>>> +        # kludge until Avocado support gzip files
>>> +        import gzip, shutil
>>> +        with gzip.open(image_path_gz) as gz, open(image_path, 'wb') as img:
>>> +            shutil.copyfileobj(gz, img)
>>> +
>>> +        serial_path = os.path.join(self.workdir, 'serial.log')
>>> +        self.vm.set_machine('virt')
>>> +        self.vm.add_args('-nographic',
>>> +                         '-cpu', 'cortex-a57',
>>> +                         '-m', '1G', # 1GB min to boot fw?
>>> +                         '-drive', 'file=%s,format=raw,if=pflash' % image_path,
>>> +                         '-chardev', 'file,path=%s,id=console' % serial_path,
>>> +                         '-serial', 'chardev:console')
>>> +        self.vm.launch()
>>> +        serial_logger = logging.getLogger('serial')
>>> +
>>> +        # serial console checks
>>> +        if not wait_for(read_console_for_string, timeout=15, step=0,
>>> +                        args=(open(serial_path),
>>> +                              'Start PXE over IPv4',
>>> +                              serial_logger)):
>>> +            self.fail("OVMF failed to boot")
>>>
>>
>> I suggest replacing "OVMF" with "ArmVirtQemu" in comments and strings as
>> well.
> 
> Oops OK.
> 
>>
>> I'd also suggest renaming the method test_ovmf_virt() to
>> test_armvirtqemu_virt().
>>
>> If that seems baroque, then I suggest "test_uefi_<machtype>" in both
>> patches #2 and #3.
> 
> What about this?
> 
> - test_bios_seabios_x86_64_pc()
> - test_uefi_ovmf_x86_64_pc()
> - test_uefi_armvirtqemu_aarch64_virt()

Those work for me :)

Laszlo
diff mbox series

Patch

diff --git a/tests/acceptance/boot_firmware.py b/tests/acceptance/boot_firmware.py
index 2053b1a4b6..42f0672963 100644
--- a/tests/acceptance/boot_firmware.py
+++ b/tests/acceptance/boot_firmware.py
@@ -121,3 +121,39 @@  class BootFirmware(Test):
                 debugcon_logger.debug(line.strip())
             for exp in expected:
                 self.assertIn(exp + '\r\n', content)
+
+    def test_ovmf_virt(self):
+        """
+        Boots OVMF on the default virt machine, checks the debug console
+
+        :avocado: tags=arch:aarch64
+        :avocado: tags=maxtime:20s
+        """
+        image_url = ('http://snapshots.linaro.org/components/kernel/'
+                    'leg-virt-tianocore-edk2-upstream/latest/'
+                    'QEMU-AARCH64/DEBUG_GCC5/QEMU_EFI.img.gz')
+        image_path_gz = self.fetch_asset(image_url)
+        image_path = os.path.join(self.workdir, 'flash.img')
+
+        # kludge until Avocado support gzip files
+        import gzip, shutil
+        with gzip.open(image_path_gz) as gz, open(image_path, 'wb') as img:
+            shutil.copyfileobj(gz, img)
+
+        serial_path = os.path.join(self.workdir, 'serial.log')
+        self.vm.set_machine('virt')
+        self.vm.add_args('-nographic',
+                         '-cpu', 'cortex-a57',
+                         '-m', '1G', # 1GB min to boot fw?
+                         '-drive', 'file=%s,format=raw,if=pflash' % image_path,
+                         '-chardev', 'file,path=%s,id=console' % serial_path,
+                         '-serial', 'chardev:console')
+        self.vm.launch()
+        serial_logger = logging.getLogger('serial')
+
+        # serial console checks
+        if not wait_for(read_console_for_string, timeout=15, step=0,
+                        args=(open(serial_path),
+                              'Start PXE over IPv4',
+                              serial_logger)):
+            self.fail("OVMF failed to boot")