From a9f688e2766ee81baa943df86c9103c0f169250d Mon Sep 17 00:00:00 2001 From: Alexey Shilov Date: Wed, 25 Aug 2010 13:26:46 +0300 Subject: [PATCH 01/19] Changes: signals forwarding update --- CMakeLists.txt | 5 ++- debian/changelog | 7 +++ src/invoker/CMakeLists.txt | 2 +- src/invoker/invoker.c | 9 ++-- src/invoker/report.c | 4 +- src/launcher/booster.cpp | 22 +++++---- src/launcher/booster.h | 2 +- src/launcher/connection.cpp | 2 +- src/launcher/connection.h | 2 +- src/launcher/daemon.cpp | 47 +++++++++++++++----- src/launcher/daemon.h | 6 +++ src/launcher/logger.cpp | 2 +- src/launcher/main.cpp | 6 +-- src/launcher/mbooster.cpp | 2 +- src/launcher/mbooster.h | 2 +- src/launcher/qtbooster.cpp | 2 +- src/launcher/qtbooster.h | 2 +- tests/unittests/ut_connection/CMakeLists.txt | 2 +- tests/unittests/ut_daemon/CMakeLists.txt | 2 +- 19 files changed, 89 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 16229af..cac933a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,8 +41,9 @@ if ($ENV{DISABLE_VERIFICATION}) add_definitions(-DDISABLE_VERIFICATION) endif ($ENV{DISABLE_VERIFICATION}) -# Set the program name define. Must be at this level due to unit tests. -add_definitions(-DPROG_NAME="applauncherd") +# Set the program name defines. Must be at this level due to unit tests. +add_definitions(-DPROG_NAME_INVOKER="invoker") +add_definitions(-DPROG_NAME_LAUNCHER="applauncherd") # Build with test coverage switch if BUILD_COVERAGE environment variable is set if ($ENV{BUILD_COVERAGE}) diff --git a/debian/changelog b/debian/changelog index 33745c4..6ed3e4c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +applauncherd (0.10.4) unstable; urgency=low + + * Changes: Handle PWD correctly + * Changes: PROG_NAME separated into PROG_NAME_INVOKER and PROG_NAME_LAUNCHER + + -- Jussi Lind Tue, 24 Aug 2010 18:04:39 +0300 + applauncherd (0.10.3) stable; urgency=low * Changes: pass and set gid and uid from invoker process to launcher diff --git a/src/invoker/CMakeLists.txt b/src/invoker/CMakeLists.txt index cd3e2b0..5cdd229 100644 --- a/src/invoker/CMakeLists.txt +++ b/src/invoker/CMakeLists.txt @@ -8,7 +8,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/src/comm set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -W -Wall -O2") # Set precompiler flags -add_definitions(-DPROG_NAME="invoker") +add_definitions(-DPROG_NAME_INVOKER="invoker") # Set target add_executable(invoker ${SRC}) diff --git a/src/invoker/invoker.c b/src/invoker/invoker.c index f3afe4c..e75445e 100644 --- a/src/invoker/invoker.c +++ b/src/invoker/invoker.c @@ -61,6 +61,7 @@ extern char ** environ; // pid of invoked process static pid_t invoked_pid = -1; +static void sigs_restore(void); static void sig_forwarder(int sig) { @@ -68,8 +69,10 @@ static void sig_forwarder(int sig) { if (kill(invoked_pid, sig) != 0) { - die(1, "Can't send signal to application: %s \n", strerror(errno)); + report(report_error, "Can't send signal to application: %s \n", strerror(errno)); } + sigs_restore(); + raise(sig); } } @@ -394,7 +397,7 @@ static void usage(int status) " -w, --wait-term Wait for launched process to terminate.\n" " -h, --help Print this help message.\n\n" "Example: %s --type=m /usr/bin/helloworld \n", - PROG_NAME, DEFAULT_DELAY, PROG_NAME); + PROG_NAME_INVOKER, DEFAULT_DELAY, PROG_NAME_INVOKER); exit(status); } @@ -487,7 +490,7 @@ int main(int argc, char *argv[]) char **prog_argv = NULL; char *prog_name = NULL; - if (!strstr(argv[0], PROG_NAME) ) + if (!strstr(argv[0], PROG_NAME_INVOKER) ) { // Called with a different name, old way of using invoker die(1, diff --git a/src/invoker/report.c b/src/invoker/report.c index a8cd217..66e9756 100644 --- a/src/invoker/report.c +++ b/src/invoker/report.c @@ -35,7 +35,7 @@ void report_set_output(enum report_output new_output) closelog(); if (new_output == report_syslog) - openlog(PROG_NAME, LOG_PID, LOG_DAEMON); + openlog(PROG_NAME_INVOKER, LOG_PID, LOG_DAEMON); output = new_output; } @@ -72,7 +72,7 @@ static void vreport(enum report_type type, char *msg, va_list arg) vsnprintf(str, sizeof(str), msg, arg); if (output == report_console) - printf("%s: %s%s", PROG_NAME, str_type, str); + printf("%s: %s%s", PROG_NAME_INVOKER, str_type, str); else if (output == report_syslog) syslog(log_type, "%s%s", str_type, str); } diff --git a/src/launcher/booster.cpp b/src/launcher/booster.cpp index 654f75f..7f85b16 100644 --- a/src/launcher/booster.cpp +++ b/src/launcher/booster.cpp @@ -174,24 +174,30 @@ int Booster::launchProcess() if (!errno && cur_prio < m_app.priority()) setpriority(PRIO_PROCESS, 0, m_app.priority()); - // Possible set user ID and group ID of calling process - uid_t uid = getuid(); - gid_t gid = getgid(); + // Set user ID and group ID of calling process if differing + // from the ones we got from invoker - if (uid != m_app.userId()) + if (getuid() != m_app.userId()) setuid(m_app.userId()); - if (gid != m_app.groupId()) + if (getgid() != m_app.groupId()) setgid(m_app.groupId()); - // Load the application and find out the address of main() void* handle = loadMain(); + // Duplicate I/O descriptors for (unsigned int i = 0; i < m_app.ioDescriptors().size(); i++) if (m_app.ioDescriptors()[i] > 0) dup2(m_app.ioDescriptors()[i], i); + // Set PWD + const char * pwd = getenv("PWD"); + if (pwd) + { + chdir(pwd); + } + Logger::logNotice("launching process: '%s' ", m_app.fileName().c_str()); // Close logger @@ -256,11 +262,11 @@ bool Booster::popPriority() return false; } -pid_t Booster::invokersPid() +pid_t Booster::invokerPid() { if (m_conn->isReportAppExitStatusNeeded()) { - return m_conn->peersPid(); + return m_conn->peerPid(); } else { diff --git a/src/launcher/booster.h b/src/launcher/booster.h index 3f8551b..0499652 100644 --- a/src/launcher/booster.h +++ b/src/launcher/booster.h @@ -105,7 +105,7 @@ public: bool popPriority(); //! Get invoker's pid - pid_t invokersPid(); + pid_t invokerPid(); protected: diff --git a/src/launcher/connection.cpp b/src/launcher/connection.cpp index 640504e..5712303 100644 --- a/src/launcher/connection.cpp +++ b/src/launcher/connection.cpp @@ -548,7 +548,7 @@ bool Connection::isReportAppExitStatusNeeded() return m_sendPid; } -pid_t Connection::peersPid() +pid_t Connection::peerPid() { struct ucred cr; diff --git a/src/launcher/connection.h b/src/launcher/connection.h index 775cb50..6327840 100644 --- a/src/launcher/connection.h +++ b/src/launcher/connection.h @@ -90,7 +90,7 @@ public: static void closeAllSockets(); //! \brief Get pid of the process on the other end of socket connection - pid_t peersPid(); + pid_t peerPid(); private: diff --git a/src/launcher/daemon.cpp b/src/launcher/daemon.cpp index b85007b..28c4406 100644 --- a/src/launcher/daemon.cpp +++ b/src/launcher/daemon.cpp @@ -147,18 +147,32 @@ void Daemon::run() ssize_t count = read(m_pipefd[0], reinterpret_cast(&msg), 1); if (count) { - // read pid of peer invoker pid_t invoker_pid; count = read(m_pipefd[0], reinterpret_cast(&invoker_pid), sizeof(pid_t)); - if (count < sizeof(pid_t)) + if (count < static_cast(sizeof(pid_t))) { Logger::logErrorAndDie(EXIT_FAILURE, "Daemon: pipe connection with booster failed"); } else { - Logger::logError("Daemon: invokers pid: \n", invoker_pid); + Logger::logError("Daemon: invoker's pid: %d \n", invoker_pid); + } + + if (invoker_pid != 0) + { + // store booster - invoker pids pair + pid_t booster_pid; + if (MBooster::type() == msg) + { + booster_pid = MBooster::processId(); + } + else if (QtBooster::type() == msg) + { + booster_pid = QtBooster::processId(); + } + m_kindergarten[booster_pid] = invoker_pid; } // Fork a new booster of the given type @@ -256,7 +270,7 @@ bool Daemon::forkBooster(char type, int sleepTime) } // Send to the parent process pid of invoker for tracking - pid_t pid = booster->invokersPid(); + pid_t pid = booster->invokerPid(); ret = write(m_pipefd[1], reinterpret_cast(&pid), sizeof(pid_t)); if (ret == -1) { Logger::logError("Daemon: Can't send invoker's pid to launcher process' \n"); @@ -305,20 +319,33 @@ void Daemon::reapZombies() if (pid) { i = m_children.erase(i); - Logger::logError("Daemon: terminated process pid is %d", pid); - if (WIFSIGNALED(status)) + PidMap::iterator it = m_kindergarten.find(pid); + if (it != m_kindergarten.end()) { - // todo: send signal to corresponding invoker form here - Logger::logError("Daemon: booster (pid=%d) terminated due to signal=%d\n", pid, WTERMSIG(status)); + Logger::logInfo("Daemon: terminated process is in the kendergarten"); + + if (WIFSIGNALED(status)) + { + int signal = WTERMSIG(status); + pid_t invoker_pid = (*it).second; + Logger::logInfo("Daemon: booster (pid=%d) terminated due to signal=%d\n", pid, signal); + Logger::logInfo("Daemon: kill invoker process %d by signal %d \n", invoker_pid, signal); + if (kill(invoker_pid, signal) != 0) + { + Logger::logError("Daemon: failed to send signal to invoker: %s \n", strerror(errno)); + } + } + // remove dead booster + m_kindergarten.erase(it); } // Check if pid belongs to boosters, restart dead booster if needed - if (pid == MBooster::ProcessId()) + if (pid == MBooster::processId()) { forkBooster(MBooster::type(), m_boosterSleepTime); } - else if (pid == QtBooster::ProcessId()) + else if (pid == QtBooster::processId()) { forkBooster(QtBooster::type(), m_boosterSleepTime); } diff --git a/src/launcher/daemon.h b/src/launcher/daemon.h index 4f06cf0..e9901d3 100644 --- a/src/launcher/daemon.h +++ b/src/launcher/daemon.h @@ -22,10 +22,12 @@ #include #include +#include #include using std::vector; using std::string; +using std::map; /*! * \class Daemon. @@ -107,6 +109,10 @@ private: typedef vector PidVect; PidVect m_children; + //! storage of booster-invoker pid pairs + typedef map PidMap; + PidMap m_kindergarten; + // Pipe used to tell the parent that a new booster is needed int m_pipefd[2]; diff --git a/src/launcher/logger.cpp b/src/launcher/logger.cpp index 851cd3c..2635179 100644 --- a/src/launcher/logger.cpp +++ b/src/launcher/logger.cpp @@ -27,7 +27,7 @@ namespace { const QString logDirectory("/var/log"); - const QString logFileName(logDirectory + QDir::separator() + PROG_NAME + ".log"); + const QString logFileName(logDirectory + QDir::separator() + PROG_NAME_LAUNCHER + ".log"); const QString oldLogFileName(logFileName + ".old"); const QString dateFormat("yyyy-MM-dd hh:mm:ss.zzz"); } diff --git a/src/launcher/main.cpp b/src/launcher/main.cpp index 720df2c..a6d4aca 100644 --- a/src/launcher/main.cpp +++ b/src/launcher/main.cpp @@ -48,7 +48,7 @@ void exitLauncher(int) void usage() { - std::cout << "Usage: "<< PROG_NAME << " [options]\n" + std::cout << "Usage: "<< PROG_NAME_LAUNCHER << " [options]\n" << "\n" << "Options:\n" << " --daemon Fork and go into the background.\n" @@ -77,8 +77,8 @@ int main(int argc, char * argv[]) } // Open the log - Logger::openLog(PROG_NAME); - Logger::logNotice("%s starting..", PROG_NAME); + Logger::openLog(PROG_NAME_LAUNCHER); + Logger::logNotice("%s starting..", PROG_NAME_LAUNCHER); // Check that an instance of launcher is not already running if(!Daemon::lock()) diff --git a/src/launcher/mbooster.cpp b/src/launcher/mbooster.cpp index b56ecae..26502a3 100644 --- a/src/launcher/mbooster.cpp +++ b/src/launcher/mbooster.cpp @@ -64,7 +64,7 @@ void MBooster::setProcessId(int pid) } -int MBooster::ProcessId() +int MBooster::processId() { return m_ProcessID; } diff --git a/src/launcher/mbooster.h b/src/launcher/mbooster.h index 0d21de6..001280c 100644 --- a/src/launcher/mbooster.h +++ b/src/launcher/mbooster.h @@ -67,7 +67,7 @@ public: /*! * \brief Return booster pid */ - static int ProcessId(); + static int processId(); protected: diff --git a/src/launcher/qtbooster.cpp b/src/launcher/qtbooster.cpp index d5c9db5..f95e36b 100644 --- a/src/launcher/qtbooster.cpp +++ b/src/launcher/qtbooster.cpp @@ -55,7 +55,7 @@ void QtBooster::setProcessId(int pid) m_ProcessID = pid; } -int QtBooster::ProcessId() +int QtBooster::processId() { return m_ProcessID; } diff --git a/src/launcher/qtbooster.h b/src/launcher/qtbooster.h index 7b079e9..463c47b 100644 --- a/src/launcher/qtbooster.h +++ b/src/launcher/qtbooster.h @@ -59,7 +59,7 @@ public: /*! * \brief Return booster pid */ - static int ProcessId(); + static int processId(); //! \reimp diff --git a/tests/unittests/ut_connection/CMakeLists.txt b/tests/unittests/ut_connection/CMakeLists.txt index 9e10ba5..d162b83 100644 --- a/tests/unittests/ut_connection/CMakeLists.txt +++ b/tests/unittests/ut_connection/CMakeLists.txt @@ -7,7 +7,7 @@ set(SRC ut_connection.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/booster.cpp ${LAUN set(MOC_HDRS ut_connection.h) # Set the program name define used in daemon.cpp -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPROG_NAME=\\\"applauncherd\\\"") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPROG_NAME_LAUNCHER=\\\"applauncherd\\\"") # Run moc qt4_wrap_cpp(MOC_SRC ${MOC_HDRS}) diff --git a/tests/unittests/ut_daemon/CMakeLists.txt b/tests/unittests/ut_daemon/CMakeLists.txt index 097d476..2e9a12a 100644 --- a/tests/unittests/ut_daemon/CMakeLists.txt +++ b/tests/unittests/ut_daemon/CMakeLists.txt @@ -6,7 +6,7 @@ set(SRC ut_daemon.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/booster.cpp ${LAUNCHER set(MOC_HDRS ut_daemon.h) # Set the program name define used in daemon.cpp -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPROG_NAME=\\\"applauncherd\\\"") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPROG_NAME_LAUNCHER=\\\"applauncherd\\\"") # Run moc qt4_wrap_cpp(MOC_SRC ${MOC_HDRS} ) From 816670c5e6d76dc8b4e87a92d55a45c96504b036 Mon Sep 17 00:00:00 2001 From: Alexey Shilov Date: Wed, 25 Aug 2010 13:40:46 +0300 Subject: [PATCH 02/19] Changes: logging message update --- src/launcher/daemon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/launcher/daemon.cpp b/src/launcher/daemon.cpp index 28c4406..e001ea8 100644 --- a/src/launcher/daemon.cpp +++ b/src/launcher/daemon.cpp @@ -157,7 +157,7 @@ void Daemon::run() } else { - Logger::logError("Daemon: invoker's pid: %d \n", invoker_pid); + Logger::logInfo("Daemon: invoker's pid: %d \n", invoker_pid); } if (invoker_pid != 0) From 5a9512b2d1c443c257324572066b7eed7e61465f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pertti=20Kellom=C3=A4ki?= Date: Wed, 25 Aug 2010 14:39:35 +0300 Subject: [PATCH 03/19] Changes: Updates to meego packaging files. Submitted to devel:ux:handset. --- meego/meegotouch-applauncherd.changes | 5 ++++- meego/meegotouch-applauncherd.yaml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/meego/meegotouch-applauncherd.changes b/meego/meegotouch-applauncherd.changes index 3464cf2..113535d 100644 --- a/meego/meegotouch-applauncherd.changes +++ b/meego/meegotouch-applauncherd.changes @@ -1,2 +1,5 @@ -* Wed Jul 14 2010 Pertti Kellomäki - 0.0.0 +* Wed Aug 25 2010 Pertti Kellomäki - 0.10.3 +- Updated to version 0.10.3. + +* Wed Jul 14 2010 Pertti Kellomäki - 0.8.0 - Initial packaging. diff --git a/meego/meegotouch-applauncherd.yaml b/meego/meegotouch-applauncherd.yaml index ff92267..7e76e99 100644 --- a/meego/meegotouch-applauncherd.yaml +++ b/meego/meegotouch-applauncherd.yaml @@ -1,6 +1,6 @@ Name: meegotouch-applauncherd Summary: Application launcher for fast startup -Version: 0.9.0 +Version: 0.10.3 Release: 1 Group: System/Daemons License: LGPLv2+ From d195242eee52f412ea8a8377e5dc70c3ce479183 Mon Sep 17 00:00:00 2001 From: Alexey Shilov Date: Wed, 25 Aug 2010 16:23:30 +0300 Subject: [PATCH 04/19] Changes: remove CAP::kill from invoker's aegis file --- debian/applauncherd-invoker.aegis | 1 - 1 file changed, 1 deletion(-) diff --git a/debian/applauncherd-invoker.aegis b/debian/applauncherd-invoker.aegis index dba3102..46a6eec 100644 --- a/debian/applauncherd-invoker.aegis +++ b/debian/applauncherd-invoker.aegis @@ -1,7 +1,6 @@ - From b240224f6e319d048a20088c49e475e078cc0e5d Mon Sep 17 00:00:00 2001 From: Alexey Shilov Date: Thu, 26 Aug 2010 17:10:26 +0300 Subject: [PATCH 05/19] Changes: invoker can launch applications even without applauncherd --- src/invoker/invoker.c | 70 ++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 27 deletions(-) diff --git a/src/invoker/invoker.c b/src/invoker/invoker.c index e75445e..c3d18b2 100644 --- a/src/invoker/invoker.c +++ b/src/invoker/invoker.c @@ -182,7 +182,8 @@ static int invoker_init(enum APP_TYPE app_type) fd = socket(PF_UNIX, SOCK_STREAM, 0); if (fd < 0) { - die(1, "Failed to open invoker socket.\n"); + warning("Failed to open invoker socket.\n"); + return -1; } sun.sun_family = AF_UNIX; //AF_FILE; @@ -205,7 +206,8 @@ static int invoker_init(enum APP_TYPE app_type) if (connect(fd, (struct sockaddr *)&sun, sizeof(sun)) < 0) { - die(1, "Failed to initiate connect on the socket.\n"); + warning("Failed to initiate connect on the socket.\n"); + return -1; } return fd; @@ -444,38 +446,52 @@ static int invoke(int prog_argc, char **prog_argv, char *prog_name, int fd = invoker_init(app_type); - invoker_send_magic(fd, magic_options); - invoker_send_name(fd, prog_argv[0]); - invoker_send_exec(fd, prog_name); - invoker_send_args(fd, prog_argc, prog_argv); - invoker_send_prio(fd, prog_prio); - invoker_send_ids(fd, uid, gid); - invoker_send_io(fd); - invoker_send_env(fd); - invoker_send_end(fd); - - if (prog_name) + if (fd == -1) { - free(prog_name); - } + // connection with launcher is broken, try to launch application via execve + warning("Connection with launcher is broken\n"); + + execve(prog_name, prog_argv, environ); + perror("execve"); /* execve() only returns on error */ + exit(EXIT_FAILURE); - // Wait for launched process to exit - if (wait_term) + } + else { - invoked_pid = invoker_recv_pid(fd); - debug("Booster's pid is %d \n ", invoked_pid); + // connection with launcher process is established + invoker_send_magic(fd, magic_options); + invoker_send_name(fd, prog_argv[0]); + invoker_send_exec(fd, prog_name); + invoker_send_args(fd, prog_argc, prog_argv); + invoker_send_prio(fd, prog_prio); + invoker_send_ids(fd, uid, gid); + invoker_send_io(fd); + invoker_send_env(fd); + invoker_send_end(fd); + + if (prog_name) + { + free(prog_name); + } - // forward signals to invoked process - sigs_init(); + // Wait for launched process to exit + if (wait_term) + { + invoked_pid = invoker_recv_pid(fd); + debug("Booster's pid is %d \n ", invoked_pid); - // wait for exit status from invoked application - status = invoker_recv_exit(fd); + // forward signals to invoked process + sigs_init(); - // restore default signal handlers - sigs_restore(); - } + // wait for exit status from invoked application + status = invoker_recv_exit(fd); - close(fd); + // restore default signal handlers + sigs_restore(); + } + + close(fd); + } } return status; } From dd68e8af23026d916e4429fef0b81e3c137f67a0 Mon Sep 17 00:00:00 2001 From: Nimika Keshri Date: Fri, 27 Aug 2010 13:09:18 +0300 Subject: [PATCH 06/19] Changes: Signal-forwarding tests added RevBy: TrustMe --- debian/applauncherd-testscripts.install | 2 ++ tests/TestScripts/CMakeLists.txt | 2 ++ tests/TestScripts/fala_sf.py | 15 +++++++++++++++ tests/TestScripts/fala_sf.sh | 3 +++ tests/TestScripts/test-func-launcher.py | 9 +++++++++ tests/bug-tests/tests.xml | 3 +++ 6 files changed, 34 insertions(+) create mode 100755 tests/TestScripts/fala_sf.py create mode 100755 tests/TestScripts/fala_sf.sh diff --git a/debian/applauncherd-testscripts.install b/debian/applauncherd-testscripts.install index 3d9da9d..c182b15 100644 --- a/debian/applauncherd-testscripts.install +++ b/debian/applauncherd-testscripts.install @@ -3,3 +3,5 @@ usr/share/applauncherd-testscripts/ts_prestartapp.rb usr/share/applauncherd-testscripts/check_pipes.py usr/share/applauncherd-testscripts/test-perf-mbooster.py usr/share/applauncherd-testscripts/tc_theming.rb +usr/share/applauncherd-testscripts/fala_sf.sh +usr/share/applauncherd-testscripts/fala_sf.py diff --git a/tests/TestScripts/CMakeLists.txt b/tests/TestScripts/CMakeLists.txt index dd22bbf..672672d 100644 --- a/tests/TestScripts/CMakeLists.txt +++ b/tests/TestScripts/CMakeLists.txt @@ -7,4 +7,6 @@ install(FILES install(PROGRAMS ts_prestartapp.rb tc_theming.rb + fala_sf.py + fala_sf.sh DESTINATION /usr/share/applauncherd-testscripts) diff --git a/tests/TestScripts/fala_sf.py b/tests/TestScripts/fala_sf.py new file mode 100755 index 0000000..3057028 --- /dev/null +++ b/tests/TestScripts/fala_sf.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python +import os +import time +import commands + +#Launching application from the script +os.system("/usr/share/applauncherd-testscripts/fala_sf.sh &") + +time.sleep(2) +st, op = commands.getstatusoutput("pgrep fala_ft_hello") + +#Killing application with a signal 11 (Segmentation Fault) +commands.getoutput("kill -11 %s" %op) +time.sleep(2) + diff --git a/tests/TestScripts/fala_sf.sh b/tests/TestScripts/fala_sf.sh new file mode 100755 index 0000000..07fef1a --- /dev/null +++ b/tests/TestScripts/fala_sf.sh @@ -0,0 +1,3 @@ +#!/bin/sh +invoker --type=m --wait-term /usr/bin/fala_ft_hello.launch + diff --git a/tests/TestScripts/test-func-launcher.py b/tests/TestScripts/test-func-launcher.py index 6fcefb3..5d61933 100644 --- a/tests/TestScripts/test-func-launcher.py +++ b/tests/TestScripts/test-func-launcher.py @@ -704,6 +704,15 @@ class launcher_tests (unittest.TestCase): self.assert_(grp_id == grp_id2, "The correct GID is not passed by invoker") + def test_019_signal_forwarding(self): + """ + To test that invoker is killed by the same signal as the application + """ + + st, op = commands.getstatusoutput("/usr/share/applauncherd-testscripts/fala_sf.py") + print ("The Invoker killed by : %s" %op) + + self.assert_(op == 'Segmentation fault (core dumped)', "The invoker was not killed by the same signal") # main if __name__ == '__main__': # When run with testrunner, for some reason the PATH doesn't include diff --git a/tests/bug-tests/tests.xml b/tests/bug-tests/tests.xml index e369789..2d8b750 100644 --- a/tests/bug-tests/tests.xml +++ b/tests/bug-tests/tests.xml @@ -73,6 +73,9 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_018_invoker_gid_uid + + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_019_signal_forwarding + true From 89c1dec365ccee0deeb5e9ade41f9d48b8359e20 Mon Sep 17 00:00:00 2001 From: Alexey Shilov Date: Fri, 27 Aug 2010 16:05:07 +0300 Subject: [PATCH 07/19] Changes: wait-term parameter support for applications started without launcher --- src/invoker/invoker.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/invoker/invoker.c b/src/invoker/invoker.c index c3d18b2..c787a61 100644 --- a/src/invoker/invoker.c +++ b/src/invoker/invoker.c @@ -449,12 +449,27 @@ static int invoke(int prog_argc, char **prog_argv, char *prog_name, if (fd == -1) { // connection with launcher is broken, try to launch application via execve - warning("Connection with launcher is broken\n"); + warning("Connection with launcher is broken \n"); + + if(!wait_term) + { + // Fork a new process + pid_t newPid = fork(); + + if (newPid == -1) + { + report(report_error, "Invoker failed to fork"); + exit(EXIT_FAILURE); + } + if (newPid != 0) /* parent process */ + { + return; + } + } execve(prog_name, prog_argv, environ); perror("execve"); /* execve() only returns on error */ exit(EXIT_FAILURE); - } else { From e28e3db132795c85acd09f3aba926f586e7550e6 Mon Sep 17 00:00:00 2001 From: Nimika Keshri Date: Fri, 27 Aug 2010 16:56:25 +0300 Subject: [PATCH 08/19] Changes: Test for invoker can launch applications even without applauncherd RevBy: TrustMe --- tests/TestScripts/test-func-launcher.py | 21 +++++++++++++++ tests/bug-tests/tests.xml | 35 ++++++++++++++----------- 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/tests/TestScripts/test-func-launcher.py b/tests/TestScripts/test-func-launcher.py index 5d61933..da5c488 100644 --- a/tests/TestScripts/test-func-launcher.py +++ b/tests/TestScripts/test-func-launcher.py @@ -713,6 +713,27 @@ class launcher_tests (unittest.TestCase): print ("The Invoker killed by : %s" %op) self.assert_(op == 'Segmentation fault (core dumped)', "The invoker was not killed by the same signal") + + def test_020_launch_wo_applauncherd(self): + """ + To Test that invoker can launch applications even when the applauncherd is not running + """ + + #Stop applauncherd + os.system("initctl stop xsession/applauncherd") + time.sleep(1) + #Try to launch an application using invoker + os.system('invoker --type=m /usr/bin/fala_ft_hello.launch &') + time.sleep(3) + process_id1 = self.get_pid('fala_ft_hello') + + self.assert_(process_id1 != None , "application not launcherd running") + time.sleep(1) + self.kill_process(PREFERED_APP) + os.system("initctl start xsession/applauncherd") + + + # main if __name__ == '__main__': # When run with testrunner, for some reason the PATH doesn't include diff --git a/tests/bug-tests/tests.xml b/tests/bug-tests/tests.xml index 2d8b750..cd3df1e 100644 --- a/tests/bug-tests/tests.xml +++ b/tests/bug-tests/tests.xml @@ -10,19 +10,24 @@ /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 test_009_launch_multiple_apps_cont + + + + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_020_launch_wo_applauncherd + + + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_007_no_aegis_Bug170905 - + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_008_invoker_creds - - source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_009_launch_multiple_apps_cont - - + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_006_creds @@ -39,11 +44,11 @@ /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 - + source /tmp/session_bus_address.user; DISPLAY=:0 /usr/share/applauncherd-testscripts/tc_theming.rb --name test_application_specific_theming - + source /tmp/session_bus_address.user; DISPLAY=:0 /usr/share/applauncherd-testscripts/tc_theming.rb --name test_global_theming @@ -61,19 +66,19 @@ /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 test_010 - + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_017_invoker_exit_status - + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_018_invoker_gid_uid - + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_019_signal_forwarding @@ -88,15 +93,15 @@ /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 test_014_fd_booster_m - + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_015_fd_booster_q - + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_016_restart_booster From c9cbbdd765e47537f402ded6ba53a7886453648d Mon Sep 17 00:00:00 2001 From: Oskari Timperi Date: Mon, 30 Aug 2010 10:35:54 +0300 Subject: [PATCH 09/19] Changes: "Deprecated" applauncherd-dev and made it depend on libmeegotouch-dev --- debian/applauncherd-dev.install | 2 -- debian/applauncherd-dev.postinst | 10 ++++++++++ debian/control | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) delete mode 100644 debian/applauncherd-dev.install create mode 100755 debian/applauncherd-dev.postinst diff --git a/debian/applauncherd-dev.install b/debian/applauncherd-dev.install deleted file mode 100644 index c95edd1..0000000 --- a/debian/applauncherd-dev.install +++ /dev/null @@ -1,2 +0,0 @@ -usr/lib/pkgconfig/meegotouch-boostable.pc -usr/share/qt4/mkspecs/features/meegotouch-boostable.prf diff --git a/debian/applauncherd-dev.postinst b/debian/applauncherd-dev.postinst new file mode 100755 index 0000000..e9b1674 --- /dev/null +++ b/debian/applauncherd-dev.postinst @@ -0,0 +1,10 @@ +#!/bin/sh + +echo +echo "**********************************************************" +echo +echo "NOTE: This package is deprecated. Instead of this package," +echo " use the libmeegotouch-dev package." +echo +echo "**********************************************************" +echo diff --git a/debian/control b/debian/control index fd664b7..6fceb92 100644 --- a/debian/control +++ b/debian/control @@ -45,7 +45,7 @@ Description: Launcher debug package Package: applauncherd-dev Architecture: all -Depends: ${shlibs:Depends}, ${misc:Depends}, pkg-config +Depends: ${shlibs:Depends}, ${misc:Depends}, libmeegotouch-dev Description: Development files for applications using applauncherd Development files for applications using applauncherd. From bd12b7311968ade7648b7021db481e511d897d2d Mon Sep 17 00:00:00 2001 From: Alexey Shilov Date: Mon, 30 Aug 2010 11:20:53 +0300 Subject: [PATCH 10/19] Changes: fix for Bug 187780 --- src/invoker/invoker.c | 5 +++-- src/launcher/daemon.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/invoker/invoker.c b/src/invoker/invoker.c index c787a61..bf0be78 100644 --- a/src/invoker/invoker.c +++ b/src/invoker/invoker.c @@ -449,7 +449,8 @@ static int invoke(int prog_argc, char **prog_argv, char *prog_name, if (fd == -1) { // connection with launcher is broken, try to launch application via execve - warning("Connection with launcher is broken \n"); + warning("Connection with launcher process is broken \n"); + warning("Try to start application as a binary executable without launcher... \n"); if(!wait_term) { @@ -463,7 +464,7 @@ static int invoke(int prog_argc, char **prog_argv, char *prog_name, } if (newPid != 0) /* parent process */ { - return; + return 0; } } diff --git a/src/launcher/daemon.cpp b/src/launcher/daemon.cpp index e001ea8..1dd142f 100644 --- a/src/launcher/daemon.cpp +++ b/src/launcher/daemon.cpp @@ -163,7 +163,7 @@ void Daemon::run() if (invoker_pid != 0) { // store booster - invoker pids pair - pid_t booster_pid; + pid_t booster_pid = 0; if (MBooster::type() == msg) { booster_pid = MBooster::processId(); From 73b17944125e41375ebbdcacb0a95542cd22f6ad Mon Sep 17 00:00:00 2001 From: Nimika Keshri Date: Mon, 30 Aug 2010 11:43:07 +0300 Subject: [PATCH 11/19] Changes: debian/changelog updated, new stable version RevBy: TrustMe --- debian/changelog | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 6ed3e4c..bf94824 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,22 @@ -applauncherd (0.10.4) unstable; urgency=low - +applauncherd (0.11.0) stable; urgency=low + + * Changes: Signal-forwarding tests added + * Changes: Test for invoker can launch applications even without applauncherd + * Changes: "Deprecated" applauncherd-dev and made it depend on libmeegotouch-dev + * Changes: wait-term parameter support for applications started without launcher + * Changes: invoker can launch applications even without applauncherd + * Changes: remove CAP::kill from invoker's aegis file + * Changes: Updates to meego packaging files. Submitted to devel:ux:handset. + * Changes: signals forwarding update + * Changes: daemon error messages refactoring + * Changes: added Connection::peersPid() method * Changes: Handle PWD correctly + * Changes: pass pid of invoker from booster to launcher * Changes: PROG_NAME separated into PROG_NAME_INVOKER and PROG_NAME_LAUNCHER + * Changes: invoker's receiving of booster process exit code refactoring + * Fixes: NB#187780 - Booster robustness improvement: launch applications even without applauncherd - -- Jussi Lind Tue, 24 Aug 2010 18:04:39 +0300 + -- Nimika Keshri Mon, 30 Aug 2010 11:38:32 +0300 applauncherd (0.10.3) stable; urgency=low From eca50a446660940d1bee4c17e933e4e5a7cdab32 Mon Sep 17 00:00:00 2001 From: Antti Kervinen Date: Wed, 25 Aug 2010 14:51:52 +0300 Subject: [PATCH 12/19] Fixes: NB#187583 - Update application launcher to use creds_confine2() for credential setup. --- debian/applauncherd-invoker.aegis | 2 +- src/launcher/appdata.cpp | 28 ++++++++++++++++++++++++++++ src/launcher/appdata.h | 19 +++++++++++++++++++ src/launcher/booster.cpp | 11 +++++++++-- src/launcher/connection.cpp | 13 ++++++++----- src/launcher/connection.h | 7 +++++-- 6 files changed, 70 insertions(+), 10 deletions(-) diff --git a/debian/applauncherd-invoker.aegis b/debian/applauncherd-invoker.aegis index 46a6eec..0c9bb79 100644 --- a/debian/applauncherd-invoker.aegis +++ b/debian/applauncherd-invoker.aegis @@ -1,6 +1,6 @@ - + diff --git a/src/launcher/appdata.cpp b/src/launcher/appdata.cpp index 3a50282..3358ff2 100644 --- a/src/launcher/appdata.cpp +++ b/src/launcher/appdata.cpp @@ -19,6 +19,10 @@ #include "appdata.h" +#ifdef HAVE_CREDS + #include +#endif + AppData::AppData() : m_options(0), m_argc(0), @@ -30,6 +34,9 @@ AppData::AppData() : m_ioDescriptors(), m_gid(0), m_uid(0) +#if defined (HAVE_CREDS) + , m_peerCreds(NULL) +#endif {} void AppData::setOptions(int newOptions) @@ -143,7 +150,28 @@ void AppData::deleteArgv() } } +#if defined (HAVE_CREDS) +void AppData::setPeerCreds(creds_t peerCreds) +{ + m_peerCreds = peerCreds; +} + +creds_t AppData::peerCreds() const +{ + return m_peerCreds; +} + +void AppData::deletePeerCreds() +{ + creds_free(m_peerCreds); + m_peerCreds = NULL; +} +#endif // defined (HAVE_CREDS) + AppData::~AppData() { deleteArgv(); +#if defined (HAVE_CREDS) + deletePeerCreds(); +#endif } diff --git a/src/launcher/appdata.h b/src/launcher/appdata.h index be03a8b..8289fd9 100644 --- a/src/launcher/appdata.h +++ b/src/launcher/appdata.h @@ -20,6 +20,10 @@ #ifndef APPDATA_H #define APPDATA_H +#ifdef HAVE_CREDS + #include +#endif + #include using std::string; @@ -101,6 +105,17 @@ public: //! Frees the memory reserved for argv void deleteArgv(); +#if defined (HAVE_CREDS) + //! Store security credentials + void setPeerCreds(creds_t peerCreds); + + //! Get the stored credentials + creds_t peerCreds() const; + + //! Free the memory reserved for credentials + void deletePeerCreds(); +#endif + private: AppData(const AppData & r); @@ -117,6 +132,10 @@ private: gid_t m_gid; uid_t m_uid; +#if defined (HAVE_CREDS) + creds_t m_peerCreds; +#endif + }; #endif // APPDATA_H diff --git a/src/launcher/booster.cpp b/src/launcher/booster.cpp index 7f85b16..962b05a 100644 --- a/src/launcher/booster.cpp +++ b/src/launcher/booster.cpp @@ -60,7 +60,7 @@ bool Booster::readCommand() m_conn = new Connection(socketId()); // Accept a new invocation. - if (m_conn->acceptConn()) + if (m_conn->acceptConn(m_app)) { bool res = m_conn->receiveApplicationData(m_app); if(!res) @@ -214,7 +214,14 @@ void* Booster::loadMain() { #ifdef HAVE_CREDS // Set application's platform security credentials - creds_confine(m_app.fileName().c_str()); + int err = creds_confine2(m_app.fileName().c_str(), credp_str2flags("set", NULL), m_app.peerCreds()); + m_app.deletePeerCreds(); + + if (err < 0) + { + // Credential setup has failed, abort. + Logger::logErrorAndDie(EXIT_FAILURE, "Failed to setup credentials for launching application: %d\n", err); + } #endif // Load the application as a library diff --git a/src/launcher/connection.cpp b/src/launcher/connection.cpp index 5712303..63d1bda 100644 --- a/src/launcher/connection.cpp +++ b/src/launcher/connection.cpp @@ -120,7 +120,7 @@ void Connection::initSocket(const string socketId) } } -bool Connection::acceptConn() +bool Connection::acceptConn(AppData & rApp) { m_fd = accept(m_curSocket, NULL, NULL); @@ -130,13 +130,15 @@ bool Connection::acceptConn() return false; } -#if defined (HAVE_CREDS) && ! defined (DISABLE_VERIFICATION) +#if defined (HAVE_CREDS) creds_t ccreds = creds_getpeer(m_fd); - int allow = creds_have_p(ccreds, m_credsType, m_credsValue); + // Fetched peer creds will be free'd with rApp.deletePeerCreds + rApp.setPeerCreds(ccreds); - creds_free(ccreds); +#if ! defined (DISABLE_VERIFICATION) + int allow = creds_have_p(ccreds, m_credsType, m_credsValue); if (!allow) { @@ -146,8 +148,9 @@ bool Connection::acceptConn() closeConn(); return false; } +#endif // ! defined (DISABLE_VERIFICATION) -#endif +#endif // defined (HAVE_CREDS) return true; } diff --git a/src/launcher/connection.h b/src/launcher/connection.h index 6327840..1056047 100644 --- a/src/launcher/connection.h +++ b/src/launcher/connection.h @@ -65,9 +65,12 @@ public: /*! \brief Accept connection. * Accept a socket connection from the invoker. + * Stores security credentials of the connected + * peer to rApp, if security is enabled. The credentials + * in rApp must be released by the caller. * \return true on success. */ - bool acceptConn(); + bool acceptConn(AppData & rApp); //! \brief Close the socket connection. void closeConn(); @@ -170,7 +173,7 @@ private: gid_t m_gid; uid_t m_uid; -#if defined (HAVE_CREDS) && ! defined (DISABLE_VERIFICATION) +#if defined (HAVE_CREDS) static const char * m_credsStr; creds_value_t m_credsValue; creds_type_t m_credsType; From 296f3353092ef2dff4615a738a7b1e00f88eed7a Mon Sep 17 00:00:00 2001 From: Antti Kervinen Date: Mon, 30 Aug 2010 14:58:59 +0300 Subject: [PATCH 13/19] Change log updated, new stable version --- debian/changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/debian/changelog b/debian/changelog index bf94824..3b83ae5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +applauncherd (0.12.0) stable; urgency=low + + * Changes: Launcher uses creds_confine2 to reset credentials during transmogrification + * Fixes: NB#187583 - Update application launcher to use creds_confine2() for credential setup + + -- Antti Kervinen Mon, 30 Aug 2010 14:57:33 +0300 + applauncherd (0.11.0) stable; urgency=low * Changes: Signal-forwarding tests added From d5d4f11086b2e6caea45a33008e3cead8d6b014e Mon Sep 17 00:00:00 2001 From: Antti Kervinen Date: Mon, 30 Aug 2010 15:05:11 +0300 Subject: [PATCH 14/19] Changes: Changelog updated (changed fixed tags because 0.11.0 got never released) --- debian/changelog | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 3b83ae5..c207d4e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,10 @@ -applauncherd (0.12.0) stable; urgency=low +applauncherd (0.12.1) stable; urgency=low * Changes: Launcher uses creds_confine2 to reset credentials during transmogrification * Fixes: NB#187583 - Update application launcher to use creds_confine2() for credential setup + * Fixes: NB#187780 - Booster robustness improvement: launch applications even without applauncherd - -- Antti Kervinen Mon, 30 Aug 2010 14:57:33 +0300 + -- Antti Kervinen Mon, 30 Aug 2010 15:03:59 +0300 applauncherd (0.11.0) stable; urgency=low From e326258213f04a74960179de96979c176c175787 Mon Sep 17 00:00:00 2001 From: Alexey Shilov Date: Tue, 31 Aug 2010 16:52:08 +0300 Subject: [PATCH 15/19] Changes: wrong comment corrected --- src/invoker/invoker.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/invoker/invoker.c b/src/invoker/invoker.c index bf0be78..22a7d93 100644 --- a/src/invoker/invoker.c +++ b/src/invoker/invoker.c @@ -244,7 +244,7 @@ static uint32_t invoker_recv_exit(int fd) // if nothing happend, just exit with error message die(1, "receiving bad exit status (%08x)\n", action); } - /* Receive pid. */ + /* Receive exit status */ invoke_recv_msg(fd, &status); return status; } From b2f8e0fd8de351fc57786bc3a2c0c36a9066870e Mon Sep 17 00:00:00 2001 From: Nimika Keshri Date: Wed, 1 Sep 2010 09:50:17 +0300 Subject: [PATCH 16/19] Changes: Test Application modifed for performance test. RevBy: TrustMe --- debian/applauncherd-testapps.install | 7 +++++++ tests/TestApps/helloworld/CMakeLists.txt | 1 + tests/TestApps/helloworld/helloworld.pro | 8 -------- tests/TestApps/testapp/CMakeLists.txt | 6 +++++- tests/TestApps/testapp/com.nokia.fala_wl.service | 3 +++ tests/TestApps/testapp/com.nokia.fala_wol.service | 3 +++ tests/TestApps/testapp/fala_wl.desktop | 8 ++++++++ tests/TestApps/testapp/fala_wol.desktop | 8 ++++++++ tests/TestApps/testapp/testapp.pro | 14 -------------- 9 files changed, 35 insertions(+), 23 deletions(-) delete mode 100644 tests/TestApps/helloworld/helloworld.pro create mode 100644 tests/TestApps/testapp/com.nokia.fala_wl.service create mode 100644 tests/TestApps/testapp/com.nokia.fala_wol.service create mode 100644 tests/TestApps/testapp/fala_wl.desktop create mode 100644 tests/TestApps/testapp/fala_wol.desktop delete mode 100644 tests/TestApps/testapp/testapp.pro diff --git a/debian/applauncherd-testapps.install b/debian/applauncherd-testapps.install index 75aa368..9a6110d 100644 --- a/debian/applauncherd-testapps.install +++ b/debian/applauncherd-testapps.install @@ -10,7 +10,14 @@ usr/bin/fala_ft_creds1.launch usr/bin/fala_ft_creds2 usr/bin/fala_ft_creds2.launch usr/bin/fala_testapp +usr/bin/fala_wl +usr/bin/fala_wl.launch +usr/bin/fala_wol usr/share/dbus-1/services/com.nokia.fala_testapp.service +usr/share/dbus-1/services/com.nokia.fala_wl.service +usr/share/dbus-1/services/com.nokia.fala_wol.service usr/bin/fala_ft_themetest.launch usr/bin/fala_ft_themetest usr/share/themes/base/meegotouch/fala_ft_themetest/* +usr/share/applications/fala_wl.desktop +usr/share/applications/fala_wol.desktop diff --git a/tests/TestApps/helloworld/CMakeLists.txt b/tests/TestApps/helloworld/CMakeLists.txt index d17351a..ec35ec7 100644 --- a/tests/TestApps/helloworld/CMakeLists.txt +++ b/tests/TestApps/helloworld/CMakeLists.txt @@ -30,6 +30,7 @@ add_executable(helloworld ${SRC}) # Install install(PROGRAMS helloworld DESTINATION /usr/bin RENAME fala_ft_hello.launch) install(PROGRAMS scripts/fala_ft_hello DESTINATION /usr/bin/) +install(PROGRAMS scripts/fala_ft_hello DESTINATION /usr/bin RENAME fala_wl) # Install symlinks so that /usr/bin/helloworldX launches /usr/bin/helloworldX.launch install(SCRIPT scripts/create_links.cmake) diff --git a/tests/TestApps/helloworld/helloworld.pro b/tests/TestApps/helloworld/helloworld.pro deleted file mode 100644 index 33b4603..0000000 --- a/tests/TestApps/helloworld/helloworld.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = app -TARGET = fala_ft_hello -CONFIG = qt meegotouch - -QMAKE_CXXFLAGS += -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -QMAKE_LFLAGS += -pie -rdynamic - -SOURCES += helloworld.cpp diff --git a/tests/TestApps/testapp/CMakeLists.txt b/tests/TestApps/testapp/CMakeLists.txt index dad2b2b..af5613e 100644 --- a/tests/TestApps/testapp/CMakeLists.txt +++ b/tests/TestApps/testapp/CMakeLists.txt @@ -28,4 +28,8 @@ add_executable(fala_testapp ${SRC}) # Install install(PROGRAMS fala_testapp DESTINATION /usr/bin/) -install(FILES com.nokia.fala_testapp.service DESTINATION /usr/share/dbus-1/services) +install(PROGRAMS fala_testapp DESTINATION /usr/bin RENAME fala_wl.launch) +install(PROGRAMS fala_testapp DESTINATION /usr/bin RENAME fala_wol) +install(FILES com.nokia.fala_testapp.service com.nokia.fala_wl.service com.nokia.fala_wol.service DESTINATION /usr/share/dbus-1/services) +install(FILES fala_wl.desktop fala_wol.desktop DESTINATION /usr/share/applications/) + diff --git a/tests/TestApps/testapp/com.nokia.fala_wl.service b/tests/TestApps/testapp/com.nokia.fala_wl.service new file mode 100644 index 0000000..488ae41 --- /dev/null +++ b/tests/TestApps/testapp/com.nokia.fala_wl.service @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=com.nokia.fala_wl +Exec=/usr/bin/fala_wl diff --git a/tests/TestApps/testapp/com.nokia.fala_wol.service b/tests/TestApps/testapp/com.nokia.fala_wol.service new file mode 100644 index 0000000..92df730 --- /dev/null +++ b/tests/TestApps/testapp/com.nokia.fala_wol.service @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=com.nokia.fala_wol +Exec=/usr/bin/fala_wol diff --git a/tests/TestApps/testapp/fala_wl.desktop b/tests/TestApps/testapp/fala_wl.desktop new file mode 100644 index 0000000..f503336 --- /dev/null +++ b/tests/TestApps/testapp/fala_wl.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Application +Name=fala_wl +Icon=icon-l-video +Exec=/usr/bin/invoker --type=m /usr/bin/fala_wl.launch +X-Maemo-Service=com.nokia.fala_wl +Categories=X-MeeGo;Demos; +OnlyShowIn=X-MeeGo; diff --git a/tests/TestApps/testapp/fala_wol.desktop b/tests/TestApps/testapp/fala_wol.desktop new file mode 100644 index 0000000..d8fe99f --- /dev/null +++ b/tests/TestApps/testapp/fala_wol.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Application +Name=fala_wol +Icon=icon-l-video +Exec=/usr/bin/fala_wol +X-Maemo-Service=com.nokia.fala_wol +Categories=X-MeeGo;Demos; +OnlyShowIn=X-MeeGo; diff --git a/tests/TestApps/testapp/testapp.pro b/tests/TestApps/testapp/testapp.pro deleted file mode 100644 index 0e829ee..0000000 --- a/tests/TestApps/testapp/testapp.pro +++ /dev/null @@ -1,14 +0,0 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed Apr 21 10:44:49 2010 -###################################################################### - -TEMPLATE = app -QMAKE_CXXFLAGS += -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -QMAKE_LFLAGS += -pie -rdynamic -TARGET = testapp -DEPENDPATH += . -INCLUDEPATH += . -CONFIG += meegotouch - -# Input -SOURCES += main.cpp From da2093802577fea876d8e4e454648c86c64cb58b Mon Sep 17 00:00:00 2001 From: Nimika Keshri Date: Wed, 1 Sep 2010 12:29:10 +0300 Subject: [PATCH 17/19] Changes: New Performance test added RevBy: TrustMe --- debian/applauncherd-testscripts.install | 1 + tests/TestScripts/CMakeLists.txt | 1 + tests/TestScripts/test-perf.rb | 132 ++++++++++++++++++++++++ tests/perftests/tests.xml | 3 + 4 files changed, 137 insertions(+) create mode 100755 tests/TestScripts/test-perf.rb diff --git a/debian/applauncherd-testscripts.install b/debian/applauncherd-testscripts.install index c182b15..650c6d6 100644 --- a/debian/applauncherd-testscripts.install +++ b/debian/applauncherd-testscripts.install @@ -5,3 +5,4 @@ usr/share/applauncherd-testscripts/test-perf-mbooster.py usr/share/applauncherd-testscripts/tc_theming.rb usr/share/applauncherd-testscripts/fala_sf.sh usr/share/applauncherd-testscripts/fala_sf.py +usr/share/applauncherd-testscripts/test-perf.rb diff --git a/tests/TestScripts/CMakeLists.txt b/tests/TestScripts/CMakeLists.txt index 672672d..294281f 100644 --- a/tests/TestScripts/CMakeLists.txt +++ b/tests/TestScripts/CMakeLists.txt @@ -9,4 +9,5 @@ install(PROGRAMS tc_theming.rb fala_sf.py fala_sf.sh + test-perf.rb DESTINATION /usr/share/applauncherd-testscripts) diff --git a/tests/TestScripts/test-perf.rb b/tests/TestScripts/test-perf.rb new file mode 100755 index 0000000..be7b36d --- /dev/null +++ b/tests/TestScripts/test-perf.rb @@ -0,0 +1,132 @@ +#!/usr/bin/ruby1.8 +# 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. +# +# * Description: Performance Test for applauncherd +# +# * Objectives: test the startup time for applications +# + +require 'tdriver' +require 'date' +require 'test/unit' +include TDriverVerify + + +class TC_PerformanceTests < Test::Unit::TestCase + COUNT = 5 + @start_time = 0 + @end_time = 0 + + $path = string = `echo $PATH ` + + # method called before any test case + def setup + if $path.include?("scratchbox") + puts "Inside SB, Do Nothing to unlock" + else + system "mcetool --set-tklock-mode=unlocked" + end + @sut = TDriver.sut(:Id=>ARGV[0] || 'sut_qt_maemo') + end + + # method called after any test case for cleanup purposes + def teardown + puts "exit from teardown" + end + + def open_Apps(appName) + #Remove the Log file if it exists + if FileTest.exists?("/tmp/testapp.log") + system "rm /tmp/testapp.log" + end + + count = 0 + + #Open the Application from the application grid + @meegoHome = @sut.application(:name => 'duihome') + @meegoHome.MButton(:name => "ToggleLauncherButton").tap + if @meegoHome.test_object_exists?("LauncherButton", :text => appName) + icon = @meegoHome.LauncherButton(:name => "LauncherButton", :text => appName) + totalPages = @meegoHome.children(:type => 'LauncherPage').length + while icon.attribute('visibleOnScreen') == 'false' and count < totalPages + @meegoHome.PagedViewport(:name => 'LauncherPagedViewport').MWidget(:name => 'glass').gesture(:Left, 1, 800) + sleep(0.2) + count = count +1 + icon.refresh + end + @start_time = Time.now + @meegoHome.LauncherButton(:name => "LauncherButton", :text => appName).tap + sleep (2) + @app = @sut.application(:name => appName) + sleep (2) + @app.MEscapeButtonPanel.MButton( :name => 'CloseButton' ).tap + else + #icon does not + #raise error and exit + raise "Application not found in Application grid" + exit 1 + end + end + + def read_file + #Reading the log file to get the time + file_name="/tmp/testapp.log" + last_line = `tail -n 2 #{file_name}` + @end_time = last_line.split(" ")[0] + end + + def measure_time + #Measuring the Startup Time for applications + start_t = "%10.6f" % @start_time.to_f + app_t = Float(@end_time) - Float(start_t) + return app_t + end + + def test_performance + wL = [] + woL = [] + wLsum = 0.0 + woLsum = 0.0 + + #Run Application with invoker + for i in 1..COUNT + open_Apps("fala_wl") + sleep (5) + read_file + wL.push(measure_time) + end + + #Run Application without invoker + for i in 1..COUNT + open_Apps("fala_wol") + sleep (5) + read_file + woL.push(measure_time) + end + + print "With Launcher \t\t Without Launcher\n" + + #Printing the data + for i in 0..COUNT-1 + print "%.2f \t\t\t %.2f\n" %[wL[i],woL[i]] + wLsum = wLsum + wL[i] + woLsum = woLsum + woL[i] + end + print "\nAverage Values \n" + print "%.2f \t\t\t %.2f\n\n" %[wLsum/COUNT, woLsum/COUNT] + + end +end diff --git a/tests/perftests/tests.xml b/tests/perftests/tests.xml index 04af177..fb13377 100644 --- a/tests/perftests/tests.xml +++ b/tests/perftests/tests.xml @@ -14,6 +14,9 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-perf-mbooster.py test_001 > /tmp/launcher_perf.txt + + source /tmp/session_bus_address.user; DISPLAY=:0 /usr/share/applauncherd-testscripts/test-perf.rb --name test_performance > /tmp/launcher_perf_new.txt + false true From 0bb7b2d39ef7b98a79b020e95a979dc6c754ec99 Mon Sep 17 00:00:00 2001 From: Nimika Keshri Date: Wed, 1 Sep 2010 14:36:48 +0300 Subject: [PATCH 18/19] Changes: Adding the results file to tests.xml for performance test RevBy: TrustMe --- tests/perftests/tests.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/perftests/tests.xml b/tests/perftests/tests.xml index fb13377..3ee9f85 100644 --- a/tests/perftests/tests.xml +++ b/tests/perftests/tests.xml @@ -24,7 +24,7 @@ /tmp/launcher_perf.txt - /tmp/testapp.log + /tmp/launcher_perf_new.txt From f34c7215af1b7c0c31a51784f31c1dd9a6b6b649 Mon Sep 17 00:00:00 2001 From: Nimika Keshri Date: Wed, 1 Sep 2010 15:48:03 +0300 Subject: [PATCH 19/19] Changes: Adding some debugs in performance test and adding the test to a new test set RevBy: TrustMe --- tests/TestScripts/test-perf.rb | 10 +++++++++- tests/perftests/tests.xml | 18 ++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/tests/TestScripts/test-perf.rb b/tests/TestScripts/test-perf.rb index be7b36d..6d93236 100755 --- a/tests/TestScripts/test-perf.rb +++ b/tests/TestScripts/test-perf.rb @@ -38,8 +38,13 @@ class TC_PerformanceTests < Test::Unit::TestCase puts "Inside SB, Do Nothing to unlock" else system "mcetool --set-tklock-mode=unlocked" + # restart duihome so that qttasserver notices it + verify { + system("/sbin/initctl restart xsession/duihome") + } + sleep (5) end - @sut = TDriver.sut(:Id=>ARGV[0] || 'sut_qt_maemo') + @sut = TDriver.sut(:Id=> 'sut_qt_maemo') end # method called after any test case for cleanup purposes @@ -58,6 +63,7 @@ class TC_PerformanceTests < Test::Unit::TestCase #Open the Application from the application grid @meegoHome = @sut.application(:name => 'duihome') @meegoHome.MButton(:name => "ToggleLauncherButton").tap + sleep(2) if @meegoHome.test_object_exists?("LauncherButton", :text => appName) icon = @meegoHome.LauncherButton(:name => "LauncherButton", :text => appName) totalPages = @meegoHome.children(:type => 'LauncherPage').length @@ -104,6 +110,7 @@ class TC_PerformanceTests < Test::Unit::TestCase #Run Application with invoker for i in 1..COUNT open_Apps("fala_wl") + print "Now Launching fala_wl %d times\n" %i sleep (5) read_file wL.push(measure_time) @@ -112,6 +119,7 @@ class TC_PerformanceTests < Test::Unit::TestCase #Run Application without invoker for i in 1..COUNT open_Apps("fala_wol") + print "Now Launching fala_wol %d times\n" %i sleep (5) read_file woL.push(measure_time) diff --git a/tests/perftests/tests.xml b/tests/perftests/tests.xml index 3ee9f85..ecd7c4b 100644 --- a/tests/perftests/tests.xml +++ b/tests/perftests/tests.xml @@ -5,7 +5,7 @@ - + /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 @@ -14,6 +14,21 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-perf-mbooster.py test_001 > /tmp/launcher_perf.txt + + false + true + + + + /tmp/launcher_perf.txt + + + + + + /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + + source /tmp/session_bus_address.user; DISPLAY=:0 /usr/share/applauncherd-testscripts/test-perf.rb --name test_performance > /tmp/launcher_perf_new.txt @@ -23,7 +38,6 @@ - /tmp/launcher_perf.txt /tmp/launcher_perf_new.txt