aboutsummaryrefslogtreecommitdiffstats
path: root/run/litmus_util.py
diff options
context:
space:
mode:
Diffstat (limited to 'run/litmus_util.py')
-rw-r--r--run/litmus_util.py50
1 files changed, 0 insertions, 50 deletions
diff --git a/run/litmus_util.py b/run/litmus_util.py
index 8a7f87d..b9080c1 100644
--- a/run/litmus_util.py
+++ b/run/litmus_util.py
@@ -1,43 +1,8 @@
1import re 1import re
2import time 2import time
3import subprocess 3import subprocess
4import os
5import stat
6import config.config as conf 4import config.config as conf
7 5
8def num_cpus():
9 '''Return the number of CPUs in the system.'''
10
11 lnx_re = re.compile(r'^(processor|online)')
12 cpus = 0
13
14 with open('/proc/cpuinfo', 'r') as f:
15 for line in f:
16 if lnx_re.match(line):
17 cpus += 1
18 return cpus
19
20def ft_freq():
21 umachine = subprocess.check_output(["uname", "-m"])
22
23 if re.match("armv7", umachine):
24 # Arm V7s use a millisecond timer
25 freq = 1000.0
26 elif re.match("x86", umachine):
27 # X86 timer is equal to processor clock
28 reg = re.compile(r'^cpu MHz\s*:\s*(?P<FREQ>\d+)', re.M)
29 with open('/proc/cpuinfo', 'r') as f:
30 data = f.read()
31
32 match = re.search(reg, data)
33 if not match:
34 raise Exception("Cannot parse CPU frequency from x86 CPU!")
35 freq = int(match.group('FREQ'))
36 else:
37 # You're on your own
38 freq = 0
39 return freq
40
41def switch_scheduler(switch_to_in): 6def switch_scheduler(switch_to_in):
42 '''Switch the scheduler to whatever is passed in. 7 '''Switch the scheduler to whatever is passed in.
43 8
@@ -60,21 +25,6 @@ def switch_scheduler(switch_to_in):
60 if switch_to != cur_plugin: 25 if switch_to != cur_plugin:
61 raise Exception("Could not switch to plugin: %s" % switch_to) 26 raise Exception("Could not switch to plugin: %s" % switch_to)
62 27
63def uname_matches(reg):
64 data = subprocess.check_output(["uname", "-r"])
65 return bool( re.match(reg, data) )
66
67def is_executable(fname):
68 '''Return whether the file passed in is executable'''
69 mode = os.stat(fname)[stat.ST_MODE]
70 return mode & stat.S_IXUSR and mode & stat.S_IRUSR
71
72def is_device(dev):
73 if not os.path.exists(dev):
74 return False
75 mode = os.stat(dev)[stat.ST_MODE]
76 return not (not mode & stat.S_IFCHR)
77
78def waiting_tasks(): 28def waiting_tasks():
79 reg = re.compile(r'^ready.*?(?P<READY>\d+)$', re.M) 29 reg = re.compile(r'^ready.*?(?P<READY>\d+)$', re.M)
80 with open('/proc/litmus/stats', 'r') as f: 30 with open('/proc/litmus/stats', 'r') as f: