summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xruntest27
1 files changed, 27 insertions, 0 deletions
diff --git a/runtest b/runtest
index 827eb3b..cfc61d4 100755
--- a/runtest
+++ b/runtest
@@ -64,9 +64,24 @@ class Monitor(object):
subprocess.Popen(self.execute, shell=True,
stdout=self.logfile)
+class Watcher(object):
+ def __init__(self, prefix, name, execute):
+ stem = '%s-%s' % (prefix, name)
+ self.logfile = open(stem + '.data', 'a')
+ self.execute = execute
+ def __del__(self):
+ print('', file=self.logfile)
+ self.logfile.close()
+ def start(self):
+ self.proc = subprocess.Popen(self.execute, shell=True,
+ stdout=self.logfile)
+ def stop(self):
+ self.proc.terminate()
+
defs = {}
works = {}
monitors = []
+watchers = []
def collect():
for m in monitors:
@@ -75,6 +90,14 @@ def collect():
def sigalrm_handler(sig, frame):
collect()
+def watchers_start():
+ for w in watchers:
+ w.start()
+
+def watchers_stop():
+ for w in watchers:
+ w.stop()
+
parser = argparse.ArgumentParser()
parser.add_argument('-s', '--spec', action='append', default=[])
parser.add_argument('-o', '--oneshot', action='store_true')
@@ -84,6 +107,8 @@ args = parser.parse_args()
def save_section(type_, name, body):
if type_ == 'monitor':
monitors.append(Monitor(args.name, name, body))
+ elif type_ == 'watcher':
+ watchers.append(Watcher(args.name, name, body))
else:
work = works.get(name)
if not work:
@@ -144,6 +169,7 @@ collect()
if not args.oneshot:
signal.signal(signal.SIGALRM, sigalrm_handler)
signal.setitimer(signal.ITIMER_REAL, 1.0, 1.0)
+ watchers_start()
workers = {}
noreap = []
@@ -173,6 +199,7 @@ while workers:
if not args.oneshot:
signal.setitimer(signal.ITIMER_REAL, 0.0, 0.0)
+ watchers_stop()
collect()