blob: 54c51fe80083bc181dd36c3209c41c9a8eaa247a [file] [log] [blame]
David Brazdilee5e25d2020-01-24 14:17:45 +00001#!/usr/bin/env python3
Andrew Scull18834872018-10-12 11:48:09 +01002#
Andrew Walbran692b3252019-03-07 15:51:31 +00003# Copyright 2018 The Hafnium Authors.
Andrew Scull18834872018-10-12 11:48:09 +01004#
Andrew Walbrane959ec12020-06-17 15:01:09 +01005# Use of this source code is governed by a BSD-style
6# license that can be found in the LICENSE file or at
7# https://opensource.org/licenses/BSD-3-Clause.
Andrew Scull18834872018-10-12 11:48:09 +01008
David Brazdil2df24082019-09-05 11:55:08 +01009"""Script which drives invocation of tests and parsing their output to produce
10a results report.
Andrew Scullbc7189d2018-08-14 09:35:13 +010011"""
12
13from __future__ import print_function
14
Andrew Scull3b62f2b2018-08-21 14:26:12 +010015import xml.etree.ElementTree as ET
16
Andrew Scullbc7189d2018-08-14 09:35:13 +010017import argparse
Olivier Depreza6d2e6d2020-11-06 18:09:50 +010018from abc import ABC, abstractmethod
David Brazdil2df24082019-09-05 11:55:08 +010019import collections
Andrew Scull04502e42018-09-03 14:54:52 +010020import datetime
David Brazdil4f9cf9a2020-02-06 17:34:44 +000021import importlib
Andrew Scullbc7189d2018-08-14 09:35:13 +010022import json
23import os
24import re
25import subprocess
26import sys
Andrew Walbran42bf2842020-06-05 18:50:19 +010027import time
Olivier Depreza6d2e6d2020-11-06 18:09:50 +010028import fdt
Olivier Depreze30c36f2022-11-22 11:26:47 +010029import platform
J-Alvesacdbb862023-01-31 17:14:55 +000030import tempfile
Andrew Scullbc7189d2018-08-14 09:35:13 +010031
Olivier Depreze30c36f2022-11-22 11:26:47 +010032MACHINE = platform.machine()
Olivier Depreze30c36f2022-11-22 11:26:47 +010033
Andrew Scull845fc9b2019-04-03 12:44:26 +010034HFTEST_LOG_PREFIX = "[hftest] "
35HFTEST_LOG_FAILURE_PREFIX = "Failure:"
36HFTEST_LOG_FINISHED = "FINISHED"
37
Daniel Boulby61049dc2023-06-16 14:15:21 +010038HFTEST_CTRL_JSON_START = "[hftest_ctrl:json_start]"
39HFTEST_CTRL_JSON_END = "[hftest_ctrl:json_end]"
40
David Brazdil17e76652020-01-29 14:44:19 +000041HFTEST_CTRL_GET_COMMAND_LINE = "[hftest_ctrl:get_command_line]"
42HFTEST_CTRL_FINISHED = "[hftest_ctrl:finished]"
43
Olivier Deprezbd432092024-07-26 14:01:12 +020044HFTEST_CTRL_JSON_REGEX = re.compile("^\\[[0-9a-fA-F]+ [0-9a-fA-F]+\\] ")
Karl Meakin6f1f1212024-07-16 10:18:16 +010045
David Brazdil2df24082019-09-05 11:55:08 +010046HF_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(
47 os.path.abspath(__file__))))
David Brazdil5715f042019-08-27 11:11:51 +010048DTC_SCRIPT = os.path.join(HF_ROOT, "build", "image", "dtc.py")
David Brazdil2df24082019-09-05 11:55:08 +010049FVP_BINARY = os.path.join(
Olivier Deprez9f4bad42021-06-18 12:19:07 +020050 os.path.dirname(HF_ROOT), "fvp", "Base_RevC_AEMvA_pkg", "models",
Olivier Deprez78d94eb2023-01-31 09:02:32 +000051 "Linux64_armv8l_GCC-9.3" if MACHINE == "aarch64" else "Linux64_GCC-9.3",
52 "FVP_Base_RevC-2xAEMvA")
Olivier Depreza6d2e6d2020-11-06 18:09:50 +010053HF_PREBUILTS = os.path.join(HF_ROOT, "prebuilts")
Olivier Deprez78d94eb2023-01-31 09:02:32 +000054QEMU_PREBUILTS = os.path.join(HF_PREBUILTS,
55 "linux-" + ("x64" if MACHINE == "x86_64" else MACHINE),
56 "qemu", "qemu-system-aarch64")
Olivier Deprez0c5e7dc2023-01-17 10:29:04 +010057FVP_PREBUILTS_TFA_ROOT = os.path.join(
58 HF_PREBUILTS, "linux-aarch64", "trusted-firmware-a", "fvp")
David Brazdil2df24082019-09-05 11:55:08 +010059FVP_PREBUILT_DTS = os.path.join(
Olivier Deprez0c5e7dc2023-01-17 10:29:04 +010060 FVP_PREBUILTS_TFA_ROOT, "fvp-base-gicv3-psci-1t.dts")
Olivier Depreza6d2e6d2020-11-06 18:09:50 +010061
Olivier Deprez1b1c4b62023-01-17 09:56:32 +010062FVP_PREBUILT_TFA_SPMD_ROOT = os.path.join(
63 HF_PREBUILTS, "linux-aarch64", "trusted-firmware-a-spmd", "fvp")
Andrew Scull845fc9b2019-04-03 12:44:26 +010064
Shruti Gupta2b1e0cd2022-12-20 17:45:24 +000065FVP_PREBUILTS_TFA_EL3_SPMC_ROOT = os.path.join(
66 HF_PREBUILTS, "linux-aarch64", "trusted-firmware-a-el3-spmc")
J-Alves852fe742021-04-22 11:59:55 +010067VM_NODE_REGEX = "vm[1-9]"
68
Olivier Deprez3917deb2023-01-19 11:08:43 +010069QEMU_CPU_MAX = "max,pauth-impdef=true"
70
David Brazdil2df24082019-09-05 11:55:08 +010071def read_file(path):
72 with open(path, "r") as f:
73 return f.read()
Andrew Scull845fc9b2019-04-03 12:44:26 +010074
David Brazdil2df24082019-09-05 11:55:08 +010075def write_file(path, to_write, append=False):
76 with open(path, "a" if append else "w") as f:
77 f.write(to_write)
78
79def append_file(path, to_write):
80 write_file(path, to_write, append=True)
81
82def join_if_not_None(*args):
83 return " ".join(filter(lambda x: x, args))
84
J-Alves852fe742021-04-22 11:59:55 +010085def get_vm_node_from_manifest(dts : str):
86 """ Get VM node string from Partition's extension to Partition Manager's
87 manifest."""
88 match = re.search(VM_NODE_REGEX, dts)
89 if not match:
90 raise Exception("Partition's node is not defined in its manifest.")
91 return match.group()
92
93def correct_vm_node(dts: str, node_index : int):
94 """ The vm node is being appended to the Partition Manager manifests.
95 Ideally, these files would be reused accross various test set-ups."""
96 return dts.replace(get_vm_node_from_manifest(dts), f"vm{node_index}")
97
J-Alves8cc7dbb2021-04-16 10:38:48 +010098DT = collections.namedtuple("DT", ["dts", "dtb"])
99
David Brazdil2df24082019-09-05 11:55:08 +0100100class ArtifactsManager:
101 """Class which manages folder with test artifacts."""
102
103 def __init__(self, log_dir):
104 self.created_files = []
105 self.log_dir = log_dir
106
107 # Create directory.
Andrew Scull845fc9b2019-04-03 12:44:26 +0100108 try:
David Brazdil2df24082019-09-05 11:55:08 +0100109 os.makedirs(self.log_dir)
110 except OSError:
111 if not os.path.isdir(self.log_dir):
112 raise
113 print("Logs saved under", log_dir)
114
115 # Create files expected by the Sponge test result parser.
116 self.sponge_log_path = self.create_file("sponge_log", ".log")
117 self.sponge_xml_path = self.create_file("sponge_log", ".xml")
118
David Brazdil623b6812019-09-09 11:41:08 +0100119 def gen_file_path(self, basename, extension):
120 """Generate path to a file in the log directory."""
121 return os.path.join(self.log_dir, basename + extension)
122
David Brazdil2df24082019-09-05 11:55:08 +0100123 def create_file(self, basename, extension):
124 """Create and touch a new file in the log folder. Ensure that no other
125 file of the same name was created by this instance of ArtifactsManager.
126 """
127 # Determine the path of the file.
David Brazdil623b6812019-09-09 11:41:08 +0100128 path = self.gen_file_path(basename, extension)
David Brazdil2df24082019-09-05 11:55:08 +0100129
130 # Check that the path is unique.
131 assert(path not in self.created_files)
132 self.created_files += [ path ]
133
134 # Touch file.
135 with open(path, "w") as f:
136 pass
137
138 return path
Andrew Scullbc7189d2018-08-14 09:35:13 +0100139
David Brazdil623b6812019-09-09 11:41:08 +0100140 def get_file(self, basename, extension):
141 """Return path to a file in the log folder. Assert that it was created
142 by this instance of ArtifactsManager."""
143 path = self.gen_file_path(basename, extension)
144 assert(path in self.created_files)
145 return path
146
Andrew Scullbc7189d2018-08-14 09:35:13 +0100147
David Brazdil2df24082019-09-05 11:55:08 +0100148# Tuple holding the arguments common to all driver constructors.
149# This is to avoid having to pass arguments from subclasses to superclasses.
150DriverArgs = collections.namedtuple("DriverArgs", [
151 "artifacts",
J-Alves8cc7dbb2021-04-16 10:38:48 +0100152 "hypervisor",
153 "spmc",
David Brazdil2df24082019-09-05 11:55:08 +0100154 "initrd",
155 "vm_args",
David Brazdil17e76652020-01-29 14:44:19 +0000156 "cpu",
J-Alves18a25f92021-05-04 17:47:41 +0100157 "partitions",
158 "global_run_name",
Saul Romero42a13632022-12-20 15:13:36 +0000159 "coverage_plugin",
J-Alvesff651e32024-07-23 13:34:56 +0100160 "disable_visualisation"
David Brazdil2df24082019-09-05 11:55:08 +0100161 ])
Marc Bonnici0a125632019-04-01 13:46:52 +0100162
David Brazdil2df24082019-09-05 11:55:08 +0100163# State shared between the common Driver class and its subclasses during
164# a single invocation of the target platform.
David Brazdil7325eaf2019-09-27 13:04:51 +0100165class DriverRunState:
166 def __init__(self, log_path):
167 self.log_path = log_path
168 self.ret_code = 0
Andrew Walbran98656252019-03-14 14:52:29 +0000169
David Brazdil7325eaf2019-09-27 13:04:51 +0100170 def set_ret_code(self, ret_code):
171 self.ret_code = ret_code
Andrew Walbran98656252019-03-14 14:52:29 +0000172
David Brazdil0dbb41f2019-09-09 18:03:35 +0100173class DriverRunException(Exception):
174 """Exception thrown if subprocess invoked by a driver returned non-zero
175 status code. Used to fast-exit from a driver command sequence."""
176 pass
177
178
David Brazdil2df24082019-09-05 11:55:08 +0100179class Driver:
180 """Parent class of drivers for all testable platforms."""
181
182 def __init__(self, args):
183 self.args = args
184
David Brazdil623b6812019-09-09 11:41:08 +0100185 def get_run_log(self, run_name):
186 """Return path to the main log of a given test run."""
187 return self.args.artifacts.get_file(run_name, ".log")
188
David Brazdil2df24082019-09-05 11:55:08 +0100189 def start_run(self, run_name):
190 """Hook called by Driver subclasses before they invoke the target
191 platform."""
David Brazdil7325eaf2019-09-27 13:04:51 +0100192 return DriverRunState(self.args.artifacts.create_file(run_name, ".log"))
David Brazdil2df24082019-09-05 11:55:08 +0100193
Andrew Walbranf636b842020-01-10 11:46:12 +0000194 def exec_logged(self, run_state, exec_args, cwd=None):
David Brazdil2df24082019-09-05 11:55:08 +0100195 """Run a subprocess on behalf of a Driver subclass and append its
196 stdout and stderr to the main log."""
David Brazdil0dbb41f2019-09-09 18:03:35 +0100197 assert(run_state.ret_code == 0)
David Brazdil2df24082019-09-05 11:55:08 +0100198 with open(run_state.log_path, "a") as f:
199 f.write("$ {}\r\n".format(" ".join(exec_args)))
200 f.flush()
Andrew Walbranf636b842020-01-10 11:46:12 +0000201 ret_code = subprocess.call(exec_args, stdout=f, stderr=f, cwd=cwd)
David Brazdil0dbb41f2019-09-09 18:03:35 +0100202 if ret_code != 0:
David Brazdil7325eaf2019-09-27 13:04:51 +0100203 run_state.set_ret_code(ret_code)
David Brazdil0dbb41f2019-09-09 18:03:35 +0100204 raise DriverRunException()
David Brazdil2df24082019-09-05 11:55:08 +0100205
David Brazdil0dbb41f2019-09-09 18:03:35 +0100206 def finish_run(self, run_state):
David Brazdil2df24082019-09-05 11:55:08 +0100207 """Hook called by Driver subclasses after they finished running the
208 target platform. `ret_code` argument is the return code of the main
209 command run by the driver. A corresponding log message is printed."""
210 # Decode return code and add a message to the log.
211 with open(run_state.log_path, "a") as f:
David Brazdil0dbb41f2019-09-09 18:03:35 +0100212 if run_state.ret_code == 124:
David Brazdil2df24082019-09-05 11:55:08 +0100213 f.write("\r\n{}{} timed out\r\n".format(
214 HFTEST_LOG_PREFIX, HFTEST_LOG_FAILURE_PREFIX))
David Brazdil0dbb41f2019-09-09 18:03:35 +0100215 elif run_state.ret_code != 0:
David Brazdil2df24082019-09-05 11:55:08 +0100216 f.write("\r\n{}{} process return code {}\r\n".format(
David Brazdil0dbb41f2019-09-09 18:03:35 +0100217 HFTEST_LOG_PREFIX, HFTEST_LOG_FAILURE_PREFIX,
218 run_state.ret_code))
David Brazdil2df24082019-09-05 11:55:08 +0100219
220 # Append log of this run to full test log.
221 log_content = read_file(run_state.log_path)
222 append_file(
223 self.args.artifacts.sponge_log_path,
224 log_content + "\r\n\r\n")
225 return log_content
Andrew Walbran98656252019-03-14 14:52:29 +0000226
David Brazdil2df24082019-09-05 11:55:08 +0100227class QemuDriver(Driver):
228 """Driver which runs tests in QEMU."""
229
Andrew Walbranf636b842020-01-10 11:46:12 +0000230 def __init__(self, args, qemu_wd, tfa):
David Brazdil2df24082019-09-05 11:55:08 +0100231 Driver.__init__(self, args)
Andrew Walbranf636b842020-01-10 11:46:12 +0000232 self.qemu_wd = qemu_wd
233 self.tfa = tfa
David Brazdil2df24082019-09-05 11:55:08 +0100234
David Brazdila2358d42020-01-27 18:51:38 +0000235 def gen_exec_args(self, test_args, is_long_running):
David Brazdil2df24082019-09-05 11:55:08 +0100236 """Generate command line arguments for QEMU."""
J-Alvescc9d1132024-10-30 13:46:33 +0000237 time_limit = "120s" if is_long_running else "30s"
Fuad Tabba36c8c2b2019-11-04 16:55:32 +0000238 # If no CPU configuration is selected, then test against the maximum
239 # configuration, "max", supported by QEMU.
Olivier Deprez3917deb2023-01-19 11:08:43 +0100240 if not self.args.cpu or self.args.cpu == "max":
241 cpu = QEMU_CPU_MAX
242 else:
243 cpu = self.args.cpu
244
David Brazdil2df24082019-09-05 11:55:08 +0100245 exec_args = [
David Brazdil3cc24aa2019-09-27 10:24:41 +0100246 "timeout", "--foreground", time_limit,
Olivier Depreze30c36f2022-11-22 11:26:47 +0100247 QEMU_PREBUILTS,
Olivier Deprez5373f232022-11-23 09:57:19 +0100248 "-no-reboot", "-machine", "virt-6.2,virtualization=on,gic-version=3",
J-Alves871e3732022-05-31 17:10:50 +0100249 "-cpu", cpu, "-smp", "8", "-m", "1G",
David Brazdil2df24082019-09-05 11:55:08 +0100250 "-nographic", "-nodefaults", "-serial", "stdio",
J-Alves8cc7dbb2021-04-16 10:38:48 +0100251 "-d", "unimp", "-kernel", os.path.abspath(self.args.hypervisor),
David Brazdil2df24082019-09-05 11:55:08 +0100252 ]
253
Andrew Walbranf636b842020-01-10 11:46:12 +0000254 if self.tfa:
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100255 bl1_path = os.path.join(
Olivier Deprez0c5e7dc2023-01-17 10:29:04 +0100256 HF_PREBUILTS, "linux-aarch64", "trusted-firmware-a",
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100257 "qemu", "bl1.bin")
Andrew Walbranf636b842020-01-10 11:46:12 +0000258 exec_args += ["-bios",
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100259 os.path.abspath(bl1_path),
260 "-machine", "secure=on", "-semihosting-config",
Andrew Walbranab4b2d52020-06-11 16:54:10 +0100261 "enable=on,target=native"]
Andrew Walbranf636b842020-01-10 11:46:12 +0000262
David Brazdil2df24082019-09-05 11:55:08 +0100263 if self.args.initrd:
Andrew Walbranf636b842020-01-10 11:46:12 +0000264 exec_args += ["-initrd", os.path.abspath(self.args.initrd)]
David Brazdil2df24082019-09-05 11:55:08 +0100265
266 vm_args = join_if_not_None(self.args.vm_args, test_args)
267 if vm_args:
268 exec_args += ["-append", vm_args]
269
270 return exec_args
271
J-Alves67c31912023-02-02 13:52:50 +0000272 def run(self, run_name, test_args, is_long_running, debug = False,
273 show_output = False):
David Brazdil2df24082019-09-05 11:55:08 +0100274 """Run test given by `test_args` in QEMU."""
J-Alves67c31912023-02-02 13:52:50 +0000275 # TODO: use 'debug' and 'show_output' flags.
David Brazdil2df24082019-09-05 11:55:08 +0100276 run_state = self.start_run(run_name)
David Brazdil0dbb41f2019-09-09 18:03:35 +0100277
278 try:
David Brazdil0dbb41f2019-09-09 18:03:35 +0100279 # Execute test in QEMU..
David Brazdila2358d42020-01-27 18:51:38 +0000280 exec_args = self.gen_exec_args(test_args, is_long_running)
Andrew Walbranf636b842020-01-10 11:46:12 +0000281 self.exec_logged(run_state, exec_args,
282 cwd=self.qemu_wd)
David Brazdil0dbb41f2019-09-09 18:03:35 +0100283 except DriverRunException:
284 pass
285
286 return self.finish_run(run_state)
Andrew Scullbc7189d2018-08-14 09:35:13 +0100287
David Brazdil94fd1e92020-02-03 16:45:20 +0000288 def finish(self):
289 """Clean up after running tests."""
290 pass
291
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100292class FvpDriver(Driver, ABC):
293 """Base class for driver which runs tests in Arm FVP emulator."""
David Brazdil2df24082019-09-05 11:55:08 +0100294
J-Alves19216692023-05-12 15:01:31 +0100295 def __init__(self, args, cpu_start_address, fvp_prebuilt_bl31):
Saul Romero42a13632022-12-20 15:13:36 +0000296 self.cov_plugin = args.coverage_plugin or None
Fuad Tabba36c8c2b2019-11-04 16:55:32 +0000297 if args.cpu:
298 raise ValueError("FVP emulator does not support the --cpu option.")
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100299 super().__init__(args)
J-Alves19216692023-05-12 15:01:31 +0100300 self._cpu_start_address = cpu_start_address
301 self._fvp_prebuilt_bl31 = fvp_prebuilt_bl31
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100302
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100303 def create_dt(self, run_name : str):
304 """Create DT related files, and return respective paths in a tuple
305 (dts,dtb)"""
J-Alves8cc7dbb2021-04-16 10:38:48 +0100306 return DT(self.args.artifacts.create_file(run_name, ".dts"),
307 self.args.artifacts.create_file(run_name, ".dtb"))
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100308
J-Alves8cc7dbb2021-04-16 10:38:48 +0100309 def compile_dt(self, run_state, dt : DT):
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100310 """Compile DT calling dtc."""
311 dtc_args = [
J-Alves8cc7dbb2021-04-16 10:38:48 +0100312 DTC_SCRIPT, "compile", "-i", dt.dts, "-o", dt.dtb,
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100313 ]
314 self.exec_logged(run_state, dtc_args)
315
316 def create_uart_log(self, run_name : str, file_name : str):
317 """Create uart log file, and return path"""
318 return self.args.artifacts.create_file(run_name, file_name)
319
320 def get_img_and_ldadd(self, partitions : dict):
321 ret = []
322 for i, p in enumerate(partitions):
J-Alves852fe742021-04-22 11:59:55 +0100323 with open(p["dts"], "r") as dt:
324 dts = dt.read()
325 manifest = fdt.parse_dts(dts)
326 vm_node = get_vm_node_from_manifest(dts)
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100327 load_address = manifest.get_property("load_address",
J-Alves852fe742021-04-22 11:59:55 +0100328 f"/hypervisor/{vm_node}").value
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100329 ret.append((p["img"], load_address))
330 return ret
331
332 def get_manifests_from_json(self, partitions : list):
333 manifests = ""
334 if partitions is not None:
J-Alves852fe742021-04-22 11:59:55 +0100335 for i, p in enumerate(partitions):
336 manifests += correct_vm_node(read_file(p["dts"]), i + 1)
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100337 return manifests
338
339 @abstractmethod
J-Alves8cc7dbb2021-04-16 10:38:48 +0100340 def gen_dts(self, dt, test_args):
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100341 """Abstract method to generate dts file. This specific to the use case
342 so should be implemented within derived driver"""
343 pass
344
345 @abstractmethod
David Brazdil2df24082019-09-05 11:55:08 +0100346 def gen_fvp_args(
J-Alves67c31912023-02-02 13:52:50 +0000347 self, is_long_running, uart0_log_path, uart1_log_path, dt,
348 debug = False, show_output = False):
David Brazdil2df24082019-09-05 11:55:08 +0100349 """Generate command line arguments for FVP."""
J-Alves67c31912023-02-02 13:52:50 +0000350 show_output = debug or show_output
J-Alvesff651e32024-07-23 13:34:56 +0100351 disable_visualisation = self.args.disable_visualisation is True
J-Alvescc9d1132024-10-30 13:46:33 +0000352 time_limit = "150s" if is_long_running else "40s"
J-Alves67c31912023-02-02 13:52:50 +0000353 fvp_args = []
354
355 if not show_output:
356 fvp_args = [
357 "timeout", "--foreground", time_limit,
358 ]
359
360 fvp_args += [
David Brazdil2df24082019-09-05 11:55:08 +0100361 FVP_BINARY,
J-Alves10446d82021-04-26 11:52:57 +0100362 "-C", "pci.pci_smmuv3.mmu.SMMU_AIDR=2",
363 "-C", "pci.pci_smmuv3.mmu.SMMU_IDR0=0x0046123B",
364 "-C", "pci.pci_smmuv3.mmu.SMMU_IDR1=0x00600002",
365 "-C", "pci.pci_smmuv3.mmu.SMMU_IDR3=0x1714",
366 "-C", "pci.pci_smmuv3.mmu.SMMU_IDR5=0xFFFF0472",
367 "-C", "pci.pci_smmuv3.mmu.SMMU_S_IDR1=0xA0000002",
368 "-C", "pci.pci_smmuv3.mmu.SMMU_S_IDR2=0",
369 "-C", "pci.pci_smmuv3.mmu.SMMU_S_IDR3=0",
David Brazdil2df24082019-09-05 11:55:08 +0100370 "-C", "pctl.startup=0.0.0.0",
Olivier Deprezcd857002022-05-09 09:06:24 +0200371 "-C", "bp.secure_memory=1",
David Brazdil2df24082019-09-05 11:55:08 +0100372 "-C", "cluster0.NUM_CORES=4",
373 "-C", "cluster1.NUM_CORES=4",
374 "-C", "cache_state_modelled=0",
David Brazdil2df24082019-09-05 11:55:08 +0100375 "-C", "bp.vis.rate_limit-enable=false",
David Brazdil2df24082019-09-05 11:55:08 +0100376 "-C", "bp.pl011_uart0.untimed_fifos=1",
377 "-C", "bp.pl011_uart0.unbuffered_output=1",
J-Alves19216692023-05-12 15:01:31 +0100378 "-C", f"cluster0.cpu0.RVBAR={self._cpu_start_address}",
379 "-C", f"cluster0.cpu1.RVBAR={self._cpu_start_address}",
380 "-C", f"cluster0.cpu2.RVBAR={self._cpu_start_address}",
381 "-C", f"cluster0.cpu3.RVBAR={self._cpu_start_address}",
382 "-C", f"cluster1.cpu0.RVBAR={self._cpu_start_address}",
383 "-C", f"cluster1.cpu1.RVBAR={self._cpu_start_address}",
384 "-C", f"cluster1.cpu2.RVBAR={self._cpu_start_address}",
385 "-C", f"cluster1.cpu3.RVBAR={self._cpu_start_address}",
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100386 "--data",
J-Alves19216692023-05-12 15:01:31 +0100387 f"cluster0.cpu0={self._fvp_prebuilt_bl31}@{self._cpu_start_address}",
David Brazdil2df24082019-09-05 11:55:08 +0100388 "-C", "bp.ve_sysregs.mmbSiteDefault=0",
Raghu Krishnamurthy75ebf8c2021-11-28 07:22:12 -0800389 "-C", "cluster0.has_arm_v8-5=1",
390 "-C", "cluster1.has_arm_v8-5=1",
391 "-C", "cluster0.has_branch_target_exception=1",
392 "-C", "cluster1.has_branch_target_exception=1",
Maksims Svecovsce1261f2022-03-04 15:22:58 +0000393 "-C", "cluster0.memory_tagging_support_level=2",
394 "-C", "cluster1.memory_tagging_support_level=2",
395 "-C", "bp.dram_metadata.is_enabled=1",
Raghu Krishnamurthye2eae292022-08-10 22:38:41 -0700396 "-C", "cluster0.gicv3.extended-interrupt-range-support=1",
397 "-C", "cluster1.gicv3.extended-interrupt-range-support=1",
398 "-C", "gic_distributor.extended-ppi-count=64",
399 "-C", "gic_distributor.extended-spi-count=1024",
400 "-C", "gic_distributor.ARE-fixed-to-one=1",
David Brazdil2df24082019-09-05 11:55:08 +0100401 ]
J-Alves18a25f92021-05-04 17:47:41 +0100402
403 if uart0_log_path and uart1_log_path:
404 fvp_args += [
405 "-C", f"bp.pl011_uart0.out_file={uart0_log_path}",
406 "-C", f"bp.pl011_uart1.out_file={uart1_log_path}",
407 ]
J-Alves67c31912023-02-02 13:52:50 +0000408
409 if not show_output:
410 fvp_args += [
J-Alves67c31912023-02-02 13:52:50 +0000411 "-C", "bp.terminal_0.start_telnet=false",
412 "-C", "bp.terminal_1.start_telnet=false",
413 "-C", "bp.terminal_2.start_telnet=false",
414 "-C", "bp.terminal_3.start_telnet=false",
415 "-C", "bp.ve_sysregs.exit_on_shutdown=1",
416 ]
J-Alvesff651e32024-07-23 13:34:56 +0100417 disable_visualisation = True
418
419 if disable_visualisation:
420 fvp_args += [
421 "-C", "bp.vis.disable_visualisation=true"
422 ]
J-Alves67c31912023-02-02 13:52:50 +0000423
424 if debug:
425 fvp_args += [
J-Alves9a444ad2024-02-19 10:56:09 +0000426 "--iris-connect", "tcpserver,allowRemote",
427 "-p",
Saul Romero42a13632022-12-20 15:13:36 +0000428 ]
429
430 if self.cov_plugin is not None:
431 fvp_args += [
432 "--plugin", self.cov_plugin
J-Alves67c31912023-02-02 13:52:50 +0000433 ]
David Brazdil2df24082019-09-05 11:55:08 +0100434 return fvp_args
435
J-Alves67c31912023-02-02 13:52:50 +0000436 def run(self, run_name, test_args, is_long_running, debug = False,
437 show_output = False):
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100438 """ Run test """
David Brazdil2df24082019-09-05 11:55:08 +0100439 run_state = self.start_run(run_name)
J-Alves8cc7dbb2021-04-16 10:38:48 +0100440 dt = self.create_dt(run_name)
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100441 uart0_log_path = self.create_uart_log(run_name, ".uart0.log")
442 uart1_log_path = self.create_uart_log(run_name, ".uart1.log")
David Brazdil2df24082019-09-05 11:55:08 +0100443
David Brazdil0dbb41f2019-09-09 18:03:35 +0100444 try:
J-Alves8cc7dbb2021-04-16 10:38:48 +0100445 self.gen_dts(dt, test_args)
446 self.compile_dt(run_state, dt)
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100447 fvp_args = self.gen_fvp_args(is_long_running, uart0_log_path,
J-Alves67c31912023-02-02 13:52:50 +0000448 uart1_log_path, dt, debug=debug,
449 show_output=show_output)
David Brazdil0dbb41f2019-09-09 18:03:35 +0100450 self.exec_logged(run_state, fvp_args)
451 except DriverRunException:
452 pass
David Brazdil2df24082019-09-05 11:55:08 +0100453
454 # Append UART0 output to main log.
455 append_file(run_state.log_path, read_file(uart0_log_path))
David Brazdil0dbb41f2019-09-09 18:03:35 +0100456 return self.finish_run(run_state)
David Brazdil2df24082019-09-05 11:55:08 +0100457
David Brazdil94fd1e92020-02-03 16:45:20 +0000458 def finish(self):
459 """Clean up after running tests."""
460 pass
461
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100462class FvpDriverHypervisor(FvpDriver):
463 """
464 Driver which runs tests in Arm FVP emulator, with hafnium as hypervisor
465 """
466 INITRD_START= 0x84000000
Olivier Depreza516f482021-04-30 18:47:59 +0200467 INITRD_END = 0x86000000 #Default value, however may change if initrd in args
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100468
J-Alves19216692023-05-12 15:01:31 +0100469 def __init__(self, args, hypervisor_address=0x80000000, hypervisor_dtb_address=0x82000000):
470 fvp_prebuilt_bl31 = os.path.join(FVP_PREBUILTS_TFA_ROOT, "bl31.bin")
471 FvpDriver.__init__(self, args, 0x04020000, fvp_prebuilt_bl31)
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100472 self.vms_in_partitions_json = args.partitions and args.partitions["VMs"]
J-Alves19216692023-05-12 15:01:31 +0100473 self._hypervisor_address = hypervisor_address
474 self._hypervisor_dtb_address = hypervisor_dtb_address
J-Alves38223dd2021-04-20 17:31:48 +0100475
J-Alves8cc7dbb2021-04-16 10:38:48 +0100476 def gen_dts(self, dt, test_args):
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100477 """Create a DeviceTree source which will be compiled into a DTB and
478 passed to FVP for a test run."""
479
480 vm_args = join_if_not_None(self.args.vm_args, test_args)
J-Alves8cc7dbb2021-04-16 10:38:48 +0100481 write_file(dt.dts, read_file(FVP_PREBUILT_DTS))
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100482
483 # Write the vm arguments to the partition manifest
484 to_append = f"""
485/ {{
486 chosen {{
487 bootargs = "{vm_args}";
488 stdout-path = "serial0:115200n8";
489 linux,initrd-start = <{self.INITRD_START if self.args.initrd else 0}>;
490 linux,initrd-end = <{self.INITRD_END if self.args.initrd else 0}>;
491 }};
492}};"""
493 if self.vms_in_partitions_json:
494 to_append += self.get_manifests_from_json(self.args.partitions["VMs"])
495
J-Alves8cc7dbb2021-04-16 10:38:48 +0100496 append_file(dt.dts, to_append)
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100497
498 def gen_fvp_args(
J-Alves67c31912023-02-02 13:52:50 +0000499 self, is_long_running, uart0_log_path, uart1_log_path, dt,
500 debug = False, show_output = False):
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100501 """Generate command line arguments for FVP."""
J-Alves67c31912023-02-02 13:52:50 +0000502 common_args = (self, is_long_running, uart0_log_path, uart1_log_path, dt,
503 debug, show_output)
504 fvp_args = FvpDriver.gen_fvp_args(*common_args)
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100505
J-Alves8cc7dbb2021-04-16 10:38:48 +0100506 fvp_args += [
J-Alves19216692023-05-12 15:01:31 +0100507 "--data", f"cluster0.cpu0={dt.dtb}@{self._hypervisor_dtb_address}",
508 "--data", f"cluster0.cpu0={self.args.hypervisor}@{self._hypervisor_address}",
J-Alves8cc7dbb2021-04-16 10:38:48 +0100509 ]
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100510
511 if self.vms_in_partitions_json:
512 img_ldadd = self.get_img_and_ldadd(self.args.partitions["VMs"])
513 for img, ldadd in img_ldadd:
514 fvp_args += ["--data", f"cluster0.cpu0={img}@{hex(ldadd)}"]
515
516 if self.args.initrd:
517 fvp_args += [
518 "--data",
519 f"cluster0.cpu0={self.args.initrd}@{self.INITRD_START}"
520 ]
521 return fvp_args
522
523class FvpDriverSPMC(FvpDriver):
524 """
525 Driver which runs tests in Arm FVP emulator, with hafnium as SPMC
526 """
527 FVP_PREBUILT_SECURE_DTS = os.path.join(
528 HF_ROOT, "test", "vmapi", "fvp-base-spmc.dts")
J-Alvesacdbb862023-01-31 17:14:55 +0000529 hftest_cmd_file = tempfile.NamedTemporaryFile(mode="w+")
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100530
J-Alves19216692023-05-12 15:01:31 +0100531 def __init__(self, args, cpu_start_address=0x04010000, fvp_prebuilt_bl31=None):
532 fvp_prebuilt_bl31 = os.path.join(FVP_PREBUILT_TFA_SPMD_ROOT, "bl31.bin") if fvp_prebuilt_bl31 is None else fvp_prebuilt_bl31
533 super().__init__(args, cpu_start_address, fvp_prebuilt_bl31)
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100534
J-Alves19216692023-05-12 15:01:31 +0100535 self._spmc_address = 0x6000000
536 self._spmc_dtb_address = 0x0403f000
J-Alves38223dd2021-04-20 17:31:48 +0100537
J-Alves8cc7dbb2021-04-16 10:38:48 +0100538 def gen_dts(self, dt, test_args):
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100539 """Create a DeviceTree source which will be compiled into a DTB and
540 passed to FVP for a test run."""
541 to_append = self.get_manifests_from_json(self.args.partitions["SPs"])
J-Alves8cc7dbb2021-04-16 10:38:48 +0100542 write_file(dt.dts, read_file(FvpDriverSPMC.FVP_PREBUILT_SECURE_DTS))
543 append_file(dt.dts, to_append)
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100544
Shruti Gupta2b1e0cd2022-12-20 17:45:24 +0000545 def secure_ctrl_fvp_args(self, secure_ctrl):
546 fvp_args = ""
547 if secure_ctrl:
548 fvp_args = [
549 "-C", f"bp.pl011_uart0.in_file={FvpDriverSPMC.hftest_cmd_file.name}",
550 "-C", f"bp.pl011_uart0.shutdown_tag=\"{HFTEST_CTRL_FINISHED}\"",
551 ]
552 return fvp_args
553
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100554 def gen_fvp_args(
J-Alves8cc7dbb2021-04-16 10:38:48 +0100555 self, is_long_running, uart0_log_path, uart1_log_path, dt,
J-Alves67c31912023-02-02 13:52:50 +0000556 call_super = True, secure_ctrl = True, debug = False, show_output = False):
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100557 """Generate command line arguments for FVP."""
J-Alves67c31912023-02-02 13:52:50 +0000558 common_args = (self, is_long_running, uart0_log_path, uart1_log_path, dt.dtb,
559 debug, show_output)
J-Alves38223dd2021-04-20 17:31:48 +0100560 fvp_args = FvpDriver.gen_fvp_args(*common_args) if call_super else []
J-Alves8cc7dbb2021-04-16 10:38:48 +0100561
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100562 fvp_args += [
J-Alves19216692023-05-12 15:01:31 +0100563 "--data", f"cluster0.cpu0={dt.dtb}@{self._spmc_dtb_address}",
564 "--data", f"cluster0.cpu0={self.args.spmc}@{self._spmc_address}",
J-Alves8cc7dbb2021-04-16 10:38:48 +0100565 ]
566
Shruti Gupta2b1e0cd2022-12-20 17:45:24 +0000567 fvp_args += FvpDriverSPMC.secure_ctrl_fvp_args(self, secure_ctrl)
J-Alves18a25f92021-05-04 17:47:41 +0100568
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100569 img_ldadd = self.get_img_and_ldadd(self.args.partitions["SPs"])
570 for img, ldadd in img_ldadd:
571 fvp_args += ["--data", f"cluster0.cpu0={img}@{hex(ldadd)}"]
572
573 return fvp_args
574
J-Alves67c31912023-02-02 13:52:50 +0000575 def run(self, run_name, test_args, is_long_running, debug = False, show_output = False):
J-Alvesacdbb862023-01-31 17:14:55 +0000576 vm_args = join_if_not_None(self.args.vm_args, test_args)
577 FvpDriverSPMC.hftest_cmd_file.write(f"{vm_args}\n")
578 FvpDriverSPMC.hftest_cmd_file.seek(0)
J-Alves67c31912023-02-02 13:52:50 +0000579 return super().run(run_name, test_args, is_long_running, debug, show_output)
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100580
581 def finish(self):
582 """Clean up after running tests."""
J-Alvesacdbb862023-01-31 17:14:55 +0000583 FvpDriverSPMC.hftest_cmd_file.close()
David Brazdil2df24082019-09-05 11:55:08 +0100584
J-Alves38223dd2021-04-20 17:31:48 +0100585class FvpDriverBothWorlds(FvpDriverHypervisor, FvpDriverSPMC):
586 def __init__(self, args):
J-Alves19216692023-05-12 15:01:31 +0100587 FvpDriverHypervisor.__init__(self, args, hypervisor_address=0x88000000)
J-Alves38223dd2021-04-20 17:31:48 +0100588 FvpDriverSPMC.__init__(self, args)
589
J-Alves38223dd2021-04-20 17:31:48 +0100590 def create_dt(self, run_name):
591 dt = dict()
592 dt["hypervisor"] = FvpDriver.create_dt(self, run_name + "_hypervisor")
593 dt["spmc"] = FvpDriver.create_dt(self, run_name + "_spmc")
594 return dt
595
J-Alves38223dd2021-04-20 17:31:48 +0100596 def compile_dt(self, run_state, dt):
597 FvpDriver.compile_dt(self, run_state, dt["hypervisor"])
598 FvpDriver.compile_dt(self, run_state, dt["spmc"])
599
600 def gen_dts(self, dt, test_args):
601 FvpDriverHypervisor.gen_dts(self, dt["hypervisor"], test_args)
602 FvpDriverSPMC.gen_dts(self, dt["spmc"], test_args)
603
J-Alves67c31912023-02-02 13:52:50 +0000604 def gen_fvp_args(self, is_long_running, uart0_log_path, uart1_log_path, dt,
605 debug = False, show_output = False):
J-Alves38223dd2021-04-20 17:31:48 +0100606 """Generate command line arguments for FVP."""
J-Alves8d9fbb92021-12-13 17:28:15 +0000607 common_args = (self, is_long_running, uart0_log_path, uart1_log_path)
J-Alves67c31912023-02-02 13:52:50 +0000608 fvp_args = FvpDriverHypervisor.gen_fvp_args(*common_args, dt["hypervisor"],
609 debug, show_output)
J-Alves18a25f92021-05-04 17:47:41 +0100610 fvp_args += FvpDriverSPMC.gen_fvp_args(*common_args, dt["spmc"], False,
611 False)
J-Alves8d9fbb92021-12-13 17:28:15 +0000612 return fvp_args
J-Alves18a25f92021-05-04 17:47:41 +0100613
J-Alves67c31912023-02-02 13:52:50 +0000614 def run(self, run_name, test_args, is_long_running, debug = False,
615 show_output = False):
616
617 return FvpDriver.run(self, run_name, test_args, is_long_running,
618 debug, show_output)
J-Alves38223dd2021-04-20 17:31:48 +0100619
620 def finish(self):
621 """Clean up after running tests."""
J-Alves8d9fbb92021-12-13 17:28:15 +0000622 FvpDriver.finish(self)
J-Alves38223dd2021-04-20 17:31:48 +0100623
Shruti Gupta2b1e0cd2022-12-20 17:45:24 +0000624class FvpDriverEL3SPMC(FvpDriverSPMC):
625 """
626 Driver which runs tests in Arm FVP emulator, with EL3 as SPMC
627 """
628
629 def __init__(self, args):
J-Alves19216692023-05-12 15:01:31 +0100630 FvpDriverSPMC.__init__(
631 self, args, cpu_start_address=0x04003000,
632 fvp_prebuilt_bl31=os.path.join(FVP_PREBUILTS_TFA_EL3_SPMC_ROOT, "bl31.bin"))
Shruti Gupta2b1e0cd2022-12-20 17:45:24 +0000633 self.vms_in_partitions_json = args.partitions and args.partitions["SPs"]
J-Alves19216692023-05-12 15:01:31 +0100634 self._sp_dtb_address = 0x0403f000
Shruti Gupta2b1e0cd2022-12-20 17:45:24 +0000635
636 def sp_partition_manifest_fvp_args(self):
637 img_ldadd = self.get_img_and_ldadd(self.args.partitions["SPs"])
638
639 # Expect only one tuple with img and load address, as EL3 SPMC only supports
640 # one SP.
641 assert(len(img_ldadd) == 1)
642 img, ldadd = img_ldadd[0]
643 fvp_args = ["--data", f"cluster0.cpu0={img}@{ldadd}"]
644
645 # Even though FF-A manifest is part of the SP PKG we need to load at a specific
646 # location. Fetch the respective dtb file and load at the following address.
Shruti Gupta2b1e0cd2022-12-20 17:45:24 +0000647 output_path = os.path.dirname(os.path.dirname(img))
648 partition_manifest = f"{output_path}/partition-manifest.dtb"
J-Alves19216692023-05-12 15:01:31 +0100649 fvp_args += ["--data", f"cluster0.cpu0={partition_manifest}@{self._sp_dtb_address}"]
Shruti Gupta2b1e0cd2022-12-20 17:45:24 +0000650 return fvp_args
651
652 def gen_fvp_args(
653 self, is_long_running, uart0_log_path, uart1_log_path, dt,
654 call_super = True, secure_ctrl = True, debug = False, show_output = False):
655 """Generate command line arguments for FVP."""
656 common_args = (self, is_long_running, uart0_log_path, uart1_log_path, dt.dtb,
657 debug, show_output)
658 fvp_args = FvpDriver.gen_fvp_args(*common_args) if call_super else []
659
660 fvp_args += FvpDriverSPMC.secure_ctrl_fvp_args(self, secure_ctrl)
661
662 fvp_args += self.sp_partition_manifest_fvp_args()
663
664 return fvp_args
665
Shruti Gupta22dbef32023-04-03 10:26:31 +0100666class FvpDriverEL3SPMCBothWorlds(FvpDriverHypervisor, FvpDriverEL3SPMC):
667 """
668 Driver which runs tests in Arm FVP emulator, with EL3 as SPMC
669 """
670
J-Alves19216692023-05-12 15:01:31 +0100671 def __init__(self, args):
672 FvpDriverHypervisor.__init__(self, args)
673 FvpDriverEL3SPMC.__init__(self, args)
Shruti Gupta22dbef32023-04-03 10:26:31 +0100674
J-Alves19216692023-05-12 15:01:31 +0100675 self._fvp_prebuilt_bl32 = os.path.join(FVP_PREBUILTS_TFA_EL3_SPMC_ROOT, "bl32.bin")
676 self._fvp_prebuilt_dtb = os.path.join(FVP_PREBUILTS_TFA_EL3_SPMC_ROOT, "fdts/fvp_tsp_sp_manifest.dtb")
Shruti Gupta22dbef32023-04-03 10:26:31 +0100677
678 def gen_fvp_args(
679 self, is_long_running, uart0_log_path, uart1_log_path, dt,
680 call_super = True, secure_ctrl = True, debug = False, show_output = False):
681 """Generate command line arguments for FVP."""
682
683 fvp_args = FvpDriverHypervisor.gen_fvp_args(self, is_long_running, uart0_log_path, uart1_log_path, dt,
684 debug, show_output)
685
686 fvp_args += FvpDriverSPMC.secure_ctrl_fvp_args(self, secure_ctrl)
687
688 if self.args.partitions is not None and self.args.partitions["SPs"] is not None:
689 fvp_args += FvpDriverEL3SPMC.sp_partition_manifest_fvp_args(self)
690 else :
691 # Use prebuilt TSP and TSP manifest if build does not specify SP
692 # EL3 SPMC expects SP to be loaded at 0xFF200000 and SP manifest at 0x0403F000
J-Alves19216692023-05-12 15:01:31 +0100693 fvp_args += ["--data", f"cluster0.cpu0={self._fvp_prebuilt_bl32}@0xff200000"]
694 fvp_args += ["--data", f"cluster0.cpu0={self._fvp_prebuilt_dtb}@{self._sp_dtb_address}"]
Shruti Gupta22dbef32023-04-03 10:26:31 +0100695
696 return fvp_args
697
David Brazdil17e76652020-01-29 14:44:19 +0000698class SerialDriver(Driver):
699 """Driver which communicates with a device over the serial port."""
700
David Brazdil9d4ed962020-02-06 17:23:48 +0000701 def __init__(self, args, tty_file, baudrate, init_wait):
David Brazdil17e76652020-01-29 14:44:19 +0000702 Driver.__init__(self, args)
David Brazdil9d4ed962020-02-06 17:23:48 +0000703 self.tty_file = tty_file
704 self.baudrate = baudrate
David Brazdil4f9cf9a2020-02-06 17:34:44 +0000705 self.pyserial = importlib.import_module("serial")
David Brazdild8013f92020-02-03 16:40:25 +0000706
David Brazdil9d4ed962020-02-06 17:23:48 +0000707 if init_wait:
David Brazdild8013f92020-02-03 16:40:25 +0000708 input("Press ENTER and then reset the device...")
David Brazdil17e76652020-01-29 14:44:19 +0000709
David Brazdil9d4ed962020-02-06 17:23:48 +0000710 def connect(self):
David Brazdil4f9cf9a2020-02-06 17:34:44 +0000711 return self.pyserial.Serial(self.tty_file, self.baudrate, timeout=10)
David Brazdil9d4ed962020-02-06 17:23:48 +0000712
David Brazdil17e76652020-01-29 14:44:19 +0000713 def run(self, run_name, test_args, is_long_running):
714 """Communicate `test_args` to the device over the serial port."""
715 run_state = self.start_run(run_name)
716
David Brazdil9d4ed962020-02-06 17:23:48 +0000717 with self.connect() as ser:
David Brazdil17e76652020-01-29 14:44:19 +0000718 with open(run_state.log_path, "a") as f:
719 while True:
720 # Read one line from the serial port.
721 line = ser.readline().decode('utf-8')
722 if len(line) == 0:
723 # Timeout
724 run_state.set_ret_code(124)
725 input("Timeout. " +
726 "Press ENTER and then reset the device...")
727 break
728 # Write the line to the log file.
729 f.write(line)
730 if HFTEST_CTRL_GET_COMMAND_LINE in line:
731 # Device is waiting for `test_args`.
732 ser.write(test_args.encode('ascii'))
733 ser.write(b'\r')
734 elif HFTEST_CTRL_FINISHED in line:
735 # Device has finished running this test and will reboot.
736 break
J-Alves18a25f92021-05-04 17:47:41 +0100737
David Brazdil17e76652020-01-29 14:44:19 +0000738 return self.finish_run(run_state)
739
David Brazdil94fd1e92020-02-03 16:45:20 +0000740 def finish(self):
741 """Clean up after running tests."""
David Brazdil9d4ed962020-02-06 17:23:48 +0000742 with self.connect() as ser:
David Brazdil94fd1e92020-02-03 16:45:20 +0000743 while True:
744 line = ser.readline().decode('utf-8')
745 if len(line) == 0:
746 input("Timeout. Press ENTER and then reset the device...")
747 elif HFTEST_CTRL_GET_COMMAND_LINE in line:
748 # Device is waiting for a command. Instruct it to exit
749 # the test environment.
750 ser.write("exit".encode('ascii'))
751 ser.write(b'\r')
752 break
753
David Brazdil2df24082019-09-05 11:55:08 +0100754# Tuple used to return information about the results of running a set of tests.
755TestRunnerResult = collections.namedtuple("TestRunnerResult", [
756 "tests_run",
757 "tests_failed",
Andrew Walbranf9463922020-06-05 16:44:42 +0100758 "tests_skipped",
David Brazdil2df24082019-09-05 11:55:08 +0100759 ])
760
David Brazdil2df24082019-09-05 11:55:08 +0100761class TestRunner:
762 """Class which communicates with a test platform to obtain a list of
763 available tests and driving their execution."""
764
J-Alves8cc7dbb2021-04-16 10:38:48 +0100765 def __init__(self, artifacts, driver, test_set_up, suite_regex, test_regex,
J-Alves67c31912023-02-02 13:52:50 +0000766 skip_long_running_tests, force_long_running, debug, show_output):
David Brazdil2df24082019-09-05 11:55:08 +0100767 self.artifacts = artifacts
768 self.driver = driver
J-Alves8cc7dbb2021-04-16 10:38:48 +0100769 self.test_set_up = test_set_up
David Brazdil3cc24aa2019-09-27 10:24:41 +0100770 self.skip_long_running_tests = skip_long_running_tests
Andrew Walbrane1fa70b2020-05-28 11:30:11 +0100771 self.force_long_running = force_long_running
J-Alves67c31912023-02-02 13:52:50 +0000772 self.debug = debug
773 self.show_output = show_output
David Brazdil2df24082019-09-05 11:55:08 +0100774
775 self.suite_re = re.compile(suite_regex or ".*")
776 self.test_re = re.compile(test_regex or ".*")
777
778 def extract_hftest_lines(self, raw):
779 """Extract hftest-specific lines from a raw output from an invocation
780 of the test platform."""
781 lines = []
J-Alves07be7bb2021-04-13 11:09:12 +0100782 lines_to_process = raw.splitlines()
783
784 try:
785 # If logs have logs of more than one VM, the loop below to extract
786 # lines won't work. Thus, extracting between starting and ending
787 # logs: HFTEST_CTRL_GET_COMMAND_LINE and HFTEST_CTRL_FINISHED.
788 hftest_start = lines_to_process.index(HFTEST_CTRL_GET_COMMAND_LINE) + 1
789 hftest_end = lines_to_process.index(HFTEST_CTRL_FINISHED)
790 except ValueError:
791 hftest_start = 0
792 hftest_end = len(lines_to_process)
793
794 lines_to_process = lines_to_process[hftest_start : hftest_end]
795
796 for line in lines_to_process:
Karl Meakin6f1f1212024-07-16 10:18:16 +0100797 match = HFTEST_CTRL_JSON_REGEX.search(line)
J-Alves3dbb8562020-12-01 10:45:37 +0000798 if match is not None:
799 line = line[match.end():]
David Brazdil2df24082019-09-05 11:55:08 +0100800 if line.startswith(HFTEST_LOG_PREFIX):
801 lines.append(line[len(HFTEST_LOG_PREFIX):])
802 return lines
803
804 def get_test_json(self):
805 """Invoke the test platform and request a JSON of available test and
806 test suites."""
Andrew Walbrane1fa70b2020-05-28 11:30:11 +0100807 out = self.driver.run("json", "json", self.force_long_running)
Daniel Boulby61049dc2023-06-16 14:15:21 +0100808 hf_out = self.extract_hftest_lines(out)
Karl Meakinc7a38482024-07-15 10:29:11 +0100809 try:
810 hf_out = hf_out[hf_out.index(HFTEST_CTRL_JSON_START) + 1
Daniel Boulby61049dc2023-06-16 14:15:21 +0100811 :hf_out.index(HFTEST_CTRL_JSON_END)];
Karl Meakinc7a38482024-07-15 10:29:11 +0100812 except ValueError as e:
813 print("Unable to find JSON control string:")
814 print(f"out={out}")
815 print(f"hf_out={hf_out}")
816 raise e
817
Daniel Boulby61049dc2023-06-16 14:15:21 +0100818 hf_out = "\n".join(hf_out)
David Brazdil2df24082019-09-05 11:55:08 +0100819 try:
820 return json.loads(hf_out)
821 except ValueError as e:
Karl Meakinc7a38482024-07-15 10:29:11 +0100822 print("Unable to parse JSON:")
823 print(f"out={out}")
824 print(f"hf_out={hf_outout}")
David Brazdil2df24082019-09-05 11:55:08 +0100825 print(out)
826 raise e
827
828 def collect_results(self, fn, it, xml_node):
829 """Run `fn` on every entry in `it` and collect their TestRunnerResults.
830 Insert "tests" and "failures" nodes to `xml_node`."""
831 tests_run = 0
832 tests_failed = 0
Andrew Walbranf9463922020-06-05 16:44:42 +0100833 tests_skipped = 0
Andrew Walbran42bf2842020-06-05 18:50:19 +0100834 start_time = time.perf_counter()
David Brazdil2df24082019-09-05 11:55:08 +0100835 for i in it:
836 sub_result = fn(i)
837 assert(sub_result.tests_run >= sub_result.tests_failed)
838 tests_run += sub_result.tests_run
839 tests_failed += sub_result.tests_failed
Andrew Walbranf9463922020-06-05 16:44:42 +0100840 tests_skipped += sub_result.tests_skipped
Andrew Walbran42bf2842020-06-05 18:50:19 +0100841 elapsed_time = time.perf_counter() - start_time
David Brazdil2df24082019-09-05 11:55:08 +0100842
Andrew Walbranf9463922020-06-05 16:44:42 +0100843 xml_node.set("tests", str(tests_run + tests_skipped))
David Brazdil2df24082019-09-05 11:55:08 +0100844 xml_node.set("failures", str(tests_failed))
Andrew Walbranf9463922020-06-05 16:44:42 +0100845 xml_node.set("skipped", str(tests_skipped))
Andrew Walbran42bf2842020-06-05 18:50:19 +0100846 xml_node.set("time", str(elapsed_time))
Andrew Walbranf9463922020-06-05 16:44:42 +0100847 return TestRunnerResult(tests_run, tests_failed, tests_skipped)
David Brazdil2df24082019-09-05 11:55:08 +0100848
849 def is_passed_test(self, test_out):
850 """Parse the output of a test and return True if it passed."""
851 return \
852 len(test_out) > 0 and \
853 test_out[-1] == HFTEST_LOG_FINISHED and \
854 not any(l.startswith(HFTEST_LOG_FAILURE_PREFIX) for l in test_out)
855
Andrew Walbranf9463922020-06-05 16:44:42 +0100856 def get_failure_message(self, test_out):
857 """Parse the output of a test and return the message of the first
858 assertion failure."""
859 for i, line in enumerate(test_out):
860 if line.startswith(HFTEST_LOG_FAILURE_PREFIX) and i + 1 < len(test_out):
861 # The assertion message is on the line after the 'Failure:'
862 return test_out[i + 1].strip()
863
864 return None
865
Fuad Tabba36c8c2b2019-11-04 16:55:32 +0000866 def get_log_name(self, suite, test):
867 """Returns a string with a generated log name for the test."""
868 log_name = ""
869
870 cpu = self.driver.args.cpu
871 if cpu:
872 log_name += cpu + "."
873
874 log_name += suite["name"] + "." + test["name"]
875
876 return log_name
877
David Brazdil2df24082019-09-05 11:55:08 +0100878 def run_test(self, suite, test, suite_xml):
879 """Invoke the test platform and request to run a given `test` in given
880 `suite`. Create a new XML node with results under `suite_xml`.
881 Test only invoked if it matches the regex given to constructor."""
David Brazdil3cc24aa2019-09-27 10:24:41 +0100882 if not self.test_re.match(test["name"]):
Andrew Walbranf9463922020-06-05 16:44:42 +0100883 return TestRunnerResult(tests_run=0, tests_failed=0, tests_skipped=0)
David Brazdil2df24082019-09-05 11:55:08 +0100884
885 test_xml = ET.SubElement(suite_xml, "testcase")
David Brazdil3cc24aa2019-09-27 10:24:41 +0100886 test_xml.set("name", test["name"])
887 test_xml.set("classname", suite["name"])
Andrew Walbranf9463922020-06-05 16:44:42 +0100888
J-Alvesd459b562022-12-05 14:56:33 +0000889 if (self.skip_long_running_tests and test["is_long_running"]) or test["skip_test"]:
Andrew Walbranf9463922020-06-05 16:44:42 +0100890 print(" SKIP", test["name"])
891 test_xml.set("status", "notrun")
892 skipped_xml = ET.SubElement(test_xml, "skipped")
893 skipped_xml.set("message", "Long running")
894 return TestRunnerResult(tests_run=0, tests_failed=0, tests_skipped=1)
895
J-Alves67c31912023-02-02 13:52:50 +0000896 action_log = "DEBUG" if self.debug else "RUN"
897 print(f" {action_log}", test["name"])
Andrew Walbranf9463922020-06-05 16:44:42 +0100898 log_name = self.get_log_name(suite, test)
899
David Brazdil2df24082019-09-05 11:55:08 +0100900 test_xml.set("status", "run")
901
Andrew Walbran42bf2842020-06-05 18:50:19 +0100902 start_time = time.perf_counter()
Andrew Walbranf9463922020-06-05 16:44:42 +0100903 out = self.driver.run(
David Brazdil3cc24aa2019-09-27 10:24:41 +0100904 log_name, "run {} {}".format(suite["name"], test["name"]),
J-Alves67c31912023-02-02 13:52:50 +0000905 test["is_long_running"] or self.force_long_running,
906 self.debug, self.show_output)
907
Andrew Walbranf9463922020-06-05 16:44:42 +0100908 hftest_out = self.extract_hftest_lines(out)
Andrew Walbran42bf2842020-06-05 18:50:19 +0100909 elapsed_time = time.perf_counter() - start_time
910
911 test_xml.set("time", str(elapsed_time))
David Brazdil2df24082019-09-05 11:55:08 +0100912
Andrew Walbranf9463922020-06-05 16:44:42 +0100913 system_out_xml = ET.SubElement(test_xml, "system-out")
914 system_out_xml.text = out
915
916 if self.is_passed_test(hftest_out):
David Brazdil2df24082019-09-05 11:55:08 +0100917 print(" PASS")
Andrew Walbranf9463922020-06-05 16:44:42 +0100918 return TestRunnerResult(tests_run=1, tests_failed=0, tests_skipped=0)
David Brazdil2df24082019-09-05 11:55:08 +0100919 else:
David Brazdil623b6812019-09-09 11:41:08 +0100920 print("[x] FAIL --", self.driver.get_run_log(log_name))
David Brazdil2df24082019-09-05 11:55:08 +0100921 failure_xml = ET.SubElement(test_xml, "failure")
Andrew Walbranf9463922020-06-05 16:44:42 +0100922 failure_message = self.get_failure_message(hftest_out) or "Test failed"
923 failure_xml.set("message", failure_message)
924 failure_xml.text = '\n'.join(hftest_out)
925 return TestRunnerResult(tests_run=1, tests_failed=1, tests_skipped=0)
David Brazdil2df24082019-09-05 11:55:08 +0100926
927 def run_suite(self, suite, xml):
928 """Invoke the test platform and request to run all matching tests in
929 `suite`. Create new XML nodes with results under `xml`.
930 Suite skipped if it does not match the regex given to constructor."""
931 if not self.suite_re.match(suite["name"]):
Andrew Walbranf9463922020-06-05 16:44:42 +0100932 return TestRunnerResult(tests_run=0, tests_failed=0, tests_skipped=0)
David Brazdil2df24082019-09-05 11:55:08 +0100933
934 print(" SUITE", suite["name"])
935 suite_xml = ET.SubElement(xml, "testsuite")
936 suite_xml.set("name", suite["name"])
Andrew Walbran16ae62e2020-06-05 18:27:46 +0100937 properties_xml = ET.SubElement(suite_xml, "properties")
938
939 property_xml = ET.SubElement(properties_xml, "property")
940 property_xml.set("name", "driver")
941 property_xml.set("value", type(self.driver).__name__)
942
943 if self.driver.args.cpu:
944 property_xml = ET.SubElement(properties_xml, "property")
945 property_xml.set("name", "cpu")
946 property_xml.set("value", self.driver.args.cpu)
David Brazdil2df24082019-09-05 11:55:08 +0100947
948 return self.collect_results(
949 lambda test: self.run_test(suite, test, suite_xml),
950 suite["tests"],
951 suite_xml)
952
953 def run_tests(self):
954 """Run all suites and tests matching regexes given to constructor.
955 Write results to sponge log XML. Return the number of run and failed
956 tests."""
957
958 test_spec = self.get_test_json()
959 timestamp = datetime.datetime.now().replace(microsecond=0).isoformat()
960
961 xml = ET.Element("testsuites")
J-Alves8cc7dbb2021-04-16 10:38:48 +0100962 xml.set("name", self.test_set_up)
David Brazdil2df24082019-09-05 11:55:08 +0100963 xml.set("timestamp", timestamp)
964
965 result = self.collect_results(
966 lambda suite: self.run_suite(suite, xml),
967 test_spec["suites"],
968 xml)
969
970 # Write XML to file.
David Brazdilee5e25d2020-01-24 14:17:45 +0000971 ET.ElementTree(xml).write(self.artifacts.sponge_xml_path,
972 encoding='utf-8', xml_declaration=True)
David Brazdil2df24082019-09-05 11:55:08 +0100973
974 if result.tests_failed > 0:
975 print("[x] FAIL:", result.tests_failed, "of", result.tests_run,
976 "tests failed")
977 elif result.tests_run > 0:
978 print(" PASS: all", result.tests_run, "tests passed")
979
David Brazdil94fd1e92020-02-03 16:45:20 +0000980 # Let the driver clean up.
981 self.driver.finish()
982
David Brazdil2df24082019-09-05 11:55:08 +0100983 return result
Andrew Scullbc7189d2018-08-14 09:35:13 +0100984
Andrew Scullbc7189d2018-08-14 09:35:13 +0100985def Main():
986 parser = argparse.ArgumentParser()
J-Alves8cc7dbb2021-04-16 10:38:48 +0100987 parser.add_argument("--hypervisor")
988 parser.add_argument("--spmc")
Shruti Gupta2b1e0cd2022-12-20 17:45:24 +0000989 parser.add_argument("--el3_spmc", action="store_true")
Andrew Scull23e93a82018-10-26 14:56:04 +0100990 parser.add_argument("--log", required=True)
Andrew Walbran7559fcf2019-05-09 17:11:20 +0100991 parser.add_argument("--out_initrd")
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100992 parser.add_argument("--out_partitions")
Andrew Scull7fd4bb72018-12-08 23:40:12 +0000993 parser.add_argument("--initrd")
Olivier Depreza6d2e6d2020-11-06 18:09:50 +0100994 parser.add_argument("--partitions_json")
Andrew Scullbc7189d2018-08-14 09:35:13 +0100995 parser.add_argument("--suite")
996 parser.add_argument("--test")
Andrew Walbranbc342d42019-02-05 16:56:02 +0000997 parser.add_argument("--vm_args")
David Brazdil17e76652020-01-29 14:44:19 +0000998 parser.add_argument("--driver", default="qemu")
999 parser.add_argument("--serial-dev", default="/dev/ttyUSB0")
1000 parser.add_argument("--serial-baudrate", type=int, default=115200)
David Brazdild8013f92020-02-03 16:40:25 +00001001 parser.add_argument("--serial-no-init-wait", action="store_true")
David Brazdil3cc24aa2019-09-27 10:24:41 +01001002 parser.add_argument("--skip-long-running-tests", action="store_true")
Andrew Walbrane1fa70b2020-05-28 11:30:11 +01001003 parser.add_argument("--force-long-running", action="store_true")
J-Alves67c31912023-02-02 13:52:50 +00001004 parser.add_argument("--debug", action="store_true",
1005 help="Makes platforms stall waiting for debugger connection.")
1006 parser.add_argument("--show-output", action="store_true")
Fuad Tabba36c8c2b2019-11-04 16:55:32 +00001007 parser.add_argument("--cpu",
1008 help="Selects the CPU configuration for the run environment.")
Andrew Walbranf636b842020-01-10 11:46:12 +00001009 parser.add_argument("--tfa", action="store_true")
Saul Romero42a13632022-12-20 15:13:36 +00001010 parser.add_argument("--coverage_plugin", default="")
J-Alvesff651e32024-07-23 13:34:56 +01001011 parser.add_argument("--disable_visualisation", action="store_true")
Andrew Scullbc7189d2018-08-14 09:35:13 +01001012 args = parser.parse_args()
David Brazdil2df24082019-09-05 11:55:08 +01001013
J-Alves8cc7dbb2021-04-16 10:38:48 +01001014 # Create class which will manage all test artifacts.
1015 if args.hypervisor and args.spmc:
1016 test_set_up = "hypervisor_and_spmc"
1017 elif args.hypervisor:
1018 test_set_up = "hypervisor"
1019 elif args.spmc:
1020 test_set_up = "spmc"
Shruti Gupta2b1e0cd2022-12-20 17:45:24 +00001021 elif args.el3_spmc:
1022 test_set_up = "el3_spmc"
J-Alves8cc7dbb2021-04-16 10:38:48 +01001023 else:
1024 raise Exception("No Hafnium image provided!\n")
Olivier Depreza6d2e6d2020-11-06 18:09:50 +01001025
J-Alves8cc7dbb2021-04-16 10:38:48 +01001026 initrd = None
1027 if args.hypervisor and args.initrd:
David Brazdil0dbb41f2019-09-09 18:03:35 +01001028 initrd_dir = os.path.join(args.out_initrd, "obj", args.initrd)
1029 initrd = os.path.join(initrd_dir, "initrd.img")
J-Alves8cc7dbb2021-04-16 10:38:48 +01001030 test_set_up += "_" + args.initrd
Andrew Walbranbc342d42019-02-05 16:56:02 +00001031 vm_args = args.vm_args or ""
David Brazdil2df24082019-09-05 11:55:08 +01001032
Olivier Depreza6d2e6d2020-11-06 18:09:50 +01001033 partitions = None
J-Alves6acc5372024-09-11 17:30:11 +01001034 global_run_name = "arch"
J-Alves18a25f92021-05-04 17:47:41 +01001035 if args.driver == "fvp":
1036 if args.partitions_json is not None:
1037 partitions_dir = os.path.join(
1038 args.out_partitions, "obj", args.partitions_json)
1039 partitions = json.load(open(partitions_dir, "r"))
1040 global_run_name = os.path.basename(args.partitions_json).split(".")[0]
1041 elif args.hypervisor:
1042 if args.initrd:
1043 global_run_name = os.path.basename(args.initrd)
1044 else:
1045 global_run_name = os.path.basename(args.hypervisor).split(".")[0]
Olivier Depreza6d2e6d2020-11-06 18:09:50 +01001046
David Brazdil2df24082019-09-05 11:55:08 +01001047 # Create class which will manage all test artifacts.
J-Alves6acc5372024-09-11 17:30:11 +01001048 log_dir = os.path.join(os.path.join(args.log, test_set_up), global_run_name)
Olivier Depreza6d2e6d2020-11-06 18:09:50 +01001049 artifacts = ArtifactsManager(log_dir)
David Brazdil2df24082019-09-05 11:55:08 +01001050
1051 # Create a driver for the platform we want to test on.
J-Alves8cc7dbb2021-04-16 10:38:48 +01001052 driver_args = DriverArgs(artifacts, args.hypervisor, args.spmc, initrd,
Saul Romero42a13632022-12-20 15:13:36 +00001053 vm_args, args.cpu, partitions, global_run_name,
J-Alvesff651e32024-07-23 13:34:56 +01001054 args.coverage_plugin, args.disable_visualisation)
David Brazdil17e76652020-01-29 14:44:19 +00001055
Shruti Gupta2b1e0cd2022-12-20 17:45:24 +00001056 if args.el3_spmc:
J-Alves38223dd2021-04-20 17:31:48 +01001057 # So far only FVP supports tests for SPMC.
Olivier Depreza6d2e6d2020-11-06 18:09:50 +01001058 if args.driver != "fvp":
1059 raise Exception("Secure tests can only run with fvp driver")
Shruti Gupta22dbef32023-04-03 10:26:31 +01001060 if args.hypervisor:
1061 driver = FvpDriverEL3SPMCBothWorlds(driver_args)
1062 else:
1063 driver = FvpDriverEL3SPMC(driver_args)
Shruti Gupta2b1e0cd2022-12-20 17:45:24 +00001064 elif args.spmc:
1065 # So far only FVP supports tests for SPMC.
1066 if args.driver != "fvp":
1067 raise Exception("Secure tests can only run with fvp driver")
J-Alves38223dd2021-04-20 17:31:48 +01001068 if args.hypervisor:
1069 driver = FvpDriverBothWorlds(driver_args)
1070 else:
1071 driver = FvpDriverSPMC(driver_args)
J-Alves8cc7dbb2021-04-16 10:38:48 +01001072 elif args.hypervisor:
Olivier Depreza6d2e6d2020-11-06 18:09:50 +01001073 if args.driver == "qemu":
J-Alves8cc7dbb2021-04-16 10:38:48 +01001074 out = os.path.dirname(args.hypervisor)
1075 driver = QemuDriver(driver_args, out, args.tfa)
Olivier Depreza6d2e6d2020-11-06 18:09:50 +01001076 elif args.driver == "fvp":
1077 driver = FvpDriverHypervisor(driver_args)
1078 elif args.driver == "serial":
1079 driver = SerialDriver(driver_args, args.serial_dev,
1080 args.serial_baudrate, not args.serial_no_init_wait)
1081 else:
1082 raise Exception("Unknown driver name: {}".format(args.driver))
J-Alves8cc7dbb2021-04-16 10:38:48 +01001083 else:
1084 raise Exception("No Hafnium image provided!\n")
David Brazdil2df24082019-09-05 11:55:08 +01001085
1086 # Create class which will drive test execution.
J-Alves8cc7dbb2021-04-16 10:38:48 +01001087 runner = TestRunner(artifacts, driver, test_set_up, args.suite, args.test,
J-Alves67c31912023-02-02 13:52:50 +00001088 args.skip_long_running_tests, args.force_long_running, args.debug, args.show_output)
David Brazdil2df24082019-09-05 11:55:08 +01001089
1090 # Run tests.
1091 runner_result = runner.run_tests()
1092
1093 # Print error message if no tests were run as this is probably unexpected.
1094 # Return suitable error code.
1095 if runner_result.tests_run == 0:
Andrew Scullbc7189d2018-08-14 09:35:13 +01001096 print("Error: no tests match")
1097 return 10
David Brazdil2df24082019-09-05 11:55:08 +01001098 elif runner_result.tests_failed > 0:
Andrew Scullbc7189d2018-08-14 09:35:13 +01001099 return 1
1100 else:
David Brazdil2df24082019-09-05 11:55:08 +01001101 return 0
Andrew Scullbc7189d2018-08-14 09:35:13 +01001102
1103if __name__ == "__main__":
1104 sys.exit(Main())