summaryrefslogtreecommitdiff
path: root/tests/fwu_tests
diff options
context:
space:
mode:
authorYatharth Kochar <yatharth.kochar@arm.com>2015-08-17 18:01:29 +0100
committerYatharth Kochar <yatharth.kochar@arm.com>2015-12-09 14:53:01 +0000
commita26ca3f22abacf41d05c0a28b8d91fde818e3f42 (patch)
tree714d23b5fad131ad5f4abcb3339c27e5c66ac616 /tests/fwu_tests
parentd300bffb2b7d08b1718042a74cc5671254471acf (diff)
FWU: Add FWU TOC test case support in TFTF.
The Firmware Update feature implemented in Trusted Firmware code needs to be tested to check if FWU process gets started or not when the TOC header value in fip.bin is invalid. This patch adds this new test case to TFTF test framework. Following steps are carried out by the test case: * Invalidates the TOC header in fip.bin. * Calls PSCI SMC to reboot the system. * After reboot it checks TOC header validity. Change-Id: Ida96d8d7bf94485f63104009c28308cc1083c6a3
Diffstat (limited to 'tests/fwu_tests')
-rw-r--r--tests/fwu_tests/fwu_tests.xml21
-rw-r--r--tests/fwu_tests/test_fwu_toc.c95
2 files changed, 116 insertions, 0 deletions
diff --git a/tests/fwu_tests/fwu_tests.xml b/tests/fwu_tests/fwu_tests.xml
new file mode 100644
index 0000000..6753014
--- /dev/null
+++ b/tests/fwu_tests/fwu_tests.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ Copyright (c) 2015, ARM Limited. All rights reserved.
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+-->
+
+<testsuites>
+
+ <testsuite name="fwu toc test" description="Validate FWU TOC invalid scenario">
+ <testcase name="FWU TOC Invalid" function="test_fwu_toc" />
+ </testsuite>
+
+</testsuites>
diff --git a/tests/fwu_tests/test_fwu_toc.c b/tests/fwu_tests/test_fwu_toc.c
new file mode 100644
index 0000000..fee7582
--- /dev/null
+++ b/tests/fwu_tests/test_fwu_toc.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * Neither the name of ARM nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <firmware_image_package.h>
+#include <fwu_nvm.h>
+#include <io_storage.h>
+#include <platform.h>
+#include <psci.h>
+#include <smc.h>
+#include <status.h>
+#include <tftf_lib.h>
+
+/*
+ * @Test_Aim@ Validate the FWU ToC invalid case.
+ * The Firmware Update feature implemented in Trusted Firmware
+ * code needs to be tested to check if FWU process gets started
+ * or not when the ToC header value in fip.bin is invalid.
+ * Test SUCCESS in case ToC is found valid.
+ * Test FAIL in case ToC is found invalid.
+ */
+test_result_t test_fwu_toc(void)
+{
+ STATUS status;
+ unsigned int toc_header;
+ smc64_args args = { SMC_PSCI_SYSTEM_RESET };
+ smc64_ret_values ret = {0};
+
+ if (tftf_is_rebooted()) {
+ /*
+ * Check whether we successfully resumed from the
+ * Firmware Update process. If we have, then the
+ * ToC header value will have been repaired.
+ */
+ status = fwu_nvm_read(0, &toc_header, 4);
+ if (status != STATUS_SUCCESS) {
+ tftf_testcase_printf("Failed to read NVM (%d)\n", status);
+ return TEST_RESULT_FAIL;
+ }
+
+ if (toc_header != TOC_HEADER_NAME) {
+ tftf_testcase_printf("ToC is Invalid (%u)\n", toc_header);
+ return TEST_RESULT_FAIL;
+ }
+
+ return TEST_RESULT_SUCCESS;
+ }
+
+ /* Corrupt the TOC in fip.bin. */
+ toc_header = 0xdeadbeef;
+ status = fwu_nvm_write(0, &toc_header, 4);
+ if (status != STATUS_SUCCESS) {
+ tftf_testcase_printf("Failed to overwrite the ToC header (%d)\n",
+ status);
+ return TEST_RESULT_SKIPPED;
+ }
+
+ /* Notify that we are rebooting now. */
+ tftf_notify_reboot();
+
+ /* Request PSCI system reset. */
+ ret = tftf_smc64(&args);
+
+ /* The PSCI SYSTEM_RESET call is not supposed to return */
+ tftf_testcase_printf("System didn't reboot properly (%d)\n",
+ (unsigned int)ret.ret0);
+
+ return TEST_RESULT_FAIL;
+}