blob: 1f0420bd0d3975522a67c94356fb2afdd044bbf8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
import os
import stat
from .executable import Executable
class FTcat(Executable):
'''Used to wrap the ftcat binary in the Experiment object.'''
def __init__(self, ft_cat_bin, stdout_file, stderr_file, dev, events, cpu=None):
'''Extends the Executable initializer method with ftcat attributes.'''
super(FTcat, self).__init__('/usr/bin/taskset')
self.stdout_file = stdout_file
self.stderr_file = stderr_file
mode = os.stat(dev)[stat.ST_MODE]
if not mode & stat.S_IFCHR:
raise Exception("%s is not a character device" % dev)
if events is None:
raise Exception('No events!')
if cpu is not None:
# Execute only on the given CPU
self.extra_args = ['-c', str(cpu)]
else:
# Execute on any cpu
self.extra_args = ['0xFFFFFFFF']
events_str_arr = map(str, events)
ft_cat_cmd = [ft_cat_bin, dev] + list(events_str_arr)
self.extra_args.extend(ft_cat_cmd)
|