Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 1 | import os |
| 2 | |
Jared Smolens | 2a76ad2 | 2021-03-04 11:18:54 -0800 | [diff] [blame] | 3 | # Copyright (c) 2020-2021, ARM Limited. |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 4 | # |
| 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 Cheng | cd79f0e | 2021-06-03 15:00:34 -0700 | [diff] [blame^] | 17 | import os |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 18 | import json |
| 19 | import shlex |
| 20 | import subprocess |
| 21 | from tosa_test_runner import TosaTestRunner, run_sh_command |
| 22 | |
Kevin Cheng | 550ccc5 | 2021-03-03 11:21:43 -0800 | [diff] [blame] | 23 | |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 24 | class 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 Cheng | 550ccc5 | 2021-03-03 11:21:43 -0800 | [diff] [blame] | 33 | ref_cmd = [ |
| 34 | args.ref_model_path, |
Kevin Cheng | cd79f0e | 2021-06-03 15:00:34 -0700 | [diff] [blame^] | 35 | "-Ctest_desc={}".format(os.path.join(self.testDir, "desc.json")), |
Kevin Cheng | 550ccc5 | 2021-03-03 11:21:43 -0800 | [diff] [blame] | 36 | ] |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 37 | |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 38 | if args.ref_debug: |
Kevin Cheng | 550ccc5 | 2021-03-03 11:21:43 -0800 | [diff] [blame] | 39 | ref_cmd.extend(["-dALL", "-l{}".format(args.ref_debug)]) |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 40 | |
| 41 | if args.ref_intermediates: |
Kevin Cheng | 550ccc5 | 2021-03-03 11:21:43 -0800 | [diff] [blame] | 42 | ref_cmd.extend(["-Ddump_intermediates=1"]) |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 43 | |
Kevin Cheng | 550ccc5 | 2021-03-03 11:21:43 -0800 | [diff] [blame] | 44 | expectedFailure = self.testDesc["expected_failure"] |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 45 | |
| 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 Smolens | 2a76ad2 | 2021-03-04 11:18:54 -0800 | [diff] [blame] | 56 | result = TosaTestRunner.Result.UNEXPECTED_FAILURE |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 57 | |
| 58 | return result |