From e72d9ee52352d8e3b7c9ae713e282d062ddc1e8e Mon Sep 17 00:00:00 2001 From: Oskari Timperi Date: Thu, 22 Jul 2010 10:35:34 +0300 Subject: [PATCH] New: Testcase for the daemonized mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RevBy: Olli Leppänen --- tests/TestScripts/test-func-launcher.py | 40 +++++++++++++++++++++++++ tests/functests/tests.xml | 4 +++ 2 files changed, 44 insertions(+) diff --git a/tests/TestScripts/test-func-launcher.py b/tests/TestScripts/test-func-launcher.py index 5144284..4dee19e 100644 --- a/tests/TestScripts/test-func-launcher.py +++ b/tests/TestScripts/test-func-launcher.py @@ -47,6 +47,8 @@ DEV_NULL = file("/dev/null","w") LAUNCHABLE_APPS = ['/usr/bin/fala_ft_hello','/usr/bin/fala_ft_hello1', '/usr/bin/fala_ft_hello2'] PREFERED_APP = '/usr/bin/fala_ft_hello' +using_scratchbox = False + def debug(*msg): """ Debug function @@ -417,6 +419,43 @@ class launcher_tests (unittest.TestCase): self.kill_process(None, app_pid2) self.assert_(False, "%s was not killed" % app_path) + def test_011(self): + # stop/kill applauncherd if it's running + if using_scratchbox: + commands.getstatusoutput("pkill applauncherd") + else: + commands.getstatusoutput("initctl stop xsession/applauncherd") + + files = ['/tmp/applauncherd.lock', '/tmp/qtlnchr', '/tmp/mlnchr'] + + for f in files: + os.remove(f) + + # start applauncherd daemonized + subprocess.Popen(["applauncherd.bin", "--daemon"], + shell=False, + stdout=DEV_NULL, stderr=DEV_NULL) + + time.sleep(2) + + # count should be 2 (pgrep -f returns the shell in which it is run ...) + st, op = commands.getstatusoutput('pgrep -f "applauncherd.bin --daemon"') + count = len(op.split("\n")) + + commands.getstatusoutput('pkill -f "applauncherd.bin --daemon"') + + for f in files: + os.remove(f) + + # start applauncherd again + if using_scratchbox: + subprocess.Popen("applauncherd", + shell=False, + stdout=DEV_NULL, stderr=DEV_NULL) + else: + commands.getstatusoutput("initctl start xsession/applauncherd") + + self.assert_(count == 2, "applauncherd was not daemonized") # main if __name__ == '__main__': @@ -424,6 +463,7 @@ if __name__ == '__main__': # the tools/bin directory if os.getenv('_SBOX_DIR') != None: os.environ['PATH'] = os.getenv('PATH') + ":" + os.getenv('_SBOX_DIR') + '/tools/bin' + using_scratchbox = True check_prerequisites() start_launcher_daemon() diff --git a/tests/functests/tests.xml b/tests/functests/tests.xml index 6093259..41523e6 100644 --- a/tests/functests/tests.xml +++ b/tests/functests/tests.xml @@ -31,6 +31,10 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_005_one_instance + + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_011 + + true true