run-report: Allow tests to spawn and control their own sessiond
authorChristian Babeux <christian.babeux@efficios.com>
Tue, 18 Dec 2012 21:31:17 +0000 (16:31 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 18 Dec 2012 21:47:58 +0000 (16:47 -0500)
The run-report script can spawn a sessiond if the 'daemon' key value is
set to 'True' in the test description dictionary. If the 'daemon' key is
set to 'False', the TEST_NO_SESSIOND environment variable is set so no
sessiond can be spawned in the tests. This variable is also set when the
run-report spawn its own sessiond.

This behavior has the unfortunate side-effect of restricting any kind of
spawning and control of the sessiond via the tests.

Fix this issue by allowing the tests to spawn their own sessiond. We
need to pass an additional env dictionary to the TestWorker in order to
spawn the test with the proper environment variables set.

To indicate that a test will spawn and manage its own sessiond, the
'daemon' key value should be set to the "test" string.

Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
tests/run-report.py

index 5e8a0cfabe554521053d07fbdfc54ca428baa808..acee18181adbac9267939d61d9efd6119fa7130c 100755 (executable)
@@ -173,18 +173,16 @@ class SamplingWorker(threading.Thread):
             mem_ret_q.put((count, mem_stat))
 
 class TestWorker(threading.Thread):
-    def __init__(self, path, name):
+    def __init__(self, path, name, env):
         threading.Thread.__init__(self)
         self.path = path
         self.name = name
+        self.env  = env
 
     def run(self):
         bin_path_name = os.path.join(self.path, self.name)
 
-        env = os.environ
-        env['TEST_NO_SESSIOND'] = '1'
-
-        test = subprocess.Popen([bin_path_name], env=env, preexec_fn = lambda: signal(SIGPIPE, SIG_DFL))
+        test = subprocess.Popen([bin_path_name], env=self.env, preexec_fn = lambda: signal(SIGPIPE, SIG_DFL))
         test.wait()
 
         # Send ret value to main thread
@@ -303,10 +301,23 @@ def run_test(test):
         print "Unable to find test file '%s'. Skipping" % (test['bin'])
         return 0
 
-    # No session daemon needed
-    if not test['daemon']:
+    # Session daemon is controlled by the test
+    if test['daemon'] == "test":
+        print PRINT_ARROW + " Session daemon is controlled by the test"
+        env = os.environ
+        env['TEST_NO_SESSIOND'] = '0'
+        tw = TestWorker(".", test['bin'], env)
+        tw.start()
+        ret = test_ret_q.get(True)
+        print_test_success(ret, test['success'])
+        return 0
+    elif test['daemon'] == False:
         print PRINT_ARROW + " No session daemon needed"
-        ret = start_test(test['bin'])
+        env = os.environ
+        env['TEST_NO_SESSIOND'] = '1'
+        tw = TestWorker(".", test['bin'], env)
+        tw.start()
+        ret = test_ret_q.get(True)
         print_test_success(ret, test['success'])
         return 0
     else:
@@ -327,7 +338,12 @@ def run_test(test):
         cpu_count, cpu_stats = get_cpu_usage(pid = dem_pid)
         print_cpu_stats(cpu_stats, cpu_count)
 
-    tw = TestWorker(".", test['bin'])
+    # Sessiond was already spawned, do not let the test spawn
+    # an additional sessiond
+    env = os.environ
+    env['TEST_NO_SESSIOND'] = '1'
+
+    tw = TestWorker(".", test['bin'], env)
     tw.start()
 
     if not no_stats:
This page took 0.025578 seconds and 4 git commands to generate.