6
from lava_dispatcher.downloader import download_image
7
from lava_dispatcher.signals import SignalHandler
10
class ArmProbe(SignalHandler):
12
def __init__(self, testdef_obj, post_process_script, probe_args=None):
13
SignalHandler.__init__(self, testdef_obj)
15
self.scratch_dir = testdef_obj.context.client.target_device.scratch_dir
17
# post_process_script can be local to the repo or a URL
18
if not urlparse.urlparse(post_process_script).scheme:
19
self.post_process_script = os.path.join(
20
testdef_obj.repo, post_process_script)
22
self.post_process_script = download_image(
23
post_process_script, testdef_obj.context, self.scratch_dir)
24
os.chmod(self.post_process_script, 755) # make sure we can execute it
26
# build up the command we'll use for running the probe
27
config = testdef_obj.context.client.config
28
self.aep_channels = config.arm_probe_channels
30
config.arm_probe_binary, '-C', config.arm_probe_config]
31
for c in self.aep_channels:
32
self.aep_args.append('-c')
33
self.aep_args.append(c)
35
for arg in probe_args:
36
self.aep_args.append(arg)
38
def start_testcase(self, test_case_id):
39
ofile = os.path.join(self.scratch_dir, '%s.out' % test_case_id)
40
efile = os.path.join(self.scratch_dir, '%s.err' % test_case_id)
41
ofile = open(ofile, 'w')
42
efile = open(efile, 'w')
44
proc = subprocess.Popen(
45
self.aep_args, stdout=ofile, stderr=efile, stdin=subprocess.PIPE)
46
# The arm-probe-binary allows you to write to stdin via a pipe and
47
# includes the content as comments in the header of its output
49
'# run from lava-test-shell with args: %r' % self.aep_args)
58
def end_testcase(self, test_case_id, data):
59
proc = data['process']
62
def postprocess_test_result(self, test_result, data):
63
tcid = test_result['test_case_id']
64
logging.info('analyzing aep data for %s ...', tcid)
66
lfile = data['logfile']
67
efile = data['errfile']
72
with self._result_as_dir(test_result) as result_dir:
73
args = [self.post_process_script, tcid, lfile.name, efile.name]
74
args.extend(self.aep_channels)
76
if subprocess.call(args, cwd=result_dir) != 0:
77
logging.warn('error calling post_process_script')