def define_constants(constants): ''' 'constants' are values not directly exposed by the config, but are attached to the object for centralized access. These should be used for setting common string names used across the test framework. A simple typo in a string can take a lot of debugging to uncover the issue, attribute errors are easier to notice and most autocompletion systems detect them. ''' constants.pickle_protocol = highest_pickle_protocol # The root directory which all test names will be based off of. constants.testing_base = absdirpath( os.path.join(absdirpath(__file__), os.pardir))
def path_as_testsuite(filepath, *args, **kwargs): ''' Return the given filepath as a testsuite. The testsuite will be named after the containing directory of the file. ''' return TestSuite(os.path.split(absdirpath(filepath))[-1], *args, **kwargs)
def define_defaults(defaults): ''' Defaults are provided by the config if the attribute is not found in the config or commandline. For instance, if we are using the list command fixtures might not be able to count on the build_dir being provided since we aren't going to build anything. ''' defaults.base_dir = os.path.abspath( os.path.join(absdirpath(__file__), os.pardir, os.pardir)) defaults.result_path = os.path.join(os.getcwd(), '.testing-results') defaults.list_only_failed = False
def uid(testitem, class_name=None): ''' The generic function used to produce uid of test objects. ''' # Trim the file path to be the path relative to the parent of this # directory. filepath = testitem.path filepath = os.path.relpath( filepath, os.path.commonprefix((absdirpath(__file__), filepath))) fmt = '{file}:{class_}:{name}' if class_name is None: class_name = testitem.__class__.__name__ return fmt.format(file=filepath, name=testitem.name, class_=class_name)
def define_constants(constants): ''' 'constants' are values not directly exposed by the config, but are attached to the object for centralized access. These should be used for setting common string names used across the test framework. A simple typo in a string can take a lot of debugging to uncover the issue, attribute errors are easier to notice and most autocompletion systems detect them. ''' constants.system_out_name = 'system-out' constants.system_err_name = 'system-err' constants.isa_tag_type = 'isa' constants.x86_tag = 'X86' constants.sparc_tag = 'SPARC' constants.alpha_tag = 'ALPHA' constants.riscv_tag = 'RISCV' constants.arm_tag = 'ARM' constants.mips_tag = 'MIPS' constants.power_tag = 'POWER' constants.null_tag = 'NULL' constants.variant_tag_type = 'variant' constants.opt_tag = 'opt' constants.debug_tag = 'debug' constants.fast_tag = 'fast' constants.length_tag_type = 'length' constants.quick_tag = 'quick' constants.long_tag = 'long' constants.supported_tags = { constants.isa_tag_type: ( constants.x86_tag, constants.sparc_tag, constants.alpha_tag, constants.riscv_tag, constants.arm_tag, constants.mips_tag, constants.power_tag, constants.null_tag, ), constants.variant_tag_type: ( constants.opt_tag, constants.debug_tag, constants.fast_tag, ), constants.length_tag_type: ( constants.quick_tag, constants.long_tag, ), } constants.supported_isas = constants.supported_tags['isa'] constants.supported_variants = constants.supported_tags['variant'] constants.supported_lengths = constants.supported_tags['length'] constants.tempdir_fixture_name = 'tempdir' constants.gem5_simulation_stderr = 'simerr' constants.gem5_simulation_stdout = 'simout' constants.gem5_simulation_stats = 'stats.txt' constants.gem5_simulation_config_ini = 'config.ini' constants.gem5_simulation_config_json = 'config.json' constants.gem5_returncode_fixture_name = 'gem5-returncode' constants.gem5_binary_fixture_name = 'gem5' constants.xml_filename = 'results.xml' constants.pickle_filename = 'results.pickle' constants.pickle_protocol = highest_pickle_protocol # The root directory which all test names will be based off of. constants.testing_base = absdirpath( os.path.join(absdirpath(__file__), os.pardir))
val = self.lookup_attr(attr) if val is not None: return val[0] else: raise AttributeError('Could not find %s config value' % attr) config = _Config() # Defaults are provided by the config if the attribute is not found in the # config or commandline. For instance, if we are using the list command # fixtures might not be able to count on the build_dir being provided since we # aren't going to build anything. _defaults = config._defaults constants = config.constants _defaults.base_dir = os.path.abspath( os.path.join(absdirpath(__file__), os.pardir, os.pardir)) _defaults.result_path = os.path.join(os.getcwd(), '.testing-results') _defaults.list_only_failed = False def set_default_build_dir(build_dir): ''' Post-processor to set the default build_dir based on the base_dir. .. seealso :func:`~_Config.add_post_processor` for a description on this callback format. ''' if not build_dir\ or build_dir[0] is None: base_dir = config.lookup_attr('base_dir')[0] build_dir = (os.path.join(base_dir, 'build'), )