feat(fwu): firmware corrupt GPT MBR test

Adding a test case for corrupted GPT mbr.
The FWU should be panic and the update process
cannot be done

Signed-off-by: Xialin Liu <xialin.liu@arm.com>
Change-Id: I3597f5e668e4c9797b5e428f469394c2935dc0cf
diff --git a/expect-lava/crash_gpt.exp b/expect-lava/crash_gpt.exp
new file mode 100644
index 0000000..323e51f
--- /dev/null
+++ b/expect-lava/crash_gpt.exp
@@ -0,0 +1,9 @@
+#
+# Copyright (c) 2025 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware Test Framework
+#
+
+expect_string+=('i;GPT partition initialisation failed')
diff --git a/expect/crash_gpt.exp b/expect/crash_gpt.exp
new file mode 100644
index 0000000..f861cf3
--- /dev/null
+++ b/expect/crash_gpt.exp
@@ -0,0 +1,12 @@
+#
+# Copyright (c) 2025, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware Test Framework
+#
+
+source [file join [file dirname [info script]] handle-arguments.inc]
+
+expect_string "GPT partition initialisation failed"
+exit_uart 0
\ No newline at end of file
diff --git a/fvp_utils.sh b/fvp_utils.sh
index 71e71eb..fe76023 100644
--- a/fvp_utils.sh
+++ b/fvp_utils.sh
@@ -596,8 +596,12 @@
             seek=$(gdisk -l $bin | grep " FWU-Metadata$" | awk '{print $2}')
             count=1
             ;;
+        "mbr")
+            seek=0
+            count=1
+            ;;
         *)
-            echo "Invalid $corrupt_data. Use 'header', 'partition-entries'"
+            echo "Invalid $corrupt_data. Use 'header', 'partition-entries', 'fwu-metadata' or 'mbr'."
             return 1
             ;;
     esac
diff --git a/group/tftf-l2-fvp/fvp-gpt,fvp-default:fvp-tftf.fwu_corrupted_mbr_gpt-aemv8a.gpt-debug b/group/tftf-l2-fvp/fvp-gpt,fvp-default:fvp-tftf.fwu_corrupted_mbr_gpt-aemv8a.gpt-debug
new file mode 100644
index 0000000..8e0db6b
--- /dev/null
+++ b/group/tftf-l2-fvp/fvp-gpt,fvp-default:fvp-tftf.fwu_corrupted_mbr_gpt-aemv8a.gpt-debug
@@ -0,0 +1,5 @@
+#
+# Copyright (c) 2025, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
diff --git a/run_config/fvp-tftf.fwu_corrupted_mbr_gpt b/run_config/fvp-tftf.fwu_corrupted_mbr_gpt
new file mode 100644
index 0000000..2a7360e
--- /dev/null
+++ b/run_config/fvp-tftf.fwu_corrupted_mbr_gpt
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2025, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+post_tf_build() {
+	build_fip BL33="$archive/tftf.bin"
+}
+
+post_tf_archive() {
+        # Maximum FIP size is 2MiB = 2097152
+	gen_gpt_bin "$archive/fip.bin" 2097152
+
+	# Corrupt the mbr to fail the update
+	corrupt_gpt_bin "$archive/fip_gpt.bin" "mbr"
+}
+
+generate_lava_job_template() {
+	uart="0" file="crash_gpt.exp" track_expect
+	uart="1" file="crash_panic.exp" track_expect
+
+	payload_type="tftf" gen_yaml_template
+}