From dc688aa70e43fa592814a065ccfa5a2537ecb17f Mon Sep 17 00:00:00 2001 From: Stuart Pernsteiner Date: Fri, 31 May 2024 10:31:35 -0700 Subject: [PATCH] vm_runner: add configs for running the MPS test suite --- .../tests/mps_tests/base_nested.toml | 21 +++++++++++++++++++ .../tests/mps_tests/base_single.toml | 17 +++++++++++++++ src/vm_runner/tests/mps_tests/build_img.sh | 18 ++++++++++++++++ src/vm_runner/tests/mps_tests/guest.toml | 6 ++++++ src/vm_runner/tests/mps_tests/host.toml | 17 +++++++++++++++ src/vm_runner/tests/mps_tests/mps_tests.sh | 8 +++++++ 6 files changed, 87 insertions(+) create mode 100644 src/vm_runner/tests/mps_tests/base_nested.toml create mode 100644 src/vm_runner/tests/mps_tests/base_single.toml create mode 100644 src/vm_runner/tests/mps_tests/build_img.sh create mode 100644 src/vm_runner/tests/mps_tests/guest.toml create mode 100644 src/vm_runner/tests/mps_tests/host.toml create mode 100755 src/vm_runner/tests/mps_tests/mps_tests.sh diff --git a/src/vm_runner/tests/mps_tests/base_nested.toml b/src/vm_runner/tests/mps_tests/base_nested.toml new file mode 100644 index 00000000..3580d1be --- /dev/null +++ b/src/vm_runner/tests/mps_tests/base_nested.toml @@ -0,0 +1,21 @@ +mode = "exec" + +[[process]] +type = "vm" +kvm = false +kernel = "../../../pkvm_setup/vms/debian-boot/vmlinuz" +initrd = "../../../pkvm_setup/vms/debian-boot/initrd.img" +append = 'earlycon root=/dev/vda2 systemd.run=/opt/opensut/bin/opensut_boot opensut.app_device=/dev/vdc' + +[process.disk.vda] +format = "qcow2" +path = "../../../pkvm_setup/vms/disk_host.img" + +[process.disk.vdb] +format = "qcow2" +path = "../../../pkvm_setup/vms/disk_guest.img" + +[process.disk.vdc] +format = "raw" +path = "host.img" +read_only = true diff --git a/src/vm_runner/tests/mps_tests/base_single.toml b/src/vm_runner/tests/mps_tests/base_single.toml new file mode 100644 index 00000000..47e68965 --- /dev/null +++ b/src/vm_runner/tests/mps_tests/base_single.toml @@ -0,0 +1,17 @@ +mode = "exec" + +[[process]] +type = "vm" +kvm = false +kernel = "../../../pkvm_setup/vms/debian-boot/vmlinuz" +initrd = "../../../pkvm_setup/vms/debian-boot/initrd.img" +append = 'earlycon root=/dev/vda2 systemd.run=/opt/opensut/bin/opensut_boot opensut.app_device=/dev/vdb' + +[process.disk.vda] +format = "qcow2" +path = "../../../pkvm_setup/vms/disk_host.img" + +[process.disk.vdb] +format = "raw" +path = "guest.img" +read_only = true diff --git a/src/vm_runner/tests/mps_tests/build_img.sh b/src/vm_runner/tests/mps_tests/build_img.sh new file mode 100644 index 00000000..859a3c97 --- /dev/null +++ b/src/vm_runner/tests/mps_tests/build_img.sh @@ -0,0 +1,18 @@ +#!/bin/bash +set -euo pipefail + +mps_dir="$(dirname "$0")" + +python3 "$mps_dir/../../build_application_image.py" \ + -f "$mps_dir/guest.toml=runner.toml" \ + -f "$mps_dir/../../../../components/mission_protection_system/src/rts.self_test.aarch64=src/rts.self_test" \ + -f "$mps_dir/../../../../components/mission_protection_system/src/rts.no_self_test.aarch64=src/rts.no_self_test" \ + -d "$mps_dir/../../../../components/mission_protection_system/tests" \ + -f "$mps_dir/mps_tests.sh" \ + -o "$mps_dir/guest.img" + +python3 "$mps_dir/../../build_application_image.py" \ + -f "$mps_dir/host.toml=runner.toml" \ + -f "$mps_dir/guest.img" \ + -o "$mps_dir/host.img" + diff --git a/src/vm_runner/tests/mps_tests/guest.toml b/src/vm_runner/tests/mps_tests/guest.toml new file mode 100644 index 00000000..ecc2a851 --- /dev/null +++ b/src/vm_runner/tests/mps_tests/guest.toml @@ -0,0 +1,6 @@ +mode = "exec" + +[[process]] +type = "shell" +command = "./mps_tests.sh" + diff --git a/src/vm_runner/tests/mps_tests/host.toml b/src/vm_runner/tests/mps_tests/host.toml new file mode 100644 index 00000000..1f443f7e --- /dev/null +++ b/src/vm_runner/tests/mps_tests/host.toml @@ -0,0 +1,17 @@ +mode = "exec" + +[[process]] +type = "vm" +kvm = true +kernel = "/boot/vmlinuz" +initrd = "/boot/initrd.img" +append = 'earlycon root=/dev/vda2 systemd.run=/opt/opensut/bin/opensut_boot opensut.app_device=/dev/vdb' + +[process.disk.vda] +format = "raw" +path = "/dev/vdb" + +[process.disk.vdb] +format = "raw" +path = "/opt/opensut/app/guest.img" +read_only = true diff --git a/src/vm_runner/tests/mps_tests/mps_tests.sh b/src/vm_runner/tests/mps_tests/mps_tests.sh new file mode 100755 index 00000000..bb40cfc0 --- /dev/null +++ b/src/vm_runner/tests/mps_tests/mps_tests.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -euo pipefail + +apt install -y python3-pexpect + +echo "Starting test suite" +cd tests +RTS_DEBUG=1 python3 run_all.py