mirror of https://github.com/cutefishos/appmotor
commit
4400a6f836
@ -1,36 +0,0 @@
|
||||
# Sub build: meego/testscripts
|
||||
add_subdirectory(meego/testscripts)
|
||||
|
||||
# Sub build: meego/art-tests
|
||||
add_subdirectory(meego/art-tests)
|
||||
|
||||
# Sub build: meego/bug-tests
|
||||
add_subdirectory(meego/bug-tests)
|
||||
|
||||
# Sub build: meego/functests
|
||||
add_subdirectory(meego/functests)
|
||||
|
||||
# Sub build: meego/perftests
|
||||
add_subdirectory(meego/perftests)
|
||||
|
||||
# Sub build: common/unittests
|
||||
add_subdirectory(common/unittests)
|
||||
|
||||
# Sub build: common/testapps/fala_status
|
||||
add_subdirectory(common/testapps/fala_status)
|
||||
|
||||
# Sub build: common/testapps/fala_wait
|
||||
add_subdirectory(common/testapps/fala_wait)
|
||||
|
||||
# Sub build: common/testapps/fala_gettime
|
||||
add_subdirectory(common/testapps/fala_gettime)
|
||||
|
||||
# Sub build: common/testapps/fala_gettime_ms
|
||||
add_subdirectory(common/testapps/fala_gettime_ms)
|
||||
|
||||
# Sub build: common/testapps/pixelchanged
|
||||
add_subdirectory(common/testapps/pixelchanged)
|
||||
|
||||
# Sub build: common/testapps/fala_windowid
|
||||
add_subdirectory(common/testapps/fala_windowid)
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
# Set sources
|
||||
set(SRC fala_gettime.c)
|
||||
|
||||
# Link statically not supported in meego.
|
||||
#set(CMAKE_EXE_LINKER_FLAGS "-static")
|
||||
|
||||
add_executable(fala_gettime ${SRC})
|
||||
|
||||
# Install
|
||||
install(PROGRAMS fala_gettime DESTINATION /usr/bin/)
|
||||
|
||||
@ -1,31 +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 <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
struct timeval tim;
|
||||
gettimeofday(&tim, NULL);
|
||||
printf("%d.%06d\n", (int)(tim.tv_sec), (int)(tim.tv_usec));
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
# Set sources
|
||||
set(SRC fala_gettime_ms.c)
|
||||
|
||||
# Link statically not supported in meego
|
||||
#set(CMAKE_EXE_LINKER_FLAGS "-static")
|
||||
|
||||
add_executable(fala_gettime_ms ${SRC})
|
||||
|
||||
# Install
|
||||
install(PROGRAMS fala_gettime_ms DESTINATION /usr/bin/)
|
||||
|
||||
@ -1,36 +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 <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
struct timeval tim;
|
||||
gettimeofday(&tim, NULL);
|
||||
if (argc > 0) {
|
||||
printf("%d%03d %s\n",
|
||||
(int)(tim.tv_sec), (int)(tim.tv_usec/1000), argv[1]);
|
||||
} else {
|
||||
printf("%d%03d\n", (int)(tim.tv_sec), (int)(tim.tv_usec/1000));
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1,8 +0,0 @@
|
||||
# Set sources
|
||||
set(SRC fala_status.cpp)
|
||||
|
||||
add_executable(fala_status ${SRC})
|
||||
|
||||
# Install
|
||||
install(PROGRAMS fala_status DESTINATION /usr/bin/ )
|
||||
|
||||
@ -1,33 +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 <iostream>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
int usr_id = getuid();
|
||||
int grp_id = getgid();
|
||||
|
||||
std::cerr << "uid=" << usr_id <<"\n";
|
||||
std::cerr << "gid=" << grp_id <<"\n";
|
||||
|
||||
usleep(5000);
|
||||
_exit(29);
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
# Set sources
|
||||
set(SRC fala_wait.cpp)
|
||||
|
||||
add_executable(fala_wait ${SRC})
|
||||
|
||||
# Install
|
||||
install(PROGRAMS fala_wait DESTINATION /usr/bin/ )
|
||||
|
||||
@ -1,27 +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 <iostream>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
sleep(6);
|
||||
return 0;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
# Set sources
|
||||
set(SRC main.cpp)
|
||||
|
||||
include(FindPkgConfig)
|
||||
pkg_check_modules(X11 x11 REQUIRED)
|
||||
include_directories(${X11_INCLUDE_DIRS})
|
||||
|
||||
link_libraries(${X11_LDFLAGS})
|
||||
add_executable(fala_windowid ${SRC})
|
||||
|
||||
# Install
|
||||
install(PROGRAMS fala_windowid DESTINATION /usr/bin/)
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
README
|
||||
======
|
||||
|
||||
This is a program that outputs id's of all X11 windows of given PID.
|
||||
|
||||
Example:
|
||||
|
||||
$ ./windowpid 1264
|
||||
|
||||
|
||||
-- Jussi Lind <jussi.lind@nokia.com>
|
||||
|
||||
@ -1,120 +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 <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <cstdlib>
|
||||
#include <exception>
|
||||
|
||||
using std::atoi;
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
#include <list>
|
||||
|
||||
using std::list;
|
||||
|
||||
class WindowsMatchingPid
|
||||
{
|
||||
public:
|
||||
|
||||
WindowsMatchingPid(Display *display, Window wRoot, unsigned long pid)
|
||||
: m_display(display)
|
||||
, m_pid(pid)
|
||||
{
|
||||
// Get the PID property atom.
|
||||
m_atomPID = XInternAtom(display, "_NET_WM_PID", False);
|
||||
search(wRoot);
|
||||
}
|
||||
|
||||
const list<Window> &result() const { return m_result; }
|
||||
|
||||
private:
|
||||
|
||||
Display *m_display;
|
||||
unsigned long m_pid;
|
||||
Atom m_atomPID;
|
||||
list<Window> m_result;
|
||||
|
||||
void search(Window w)
|
||||
{
|
||||
// Get the PID for the current Window.
|
||||
Atom type;
|
||||
int format;
|
||||
unsigned long nItems;
|
||||
unsigned long bytesAfter;
|
||||
unsigned char *propPID = 0;
|
||||
|
||||
if(Success == XGetWindowProperty(m_display, w, m_atomPID, 0, 1, False, XA_CARDINAL,
|
||||
&type, &format, &nItems, &bytesAfter, &propPID))
|
||||
{
|
||||
if(propPID != 0)
|
||||
{
|
||||
// If the PID matches, add this window to the result set.
|
||||
if(m_pid == *((unsigned long *)propPID))
|
||||
m_result.push_back(w);
|
||||
|
||||
XFree(propPID);
|
||||
}
|
||||
}
|
||||
|
||||
// Recurse into child windows.
|
||||
Window wRoot;
|
||||
Window wParent;
|
||||
Window *wChild;
|
||||
unsigned numChildren;
|
||||
|
||||
if(XQueryTree(m_display, w, &wRoot, &wParent, &wChild, &numChildren) != 0)
|
||||
{
|
||||
for(unsigned i = 0; i < numChildren; i++)
|
||||
search(wChild[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if(argc < 2) return EXIT_FAILURE;
|
||||
|
||||
try
|
||||
{
|
||||
const int pid = atoi(argv[1]);
|
||||
|
||||
// Start with the root window.
|
||||
Display *display = XOpenDisplay(0);
|
||||
|
||||
WindowsMatchingPid match(display, XDefaultRootWindow(display), pid);
|
||||
|
||||
// Print the resulting window id's
|
||||
const list<Window> &result = match.result();
|
||||
for(list<Window>::const_iterator it = result.begin(); it != result.end(); it++)
|
||||
cout << "0x" << std::hex << (unsigned long)(*it) << std::dec << endl;
|
||||
|
||||
}
|
||||
catch(std::exception& e)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
# Set sources
|
||||
set(SRC main.c)
|
||||
|
||||
include(FindPkgConfig)
|
||||
|
||||
# This is needed for MeeGo only?
|
||||
pkg_check_modules(XI xi REQUIRED)
|
||||
include_directories(${XI_INCLUDE_DIRS})
|
||||
|
||||
pkg_check_modules(X11 x11 REQUIRED)
|
||||
include_directories(${X11_INCLUDE_DIRS})
|
||||
|
||||
pkg_check_modules(XTST xtst REQUIRED)
|
||||
include_directories(${XTST_INCLUDE_DIRS})
|
||||
|
||||
link_libraries(${X11_LDFLAGS} ${XTST_LDFLAGS} ${XI_LDFLAGS})
|
||||
add_executable(fala_pixelchanged ${SRC})
|
||||
|
||||
# Install
|
||||
install(PROGRAMS fala_pixelchanged DESTINATION /usr/bin/)
|
||||
|
||||
@ -1,297 +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 <X11/Xlib.h>
|
||||
#include <X11/Xos.h>
|
||||
#include <X11/Xfuncs.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/XKBlib.h>
|
||||
#include <X11/Xproto.h>
|
||||
#include <X11/extensions/XTest.h>
|
||||
#include <X11/extensions/record.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
struct timeval g_prev_stamp;
|
||||
char g_output_filename[1024];
|
||||
|
||||
void timestamp(char *msg)
|
||||
{
|
||||
struct timeval tim;
|
||||
FILE *output_file;
|
||||
char txtbuffer[80];
|
||||
|
||||
gettimeofday(&tim, NULL);
|
||||
|
||||
snprintf(txtbuffer, 80, "%d%03d ms %s\n",
|
||||
(int)tim.tv_sec, (int)tim.tv_usec/1000,
|
||||
msg);
|
||||
|
||||
if (g_output_filename[0] == '\0') {
|
||||
printf("%s", txtbuffer);
|
||||
} else {
|
||||
if ((output_file = fopen(g_output_filename, "a+"))) {
|
||||
fprintf(output_file, "%s", txtbuffer);
|
||||
fclose(output_file);
|
||||
} else {
|
||||
fprintf(stderr, "pixelchanged: cannot open file '%s' for appending\n", g_output_filename);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum {
|
||||
SCHEDULER_EVENT_NONE = 0,
|
||||
SCHEDULER_EVENT_BUTTON,
|
||||
SCHEDULER_EVENT_KEY,
|
||||
SCHEDULER_EVENT_MOTION
|
||||
};
|
||||
|
||||
XDevice* XPointerDevice = NULL;
|
||||
|
||||
/*!
|
||||
* Simulates user input event.
|
||||
*
|
||||
* \param dpy[in] the display connection.
|
||||
* \param event[in] the event to simulate.
|
||||
*/
|
||||
void scheduler_fake_event(Display* dpy, int event_type, int event_param1, int event_param2)
|
||||
{
|
||||
static int xPos = 0;
|
||||
static int yPos = 0;
|
||||
|
||||
switch (event_type) {
|
||||
case SCHEDULER_EVENT_BUTTON: {
|
||||
int axis[2] = {xPos, yPos};
|
||||
XTestFakeDeviceButtonEvent(dpy, XPointerDevice, event_param1, event_param2, axis, 2, CurrentTime);
|
||||
break;
|
||||
}
|
||||
|
||||
case SCHEDULER_EVENT_KEY:
|
||||
XTestFakeDeviceKeyEvent(dpy, XPointerDevice, event_param1, event_param2, NULL, 0, CurrentTime );
|
||||
break;
|
||||
|
||||
case SCHEDULER_EVENT_MOTION:
|
||||
xPos = event_param1;
|
||||
yPos = event_param2;
|
||||
{
|
||||
int axis[2] = {xPos, yPos};
|
||||
XTestFakeDeviceMotionEvent(dpy, XPointerDevice, False, 0, axis, 2, CurrentTime);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! 'Fakes' a mouse click, returning time sent.
|
||||
void fake_event(Display *dpy, int x, int y)
|
||||
{
|
||||
if (XPointerDevice) {
|
||||
scheduler_fake_event(dpy, SCHEDULER_EVENT_MOTION, x, y);
|
||||
scheduler_fake_event(dpy, SCHEDULER_EVENT_BUTTON, Button1, True);
|
||||
XSync(dpy, False);
|
||||
usleep(200000);
|
||||
scheduler_fake_event(dpy, SCHEDULER_EVENT_BUTTON, Button1, False);
|
||||
timestamp("Button1 released");
|
||||
}
|
||||
}
|
||||
|
||||
//! This code is from "wmctrl" by Tomas Styblo <tripie@cpan.org>
|
||||
static int client_msg(Display *disp, Window win, char *msg, /* {{{ */
|
||||
unsigned long data0, unsigned long data1,
|
||||
unsigned long data2, unsigned long data3,
|
||||
unsigned long data4) {
|
||||
|
||||
XEvent event;
|
||||
long mask = SubstructureRedirectMask | SubstructureNotifyMask;
|
||||
|
||||
event.xclient.type = ClientMessage;
|
||||
event.xclient.serial = 0;
|
||||
event.xclient.send_event = True;
|
||||
event.xclient.message_type = XInternAtom(disp, msg, False);
|
||||
event.xclient.window = win;
|
||||
event.xclient.format = 32;
|
||||
event.xclient.data.l[0] = data0;
|
||||
event.xclient.data.l[1] = data1;
|
||||
event.xclient.data.l[2] = data2;
|
||||
event.xclient.data.l[3] = data3;
|
||||
event.xclient.data.l[4] = data4;
|
||||
|
||||
if (XSendEvent(disp, DefaultRootWindow(disp), False, mask, &event)) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Cannot send %s event.\n", msg);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}/*}}}*/
|
||||
|
||||
//! Raises the given window of given display.
|
||||
void raise_window(Display *dpy, Window win)
|
||||
{
|
||||
client_msg(dpy, win, "_NET_ACTIVE_WINDOW", 0, 0, 0, 0, 0);
|
||||
XSync(dpy, False);
|
||||
}
|
||||
|
||||
//! Main function.
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
Display *dpy;
|
||||
int screen = 0;
|
||||
Window rootw;
|
||||
char *DISPLAY = NULL;
|
||||
XDeviceInfo *devInfo;
|
||||
char txtbuffer[80];
|
||||
|
||||
int click_x = -1;
|
||||
int click_y = -1;
|
||||
unsigned long pixel_value = 0;
|
||||
int pixel_value_defined = False;
|
||||
int pixel_x = 423;
|
||||
int pixel_y = 240;
|
||||
int pixel2_x = -1;
|
||||
int pixel2_y = -1;
|
||||
int quit_when_found = 0;
|
||||
int window_id = 0;
|
||||
int count = 0;
|
||||
int i = 0;
|
||||
|
||||
int arg = 1;
|
||||
|
||||
g_output_filename[0] = '\0';
|
||||
|
||||
DISPLAY = (char*)getenv("DISPLAY");
|
||||
if (DISPLAY == NULL) {
|
||||
printf("Cannot open display. DISPLAY variable not set.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
dpy = XOpenDisplay(DISPLAY);
|
||||
screen = XDefaultScreen(dpy);
|
||||
rootw = RootWindow(dpy, screen);
|
||||
|
||||
i = 0;
|
||||
|
||||
while (arg < argc) {
|
||||
if (0 == strcmp("-c", argv[arg])) {
|
||||
// coverity[secure_coding]
|
||||
sscanf(argv[++arg], "%ux%u", &click_x, &click_y);
|
||||
} else if (0 == strcmp("-p", argv[arg])) {
|
||||
// coverity[secure_coding]
|
||||
sscanf(argv[++arg], "%lx", &pixel_value);
|
||||
pixel_value_defined = True;
|
||||
} else if (0 == strcmp("-r", argv[arg])) {
|
||||
// coverity[secure_coding]
|
||||
sscanf(argv[++arg], "%x", &window_id);
|
||||
raise_window(dpy, window_id);
|
||||
return EXIT_SUCCESS;
|
||||
} else if (0 == strcmp("-t", argv[arg])) { /* tracked pixel coordinates */
|
||||
if (i == 0) {
|
||||
// coverity[secure_coding]
|
||||
sscanf(argv[++arg], "%ux%u", &pixel_x, &pixel_y);
|
||||
} else {
|
||||
// coverity[secure_coding]
|
||||
sscanf(argv[++arg], "%ux%u", &pixel2_x, &pixel2_y);
|
||||
}
|
||||
i++;
|
||||
} else if (0 == strcmp("-f", argv[arg])) {
|
||||
// coverity[secure_coding]
|
||||
sscanf(argv[++arg], "%s", g_output_filename);
|
||||
} else if (0 == strcmp("-q", argv[arg])) {
|
||||
quit_when_found = 1;
|
||||
} else {
|
||||
fprintf(stderr, "Unrecognized option %s\n", argv[arg]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
++arg;
|
||||
}
|
||||
|
||||
|
||||
// open input device required for XTestFakeDeviceXXX functions
|
||||
if (!(devInfo = XListInputDevices(dpy, &count)) || !count) {
|
||||
fprintf(stderr, "Cannot input list devices\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// find out where's the mouse
|
||||
for (i = 0; i < count; i++) {
|
||||
if ( devInfo[i].use == IsXExtensionPointer) {
|
||||
XPointerDevice = XOpenDevice(dpy, devInfo[i].id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
XImage *image;
|
||||
unsigned long pixel = 0, pixel2 = 0;
|
||||
unsigned long previous_pixel = 0, previous_pixel2 = 0;
|
||||
|
||||
image = XGetImage(dpy, rootw, pixel_x, pixel_y, 1, 1, AllPlanes, ZPixmap);
|
||||
previous_pixel = XGetPixel(image, 0, 0);
|
||||
|
||||
if (pixel2_x != -1) {
|
||||
image = XGetImage(dpy, rootw, pixel2_x, pixel2_y, 1, 1, AllPlanes, ZPixmap);
|
||||
previous_pixel2 = XGetPixel(image, 0, 0);
|
||||
}
|
||||
|
||||
if (click_x > -1) fake_event(dpy, click_x, click_y);
|
||||
|
||||
int repeat = 1;
|
||||
while (repeat) {
|
||||
//usleep(50000);
|
||||
usleep(5000);
|
||||
|
||||
image = XGetImage(dpy, rootw, pixel_x, pixel_y, 1, 1, AllPlanes, ZPixmap);
|
||||
pixel = XGetPixel(image, 0, 0);
|
||||
|
||||
if (pixel2_x != -1) {
|
||||
image = XGetImage(dpy, rootw, pixel2_x, pixel2_y, 1, 1, AllPlanes, ZPixmap);
|
||||
pixel2 = XGetPixel(image, 0, 0);
|
||||
}
|
||||
|
||||
if (
|
||||
(!pixel_value_defined && pixel != previous_pixel)
|
||||
|| (pixel_value_defined && pixel == pixel_value) ) {
|
||||
snprintf(txtbuffer, 80, "pixel changed to value 0x%lx", pixel);
|
||||
timestamp(txtbuffer);
|
||||
previous_pixel = pixel;
|
||||
|
||||
if (quit_when_found)
|
||||
repeat = 0;
|
||||
}
|
||||
|
||||
if (
|
||||
pixel2_x != -1 &&
|
||||
((!pixel_value_defined && pixel2 != previous_pixel2)
|
||||
|| (pixel_value_defined && pixel2 == pixel_value)) ) {
|
||||
snprintf(txtbuffer, 80, "pixel2 changed to value 0x%lx", pixel2);
|
||||
timestamp(txtbuffer);
|
||||
previous_pixel2 = pixel2;
|
||||
|
||||
if (quit_when_found)
|
||||
repeat = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
# Find Qt4
|
||||
find_package(Qt4 4.6.0 REQUIRED)
|
||||
include(${QT_USE_FILE})
|
||||
if (${QTVERSION} VERSION_LESS 4.6.0)
|
||||
message(FATAL_ERROR "You need Qt4.6, found ${QTVERSION}.")
|
||||
endif (${QTVERSION} VERSION_LESS 4.6.0)
|
||||
|
||||
add_subdirectory(ut_booster)
|
||||
add_subdirectory(ut_connection)
|
||||
add_subdirectory(ut_daemon)
|
||||
add_subdirectory(ut_socketmanager)
|
||||
add_subdirectory(ut_singleinstance)
|
||||
add_subdirectory(ut_appdata)
|
||||
add_subdirectory(ut_logger)
|
||||
|
||||
install(FILES tests.xml DESTINATION /usr/share/applauncherd-tests)
|
||||
|
||||
@ -1,80 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<testdefinition version="0.1">
|
||||
|
||||
<!-- Test suite, name mandatory - the same as test package name -->
|
||||
<!-- Schema: https://projects.maemo.org/docs/testing/xml-definition.html -->
|
||||
<suite name="applauncherd-tests" domain="Application framework">
|
||||
|
||||
<set name="launcher-tests" description="Basic launcher unit tests" feature="AF Basic Launcher daemon support" requirement="300168" >
|
||||
|
||||
<case name="Daemon" type="Functional" description="Unit tests for Daemon class" level="Component" timeout="20">
|
||||
<step expected_result="0">/usr/share/applauncherd-tests/ut_daemon</step>
|
||||
</case>
|
||||
|
||||
<case name="Connection" type="Functional" description="Unit tests for Connection class" level="Component" timeout="20">
|
||||
<step expected_result="0">/usr/share/applauncherd-tests/ut_connection</step>
|
||||
</case>
|
||||
|
||||
<case name="SocketManager" type="Functional" description="Unit tests for SocketManager class" level="Component" timeout="20">
|
||||
<step expected_result="0">/usr/share/applauncherd-tests/ut_socketmanager</step>
|
||||
</case>
|
||||
|
||||
<environments>
|
||||
<scratchbox>true</scratchbox>
|
||||
<hardware>true</hardware>
|
||||
</environments>
|
||||
|
||||
<!--get>
|
||||
</get-->
|
||||
</set>
|
||||
|
||||
<set name="booster-tests" description="Booster unit tests" feature="AF MBooster for Launcher daemon" requirement="300195" >
|
||||
|
||||
<case name="Booster" type="Functional" description="Unit tests for Booster class" level="Component" timeout="20">
|
||||
<step expected_result="0">/usr/share/applauncherd-tests/ut_booster</step>
|
||||
</case>
|
||||
|
||||
<environments>
|
||||
<scratchbox>true</scratchbox>
|
||||
<hardware>true</hardware>
|
||||
</environments>
|
||||
|
||||
<!--get>
|
||||
</get-->
|
||||
</set>
|
||||
|
||||
<set name="singleinstance-test" description="Singleinstance unit tests" feature="AF Singleinstance for Launcher daemon" requirement="1131430" >
|
||||
|
||||
<case name="Singleinstance" type="Functional" description="Unit tests for Singleinstance class" level="Component" timeout="20">
|
||||
<step expected_result="0">su - user -c 'source /tmp/session_bus_address.user && DISPLAY=:0 /usr/share/applauncherd-tests/ut_singleinstance'</step>
|
||||
</case>
|
||||
|
||||
<environments>
|
||||
<scratchbox>true</scratchbox>
|
||||
<hardware>true</hardware>
|
||||
</environments>
|
||||
|
||||
<!--get>
|
||||
</get-->
|
||||
</set>
|
||||
|
||||
<set name="logger-test" description="Logger unit tests" feature="AF Logger for Launcher daemon" requirement="1131430" >
|
||||
|
||||
<case name="Logger" type="Functional" description="Unit tests for Logger class" level="Component" timeout="20">
|
||||
<step expected_result="0">su - user -c 'source /tmp/session_bus_address.user && DISPLAY=:0 /usr/share/applauncherd-tests/ut_logger'</step>
|
||||
</case>
|
||||
|
||||
<environments>
|
||||
<scratchbox>true</scratchbox>
|
||||
<hardware>true</hardware>
|
||||
</environments>
|
||||
|
||||
<!--get>
|
||||
</get-->
|
||||
</set>
|
||||
|
||||
|
||||
</suite>
|
||||
</testdefinition>
|
||||
|
||||
|
||||
@ -1,32 +0,0 @@
|
||||
set(LAUNCHER ${CMAKE_HOME_DIRECTORY}/src/launcherlib)
|
||||
set(PROTOCOL ${CMAKE_HOME_DIRECTORY}/src/common)
|
||||
set(DESTINATION "/usr/share/applauncherd-tests/")
|
||||
|
||||
|
||||
# Set sources
|
||||
set(SRC ut_appdata.cpp ${LAUNCHER}/appdata.cpp)
|
||||
|
||||
# Set moc headers
|
||||
set(MOC_HDRS ut_appdata.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} ${PROTOCOL})
|
||||
|
||||
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_appdata ${SRC} ${MOC_SRC} )
|
||||
|
||||
|
||||
|
||||
# Install
|
||||
install(PROGRAMS ut_appdata DESTINATION ${DESTINATION})
|
||||
|
||||
@ -1,50 +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_appdata.h"
|
||||
#include "appdata.h"
|
||||
|
||||
|
||||
Ut_AppData::Ut_AppData()
|
||||
|
||||
{}
|
||||
|
||||
Ut_AppData::~Ut_AppData()
|
||||
{}
|
||||
|
||||
void Ut_AppData::initTestCase()
|
||||
{}
|
||||
|
||||
void Ut_AppData::cleanupTestCase()
|
||||
{}
|
||||
|
||||
void Ut_AppData::testEntry()
|
||||
{
|
||||
AppData * appData = new AppData();
|
||||
QVERIFY(appData);
|
||||
entry_t newEntry = (entry_t)(new int(1));
|
||||
appData->setEntry(newEntry);
|
||||
entry_t checkEntry = appData->entry();
|
||||
QVERIFY(checkEntry == newEntry);
|
||||
delete appData;
|
||||
appData = NULL;
|
||||
}
|
||||
|
||||
|
||||
QTEST_APPLESS_MAIN(Ut_AppData);
|
||||
@ -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_APPDATA_H
|
||||
#define UT_APPDATA_H
|
||||
|
||||
#include<QtTest/QtTest>
|
||||
#include<QObject>
|
||||
|
||||
|
||||
|
||||
#define UNIT_TEST
|
||||
|
||||
class Ut_AppData : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Ut_AppData();
|
||||
virtual ~Ut_AppData();
|
||||
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
void testEntry();
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // UT_APPDATA_H
|
||||
@ -1,28 +0,0 @@
|
||||
set(LAUNCHER ${CMAKE_HOME_DIRECTORY}/src/launcherlib)
|
||||
|
||||
# Set sources
|
||||
set(SRC ut_booster.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/booster.cpp ${LAUNCHER}/connection.cpp
|
||||
${LAUNCHER}/logger.cpp ${LAUNCHER}/singleinstance.cpp ${LAUNCHER}/socketmanager.cpp)
|
||||
|
||||
# Set moc headers
|
||||
set(MOC_HDRS ut_booster.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})
|
||||
|
||||
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_booster ${SRC} ${MOC_SRC})
|
||||
|
||||
# Install
|
||||
install(PROGRAMS ut_booster DESTINATION /usr/share/applauncherd-tests/)
|
||||
|
||||
@ -1,183 +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 "ut_booster.h"
|
||||
#include "booster.h"
|
||||
#include <stdexcept>
|
||||
#include <QString>
|
||||
|
||||
// Booster is an abstract base-class, so let's inherit it and
|
||||
// define methods that are pure virtual
|
||||
class MyBooster : public Booster
|
||||
{
|
||||
public:
|
||||
MyBooster();
|
||||
const std::string & boosterType() const;
|
||||
|
||||
protected:
|
||||
bool preload();
|
||||
|
||||
private:
|
||||
const string m_boosterType;
|
||||
};
|
||||
|
||||
MyBooster::MyBooster() :
|
||||
m_boosterType("TestBooster")
|
||||
{}
|
||||
|
||||
const std::string & MyBooster::boosterType() const
|
||||
{
|
||||
return m_boosterType;
|
||||
}
|
||||
|
||||
bool MyBooster::preload()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void Ut_Booster::initTestCase()
|
||||
{}
|
||||
|
||||
void Ut_Booster::cleanupTestCase()
|
||||
{}
|
||||
|
||||
char ** Ut_Booster::packTwoArgs(const char * arg0, const char * arg1)
|
||||
{
|
||||
char ** argv = new char * [2];
|
||||
char * result = new char[strlen(arg0) + strlen(arg1) + 2];
|
||||
memset(result, '\0', strlen(arg0) + strlen(arg1) + 2);
|
||||
|
||||
strcat(result, arg0);
|
||||
strcat(result, " ");
|
||||
strcat(result, arg1);
|
||||
|
||||
// Arguments are allocated consecutively in Linux
|
||||
argv[0] = result;
|
||||
argv[1] = argv[0] + strlen(arg0) + 1;
|
||||
argv[0][strlen(arg0)] = '\0';
|
||||
|
||||
return argv;
|
||||
}
|
||||
|
||||
void Ut_Booster::testRenameProcess()
|
||||
{
|
||||
m_subject.reset(new MyBooster);
|
||||
|
||||
// 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
|
||||
const int INIT_ARGC = 2;
|
||||
char ** initialArgv = packTwoArgs("oldName", " ");
|
||||
|
||||
// Rename process
|
||||
const char * tempArgv[] = {"test booster"};
|
||||
m_subject->renameProcess(INIT_ARGC, initialArgv, 1, tempArgv);
|
||||
|
||||
// Check that new name and arguments fit and are correct
|
||||
QVERIFY(strcmp(initialArgv[0], "test booster") == 0);
|
||||
|
||||
// Define and copy args because it's assumed that they are allocated in the heap
|
||||
// (AppData deletes the argv on exit)
|
||||
const int ARGC = 3;
|
||||
m_subject->appData()->setArgc(ARGC);
|
||||
|
||||
char ** argv = new char * [ARGC];
|
||||
argv[0] = strdup("newName");
|
||||
argv[1] = strdup("--foo");
|
||||
argv[2] = strdup("--bar");
|
||||
m_subject->appData()->setArgv(const_cast<const char **>(argv));
|
||||
m_subject->renameProcess(INIT_ARGC, initialArgv, ARGC, const_cast<const char **>(argv));
|
||||
|
||||
// New name and arguments fit and are correct
|
||||
const char * result = "newName\0--foo\0--bar\0";
|
||||
QVERIFY2(memcmp(initialArgv[0], result, 20) == 0, initialArgv[0]);
|
||||
|
||||
delete initialArgv[0];
|
||||
delete [] initialArgv;
|
||||
}
|
||||
|
||||
void Ut_Booster::testRenameProcessNotEnoughSpace()
|
||||
{
|
||||
m_subject.reset(new MyBooster);
|
||||
|
||||
const int NEW_ARGC = 3;
|
||||
m_subject->appData()->setArgc(NEW_ARGC);
|
||||
char ** argv = new char * [NEW_ARGC];
|
||||
argv[0] = strdup("newNameLong");
|
||||
argv[1] = strdup("--foo");
|
||||
argv[2] = strdup("--bar");
|
||||
m_subject->appData()->setArgv(const_cast<const char **>(argv));
|
||||
|
||||
const int INIT_ARGC = 2;
|
||||
char ** initialArgv = packTwoArgs("old0123", "");
|
||||
int initLen = strlen(initialArgv[0]) + 1 + strlen("");
|
||||
m_subject->renameProcess(INIT_ARGC, initialArgv,
|
||||
m_subject->appData()->argc(), m_subject->appData()->argv());
|
||||
|
||||
// Not enough space for the new name nor the arguments:
|
||||
// name should be cut
|
||||
QVERIFY(memcmp(initialArgv[0], m_subject->appData()->argv()[0], initLen) == 0);
|
||||
QVERIFY(initialArgv[0][initLen] == '\0');
|
||||
QVERIFY(initialArgv[0][initLen - 1] == 'L');
|
||||
}
|
||||
|
||||
void Ut_Booster::testBoosterLauncherSocket()
|
||||
{
|
||||
int testValue = 11;
|
||||
m_subject->setBoosterLauncherSocket(testValue);
|
||||
int resultValue = m_subject->boosterLauncherSocket();
|
||||
QVERIFY(resultValue == testValue);
|
||||
}
|
||||
|
||||
void Ut_Booster::testLoadMain()
|
||||
{
|
||||
|
||||
m_subject->appData()->setFileName("/no/such/file");
|
||||
bool exceptionTriggered = false;
|
||||
QString exceptionDetails;
|
||||
try{
|
||||
m_subject->loadMain();
|
||||
}
|
||||
catch (std::runtime_error & e)
|
||||
{
|
||||
exceptionTriggered = true;
|
||||
exceptionDetails = e.what();
|
||||
}
|
||||
|
||||
QVERIFY(exceptionTriggered == true);
|
||||
QVERIFY(exceptionDetails.contains("Booster: Loading invoked application failed:", Qt::CaseInsensitive) == true);
|
||||
|
||||
m_subject->appData()->setFileName("/usr/share/applauncherd-tests/libutplugin.so");
|
||||
|
||||
exceptionTriggered = false;
|
||||
exceptionDetails = "";
|
||||
try{
|
||||
m_subject->loadMain();
|
||||
}
|
||||
catch (std::runtime_error & e)
|
||||
{
|
||||
exceptionTriggered = true;
|
||||
exceptionDetails = e.what();
|
||||
}
|
||||
|
||||
QVERIFY(exceptionTriggered == true);
|
||||
QVERIFY(exceptionDetails.contains("Booster: Loading symbol 'main' failed:", Qt::CaseInsensitive) == true) ;
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(Ut_Booster);
|
||||
|
||||
@ -1,50 +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 UT_BOOSTER_H
|
||||
#define UT_BOOSTER_H
|
||||
|
||||
#include<QtTest/QtTest>
|
||||
#include<QObject>
|
||||
|
||||
#include <tr1/memory>
|
||||
|
||||
#define UNIT_TEST
|
||||
|
||||
class Booster;
|
||||
|
||||
class Ut_Booster : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void testRenameProcess();
|
||||
void testRenameProcessNotEnoughSpace();
|
||||
void testBoosterLauncherSocket();
|
||||
void testLoadMain();
|
||||
void cleanupTestCase();
|
||||
|
||||
private:
|
||||
|
||||
char ** packTwoArgs(const char * arg0, const char * arg1);
|
||||
std::tr1::shared_ptr<Booster> m_subject;
|
||||
};
|
||||
|
||||
#endif // UT_BOOSTER_H
|
||||
@ -1,30 +0,0 @@
|
||||
set(LAUNCHER ${CMAKE_HOME_DIRECTORY}/src/launcherlib)
|
||||
|
||||
# Set sources
|
||||
set(SRC ut_connection.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/booster.cpp
|
||||
${LAUNCHER}/daemon.cpp ${LAUNCHER}/connection.cpp ${LAUNCHER}/logger.cpp
|
||||
${LAUNCHER}/singleinstance.cpp ${LAUNCHER}/socketmanager.cpp)
|
||||
|
||||
# Set moc headers
|
||||
set(MOC_HDRS ut_connection.h)
|
||||
|
||||
# Set the program name define used in daemon.cpp
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPROG_NAME_LAUNCHER=\\\"applauncherd\\\"")
|
||||
|
||||
# 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})
|
||||
link_libraries(${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY} ${X11_LIBRARIES} -ldl "-L/lib -lsystemd-daemon")
|
||||
|
||||
# Enable Qt (may not be needed, because already defined on higher level)
|
||||
include(${QT_USE_FILE})
|
||||
add_executable(ut_connection ${SRC} ${MOC_SRC})
|
||||
|
||||
# Install
|
||||
install(PROGRAMS ut_connection DESTINATION /usr/share/applauncherd-tests/)
|
||||
|
||||
@ -1,190 +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 "ut_connection.h"
|
||||
#include "connection.h"
|
||||
#include "socketmanager.h"
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <errno.h>
|
||||
#include <stdexcept>
|
||||
|
||||
static const QString syslogFile = "/var/log/syslog";
|
||||
static const int delay = 1000;
|
||||
|
||||
// Redefine some methods for Connection class
|
||||
class MyConnection : public Connection
|
||||
{
|
||||
public:
|
||||
int nextMsg;
|
||||
char* nextStr;
|
||||
|
||||
MyConnection(int socketFd, bool testMode);
|
||||
|
||||
private:
|
||||
bool recvMsg(uint32_t *msg);
|
||||
const char* recvStr();
|
||||
};
|
||||
|
||||
MyConnection::MyConnection(int socketFd, bool testMode) :
|
||||
Connection(socketFd, testMode),
|
||||
nextMsg(0),
|
||||
nextStr(NULL)
|
||||
{}
|
||||
|
||||
bool MyConnection::recvMsg(uint32_t *msg)
|
||||
{
|
||||
*msg = nextMsg;
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* MyConnection::recvStr()
|
||||
{
|
||||
return nextStr;
|
||||
}
|
||||
|
||||
Ut_Connection::Ut_Connection()
|
||||
{}
|
||||
|
||||
Ut_Connection::~Ut_Connection()
|
||||
{}
|
||||
|
||||
void Ut_Connection::initTestCase()
|
||||
{}
|
||||
|
||||
void Ut_Connection::cleanupTestCase()
|
||||
{}
|
||||
|
||||
/*
|
||||
* Test that socket creation / closing works.
|
||||
*/
|
||||
void Ut_Connection::testSocket()
|
||||
{
|
||||
const char* socketName = "testAccept";
|
||||
SocketManager sm;
|
||||
|
||||
sm.initSocket(socketName);
|
||||
m_subject.reset(new MyConnection(sm.findSocket(socketName), false));
|
||||
m_subject->m_fd = 1000;
|
||||
|
||||
QVERIFY(m_subject->m_fd > 0);
|
||||
|
||||
m_subject->close();
|
||||
QVERIFY(m_subject->m_fd == -1);
|
||||
|
||||
unlink(socketName);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check that env variable passed from invoker will
|
||||
* be set in launcher process.
|
||||
*
|
||||
* Run in the test mode (no sockets really created).
|
||||
*/
|
||||
void Ut_Connection::testGetEnv()
|
||||
{
|
||||
QVERIFY(getenv("MY_TEST_ENV_VAR") == NULL);
|
||||
QVERIFY(getenv("PATH") != NULL);
|
||||
|
||||
const int socketFd = 0;
|
||||
m_subject.reset(new MyConnection(socketFd, true));
|
||||
|
||||
char* envVar = strdup("MY_TEST_ENV_VAR=3");
|
||||
|
||||
m_subject->nextMsg = 1;
|
||||
m_subject->nextStr = envVar;
|
||||
|
||||
QVERIFY(m_subject->receiveEnv() == true);
|
||||
QVERIFY(getenv("MY_TEST_ENV_VAR") != NULL);
|
||||
QVERIFY(getenv("PATH") != NULL);
|
||||
|
||||
delete envVar;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check getAppName() function correctness
|
||||
*
|
||||
* Run in the test mode (no sockets really created).
|
||||
*/
|
||||
void Ut_Connection::testGetAppName()
|
||||
{
|
||||
const int socketFd = 0;
|
||||
m_subject.reset(new MyConnection(socketFd, true));
|
||||
|
||||
// Wrong type of message
|
||||
m_subject->nextMsg = INVOKER_MSG_EXEC;
|
||||
string wrongStr = m_subject->receiveAppName();
|
||||
QVERIFY(wrongStr.empty());
|
||||
|
||||
// Empty app name
|
||||
m_subject->nextMsg = INVOKER_MSG_NAME;
|
||||
m_subject->nextStr = NULL;
|
||||
string emptyName = m_subject->receiveAppName();
|
||||
QVERIFY(emptyName.empty());
|
||||
|
||||
// Real name
|
||||
string realName("looooongApplicationName");
|
||||
char* dupName = strdup(realName.c_str());
|
||||
|
||||
m_subject->nextMsg = INVOKER_MSG_NAME;
|
||||
m_subject->nextStr = dupName;
|
||||
|
||||
string resName = m_subject->receiveAppName();
|
||||
QVERIFY(!resName.empty());
|
||||
QVERIFY(resName.compare(realName) == 0);
|
||||
}
|
||||
|
||||
void Ut_Connection::testConnection()
|
||||
{
|
||||
//negative testcase for wrong socket
|
||||
bool exceptionTriggered = false;
|
||||
QString exceptionDetails;
|
||||
Connection * cn = NULL;
|
||||
try {
|
||||
cn = new Connection(-1);
|
||||
}catch (std::runtime_error & e) {
|
||||
exceptionTriggered = true;
|
||||
exceptionDetails = e.what();
|
||||
}
|
||||
if (cn)
|
||||
delete cn;
|
||||
QCOMPARE(exceptionTriggered, true);
|
||||
QVERIFY(exceptionDetails.compare("Connection: Socket isn't initialized!\n") == 0);
|
||||
}
|
||||
|
||||
void Ut_Connection::testReceiveArgs()
|
||||
{
|
||||
m_subject.reset(new MyConnection(0, true));
|
||||
//positive testcase
|
||||
m_subject->nextMsg = 1;
|
||||
char testValue[] = "test";
|
||||
m_subject->nextStr = testValue;
|
||||
QVERIFY(m_subject->receiveArgs() == true);
|
||||
|
||||
//negative testcase with zero number of args
|
||||
m_subject->nextMsg = 0;
|
||||
QVERIFY(m_subject->receiveArgs() == false);
|
||||
|
||||
//negative testcase with null arg pointer
|
||||
m_subject->nextMsg = 1;
|
||||
m_subject->nextStr = NULL;
|
||||
QVERIFY(m_subject->receiveArgs() == false);
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(Ut_Connection);
|
||||
@ -1,54 +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 UT_CONNECTION_H
|
||||
#define UT_CONNECTION_H
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <QObject>
|
||||
#include <tr1/memory>
|
||||
|
||||
#define UNIT_TEST
|
||||
|
||||
class Connection;
|
||||
class MyConnection;
|
||||
|
||||
class Ut_Connection : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Ut_Connection();
|
||||
~Ut_Connection();
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
void testSocket();
|
||||
void testGetEnv();
|
||||
void testGetAppName();
|
||||
void testConnection();
|
||||
void testReceiveArgs();
|
||||
|
||||
private:
|
||||
std::tr1::shared_ptr<MyConnection> m_subject;
|
||||
};
|
||||
|
||||
#endif // UT_CONNECTION_H
|
||||
@ -1,31 +0,0 @@
|
||||
# Set sources
|
||||
set(LAUNCHER ${CMAKE_HOME_DIRECTORY}/src/launcherlib)
|
||||
set(COMMON "${CMAKE_HOME_DIRECTORY}/src/common")
|
||||
|
||||
set(SRC ut_daemon.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/booster.cpp ${LAUNCHER}/daemon.cpp
|
||||
${LAUNCHER}/connection.cpp ${LAUNCHER}/logger.cpp
|
||||
${LAUNCHER}/singleinstance.cpp ${LAUNCHER}/socketmanager.cpp)
|
||||
|
||||
# Set moc headers
|
||||
set(MOC_HDRS ut_daemon.h)
|
||||
|
||||
# Set the program name define used in daemon.cpp
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPROG_NAME_LAUNCHER=\\\"applauncherd\\\"")
|
||||
|
||||
# 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})
|
||||
link_libraries(${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY} ${X11_LIBRARIES} -ldl "-L/lib -lsystemd-daemon")
|
||||
|
||||
# Enable Qt (may not be needed, because already defined on higher level)
|
||||
include(${QT_USE_FILE})
|
||||
add_executable(ut_daemon ${SRC} ${MOC_SRC})
|
||||
|
||||
# Install
|
||||
install(PROGRAMS ut_daemon DESTINATION /usr/share/applauncherd-tests/)
|
||||
|
||||
@ -1,126 +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 "ut_daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
Ut_Daemon::Ut_Daemon()
|
||||
{
|
||||
int argc = 2;
|
||||
char **argv = new char * [argc];
|
||||
argv[0] = strdup("app");
|
||||
argv[1] = strdup("--boot-mode");
|
||||
|
||||
m_subject.reset(new Daemon( argc, argv ));
|
||||
}
|
||||
|
||||
Ut_Daemon::~Ut_Daemon()
|
||||
{}
|
||||
|
||||
void Ut_Daemon::initTestCase()
|
||||
{}
|
||||
|
||||
void Ut_Daemon::cleanupTestCase()
|
||||
{}
|
||||
|
||||
void Ut_Daemon::testInitialArguments()
|
||||
{
|
||||
|
||||
QVERIFY(m_subject->m_initialArgc == 2);
|
||||
|
||||
QCOMPARE(m_subject->m_initialArgv[0], "app");
|
||||
QCOMPARE(m_subject->m_initialArgv[1], "--boot-mode");
|
||||
|
||||
}
|
||||
|
||||
void Ut_Daemon::testParseArgs()
|
||||
{
|
||||
int argc = 2;
|
||||
char **argv = new char * [argc];
|
||||
|
||||
argv[0] = strdup("app");
|
||||
argv[1] = strdup("--daemon");
|
||||
|
||||
QVERIFY(m_subject->m_daemon == false);
|
||||
|
||||
m_subject->parseArgs(vector<string>(argv, argv + argc));
|
||||
|
||||
QVERIFY(m_subject->m_daemon == true);
|
||||
|
||||
delete argv[0];
|
||||
delete argv[1];
|
||||
delete [] argv;
|
||||
}
|
||||
|
||||
void Ut_Daemon::testVerifyInstance()
|
||||
{
|
||||
QVERIFY(m_subject.get() == Daemon::instance());
|
||||
}
|
||||
|
||||
void Ut_Daemon::testReapZombies()
|
||||
{
|
||||
QVERIFY(m_subject->m_children.size() == 0);
|
||||
|
||||
for (int i = 1; i < 10; i++) {
|
||||
m_subject->m_children.push_back(i);
|
||||
}
|
||||
|
||||
m_subject->reapZombies();
|
||||
|
||||
QVERIFY(m_subject->m_children.size() == 0);
|
||||
}
|
||||
|
||||
void Ut_Daemon::testForkBooster()
|
||||
{
|
||||
//negative testcase for unregistered booster type '0'
|
||||
pid_t pid = fork();
|
||||
if (pid == 0) { // child
|
||||
// Code only executed by child process
|
||||
m_subject->forkBooster();
|
||||
QFAIL("Not exited on invalid booster type");
|
||||
_exit(0); //exit from child if something goes wrong
|
||||
} else if (pid < 0) { // failed to fork
|
||||
QFAIL("Unable to fork for test _exit");
|
||||
} else { //parent only
|
||||
QTest::qSleep(1000);
|
||||
int resultCode = QProcess::execute("grep",QStringList() << "Daemon: Unknown booster type '0'" << "/var/log/syslog");
|
||||
QVERIFY(resultCode == 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Ut_Daemon::testReadFromBoosterSocket()
|
||||
{
|
||||
//negative testcase reads from invalid socket
|
||||
pid_t pid = fork();
|
||||
if (pid == 0) { // child
|
||||
// Code only executed by child process
|
||||
m_subject->readFromBoosterSocket(-1);
|
||||
QFAIL("Not exited on invalid socket");
|
||||
_exit(0); //exit from child if something goes wrong
|
||||
} else if (pid < 0) { // failed to fork
|
||||
QFAIL("Unable to fork for test _exit");
|
||||
} else { //parent only
|
||||
QTest::qSleep(1000);
|
||||
int resultCode = QProcess::execute("grep",QStringList() << "Daemon: Nothing read from the socket" << "/var/log/syslog");
|
||||
QVERIFY(resultCode == 0);
|
||||
}
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(Ut_Daemon)
|
||||
@ -1,54 +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 UT_DAEMON_H
|
||||
#define UT_DAEMON_H
|
||||
|
||||
#include<QtTest/QtTest>
|
||||
#include<QObject>
|
||||
|
||||
#include <tr1/memory>
|
||||
|
||||
#define UNIT_TEST
|
||||
|
||||
class Daemon;
|
||||
|
||||
class Ut_Daemon : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Ut_Daemon();
|
||||
~Ut_Daemon();
|
||||
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
void testInitialArguments();
|
||||
void testParseArgs();
|
||||
void testVerifyInstance();
|
||||
void testReapZombies();
|
||||
void testForkBooster();
|
||||
void testReadFromBoosterSocket();
|
||||
|
||||
private:
|
||||
std::tr1::shared_ptr<Daemon> m_subject;
|
||||
};
|
||||
|
||||
#endif // UT_DAEMON_H
|
||||
@ -1,29 +0,0 @@
|
||||
set(LAUNCHER ${CMAKE_HOME_DIRECTORY}/src/launcherlib)
|
||||
set(COMMON ${CMAKE_HOME_DIRECTORY}/src/common)
|
||||
set(DESTINATION "/usr/share/applauncherd-tests/")
|
||||
|
||||
# Set sources
|
||||
set(SRC ut_logger.cpp ${LAUNCHER}/logger.cpp)
|
||||
|
||||
# Set moc headers
|
||||
set(MOC_HDRS ut_logger.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} ${COMMON})
|
||||
|
||||
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_logger ${SRC} ${MOC_SRC})
|
||||
|
||||
# Install
|
||||
install(PROGRAMS ut_logger DESTINATION ${DESTINATION})
|
||||
|
||||
@ -1,133 +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 <QString>
|
||||
#include <QProcess>
|
||||
#include <QDateTime>
|
||||
#include <QtGlobal>
|
||||
#include <sys/syslog.h>
|
||||
|
||||
#include "ut_logger.h"
|
||||
#include "logger.h"
|
||||
|
||||
static const QString syslogFile = "/var/log/syslog";
|
||||
static const char * progName = "Ut_Logger";
|
||||
static const int delay = 1000;
|
||||
|
||||
Ut_Logger::Ut_Logger() :
|
||||
m_subject(new Logger)
|
||||
{}
|
||||
|
||||
Ut_Logger::~Ut_Logger()
|
||||
{}
|
||||
|
||||
void Ut_Logger::initTestCase()
|
||||
{
|
||||
qsrand(QDateTime::currentMSecsSinceEpoch());
|
||||
}
|
||||
|
||||
void Ut_Logger::cleanupTestCase()
|
||||
{}
|
||||
|
||||
void Ut_Logger::testOpenLog() {
|
||||
QVERIFY(m_subject->m_isOpened == false);
|
||||
Logger::openLog(progName);
|
||||
QVERIFY(m_subject->m_isOpened == true);
|
||||
}
|
||||
|
||||
void Ut_Logger::testSetDebugMode() {
|
||||
QVERIFY(m_subject->m_debugMode == false);
|
||||
Logger::setDebugMode(true);
|
||||
QVERIFY(m_subject->m_debugMode == true);
|
||||
}
|
||||
|
||||
|
||||
void Ut_Logger::testLogDebug() {
|
||||
//case with debug mode on
|
||||
Logger::setDebugMode(true);
|
||||
_setTestPhrase(Q_FUNC_INFO);
|
||||
Logger::logDebug(m_testPhrase);
|
||||
QTest::qSleep(delay);
|
||||
QVERIFY(_findPhraseInSyslog() == true);
|
||||
|
||||
//case with debug mode off
|
||||
Logger::setDebugMode(false);
|
||||
_setTestPhrase(Q_FUNC_INFO);
|
||||
Logger::logDebug(m_testPhrase);
|
||||
QTest::qSleep(delay);
|
||||
QVERIFY(_findPhraseInSyslog() == false);
|
||||
}
|
||||
|
||||
void Ut_Logger::testLogError() {
|
||||
_setTestPhrase(Q_FUNC_INFO);
|
||||
Logger::logError(m_testPhrase);
|
||||
QTest::qSleep(delay);
|
||||
QVERIFY(_findPhraseInSyslog() == true);
|
||||
}
|
||||
|
||||
void Ut_Logger::testLogInfo() {
|
||||
_setTestPhrase(Q_FUNC_INFO);
|
||||
Logger::logInfo(m_testPhrase);
|
||||
QTest::qSleep(delay);
|
||||
QVERIFY(_findPhraseInSyslog() == true);
|
||||
}
|
||||
|
||||
void Ut_Logger::testLogWarning() {
|
||||
_setTestPhrase(Q_FUNC_INFO);
|
||||
Logger::logWarning(m_testPhrase);
|
||||
QTest::qSleep(delay);
|
||||
QVERIFY(_findPhraseInSyslog() == true);
|
||||
}
|
||||
|
||||
void Ut_Logger::testCloseLog() {
|
||||
QVERIFY(m_subject->m_isOpened == true);
|
||||
Logger::closeLog();
|
||||
QVERIFY(m_subject->m_isOpened == false);
|
||||
}
|
||||
|
||||
void Ut_Logger::testOpenLogTwice() {
|
||||
//open log first time with random name
|
||||
_setTestPhrase(Q_FUNC_INFO);
|
||||
Logger::openLog(m_testPhrase);
|
||||
QVERIFY(m_subject->m_isOpened == true);
|
||||
Logger::logInfo("Testing OpenLog twice");
|
||||
QVERIFY(_findPhraseInSyslog() == true);
|
||||
//open log second time with another random name
|
||||
_setTestPhrase(Q_FUNC_INFO);
|
||||
Logger::openLog(m_testPhrase);
|
||||
QVERIFY(m_subject->m_isOpened == true);
|
||||
Logger::logInfo("Testing OpenLog twice");
|
||||
QVERIFY(_findPhraseInSyslog() == true);
|
||||
Logger::closeLog();
|
||||
}
|
||||
|
||||
|
||||
bool Ut_Logger::_findPhraseInSyslog()
|
||||
{
|
||||
QTest::qSleep(delay);
|
||||
int exitCode = QProcess::execute("grep", QStringList() << QString(m_testPhrase) << syslogFile);
|
||||
return exitCode == 0;
|
||||
}
|
||||
|
||||
void Ut_Logger::_setTestPhrase(const char * base)
|
||||
{
|
||||
sprintf(m_testPhrase, "%s: %d", base, qrand());
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(Ut_Logger)
|
||||
@ -1,59 +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_LOGGER_H
|
||||
#define UT_LOGGER_H
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <QObject>
|
||||
#include <tr1/memory>
|
||||
|
||||
#define UNIT_TEST
|
||||
|
||||
class Logger;
|
||||
|
||||
class Ut_Logger : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Ut_Logger();
|
||||
virtual ~Ut_Logger();
|
||||
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
void testOpenLog();
|
||||
void testSetDebugMode();
|
||||
void testLogDebug();
|
||||
void testLogError();
|
||||
void testLogInfo();
|
||||
void testLogWarning();
|
||||
void testCloseLog();
|
||||
void testOpenLogTwice();
|
||||
|
||||
private:
|
||||
char m_testPhrase[255];
|
||||
bool _findPhraseInSyslog();
|
||||
void _setTestPhrase(const char * base);
|
||||
std::tr1::shared_ptr<Logger> m_subject;
|
||||
|
||||
};
|
||||
|
||||
#endif // UT_LOGGER_H
|
||||
@ -1,33 +0,0 @@
|
||||
set(LAUNCHER ${CMAKE_HOME_DIRECTORY}/src/launcherlib)
|
||||
set(DESTINATION "/usr/share/applauncherd-tests/")
|
||||
|
||||
add_definitions(-DTEST_LIB_LOCK_PATH="${DESTINATION}libutwithlock.so")
|
||||
add_definitions(-DTEST_LIB_LOCKUNLOCK_PATH="${DESTINATION}libutwithlockunlock.so")
|
||||
|
||||
# Set sources
|
||||
set(SRC ut_singleinstance.cpp ${LAUNCHER}/singleinstance.cpp)
|
||||
|
||||
# Set moc headers
|
||||
set(MOC_HDRS ut_singleinstance.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_singleinstance ${SRC} ${MOC_SRC} )
|
||||
add_library(utwithlock MODULE ut_library_withlock.cpp)
|
||||
add_library(utwithlockunlock MODULE ut_library_withlockunlock.cpp)
|
||||
|
||||
# Install
|
||||
install(PROGRAMS ut_singleinstance DESTINATION ${DESTINATION})
|
||||
install(FILES libutwithlock.so libutwithlockunlock.so DESTINATION ${DESTINATION})
|
||||
@ -1,27 +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 bool lock(const char * binaryName)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -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 bool lock(const char * binaryName)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
DECL_EXPORT void unlock()
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -1,69 +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_singleinstance.h"
|
||||
#include "singleinstance.h"
|
||||
#include <dlfcn.h>
|
||||
|
||||
Ut_SingleInstance::Ut_SingleInstance() :
|
||||
m_subject(new SingleInstance)
|
||||
{}
|
||||
|
||||
Ut_SingleInstance::~Ut_SingleInstance()
|
||||
{}
|
||||
|
||||
void Ut_SingleInstance::initTestCase()
|
||||
{}
|
||||
|
||||
void Ut_SingleInstance::cleanupTestCase()
|
||||
{}
|
||||
|
||||
void Ut_SingleInstance::testValidateAndRegisterPlugin()
|
||||
{
|
||||
//positive
|
||||
void * handle = dlopen(SINGLE_INSTANCE_PATH, RTLD_NOW);
|
||||
QVERIFY(handle);
|
||||
QVERIFY(m_subject->validateAndRegisterPlugin(handle) == true);
|
||||
m_subject->closePlugin();
|
||||
//negative invalid handle
|
||||
handle = 0;
|
||||
QVERIFY(m_subject->validateAndRegisterPlugin(handle) == false);
|
||||
//negative no "unlock" symbol in the plugin (only lock)
|
||||
handle = dlopen(TEST_LIB_LOCK_PATH, RTLD_NOW);
|
||||
QVERIFY(handle);
|
||||
QVERIFY(m_subject->validateAndRegisterPlugin(handle) == false);
|
||||
//negative no "activateExistingInstance" symbol in the plugin (only lock and unlock)
|
||||
handle = dlopen(TEST_LIB_LOCKUNLOCK_PATH, RTLD_NOW);
|
||||
QVERIFY(handle);
|
||||
QVERIFY(m_subject->validateAndRegisterPlugin(handle) == false);
|
||||
}
|
||||
|
||||
void Ut_SingleInstance::testPluginEntry()
|
||||
{
|
||||
QVERIFY(!m_subject->pluginEntry()); //plugin not loaded yet
|
||||
|
||||
void * handle = dlopen(SINGLE_INSTANCE_PATH, RTLD_NOW);
|
||||
QVERIFY(handle);
|
||||
QVERIFY(m_subject->validateAndRegisterPlugin(handle) == true);
|
||||
QVERIFY(m_subject->pluginEntry()); //plugin loaded
|
||||
m_subject->closePlugin();
|
||||
}
|
||||
|
||||
|
||||
QTEST_APPLESS_MAIN(Ut_SingleInstance);
|
||||
@ -1,50 +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_SINGLEINSTANCE_H
|
||||
#define UT_SINGLEINSTANCE_H
|
||||
|
||||
#include<QtTest/QtTest>
|
||||
#include<QObject>
|
||||
|
||||
#include <tr1/memory>
|
||||
|
||||
#define UNIT_TEST
|
||||
|
||||
class SingleInstance;
|
||||
|
||||
class Ut_SingleInstance : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Ut_SingleInstance();
|
||||
virtual ~Ut_SingleInstance();
|
||||
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
void testValidateAndRegisterPlugin();
|
||||
void testPluginEntry();
|
||||
|
||||
private:
|
||||
std::tr1::shared_ptr<SingleInstance> m_subject;
|
||||
};
|
||||
|
||||
#endif // UT_QTBOOSTER_H
|
||||
@ -1,28 +0,0 @@
|
||||
set(LAUNCHER ${CMAKE_HOME_DIRECTORY}/src/launcherlib)
|
||||
|
||||
# Set sources
|
||||
set(SRC ut_socketmanager.cpp ${LAUNCHER}/logger.cpp ${LAUNCHER}/socketmanager.cpp)
|
||||
|
||||
# Set moc headers
|
||||
set(MOC_HDRS ut_socketmanager.h)
|
||||
|
||||
# Set the program name define used in daemon.cpp
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPROG_NAME_LAUNCHER=\\\"applauncherd\\\"")
|
||||
|
||||
# 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})
|
||||
link_libraries(${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY} "-L/lib -lsystemd-daemon")
|
||||
|
||||
# Enable Qt (may not be needed, because already defined on higher level)
|
||||
include(${QT_USE_FILE})
|
||||
add_executable(ut_socketmanager ${SRC} ${MOC_SRC})
|
||||
|
||||
# Install
|
||||
install(PROGRAMS ut_socketmanager DESTINATION /usr/share/applauncherd-tests/)
|
||||
|
||||
@ -1,72 +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 "ut_socketmanager.h"
|
||||
#include "socketmanager.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
Ut_SocketManager::Ut_SocketManager()
|
||||
{}
|
||||
|
||||
Ut_SocketManager::~Ut_SocketManager()
|
||||
{}
|
||||
|
||||
void Ut_SocketManager::initTestCase()
|
||||
{}
|
||||
|
||||
void Ut_SocketManager::cleanupTestCase()
|
||||
{}
|
||||
|
||||
// Check that socket gets initialized for provided socket id
|
||||
void Ut_SocketManager::testInitSocket()
|
||||
{
|
||||
m_subject.reset(new SocketManager);
|
||||
|
||||
QVERIFY(m_subject->socketCount() == 0);
|
||||
|
||||
QString name1 = QString("a-%1").arg(getpid());
|
||||
QString name2 = QString("b-%1").arg(getpid());
|
||||
|
||||
m_subject->initSocket(name1.toStdString());
|
||||
m_subject->initSocket(name2.toStdString());
|
||||
m_subject->initSocket(name2.toStdString());
|
||||
m_subject->initSocket(name1.toStdString());
|
||||
|
||||
QVERIFY(m_subject->socketCount() == 2);
|
||||
|
||||
QVERIFY(m_subject->findSocket(name1.toStdString()) != -1);
|
||||
QVERIFY(m_subject->findSocket(name2.toStdString()) != -1);
|
||||
QVERIFY(m_subject->findSocket("foo") == -1);
|
||||
|
||||
QVERIFY(m_subject->socketCount() == 2);
|
||||
|
||||
m_subject->closeAllSockets();
|
||||
|
||||
QVERIFY(m_subject->socketCount() == 0);
|
||||
|
||||
QVERIFY(unlink(name1.toStdString().c_str()) == 0);
|
||||
QVERIFY(unlink(name2.toStdString().c_str()) == 0);
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(Ut_SocketManager);
|
||||
@ -1,51 +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 UT_SOCKETMANAGER_H
|
||||
#define UT_SOCKETMANAGER_H
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <QObject>
|
||||
#include <tr1/memory>
|
||||
|
||||
#define UNIT_TEST
|
||||
|
||||
class SocketManager;
|
||||
|
||||
class Ut_SocketManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
Ut_SocketManager();
|
||||
~Ut_SocketManager();
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
void testInitSocket();
|
||||
|
||||
private:
|
||||
|
||||
std::tr1::shared_ptr<SocketManager> m_subject;
|
||||
};
|
||||
|
||||
#endif // UT_SOCKETMANAGER_H
|
||||
@ -1,2 +0,0 @@
|
||||
install(FILES tests.xml DESTINATION /usr/share/applauncherd-M-art-tests)
|
||||
|
||||
@ -1,53 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<testdefinition version="0.1">
|
||||
|
||||
<!-- Test suite, name mandatory - the same as test package name -->
|
||||
<!-- Schema: https://projects.maemo.org/docs/testing/xml-definition.html -->
|
||||
<suite name="applauncherd-M-art-tests" domain="Application framework">
|
||||
|
||||
<set name="applauncherd-M-art-tests" description="Launcher functional tests" feature="AF Basic Launcher daemon support" requirement="300168">
|
||||
<pre_steps>
|
||||
<step>/usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120</step>
|
||||
</pre_steps>
|
||||
|
||||
<case name="zombie-state" type="Functional" description="To test that process exits after the application is killed" timeout="120" level="System">
|
||||
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 python /usr/share/applauncherd-M-testscripts/test-func-launcher.py test_003_zombie_state</step>
|
||||
</case>
|
||||
|
||||
<case name="launch-multi-app" type="Functional" description="To test that more than one applications are launched by the launcher" timeout="120" level="System">
|
||||
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 python /usr/share/applauncherd-M-testscripts/test-func-launcher.py test_004_launch_multiple_apps</step>
|
||||
</case>
|
||||
|
||||
<case name="one-instance" type="Functional" description="To test that only one instance of a application exist" timeout="120" level="System">
|
||||
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 python /usr/share/applauncherd-M-testscripts/test-func-launcher.py test_005_one_instance</step>
|
||||
</case>
|
||||
|
||||
<environments>
|
||||
<scratchbox>false</scratchbox>
|
||||
<hardware>true</hardware>
|
||||
</environments>
|
||||
|
||||
<!--get>
|
||||
</get-->
|
||||
</set>
|
||||
|
||||
<set name="Prestart-launched" description="To test that prestarted application is launched" feature="AF DUI Booster for Launcher daemon" requirement="300195">
|
||||
<pre_steps>
|
||||
<step>/usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120</step>
|
||||
</pre_steps>
|
||||
<case name="Prestart-launched" type="Functional" description="To test that prestarted application is launched" timeout="120" level="System">
|
||||
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 /usr/share/applauncherd-M-testscripts/ts_prestartapp.rb --name test_launch_prestarted_app</step>
|
||||
</case>
|
||||
|
||||
<environments>
|
||||
<scratchbox>false</scratchbox>
|
||||
<hardware>true</hardware>
|
||||
</environments>
|
||||
|
||||
<!--get>
|
||||
</get-->
|
||||
</set>
|
||||
</suite>
|
||||
</testdefinition>
|
||||
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
install(FILES tests.xml DESTINATION /usr/share/applauncherd-M-bug-tests)
|
||||
|
||||
@ -1,106 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<testdefinition version="0.1">
|
||||
|
||||
<!-- Test suite, name mandatory - the same as test package name -->
|
||||
<!-- Schema: https://projects.maemo.org/docs/testing/xml-definition.html -->
|
||||
<suite name="applauncherd-M-bug-tests" domain="Application framework">
|
||||
|
||||
<set name="applauncherd-tests" description="Launcher functional tests" feature="AF Basic Launcher daemon support" requirement="300168">
|
||||
<pre_steps>
|
||||
<step>/usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120</step>
|
||||
</pre_steps>
|
||||
|
||||
<case name="launch-multi-app-cont" type="Functional" description="Test that launcher and invoker have correct credentials" timeout="360" level="System" insignificant="true">
|
||||
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 python /usr/share/applauncherd-M-testscripts/test-func-launcher.py test_009_launch_multiple_apps_cont</step>
|
||||
</case>
|
||||
|
||||
<case name="launch-without-applauncherd" type="Functional" description="Test invoker can launch applications even when applauncherd is not running" timeout="360" level="System" insignificant="true">
|
||||
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 python /usr/share/applauncherd-M-testscripts/test-func-launcher.py test_020_launch_wo_applauncherd</step>
|
||||
</case>
|
||||
|
||||
<environments>
|
||||
<scratchbox>false</scratchbox>
|
||||
<hardware>true</hardware>
|
||||
</environments>
|
||||
|
||||
<!--get>
|
||||
</get-->
|
||||
</set>
|
||||
|
||||
<set name="Theme-tests" description="Test that global and application specific theming work with launched apps" feature="AF DUI Booster for Launcher daemon" requirement="300195">
|
||||
<pre_steps>
|
||||
<step>/usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120</step>
|
||||
</pre_steps>
|
||||
|
||||
<case name="app-specific" 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-M-testscripts/tc_theming.rb --name test_application_specific_theming</step>
|
||||
</case>
|
||||
|
||||
<case name="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-M-testscripts/tc_theming.rb --name test_global_theming</step>
|
||||
</case>
|
||||
|
||||
<case name="booster-killer" type="Functional" description="Tests that booster-m and booster-w are restarted after theme change" timeout="360" level="System" insignificant="true">
|
||||
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 /usr/share/applauncherd-M-testscripts/tc_theming.rb --name test_booster_killer</step>
|
||||
</case>
|
||||
<environments>
|
||||
<scratchbox>true</scratchbox>
|
||||
<hardware>true</hardware>
|
||||
</environments>
|
||||
|
||||
<!--get>
|
||||
</get-->
|
||||
</set>
|
||||
|
||||
<set name="wait-term" description="Launcher functional tests" feature="AF Basic Launcher daemon support" requirement="300168">
|
||||
<pre_steps>
|
||||
<step>/usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120</step>
|
||||
</pre_steps>
|
||||
|
||||
<case name="invoker-wait-term" type="Functional" description="Test that the launched application is killed when killing invoker that is waiting for app to terminate" timeout="360" level="System" insignificant="true">
|
||||
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 python /usr/share/applauncherd-M-testscripts/test-func-launcher.py test_010</step>
|
||||
</case>
|
||||
|
||||
<case name="invoker-status" type="Functional" description="To test that invoker returns the same exit status as the application" timeout="360" level="System" insignificant="true">
|
||||
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 python /usr/share/applauncherd-M-testscripts/test-func-launcher.py test_017_invoker_exit_status</step>
|
||||
</case>
|
||||
|
||||
<case name="gid-uid" type="Functional" description="To Test that the set gid and uid is passed from invoker process to launcher" timeout="360" level="System" insignificant="true">
|
||||
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 python /usr/share/applauncherd-M-testscripts/test-func-launcher.py test_018_invoker_gid_uid</step>
|
||||
</case>
|
||||
|
||||
<case name="signal-forwarding" type="Functional" description="To Test that invoker is killed by the same signal as the application" timeout="360" level="System" insignificant="true">
|
||||
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 python /usr/share/applauncherd-M-testscripts/test-func-launcher.py test_019_signal_forwarding</step>
|
||||
</case>
|
||||
|
||||
<environments>
|
||||
<scratchbox>true</scratchbox>
|
||||
<hardware>true</hardware>
|
||||
</environments>
|
||||
</set>
|
||||
|
||||
<set name="Booster-tests" description="Launcher functional tests" feature="Closing File Descriptors" requirement="300168">
|
||||
<pre_steps>
|
||||
<step>/usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120</step>
|
||||
</pre_steps>
|
||||
|
||||
<case name="fd-booster-m" type="Functional" description="File descriptor test for booster-m" timeout="360" level="System" insignificant="true">
|
||||
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 python /usr/share/applauncherd-M-testscripts/test-func-launcher.py test_014_fd_booster_m</step>
|
||||
</case>
|
||||
|
||||
<case name="fd-booster-q" type="Functional" description="File descriptor test for booster-q" timeout="360" level="System" insignificant="true">
|
||||
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 python /usr/share/applauncherd-M-testscripts/test-func-launcher.py test_015_fd_booster_q</step>
|
||||
</case>
|
||||
|
||||
<case name="kill-boosters" type="Functional" description="Test that booster is restarted if it is killed" timeout="360" level="System" insignificant="true">
|
||||
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 python /usr/share/applauncherd-M-testscripts/test-func-launcher.py test_016_restart_booster</step>
|
||||
</case>
|
||||
<environments>
|
||||
<scratchbox>true</scratchbox>
|
||||
<hardware>true</hardware>
|
||||
</environments>
|
||||
</set>
|
||||
</suite>
|
||||
</testdefinition>
|
||||
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
install(FILES tests.xml DESTINATION /usr/share/applauncherd-M-functional-tests)
|
||||
|
||||
@ -1,58 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<testdefinition version="0.1">
|
||||
|
||||
<!-- Test suite, name mandatory - the same as test package name -->
|
||||
<!-- Schema: https://projects.maemo.org/docs/testing/xml-definition.html -->
|
||||
<suite name="applauncherd-M-functional-tests" domain="Application framework">
|
||||
|
||||
<set name="applauncherd-M-functional-tests" description="Launcher functional tests" feature="AF Basic Launcher daemon support" requirement="300168">
|
||||
<pre_steps>
|
||||
<step>/usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120</step>
|
||||
</pre_steps>
|
||||
|
||||
|
||||
<case name="launcher-exist" type="Functional" description="To test if the launcher exists and is executable or not" timeout="360" level="System" insignificant="false">
|
||||
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 python /usr/share/applauncherd-M-testscripts/test-func-launcher.py test_001_launcher_exist</step>
|
||||
</case>
|
||||
|
||||
<case name="launchable-app-exist" type="Functional" description="test_launchable_application_exists " timeout="360" level="System" insignificant="false">
|
||||
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 python /usr/share/applauncherd-M-testscripts/test-func-launcher.py test_002_applications_exist</step>
|
||||
</case>
|
||||
|
||||
<case name="zombie-state" type="Functional" description="To test that process exits after the application is killed" timeout="360" level="System" insignificant="false">
|
||||
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 python /usr/share/applauncherd-M-testscripts/test-func-launcher.py test_003_zombie_state</step>
|
||||
</case>
|
||||
|
||||
<case name="launch-multi-app" type="Functional" description="To test that more than one applications are launched by the launcher" timeout="360" level="System" insignificant="false">
|
||||
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 python /usr/share/applauncherd-M-testscripts/test-func-launcher.py test_004_launch_multiple_apps</step>
|
||||
</case>
|
||||
|
||||
<case name="one-instance" type="Functional" description="To test that only one instance of a application exist" timeout="360" level="System" insignificant="false">
|
||||
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 python /usr/share/applauncherd-M-testscripts/test-func-launcher.py test_005_one_instance</step>
|
||||
</case>
|
||||
|
||||
<case name="daemonized" type="Functional" description="Test that the applauncherd can be started daemonized" timeout="360" level="System" insignificant="true">
|
||||
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 python /usr/share/applauncherd-M-testscripts/test-func-launcher.py test_011</step>
|
||||
</case>
|
||||
|
||||
<case name="invoker-delay" type="Functional" description="Test that invokers --delay parameter works" timeout="360" level="System" insignificant="true">
|
||||
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 python /usr/share/applauncherd-M-testscripts/test-func-launcher.py test_012</step>
|
||||
</case>
|
||||
|
||||
<case name="invoker_search_prog" type="Functional" description="Test that invoker finds binaries from PATH" timeout="360" level="System" insignificant="true">
|
||||
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 python /usr/share/applauncherd-M-testscripts/test-func-launcher.py test_invoker_search_prog</step>
|
||||
</case>
|
||||
|
||||
|
||||
<environments>
|
||||
<scratchbox>true</scratchbox>
|
||||
<hardware>true</hardware>
|
||||
</environments>
|
||||
|
||||
<!--get>
|
||||
</get-->
|
||||
</set>
|
||||
</suite>
|
||||
</testdefinition>
|
||||
|
||||
|
||||
@ -1 +0,0 @@
|
||||
install(FILES tests.xml DESTINATION /usr/share/applauncherd-M-performance-tests/)
|
||||
@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<testdefinition version="0.1">
|
||||
|
||||
<!-- Test suite, name mandatory - the same as test package name -->
|
||||
<!-- Schema: https://projects.maemo.org/docs/testing/xml-definition.html -->
|
||||
<suite name="applauncherd-M-performance-tests" domain="Application framework">
|
||||
|
||||
<!--set name="test-applicationGrid" description="applauncherd application startup time from application grid" feature="AF DUI Booster for Launcher daemon" requirement="300195">
|
||||
<pre_steps>
|
||||
<step>/usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120</step>
|
||||
</pre_steps>
|
||||
|
||||
<case name="Perf-Test" type="Performance" description="Measure launcher performance" timeout="360" level="System" insignificant="true">
|
||||
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 /usr/share/applauncherd-M-testscripts/test-perf.rb name test_performance > /tmp/launcher_perf_new.txt</step>
|
||||
</case>
|
||||
<environments>
|
||||
<scratchbox>false</scratchbox>
|
||||
<hardware>true</hardware>
|
||||
</environments>
|
||||
|
||||
<get>
|
||||
<file>/tmp/launcher_perf_new.txt</file>
|
||||
</get>
|
||||
</set-->
|
||||
|
||||
</suite>
|
||||
</testdefinition>
|
||||
|
||||
|
||||
@ -1,16 +0,0 @@
|
||||
install(FILES
|
||||
check_pipes.py
|
||||
test-func-launcher.py
|
||||
utils.py
|
||||
DESTINATION /usr/share/applauncherd-M-testscripts)
|
||||
|
||||
install(PROGRAMS
|
||||
ts_prestartapp.rb
|
||||
tc_theming.rb
|
||||
test-perf.rb
|
||||
fala_wid
|
||||
fala_xres_wl
|
||||
fala_xres_wol
|
||||
DESTINATION /usr/share/applauncherd-M-testscripts)
|
||||
|
||||
add_subdirectory (signal-forward)
|
||||
@ -1,48 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
# All rights reserved.
|
||||
# Contact: Nokia Corporation (directui@nokia.com)
|
||||
#
|
||||
# This file is part of applauncherd.
|
||||
#
|
||||
# If you have questions regarding the use of this file, please contact
|
||||
# Nokia at directui@nokia.com.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License version 2.1 as published by the Free Software Foundation
|
||||
# and appearing in the file LICENSE.LGPL included in the packaging
|
||||
# of this file.
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
p = subprocess.Popen("(for p in $(pgrep applauncherd); do ls -l /proc/$p/fd | grep pipe ; done) | awk -F\: '{print $3}' | sort -u",
|
||||
shell=True,
|
||||
stdout=subprocess.PIPE)
|
||||
|
||||
result= p.stdout.read()
|
||||
print type(result), result
|
||||
|
||||
if result[0]!='[':
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
p = subprocess.Popen("(for p in $(pgrep applauncherd); do ls -l /proc/$p/fd | grep pipe ; done) | awk -F\: '{print $3}' | sort -u | wc -l",
|
||||
shell=True,
|
||||
stdout=subprocess.PIPE)
|
||||
|
||||
result= int(p.stdout.read())
|
||||
|
||||
if result!=1:
|
||||
sys.exit(2)
|
||||
|
||||
p = subprocess.Popen("(for p in $(pgrep applauncherd); do ls -l /proc/$p/fd | grep pipe ; done) | awk -F\: '{print $3}' | wc -l",
|
||||
shell=True,
|
||||
stdout=subprocess.PIPE)
|
||||
|
||||
result= int(p.stdout.read())
|
||||
|
||||
if result!=4:
|
||||
sys.exit(4)
|
||||
@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
for wid in $(xwininfo -root -tree| awk '/864x480\+0\+0/{print $1}'); do echo $wid $(xprop -id $wid | awk '/_NET_WM_PID/{print $3}') | awk -v BOOSTERPID=$(pidof booster-m) '{if (BOOSTERPID == $2) print $1}'; done
|
||||
@ -1,5 +0,0 @@
|
||||
#!/bin/sh
|
||||
x=`sh /usr/share/applauncherd-M-testscripts/fala_wid`
|
||||
xresponse -a 'meegotouchhome' -w 0 -id $x -c $1 -u > /tmp/app_xresponse.log&
|
||||
echo $x
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
xresponse -a 'meegotouchhome' -w 0 -a 'fala_wol' -c $1 -u > /tmp/app_xresponse.log&
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
install(PROGRAMS fala_sf_m.sh fala_sf_qt.sh DESTINATION /usr/share/applauncherd-M-testscripts/signal-forward)
|
||||
install(PROGRAMS fala_sf_m.py fala_sf_qt.py DESTINATION /usr/share/applauncherd-M-testscripts/signal-forward)
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
import os
|
||||
import time
|
||||
import commands
|
||||
|
||||
#Launching application from the script
|
||||
os.system("/usr/share/applauncherd-M-testscripts/signal-forward/fala_sf_m.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)
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
invoker --type=m --wait-term /usr/bin/fala_ft_hello.launch
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
import os
|
||||
import time
|
||||
import commands
|
||||
|
||||
#Launching application from the script
|
||||
os.system("/usr/share/applauncherd-testscripts/signal-forward/fala_sf_qt.sh &")
|
||||
|
||||
time.sleep(3)
|
||||
st, op = commands.getstatusoutput("pgrep fala_ft_hello")
|
||||
|
||||
#Killing application with a signal 11 (Segmentation Fault)
|
||||
commands.getoutput("kill -6 %s" %op)
|
||||
time.sleep(2)
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
su user -c 'invoker --type=qt --wait-term /usr/bin/fala_ft_hello.launch'
|
||||
|
||||
@ -1,206 +0,0 @@
|
||||
#!/usr/bin/ruby
|
||||
#
|
||||
# Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
# All rights reserved.
|
||||
# Contact: Nokia Corporation (directui@nokia.com)
|
||||
#
|
||||
# This file is part of applauncherd.
|
||||
#
|
||||
# If you have questions regarding the use of this file, please contact
|
||||
# Nokia at directui@nokia.com.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License version 2.1 as published by the Free Software Foundation
|
||||
# and appearing in the file LICENSE.LGPL included in the packaging
|
||||
# of this file.
|
||||
|
||||
"""
|
||||
This script tests that system theming works for launched applications.
|
||||
|
||||
Testing that changing the theme is done as follows:
|
||||
|
||||
* launch application
|
||||
* take a screenshot (1)
|
||||
* change theme
|
||||
* take a screenshot (2)
|
||||
* change theme back to original theme
|
||||
* take a screenshot (3)
|
||||
* make sure that 1 and 2 differ and that 1 and 3 are the same
|
||||
|
||||
Testing that application specific theming is done using an application
|
||||
which has application specific theming and application specific svg
|
||||
graphics:
|
||||
|
||||
* start application without launcher
|
||||
* take screenshot of themed widgets (1)
|
||||
* start application with launcher
|
||||
* take screenshot of themed widgets (2)
|
||||
* verify that (1) and (2) are equal
|
||||
|
||||
Testing that booster-m is restarted after theme change
|
||||
|
||||
* get the pid of booster-m (1)
|
||||
* launch application
|
||||
* change theme
|
||||
* Again get the new pids of booster-m (2)
|
||||
* Make sure 1 and 2 differ.
|
||||
"""
|
||||
|
||||
require 'tdriver'
|
||||
require 'date'
|
||||
require 'test/unit'
|
||||
include TDriverVerify
|
||||
|
||||
SCREENSHOT_DIR = '/home/user/MyDocs'
|
||||
|
||||
if ENV.has_key?('_SBOX_DIR')
|
||||
ENV['PATH'] += ":" + ENV['_SBOX_DIR'] + "/tools/bin"
|
||||
SCREENSHOT_DIR = '/tmp'
|
||||
end
|
||||
|
||||
class TC_Theming < Test::Unit::TestCase
|
||||
def change_theme(theme_name)
|
||||
puts "Changing theme from #{get_theme()} to #{theme_name}"
|
||||
|
||||
cmd = "gconftool-2 -s /meegotouch/theme/name -t string " + theme_name
|
||||
|
||||
verify_equal(true, 5, "Could not change theme") {
|
||||
system(cmd)
|
||||
}
|
||||
|
||||
sleep(15)
|
||||
end
|
||||
|
||||
def get_theme()
|
||||
`gconftool-2 -g /meegotouch/theme/name`.strip()
|
||||
end
|
||||
|
||||
def setup
|
||||
system('mcetool --set-tklock-mode=unlocked')
|
||||
@sut = TDriver.sut(:Id => ARGV[0] || 'sut_qt_maemo')
|
||||
end
|
||||
|
||||
def test_global_theming
|
||||
app_name = 'fala_ft_hello'
|
||||
|
||||
system("pkill #{app_name}")
|
||||
|
||||
system("su - meego -c #{app_name}&")
|
||||
sleep(5)
|
||||
|
||||
#pid = `pgrep -n #{app_name}`
|
||||
|
||||
app = @sut.application(:name => app_name)
|
||||
widget = app.MWidget(:name => 'centralWidget')
|
||||
|
||||
original_theme = get_theme()
|
||||
alternative_theme = 'plankton'
|
||||
|
||||
if original_theme == alternative_theme
|
||||
alternative_theme = 'blanco'
|
||||
end
|
||||
|
||||
widget.capture_screen('PNG', SCREENSHOT_DIR + '/testshot1.png', true)
|
||||
|
||||
change_theme(alternative_theme)
|
||||
|
||||
widget.capture_screen('PNG', SCREENSHOT_DIR + '/testshot2.png', true)
|
||||
|
||||
change_theme(original_theme)
|
||||
|
||||
widget.capture_screen('PNG', SCREENSHOT_DIR + '/testshot3.png', true)
|
||||
|
||||
system("pkill #{app_name}")
|
||||
|
||||
# diff returns an error when files are different
|
||||
verify_equal(false, 1, "Shots 1 & 2 should differ!") {
|
||||
system("diff #{SCREENSHOT_DIR}/testshot1.png #{SCREENSHOT_DIR}/testshot2.png")
|
||||
}
|
||||
|
||||
# diff returns success when files are the same
|
||||
verify_equal(true, 1, "Shots 1 & 3 should be the same!") {
|
||||
system("diff #{SCREENSHOT_DIR}/testshot1.png #{SCREENSHOT_DIR}/testshot3.png")
|
||||
}
|
||||
|
||||
File.delete(SCREENSHOT_DIR + "/testshot1.png",
|
||||
SCREENSHOT_DIR + "/testshot2.png",
|
||||
SCREENSHOT_DIR + "/testshot3.png")
|
||||
end
|
||||
|
||||
def test_application_specific_theming
|
||||
|
||||
app_with_launcher = 'fala_ft_themetest'
|
||||
app_without_launcher = "#{app_with_launcher}.launch"
|
||||
|
||||
# start app and take screenshots of the themed widgets
|
||||
system("pkill #{app_without_launcher}")
|
||||
system("pkill #{app_with_launcher}")
|
||||
system("su - meego -c #{app_without_launcher} &")
|
||||
sleep(5)
|
||||
|
||||
app = @sut.application(:name => app_without_launcher)
|
||||
widget = app.MLabel(:name => 'themedlabel')
|
||||
widget.capture_screen('PNG', '/tmp/testshot1.png', true)
|
||||
widget = app.MLabel(:name => 'themedlabelwithgraphics')
|
||||
widget.capture_screen('PNG', '/tmp/testshot2.png', true)
|
||||
close_button = app.MButton( :name => 'CloseButton' )
|
||||
close_button.tap
|
||||
|
||||
sleep(5)
|
||||
|
||||
# once again using the launcher
|
||||
system("su - meego -c #{app_with_launcher} &")
|
||||
sleep(5)
|
||||
|
||||
app = @sut.application(:name => app_with_launcher)
|
||||
widget = app.MLabel(:name => 'themedlabel')
|
||||
widget.capture_screen('PNG', '/tmp/testshot3.png', true)
|
||||
widget = app.MLabel(:name => 'themedlabelwithgraphics')
|
||||
widget.capture_screen('PNG', '/tmp/testshot4.png', true)
|
||||
close_button = app.MButton( :name => 'CloseButton' )
|
||||
close_button.tap
|
||||
|
||||
|
||||
verify_equal(true, 1, "Application specific theming failed with launcher!") {
|
||||
# diff returns success when files are the same
|
||||
system("diff /tmp/testshot1.png /tmp/testshot3.png")
|
||||
}
|
||||
|
||||
verify_equal(true, 1, "Application specific svg files not found with launcher!") {
|
||||
# diff returns success when files are the same
|
||||
system("diff /tmp/testshot2.png /tmp/testshot4.png")
|
||||
}
|
||||
|
||||
File.delete("/tmp/testshot1.png", "/tmp/testshot2.png",
|
||||
"/tmp/testshot3.png", "/tmp/testshot4.png")
|
||||
end
|
||||
|
||||
def test_booster_killer
|
||||
m_pid = `pgrep -n booster-m`
|
||||
print "Current booster-m %s" % m_pid
|
||||
|
||||
app_name = 'fala_ft_hello'
|
||||
system("pkill #{app_name}")
|
||||
system("su - meego -c #{app_name}&")
|
||||
sleep(2)
|
||||
|
||||
original_theme = get_theme()
|
||||
alternative_theme = 'plankton'
|
||||
if original_theme == alternative_theme
|
||||
alternative_theme = 'blanco'
|
||||
end
|
||||
change_theme(alternative_theme)
|
||||
sleep(6)
|
||||
|
||||
new_mpid = `pgrep -n booster-m`
|
||||
|
||||
system("pkill #{app_name}")
|
||||
|
||||
print "New booster-m %s" % new_mpid
|
||||
|
||||
verify_true(2,"The booster-m was not restarted"){
|
||||
m_pid != new_mpid}
|
||||
|
||||
end
|
||||
end
|
||||
@ -1,599 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
# All rights reserved.
|
||||
# Contact: Nokia Corporation (directui@nokia.com)
|
||||
#
|
||||
# This file is part of applauncherd.
|
||||
#
|
||||
# If you have questions regarding the use of this file, please contact
|
||||
# Nokia at directui@nokia.com.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License version 2.1 as published by the Free Software Foundation
|
||||
# and appearing in the file LICENSE.LGPL included in the packaging
|
||||
# of this file.
|
||||
|
||||
"""
|
||||
This program tests the startup time of the given application with and
|
||||
without launcher.
|
||||
|
||||
Requirements:
|
||||
1. DISPLAY environment variable must be set correctly.
|
||||
2. DBus session bus must be running.
|
||||
3. DBus session bus address must be stored in /tmp/session_bus_address.user.
|
||||
4. Given application supports launcher with .launcher binary in /usr/bin/.
|
||||
5. launcher application should be installed.
|
||||
|
||||
Usage: test-func-launcher <launcherable application>
|
||||
|
||||
Example: test-func-launcher /usr/bin/fala_ft_hello
|
||||
|
||||
Authors: ext-nimika.1.keshri@nokia.com
|
||||
ext-oskari.timperi@nokia.com
|
||||
"""
|
||||
|
||||
import os, os.path, glob
|
||||
import subprocess
|
||||
import commands
|
||||
import time
|
||||
import sys
|
||||
import unittest
|
||||
import re
|
||||
from subprocess import Popen
|
||||
from utils import *
|
||||
from os.path import basename
|
||||
|
||||
LAUNCHER_BINARY='/usr/bin/applauncherd'
|
||||
DEV_NULL = file("/dev/null","w")
|
||||
LAUNCHABLE_APPS = ['/usr/bin/fala_ft_hello','/usr/bin/fala_ft_hello1', '/usr/bin/fala_ft_hello2']
|
||||
PREFERED_APP = '/usr/bin/fala_ft_hello'
|
||||
|
||||
using_scratchbox = False
|
||||
|
||||
def start_launcher_daemon():
|
||||
temp = basename(LAUNCHER_BINARY)
|
||||
st, op = commands.getstatusoutput("pgrep %s" %temp)
|
||||
if st == 0:
|
||||
debug("Launcher already started")
|
||||
return op
|
||||
|
||||
def check_prerequisites():
|
||||
if os.getenv('DISPLAY') == None:
|
||||
error("DISPLAY is not set. Check the requirements.")
|
||||
|
||||
if os.getenv('DBUS_SESSION_BUS_ADDRESS') == None:
|
||||
error("DBUS_SESSION_BUS_ADDRESS is not set.\n" +
|
||||
"You probably want to source /tmp/session_bus_address.user")
|
||||
|
||||
for app in LAUNCHABLE_APPS:
|
||||
assert(len(basename(app)) < 15, "For app: %s, base name !<= 14" % app)
|
||||
|
||||
class launcher_tests (unittest.TestCase):
|
||||
def setUp(self):
|
||||
#setup here
|
||||
print "Executing SetUp"
|
||||
|
||||
def tearDown(self):
|
||||
#teardown here
|
||||
print "Executing TearDown"
|
||||
if get_pid('applauncherd') == None:
|
||||
os.system('initctl start xsession/applauncherd')
|
||||
|
||||
#Testcases
|
||||
def test_001_launcher_exist(self):
|
||||
"""
|
||||
To test if the launcher exists and is executable or not
|
||||
"""
|
||||
self.assert_(os.path.isfile(LAUNCHER_BINARY), "Launcher file does not exist")
|
||||
self.assert_(os.access(LAUNCHER_BINARY, os.X_OK), "Launcher exists, but is not executable")
|
||||
|
||||
def test_002_applications_exist(self):
|
||||
"""
|
||||
test_launchable_application_exists
|
||||
"""
|
||||
failed_apps = []
|
||||
for app in LAUNCHABLE_APPS:
|
||||
temp = "%s.launch" % app
|
||||
if not (os.path.isfile(temp) and os.access(temp, os.X_OK)):
|
||||
failed_apps.append(temp)
|
||||
self.assert_(failed_apps == [], "Some applications do not have the launch files, list: %s" % str(failed_apps))
|
||||
|
||||
def test_003_zombie_state(self):
|
||||
"""
|
||||
To test that no Zombie process exist after the application is killed
|
||||
"""
|
||||
#launch application with launcher
|
||||
#check if the application is running
|
||||
#kill the application (pid = p.pid)
|
||||
#check if pgrep appname should be nothing
|
||||
#self.kill_process(LAUNCHER_BINARY)
|
||||
|
||||
process_handle = run_app_as_user(PREFERED_APP)
|
||||
process_id = wait_for_app(PREFERED_APP, 50)
|
||||
debug("Pid of ",PREFERED_APP," is :",process_id)
|
||||
time.sleep(2)
|
||||
kill_process(PREFERED_APP)
|
||||
time.sleep(2)
|
||||
|
||||
process_handle = run_app_as_user(PREFERED_APP)
|
||||
process_id1 = wait_for_app(PREFERED_APP, 50)
|
||||
debug("Pid of ",PREFERED_APP," is :",process_id1)
|
||||
time.sleep(2)
|
||||
kill_process(PREFERED_APP)
|
||||
time.sleep(2)
|
||||
|
||||
process_id1 = get_pid(PREFERED_APP)
|
||||
print process_id1
|
||||
|
||||
self.assert_(process_id != process_id1 , "New Process not launched")
|
||||
self.assert_(process_id1 == None , "Process still running")
|
||||
|
||||
def test_004_launch_multiple_apps(self):
|
||||
"""
|
||||
To test that more than one applications are launched by the launcher
|
||||
"""
|
||||
|
||||
def kill_launched(pids):
|
||||
for pid in pids:
|
||||
kill_process(apppid = pid)
|
||||
|
||||
pidlist = []
|
||||
|
||||
for app in LAUNCHABLE_APPS:
|
||||
p = run_app_as_user(app)
|
||||
pid = wait_for_app(app, timeout = 100, sleep = 1)
|
||||
time.sleep(6)
|
||||
debug("Pid of ",app," is :",pid)
|
||||
|
||||
if pid == None:
|
||||
kill_launched(pidlist)
|
||||
self.fail("%s was not launched using applauncherd",app)
|
||||
|
||||
pidlist.append(pid)
|
||||
|
||||
kill_launched(pidlist)
|
||||
|
||||
def test_005_one_instance(self):
|
||||
"""
|
||||
To test that only one instance of a application exist
|
||||
"""
|
||||
#launch application
|
||||
#self.run_app_as_user(appname)
|
||||
#get pid of application
|
||||
#launch applicatoin again
|
||||
#check pgrep application
|
||||
#y = commands.getstatusoutput(pgrep appname)
|
||||
#len(y[-1].split(' ')) == 1
|
||||
process_handle = run_app_as_user(PREFERED_APP)
|
||||
time.sleep(2)
|
||||
process_id = wait_for_app(PREFERED_APP, 100)
|
||||
debug("PID of 1st %s" % process_id)
|
||||
|
||||
process_handle1 = run_app_as_user(PREFERED_APP)
|
||||
time.sleep(2)
|
||||
process_id = wait_for_app(PREFERED_APP,100)
|
||||
debug("PID of 2nd %s" % process_id)
|
||||
|
||||
kill_process(PREFERED_APP)
|
||||
|
||||
self.assert_( len(process_id.split(' ')) == 1, "Only one instance of app not running")
|
||||
|
||||
def test_009_launch_multiple_apps_cont(self):
|
||||
"""
|
||||
To test that more than one applications are launched by the launcher
|
||||
"""
|
||||
for app in LAUNCHABLE_APPS:
|
||||
#launch application with launcher
|
||||
#check if the application is running
|
||||
#check if p.pid is same as pgrep appname
|
||||
#in a global dictionary, append the pid
|
||||
process_handle = run_app_as_user(app)
|
||||
|
||||
time.sleep(30)
|
||||
|
||||
process_id = get_pid('fala_ft_hello')
|
||||
pid_list = process_id.split()
|
||||
|
||||
self.assert_(len(pid_list) == len(LAUNCHABLE_APPS), "All Applications were not launched using launcher")
|
||||
|
||||
for pid in pid_list:
|
||||
kill_process(apppid=pid)
|
||||
|
||||
def test_010(self):
|
||||
"""
|
||||
NB#179266
|
||||
|
||||
When calling invoker with --wait-term and killing invoker,
|
||||
the launched application should die too.
|
||||
"""
|
||||
|
||||
app_path = '/usr/bin/fala_ft_hello.launch'
|
||||
|
||||
# Launch the app with invoker using --wait-term
|
||||
p = run_app_as_user('invoker --type=m --wait-term %s' % app_path)
|
||||
|
||||
time.sleep(4)
|
||||
|
||||
# Retrieve their pids
|
||||
invoker_pid = wait_for_app('invoker')
|
||||
time.sleep(4)
|
||||
app_pid = wait_for_app('fala_ft_hello')
|
||||
time.sleep(4)
|
||||
|
||||
debug("invoker_pid ", invoker_pid)
|
||||
debug("app_pid " ,app_pid)
|
||||
|
||||
# Make sure that both apps started
|
||||
self.assert_(invoker_pid != None, "invoker not executed?")
|
||||
self.assert_(app_pid != None, "%s not launched by invoker?" % app_path)
|
||||
|
||||
# Send SIGTERM to invoker, the launched app should die
|
||||
kill_process(None, invoker_pid, 15)
|
||||
|
||||
time.sleep(8)
|
||||
|
||||
# This should be None
|
||||
app_pid2 = get_pid('fala_ft_hello')
|
||||
|
||||
if (app_pid2 != None):
|
||||
kill_process(None, app_pid2)
|
||||
self.assert_(False, "%s was not killed" % app_path)
|
||||
|
||||
|
||||
def test_011(self):
|
||||
"""
|
||||
Test that the --daemon parameter works for applauncherd
|
||||
"""
|
||||
|
||||
stop_applauncherd()
|
||||
|
||||
# and for the fun of it let's do it again
|
||||
commands.getstatusoutput("pkill applauncherd")
|
||||
|
||||
remove_applauncherd_runtime_files()
|
||||
|
||||
p = run_app_as_user('/usr/bin/applauncherd.bin --daemon')
|
||||
|
||||
time.sleep(5)
|
||||
|
||||
st, op = commands.getstatusoutput('pgrep -lf "applauncherd.bin --daemon"')
|
||||
time.sleep(5)
|
||||
|
||||
debug("The pid of applauncherd in daemon mode is :", op)
|
||||
|
||||
# filter some cruft out from the output and see how many
|
||||
# instances are running
|
||||
op = filter(lambda x: x.find("sh ") == -1, op.split("\n"))
|
||||
count = len(op)
|
||||
|
||||
print "count = %d" % count
|
||||
|
||||
self.assert_(count == 1, "applauncherd was not daemonized (or too many instances running ..)")
|
||||
|
||||
# try to launch an app
|
||||
run_app_as_user('/usr/bin/fala_ft_hello')
|
||||
time.sleep(6)
|
||||
|
||||
pid = wait_for_app('fala_ft_hello')
|
||||
time.sleep(6)
|
||||
|
||||
if pid != None:
|
||||
kill_process(apppid = pid)
|
||||
else:
|
||||
self.assert_(False, "fala_ft_hello was not launched!")
|
||||
|
||||
# only the daemonized applauncherd should be running now
|
||||
commands.getstatusoutput('pkill applauncherd')
|
||||
|
||||
remove_applauncherd_runtime_files()
|
||||
|
||||
start_applauncherd()
|
||||
|
||||
def test_012(self):
|
||||
"""
|
||||
Test the --delay parameter of the invoker.
|
||||
"""
|
||||
|
||||
# launch an app with invoker --delay n
|
||||
print "launching fala_ft_hello ..."
|
||||
p = Popen(['/usr/bin/invoker', '--delay', '10', '--type=m', '--no-wait',
|
||||
'/usr/bin/fala_ft_hello.launch'],
|
||||
shell=False,
|
||||
stdout=DEV_NULL, stderr=DEV_NULL)
|
||||
|
||||
# wait a little
|
||||
print "waiting ..."
|
||||
time.sleep(5)
|
||||
|
||||
success = True
|
||||
|
||||
if p.poll() == None:
|
||||
print "NOT DEAD"
|
||||
else:
|
||||
print "DEAD"
|
||||
success = False
|
||||
|
||||
print "waiting for invoker to terminate ..."
|
||||
p.wait()
|
||||
|
||||
print "terminating fala_ft_hello ..."
|
||||
Popen(['pkill', 'fala_ft_hello']).wait()
|
||||
|
||||
self.assert_(success, "invoker terminated before delay elapsed")
|
||||
|
||||
|
||||
def test_014_fd_booster_m(self):
|
||||
"""
|
||||
File descriptor test for booster-m
|
||||
"""
|
||||
count = get_file_descriptor("booster-m","m")
|
||||
self.assert_(count != 0, "None of the file descriptors were changed")
|
||||
|
||||
def test_015_fd_booster_q(self):
|
||||
"""
|
||||
File descriptor test for booster-q
|
||||
"""
|
||||
count = get_file_descriptor("booster-q","qt")
|
||||
self.assert_(count != 0, "None of the file descriptors were changed")
|
||||
|
||||
def test_016_restart_booster(self):
|
||||
"""
|
||||
Test that booster is restarted if it is killed
|
||||
"""
|
||||
#get the pids of boosters and make sure they are running
|
||||
qpid = get_pid('booster-q')
|
||||
print "Pid of booster-q before killing :%s" %qpid
|
||||
self.assert_(qpid != None, "No booster process running")
|
||||
|
||||
mpid = get_pid('booster-m')
|
||||
print "Pid of booster-m before killing :%s" %mpid
|
||||
self.assert_(mpid != None, "No booster process running")
|
||||
|
||||
#Kill the booster processes
|
||||
kill_process(apppid=qpid)
|
||||
kill_process(apppid=mpid)
|
||||
|
||||
#wait for the boosters to be restarted
|
||||
time.sleep(6)
|
||||
|
||||
#check that the new boosters are started
|
||||
qpid_new = get_pid('booster-q')
|
||||
print "Pid of booster-q after killing :%s" %qpid_new
|
||||
self.assert_(qpid_new != None, "No booster process running")
|
||||
self.assert_(qpid_new != qpid, "booster process was not killed")
|
||||
|
||||
mpid_new = get_pid('booster-m')
|
||||
print "Pid of booster-m after killing :%s" %mpid_new
|
||||
self.assert_(mpid_new != None, "No booster process running")
|
||||
self.assert_(mpid_new != mpid, "booster process was not killed")
|
||||
|
||||
def test_017_invoker_exit_status(self):
|
||||
"""
|
||||
To test that invoker returns the same exit status as the application
|
||||
"""
|
||||
#Run application without invoker and get the exit status
|
||||
st, op = commands.getstatusoutput('/usr/bin/fala_status.launch')
|
||||
app_st_wo_inv = os.WEXITSTATUS(st)
|
||||
|
||||
#Run application with invoker and get the exit status
|
||||
st, op = commands.getstatusoutput('invoker --type=m --wait-term /usr/bin/fala_status.launch')
|
||||
app_st_w_inv = os.WEXITSTATUS(st)
|
||||
|
||||
self.assert_(app_st_wo_inv == app_st_w_inv, "The invoker returns a wrong exit status")
|
||||
|
||||
def test_018_invoker_gid_uid(self):
|
||||
"""
|
||||
To Test that the set gid and uid is passed from invoker process to launcher
|
||||
"""
|
||||
#get the id in user mode
|
||||
print ("In User Mode \n")
|
||||
st, op = commands.getstatusoutput('su user -c ' "id")
|
||||
usr_id1 = op.split(' ')[0].split('(')[0]
|
||||
grp_id1 = op.split(' ')[1].split('(')[0]
|
||||
print("System %s \nSyetem %s" %(usr_id1, grp_id1))
|
||||
|
||||
#get id by running the application using invoker in user mode
|
||||
app = "invoker --type=m --no-wait /usr/bin/fala_status.launch"
|
||||
st, op = commands.getstatusoutput('su user -c "%s"' %app );
|
||||
usr_id = op.split('\n')[1]
|
||||
grp_id = op.split('\n')[2]
|
||||
print("Invoker %s \nInvoker %s" %(usr_id, grp_id))
|
||||
|
||||
#get id by running the application without invoker in user mode
|
||||
app = "/usr/bin/fala_status.launch"
|
||||
st, op = commands.getstatusoutput('su user -c "%s"' %app );
|
||||
usr_id2 = op.split('\n')[-2]
|
||||
grp_id2 = op.split('\n')[-1]
|
||||
print("Application %s \nApplication %s" %(usr_id2, grp_id2))
|
||||
|
||||
self.assert_(usr_id == usr_id1, "The correct UID is not passed by invoker")
|
||||
self.assert_(grp_id == grp_id1, "The correct GID is not passed by invoker")
|
||||
|
||||
self.assert_(usr_id == usr_id2, "The correct UID is not passed by invoker")
|
||||
self.assert_(grp_id == grp_id2, "The correct GID is not passed by invoker")
|
||||
|
||||
#get the id in root mode
|
||||
print ("In Root Mode \n")
|
||||
st, op = commands.getstatusoutput("id")
|
||||
usr_id1 = op.split(' ')[0].split('(')[0]
|
||||
grp_id1 = op.split(' ')[1].split('(')[0]
|
||||
print("System %s \nSyetem %s" %(usr_id1, grp_id1))
|
||||
|
||||
#get id by running the application using invoker in root mode
|
||||
app = "invoker --type=m --no-wait /usr/bin/fala_status.launch"
|
||||
st, op = commands.getstatusoutput("%s" %app );
|
||||
usr_id = op.split('\n')[1]
|
||||
grp_id = op.split('\n')[2]
|
||||
print("Invoker %s \nInvoker %s" %(usr_id, grp_id))
|
||||
|
||||
#get id by running the application without invoker in root mode
|
||||
app = "/usr/bin/fala_status.launch"
|
||||
st, op = commands.getstatusoutput("%s" %app );
|
||||
usr_id2 = op.split('\n')[-2]
|
||||
grp_id2 = op.split('\n')[-1]
|
||||
print("Application %s \nApplication %s" %(usr_id2, grp_id2))
|
||||
|
||||
self.assert_(usr_id == usr_id1, "The correct UID is not passed by invoker")
|
||||
self.assert_(grp_id == grp_id1, "The correct GID is not passed by invoker")
|
||||
|
||||
self.assert_(usr_id == usr_id2, "The correct UID is not passed by invoker")
|
||||
self.assert_(grp_id == grp_id2, "The correct GID is not passed by invoker")
|
||||
|
||||
|
||||
def test_019_signal_forwarding(self):
|
||||
"""
|
||||
To test that invoker is killed by the same signal as the application
|
||||
"""
|
||||
#Test for m-booster
|
||||
st, op = commands.getstatusoutput("/usr/share/applauncherd-M-testscripts/signal-forward/fala_sf_m.py")
|
||||
print ("The Invoker killed by : %s" %op)
|
||||
|
||||
self.assert_(op == 'Segmentation fault (core dumped)', "The invoker(m-booster) was not killed by the same signal")
|
||||
time.sleep(2)
|
||||
|
||||
#This case is launching the application in user mode
|
||||
#Test for q-booster
|
||||
st, op = commands.getstatusoutput("/usr/share/applauncherd-M-testscripts/signal-forward/fala_sf_qt.py")
|
||||
print ("The Invoker killed by : %s" %op.split('\n')[-1])
|
||||
|
||||
self.assert_(op.split('\n')[-1] == 'Aborted (core dumped)', "The invoker(q-booster) was not killed by the same signal")
|
||||
time.sleep(2)
|
||||
|
||||
def test_020_launch_wo_applauncherd(self):
|
||||
"""
|
||||
To Test that invoker can launch applications even when the
|
||||
applauncherd is not running
|
||||
"""
|
||||
|
||||
stop_applauncherd()
|
||||
|
||||
handle = run_app_as_user('fala_ft_hello')
|
||||
time.sleep(3)
|
||||
pid1 = get_pid('fala_ft_hello')
|
||||
|
||||
self.assert_(pid1 != None, "Application wasn't executed")
|
||||
|
||||
kill_process('fala_ft_hello')
|
||||
|
||||
start_applauncherd()
|
||||
|
||||
def test_invoker_search_prog(self):
|
||||
"""
|
||||
Test that invoker can find programs from directories listed in
|
||||
PATH environment variable and that it doesn't find something
|
||||
that isn't there.
|
||||
"""
|
||||
|
||||
# invoker searches PATH for the executable
|
||||
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")
|
||||
kill_process('fala_ft_hello')
|
||||
|
||||
# launch with relative path
|
||||
cwd = os.getcwd()
|
||||
os.chdir('/usr/share')
|
||||
|
||||
p = run_app_as_user('invoker --type=m --no-wait ' +
|
||||
"../bin/fala_ft_hello.launch")
|
||||
self.assert_(p.wait() == 0, "Couldnt launch fala_ft_hello.launch" +
|
||||
" with relative path")
|
||||
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
|
||||
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")
|
||||
kill_process('spam_cake')
|
||||
|
||||
def test_booster_killed_or_restarted(self):
|
||||
"""
|
||||
Test that boosters are killed if applauncherd is stopped
|
||||
and restarted if applauncherd is killed
|
||||
"""
|
||||
#get the pids of boosters and make sure they are running
|
||||
qpid = get_pid('booster-q')
|
||||
print "Pid of booster-q before killing :%s" %qpid
|
||||
self.assert_(qpid != None, "No booster process running")
|
||||
|
||||
mpid = get_pid('booster-m')
|
||||
print "Pid of booster-m before killing :%s" %mpid
|
||||
self.assert_(mpid != None, "No booster process running")
|
||||
|
||||
#stop applauncherd
|
||||
os.system("initctl stop xsession/applauncherd")
|
||||
|
||||
#wait for the boosters to be killed
|
||||
time.sleep(2)
|
||||
|
||||
#check that the none of the booster is running
|
||||
qpid_new = get_pid('booster-q')
|
||||
print "Pid of booster-q after killing :%s" %qpid_new
|
||||
self.assert_(qpid_new == None, "booster-q still running")
|
||||
|
||||
mpid_new = get_pid('booster-m')
|
||||
print "Pid of booster-m after killing :%s" %mpid_new
|
||||
self.assert_(mpid_new == None, "booster-m still running")
|
||||
|
||||
#Now start the applauncherd
|
||||
os.system("initctl start xsession/applauncherd")
|
||||
|
||||
#wait for the boosters to be restarted
|
||||
time.sleep(6)
|
||||
|
||||
#get the pids of boosters and make sure they are running
|
||||
qpid = get_pid('booster-q')
|
||||
print "Pid of booster-q before killing :%s" %qpid
|
||||
self.assert_(qpid != None, "No booster process running")
|
||||
|
||||
mpid = get_pid('booster-m')
|
||||
print "Pid of booster-m before killing :%s" %mpid
|
||||
self.assert_(mpid != None, "No booster process running")
|
||||
|
||||
#Now kill applauncherd
|
||||
kill_process('applauncherd')
|
||||
|
||||
#wait for the boosters to be restarted
|
||||
time.sleep(6)
|
||||
|
||||
#check that the new boosters are started
|
||||
qpid_new = get_pid('booster-q')
|
||||
print "Pid of booster-q after killing :%s" %qpid_new
|
||||
self.assert_(qpid_new != None, "No booster process running")
|
||||
self.assert_(qpid_new != qpid, "booster process was not killed")
|
||||
|
||||
mpid_new = get_pid('booster-m')
|
||||
print "Pid of booster-m after killing :%s" %mpid_new
|
||||
self.assert_(mpid_new != None, "No booster process running")
|
||||
self.assert_(mpid_new != mpid, "booster process was not killed")
|
||||
|
||||
# main
|
||||
if __name__ == '__main__':
|
||||
# When run with testrunner, for some reason the PATH doesn't include
|
||||
# the tools/bin directory
|
||||
if os.getenv('_SBOX_DIR') != None:
|
||||
os.environ['PATH'] = os.getenv('PATH') + ":" + os.getenv('_SBOX_DIR') + '/tools/bin'
|
||||
using_scratchbox = True
|
||||
|
||||
check_prerequisites()
|
||||
start_launcher_daemon()
|
||||
tests = sys.argv[1:]
|
||||
mysuite = unittest.TestSuite(map(launcher_tests, tests))
|
||||
result = unittest.TextTestRunner(verbosity=2).run(mysuite)
|
||||
if not result.wasSuccessful():
|
||||
sys.exit(1)
|
||||
sys.exit(0)
|
||||
@ -1,180 +0,0 @@
|
||||
#!/usr/bin/ruby
|
||||
# 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 = 3
|
||||
APP_WITH_LAUNCHER = 'fala_wl'
|
||||
APP_WITHOUT_LAUNCHER = 'fala_wol'
|
||||
PIXELCHANGED_BINARY= '/usr/bin/fala_pixelchanged'
|
||||
TEST_SCRIPT_LOCATION = '/usr/share/applauncherd-M-testscripts'
|
||||
PIXELCHANGED_LOG = '/tmp/fala_pixelchanged.log'
|
||||
@start_time = 0
|
||||
@end_time = 0
|
||||
@pos = 0
|
||||
|
||||
$path = string = `echo $PATH `
|
||||
|
||||
# method called before any test case
|
||||
def setup
|
||||
|
||||
@sut = TDriver.sut(:Id=> 'sut_qt_maemo')
|
||||
if $path.include?("scratchbox")
|
||||
puts "Inside SB, Do Nothing to unlock"
|
||||
else
|
||||
system "mcetool --set-tklock-mode=unlocked"
|
||||
|
||||
# restart duihome so that qttasserver notices it
|
||||
# NOTE: Remove the cludge after duihome -> meegotouchhome renaming is complete
|
||||
if not system("/sbin/initctl restart xsession/duihome")
|
||||
system("/sbin/initctl restart xsession/mthome")
|
||||
end
|
||||
|
||||
system("initctl stop xsession/sysuid")
|
||||
system("initctl stop xsession/applifed")
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
# method called after any test case for cleanup purposes
|
||||
def teardown
|
||||
puts "exit from teardown"
|
||||
system("initctl start xsession/sysuid")
|
||||
system("initctl start xsession/applifed")
|
||||
end
|
||||
|
||||
def open_Apps(appName)
|
||||
#Remove the Log file if it exists
|
||||
if FileTest.exists?(PIXELCHANGED_LOG)
|
||||
system "rm #{PIXELCHANGED_LOG}"
|
||||
end
|
||||
appOnTop = @sut.application()
|
||||
while appOnTop.attribute('objectName') != 'meegotouchhome'
|
||||
fullName = appOnTop.attribute('FullName')
|
||||
puts "Now killing #{fullName} from the top"
|
||||
system "pkill #{fullName}"
|
||||
appOnTop = @sut.application()
|
||||
end
|
||||
|
||||
#Open the Application from the application grid
|
||||
begin
|
||||
@meegoHome = @sut.application(:name => 'duihome')
|
||||
rescue MobyBase::TestObjectNotFoundError
|
||||
@meegoHome = @sut.application(:name => 'meegotouchhome')
|
||||
end
|
||||
|
||||
sleep(2)
|
||||
if @meegoHome.test_object_exists?("LauncherButton", :text => appName)
|
||||
icon = @meegoHome.LauncherButton(:name => "LauncherButton", :text => appName)
|
||||
while icon.attribute('visibleOnScreen') == 'false'
|
||||
@meegoHome.Launcher.MPannableViewport( :name => 'SwipePage' ).MWidget( :name => 'glass' ).gesture(:Up, 1, 300)
|
||||
sleep(0.2)
|
||||
icon.refresh
|
||||
end
|
||||
xpos = @meegoHome.LauncherButton(:name => "LauncherButton", :text => appName).attribute('x')
|
||||
ypos = @meegoHome.LauncherButton(:name => "LauncherButton", :text => appName).attribute('y')
|
||||
@pos = "#{xpos}x#{ypos}"
|
||||
|
||||
puts @pos
|
||||
sleep (2)
|
||||
system "#{PIXELCHANGED_BINARY} -c #{@pos} -f #{PIXELCHANGED_LOG} -q"
|
||||
sleep (4)
|
||||
system "pkill #{appName}"
|
||||
else
|
||||
#icon does not
|
||||
#raise error and exit
|
||||
raise "Application not found in Application grid"
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
|
||||
def read_file(appName)
|
||||
#Reading the log file to get the time
|
||||
|
||||
lines = File.open(PIXELCHANGED_LOG).readlines().collect { |x| x.split(" ")[0].to_i }
|
||||
|
||||
# First line tells when the button is released
|
||||
@start_time = lines[0]
|
||||
puts "Line1: #{lines[0]}"
|
||||
# Second one when the first pixel has changed its color
|
||||
@end_time = lines[1]
|
||||
puts "Line2: #{lines[1]}"
|
||||
|
||||
end
|
||||
|
||||
|
||||
def measure_time
|
||||
#Measuring the Startup Time for applications
|
||||
app_t = @end_time - @start_time
|
||||
return app_t
|
||||
end
|
||||
|
||||
def test_performance
|
||||
wL = []
|
||||
woL = []
|
||||
wLsum = 0
|
||||
woLsum = 0
|
||||
|
||||
#Run Application with invoker
|
||||
for i in 1..COUNT
|
||||
print "Now Launching #{APP_WITH_LAUNCHER} %d times\n" %i
|
||||
open_Apps(APP_WITH_LAUNCHER)
|
||||
sleep (5)
|
||||
read_file(APP_WITH_LAUNCHER)
|
||||
wL.push(measure_time)
|
||||
end
|
||||
|
||||
|
||||
#Run Application without invoker
|
||||
for i in 1..COUNT
|
||||
print "Now Launching #{APP_WITHOUT_LAUNCHER} %d times\n" %i
|
||||
open_Apps(APP_WITHOUT_LAUNCHER)
|
||||
sleep (5)
|
||||
read_file(APP_WITHOUT_LAUNCHER)
|
||||
woL.push(measure_time)
|
||||
end
|
||||
print "Startup time in milliseconds\n"
|
||||
print "With Launcher \t\t Without Launcher\n"
|
||||
|
||||
#Printing the data
|
||||
for i in 0..COUNT-1
|
||||
print "%d \t\t\t %d\n" %[wL[i],woL[i]]
|
||||
wLsum = wLsum + wL[i]
|
||||
woLsum = woLsum + woL[i]
|
||||
end
|
||||
print "\nAverage Values \n"
|
||||
print "%d \t\t\t %d\n\n" %[wLsum/COUNT, woLsum/COUNT]
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
@ -1,77 +0,0 @@
|
||||
#!/usr/bin/ruby
|
||||
#
|
||||
# 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: Testcases for the prestart functionality
|
||||
#
|
||||
# * Objectives: Test that a prestarted application can be
|
||||
# launched as well
|
||||
|
||||
require 'tdriver'
|
||||
require 'date'
|
||||
require 'test/unit'
|
||||
include TDriverVerify
|
||||
|
||||
# When run by testrunner in scratchbox, the PATH environment variable
|
||||
# is missing some vital entries ...
|
||||
if ENV.has_key?('_SBOX_DIR')
|
||||
ENV['PATH'] += ":" + ENV['_SBOX_DIR'] + "/tools/bin"
|
||||
end
|
||||
|
||||
class TC_PRESTARTLAUNCHTESTS < Test::Unit::TestCase
|
||||
|
||||
# method called before any test case
|
||||
def setup
|
||||
system "mcetool --set-tklock-mode=unlocked"
|
||||
system "initctl stop xsession/applifed"
|
||||
@sut = TDriver.sut(:Id=> 'sut_qt_maemo')
|
||||
end
|
||||
|
||||
# method called after any test case for cleanup purposes
|
||||
def teardown
|
||||
system "initctl start xsession/applifed"
|
||||
end
|
||||
|
||||
def test_launch_prestarted_app
|
||||
#Test that a prestarted application can be launched
|
||||
@appname = 'fala_testapp'
|
||||
if system("pgrep #{@appname}") == true
|
||||
system("kill -9 `pgrep #{@appname}`")
|
||||
end
|
||||
sleep 2
|
||||
verify_equal(false,2,"Application is Prestarted"){
|
||||
system "pgrep #{@appname}"}
|
||||
sleep 2
|
||||
|
||||
string = `export DISPLAY=:0; source /tmp/session_bus_address.user;dbus-send --dest=com.nokia.#{@appname} --type="method_call" /org/maemo/m com.nokia.MApplicationIf.ping`
|
||||
sleep 1
|
||||
|
||||
verify_equal(true,2,"Application is not Prestarted"){
|
||||
system "pgrep #{@appname}"}
|
||||
pid = string = `pgrep #{@appname}`
|
||||
sleep 1
|
||||
|
||||
string = `export DISPLAY=:0; source /tmp/session_bus_address.user;dbus-send --dest=com.nokia.#{@appname} --type="method_call" /org/maemo/m com.nokia.MApplicationIf.launch`
|
||||
@app = @sut.application( :name => 'fala_testapp' )
|
||||
@app.MButton( :name => 'CloseButton' ).tap
|
||||
newid = string = `pgrep #{@appname}`
|
||||
verify_true(30,"The application is not prestarted"){pid == newid}
|
||||
sleep 1
|
||||
system "kill -9 `pgrep #{@appname}`"
|
||||
end
|
||||
|
||||
end
|
||||
@ -1,198 +0,0 @@
|
||||
import os, os.path, glob
|
||||
import subprocess
|
||||
import commands
|
||||
import time
|
||||
import sys
|
||||
import re
|
||||
from subprocess import Popen
|
||||
from os.path import basename
|
||||
|
||||
DEV_NULL = file("/dev/null","w")
|
||||
|
||||
def debug(*msg):
|
||||
"""
|
||||
Debug function
|
||||
"""
|
||||
sys.stderr.write('[DEBUG %s] %s\n' % (time.ctime(), \
|
||||
' '.join([str(s) for s in msg]),))
|
||||
|
||||
def error(*msg):
|
||||
"""
|
||||
exit when error, give proper log
|
||||
"""
|
||||
sys.stderr.write('ERROR %s\n' % (' '.join([str(s) for s in msg]),))
|
||||
sys.exit(1)
|
||||
|
||||
def remove_applauncherd_runtime_files():
|
||||
"""
|
||||
Removes files that applauncherd leaves behind after it has been stopped
|
||||
"""
|
||||
|
||||
files = ["%s/applauncherd.lock" % (os.environ['XDG_RUNTIME_DIR'])]
|
||||
files += glob.glob('/tmp/boost*')
|
||||
|
||||
for f in files:
|
||||
print "removing %s" % f
|
||||
|
||||
try:
|
||||
os.remove(f)
|
||||
except:
|
||||
pass
|
||||
|
||||
def start_applauncherd():
|
||||
handle = Popen(['initctl', 'start', 'xsession/applauncherd'],
|
||||
stdout = DEV_NULL, stderr = DEV_NULL,
|
||||
shell = False)
|
||||
|
||||
return handle.wait() == 0
|
||||
|
||||
def kill_applauncherd():
|
||||
handle = Popen(['initctl', 'stop', 'xsession/applauncherd'],
|
||||
stdout = DEV_NULL, stderr = DEV_NULL,
|
||||
shell = False)
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
remove_applauncherd_runtime_files()
|
||||
|
||||
return handle.wait()
|
||||
|
||||
def restart_applauncherd():
|
||||
stop_applauncherd()
|
||||
start_applauncherd()
|
||||
|
||||
def run_app_as_user(appname, out = DEV_NULL, err = DEV_NULL):
|
||||
"""
|
||||
Runs the specified command as a user.
|
||||
"""
|
||||
|
||||
cmd = ['su', '-', 'meego', '-c']
|
||||
|
||||
if type(appname) == list:
|
||||
cmd += appname
|
||||
elif type(appname) == str:
|
||||
cmd.append(appname)
|
||||
else:
|
||||
raise TypeError("List or string expected")
|
||||
|
||||
p = subprocess.Popen(cmd, shell = False,
|
||||
stdout = out, stderr = err)
|
||||
return p
|
||||
|
||||
def get_pid(appname):
|
||||
temp = basename(appname)[:14]
|
||||
st, op = commands.getstatusoutput("pgrep %s" % temp)
|
||||
if st == 0:
|
||||
return op
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_newest_pid(appname):
|
||||
temp = basename(appname)[:14]
|
||||
st, op = commands.getstatusoutput("pgrep -n %s" % temp)
|
||||
time.sleep(5)
|
||||
if st == 0:
|
||||
return op
|
||||
else:
|
||||
return None
|
||||
|
||||
def wait_for_app(app = None, timeout = 5, sleep = 0.5):
|
||||
"""
|
||||
Waits for an application to start. Checks periodically if
|
||||
the app is running for a maximum wait set in timeout.
|
||||
|
||||
Returns the pid of the application if it was running before
|
||||
the timeout finished, otherwise None is returned.
|
||||
"""
|
||||
|
||||
pid = None
|
||||
start = time.time()
|
||||
|
||||
while pid == None and time.time() < start + timeout:
|
||||
pid = get_newest_pid(app)
|
||||
|
||||
if pid != None:
|
||||
break
|
||||
|
||||
print "waiting %s secs for %s" % (sleep, app)
|
||||
|
||||
time.sleep(sleep)
|
||||
|
||||
return pid
|
||||
|
||||
|
||||
def kill_process(appname=None, apppid=None, signum=9):
|
||||
if apppid and appname:
|
||||
return None
|
||||
else:
|
||||
if apppid:
|
||||
st, op = commands.getstatusoutput("kill -%s %s" % (str(signum), str(apppid)))
|
||||
if appname:
|
||||
temp = basename(appname)[:14]
|
||||
st, op = commands.getstatusoutput("pkill -%s %s" % (str(signum), temp))
|
||||
|
||||
try:
|
||||
os.wait()
|
||||
except Exception as e:
|
||||
print e
|
||||
|
||||
def process_state(processid):
|
||||
st, op = commands.getstatusoutput('cat /proc/%s/stat' %processid)
|
||||
if st == 0:
|
||||
return op
|
||||
else:
|
||||
debug(op)
|
||||
return None
|
||||
|
||||
def get_file_descriptor(booster, type):
|
||||
"""
|
||||
To test that file descriptors are closed before calling application main
|
||||
"""
|
||||
#get fd of booster before launching application
|
||||
pid = commands.getoutput("pgrep '%s$'" %booster)
|
||||
fd_info = commands.getoutput('ls -l /proc/%s/fd/' % str(pid))
|
||||
fd_info = fd_info.split('\n')
|
||||
init = {}
|
||||
final = {}
|
||||
|
||||
for fd in fd_info:
|
||||
if "->" in fd:
|
||||
init[fd.split(" -> ")[0].split(' ')[-1]] = fd.split(" -> ")[-1]
|
||||
print init
|
||||
|
||||
#launch application using booster
|
||||
st = os.system('invoker --type=%s --no-wait /usr/bin/fala_ft_hello.launch' %type)
|
||||
time.sleep(2)
|
||||
|
||||
#get fd of booster after launching the application
|
||||
if st == 0:
|
||||
fd_info = commands.getoutput('ls -l /proc/%s/fd/' % str(pid))
|
||||
fd_info = fd_info.split('\n')
|
||||
for fd in fd_info:
|
||||
if "->" in fd:
|
||||
final[fd.split(" -> ")[0].split(' ')[-1]] = fd.split(" -> ")[-1]
|
||||
print final
|
||||
pid = commands.getoutput('pgrep fala_ft_hello')
|
||||
|
||||
mykeys = init.keys()
|
||||
count = 0
|
||||
|
||||
for key in mykeys:
|
||||
try:
|
||||
if init[key] != final[key]:
|
||||
count = count + 1
|
||||
except KeyError:
|
||||
print "some key in init is not in final"
|
||||
time.sleep(2)
|
||||
print "The number of changed file descriptors %d" %count
|
||||
kill_process(apppid=pid)
|
||||
return count
|
||||
|
||||
def get_groups_for_user():
|
||||
# get supplementary groups user belongs to (doesn't return
|
||||
# the gid group)
|
||||
p = run_app_as_user('id -Gn', out = subprocess.PIPE)
|
||||
groups = p.communicate()[0].split()
|
||||
p.wait()
|
||||
|
||||
return groups
|
||||
Loading…
Reference in New Issue