@@ -11,13 +11,16 @@
import time
import os
import logging
+import shutil
from avocado_qemu import QemuSystemTest
from avocado_qemu import wait_for_console_pattern
from avocado_qemu import exec_command
from avocado_qemu import BUILD_DIR
+from avocado_qemu import is_readable_executable_file
from avocado.utils import process
from avocado.utils.path import find_command
+from avocado.utils import archive
class Aarch64VirtMachine(QemuSystemTest):
KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
@@ -144,3 +147,63 @@ def test_aarch64_virt_gicv2(self):
:avocado: tags=cpu:max
"""
self.common_aarch64_virt("virt,gic-version=2")
+
+ def copy_sel2_prebuilt_images(self):
+ """extract the prebuilt S-EL2 binaries to the test directory. """
+
+ relative_path = "./tests/data/sel2-boot-images/prebuilt-sel2-images.zip"
+ prebuilt_bin_path = os.path.join(BUILD_DIR, relative_path)
+ target_dir = os.path.join(BUILD_DIR)
+
+ self.assertTrue(os.path.exists(prebuilt_bin_path))
+ self.assertTrue(os.path.exists(target_dir))
+ archive.extract(prebuilt_bin_path, target_dir)
+
+ timeout = 1000
+ def test_aarch64_sel2_boot(self):
+ """
+ :avocado: tags=arch:aarch64
+ :avocado: tags=machine:secure
+ :avocado: tags=machine:virt
+ :avocado: tags=cpu:max
+ """
+
+ self.copy_sel2_prebuilt_images()
+ self.vm.set_console()
+ kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
+ 'console=ttyAMA0,38400 keep_bootcon root=/dev/vda2 nokaslr')
+
+ self.vm.add_args("-cpu", "max,sme=off,pauth-impdef=on")
+ self.vm.add_args("-machine",
+ "virt,secure=on,"
+ "virtualization=on,"
+ "mte=on,"
+ "gic-version=3")
+ self.vm.add_args("-d", "unimp")
+ self.vm.add_args("-semihosting-config", "enable=on,target=native")
+ self.vm.add_args("-smp", "2", "-m", "1024")
+ self.vm.add_args('-bios', 'bl1.bin')
+ self.vm.add_args('-initrd', 'rootfs.cpio.gz')
+ self.vm.add_args('-kernel', 'Image')
+ self.vm.add_args('-machine', 'acpi=off')
+ self.vm.add_args('-append', kernel_command_line)
+ self.vm.add_args('-object', 'rng-random,filename=/dev/urandom,id=rng0')
+ self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0,max-bytes=1024,period=1000')
+ self.vm.launch()
+ self.wait_for_console_pattern('Welcome to Buildroot')
+ time.sleep(0.1)
+ exec_command(self, 'root')
+ time.sleep(0.1)
+
+ def test_aarch64_sel2_xtest(self):
+ """
+ :avocado: tags=arch:aarch64
+ :avocado: tags=machine:secure
+ :avocado: tags=machine:virt
+ :avocado: tags=cpu:max
+ """
+ self.test_aarch64_sel2_boot()
+ exec_command(self, 'xtest')
+ time.sleep(0.1)
+ self.wait_for_console_pattern('subtests of which 0 failed')
+ time.sleep(0.1)
new file mode 100644