Changes: Added tests for SIGUSR1, SIGUSR2 and 2nd instance for daemon

RevBy: Olli Leppanen
pull/1/head
Nimika Keshri 15 years ago
parent a86d2d4af8
commit 6159994d74

@ -135,6 +135,15 @@
<case name="applauncherd__test_applauncherd_fd_kill" type="Functional" description="Test that applauncherd file descriptor does not change after killing app" timeout="360" level="System" insignificant="true">
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_applauncherd_fd_kill</step>
</case>
<case name="applauncherd__test_SIGUSR2" type="Functional" description="Test for SIGUSR2" timeout="360" level="System" insignificant="true">
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-boot-mode.py test_SIGUSR2</step>
</case>
<case name="applauncherd__test_SIGUSR1" type="Functional" description="Test for SIGUSR1" timeout="360" level="System" insignificant="true">
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-boot-mode.py test_SIGUSR1 </step>
</case>
<case name="applauncherd__test_daemon_second_instance" type="Functional" description="Test that 2nd instance of daemon cannot be started" timeout="360" level="System" insignificant="true">
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_daemon_second_instance </step>
</case>
<environments>
<scratchbox>true</scratchbox>
<hardware>true</hardware>

@ -60,11 +60,6 @@ class BootModeTests(unittest.TestCase):
if get_pid('applauncherd') != None:
stop_applauncherd()
time.sleep(2)
if get_pid('applauncherd') != None:
kill_process('applauncherd')
self.start_applauncherd_in_boot_mode()
for b in ['booster-m', 'booster-q', 'booster-d']:
@ -73,14 +68,13 @@ class BootModeTests(unittest.TestCase):
def tearDown(self):
debug("tearDown")
kill_process('fala_multi-instance')
if get_pid('fala_multi-instance') != None:
kill_process('fala_multi-instance')
if get_pid('applauncherd'):
if get_pid('applauncherd') != None:
kill_process('applauncherd')
start_applauncherd()
time.sleep(5)
def start_applauncherd_in_boot_mode(self):
remove_applauncherd_runtime_files()
@ -185,6 +179,57 @@ class BootModeTests(unittest.TestCase):
res_norm[1],
6, 6))
def test_SIGUSR2(self):
"""
send SIGUSR2 for applauncherd when in boot mode. This should turn it into boot mode.
"""
pid = wait_for_single_applauncherd()
st, op = commands.getstatusoutput("kill -SIGUSR2 %s" %pid)
time.sleep(3)
st1, op1 = commands.getstatusoutput("grep '%s]: Daemon: Already in boot mode' /var/log/syslog " %pid)
debug("The log msg is %s" %op1)
self.assert_(st == 0, "Seems that SIGUSR2 was not send")
def test_SIGUSR1(self):
"""
send SIGUSR1 for applauncherd when it is in boot mode.
This should turn it into normal mode. Try sending signal twice.
Another time you would get message in syslog that it is already in normal mode
"""
#Send SIGUSR1 for the first time
#Get pids for daemon and boosters
daemon_pid = wait_for_single_applauncherd()
pid_q = wait_for_app("booster-q")
pid_d = wait_for_app("booster-d")
pid_m = wait_for_app("booster-m")
pid_e = wait_for_app("booster-e")
#Send SIGUSR1 to daemon
st, op = commands.getstatusoutput("kill -SIGUSR1 %s" %daemon_pid)
time.sleep(3)
st1, op1 = commands.getstatusoutput("grep '%s]: Daemon: Exited boot mode.' /var/log/syslog " %daemon_pid)
debug("The log msg is %s" %op1)
self.assert_(st == 0, "Seems that SIGUSR1 was not send")
#Get pids for boosters
pid_q_1 = wait_for_app("booster-q")
pid_d_1 = wait_for_app("booster-d")
pid_m_1 = wait_for_app("booster-m")
pid_e_1 = wait_for_app("booster-e")
self.assert_(pid_q != pid_q_1, "Applauncherd not changed to normal mode")
self.assert_(pid_d != pid_d_1, "Applauncherd not changed to normal mode")
self.assert_(pid_m != pid_m_1, "Applauncherd not changed to normal mode")
self.assert_(pid_e != pid_e_1, "Applauncherd not changed to normal mode")
#Send SIGUSR1 for the second time
st, op = commands.getstatusoutput("kill -SIGUSR1 %s" %daemon_pid)
time.sleep(3)
st1, op1 = commands.getstatusoutput("grep '%s]: Daemon: Already in normal mode.' /var/log/syslog " %daemon_pid)
debug("The log msg is %s" %op1)
self.assert_(st == 0, "Seems that SIGUSR1 was not send")
if __name__ == '__main__':
# When run with testrunner, for some reason the PATH doesn't include
# the tools/bin directory

@ -1216,6 +1216,21 @@ class launcher_tests (unittest.TestCase):
for i in range(ARGV_LIMIT):
self.assert_(original_argv[i] == cache_argv[i], "Wrong arguments passed.\nOriginal: %s\nCached: %s" % (original_argv, cache_argv))
kill_process(apppid=pid)
def test_daemon_second_instance(self):
"""
Test that second instance of applauncherd cannot be started
"""
daemon_pid = get_pid("applauncherd")
if daemon_pid == None:
start_applauncherd
daemon_pid = get_pid("applauncherd")
debug("start applauncherd again")
st, op = commands.getstatusoutput("initctl start xsession/applauncherd")
time.sleep(3)
daemon_pid_new = get_pid("applauncherd")
self.assert_(daemon_pid == daemon_pid_new, "New instance of applauncherd started")
self.assert_(st != 0, "Second instance of applauncherd started")
# main

@ -120,7 +120,7 @@ def run_cmd_as_user(cmnd, out = DEV_NULL, err = DEV_NULL):
def get_pid(appname):
temp = basename(appname)[:14]
st, op = commands.getstatusoutput("pgrep %s" % temp)
debug("The Pid of %s is: %s" %(appname, op))
debug("The Pid of %s is %s" %(appname, op))
if st == 0:
return op
else:
@ -132,7 +132,7 @@ def get_newest_pid(app):
op = p.communicate()[0]
debug("The New Pid of %s is %s:" %(app, op.strip()))
debug("The New Pid of %s is %s" %(app, op.strip()))
if p.wait() == 0:
return op.strip()
@ -176,6 +176,7 @@ def wait_for_single_applauncherd(timeout = 20, sleep = 1):
count = len(pid.split("\n"))
if count == 1:
break
return pid
def get_booster_pid():
wait_for_app('booster-q')

Loading…
Cancel
Save