Changes: Merge 'fangorn/my-re-exec' - updated test cases with sighup

RevBy: Olli, Marek
pull/1/head
Thyagarajan Balakrishnan 14 years ago
parent 2f9bbaf65e
commit e869ab7ff7

@ -31,12 +31,21 @@ class DaemonTests(unittest.TestCase):
def tearDown(self):
debug("tearDown")
def test_launcher_exist(self):
def sighup_applauncherd(self):
same_pid, booster_status = send_sighup_to_applauncherd()
self.assert_(same_pid, "Applauncherd has new pid after SIGHUP")
self.assert_(booster_status, "Atleast one of the boosters is not restarted")
def test_launcher_exist(self, sighup = True):
"""
To test if the launcher exists and is executable or not
"""
self.assert_(os.path.isfile(LAUNCHER_BINARY), "Launcher file does not exist")
self.assert_(os.access(LAUNCHER_BINARY, os.X_OK), "Launcher exists, but is not executable")
if(sighup):
self.sighup_applauncherd()
self.test_launcher_exist(False)
def test_daemon_list(self):
"""
@ -93,7 +102,7 @@ class DaemonTests(unittest.TestCase):
start_applauncherd()
def test_daemon_second_instance(self):
def test_daemon_second_instance(self, sighup = True):
"""
Test that second instance of applauncherd cannot be started
"""
@ -108,7 +117,11 @@ class DaemonTests(unittest.TestCase):
self.assert_(daemon_pid == daemon_pid_new, "New instance of applauncherd started")
self.assert_(st != 0, "Second instance of applauncherd started")
def test_writable_executable_mem(self):
if(sighup):
self.sighup_applauncherd()
self.test_daemon_second_instance(False)
def test_writable_executable_mem(self, sighup = True):
"""
Test that applauncherd does not have the writable and executable memory
"""
@ -118,12 +131,22 @@ class DaemonTests(unittest.TestCase):
debug("The value of status is %d" %st)
debug("The value of output is %s" %op)
self.assert_(st != 0, "applauncherd has writable and executable memory")
if(sighup):
self.sighup_applauncherd()
self.test_writable_executable_mem(False)
def test_applauncherd_fd_close(self):
def test_applauncherd_fd_close(self, sighup = True):
self._test_applauncherd_fd()
if(sighup):
self.sighup_applauncherd()
self.test_applauncherd_fd_close(False)
def test_applauncherd_fd_kill(self):
def test_applauncherd_fd_kill(self, sighup = True):
self._test_applauncherd_fd(False)
if(sighup):
self.sighup_applauncherd()
self.test_applauncherd_fd_kill(False)
def _test_applauncherd_fd(self, close = True):
"""
@ -218,7 +241,7 @@ class DaemonTests(unittest.TestCase):
self.assert_(op == 'FATAL!!: DISPLAY environment variable not set.',\
"Applauncherd was started even when DISPLAY was not set")
def test_app_exits_clean(self):
def test_app_exits_clean(self, sighup = True):
"""
Test that a test applications exits clean.
"""
@ -239,7 +262,9 @@ class DaemonTests(unittest.TestCase):
launcher_pid_new = wait_for_single_applauncherd
self.assert_(launcher_pid == launcher_pid_new, "The Pid of applauncherd has changed")
if(sighup):
self.sighup_applauncherd()
self.test_app_exits_clean(False)
if __name__ == '__main__':

@ -107,6 +107,11 @@ class launcher_tests (unittest.TestCase):
if self.START_DAEMONS_AT_TEARDOWN:
start_daemons()
def sighup_applauncherd(self):
same_pid, booster_status = send_sighup_to_applauncherd()
self.assert_(same_pid, "Applauncherd has new pid after SIGHUP")
self.assert_(booster_status, "Atleast one of the boosters is not restarted")
#Testcases
def test_applications_exist(self):
@ -140,7 +145,7 @@ class launcher_tests (unittest.TestCase):
def test_zombie_state_e(self):
self._test_zombie_state(PREFERED_APP, 'e')
def _test_zombie_state(self, prefered_app, btype):
def _test_zombie_state(self, prefered_app, btype, sighup = True):
"""
To test that no Zombie process exist after the application is killed
"""
@ -167,6 +172,9 @@ class launcher_tests (unittest.TestCase):
self.assert_(process_id != process_id1 , "New Process not launched")
self.assert_(process_id1 == None , "Process still running")
if(sighup):
self.sighup_applauncherd()
self._test_zombie_state(prefered_app, btype, False)
def test_launch_multiple_apps_m(self):
self._test_launch_multiple_apps(LAUNCHABLE_APPS, 'm')
@ -177,7 +185,7 @@ class launcher_tests (unittest.TestCase):
def test_launch_multiple_apps_e(self):
self._test_launch_multiple_apps(LAUNCHABLE_APPS, 'e')
def _test_launch_multiple_apps(self, launchable_apps, btype):
def _test_launch_multiple_apps(self, launchable_apps, btype, sighup = True):
"""
To test that more than one applications are launched by the launcher
"""
@ -199,6 +207,9 @@ class launcher_tests (unittest.TestCase):
pidlist.append(pid)
kill_launched(pidlist)
self.assert_(len(pidlist) == len(launchable_apps),"All apps were not launched")
if(sighup):
self.sighup_applauncherd()
self._test_launch_multiple_apps(launchable_apps, btype, False)
def test_one_instance_m(self):
self._test_one_instance(PREFERED_APP, 'm')
@ -209,7 +220,7 @@ class launcher_tests (unittest.TestCase):
def test_one_instance_e(self):
self._test_one_instance(PREFERED_APP, 'e')
def _test_one_instance(self, prefered_app, btype):
def _test_one_instance(self, prefered_app, btype, sighup = True):
"""
To test that only one instance of a application exist
"""
@ -233,6 +244,9 @@ class launcher_tests (unittest.TestCase):
kill_process(prefered_app)
self.assert_( len(process_id.split(' ')) == 1, "Only one instance of app not running")
if(sighup):
self.sighup_applauncherd()
self._test_one_instance(prefered_app, btype, False)
def test_launch_multiple_apps_cont_m(self):
self._test_launch_multiple_apps_cont(LAUNCHABLE_APPS, 'fala_ft_hello', 'm')
@ -243,7 +257,7 @@ class launcher_tests (unittest.TestCase):
def test_launch_multiple_apps_cont_e(self):
self._test_launch_multiple_apps_cont(LAUNCHABLE_APPS, 'fala_ft_hello', 'e')
def _test_launch_multiple_apps_cont(self, launchable_apps, app_common_prefix, btype):
def _test_launch_multiple_apps_cont(self, launchable_apps, app_common_prefix, btype, sighup = True):
"""
To test that more than one applications are launched by the launcher
"""
@ -262,37 +276,52 @@ class launcher_tests (unittest.TestCase):
kill_process(apppid=pid)
self.assert_(len(pid_list) == len(launchable_apps), "All Applications were not launched using launcher")
if(sighup):
self.sighup_applauncherd()
self._test_launch_multiple_apps_cont(launchable_apps, app_common_prefix, btype, False)
def test_fd_booster_m(self):
def test_fd_booster_m(self, sighup = True):
"""
File descriptor test for booster-m
"""
count = get_file_descriptor("booster-m", "m", "fala_ft_hello")
self.assert_(count != 0, "None of the file descriptors were changed")
if(sighup):
self.sighup_applauncherd()
self.test_fd_booster_m(False)
def test_fd_booster_q(self):
def test_fd_booster_q(self, sighup = True):
"""
File descriptor test for booster-q
"""
count = get_file_descriptor("booster-q", "qt", "fala_ft_hello")
self.assert_(count != 0, "None of the file descriptors were changed")
if(sighup):
self.sighup_applauncherd()
self.test_fd_booster_q(False)
def test_fd_booster_d(self):
def test_fd_booster_d(self, sighup = True):
"""
File descriptor test for booster-d
"""
count = get_file_descriptor("booster-d", "d", "fala_qml_helloworld")
self.assert_(count != 0, "None of the file descriptors were changed")
if(sighup):
self.sighup_applauncherd()
self.test_fd_booster_d(False)
def test_fd_booster_e(self):
def test_fd_booster_e(self, sighup = True):
"""
File descriptor test for booster-e
"""
count = get_file_descriptor("booster-e", "e", "fala_ft_hello")
self.assert_(count != 0, "None of the file descriptors were changed")
if(sighup):
self.sighup_applauncherd()
self.test_fd_booster_e(False)
def test_restart_booster(self):
def test_restart_booster(self, sighup = True):
"""
Test that booster is restarted if it is killed
"""
@ -339,6 +368,10 @@ class launcher_tests (unittest.TestCase):
self.assert_(epid_new != None, "No booster process running")
self.assert_(epid_new != epid, "booster process was not killed")
if(sighup):
self.sighup_applauncherd()
self.test_restart_booster(False)
def test_booster_killed_or_restarted(self):
"""
Test that boosters are killed if applauncherd is stopped
@ -434,8 +467,8 @@ class launcher_tests (unittest.TestCase):
self.assert_(len(epid_new.split("\n")) == 1, "multiple instances of booster-e running")
self.assert_(epid_new != None, "No booster process running")
self.assert_(epid_new != epid, "booster process was not killed")
def test_booster_pid_change(self):
def test_booster_pid_change(self, sighup = True):
"""
Test that application pid changes to the booster 'x' when application
is started with invoker --type='x'
@ -489,6 +522,10 @@ class launcher_tests (unittest.TestCase):
self.assert_(qpid_new != None, "No booster process running")
self.assert_(qpid_new != qpid, "booster-q process did not receive the new pid")
if(sighup):
self.sighup_applauncherd()
self.test_booster_pid_change(False)
def test_stress_boosted_apps(self):
self._test_stress_boosted_apps('m', 'fala_ft_hello')
@ -498,7 +535,7 @@ class launcher_tests (unittest.TestCase):
self._test_stress_boosted_apps('e', 'fala_ft_hello')
time.sleep(5)
def _test_stress_boosted_apps(self, booster_type, app_name, invoker_extra_flags=''):
def _test_stress_boosted_apps(self, booster_type, app_name, invoker_extra_flags='', sighup = True):
"""
Stress test for boosted applications to check only one instance is running.
"""
@ -524,8 +561,11 @@ class launcher_tests (unittest.TestCase):
self.assert_(pid == app_pid, "Same instance of application not running")
st, op = commands.getstatusoutput('ps ax | grep invoker | grep %s| grep -v -- -sh | wc -l' % app_name)
count = int(op)
if(sighup):
self.sighup_applauncherd()
self._test_stress_boosted_apps(booster_type, app_name, invoker_extra_flags, False)
def test_launched_app_name(self):
def test_launched_app_name(self, sighup = True):
"""
Test that launched application have correct applicationname
"""
@ -585,11 +625,14 @@ class launcher_tests (unittest.TestCase):
kill_process('fala_wl')
self.assert_(op1.split(",")[0] == '"fala_wl"','Application name is incorrect')
if(sighup):
self.sighup_applauncherd()
self.test_launched_app_name(False)
def test_unix_signal_handlers(self):
def test_unix_signal_handlers(self, sighup = True):
"""
Test unixSignalHAndlers by killing booster-m and booster-d, singnal hub
Test unixSignalHandlers by killing booster-m and booster-d, signal hup
"""
mpid = get_pid('booster-m')
@ -605,13 +648,17 @@ class launcher_tests (unittest.TestCase):
dpid_new = wait_for_app('booster-d')
self.assert_(dpid != dpid_new, "booster-d pid is not changed")
if(sighup):
self.sighup_applauncherd()
self.test_unix_signal_handlers(False)
def test_qttas_load_booster_d(self):
self._test_qttas_load_booster(PREFERED_APP_QML, 'd')
def test_qttas_load_booster_m(self):
self._test_qttas_load_booster(PREFERED_APP, 'm')
def _test_qttas_load_booster(self, testapp, btype):
def _test_qttas_load_booster(self, testapp, btype, sighup = True):
"""
To test invoker that qttestability plugin is loaded with -testability argument for booster-d
"""
@ -638,13 +685,17 @@ class launcher_tests (unittest.TestCase):
time.sleep(2)
if(sighup):
self.sighup_applauncherd()
self._test_qttas_load_booster(testapp, btype, False)
def test_qttas_load_env_booster_d(self):
self._test_qttas_load_env_booster(PREFERED_APP_QML, 'd')
def test_qttas_load_env_booster_m(self):
self._test_qttas_load_env_booster(PREFERED_APP, 'm')
def _test_qttas_load_env_booster(self, testapp, btype):
def _test_qttas_load_env_booster(self, testapp, btype, sighup = True):
"""
To test invoker that qttestability plugin is loaded with QT_LOAD_TESTABILITY env variable for booster-d
"""
@ -676,6 +727,10 @@ class launcher_tests (unittest.TestCase):
time.sleep(2)
if(sighup):
self.sighup_applauncherd()
self._test_qttas_load_env_booster(testapp, btype, False)
def test_dirPath_filePath_m(self):
self._test_dirPath_filePath('m', "/usr/share/fala_images", "fala_hello")
@ -689,7 +744,7 @@ class launcher_tests (unittest.TestCase):
def test_dirPath_filePath_e(self):
self._test_dirPath_filePath('e', "/usr/share/fala_images", "fala_qml_helloworld")
def _test_dirPath_filePath(self, btype, path, testapp):
def _test_dirPath_filePath(self, btype, path, testapp, sighup = True):
"""
Test that correct file path and dir path is passed
"""
@ -708,6 +763,10 @@ class launcher_tests (unittest.TestCase):
filepath = op.split("\n")[1].split(" ")[2]
kill_process(apppid=pid)
self.assert_(filepath == "%s/%s" % (path, testapp), "Wrong filePath: %s" % filepath)
if(sighup):
self.sighup_applauncherd()
self._test_dirPath_filePath(btype, path, testapp, False)
def test_argv_mbooster_limit(self):
self._test_argv_booster_limit("m", "fala_wl")
@ -715,7 +774,7 @@ class launcher_tests (unittest.TestCase):
def test_argv_dbooster_limit(self):
self._test_argv_booster_limit("d", "fala_qml_helloworld")
def _test_argv_booster_limit(self, btype, testapp):
def _test_argv_booster_limit(self, btype, testapp, sighup = True):
"""
Test that ARGV_LIMIT (32) arguments are successfully passed to cached [QM]Application.
"""
@ -734,13 +793,17 @@ class launcher_tests (unittest.TestCase):
kill_process(apppid=pid)
self.assert_(original_argv == cache_argv, "Wrong arguments passed.\nOriginal: %s\nCached: %s" % (original_argv, cache_argv))
if(sighup):
self.sighup_applauncherd()
self._test_argv_booster_limit(btype, testapp, False)
def test_argv_mbooster_over_limit(self):
self._test_argv_booster_over_limit("m", "fala_wl")
def test_argv_dbooster_over_limit(self):
self._test_argv_booster_over_limit("d", "fala_qml_helloworld")
def _test_argv_booster_over_limit(self, btype, testapp):
def _test_argv_booster_over_limit(self, btype, testapp, sighup = True):
"""
Test that if more than ARGV_LIMIT (32) arguments are passed to cached [QM]Application,
the application is still launched and ARGV_LIMIT arguments are successfully passed.
@ -763,6 +826,10 @@ 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))
if(sighup):
self.sighup_applauncherd()
self._test_argv_booster_over_limit(btype, testapp, False)
def test_signal_status_m(self):
self._test_signal_status("fala_wl", "fala_wol")
@ -915,72 +982,57 @@ class launcher_tests (unittest.TestCase):
def test_q_booster_dont_have_GL_context(self):
qpid = get_pid('booster-q')
self.assert_(qpid != None, "Process 'booster-q' is not running")
self.assert_(not has_GL_context(qpid), "booster-q has GL context!")
self._test_booster_dont_have_glcontext('q')
def test_m_booster_dont_have_GL_context(self):
mpid = get_pid('booster-m')
self.assert_(mpid != None, "Process 'booster-m' is not running")
self.assert_(not has_GL_context(mpid), "booster-m has GL context!")
self._test_booster_dont_have_glcontext('m')
def test_e_booster_dont_have_GL_context(self):
epid = get_pid('booster-e')
self.assert_(epid != None, "Process 'booster-e' is not running")
self.assert_(not has_GL_context(epid), "booster-e has GL context!")
self._test_booster_dont_have_glcontext('e')
def test_d_booster_dont_have_GL_context(self):
dpid = get_pid('booster-d')
self.assert_(dpid != None, "Process 'booster-d' is not running")
self.assert_(not has_GL_context(dpid), "booster-d has GL context!")
self._test_booster_dont_have_glcontext('d')
def _test_booster_dont_have_glcontext(self, btype, sighup = True):
pid = get_pid('booster-%s'%btype)
self.assert_(pid != None, "Process 'booster-%s' is not running"%btype)
self.assert_(not has_GL_context(pid), "booster-%s has GL context!"%btype)
if(sighup):
self.sighup_applauncherd()
self._test_booster_dont_have_glcontext(btype, False)
def test_q_boosted_has_glcontext(self):
qpid = get_pid('booster-q')
self.assert_(qpid != None, "Process 'booster-q' is not running")
self.assert_(not has_GL_context(qpid), "booster-q has GL context!")
p = run_app_as_user_with_invoker(PREFERED_APP, booster = 'q', arg = '--no-wait')
time.sleep(4)
app_pid = get_pid('fala_ft_hello')
self.assert_(app_pid != None, "Process 'fala_ft_hello' is not running")
glcontext = has_GL_context(app_pid)
kill_process('fala_ft_hello')
self.assert_(glcontext, "fala_ft_hello does not have GL context!")
self._test_boosted_app_has_glcontext(PREFERED_APP, 'q')
def test_m_boosted_has_glcontext(self):
mpid = get_pid('booster-m')
self.assert_(mpid != None, "Process 'booster-m' is not running")
self.assert_(not has_GL_context(mpid), "booster-m has GL context!")
p = run_app_as_user_with_invoker(PREFERED_APP, booster = 'm', arg = '--no-wait')
time.sleep(4)
app_pid = get_pid('fala_ft_hello')
self.assert_(app_pid != None, "Process 'fala_ft_hello' is not running")
glcontext = has_GL_context(app_pid)
kill_process('fala_ft_hello')
self.assert_(glcontext, "fala_ft_hello does not have GL context!")
self._test_boosted_app_has_glcontext(PREFERED_APP, 'm')
def test_e_boosted_has_glcontext(self):
epid = get_pid('booster-e')
self.assert_(epid != None, "Process 'booster-e' is not running")
self.assert_(not has_GL_context(epid), "booster-e has GL context!")
p = run_app_as_user_with_invoker(PREFERED_APP, booster = 'e', arg = '--no-wait')
time.sleep(4)
app_pid = get_pid('fala_ft_hello')
self.assert_(app_pid != None, "Process 'fala_ft_hello' is not running")
glcontext = has_GL_context(app_pid)
kill_process('fala_ft_hello')
self.assert_(glcontext, "fala_ft_hello does not have GL context!")
self._test_boosted_app_has_glcontext(PREFERED_APP, 'e')
def test_d_boosted_has_glcontext(self):
dpid = get_pid('booster-d')
self.assert_(dpid != None, "Process 'booster-d' is not running")
self.assert_(not has_GL_context(dpid), "booster-d has GL context!")
p = run_app_as_user_with_invoker(PREFERED_APP_QML, booster = 'd', arg = '--no-wait')
self._test_boosted_app_has_glcontext(PREFERED_APP_QML, 'd')
def _test_boosted_app_has_glcontext(self, testapp, btype, sighup = True):
#check booster does not have GL context
booster_pid = get_pid('booster-%s'%btype)
self.assert_(booster_pid != None, "Process 'booster-%s' is not running"%btype)
self.assert_(not has_GL_context(booster_pid), "booster-%s has GL context!"%btype)
# run app which has GL context
p = run_app_as_user_with_invoker(testapp, booster = btype, arg = '--no-wait')
time.sleep(4)
app_pid = get_pid('fala_qml_helloworld')
self.assert_(app_pid != None, "Process 'fala_qml_helloworld' is not running")
app_pid = get_pid(testapp)
self.assert_(app_pid != None, "Process '%s' is not running"%testapp)
self.assert_(app_pid == booster_pid, "Process '%s' is not a boosted app"%testapp)
#check if app has GL context
glcontext = has_GL_context(app_pid)
kill_process('fala_qml_helloworld')
self.assert_(glcontext, "fala_qml_helloworld does not have GL context!")
kill_process(apppid=app_pid)
self.assert_(glcontext, "%s does not have GL context!"%testapp)
if(sighup):
self.sighup_applauncherd()
self._test_boosted_app_has_glcontext(testapp, btype, False)
# detects bug
def test_detect_booster_m_leaks_file_descriptor_when_invoker_is_using_app_directly(self) :

@ -51,15 +51,29 @@ class InvokerTests(unittest.TestCase):
if self.START_DAEMONS_AT_TEARDOWN:
start_daemons()
def sighup_applauncherd(self):
same_pid, booster_status = send_sighup_to_applauncherd()
self.assert_(same_pid, "Applauncherd has new pid after SIGHUP")
self.assert_(booster_status, "Atleast one of the boosters is not restarted")
#Testcases
def test_wait_term_m(self):
def test_wait_term_m(self, sighup = True):
self._test_wait_term('/usr/bin/fala_ft_hello', 'fala_ft_hello', 'm')
if(sighup):
self.sighup_applauncherd()
self.test_wait_term_m(False)
def test_wait_term_qml(self):
def test_wait_term_qml(self, sighup = True):
self._test_wait_term('/usr/bin/fala_qml_helloworld', 'fala_qml_helloworld', 'd')
if(sighup):
self.sighup_applauncherd()
self.test_wait_term_qml(False)
def test_wait_term_e(self):
def test_wait_term_e(self, sighup = True):
self._test_wait_term('/usr/bin/fala_ft_hello', 'fala_ft_hello', 'e')
if(sighup):
self.sighup_applauncherd()
self.test_wait_term_e(False)
def _test_wait_term(self, app_path, app_name, btype):
"""
@ -123,7 +137,7 @@ class InvokerTests(unittest.TestCase):
start_applauncherd()
def test_signal_forwarding(self):
def test_signal_forwarding(self, sighup = True):
"""
To test that invoker is killed by the same signal as the application
"""
@ -163,9 +177,13 @@ class InvokerTests(unittest.TestCase):
self.assert_(op.split('\n')[-1].startswith('Aborted') == True, "The invoker(q-booster) was not killed by the same signal")
time.sleep(2)
if(sighup):
self.sighup_applauncherd()
self.test_signal_forwarding(False)
def test_invoker_delay(self):
def test_invoker_delay(self, sighup = True):
"""
Test the --delay parameter of the invoker.
"""
@ -197,7 +215,11 @@ class InvokerTests(unittest.TestCase):
self.assert_(success, "invoker terminated before delay elapsed")
def test_invoker_exit_status(self):
if(sighup):
self.sighup_applauncherd()
self.test_invoker_delay(False)
def test_invoker_exit_status(self, sighup = True):
"""
To test that invoker returns the same exit status as the application
"""
@ -222,7 +244,11 @@ class InvokerTests(unittest.TestCase):
self.assert_(app_st_wo_inv == app_st_w_inv, "The invoker returns a wrong exit status for booster-m")
self.assert_(app_st_wo_inv == app_st_we_inv, "The invoker returns a wrong exit status for booster-e")
def test_invoker_search_prog(self):
if(sighup):
self.sighup_applauncherd()
self.test_invoker_exit_status(False)
def test_invoker_search_prog(self, sighup = True):
"""
Test that invoker can find programs from directories listed in
PATH environment variable and that it doesn't find something
@ -249,8 +275,12 @@ class InvokerTests(unittest.TestCase):
self.assert_(p.wait() != 127, "Found spam_cakefor some reason")
time.sleep(2)
kill_process('spam_cake')
if(sighup):
self.sighup_applauncherd()
self.test_invoker_search_prog(False)
def test_invoker_gid_uid(self):
def test_invoker_gid_uid(self, sighup = True):
"""
To Test that the set gid and uid is passed from invoker process to launcher
"""
@ -312,13 +342,17 @@ class InvokerTests(unittest.TestCase):
self.assert_(usr_id == usr_id2, "The correct UID is not passed by invoker")
self.assert_(grp_id == grp_id2, "The correct GID is not passed by invoker")
if(sighup):
self.sighup_applauncherd()
self.test_invoker_gid_uid(False)
def test_invoker_param_creds(self):
p = run_cmd_as_user('invoker --creds')
self.assert_(p.wait() == 0, "'invoker --creds' failed")
def test_invoker_param_respawn_delay(self):
def test_invoker_param_respawn_delay(self, sighup = True):
p = run_cmd_as_user('invoker --respawn 10 --type=q --no-wait fala_ft_hello')
time.sleep(7)
@ -335,6 +369,10 @@ class InvokerTests(unittest.TestCase):
self.assert_(p.wait() != 0, "invoker didn't die with too big respawn delay")
kill_process('fala_ft_hello')
if(sighup):
self.sighup_applauncherd()
self.test_invoker_param_respawn_delay(False)
def test_invoker_bogus_apptype(self):
p = run_cmd_as_user('invoker --type=foobar fala_ft_hello')
self.assert_(p.wait() != 0, "invoker didn't die with bogus apptype")
@ -342,7 +380,7 @@ class InvokerTests(unittest.TestCase):
p = run_cmd_as_user('invoker fala_ft_hello')
self.assert_(p.wait() != 0, "invoker didn't die with empty apptype")
def test_invoker_signal_forward(self):
def test_invoker_signal_forward(self, sighup = True):
"""
Test that UNIX signals are forwarded from
invoker to the invoked process
@ -354,6 +392,10 @@ class InvokerTests(unittest.TestCase):
self.assert_(op.startswith('Segmentation fault') == True, "The invoker(m-booster) was not killed by the same signal")
time.sleep(2)
if(sighup):
self.sighup_applauncherd()
self.test_invoker_signal_forward(False)
def test_wrong_type(self):
"""
Test that invoker help is printed if application is
@ -411,7 +453,7 @@ class InvokerTests(unittest.TestCase):
p = run_cmd_as_user('invoker')
self.assert_(p.wait() == 1, "'invoker' failed")
def test_app_link(self):
def test_app_link(self, sighup = True):
"""
Test that symlink of an application can be launched.
"""
@ -424,7 +466,11 @@ class InvokerTests(unittest.TestCase):
kill_process("fala_link")
self.assert_(pid != None ,"The application was not launched")
def test_D_and_G_option(self):
if(sighup):
self.sighup_applauncherd()
self.test_app_link(False)
def test_D_and_G_option(self, sighup = True):
"""
Test that -D and -G options work and applications are launcherd
-G = INVOKER_MSG_MAGIC_OPTION_DLOPEN_GLOBAL
@ -442,7 +488,11 @@ class InvokerTests(unittest.TestCase):
kill_process("fala_wl")
self.assert_(pid != None ,"The application was not launched")
def test_app_directory(self):
if(sighup):
self.sighup_applauncherd()
self.test_D_and_G_option(False)
def test_app_directory(self, sighup = True):
"""
Test that invoker is unable to launch a application which is a directory
"""
@ -453,6 +503,10 @@ class InvokerTests(unittest.TestCase):
os.system("rm -rf /usr/bin/fala_dir")
self.assert_(st != 0 ,"The application was not launched")
if(sighup):
self.sighup_applauncherd()
self.test_app_directory(False)
def test_unsetPATH_launch(self):
"""
Unset the PATH env variable and try to launch an application with
@ -462,7 +516,7 @@ class InvokerTests(unittest.TestCase):
self.assert_(st != 0, "The application was launched")
self.assert_(op == "invoker: died: could not get PATH environment variable", "The application was launched")
def test_invoker_wait_term(self):
def test_invoker_wait_term(self, sighup = True):
"""
start application with --wait-term parameter.
Check that application is started and invoker is waiting termination before exit
@ -494,7 +548,11 @@ class InvokerTests(unittest.TestCase):
self.assert_(success, "invoker terminated before delay elapsed")
def test_relative_path_search(self):
if(sighup):
self.sighup_applauncherd()
self.test_invoker_wait_term(False)
def test_relative_path_search(self, sighup = True):
"""
Test that invoker searches the application through relative path
"""
@ -503,7 +561,11 @@ class InvokerTests(unittest.TestCase):
kill_process("fala_wl")
self.assert_(pid != None ,"The application was not launched")
def test_oom_adj_minus_two(self):
if(sighup):
self.sighup_applauncherd()
self.test_relative_path_search(False)
def test_oom_adj_minus_two(self, sighup = True):
"""
Test that oom.adj is -2 for launched application process when using
invokers -o param
@ -521,6 +583,10 @@ class InvokerTests(unittest.TestCase):
kill_process(PREFERED_APP)
if(sighup):
self.sighup_applauncherd()
self.test_oom_adj_minus_two(False)
def test_invoker_applauncherd_dies(self):
"""

@ -78,6 +78,11 @@ class SingleInstanceTests(unittest.TestCase):
if self.START_DAEMONS_AT_TEARDOWN:
start_daemons()
def sighup_applauncherd(self):
same_pid, booster_status = send_sighup_to_applauncherd()
self.assert_(same_pid, "Applauncherd has new pid after SIGHUP")
self.assert_(booster_status, "Atleast one of the boosters is not restarted")
#Testcases
def minimize(self, app = None, pid = None):
# get window id
@ -358,55 +363,73 @@ class SingleInstanceTests(unittest.TestCase):
def test_single_instance_abnormal_lock_release_without_invoker(self):
self.single_instance_abnormal_lock_release('single-instance')
def test_single_instance_window_raise_with_invoker(self):
def test_single_instance_window_raise_with_invoker(self, sighup = True):
self.single_instance_window_raise('invoker --type=m --single-instance')
if(sighup):
self.sighup_applauncherd()
self.test_single_instance_window_raise_with_invoker(False)
def test_single_instance_and_non_single_instance_with_invoker(self):
def test_single_instance_and_non_single_instance_with_invoker(self, sighup = True):
self.single_instance_and_non_single_instance('invoker --type=m --single-instance')
if(sighup):
self.sighup_applauncherd()
self.test_single_instance_and_non_single_instance_with_invoker(False)
def test_single_instance_stress_test_with_invoker(self):
def test_single_instance_stress_test_with_invoker(self, sighup = True):
self.single_instance_stress_test('invoker --type=m --single-instance')
if(sighup):
self.sighup_applauncherd()
self.test_single_instance_stress_test_with_invoker(False)
def test_single_instance_abnormal_lock_release_with_invoker(self):
def test_single_instance_abnormal_lock_release_with_invoker(self, sighup = True):
self.single_instance_abnormal_lock_release('invoker --type=m --single-instance')
if(sighup):
self.sighup_applauncherd()
self.test_single_instance_abnormal_lock_release_with_invoker(False)
def test_single_instance_window_raise_with_script(self):
def test_single_instance_window_raise_with_script(self, sighup = True):
self.single_instance_window_raise_with_script('invoker --single-instance --type=e')
if(sighup):
self.sighup_applauncherd()
self.test_single_instance_window_raise_with_script(False)
def test_single_instance_windowless_w_invoker(self):
def test_single_instance_windowless_w_invoker(self, sighup = True):
"""
To test that starting twice windowless application with invoker with single-instance
will report error in syslog
will report error in syslog
"""
app = '/usr/bin/fala_windowless'
#remove already running fala_windowless if any
app = '/usr/bin/fala_windowless'
#remove already running fala_windowless if any
kill_process(app)
#check applauncherd is started
#check applauncherd is started
pid_ad = wait_for_single_applauncherd()
self.assert_(pid_ad != None, "Applauncherd was not started")
#run fala_windowless first time
#run fala_windowless first time
run_app_as_user_with_invoker(app, booster = 'm', arg = "--single-instance")
pid1 = wait_for_app(app)
self.assert_(pid1 != None, "%s was not started." % app)
#count previous error messages related to single instance application start attempts
st, op = commands.getstatusoutput('grep -c "]: Booster: Can\'t activate existing instance of the application!" /var/log/syslog ')
debug("The errors count in syslog is: %s" %op)
#run fala_windowless second time
#count previous error messages related to single instance application start attempts
st, op = commands.getstatusoutput('grep -c "]: Booster: Can\'t activate existing instance of the application!" /var/log/syslog ')
debug("The errors count in syslog is: %s" %op)
#run fala_windowless second time
run_app_as_user_with_invoker(app, booster = 'm', arg = "--single-instance")
time.sleep(5)
pid2 = get_pid(app)
time.sleep(5)
pid2 = get_pid(app)
#count error messages in sislog once again
st1, op1 = commands.getstatusoutput('grep -c "]: Booster: Can\'t activate existing instance of the application!" /var/log/syslog ')
debug("The errors count in syslog is: %s" %op1)
#cleanup
pid_list = pid2.split()
st1, op1 = commands.getstatusoutput('grep -c "]: Booster: Can\'t activate existing instance of the application!" /var/log/syslog ')
debug("The errors count in syslog is: %s" %op1)
#cleanup
pid_list = pid2.split()
for pid in pid_list:
kill_process(apppid=pid)
#check only one instance has been started
#check only one instance has been started
self.assert_(len(pid_list) == 1, "Second instance of single-instance app has been started.");
#check +1 error message found
self.assert_(int(op) + 1 == int(op1), "No errror has been logged to syslog for windowless single instance app.")
#check +1 error message found
self.assert_(int(op) + 1 == int(op1), "No errror has been logged to syslog for windowless single instance app.")
if(sighup):
self.sighup_applauncherd()
self.test_single_instance_windowless_w_invoker(False)
if __name__ == '__main__':
# When run with testrunner, for some reason the PATH doesn't include

@ -134,6 +134,15 @@ def get_pid(appname):
else:
return None
def get_oldest_pid(appname):
temp = basename(appname)[:14]
st, op = commands.getstatusoutput("pgrep -o %s" % temp)
debug("The Pid of %s is %s" %(appname, op))
if st == 0:
return op
else:
return None
def get_newest_pid(app):
p = subprocess.Popen(['pgrep', '-n', app], shell = False,
stdout = subprocess.PIPE, stderr = DEV_NULL)
@ -187,10 +196,11 @@ def wait_for_single_applauncherd(timeout = 20, sleep = 1):
return pid
def get_booster_pid():
wait_for_app('booster-q')
wait_for_app('booster-e')
wait_for_app('booster-d')
wait_for_app('booster-m')
qpid = wait_for_app('booster-q')
epid = wait_for_app('booster-e')
dpid = wait_for_app('booster-d')
mpid = wait_for_app('booster-m')
return (epid, dpid, qpid, mpid)
def kill_process(appname=None, apppid=None, signum=15):
# obtained by running 'kill -l'
@ -339,3 +349,16 @@ def get_groups_for_user():
p.wait()
return groups
def send_sighup_to_applauncherd():
pid1 = get_oldest_pid('applauncherd')
(e1, d1, q1, m1) = get_booster_pid()
debug("before sighup, applauncherd pid = ", pid1)
kill_process(None, pid1, 1)
time.sleep(5)
pid2 = wait_for_single_applauncherd()
(e2, d2, q2, m2) = get_booster_pid()
debug("after sighup, applauncherd pid = ", pid2)
return (pid1==pid2, m1!=m2 and q1!=q2 and d1!=d2 and e1!=e2)

Loading…
Cancel
Save