1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
"""TOSA test runner module for the Reference Model."""
# Copyright (c) 2020-2022, ARM Limited.
# SPDX-License-Identifier: Apache-2.0
from enum import IntEnum
from enum import unique
from runner.run_command import run_sh_command
from runner.run_command import RunShCommandError
from runner.tosa_test_runner import TosaTestRunner
@unique
class TosaRefReturnCode(IntEnum):
"""Return codes from the Tosa Reference Model."""
VALID = 0
UNPREDICTABLE = 1
ERROR = 2
class TosaSUTRunner(TosaTestRunner):
"""TOSA Reference Model runner."""
def __init__(self, args, runnerArgs, testDirPath):
"""Initialize using the given test details."""
super().__init__(args, runnerArgs, testDirPath)
def runTestGraph(self):
"""Run the test on the reference model."""
# Build up the TOSA reference command line
# Uses arguments from the argParser args, not the runnerArgs
args = self.args
# Call Reference model with description file to provide all file details
cmd = [
args.ref_model_path,
"--operator_fbs={}".format(args.operator_fbs),
"--test_desc={}".format(self.descFile),
]
# Specific debug options for reference model
if args.ref_debug:
cmd.extend(["-d", "ALL", "-l", args.ref_debug])
if args.ref_intermediates:
cmd.extend(["--dump_intermediates", str(args.ref_intermediates)])
# Run command and interpret tosa graph result via process return codes
graphMessage = None
try:
run_sh_command(cmd, self.args.verbose, capture_output=True)
graphResult = TosaTestRunner.TosaGraphResult.TOSA_VALID
except RunShCommandError as e:
graphMessage = e.stderr
if e.return_code == TosaRefReturnCode.ERROR:
graphResult = TosaTestRunner.TosaGraphResult.TOSA_ERROR
elif e.return_code == TosaRefReturnCode.UNPREDICTABLE:
graphResult = TosaTestRunner.TosaGraphResult.TOSA_UNPREDICTABLE
else:
graphResult = TosaTestRunner.TosaGraphResult.OTHER_ERROR
if not self.args.verbose:
print(e)
except Exception as e:
print(e)
graphMessage = str(e)
graphResult = TosaTestRunner.TosaGraphResult.OTHER_ERROR
# Return graph result and message
return graphResult, graphMessage
|