From: Kane-Chen-AS <kane_chen@aspeedtech.com>
Introduce a functional test suite to validate the ASPEED OTP memory
device integration under different machine configurations.
The following cases are covered:
- AST2600 with blockdev + device + machine parameter (full binding)
- AST2600 fallback with no machine parameter
- AST2600 with only blockdev + device (no machine param)
- AST2600 with only machine parameter (no backend/device)
- AST1030 fallback test with Zephyr-based image
The tests ensure that the OTP model behaves correctly across boot-time
binding variations and fallback paths, and that firmware boot is
successful under each condition.
Signed-off-by: Kane-Chen-AS <kane_chen@aspeedtech.com>
---
tests/functional/meson.build | 1 +
tests/functional/test_aspeed_otpmem.py | 82 ++++++++++++++++++++++++++
2 files changed, 83 insertions(+)
create mode 100644 tests/functional/test_aspeed_otpmem.py
diff --git a/tests/functional/meson.build b/tests/functional/meson.build
index e9f19d54a2..ce999eeab1 100644
--- a/tests/functional/meson.build
+++ b/tests/functional/meson.build
@@ -41,6 +41,7 @@ test_timeouts = {
'arm_replay' : 240,
'arm_tuxrun' : 240,
'arm_sx1' : 360,
+ 'aspeed_otpmem': 1200,
'intel_iommu': 300,
'mips_malta' : 480,
'mipsel_malta' : 420,
diff --git a/tests/functional/test_aspeed_otpmem.py b/tests/functional/test_aspeed_otpmem.py
new file mode 100644
index 0000000000..67d2a7ecf6
--- /dev/null
+++ b/tests/functional/test_aspeed_otpmem.py
@@ -0,0 +1,82 @@
+
+import os
+import time
+import tempfile
+import subprocess
+
+from qemu_test import LinuxKernelTest, Asset
+from aspeed import AspeedTest
+from qemu_test import exec_command_and_wait_for_pattern, skipIfMissingCommands
+
+class AspeedOtpMemoryTest(AspeedTest):
+ # AST2600 SDK image
+ ASSET_SDK_V906_AST2600 = Asset(
+ 'https://github.com/AspeedTech-BMC/openbmc/releases/download/v09.06/ast2600-default-obmc.tar.gz',
+ '768d76e247896ad78c154b9cff4f766da2ce65f217d620b286a4a03a8a4f68f5')
+
+ # AST1030 Zephyr image
+ ASSET_ZEPHYR_3_00 = Asset(
+ ('https://github.com/AspeedTech-BMC'
+ '/zephyr/releases/download/v00.03.00/ast1030-evb-demo.zip'),
+ '37fe3ecd4a1b9d620971a15b96492a81093435396eeac69b6f3e384262ff555f')
+ def generate_otpmem_image(self):
+ path = self.scratch_file("otpmem.img")
+ pattern = b'\x00\x00\x00\x00\xff\xff\xff\xff' * (16 * 1024 // 8)
+ with open(path, "wb") as f:
+ f.write(pattern)
+ return path
+
+ def test_ast2600_otp_fallback(self):
+ image_path = self.archive_extract(self.ASSET_SDK_V906_AST2600)
+ bmc_image = self.scratch_file("ast2600-default", "image-bmc")
+ self.vm.set_machine("ast2600-evb")
+ self.vm.set_console()
+ self.do_test_arm_aspeed_sdk_start(
+ self.scratch_file("ast2600-default", "image-bmc"))
+ self.wait_for_console_pattern('ast2600-default login:')
+
+ def test_ast2600_otp_blockdev_device(self):
+ image_path = self.archive_extract(self.ASSET_SDK_V906_AST2600)
+ otp_img = self.generate_otpmem_image()
+ self.vm.set_console()
+ self.vm.add_args(
+ "-blockdev", f"node-name=otpmem,driver=file,filename={otp_img}",
+ "-device", "aspeed.otpmem,drive=otpmem,id=otpmem-drive",
+ "-machine", "ast2600-evb,otpmem=otpmem-drive"
+ )
+ self.do_test_arm_aspeed_sdk_start(self.scratch_file("ast2600-default", "image-bmc"))
+ self.wait_for_console_pattern("ast2600-default login:")
+
+ def test_ast2600_otp_only_blockdev(self):
+ image_path = self.archive_extract(self.ASSET_SDK_V906_AST2600)
+ otp_img = self.generate_otpmem_image()
+ self.vm.set_machine("ast2600-evb")
+ self.vm.set_console()
+ self.vm.add_args(
+ "-blockdev", f"node-name=otpmem,driver=file,filename={otp_img}",
+ "-device", "aspeed.otpmem,drive=otpmem,id=otpmem-drive",
+ )
+ self.do_test_arm_aspeed_sdk_start(self.scratch_file("ast2600-default", "image-bmc"))
+ self.wait_for_console_pattern("ast2600-default login:")
+
+ def test_ast2600_otp_only_machine_param(self):
+ image_path = self.archive_extract(self.ASSET_SDK_V906_AST2600)
+ self.vm.set_console()
+ self.vm.add_args(
+ "-machine", "ast2600-evb,otpmem=otpmem-drive"
+ )
+ self.do_test_arm_aspeed_sdk_start(self.scratch_file("ast2600-default", "image-bmc"))
+ self.wait_for_console_pattern("ast2600-default login:")
+
+ def test_ast1030_otp_fallback(self):
+ kernel_name = "ast1030-evb-demo/zephyr.elf"
+ kernel_file = self.archive_extract(self.ASSET_ZEPHYR_3_00, member=kernel_name)
+
+ self.vm.set_machine("ast1030-evb")
+ self.vm.set_console()
+ self.vm.add_args("-kernel", kernel_file)
+ self.vm.launch()
+ self.wait_for_console_pattern("Booting Zephyr OS")
+
+if __name__ == '__main__':
+ AspeedTest.main()
\ No newline at end of file
--
2.43.0