fixture.py (13793:3fc62003f9cc) | fixture.py (13851:a71317af0ac2) |
---|---|
1# Copyright (c) 2017 Mark D. Hill and David A. Wood 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are 6# met: redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer; 8# redistributions in binary form must reproduce the above copyright --- 55 unchanged lines hidden (view full) --- 64 ''' 65 Fixture will wait until all SCons targets are collected and tests are 66 about to be ran, then will invocate a single instance of SCons for all 67 targets. 68 69 :param directory: The directory which scons will -C (cd) into before 70 executing. If None is provided, will choose the config base_dir. 71 ''' | 1# Copyright (c) 2017 Mark D. Hill and David A. Wood 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are 6# met: redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer; 8# redistributions in binary form must reproduce the above copyright --- 55 unchanged lines hidden (view full) --- 64 ''' 65 Fixture will wait until all SCons targets are collected and tests are 66 about to be ran, then will invocate a single instance of SCons for all 67 targets. 68 69 :param directory: The directory which scons will -C (cd) into before 70 executing. If None is provided, will choose the config base_dir. 71 ''' |
72 def __init__(self, directory=None, target_class=None): | 72 def __init__(self, directory=None, target_class=None, options=[]): |
73 self.directory = directory if directory else config.base_dir 74 self.target_class = target_class if target_class else SConsTarget 75 self.threads = config.threads 76 self.targets = set() | 73 self.directory = directory if directory else config.base_dir 74 self.target_class = target_class if target_class else SConsTarget 75 self.threads = config.threads 76 self.targets = set() |
77 self.options = options |
|
77 super(SConsFixture, self).__init__() 78 79 def setup(self, testitem): 80 if config.skip_build: 81 return 82 83 command = [ 84 'scons', '-C', self.directory, --- 11 unchanged lines hidden (view full) --- 96 log.test_log.message( 97 'Building the following targets.' 98 ' This may take a while.') 99 log.test_log.message('%s' % (', '.join(self.targets))) 100 log.test_log.message( 101 "You may want to run with only a single ISA" 102 "(--isa=), use --skip-build, or use 'rerun'.") 103 | 78 super(SConsFixture, self).__init__() 79 80 def setup(self, testitem): 81 if config.skip_build: 82 return 83 84 command = [ 85 'scons', '-C', self.directory, --- 11 unchanged lines hidden (view full) --- 97 log.test_log.message( 98 'Building the following targets.' 99 ' This may take a while.') 100 log.test_log.message('%s' % (', '.join(self.targets))) 101 log.test_log.message( 102 "You may want to run with only a single ISA" 103 "(--isa=), use --skip-build, or use 'rerun'.") 104 |
104 105 | |
106 command.extend(self.targets) | 105 command.extend(self.targets) |
106 if self.options: 107 command.extend(self.options) |
|
107 log_call(log.test_log, command) 108 109 110class SConsTarget(Fixture): 111 # The singleton scons fixture we'll use for all targets. 112 default_scons_invocation = None 113 114 def __init__(self, target, build_dir=None, invocation=None): --- 23 unchanged lines hidden (view full) --- 138 invocation = self.default_scons_invocation 139 self.invocation = invocation 140 141 def schedule_finalized(self, schedule): 142 self.invocation.targets.add(self.target) 143 return Fixture.schedule_finalized(self, schedule) 144 145class Gem5Fixture(SConsTarget): | 108 log_call(log.test_log, command) 109 110 111class SConsTarget(Fixture): 112 # The singleton scons fixture we'll use for all targets. 113 default_scons_invocation = None 114 115 def __init__(self, target, build_dir=None, invocation=None): --- 23 unchanged lines hidden (view full) --- 139 invocation = self.default_scons_invocation 140 self.invocation = invocation 141 142 def schedule_finalized(self, schedule): 143 self.invocation.targets.add(self.target) 144 return Fixture.schedule_finalized(self, schedule) 145 146class Gem5Fixture(SConsTarget): |
146 def __init__(self, isa, variant): 147 target = joinpath(isa.upper(), 'gem5.%s' % variant) 148 super(Gem5Fixture, self).__init__(target) | 147 other_invocations = {} # stores scons invocations other than the default |
149 | 148 |
149 def __init__(self, isa, variant, protocol=None): 150 if protocol: 151 # When specifying an non-default protocol, we have to make a 152 # separate scons invocation with specific parameters. However, if 153 # more than one tests needs the same target, we need to make sure 154 # that we don't call scons too many times. 155 target_dir = isa.upper()+'-'+protocol 156 target = joinpath(target_dir, 'gem5.%s' % variant) 157 if target_dir in self.other_invocations.keys(): 158 invocation = self.other_invocations[target_dir] 159 else: 160 options = ['PROTOCOL='+protocol, '--default='+isa.upper()] 161 invocation = SConsFixture(options=options) 162 globalfixture(invocation) 163 Gem5Fixture.other_invocations[target_dir] = invocation 164 else: 165 target = joinpath(isa.upper(), 'gem5.%s' % variant) 166 invocation = None # use default 167 super(Gem5Fixture, self).__init__(target, invocation=invocation) 168 |
|
150 self.name = constants.gem5_binary_fixture_name 151 self.path = self.target 152 self.isa = isa 153 self.variant = variant 154 155 156class MakeFixture(Fixture): 157 def __init__(self, directory, *args, **kwargs): --- 119 unchanged lines hidden --- | 169 self.name = constants.gem5_binary_fixture_name 170 self.path = self.target 171 self.isa = isa 172 self.variant = variant 173 174 175class MakeFixture(Fixture): 176 def __init__(self, directory, *args, **kwargs): --- 119 unchanged lines hidden --- |