Merge remote branch 'origin/master'

pull/1/head
Alexey Shilov 15 years ago
commit 05abf64ae3

5
debian/changelog vendored

@ -3,9 +3,12 @@ applauncherd (0.16.0) unstable; urgency=low
* Changes: Boosters loaded as plugins. * Changes: Boosters loaded as plugins.
* Changes: New test added that checks that booster pid is acquired by application started using booster * Changes: New test added that checks that booster pid is acquired by application started using booster
* Changes: Changed wait time between button press and release from 100ms to 200ms in pixelchanged. * Changes: Changed wait time between button press and release from 100ms to 200ms in pixelchanged.
* Changes: Single-instance binary added
* Fixes: NB#214093 - application started with launcher has wrong name in the process list * Fixes: NB#214093 - application started with launcher has wrong name in the process list
* Fixes: NB#216191 - Lack of single instance support for qml applications
* Fixes: NB#216196 - Boosters are not loaded as plugins
-- Jussi Lind <jussi.lind@nokia.com> Thu, 30 Dec 2010 12:32:32 +0200 -- Juha Lintula <juha.lintula@nokia.com> Wed, 12 Jan 2011 12:00:00 +0200
applauncherd (0.15.10) stable; urgency=low applauncherd (0.15.10) stable; urgency=low

@ -168,35 +168,21 @@ mv %{buildroot}/usr/share/applauncherd-tests %{buildroot}/usr/lib
%{_libdir}/applauncherd-tests/ut_boosterfactory %{_libdir}/applauncherd-tests/ut_boosterfactory
%{_libdir}/applauncherd-tests/ut_wrtbooster %{_libdir}/applauncherd-tests/ut_wrtbooster
%{_datadir}/applauncherd-M-testscripts/check_pipes.py %{_datadir}/applauncherd-M-testscripts/check_pipes.py
%exclude %{_datadir}/applauncherd-M-testscripts/check_pipes.pyc
%exclude %{_datadir}/applauncherd-M-testscripts/check_pipes.pyo
%{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_m.py %{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_m.py
%exclude %{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_m.pyc
%exclude %{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_m.pyo
%{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_m.sh %{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_m.sh
%{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_qt.py %{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_qt.py
%exclude %{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_qt.pyc
%exclude %{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_qt.pyo
%{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_qt.sh %{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_qt.sh
%{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_wrt.py %{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_wrt.py
%exclude %{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_wrt.pyc
%exclude %{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_wrt.pyo
%{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_wrt.sh %{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_wrt.sh
%{_datadir}/applauncherd-M-testscripts/tc_theming.rb %{_datadir}/applauncherd-M-testscripts/tc_theming.rb
%{_datadir}/applauncherd-M-testscripts/test-func-launcher.py %{_datadir}/applauncherd-M-testscripts/test-func-launcher.py
%exclude %{_datadir}/applauncherd-M-testscripts/test-func-launcher.pyc
%exclude %{_datadir}/applauncherd-M-testscripts/test-func-launcher.pyo
%{_datadir}/applauncherd-M-testscripts/test-perf-mbooster.py %{_datadir}/applauncherd-M-testscripts/test-perf-mbooster.py
%exclude %{_datadir}/applauncherd-M-testscripts/test-perf-mbooster.pyc
%exclude %{_datadir}/applauncherd-M-testscripts/test-perf-mbooster.pyo
%{_datadir}/applauncherd-M-testscripts/ts_prestartapp.rb %{_datadir}/applauncherd-M-testscripts/ts_prestartapp.rb
%{_datadir}/applauncherd-M-testscripts/fala_wid %{_datadir}/applauncherd-M-testscripts/fala_wid
%{_datadir}/applauncherd-M-testscripts/fala_xres_wl %{_datadir}/applauncherd-M-testscripts/fala_xres_wl
%{_datadir}/applauncherd-M-testscripts/fala_xres_wol %{_datadir}/applauncherd-M-testscripts/fala_xres_wol
%{_datadir}/applauncherd-M-testscripts/test-perf.rb %{_datadir}/applauncherd-M-testscripts/test-perf.rb
%{_datadir}/applauncherd-M-testscripts/utils.py %{_datadir}/applauncherd-M-testscripts/utils.py
%exclude %{_datadir}/applauncherd-M-testscripts/utils.pyc
%exclude %{_datadir}/applauncherd-M-testscripts/utils.pyo
%{_datadir}/themes/base/meegotouch/fala_ft_themetest/style/fala_ft_themetest.css %{_datadir}/themes/base/meegotouch/fala_ft_themetest/style/fala_ft_themetest.css
%{_datadir}/applications/fala_wl.desktop %{_datadir}/applications/fala_wl.desktop
%{_datadir}/applications/fala_wol.desktop %{_datadir}/applications/fala_wol.desktop

@ -84,35 +84,21 @@ SubPackages:
- "%{_libdir}/applauncherd-tests/ut_boosterfactory" - "%{_libdir}/applauncherd-tests/ut_boosterfactory"
- "%{_libdir}/applauncherd-tests/ut_wrtbooster" - "%{_libdir}/applauncherd-tests/ut_wrtbooster"
- "%{_datadir}/applauncherd-M-testscripts/check_pipes.py" - "%{_datadir}/applauncherd-M-testscripts/check_pipes.py"
- "%exclude %{_datadir}/applauncherd-M-testscripts/check_pipes.pyc"
- "%exclude %{_datadir}/applauncherd-M-testscripts/check_pipes.pyo"
- "%{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_m.py" - "%{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_m.py"
- "%exclude %{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_m.pyc"
- "%exclude %{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_m.pyo"
- "%{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_m.sh" - "%{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_m.sh"
- "%{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_qt.py" - "%{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_qt.py"
- "%exclude %{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_qt.pyc"
- "%exclude %{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_qt.pyo"
- "%{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_qt.sh" - "%{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_qt.sh"
- "%{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_wrt.py" - "%{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_wrt.py"
- "%exclude %{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_wrt.pyc"
- "%exclude %{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_wrt.pyo"
- "%{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_wrt.sh" - "%{_datadir}/applauncherd-M-testscripts/signal-forward/fala_sf_wrt.sh"
- "%{_datadir}/applauncherd-M-testscripts/tc_theming.rb" - "%{_datadir}/applauncherd-M-testscripts/tc_theming.rb"
- "%{_datadir}/applauncherd-M-testscripts/test-func-launcher.py" - "%{_datadir}/applauncherd-M-testscripts/test-func-launcher.py"
- "%exclude %{_datadir}/applauncherd-M-testscripts/test-func-launcher.pyc"
- "%exclude %{_datadir}/applauncherd-M-testscripts/test-func-launcher.pyo"
- "%{_datadir}/applauncherd-M-testscripts/test-perf-mbooster.py" - "%{_datadir}/applauncherd-M-testscripts/test-perf-mbooster.py"
- "%exclude %{_datadir}/applauncherd-M-testscripts/test-perf-mbooster.pyc"
- "%exclude %{_datadir}/applauncherd-M-testscripts/test-perf-mbooster.pyo"
- "%{_datadir}/applauncherd-M-testscripts/ts_prestartapp.rb" - "%{_datadir}/applauncherd-M-testscripts/ts_prestartapp.rb"
- "%{_datadir}/applauncherd-M-testscripts/fala_wid" - "%{_datadir}/applauncherd-M-testscripts/fala_wid"
- "%{_datadir}/applauncherd-M-testscripts/fala_xres_wl" - "%{_datadir}/applauncherd-M-testscripts/fala_xres_wl"
- "%{_datadir}/applauncherd-M-testscripts/fala_xres_wol" - "%{_datadir}/applauncherd-M-testscripts/fala_xres_wol"
- "%{_datadir}/applauncherd-M-testscripts/test-perf.rb" - "%{_datadir}/applauncherd-M-testscripts/test-perf.rb"
- "%{_datadir}/applauncherd-M-testscripts/utils.py" - "%{_datadir}/applauncherd-M-testscripts/utils.py"
- "%exclude %{_datadir}/applauncherd-M-testscripts/utils.pyc"
- "%exclude %{_datadir}/applauncherd-M-testscripts/utils.pyo"
- "%{_datadir}/themes/base/meegotouch/fala_ft_themetest/style/fala_ft_themetest.css" - "%{_datadir}/themes/base/meegotouch/fala_ft_themetest/style/fala_ft_themetest.css"
- "%{_datadir}/applications/fala_wl.desktop" - "%{_datadir}/applications/fala_wl.desktop"
- "%{_datadir}/applications/fala_wol.desktop" - "%{_datadir}/applications/fala_wol.desktop"

@ -49,9 +49,9 @@
Booster::Booster() : Booster::Booster() :
m_appData(new AppData), m_appData(new AppData),
m_connection(NULL), m_connection(NULL),
m_argvArraySize(0),
m_oldPriority(0), m_oldPriority(0),
m_oldPriorityOk(false) m_oldPriorityOk(false),
m_spaceAvailable(0)
{} {}
Booster::~Booster() Booster::~Booster()
@ -80,7 +80,8 @@ void Booster::initialize(int initialArgc, char ** initialArgv, int newPipeFd[2],
preload(); preload();
// Rename process to temporary booster process name, e.g. "booster-m" // Rename process to temporary booster process name, e.g. "booster-m"
renameProcess(initialArgc, initialArgv); const char * tempArgv[] = {boosterTemporaryProcessName().c_str()};
renameProcess(initialArgc, initialArgv, 1, tempArgv);
// Restore priority // Restore priority
popPriority(); popPriority();
@ -121,7 +122,7 @@ void Booster::initialize(int initialArgc, char ** initialArgv, int newPipeFd[2],
// Give the process the real application name now that it // Give the process the real application name now that it
// has been read from invoker in receiveDataFromInvoker(). // has been read from invoker in receiveDataFromInvoker().
renameProcess(initialArgc, initialArgv); renameProcess(initialArgc, initialArgv, m_appData->argc(), m_appData->argv());
// Send parent process a message that it can create a new booster, // Send parent process a message that it can create a new booster,
// send pid of invoker, send booster respawn value // send pid of invoker, send booster respawn value
@ -222,61 +223,51 @@ void Booster::run(SocketManager * socketManager)
} }
} }
void Booster::renameProcess(int parentArgc, char** parentArgv) void Booster::renameProcess(int parentArgc, char** parentArgv,
int sourceArgc, const char** sourceArgv)
{ {
if (m_argvArraySize == 0) if (sourceArgc > 0 && parentArgc > 0)
{ {
// rename process for the first time // Calculate original space reserved for arguments, if not
// calculate and store size of parentArgv array // already calculated
if (!m_spaceAvailable)
for (int i = 0; i < parentArgc; i++)
m_spaceAvailable += strlen(parentArgv[i]) + 1;
for (int i = 0; i < parentArgc; i++) if (m_spaceAvailable)
m_argvArraySize += strlen(parentArgv[i]) + 1;
m_argvArraySize--;
}
if (m_appData->appName().empty())
{
// application name isn't known yet, let's give to the process
// temporary booster name
m_appData->setAppName(boosterTemporaryProcessName());
}
const char* newProcessName = m_appData->appName().c_str();
Logger::logNotice("Booster: set new name for process: %s", newProcessName);
// This code copies all the new arguments to the space reserved
// in the old argv array. If an argument won't fit then the algorithm
// leaves it fully out and terminates.
int spaceAvailable = m_argvArraySize;
if (spaceAvailable > 0)
{
memset(parentArgv[0], '\0', spaceAvailable);
strncat(parentArgv[0], newProcessName, spaceAvailable);
spaceAvailable -= strlen(parentArgv[0]);
for (int i = 1; i < m_appData->argc(); i++)
{ {
if (spaceAvailable > static_cast<int>(strlen(m_appData->argv()[i])) + 1) // Build a contiguous, NULL-separated block for the new arguments.
// This is how Linux puts them.
std::string newArgv;
for (int i = 0; i < sourceArgc; i++)
{ {
strncat(parentArgv[0], " ", 1); newArgv += sourceArgv[i];
strncat(parentArgv[0], m_appData->argv()[i], spaceAvailable); newArgv += '\0';
spaceAvailable -= strlen(m_appData->argv()[i] + 1);
} }
else
const int spaceNeeded = std::min(m_spaceAvailable,
static_cast<int>(newArgv.size()));
// Reset the old space
memset(parentArgv[0], '\0', m_spaceAvailable);
if (spaceNeeded > 0)
{ {
break; // Copy the argument data. Note: if they don't fit, then
// they are just cut off.
memcpy(parentArgv[0], newArgv.c_str(), spaceNeeded);
// Ensure NULL at the end
parentArgv[0][spaceNeeded - 1] = '\0';
} }
} }
}
// Set the process name using prctl, 'killall' and 'top' use it // Set the process name using prctl, 'killall' and 'top' use it
if ( prctl(PR_SET_NAME, basename(newProcessName)) == -1 ) if ( prctl(PR_SET_NAME, basename(sourceArgv[0])) == -1 )
Logger::logError("Booster: on set new process name: %s ", strerror(errno)); Logger::logError("Booster: on set new process name: %s ", strerror(errno));
setenv("_", newProcessName, true); setenv("_", sourceArgv[0], true);
}
} }
int Booster::launchProcess() int Booster::launchProcess()

@ -102,7 +102,8 @@ public:
* \param initialArgc Number of the arguments of the launcher process. * \param initialArgc Number of the arguments of the launcher process.
* \param initialArgv Address of the argument array of the launcher process. * \param initialArgv Address of the argument array of the launcher process.
*/ */
void renameProcess(int initialArgc, char** initialArgv); void renameProcess(int parentArgc, char** parentArgv,
int sourceArgc, const char** sourceArgv);
/*! /*!
* \brief Return booster type common to all instances. * \brief Return booster type common to all instances.
@ -195,9 +196,6 @@ private:
//! Socket connection to invoker //! Socket connection to invoker
Connection* m_connection; Connection* m_connection;
//! Size (length) of the argument vector
int m_argvArraySize;
//! Process priority before pushPriority() is called //! Process priority before pushPriority() is called
int m_oldPriority; int m_oldPriority;
@ -208,6 +206,9 @@ private:
//! Pipe used to tell the parent that a new booster is needed //! Pipe used to tell the parent that a new booster is needed
int m_pipeFd[2]; int m_pipeFd[2];
//! Original space available for arguments
int m_spaceAvailable;
#ifdef HAVE_CREDS #ifdef HAVE_CREDS
//! filter out invoker-specific credentials from boosted application //! filter out invoker-specific credentials from boosted application
static void filterOutCreds(creds_t creds); static void filterOutCreds(creds_t creds);

@ -1,15 +1,10 @@
#!/bin/sh #!/bin/sh
# Forces resolving symbols of libraries to which applauncherd.bin is
# linked to.
# commented out because of broken libamjpeg library
# export LD_BIND_NOW=1
# Use 50 chars long dummy parameter to reserve place for application # Use 50 chars long dummy parameter to reserve place for application
# name and parameters so that we get some space to modify them # name and parameters so that we get some space to modify the argument
# afterwards. If the length of the application name with parameters is # list seen in /proc/[PID]/cmdline.
# longer than space available, only the params that fully fit will be # If the length of the application name with parameters is longer than space
# shown in the output of top and ps commands. # available, parameters will be cut off. The main function will still always
# get the complete argument list.
exec /usr/bin/applauncherd.bin " " exec /usr/bin/applauncherd.bin " "

@ -1,10 +0,0 @@
xsendevent - tool for sending various xevents to windows on command line
# Compile:
qmake -project; qmake; make
# Install:
scp xsendevent dali:/usr/bin/
# Usage:
xsendevent close 0xwhatever

@ -79,61 +79,37 @@ char ** Ut_Booster::packTwoArgs(const char * arg0, const char * arg1)
return argv; return argv;
} }
void Ut_Booster::testRenameBoosterProcess() void Ut_Booster::testRenameProcess()
{ {
m_subject.reset(new MyBooster); m_subject.reset(new MyBooster);
// if appData()->appName isn't initialized, new process name is booster_x // If appData()->appName isn't initialized, new process name is booster_x
// 20 chars dummy buffer used to fool ps to show correct process name with args // 20 chars dummy buffer used to fool ps to show correct process name with args
const int INIT_ARGS = 2; const int INIT_ARGC = 2;
char ** initialArgv = packTwoArgs("oldName", " "); char ** initialArgv = packTwoArgs("oldName", " ");
m_subject->renameProcess(INIT_ARGS, const_cast<char **>(initialArgv));
// New name and arguments fit and are correct // Rename process
const char * tempArgv[] = {m_subject->boosterTemporaryProcessName().c_str()};
m_subject->renameProcess(INIT_ARGC, initialArgv, 1, tempArgv);
// Check that new name and arguments fit and are correct
QVERIFY(strcmp(initialArgv[0], m_subject->boosterTemporaryProcessName().c_str()) == 0); QVERIFY(strcmp(initialArgv[0], m_subject->boosterTemporaryProcessName().c_str()) == 0);
// Define and copy args because it's assumed that they are allocated in the heap // Define and copy args because it's assumed that they are allocated in the heap
// (AppData deletes the argv on exit) // (AppData deletes the argv on exit)
const int ARGS = 3; const int ARGC = 3;
m_subject->appData()->setArgc(ARGS); m_subject->appData()->setArgc(ARGC);
char ** argv = new char * [ARGS];
argv[0] = strdup("newName");
argv[1] = strdup("--foo");
argv[2] = strdup("--bar");
m_subject->appData()->setArgv(const_cast<const char **>(argv));
m_subject->appData()->setAppName("newName");
m_subject->renameProcess(INIT_ARGS, const_cast<char **>(initialArgv));
// New name and arguments fit and are correct
QVERIFY2(strcmp(initialArgv[0], "newName --foo --bar") == 0, initialArgv[0]);
delete initialArgv[0]; char ** argv = new char * [ARGC];
delete [] initialArgv;
}
void Ut_Booster::testRenameProcess()
{
m_subject.reset(new MyBooster);
// Define and copy args because it's assumed that they are allocated in the heap
// (AppData deletes the argv on exit)
const int ARGS = 3;
m_subject->appData()->setArgc(ARGS);
char ** argv = new char * [ARGS];
argv[0] = strdup("newName"); argv[0] = strdup("newName");
argv[1] = strdup("--foo"); argv[1] = strdup("--foo");
argv[2] = strdup("--bar"); argv[2] = strdup("--bar");
m_subject->appData()->setArgv(const_cast<const char **>(argv)); m_subject->appData()->setArgv(const_cast<const char **>(argv));
m_subject->appData()->setAppName(m_subject->appData()->argv()[0]); m_subject->renameProcess(INIT_ARGC, initialArgv, ARGC, const_cast<const char **>(argv));
// 20 chars dummy buffer used to fool ps to show correct process name with args
const int INIT_ARGS = 2;
char ** initialArgv = packTwoArgs("oldName", " ");
m_subject->renameProcess(INIT_ARGS, const_cast<char **>(initialArgv));
// New name and arguments fit and are correct // New name and arguments fit and are correct
QVERIFY(strcmp(initialArgv[0], "newName --foo --bar") == 0); const char * result = "newName\0--foo\0--bar\0";
QVERIFY2(memcmp(initialArgv[0], result, 20) == 0, initialArgv[0]);
delete initialArgv[0]; delete initialArgv[0];
delete [] initialArgv; delete [] initialArgv;
@ -143,125 +119,25 @@ void Ut_Booster::testRenameProcessNotEnoughSpace()
{ {
m_subject.reset(new MyBooster); m_subject.reset(new MyBooster);
const int ARGS = 3; const int NEW_ARGC = 3;
m_subject->appData()->setArgc(ARGS); m_subject->appData()->setArgc(NEW_ARGC);
char ** argv = new char * [ARGS]; char ** argv = new char * [NEW_ARGC];
argv[0] = strdup("newNameLong"); argv[0] = strdup("newNameLong");
argv[1] = strdup("--foo"); argv[1] = strdup("--foo");
argv[2] = strdup("--bar"); argv[2] = strdup("--bar");
m_subject->appData()->setArgv(const_cast<const char **>(argv)); m_subject->appData()->setArgv(const_cast<const char **>(argv));
m_subject->appData()->setAppName(m_subject->appData()->argv()[0]);
const int INIT_ARGS = 2; const int INIT_ARGC = 2;
char ** initialArgv = packTwoArgs("oldName", " "); char ** initialArgv = packTwoArgs("old0123", "");
int initLen = strlen(initialArgv[0]); int initLen = strlen(initialArgv[0]) + 1 + strlen("");
m_subject->renameProcess(INIT_ARGS, initialArgv); m_subject->renameProcess(INIT_ARGC, initialArgv,
m_subject->appData()->argc(), m_subject->appData()->argv());
// Not enough space for the new name nor the arguments: // Not enough space for the new name nor the arguments:
// name should be cut // name should be cut
QVERIFY(strncmp(initialArgv[0], m_subject->appData()->argv()[0], initLen - 1) == 0); QVERIFY(memcmp(initialArgv[0], m_subject->appData()->argv()[0], initLen) == 0);
QVERIFY(initialArgv[0][initLen] == '\0');
delete [] initialArgv[0]; QVERIFY(initialArgv[0][initLen - 1] == 'L');
delete [] initialArgv;
}
void Ut_Booster::testRenameProcessNotEnoughSpace2()
{
m_subject.reset(new MyBooster);
const int ARGS = 3;
m_subject->appData()->setArgc(ARGS);
char ** argv = new char * [ARGS];
argv[0] = strdup("newName");
argv[1] = strdup("--foo");
argv[2] = strdup("--bar");
m_subject->appData()->setArgv(const_cast<const char **>(argv));
m_subject->appData()->setAppName(m_subject->appData()->argv()[0]);
const int INIT_ARGS = 2;
char ** initialArgv = packTwoArgs("oldName", " ");
m_subject->renameProcess(INIT_ARGS, initialArgv);
// Not enough space for the second argument:
// second argument should be left out
QVERIFY(strcmp(initialArgv[0], "newName --foo") == 0);
delete initialArgv[0];
delete [] initialArgv;
}
void Ut_Booster::testRenameProcessNotEnoughSpace3()
{
m_subject.reset(new MyBooster);
const int ARGS = 3;
m_subject->appData()->setArgc(ARGS);
char ** argv = new char * [ARGS];
argv[0] = strdup("newName");
argv[1] = strdup("--foo");
argv[2] = strdup("--bar");
m_subject->appData()->setArgv(const_cast<const char **>(argv));
m_subject->appData()->setAppName(m_subject->appData()->argv()[0]);
const int INIT_ARGS = 2;
char ** initialArgv = packTwoArgs("app", " ");
m_subject->renameProcess(INIT_ARGS, initialArgv);
// Not enough space for arguments but just enough space
// for the new name
QVERIFY(strcmp(initialArgv[0], "newName") == 0);
delete initialArgv[0];
delete [] initialArgv;
}
void Ut_Booster::testRenameProcessNotEnoughSpace4()
{
m_subject.reset(new MyBooster);
const int ARGS = 3;
m_subject->appData()->setArgc(ARGS);
char ** argv = new char * [ARGS];
argv[0] = strdup("newNameLongLong");
argv[1] = strdup("--foo");
argv[2] = strdup("--bar");
m_subject->appData()->setArgv(const_cast<const char **>(argv));
m_subject->appData()->setAppName(m_subject->appData()->argv()[0]);
const int INIT_ARGS = 2;
char ** initialArgv = packTwoArgs("app", " ");
m_subject->renameProcess(INIT_ARGS, initialArgv);
// Not enough space for newName, but dummy space exist: should be cut
QVERIFY(strcmp(initialArgv[0], "newName") == 0);
delete initialArgv[0];
delete [] initialArgv;
}
void Ut_Booster::testRenameProcessNoArgs()
{
m_subject.reset(new MyBooster);
const int ARGS = 2;
m_subject->appData()->setArgc(ARGS);
char ** argv = new char * [ARGS];
argv[0] = strdup("newName");
argv[1] = strdup("--foo");
m_subject->appData()->setArgv(const_cast<const char **>(argv));
m_subject->appData()->setAppName(m_subject->appData()->argv()[0]);
const int INIT_ARGS = 1;
char ** initialArgv = new char * [INIT_ARGS];
initialArgv[0] = strdup("oldName");
m_subject->renameProcess(INIT_ARGS, initialArgv);
// No dummy space argument at all, only name fits
QVERIFY(strcmp(initialArgv[0], m_subject->appData()->argv()[0]) == 0);
delete initialArgv[0];
delete [] initialArgv;
} }
QTEST_APPLESS_MAIN(Ut_Booster); QTEST_APPLESS_MAIN(Ut_Booster);

@ -37,11 +37,6 @@ private Q_SLOTS:
void initTestCase(); void initTestCase();
void testRenameProcess(); void testRenameProcess();
void testRenameProcessNotEnoughSpace(); void testRenameProcessNotEnoughSpace();
void testRenameProcessNotEnoughSpace2();
void testRenameProcessNotEnoughSpace3();
void testRenameProcessNotEnoughSpace4();
void testRenameProcessNoArgs();
void testRenameBoosterProcess();
void cleanupTestCase(); void cleanupTestCase();
private: private:
@ -51,5 +46,3 @@ private:
}; };
#endif // UT_BOOSTER_H #endif // UT_BOOSTER_H

@ -80,6 +80,7 @@ class launcher_tests (unittest.TestCase):
debug("Executing TearDown") debug("Executing TearDown")
if get_pid('applauncherd') == None: if get_pid('applauncherd') == None:
os.system('initctl start xsession/applauncherd') os.system('initctl start xsession/applauncherd')
time.sleep(5)
#Testcases #Testcases
def test_launcher_exist(self): def test_launcher_exist(self):
@ -495,35 +496,22 @@ class launcher_tests (unittest.TestCase):
# invoker searches PATH for the executable # invoker searches PATH for the executable
p = run_app_as_user('invoker --type=m --no-wait fala_ft_hello.launch') p = run_app_as_user('invoker --type=m --no-wait fala_ft_hello.launch')
self.assert_(p.wait() == 0, "Couldn't launch fala_ft_hello.launch") self.assert_(p.wait() == 0, "Couldn't launch fala_ft_hello.launch")
time.sleep(2)
kill_process('fala_ft_hello') kill_process('fala_ft_hello')
# launch with relative path # launch with relative path
cwd = os.getcwd()
os.chdir('/usr/share')
p = run_app_as_user('invoker --type=m --no-wait ' + p = run_app_as_user('cd /usr/share/; invoker --type=m --no-wait ' +
"../bin/fala_ft_hello.launch") "../bin/fala_ft_hello.launch")
self.assert_(p.wait() == 0, "Couldnt launch fala_ft_hello.launch" + self.assert_(p.wait() == 0, "Couldnt launch fala_ft_hello.launch" +
" with relative path") " with relative path")
time.sleep(2)
kill_process('fala_ft_hello') kill_process('fala_ft_hello')
# find a relative path from PATH and launch from there
oldpath = os.environ['PATH']
os.environ['PATH'] = '../bin:' + os.environ['PATH']
p = run_app_as_user('invoker --type=m --no-wait ' +
"fala_ft_hello.launch")
self.assert_(p.wait() == 0, "Couldnt launch fala_ft_hello.launch" +
" with relative path (2)")
kill_process('fala_ft_hello')
# restore CWD and PATH
os.chdir(cwd)
os.environ['PATH'] = oldpath
# and finally, try to launch something that doesn't exist # and finally, try to launch something that doesn't exist
p = run_app_as_user('invoker --type=m --no-wait spam_cake.launch') p = run_app_as_user('invoker --type=m --no-wait spam_cake.launch')
self.assert_(p.wait() != 0, "Found spam_cake.launch for some reason") self.assert_(p.wait() != 127, "Found spam_cake.launch for some reason")
time.sleep(2)
kill_process('spam_cake') kill_process('spam_cake')
def test_booster_killed_or_restarted(self): def test_booster_killed_or_restarted(self):
@ -626,6 +614,7 @@ class launcher_tests (unittest.TestCase):
p = run_app_as_user('invoker --respawn 256 --type=q --no-wait fala_ft_hello.launch') p = run_app_as_user('invoker --respawn 256 --type=q --no-wait fala_ft_hello.launch')
self.assert_(p.wait() != 0, "invoker didn't die with too big respawn delay") self.assert_(p.wait() != 0, "invoker didn't die with too big respawn delay")
kill_process('fala_ft_hello')
def test_invoker_bogus_apptype(self): def test_invoker_bogus_apptype(self):
p = run_app_as_user('invoker --type=foobar fala_ft_hello.launch') p = run_app_as_user('invoker --type=foobar fala_ft_hello.launch')
@ -681,6 +670,10 @@ class launcher_tests (unittest.TestCase):
""" """
Stress test for boosted applications to check only one instance is running. Stress test for boosted applications to check only one instance is running.
""" """
if get_pid('fala_ft_hello') != None:
kill_process('fala_ft_hello')
time.sleep(2)
count = 0
p = run_app_as_user('invoker --type=m --no-wait fala_ft_hello.launch') p = run_app_as_user('invoker --type=m --no-wait fala_ft_hello.launch')
pid = get_pid('fala_ft_hello') pid = get_pid('fala_ft_hello')
for i in xrange(10): for i in xrange(10):
@ -688,7 +681,14 @@ class launcher_tests (unittest.TestCase):
app_pid = get_pid('fala_ft_hello') app_pid = get_pid('fala_ft_hello')
self.assert_(app_pid != None, "Application is not running") self.assert_(app_pid != None, "Application is not running")
self.assert_(pid == app_pid, "Same instance of application not running") self.assert_(pid == app_pid, "Same instance of application not running")
time.sleep(5) st, op = commands.getstatusoutput('ps ax | grep invoker | grep fala_ft_hello.launch | grep -v -- -sh | wc -l')
count = int(op)
while count != 0:
debug("The value of queue is %d" %count)
time.sleep(3)
debug("Sleeping for 3 secs")
st, op = commands.getstatusoutput('ps ax | grep invoker | grep fala_ft_hello.launch | grep -v -- -sh | wc -l')
count = int(op)
kill_process('fala_ft_hello') kill_process('fala_ft_hello')
def test_launched_app_name(self): def test_launched_app_name(self):

@ -14,19 +14,19 @@
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-security.py test_correct_creds</step> <step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-security.py test_correct_creds</step>
</case> </case>
<case name="applauncherd__test_application_specific_theming" type="Functional" description="Application specific theming tests" timeout="360" level="System" insignificant="true"> <!--case name="applauncherd__test_application_specific_theming" type="Functional" description="Application specific theming tests" timeout="360" level="System" insignificant="true">
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 /usr/share/applauncherd-testscripts/tc_theming.rb --name test_application_specific_theming</step> <step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 /usr/share/applauncherd-testscripts/tc_theming.rb name test_application_specific_theming</step>
</case> </case>
<case name="applauncherd__test_global_theming" type="Functional" description="Tests that global theming changes affect launched applications" timeout="360" level="System" insignificant="true"> <case name="applauncherd__test_global_theming" type="Functional" description="Tests that global theming changes affect launched applications" timeout="360" level="System" insignificant="true">
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 /usr/share/applauncherd-testscripts/tc_theming.rb --name test_global_theming</step> <step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 /usr/share/applauncherd-testscripts/tc_theming.rb name test_global_theming</step>
</case> </case-->
<case name="applauncherd__test_oom_adj" type="Functional" description="Test that oom.adj is 0 for launched application process" timeout="360" level="System" insignificant="true"> <case name="applauncherd__test_oom_adj" type="Functional" description="Test that oom.adj is 0 for launched application process" timeout="360" level="System" insignificant="true">
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_oom_adj</step> <step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_oom_adj</step>
</case> </case>
<case name="applauncherd__test_launched_app_name" type="Functional" description="Test that launched application name have .launch at the end" timeout="360" level="System" insignificant="true"> <case name="applauncherd__test_launched_app_name" type="Functional" description="Test that launched application name have .launch at the end" timeout="900" level="System" insignificant="true">
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_launched_app_name</step> <step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_launched_app_name</step>
</case> </case>
@ -34,19 +34,19 @@
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_stress_boosted_apps</step> <step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_stress_boosted_apps</step>
</case> </case>
<case name="invoker_param_creds" type="Functional" description="test invoker --creds" timeout="360" level="System" insignificant="true"> <case name="applauncherd__test_invoker_param_creds" type="Functional" description="test invoker --creds" timeout="360" level="System" insignificant="true">
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_invoker_param_creds</step> <step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_invoker_param_creds</step>
</case> </case>
<case name="invoker_param_respawn_delay" type="Functional" description="test invoker --respawn" timeout="360" level="System" insignificant="true"> <case name="applauncherd__test_invoker_param_respawn_delay" type="Functional" description="test invoker --respawn" timeout="360" level="System" insignificant="true">
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_invoker_param_respawn_delay</step> <step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_invoker_param_respawn_delay</step>
</case> </case>
<case name="invoker_bogus_apptype" type="Functional" description="test giving bogus apptype to invoker" timeout="360" level="System" insignificant="true"> <case name="applauncherd__test_invoker_bogus_apptype" type="Functional" description="test giving bogus apptype to invoker" timeout="360" level="System" insignificant="true">
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_invoker_bogus_apptype</step> <step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_invoker_bogus_apptype</step>
</case> </case>
<case name="applauncherd__test_launch_prestarted_app" type="Functional" description="To test that prestarted application is launched" timeout="360" level="System" insignificant="true"> <case name="applauncherd__test_launch_prestarted_app" type="Functional" description="To test that prestarted application is launched" timeout="900" level="System" insignificant="true">
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 /usr/share/applauncherd-testscripts/ts_prestartapp.rb --name test_launch_prestarted_app</step> <step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 /usr/share/applauncherd-testscripts/ts_prestartapp.rb --name test_launch_prestarted_app</step>
</case> </case>

Loading…
Cancel
Save