blob: 098f39b1903c2a4e7b5bf58632a10da6a9a7140e [file] [log] [blame]
Eric Kunzee5e26762020-10-13 16:11:07 -07001import os
2
Jared Smolens2a76ad22021-03-04 11:18:54 -08003# Copyright (c) 2020-2021, ARM Limited.
Eric Kunzee5e26762020-10-13 16:11:07 -07004#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
Kevin Chengcd79f0e2021-06-03 15:00:34 -070017import os
Eric Kunzee5e26762020-10-13 16:11:07 -070018import json
19import shlex
20import subprocess
21from tosa_test_runner import TosaTestRunner, run_sh_command
22
Kevin Cheng550ccc52021-03-03 11:21:43 -080023
Eric Kunzee5e26762020-10-13 16:11:07 -070024class TosaRefRunner(TosaTestRunner):
25 def __init__(self, args, runnerArgs, testDir):
26 super().__init__(args, runnerArgs, testDir)
27
28 def runModel(self):
29 # Build up the TOSA reference command line
30 # Uses arguments from the argParser args, not the runnerArgs
31 args = self.args
32
Kevin Cheng550ccc52021-03-03 11:21:43 -080033 ref_cmd = [
34 args.ref_model_path,
Kevin Chengcd79f0e2021-06-03 15:00:34 -070035 "-Ctest_desc={}".format(os.path.join(self.testDir, "desc.json")),
Kevin Cheng550ccc52021-03-03 11:21:43 -080036 ]
Eric Kunzee5e26762020-10-13 16:11:07 -070037
Eric Kunzee5e26762020-10-13 16:11:07 -070038 if args.ref_debug:
Kevin Cheng550ccc52021-03-03 11:21:43 -080039 ref_cmd.extend(["-dALL", "-l{}".format(args.ref_debug)])
Eric Kunzee5e26762020-10-13 16:11:07 -070040
41 if args.ref_intermediates:
Kevin Cheng550ccc52021-03-03 11:21:43 -080042 ref_cmd.extend(["-Ddump_intermediates=1"])
Eric Kunzee5e26762020-10-13 16:11:07 -070043
Kevin Cheng550ccc52021-03-03 11:21:43 -080044 expectedFailure = self.testDesc["expected_failure"]
Eric Kunzee5e26762020-10-13 16:11:07 -070045
46 try:
47 run_sh_command(self.args, ref_cmd)
48 if expectedFailure:
49 result = TosaTestRunner.Result.UNEXPECTED_PASS
50 else:
51 result = TosaTestRunner.Result.EXPECTED_PASS
52 except Exception as e:
53 if expectedFailure:
54 result = TosaTestRunner.Result.EXPECTED_FAILURE
55 else:
Jared Smolens2a76ad22021-03-04 11:18:54 -080056 result = TosaTestRunner.Result.UNEXPECTED_FAILURE
Eric Kunzee5e26762020-10-13 16:11:07 -070057
58 return result