fix(hftest): fix parsing the test json in hftests

Printing to the UART prior to hftests parsing the JSON structure
of the available tests caused the parsing to fail and the tests
to stop. Wrap the JSON structure in hftest_ctrl tags which the
hftest script can use to identify which lines of the uart contain
the JSON structure.

This is important as future patches will introduce the ability to
run functions during an SPs initialsation stage and any prints in
this code would cause the HFTEST to crash without the hftest_ctrl flags.

Signed-off-by: Daniel Boulby <daniel.boulby@arm.com>
Change-Id: Ib63a06f876e80cd4e4e360282bffda2c68474346
diff --git a/test/hftest/hftest.py b/test/hftest/hftest.py
index 4a44e2f..cf24a94 100755
--- a/test/hftest/hftest.py
+++ b/test/hftest/hftest.py
@@ -35,6 +35,9 @@
 HFTEST_LOG_FAILURE_PREFIX = "Failure:"
 HFTEST_LOG_FINISHED = "FINISHED"
 
+HFTEST_CTRL_JSON_START = "[hftest_ctrl:json_start]"
+HFTEST_CTRL_JSON_END = "[hftest_ctrl:json_end]"
+
 HFTEST_CTRL_GET_COMMAND_LINE = "[hftest_ctrl:get_command_line]"
 HFTEST_CTRL_FINISHED = "[hftest_ctrl:finished]"
 
@@ -792,7 +795,10 @@
         """Invoke the test platform and request a JSON of available test and
         test suites."""
         out = self.driver.run("json", "json", self.force_long_running)
-        hf_out = "\n".join(self.extract_hftest_lines(out))
+        hf_out = self.extract_hftest_lines(out)
+        hf_out = hf_out[hf_out.index(HFTEST_CTRL_JSON_START) + 1
+                        :hf_out.index(HFTEST_CTRL_JSON_END)];
+        hf_out = "\n".join(hf_out)
         try:
             return json.loads(hf_out)
         except ValueError as e: