mirror of https://github.com/cutefishos/appmotor
parent
8593d359db
commit
c3cba0a91e
@ -0,0 +1,32 @@
|
|||||||
|
# Set sources
|
||||||
|
set(SRC fala_wait.cpp)
|
||||||
|
|
||||||
|
link_libraries(${MEEGOTOUCH_LIBRARIES})
|
||||||
|
|
||||||
|
include(${QT_USE_FILE})
|
||||||
|
|
||||||
|
# Use the compiler and linker flags given in meegotouch-boostable.pc
|
||||||
|
# in the source tree.
|
||||||
|
execute_process(COMMAND "env"
|
||||||
|
"PKG_CONFIG_PATH=${CMAKE_SOURCE_DIR}/data/pkgconfig"
|
||||||
|
"/usr/bin/pkg-config"
|
||||||
|
"--cflags"
|
||||||
|
"meegotouch-boostable"
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE booster_cflags
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
execute_process(COMMAND "env"
|
||||||
|
"PKG_CONFIG_PATH=${CMAKE_SOURCE_DIR}/data/pkgconfig"
|
||||||
|
"/usr/bin/pkg-config" "--libs"
|
||||||
|
"meegotouch-boostable"
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE booster_libs
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${booster_cflags}")
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS ${booster_libs})
|
||||||
|
|
||||||
|
add_executable(fala_wait ${SRC})
|
||||||
|
|
||||||
|
# Install
|
||||||
|
install(PROGRAMS fala_wait DESTINATION /usr/bin/ )
|
||||||
|
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
** All rights reserved.
|
||||||
|
** Contact: Nokia Corporation (directui@nokia.com)
|
||||||
|
**
|
||||||
|
** This file is part of applauncherd
|
||||||
|
**
|
||||||
|
** If you have questions regarding the use of this file, please contact
|
||||||
|
** Nokia at directui@nokia.com.
|
||||||
|
**
|
||||||
|
** This library is free software; you can redistribute it and/or
|
||||||
|
** modify it under the terms of the GNU Lesser General Public
|
||||||
|
** License version 2.1 as published by the Free Software Foundation
|
||||||
|
** and appearing in the file LICENSE.LGPL included in the packaging
|
||||||
|
** of this file.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <MApplication>
|
||||||
|
#include <MExport>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#ifdef HAVE_MCOMPONENTCACHE
|
||||||
|
#include <mcomponentcache.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
M_EXPORT int main(int argc, char ** argv)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_MCOMPONENTCACHE
|
||||||
|
MApplication *app = MComponentCache::mApplication(argc, argv);
|
||||||
|
#endif
|
||||||
|
QTimer::singleShot(6000, app, SLOT(quit()));
|
||||||
|
app->exec();
|
||||||
|
}
|
||||||
@ -1,3 +1,3 @@
|
|||||||
install(PROGRAMS fala_sf_m.sh fala_sf_qt.sh fala_sf_d.sh fala_sf_e.sh DESTINATION /usr/share/applauncherd-testscripts/signal-forward)
|
install(PROGRAMS fala_sf_m.sh fala_sf_qt.sh fala_sf_d.sh fala_sf_e.sh DESTINATION /usr/share/applauncherd-testscripts/signal-forward)
|
||||||
install(PROGRAMS fala_sf_m.py fala_sf_qt.py fala_sf_d.py fala_sf_e.py DESTINATION /usr/share/applauncherd-testscripts/signal-forward)
|
install(PROGRAMS fala_sf_m.py fala_sf_qt.py fala_sf_d.py fala_sf_e.py fala_inv_sf.py DESTINATION /usr/share/applauncherd-testscripts/signal-forward)
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
import commands
|
||||||
|
|
||||||
|
#Launching application from the script
|
||||||
|
os.system("/usr/share/applauncherd-testscripts/signal-forward/fala_sf_m.sh &")
|
||||||
|
|
||||||
|
time.sleep(2)
|
||||||
|
st, op = commands.getstatusoutput("ps ax | grep fala_ft_hello")
|
||||||
|
if op.split("\n")[1].find("invoker") != -1:
|
||||||
|
op = op.split("\n")[1].split(" ")[0]
|
||||||
|
else:
|
||||||
|
print("The Application was not launched by invoker")
|
||||||
|
exit
|
||||||
|
|
||||||
|
#Killing application with a signal 11 (Segmentation Fault)
|
||||||
|
commands.getoutput("kill -11 %s" %op)
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
@ -0,0 +1,197 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
#
|
||||||
|
# Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
# All rights reserved.
|
||||||
|
# Contact: Nokia Corporation (directui@nokia.com)
|
||||||
|
#
|
||||||
|
# This file is part of applauncherd.
|
||||||
|
#
|
||||||
|
# If you have questions regarding the use of this file, please contact
|
||||||
|
# Nokia at directui@nokia.com.
|
||||||
|
#
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License version 2.1 as published by the Free Software Foundation
|
||||||
|
# and appearing in the file LICENSE.LGPL included in the packaging
|
||||||
|
# of this file.
|
||||||
|
|
||||||
|
"""
|
||||||
|
This program tests the functionalities of invoker
|
||||||
|
Authors: nimika.1.keshri@nokia.com
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os, os.path, glob
|
||||||
|
import subprocess
|
||||||
|
import commands
|
||||||
|
import time
|
||||||
|
import sys
|
||||||
|
import unittest
|
||||||
|
import re
|
||||||
|
from subprocess import Popen
|
||||||
|
from utils import *
|
||||||
|
from os.path import basename
|
||||||
|
|
||||||
|
class InvokerTests(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
debug("setUp")
|
||||||
|
if get_pid('applauncherd') == None:
|
||||||
|
start_applauncherd()
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
debug("tearDown")
|
||||||
|
if get_pid('applauncherd') == None:
|
||||||
|
start_applauncherd()
|
||||||
|
|
||||||
|
wait_for_single_applauncherd()
|
||||||
|
|
||||||
|
#Testcases
|
||||||
|
def test_invoker_signal_forward(self):
|
||||||
|
"""
|
||||||
|
Test that UNIX signals are forwarded from
|
||||||
|
invoker to the invoked process
|
||||||
|
"""
|
||||||
|
st, op = commands.getstatusoutput("/usr/share/applauncherd-testscripts/signal-forward/fala_inv_sf.py")
|
||||||
|
time.sleep(3)
|
||||||
|
debug("The Invoker killed by : <%s>" %op)
|
||||||
|
|
||||||
|
self.assert_(op == 'Segmentation fault', "The invoker(m-booster) was not killed by the same signal")
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
|
def test_wrong_type(self):
|
||||||
|
"""
|
||||||
|
Test that invoker help is printed if application is
|
||||||
|
invoked using a wrong type
|
||||||
|
"""
|
||||||
|
cmd = '/usr/bin/invoker --type=f /usr/bin/fala_wl'
|
||||||
|
debug("Launch application with wrong type %s" %cmd)
|
||||||
|
st, op = commands.getstatusoutput('su - user -c "%s"' %cmd)
|
||||||
|
self.assert_(op.split("\n")[0] == 'invoker: error: Unknown application type: f ',"No Error displayed")
|
||||||
|
self.assert_(op.split("\n")[2] == 'Usage: invoker [options] [--type=TYPE] [file] [args]',"No usgae displayed")
|
||||||
|
|
||||||
|
def test_unknown_parameter(self):
|
||||||
|
"""
|
||||||
|
Test that help is printed if unknown parameter
|
||||||
|
is passed to invoker
|
||||||
|
"""
|
||||||
|
cmd = '/usr/bin/invoker --type=m --x /usr/bin/fala_wl'
|
||||||
|
debug("Launch application with wrong option %s" %cmd)
|
||||||
|
st, op = commands.getstatusoutput('su - user -c "%s"' %cmd)
|
||||||
|
self.assert_(op.split("\n")[2] == 'Usage: invoker [options] [--type=TYPE] [file] [args]',"No usage displayed")
|
||||||
|
|
||||||
|
def test_non_existing_binary_launch(self):
|
||||||
|
"""
|
||||||
|
Test that invoker gives error when it tries to launch
|
||||||
|
a binary that does not exist
|
||||||
|
"""
|
||||||
|
cmd = '/usr/bin/invoker --type=m /usr/bin/fala_foo'
|
||||||
|
debug("Launch a non existing application %s" %cmd)
|
||||||
|
st, op = commands.getstatusoutput('su - user -c "%s"' %cmd)
|
||||||
|
self.assert_(st != 0,"The application was launched")
|
||||||
|
|
||||||
|
def test_invoker_symlink(self):
|
||||||
|
"""
|
||||||
|
Test that the symlink of invoker is unable to launch applications
|
||||||
|
"""
|
||||||
|
os.system("ln -s /usr/bin/invoker /usr/bin/invoker_link")
|
||||||
|
cmd = "/usr/bin/invoker_link --type=m /usr/bin/fala_wl"
|
||||||
|
st, op = commands.getstatusoutput('su - user -c "%s"' %cmd)
|
||||||
|
os.system("rm /usr/bin/invoker_link")
|
||||||
|
self.assert_(st != 0,"The application was launched")
|
||||||
|
|
||||||
|
def test_app_link(self):
|
||||||
|
"""
|
||||||
|
Test that symlink of an application can be launched.
|
||||||
|
"""
|
||||||
|
os.system("ln -s /usr/bin/fala_wl /usr/bin/fala_link")
|
||||||
|
cmd = "/usr/bin/invoker --type=m /usr/bin/fala_link"
|
||||||
|
os.system('su - user -c "%s"&' %cmd)
|
||||||
|
pid = get_pid("fala_link")
|
||||||
|
os.system("rm /usr/bin/fala_link")
|
||||||
|
kill_process("fala_link")
|
||||||
|
self.assert_(pid != None ,"The application was not launched")
|
||||||
|
|
||||||
|
def test_D_and_G_option(self):
|
||||||
|
"""
|
||||||
|
Test that -D and -G options work and applications are launcherd
|
||||||
|
-G = INVOKER_MSG_MAGIC_OPTION_DLOPEN_GLOBAL
|
||||||
|
-D = INVOKER_MSG_MAGIC_OPTION_DLOPEN_DEEP
|
||||||
|
"""
|
||||||
|
p = run_app_as_user_with_invoker("/usr/bin/fala_wl", booster='m', arg = '-G')
|
||||||
|
time.sleep(3)
|
||||||
|
pid = p.pid
|
||||||
|
kill_process("fala_wl")
|
||||||
|
self.assert_(pid != None ,"The application was not launched")
|
||||||
|
|
||||||
|
p = run_app_as_user_with_invoker("/usr/bin/fala_wl", booster='m', arg = '-D')
|
||||||
|
time.sleep(3)
|
||||||
|
pid = p.pid
|
||||||
|
kill_process("fala_wl")
|
||||||
|
self.assert_(pid != None ,"The application was not launched")
|
||||||
|
|
||||||
|
def test_app_directory_file(self):
|
||||||
|
"""
|
||||||
|
Test that invoker is unable to launch a application which is a directory
|
||||||
|
"""
|
||||||
|
#Test for a directory
|
||||||
|
os.system("mkdir /usr/bin/fala_dir")
|
||||||
|
st, op = commands.getstatusoutput("/usr/bin/invoker --type=m /usr/bin/fala_dir")
|
||||||
|
time.sleep(3)
|
||||||
|
os.system("rm -rf /usr/bin/fala_dir")
|
||||||
|
self.assert_(st != 0 ,"The application was not launched")
|
||||||
|
|
||||||
|
def test_unsetPATH_launch(self):
|
||||||
|
"""
|
||||||
|
Unset the PATH env variable and try to launch an application with
|
||||||
|
relative path. The launch should fail
|
||||||
|
"""
|
||||||
|
st, op = commands.getstatusoutput("(unset PATH;/usr/bin/invoker --type=m fala_wl)")
|
||||||
|
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):
|
||||||
|
"""
|
||||||
|
start application with --wait-term parameter.
|
||||||
|
Check that application is started and invoker is waiting termination before exit
|
||||||
|
"""
|
||||||
|
|
||||||
|
# launch an app with invoker --wait-term
|
||||||
|
debug("launching fala_wait ...")
|
||||||
|
p = Popen(['/usr/bin/invoker', '--type=m', '--wait-term',
|
||||||
|
'/usr/bin/fala_wait'],
|
||||||
|
shell=False,
|
||||||
|
stdout=DEV_NULL, stderr=DEV_NULL)
|
||||||
|
|
||||||
|
# wait a little
|
||||||
|
debug("waiting ...")
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
|
success = True
|
||||||
|
|
||||||
|
if p.poll() == None:
|
||||||
|
debug("NOT DEAD")
|
||||||
|
else:
|
||||||
|
debug("DEAD")
|
||||||
|
success = False
|
||||||
|
|
||||||
|
debug("waiting for invoker to terminate ...")
|
||||||
|
p.wait()
|
||||||
|
|
||||||
|
debug("terminating fala_wait ...")
|
||||||
|
|
||||||
|
self.assert_(success, "invoker terminated before delay elapsed")
|
||||||
|
|
||||||
|
|
||||||
|
# main
|
||||||
|
if __name__ == '__main__':
|
||||||
|
# When run with testrunner, for some reason the PATH doesn't include
|
||||||
|
# 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
|
||||||
|
|
||||||
|
tests = sys.argv[1:]
|
||||||
|
mysuite = unittest.TestSuite(map(InvokerTests, tests))
|
||||||
|
result = unittest.TextTestRunner(verbosity=2).run(mysuite)
|
||||||
|
if not result.wasSuccessful():
|
||||||
|
sys.exit(1)
|
||||||
|
sys.exit(0)
|
||||||
Loading…
Reference in New Issue