From 09bc409657606a37346d82ab1e4c44a165bd3541 Mon Sep 17 00:00:00 2001 From: Jonathan Herman Date: Fri, 12 Apr 2013 11:30:27 -0400 Subject: Improved error handling in run_exps.py. --- run/litmus_util.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'run/litmus_util.py') diff --git a/run/litmus_util.py b/run/litmus_util.py index 4709b66..70da262 100644 --- a/run/litmus_util.py +++ b/run/litmus_util.py @@ -3,6 +3,11 @@ import time import subprocess import config.config as conf +def scheduler(): + with open('/proc/litmus/active_plugin', 'r') as active_plugin: + cur_plugin = active_plugin.read().strip() + return cur_plugin + def switch_scheduler(switch_to_in): '''Switch the scheduler to whatever is passed in. @@ -18,11 +23,10 @@ def switch_scheduler(switch_to_in): # it takes a bit to do the switch, sleep an arbitrary amount of time time.sleep(2) - with open('/proc/litmus/active_plugin', 'r') as active_plugin: - cur_plugin = active_plugin.read().strip() - + cur_plugin = scheduler() if switch_to != cur_plugin: - raise Exception("Could not switch to '%s' (check dmesg)" % switch_to) + raise Exception("Could not switch to '%s' (check dmesg), current: %s" %\ + (switch_to, cur_plugin)) def waiting_tasks(): reg = re.compile(r'^ready.*?(?P\d+)$', re.M) @@ -35,6 +39,17 @@ def waiting_tasks(): return 0 if not ready else int(ready) +def all_tasks(): + reg = re.compile(r'^real-time.*?(?P\d+)$', re.M) + with open('/proc/litmus/stats', 'r') as f: + data = f.read() + + # Ignore if no tasks are waiting for release + match = re.search(reg, data) + ready = match.group("TASKS") + + return 0 if not ready else int(ready) + def release_tasks(): try: data = subprocess.check_output([conf.BINS['release']]) -- cgit v1.2.2