mirror of https://github.com/cutefishos/appmotor
[mapplauncherd] Remove applauncherd and refactor boosters into independent processes
Having a single applauncherd process with boosters as plugins is a flawed idea: most notably, it's not possible to have two boosters with conflicting libraries, like Qt4 and Qt5. A much cleaner solution is to turn libapplauncherd into a support library for boosters, and have each booster run as an independent process.pull/1/head
parent
34c64fdf1a
commit
b6e9aa171b
@ -1,12 +0,0 @@
|
||||
[Unit]
|
||||
Description=MTF app launcher daemon
|
||||
After=xorg.target
|
||||
Requires=dbus.socket xorg.target
|
||||
|
||||
[Service]
|
||||
Type=notify
|
||||
ExecStart=/usr/bin/applauncherd --systemd
|
||||
|
||||
[Install]
|
||||
# For compatibility
|
||||
Alias=meegotouch-applauncherd.service
|
||||
@ -0,0 +1,8 @@
|
||||
[Unit]
|
||||
Description=Generic application launch booster
|
||||
After=xorg.target
|
||||
Requires=dbus.socket xorg.target
|
||||
|
||||
[Service]
|
||||
Type=notify
|
||||
ExecStart=/usr/libexec/mapplauncherd/ebooster --systemd
|
||||
@ -1,46 +0,0 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** 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 "ebooster.h"
|
||||
|
||||
#define DECL_EXPORT __attribute__((visibility("default")))
|
||||
|
||||
extern "C"
|
||||
{
|
||||
// Create a new plugin instance.
|
||||
DECL_EXPORT void * create()
|
||||
{
|
||||
return new EBooster;
|
||||
}
|
||||
|
||||
DECL_EXPORT char type()
|
||||
{
|
||||
return EBooster::type();
|
||||
}
|
||||
|
||||
DECL_EXPORT const char * socketName()
|
||||
{
|
||||
return EBooster::socketName().c_str();
|
||||
}
|
||||
|
||||
DECL_EXPORT const char * temporaryProcessName()
|
||||
{
|
||||
return EBooster::temporaryProcessName().c_str();
|
||||
}
|
||||
}
|
||||
@ -1,38 +0,0 @@
|
||||
# Generate list of libraries for preload.h
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/preload-h-libraries.h
|
||||
COMMAND python ${CMAKE_HOME_DIRECTORY}/scripts/library-helper.py --preload-h-libraries
|
||||
DEPENDS ${CMAKE_HOME_DIRECTORY}/scripts/library-helper.py
|
||||
)
|
||||
|
||||
# Generate linker command line fragment
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/additional-linked-libraries.ld
|
||||
COMMAND python ${CMAKE_HOME_DIRECTORY}/scripts/library-helper.py --linker-flags
|
||||
DEPENDS ${CMAKE_HOME_DIRECTORY}/scripts/library-helper.py
|
||||
)
|
||||
|
||||
# Set sources
|
||||
set(SRC launcher.c)
|
||||
|
||||
# Set include dirs
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/src/common ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
# Set C flags
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -D_POSIX_C_SOURCE=200112L -Wl,--no-as-needed -Wl,@additional-linked-libraries.ld")
|
||||
|
||||
# Set precompiler flags
|
||||
add_definitions(-DLIBRARIES_CONFIG_FILE="/etc/applauncherd.conf")
|
||||
add_definitions(-DLAUNCHER_LIBRARY="/usr/lib/libapplauncherd.so.0")
|
||||
|
||||
link_libraries(${LIBDL})
|
||||
|
||||
# Set target
|
||||
add_executable(applauncherd.bin
|
||||
${SRC}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/preload-h-libraries.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/additional-linked-libraries.ld)
|
||||
|
||||
# Add install rule
|
||||
install(PROGRAMS applauncherd.bin DESTINATION /usr/bin/)
|
||||
|
||||
@ -1,188 +0,0 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** 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 <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <dlfcn.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "preload.h"
|
||||
|
||||
typedef int (*entry_t)(int, char **);
|
||||
|
||||
int g_debugPrinting;
|
||||
|
||||
//! Load libraries from the given array
|
||||
static void loadLibraries(const char * const libs[], unsigned int numLibs)
|
||||
{
|
||||
for (unsigned int i = 0; i < numLibs; i++)
|
||||
{
|
||||
const char * lib = libs[i];
|
||||
int len = strlen(lib);
|
||||
if (lib[0] != '#' && len > 1)
|
||||
{
|
||||
int flags = 0;
|
||||
int skipChar = 0;
|
||||
|
||||
// "now"
|
||||
if (lib[0] == 'N')
|
||||
{
|
||||
skipChar = 1;
|
||||
flags = RTLD_NOW | RTLD_GLOBAL;
|
||||
}
|
||||
// "lazy"
|
||||
else if (lib[0] == 'L')
|
||||
{
|
||||
skipChar = 1;
|
||||
flags = RTLD_LAZY | RTLD_GLOBAL;
|
||||
}
|
||||
// "deep"
|
||||
else if (lib[0] == 'D')
|
||||
{
|
||||
skipChar = 1;
|
||||
flags = RTLD_DEEPBIND | RTLD_GLOBAL;
|
||||
}
|
||||
// "default"
|
||||
else
|
||||
{
|
||||
skipChar = 0;
|
||||
flags = RTLD_NOW | RTLD_GLOBAL;
|
||||
}
|
||||
|
||||
// Open the library. Print possible errors only in debug mode.
|
||||
dlerror();
|
||||
|
||||
// coverity[leaked_storage : FALSE]
|
||||
if (!dlopen(lib + skipChar, flags) && g_debugPrinting)
|
||||
{
|
||||
fprintf(stderr, "Warning: can't preload %s\n", lib + skipChar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*! Invoke launcher daemon library and run main()
|
||||
*
|
||||
* Note that argv must have enough dummy space so that
|
||||
* the argument vector can be altered afterwards.
|
||||
*
|
||||
* See e.g. Booster::renameProcess(int parentArgc, char** parentArgv)
|
||||
* in launcherlib/booster.cpp
|
||||
*/
|
||||
static int invokeLauncherLib(int argc, char ** argv)
|
||||
{
|
||||
// Clear any existing error
|
||||
dlerror();
|
||||
|
||||
void * handle = dlopen(LAUNCHER_LIBRARY, RTLD_LAZY | RTLD_LOCAL);
|
||||
if (handle)
|
||||
{
|
||||
char * error = NULL;
|
||||
|
||||
// Clear any existing error
|
||||
dlerror();
|
||||
|
||||
// Find out address of main
|
||||
entry_t entry = (entry_t)dlsym(handle, "main");
|
||||
|
||||
// Check error
|
||||
if ((error = dlerror()) != NULL)
|
||||
{
|
||||
fprintf(stderr, "%s\n", error);
|
||||
dlclose(handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
entry(argc, argv);
|
||||
dlclose(handle);
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s\n", dlerror());
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//! Entry point
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
// Exit if DISPLAY is missing. This would result in dying
|
||||
// boosters and applauncherd would keep on re-starting them.
|
||||
if (!getenv("DISPLAY"))
|
||||
{
|
||||
fprintf(stderr, "FATAL!!: DISPLAY environment variable not set.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Parse command line
|
||||
g_debugPrinting = 0;
|
||||
|
||||
int helpWanted = 0;
|
||||
for (int i = 1; i < argc; ++i)
|
||||
{
|
||||
if (strcmp(argv[i], "--debug") == 0)
|
||||
g_debugPrinting = 1;
|
||||
|
||||
if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0)
|
||||
helpWanted = 1;
|
||||
}
|
||||
|
||||
// Set environment. Because applauncherd is usually a privileged
|
||||
// process, TMPDIR variable might be unset by the C library. In
|
||||
// case it's not set, we set it to /var/tmp, which usually is not
|
||||
// a RAM disk.
|
||||
setenv("TMPDIR", "/var/tmp", 0);
|
||||
|
||||
// Since this application is classified as suid application due to it's credentials
|
||||
// the environment variables below are not processed by eglibc
|
||||
// so we're processing this to set correct memory options
|
||||
char* s = NULL;
|
||||
if((s = getenv("MALLOC_TRIM_THRESHOLD_")))
|
||||
mallopt(M_TRIM_THRESHOLD, atoi(s));
|
||||
if((s = getenv("MALLOC_TOP_PAD_")))
|
||||
mallopt(M_TOP_PAD, atoi(s));
|
||||
if((s = getenv("MALLOC_PERTURB_")))
|
||||
mallopt(M_PERTURB, atoi(s));
|
||||
if((s = getenv("MALLOC_MMAP_THRESHOLD_")))
|
||||
mallopt(M_MMAP_THRESHOLD, atoi(s));
|
||||
if((s = getenv("MALLOC_MMAP_MAX_")))
|
||||
mallopt(M_MMAP_MAX, atoi(s));
|
||||
|
||||
// Preload libraries
|
||||
if (!helpWanted)
|
||||
loadLibraries(gLibs, sizeof(gLibs) / sizeof(char *));
|
||||
|
||||
// Start the real applauncherd.
|
||||
if (!invokeLauncherLib(argc, argv))
|
||||
{
|
||||
fprintf(stderr, "FATAL!!: Failed to load the launcher library\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef WITH_COVERAGE
|
||||
__gcov_flush();
|
||||
#endif
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef PRELOAD_H
|
||||
#define PRELOAD_H
|
||||
|
||||
const char * const gLibs[] =
|
||||
{
|
||||
|
||||
// Include the generated set of libraries.
|
||||
#include "preload-h-libraries.h"
|
||||
|
||||
"/usr/bin/single-instance"
|
||||
};
|
||||
|
||||
#endif // PRELOAD_H
|
||||
@ -1,34 +0,0 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** 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 "boosterfactory.h"
|
||||
#include "boosterpluginregistry.h"
|
||||
#include "booster.h"
|
||||
|
||||
Booster * BoosterFactory::create(char type)
|
||||
{
|
||||
if (BoosterPluginEntry * plugin = BoosterPluginRegistry::pluginEntry(type))
|
||||
{
|
||||
return static_cast<Booster *>(plugin->createFunc());
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@ -1,45 +0,0 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef BOOSTERFACTORY_H
|
||||
#define BOOSTERFACTORY_H
|
||||
|
||||
class Booster;
|
||||
|
||||
/*!
|
||||
* \class BoosterFactory
|
||||
* \brief BoosterFactory creates a new booster of given type.
|
||||
*/
|
||||
// TODO: Could be a namespace instead of a class.
|
||||
class BoosterFactory
|
||||
{
|
||||
public:
|
||||
/*! \brief Creates a new booster.
|
||||
* \param type Wanted booster type: 'q' = Qt, 'm' = MeeGo Touch.
|
||||
* \return Pointer to Booster on success, NULL if failed
|
||||
*/
|
||||
static Booster * create(char type);
|
||||
|
||||
private:
|
||||
|
||||
//! Hidden constructor
|
||||
BoosterFactory() {};
|
||||
};
|
||||
|
||||
#endif // BOOSTERFACTORY_H
|
||||
@ -1,121 +0,0 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** 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 "boosterpluginregistry.h"
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
BoosterPluginRegistry::RegistryType BoosterPluginRegistry::m_registry;
|
||||
|
||||
char BoosterPluginRegistry::validateAndRegisterPlugin(void * handle)
|
||||
{
|
||||
// Check if create() is there
|
||||
dlerror();
|
||||
create_func_t create = (create_func_t)dlsym(handle, "create");
|
||||
|
||||
// Check error
|
||||
char * error = NULL;
|
||||
if ((error = dlerror()) != NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Check if type() is there
|
||||
dlerror();
|
||||
type_func_t type = (type_func_t)dlsym(handle, "type");
|
||||
|
||||
// Check error
|
||||
if ((error = dlerror()) != NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Check if socketName() is there
|
||||
dlerror();
|
||||
sn_func_t socketName = (sn_func_t)dlsym(handle, "socketName");
|
||||
|
||||
// Check error
|
||||
if ((error = dlerror()) != NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Check if temporaryProcessName() is there
|
||||
dlerror();
|
||||
tpn_func_t temporaryProcessName = (tpn_func_t)dlsym(handle, "temporaryProcessName");
|
||||
|
||||
// Check error
|
||||
if ((error = dlerror()) != NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
registerPlugin(type(), create, socketName, temporaryProcessName);
|
||||
return type();
|
||||
}
|
||||
|
||||
void BoosterPluginRegistry::registerPlugin(char type,
|
||||
create_func_t createFunc,
|
||||
sn_func_t socketNameFunc,
|
||||
tpn_func_t temporaryProcessNameFunc)
|
||||
|
||||
{
|
||||
BoosterPluginEntry * entry = pluginEntry(type);
|
||||
if (!entry)
|
||||
{
|
||||
entry = new BoosterPluginEntry;
|
||||
m_registry.push_back(shared_ptr<BoosterPluginEntry>(entry));
|
||||
}
|
||||
|
||||
entry->type = type;
|
||||
entry->createFunc = createFunc;
|
||||
entry->socketNameFunc = socketNameFunc;
|
||||
entry->temporaryProcessNameFunc = temporaryProcessNameFunc;
|
||||
}
|
||||
|
||||
int BoosterPluginRegistry::pluginCount()
|
||||
{
|
||||
return m_registry.size();
|
||||
}
|
||||
|
||||
BoosterPluginEntry * BoosterPluginRegistry::pluginEntry(int index)
|
||||
{
|
||||
if (index < 0 || index >= static_cast<int>(m_registry.size()))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return m_registry.at(index).get();
|
||||
}
|
||||
|
||||
BoosterPluginEntry * BoosterPluginRegistry::pluginEntry(char type)
|
||||
{
|
||||
BoosterPluginRegistry::RegistryType::const_iterator i = m_registry.begin();
|
||||
while (i != m_registry.end())
|
||||
{
|
||||
if ((*i).get()->type == type)
|
||||
{
|
||||
return (*i).get();
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@ -1,101 +0,0 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef BOOSTERPLUGINREGISTRY_H
|
||||
#define BOOSTERPLUGINREGISTRY_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
using std::vector;
|
||||
|
||||
#include <tr1/memory>
|
||||
|
||||
using std::tr1::shared_ptr;
|
||||
|
||||
// Function pointer type for Booster::type()
|
||||
typedef char (*type_func_t)();
|
||||
|
||||
// Function pointer type for Booster::create()
|
||||
typedef void * (*create_func_t)();
|
||||
|
||||
// Function pointer type for Booster::socketName()
|
||||
typedef const char * (*sn_func_t)();
|
||||
|
||||
// Function pointer type for Booster::temporaryProcessName()
|
||||
typedef const char * (*tpn_func_t)();
|
||||
|
||||
//! Item in the registry
|
||||
struct BoosterPluginEntry
|
||||
{
|
||||
//! Booster type
|
||||
char type;
|
||||
|
||||
//! Create function
|
||||
create_func_t createFunc;
|
||||
|
||||
//! Socket name function
|
||||
sn_func_t socketNameFunc;
|
||||
|
||||
//! Temporary process name function
|
||||
tpn_func_t temporaryProcessNameFunc;
|
||||
};
|
||||
|
||||
/*! \class BoosterPluginRegistry
|
||||
* \brief BoosterPluginRegistry holds needed data for registered plugins.
|
||||
*/
|
||||
class BoosterPluginRegistry
|
||||
{
|
||||
public:
|
||||
|
||||
/*! Validate given plugin library handle and register to
|
||||
* BoosterPluginRegistry. Returns the type of the registered
|
||||
* plugin or 0 if failed.
|
||||
*/
|
||||
static char validateAndRegisterPlugin(void * handle);
|
||||
|
||||
//! Return number of registered plugins
|
||||
static int pluginCount();
|
||||
|
||||
//! Return pointer to given booster plugin. NULL if not found.
|
||||
static BoosterPluginEntry * pluginEntry(int index);
|
||||
|
||||
//! Return pointer to given booster plugin. NULL if not found.
|
||||
static BoosterPluginEntry * pluginEntry(char type);
|
||||
|
||||
private:
|
||||
|
||||
//! Hidden constructor
|
||||
BoosterPluginRegistry() {};
|
||||
|
||||
//! Register a booster plugin
|
||||
static void registerPlugin(char type,
|
||||
create_func_t createFunc,
|
||||
sn_func_t socketNameFunc,
|
||||
tpn_func_t temporaryProcessNameFunc);
|
||||
|
||||
//! Registry
|
||||
typedef vector<shared_ptr<BoosterPluginEntry> > RegistryType;
|
||||
static RegistryType m_registry;
|
||||
|
||||
#ifdef UNIT_TEST
|
||||
friend class Ut_BoosterPluginRegistry;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // BOOSTERPLUGINREGISTRY_H
|
||||
@ -1,123 +0,0 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** 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 "daemon.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/file.h>
|
||||
#include <stdexcept>
|
||||
|
||||
int g_sigPipeFd = -1;
|
||||
char g_pipeDataSigChld = SIGCHLD;
|
||||
char g_pipeDataSigTerm = SIGTERM;
|
||||
char g_pipeDataSigUsr1 = SIGUSR1;
|
||||
char g_pipeDataSigUsr2 = SIGUSR2;
|
||||
char g_pipeDataSigPipe = SIGPIPE;
|
||||
char g_pipeDataSigHup = SIGHUP;
|
||||
|
||||
static void sigChldHandler(int)
|
||||
{
|
||||
write(g_sigPipeFd, &g_pipeDataSigChld, 1);
|
||||
}
|
||||
|
||||
static void sigTermHandler(int)
|
||||
{
|
||||
write(g_sigPipeFd, &g_pipeDataSigTerm, 1);
|
||||
}
|
||||
|
||||
static void sigUsr1Handler(int)
|
||||
{
|
||||
write(g_sigPipeFd, &g_pipeDataSigUsr1, 1);
|
||||
}
|
||||
|
||||
static void sigUsr2Handler(int)
|
||||
{
|
||||
write(g_sigPipeFd, &g_pipeDataSigUsr2, 1);
|
||||
}
|
||||
|
||||
static void sigPipeHandler(int)
|
||||
{
|
||||
write(g_sigPipeFd, &g_pipeDataSigPipe, 1);
|
||||
}
|
||||
|
||||
static void sigHupHandler(int)
|
||||
{
|
||||
write(g_sigPipeFd, &g_pipeDataSigHup, 1);
|
||||
}
|
||||
|
||||
//! Main function
|
||||
extern "C" DECL_EXPORT int main(int argc, char * argv[])
|
||||
{
|
||||
// Open the log
|
||||
Logger::openLog(PROG_NAME_LAUNCHER);
|
||||
Logger::logDebug("%s starting..", PROG_NAME_LAUNCHER);
|
||||
|
||||
// Check that an instance of launcher is not already running already
|
||||
// here if we are not going to fork. In that case the lock should be
|
||||
// checked after fork() is done in Daemon::daemonize
|
||||
std::vector<std::string> args(argv, argv + argc);
|
||||
if (find(args.begin(), args.end(), "-d") == args.end() &&
|
||||
find(args.begin(), args.end(), "--daemon") == args.end())
|
||||
{
|
||||
if(!Daemon::lock())
|
||||
{
|
||||
Logger::logError("%s is already running \n", PROG_NAME_LAUNCHER);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Create main daemon instance
|
||||
Daemon myDaemon(argc, argv);
|
||||
|
||||
// Get fd for signal pipe.
|
||||
g_sigPipeFd = myDaemon.sigPipeFd();
|
||||
|
||||
// Install signal handlers. The original handlers are saved
|
||||
// in the daemon instance so that they can be restored in boosters.
|
||||
myDaemon.setUnixSignalHandler(SIGCHLD, sigChldHandler); // reap zombies
|
||||
myDaemon.setUnixSignalHandler(SIGTERM, sigTermHandler); // exit launcher
|
||||
myDaemon.setUnixSignalHandler(SIGUSR1, sigUsr1Handler); // enter normal mode from boot mode
|
||||
myDaemon.setUnixSignalHandler(SIGUSR2, sigUsr2Handler); // enter boot mode (same as --boot-mode)
|
||||
myDaemon.setUnixSignalHandler(SIGPIPE, sigPipeHandler); // broken invoker's pipe
|
||||
myDaemon.setUnixSignalHandler(SIGHUP, sigHupHandler); // re-exec
|
||||
|
||||
// Run the main loop
|
||||
myDaemon.run();
|
||||
|
||||
// Close the log
|
||||
Logger::closeLog();
|
||||
}
|
||||
catch (std::runtime_error & e)
|
||||
{
|
||||
Logger::logError(e.what());
|
||||
std::cout << e.what() << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Use 50 chars long dummy parameter to reserve place for application
|
||||
# name and parameters so that we get some space to modify the argument
|
||||
# list seen in /proc/[PID]/cmdline.
|
||||
# If the length of the application name with parameters is longer than space
|
||||
# available, parameters will be cut off. The main function will still always
|
||||
# get the complete argument list.
|
||||
exec /usr/bin/applauncherd.bin $@ " "
|
||||
@ -1,9 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Use 50 chars long dummy parameter to reserve place for application
|
||||
# name and parameters so that we get some space to modify the argument
|
||||
# list seen in /proc/[PID]/cmdline.
|
||||
# If the length of the application name with parameters is longer than space
|
||||
# available, parameters will be cut off. The main function will still always
|
||||
# get the complete argument list.
|
||||
exec /usr/bin/applauncherd.bin --debug $@ " "
|
||||
@ -1,37 +0,0 @@
|
||||
set(LAUNCHER ${CMAKE_HOME_DIRECTORY}/src/launcherlib)
|
||||
set(DESTINATION "/usr/share/applauncherd-tests/")
|
||||
|
||||
add_definitions(-DTEST_LIB_CREATE_PATH="${DESTINATION}libutwithcreate.so")
|
||||
add_definitions(-DTEST_LIB_CREATETYPE_PATH="${DESTINATION}libutwithcreatetype.so")
|
||||
add_definitions(-DTEST_LIB_CREATETYPESOCKETNAME_PATH="${DESTINATION}libutwithcreatetypesocketname.so")
|
||||
add_definitions(-DTEST_LIB_PLUGIN_PATH="${DESTINATION}libutplugin.so")
|
||||
|
||||
# Set sources
|
||||
set(SRC ut_boosterpluginregistry.cpp ${LAUNCHER}/boosterpluginregistry.cpp)
|
||||
|
||||
# Set moc headers
|
||||
set(MOC_HDRS ut_boosterpluginregistry.h)
|
||||
|
||||
# Run moc
|
||||
qt4_wrap_cpp(MOC_SRC ${MOC_HDRS})
|
||||
|
||||
# Enable test library
|
||||
set(QT_USE_QTTEST TRUE)
|
||||
|
||||
# Set include paths
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${LAUNCHER})
|
||||
|
||||
link_libraries(${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY} -ldl)
|
||||
|
||||
# Enable Qt (may not be needed, because already defined on higher level)
|
||||
include(${QT_USE_FILE})
|
||||
|
||||
add_executable(ut_boosterpluginregistry ${SRC} ${MOC_SRC})
|
||||
add_library(utwithcreate MODULE ut_library_withcreate.cpp)
|
||||
add_library(utwithcreatetype MODULE ut_library_withcreatetype.cpp)
|
||||
add_library(utwithcreatetypesocketname MODULE ut_library_withcreatetypesocketName.cpp)
|
||||
add_library(utplugin MODULE ut_library_plugin.cpp)
|
||||
|
||||
# Install
|
||||
install(PROGRAMS ut_boosterpluginregistry DESTINATION ${DESTINATION})
|
||||
install(FILES libutwithcreate.so libutwithcreatetype.so libutwithcreatetypesocketname.so libutplugin.so DESTINATION ${DESTINATION})
|
||||
@ -1,110 +0,0 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 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 "ut_boosterpluginregistry.h"
|
||||
#include "boosterpluginregistry.h"
|
||||
#include <dlfcn.h>
|
||||
|
||||
Ut_BoosterPluginRegistry::Ut_BoosterPluginRegistry()
|
||||
{}
|
||||
|
||||
Ut_BoosterPluginRegistry::~Ut_BoosterPluginRegistry()
|
||||
{}
|
||||
|
||||
void Ut_BoosterPluginRegistry::initTestCase()
|
||||
{}
|
||||
|
||||
void Ut_BoosterPluginRegistry::cleanupTestCase()
|
||||
{}
|
||||
|
||||
void Ut_BoosterPluginRegistry::testValidateAndRegisterPlugin()
|
||||
{
|
||||
void * handle = NULL;
|
||||
//positive
|
||||
handle = dlopen(TEST_LIB_PLUGIN_PATH, RTLD_NOW);
|
||||
QVERIFY(handle);
|
||||
char pluginType = BoosterPluginRegistry::validateAndRegisterPlugin(handle);
|
||||
QVERIFY(pluginType == 'z');
|
||||
|
||||
//negative invalid handle
|
||||
handle = NULL;
|
||||
QVERIFY(BoosterPluginRegistry::validateAndRegisterPlugin(handle) == false);
|
||||
|
||||
//negative no "type" symbol in the plugin (only create)
|
||||
handle = dlopen(TEST_LIB_CREATE_PATH, RTLD_NOW);
|
||||
QVERIFY(handle);
|
||||
QVERIFY(BoosterPluginRegistry::validateAndRegisterPlugin(handle) == false);
|
||||
|
||||
//negative no "socketName" symbol in the plugin (only create and type)
|
||||
handle = dlopen(TEST_LIB_CREATETYPE_PATH, RTLD_NOW);
|
||||
QVERIFY(handle);
|
||||
QVERIFY(BoosterPluginRegistry::validateAndRegisterPlugin(handle) == false);
|
||||
|
||||
//negative no "temporaryProcessName" symbol in the plugin (only create, type and sockeName)
|
||||
handle = dlopen(TEST_LIB_CREATETYPESOCKETNAME_PATH, RTLD_NOW);
|
||||
QVERIFY(handle);
|
||||
QVERIFY(BoosterPluginRegistry::validateAndRegisterPlugin(handle) == false);
|
||||
}
|
||||
|
||||
void Ut_BoosterPluginRegistry::testRegisterPlugin()
|
||||
{
|
||||
|
||||
void * handle = dlopen(TEST_LIB_PLUGIN_PATH, RTLD_NOW);
|
||||
QVERIFY(handle);
|
||||
dlerror();
|
||||
|
||||
create_func_t createFunc = (create_func_t)dlsym(handle, "create");
|
||||
QVERIFY(dlerror() == NULL);
|
||||
|
||||
sn_func_t socketNameFunc = (sn_func_t)dlsym(handle, "socketName");
|
||||
QVERIFY(dlerror() == NULL);
|
||||
|
||||
tpn_func_t temporaryProcessNameFunc = (tpn_func_t)dlsym(handle, "temporaryProcessName");
|
||||
QVERIFY(dlerror() == NULL);
|
||||
|
||||
BoosterPluginRegistry::registerPlugin('0', createFunc, socketNameFunc, temporaryProcessNameFunc); //register new plugin with type '0'
|
||||
BoosterPluginEntry * pluginEntry = BoosterPluginRegistry::pluginEntry('0');
|
||||
QVERIFY(pluginEntry);
|
||||
QVERIFY(pluginEntry->type == '0');
|
||||
}
|
||||
|
||||
void Ut_BoosterPluginRegistry::testPluginEntry()
|
||||
{
|
||||
//positive
|
||||
void * handle = dlopen(TEST_LIB_PLUGIN_PATH, RTLD_NOW);
|
||||
QVERIFY(handle);
|
||||
BoosterPluginRegistry::validateAndRegisterPlugin(handle);
|
||||
BoosterPluginEntry * pluginEntry = BoosterPluginRegistry::pluginEntry('z');
|
||||
QVERIFY(pluginEntry);
|
||||
QVERIFY(pluginEntry->type == 'z');
|
||||
|
||||
//negative with negative index for int type constructor
|
||||
QVERIFY(BoosterPluginRegistry::pluginEntry(-100) == false);
|
||||
|
||||
//negative with index larger then registered plugins count
|
||||
int index;
|
||||
index = BoosterPluginRegistry::pluginCount() + 1;
|
||||
QVERIFY(BoosterPluginRegistry::pluginEntry(index) == false);
|
||||
|
||||
//negative with unregistered plugin type
|
||||
QVERIFY(BoosterPluginRegistry::pluginEntry('1') == false);
|
||||
}
|
||||
|
||||
|
||||
QTEST_APPLESS_MAIN(Ut_BoosterPluginRegistry)
|
||||
@ -1,47 +0,0 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef UT_BOOSTERPLUGINREGISTRY_H
|
||||
#define UT_BOOSTERPLUGINREGISTRY_H
|
||||
|
||||
#include<QtTest/QtTest>
|
||||
#include<QObject>
|
||||
|
||||
#define UNIT_TEST
|
||||
|
||||
class BoosterPluginRegistry;
|
||||
|
||||
class Ut_BoosterPluginRegistry : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Ut_BoosterPluginRegistry();
|
||||
virtual ~Ut_BoosterPluginRegistry();
|
||||
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
void testValidateAndRegisterPlugin();
|
||||
void testRegisterPlugin();
|
||||
void testPluginEntry();
|
||||
|
||||
};
|
||||
|
||||
#endif // UT_BOOSTERPLUGINREGISTRY_H
|
||||
@ -1,42 +0,0 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#define DECL_EXPORT extern "C" __attribute__ ((__visibility__("default")))
|
||||
extern "C"
|
||||
{
|
||||
DECL_EXPORT void create()
|
||||
{
|
||||
}
|
||||
|
||||
DECL_EXPORT char type()
|
||||
{
|
||||
return 'z';
|
||||
}
|
||||
|
||||
DECL_EXPORT const char * socketName()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
DECL_EXPORT const char * temporaryProcessName()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,26 +0,0 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#define DECL_EXPORT extern "C" __attribute__ ((__visibility__("default")))
|
||||
extern "C"
|
||||
{
|
||||
DECL_EXPORT void create()
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#define DECL_EXPORT extern "C" __attribute__ ((__visibility__("default")))
|
||||
extern "C"
|
||||
{
|
||||
DECL_EXPORT void create()
|
||||
{
|
||||
}
|
||||
|
||||
DECL_EXPORT void type()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#define DECL_EXPORT extern "C" __attribute__ ((__visibility__("default")))
|
||||
extern "C"
|
||||
{
|
||||
DECL_EXPORT void create()
|
||||
{
|
||||
}
|
||||
|
||||
DECL_EXPORT void type()
|
||||
{
|
||||
}
|
||||
|
||||
DECL_EXPORT void socketName()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
set(LAUNCHER ${CMAKE_HOME_DIRECTORY}/src/launcherlib)
|
||||
set(EBOOSTER ${CMAKE_HOME_DIRECTORY}/src/ebooster)
|
||||
set(COMMON "${CMAKE_HOME_DIRECTORY}/src/common")
|
||||
|
||||
# Set sources
|
||||
set(SRC ut_ebooster.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/booster.cpp
|
||||
${LAUNCHER}/connection.cpp
|
||||
${LAUNCHER}/logger.cpp ${EBOOSTER}/ebooster.cpp
|
||||
${LAUNCHER}/singleinstance.cpp ${LAUNCHER}/socketmanager.cpp)
|
||||
|
||||
# Set moc headers
|
||||
set(MOC_HDRS ut_ebooster.h)
|
||||
|
||||
# Run moc
|
||||
qt4_wrap_cpp(MOC_SRC ${MOC_HDRS})
|
||||
|
||||
# Enable test library
|
||||
set(QT_USE_QTTEST TRUE)
|
||||
|
||||
# Set include paths
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/src/common ${LAUNCHER} ${EBOOSTER})
|
||||
|
||||
link_libraries(${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY} ${X11_LIBRARIES} -ldl)
|
||||
|
||||
# Enable Qt (may not be needed, because already defined on higher level)
|
||||
include(${QT_USE_FILE})
|
||||
|
||||
add_executable(ut_ebooster ${SRC} ${MOC_SRC} )
|
||||
|
||||
# Install
|
||||
install(PROGRAMS ut_ebooster DESTINATION /usr/share/applauncherd-tests/)
|
||||
|
||||
@ -1,67 +0,0 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 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 "ut_ebooster.h"
|
||||
#include "ebooster.h"
|
||||
#include <errno.h>
|
||||
|
||||
Ut_EBooster::Ut_EBooster() :
|
||||
m_subject(new EBooster)
|
||||
{}
|
||||
|
||||
Ut_EBooster::~Ut_EBooster()
|
||||
{}
|
||||
|
||||
void Ut_EBooster::initTestCase()
|
||||
{}
|
||||
|
||||
void Ut_EBooster::cleanupTestCase()
|
||||
{}
|
||||
|
||||
void Ut_EBooster::testSocketName()
|
||||
{
|
||||
QVERIFY(EBooster::socketName() == EBooster::m_socketId);
|
||||
QVERIFY(m_subject->socketId() == EBooster::m_socketId);
|
||||
}
|
||||
|
||||
void Ut_EBooster::testType()
|
||||
{
|
||||
QVERIFY(EBooster::type() == 'e');
|
||||
QVERIFY(m_subject->boosterType() == 'e');
|
||||
}
|
||||
|
||||
void Ut_EBooster::testPreload()
|
||||
{
|
||||
QVERIFY(m_subject->preload());
|
||||
}
|
||||
|
||||
void Ut_EBooster::testTemporaryProcessName()
|
||||
{
|
||||
QVERIFY(EBooster::temporaryProcessName() == EBooster::m_temporaryProcessName);
|
||||
QVERIFY(m_subject->temporaryProcessName() == EBooster::m_temporaryProcessName);
|
||||
QVERIFY(m_subject->boosterTemporaryProcessName() == EBooster::m_temporaryProcessName);
|
||||
}
|
||||
|
||||
|
||||
void Ut_EBooster::testLaunchProcessWithBadArg()
|
||||
{
|
||||
QVERIFY(m_subject->launchProcess() == EXIT_FAILURE);
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(Ut_EBooster);
|
||||
@ -1,53 +0,0 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef UT_EBOOSTER_H
|
||||
#define UT_EBOOSTER_H
|
||||
|
||||
#include<QtTest/QtTest>
|
||||
#include<QObject>
|
||||
|
||||
#include <tr1/memory>
|
||||
|
||||
#define UNIT_TEST
|
||||
|
||||
class EBooster;
|
||||
|
||||
class Ut_EBooster : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Ut_EBooster();
|
||||
virtual ~Ut_EBooster();
|
||||
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
void testSocketName();
|
||||
void testType();
|
||||
void testPreload();
|
||||
void testTemporaryProcessName();
|
||||
void testLaunchProcessWithBadArg();
|
||||
|
||||
private:
|
||||
std::tr1::shared_ptr<EBooster> m_subject;
|
||||
};
|
||||
|
||||
#endif // UT_EBOOSTER_H
|
||||
Loading…
Reference in New Issue