From 8b43ea2bd082efc2899422d398089a7c0813c31f Mon Sep 17 00:00:00 2001 From: Nimika Keshri Date: Fri, 29 Apr 2011 16:04:08 +0300 Subject: [PATCH] Changes: Added 'all boosters up and running'-check in applauncherd tests RevBy: TrustMe --- tests/harmattan/functests/tests.xml | 25 +++++++------ tests/harmattan/testscripts/test-core-dump.py | 10 ++--- .../testscripts/test-func-launcher.py | 15 ++++---- tests/harmattan/testscripts/test-security.py | 10 ++--- .../testscripts/test-single-instance.py | 10 ++--- tests/harmattan/testscripts/utils.py | 37 ++++++++++++++----- 6 files changed, 57 insertions(+), 50 deletions(-) diff --git a/tests/harmattan/functests/tests.xml b/tests/harmattan/functests/tests.xml index eb11d1b..6a92441 100644 --- a/tests/harmattan/functests/tests.xml +++ b/tests/harmattan/functests/tests.xml @@ -13,6 +13,10 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-daemons.py test_001_daemon_list + + + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_daemon + true true @@ -21,8 +25,8 @@ - /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py stop_daemons + /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 @@ -45,9 +49,6 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_one_instance - - source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_daemon - source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_launch_multiple_apps_cont @@ -66,6 +67,7 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py stop_daemons + /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 @@ -92,7 +94,6 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_invoker_gid_uid - source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_launch_wo_applauncherd @@ -114,6 +115,10 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py stop_daemons + + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_restart_booster + + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_booster_pid_change @@ -126,10 +131,6 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_fd_booster_q - - source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_restart_booster - - source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_booster_killed_or_restarted @@ -153,8 +154,8 @@ - /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py stop_daemons + /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 @@ -260,8 +261,8 @@ - /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py stop_daemons + /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 @@ -302,8 +303,8 @@ - /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py stop_daemons + /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 diff --git a/tests/harmattan/testscripts/test-core-dump.py b/tests/harmattan/testscripts/test-core-dump.py index 8081753..69ae08e 100644 --- a/tests/harmattan/testscripts/test-core-dump.py +++ b/tests/harmattan/testscripts/test-core-dump.py @@ -47,11 +47,7 @@ class CoreDumpTests(unittest.TestCase): self.START_DAEMONS_AT_TEARDOWN = False if get_pid('applauncherd') == None: - os.system('initctl start xsession/applauncherd') - time.sleep(5) - get_pid('booster-m') - get_pid('booster-q') - get_pid('booster-d') + start_applauncherd() #setup here debug("Executing SetUp") @@ -59,8 +55,8 @@ class CoreDumpTests(unittest.TestCase): #teardown here debug("Executing TearDown") if get_pid('applauncherd') == None: - os.system('initctl start xsession/applauncherd') - time.sleep(5) + start_applauncherd() + wait_for_single_applauncherd() if self.START_DAEMONS_AT_TEARDOWN: start_daemons() diff --git a/tests/harmattan/testscripts/test-func-launcher.py b/tests/harmattan/testscripts/test-func-launcher.py index 1640e50..112cac3 100644 --- a/tests/harmattan/testscripts/test-func-launcher.py +++ b/tests/harmattan/testscripts/test-func-launcher.py @@ -91,11 +91,8 @@ class launcher_tests (unittest.TestCase): self.START_DAEMONS_AT_TEARDOWN = False if get_pid('applauncherd') == None: - os.system('initctl start xsession/applauncherd') - time.sleep(5) - get_pid('booster-m') - get_pid('booster-q') - get_pid('booster-d') + start_applauncherd() + #setup here debug("Executing SetUp") @@ -103,9 +100,9 @@ class launcher_tests (unittest.TestCase): #teardown here debug("Executing TearDown") if get_pid('applauncherd') == None: - os.system('initctl start xsession/applauncherd') - time.sleep(5) + start_applauncherd() + wait_for_single_applauncherd() if self.START_DAEMONS_AT_TEARDOWN: start_daemons() @@ -549,6 +546,7 @@ class launcher_tests (unittest.TestCase): #Test for m-booster debug("Test for m-booster") st, op = commands.getstatusoutput("/usr/share/applauncherd-testscripts/signal-forward/fala_sf_m.py") + time.sleep(3) debug("The Invoker killed by : <%s>" %op.split ('\n')[-1]) self.assert_(op.split('\n')[-1] == 'Segmentation fault (core dumped)', "The invoker(m-booster) was not killed by the same signal") @@ -557,6 +555,7 @@ class launcher_tests (unittest.TestCase): #Test for d-booster debug("Test for d-booster") st, op = commands.getstatusoutput("/usr/share/applauncherd-testscripts/signal-forward/fala_sf_d.py") + time.sleep(3) debug("The Invoker killed by : %s" % op.split('\n')[-1]) self.assert_(op.split('\n')[-1] == 'Terminated', "The invoker(d-booster) was not killed by the same signal") @@ -565,6 +564,7 @@ class launcher_tests (unittest.TestCase): #Test for e-booster debug("Test for e-booster") st, op = commands.getstatusoutput("/usr/share/applauncherd-testscripts/signal-forward/fala_sf_e.py") + time.sleep(3) debug("The Invoker killed by : %s" % op.split('\n')[-1]) self.assert_(op.split('\n')[-1] == 'Terminated', "The invoker(e-booster) was not killed by the same signal") @@ -574,6 +574,7 @@ class launcher_tests (unittest.TestCase): #Test for q-booster debug("Test for q-booster") st, op = commands.getstatusoutput("/usr/share/applauncherd-testscripts/signal-forward/fala_sf_qt.py") + time.sleep(3) debug("The Invoker killed by : %s" %op.split('\n')[-1]) self.assert_(op.split('\n')[-1] == 'Aborted (core dumped)', "The invoker(q-booster) was not killed by the same signal") diff --git a/tests/harmattan/testscripts/test-security.py b/tests/harmattan/testscripts/test-security.py index 5d40bd1..329f1a6 100644 --- a/tests/harmattan/testscripts/test-security.py +++ b/tests/harmattan/testscripts/test-security.py @@ -28,11 +28,7 @@ class SecurityTests(unittest.TestCase): self.START_DAEMONS_AT_TEARDOWN = False if get_pid('applauncherd') == None: - os.system('initctl start xsession/applauncherd') - time.sleep(5) - get_pid('booster-m') - get_pid('booster-q') - get_pid('booster-d') + start_applauncherd() #setup here debug("Executing SetUp") @@ -40,8 +36,8 @@ class SecurityTests(unittest.TestCase): #teardown here debug("Executing TearDown") if get_pid('applauncherd') == None: - os.system('initctl start xsession/applauncherd') - time.sleep(5) + start_applauncherd() + wait_for_single_applauncherd() if self.START_DAEMONS_AT_TEARDOWN: start_daemons() diff --git a/tests/harmattan/testscripts/test-single-instance.py b/tests/harmattan/testscripts/test-single-instance.py index 0e46447..a0d0b1b 100644 --- a/tests/harmattan/testscripts/test-single-instance.py +++ b/tests/harmattan/testscripts/test-single-instance.py @@ -64,11 +64,7 @@ class SingleInstanceTests(unittest.TestCase): self.START_DAEMONS_AT_TEARDOWN = False if get_pid('applauncherd') == None: - os.system('initctl start xsession/applauncherd') - time.sleep(5) - get_pid('booster-m') - get_pid('booster-q') - get_pid('booster-d') + start_applauncherd() #setup here debug("Executing SetUp") @@ -76,8 +72,8 @@ class SingleInstanceTests(unittest.TestCase): #teardown here debug("Executing TearDown") if get_pid('applauncherd') == None: - os.system('initctl start xsession/applauncherd') - time.sleep(5) + start_applauncherd() + wait_for_single_applauncherd() if self.START_DAEMONS_AT_TEARDOWN: start_daemons() diff --git a/tests/harmattan/testscripts/utils.py b/tests/harmattan/testscripts/utils.py index ab3f868..c33f292 100644 --- a/tests/harmattan/testscripts/utils.py +++ b/tests/harmattan/testscripts/utils.py @@ -15,17 +15,16 @@ DAEMONS_TO_BE_STOPPED = ['xsession/applifed', 'xsession/conndlgs'] def stop_daemons(): for daemon in DAEMONS_TO_BE_STOPPED: os.system('initctl stop %s'%(daemon)) + wait_for_single_applauncherd() + get_booster_pid() # Function to start desired daemons. This is also done in teardown function # if start_daemons is not called before. def start_daemons(): for daemon in DAEMONS_TO_BE_STOPPED: os.system('initctl start %s'%(daemon)) - time.sleep(5) - wait_for_app('booster-m') - wait_for_app('booster-e') - wait_for_app('booster-d') - wait_for_app('booster-q') + wait_for_single_applauncherd() + get_booster_pid() def daemons_running(): st, op = commands.getstatusoutput('pgrep %s'%DAEMONS_TO_BE_STOPPED[0].split("/")[1]) @@ -50,8 +49,7 @@ def remove_applauncherd_runtime_files(): Removes files that applauncherd leaves behind after it has been stopped """ debug("Removing files that applauncherd leaves behind after it has been stopped") - files = ['/var/run/applauncherd.lock'] - files += glob.glob('/tmp/boost*') + files = glob.glob('/tmp/boost*') for f in files: debug("removing %s" % f) @@ -66,8 +64,7 @@ def start_applauncherd(): handle = Popen(['initctl', 'start', 'xsession/applauncherd'], stdout = DEV_NULL, stderr = DEV_NULL, shell = False) - - time.sleep(6) + get_booster_pid() return handle.wait() == 0 def stop_applauncherd(): @@ -141,7 +138,7 @@ def get_newest_pid(app): return None -def wait_for_app(app = None, timeout = 5, sleep = 1): +def wait_for_app(app = None, timeout = 10, sleep = 1): """ Waits for an application to start. Checks periodically if the app is running for a maximum wait set in timeout. @@ -165,6 +162,26 @@ def wait_for_app(app = None, timeout = 5, sleep = 1): return pid +def wait_for_single_applauncherd(timeout = 20, sleep = 1): + pid = get_pid('applauncherd') + count = len(pid.split("\n")) + start = time.time() + + while count > 1 and time.time() < start + timeout: + + debug("waiting %s secs for single applauncherd" %sleep) + time.sleep(sleep) + + pid = get_pid('applauncherd') + count = len(pid.split("\n")) + if count == 1: + break + +def get_booster_pid(): + wait_for_app('booster-q') + wait_for_app('booster-e') + wait_for_app('booster-d') + wait_for_app('booster-m') def kill_process(appname=None, apppid=None, signum=15): if apppid and appname: