From 0c6af71cebf95b52f86f2384728fa301eb8f7564 Mon Sep 17 00:00:00 2001 From: Olli Leppanen Date: Wed, 13 Apr 2011 11:50:05 +0300 Subject: [PATCH] Changes: Added stopping all daemons which are started with invoker before functional tests RevBy: Juha Lintula --- debian/changelog | 3 +- tests/harmattan/functests/tests.xml | 27 +++++++++++- .../testscripts/test-func-launcher.py | 43 +++++++++++++++++-- 3 files changed, 67 insertions(+), 6 deletions(-) diff --git a/debian/changelog b/debian/changelog index 47236e1..3064a97 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,8 @@ applauncherd (0.27.0) unstable; urgency=low * Changes: Fixed misbehaving pixelchanged application - * Implemented: SWP#DUI-5199 + * Changes: Added stopping all daemons which are using invoker before functional tests + * Implemented: SWP#DUI-5199, SWP#DUI-5180, SWP#DUI-5162 * Fixes: NB#244103 - Device hangs on closing application in connecting view while configuring MFE account * Fixes: NB#243857 - Mismatched new[] - delete in applauncherd * Fixes: NB#238937 - minor splash-screen bugs diff --git a/tests/harmattan/functests/tests.xml b/tests/harmattan/functests/tests.xml index d94b296..acca2a9 100644 --- a/tests/harmattan/functests/tests.xml +++ b/tests/harmattan/functests/tests.xml @@ -8,6 +8,7 @@ /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 @@ -37,7 +38,9 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_launch_multiple_apps_cont - + + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py start_daemons + true true @@ -47,6 +50,9 @@ + + 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_signal_forwarding @@ -77,6 +83,10 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_launch_wo_applauncherd + + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py start_daemons + + true true @@ -87,6 +97,7 @@ /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 @@ -114,6 +125,9 @@ source /tmp/session_bus_address.user; DISPLAY=:0 /usr/share/applauncherd-testscripts/tc_theming.rb name test_theme_change_booster_restart + + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py start_daemons + true @@ -229,6 +243,7 @@ /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 @@ -255,6 +270,11 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_fd_booster_d + + + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py start_daemons + + true true @@ -265,6 +285,7 @@ /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 @@ -291,6 +312,10 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_fd_booster_e + + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py start_daemons + + true true diff --git a/tests/harmattan/testscripts/test-func-launcher.py b/tests/harmattan/testscripts/test-func-launcher.py index e801c4b..9b77b9b 100644 --- a/tests/harmattan/testscripts/test-func-launcher.py +++ b/tests/harmattan/testscripts/test-func-launcher.py @@ -51,6 +51,7 @@ LAUNCHABLE_APPS = ['/usr/bin/fala_ft_hello','/usr/bin/fala_ft_hello1', '/usr/bin LAUNCHABLE_APPS_QML = ['/usr/bin/fala_qml_helloworld','/usr/bin/fala_qml_helloworld1', '/usr/bin/fala_qml_helloworld2'] PREFERED_APP = '/usr/bin/fala_ft_hello' PREFERED_APP_QML = '/usr/bin/fala_qml_helloworld' +DAEMONS_TO_BE_STOPPED = ['xsession/applifed', 'xsession/conndlgs'] using_scratchbox = False @@ -72,9 +73,38 @@ def check_prerequisites(): for app in LAUNCHABLE_APPS: assert len(basename(app)) <= 15, "For app: %s , base name !<= 14" %app +# Function to stop desired daemons. This is also done in setup function +# if stop_daemons is not called before. +def stop_daemons(): + for daemon in DAEMONS_TO_BE_STOPPED: + os.system('initctl stop %s'%(daemon)) + +# 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)) + + +class daemon_handling (unittest.TestCase): + + def stop_daemons(self): + stop_daemons() + + def start_daemons(self): + start_daemons() + class launcher_tests (unittest.TestCase): def setUp(self): - os.system('initctl stop xsession/applifed') + + # Check if first of the desired daemons is running, and if so, start those all + st, op = commands.getstatusoutput('pgrep %s'%DAEMONS_TO_BE_STOPPED[0].split("/")[1]) + + if st == 0: + stop_daemons() + self.START_DAEMONS_AT_TEARDOWN = True + else: + self.START_DAEMONS_AT_TEARDOWN = False if get_pid('applauncherd') == None: os.system('initctl start xsession/applauncherd') time.sleep(5) @@ -87,14 +117,16 @@ class launcher_tests (unittest.TestCase): def tearDown(self): #teardown here debug("Executing TearDown") - os.system('initctl start xsession/applifed') if get_pid('applauncherd') == None: os.system('initctl start xsession/applauncherd') time.sleep(5) + debug ("START_DAEMONS_AT_TEARDOWN: %s"%self.START_DAEMONS_AT_TEARDOWN) + if self.START_DAEMONS_AT_TEARDOWN: + start_daemons() get_pid('booster-m') get_pid('booster-q') get_pid('booster-d') - + #Testcases def test_launcher_exist(self): """ @@ -927,7 +959,10 @@ if __name__ == '__main__': check_prerequisites() start_launcher_daemon() tests = sys.argv[1:] - mysuite = unittest.TestSuite(map(launcher_tests, tests)) + try: + mysuite = unittest.TestSuite(map(launcher_tests, tests)) + except: + mysuite = unittest.TestSuite(map(daemon_handling, tests)) result = unittest.TextTestRunner(verbosity=2).run(mysuite) if not result.wasSuccessful(): sys.exit(1)