|
| 1 | +import logging |
| 2 | +import os |
| 3 | +import shutil |
| 4 | +import string |
| 5 | +import sys |
| 6 | + |
| 7 | +import riscof.utils as utils |
| 8 | +import riscof.constants as constants |
| 9 | +from riscof.pluginTemplate import pluginTemplate |
| 10 | + |
| 11 | +logger = logging.getLogger() |
| 12 | + |
| 13 | +class rc_reference(pluginTemplate): |
| 14 | + __model__ = "rc_reference" |
| 15 | + __version__ = "0.1.0" |
| 16 | + |
| 17 | + def __init__(self, *args, **kwargs): |
| 18 | + sclass = super().__init__(*args, **kwargs) |
| 19 | + |
| 20 | + config = kwargs.get('config') |
| 21 | + if config is None: |
| 22 | + print("Please enter input file paths in configuration.") |
| 23 | + raise SystemExit |
| 24 | + |
| 25 | + test_suite = os.getenv('RISCV_TEST_SUITE') |
| 26 | + if test_suite is None: |
| 27 | + config_dir = kwargs.get('config_dir') |
| 28 | + test_suite_entry = config.get('riscvTestSuite') |
| 29 | + if test_suite_entry: |
| 30 | + test_suite = utils.absolute_path(config_dir, test_suite_entry) |
| 31 | + else: |
| 32 | + logger.error("Path to reference signature not set. "\ |
| 33 | + "Please set envrionment variable 'RISCV_TEST_SUITE' "\ |
| 34 | + "or config key 'riscvTestSuite'.") |
| 35 | + raise SystemExit |
| 36 | + self.test_suite_path = test_suite |
| 37 | + |
| 38 | + return sclass |
| 39 | + |
| 40 | + def initialise(self, suite, work_dir, compliance_env): |
| 41 | + self.work_dir = work_dir |
| 42 | + |
| 43 | + |
| 44 | + def build(self, isa_yaml, platform_yaml): |
| 45 | + return |
| 46 | + |
| 47 | + def runTests(self, testList): |
| 48 | + for file in testList: |
| 49 | + testentry = testList[file] |
| 50 | + test = os.path.join(constants.root, str(file)) |
| 51 | + test_dir = testentry['work_dir'] |
| 52 | + |
| 53 | + test_name = os.path.splitext(os.path.basename(test))[0] |
| 54 | + |
| 55 | + # Extract the extension of the current test |
| 56 | + tested_extension = os.path.split(os.path.dirname(os.path.dirname(test_dir)))[1] |
| 57 | + |
| 58 | + # Create the path to the reference signature based on the current |
| 59 | + # extension and a known file structure |
| 60 | + ref_sig = os.path.join(self.test_suite_path, tested_extension) |
| 61 | + ref_sig = os.path.join(ref_sig, "references") |
| 62 | + ref_sig = os.path.join(ref_sig, test_name + ".reference_output") |
| 63 | + |
| 64 | + # Output file is stored in the current test output and a fixed file name |
| 65 | + test_sig = os.path.join(test_dir, "Reference-rc_reference.signature") |
| 66 | + |
| 67 | + # Copy reference signature as test signature |
| 68 | + shutil.copyfile(ref_sig, test_sig) |
0 commit comments