Tests: factored out code to execute test commands
Factored out code to execute test commands from standalone_main.c, in
order to reuse function in a standalone secure partition.
Change-Id: I671aa64e48f209eb718e6e12c78b4fa4995c2b4a
Signed-off-by: J-Alves <joao.alves@arm.com>
diff --git a/test/hftest/common.c b/test/hftest/common.c
index 15700e4..344ff24 100644
--- a/test/hftest/common.c
+++ b/test/hftest/common.c
@@ -227,6 +227,51 @@
HFTEST_LOG(" Run the named test from the named test suite.");
}
+void hftest_command(struct fdt *fdt)
+{
+ struct memiter command_line;
+ struct memiter command;
+
+ if (!hftest_ctrl_start(fdt, &command_line)) {
+ HFTEST_LOG("Unable to read the command line.");
+ return;
+ }
+
+ if (!memiter_parse_str(&command_line, &command)) {
+ HFTEST_LOG("Unable to parse command.");
+ return;
+ }
+
+ if (memiter_iseq(&command, "exit")) {
+ hftest_device_exit_test_environment();
+ return;
+ }
+
+ if (memiter_iseq(&command, "json")) {
+ hftest_json();
+ return;
+ }
+
+ if (memiter_iseq(&command, "run")) {
+ struct memiter suite_name;
+ struct memiter test_name;
+
+ if (!memiter_parse_str(&command_line, &suite_name)) {
+ HFTEST_LOG("Unable to parse test suite.");
+ return;
+ }
+
+ if (!memiter_parse_str(&command_line, &test_name)) {
+ HFTEST_LOG("Unable to parse test.");
+ return;
+ }
+ hftest_run(suite_name, test_name, fdt);
+ return;
+ }
+
+ hftest_help();
+}
+
static uintptr_t vcpu_index_to_id(size_t index)
{
/* For now we use indices as IDs for vCPUs. */