Changes: new test case for /usr/lib trigger

RevBy: Olli Leppanen

new test package is added to test if reexec is triggered when a file is installed/modified/deleted in the /usr/lib directory and the test case is put in the red-tests
pull/1/head
Thyagarajan Balakrishnan 14 years ago
parent 6865c7da65
commit f0566a2774

1
debian/rules vendored

@ -50,6 +50,7 @@ install: build
DESTDIR=debian/tmp make install
cp tests/harmattan/testapps/applauncherd-token-test_1.0_armel.deb debian/tmp/usr/share/fala_images
cp tests/harmattan/testapps/applauncherd-usrlib-test_1.?_armel.deb debian/tmp/usr/share/fala_images
#tests/harmattan/testapps/applauncherd-token-test_1.0_armel.deb:
# cd tests/harmattan/testapps/applauncherd-token-test-1.0 && dpkg-buildpackage

@ -82,6 +82,9 @@
<case name="applauncherd__test_reexec_when_new_token_is_installed" type="Functional" description="Checks that when new application is installed (facebookqml) containing new security token, then applauncherd gains this new security token" timeout="200" level="System" insignificant="true">
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-security.py test_reexec_when_new_token_is_installed</step>
</case>
<case name="applauncherd__test_reexec_when_file_in_usrlib_modified" type="Functional" description="Test that reexec is triggered when a package modifies a file in /usr/lib" timeout="100" level="System" insignificant="true">
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_reexec_when_file_in_usrlib_modified</step>
</case>
<environments>
<scratchbox>false</scratchbox>
<hardware>true</hardware>

@ -0,0 +1,63 @@
## This file is part of test package applauncherd-token-test
#
# Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
# All rights reserved.
#
# Contact: Thyagarajan Balakrishnan <ext-thyagarajan.1.balakrishnan@nokia.com>
#
# This software, including documentation, is protected by copyright
# controlled by Nokia Corporation. All rights are reserved. Copying,
# including reproducing, storing, adapting or translating, any or all
# of this material requires the prior written consent of Nokia
# Corporation. This material also contains confidential information
# which may not be disclosed to others without the prior written
# consent of Nokia.
##
QMAKEVERSION = $$[QMAKE_VERSION]
ISQT4 = $$find(QMAKEVERSION, ^[2-9])
isEmpty( ISQT4 ) {
error("Use the qmake include with Qt4.4 or greater, on Debian that is qmake-qt4");
}
QT += core
QT -= gui
TARGET = fala-usrlib-test-app
TEMPLATE = app
CONFIG += warn_on link_pkgconfig
CONFIG += console
CONFIG -= app_bundle
DESTDIR = bin
OBJECTS_DIR = obj
MOC_DIR = obj
SOURCES += main.cpp
# Flags to reduce binary size where possible
QMAKE_CXXFLAGS += -fdata-sections -ffunction-sections
QMAKE_LFLAGS += --discard-local --discard-all -Wl --gc-sections
QMAKE_CXXFLAGS -= -O2
QMAKE_CXXFLAGS += -Os
unix {
#VARIABLES
isEmpty(PREFIX) {
PREFIX = /usr
}
BINDIR = $$PREFIX/bin
LIBDIR =$$PREFIX/lib
DEFINES += DATADIR=\\\"$$DATADIR\\\" PKGDATADIR=\\\"$$PKGDATADIR\\\"
#MAKE INSTALL
INSTALLS += target usrlib
target.path =$$BINDIR
usrlib.files = applauncherd-usrlib-test.txt
usrlib.path = /usr/lib
}

@ -0,0 +1,4 @@
File to test triggering of applauncherd when a new file in /usr/lib is added
version 1.1: test for file being modified

@ -0,0 +1,6 @@
The Debian Package applauncherd-usrlib-test
----------------------------
This package is used to test that applauncherd is triggered for re-exec when installed application is adding/modifying a file in /usr/lib directory.
-- Thyagarajan Balakrishnan <ext-thyagarajan.1.balakrishnan@nokia.com> Wed, 09 Nov 2011 16:05:43 +0200

@ -0,0 +1,11 @@
applauncherd-usrlib-test (1.1) stable; urgency=low
* test for upgrade.
-- Thyagarajan Balakrishnan <ext-thyagarajan.1.balakrishnan@nokia.com> Thu, 10 Nov 2011 16:05:43 +0200
applauncherd-usrlib-test (1.0) stable; urgency=low
* Initial Release.
-- Thyagarajan Balakrishnan <ext-thyagarajan.1.balakrishnan@nokia.com> Wed, 09 Nov 2011 16:05:43 +0200

@ -0,0 +1,21 @@
Source: applauncherd-usrlib-test
Section: unknown
Priority: extra
Maintainer: Thyagarajan Balakrishnan <ext-thyagarajan.1.balakrishnan@nokia.com>
Build-Depends: pkg-config, debhelper (>= 7.0.50~), libqt4-dev, applauncherd
Standards-Version: 3.9.1
Package: applauncherd-usrlib-test
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, libqt4-core, libqtgui4, applauncherd, libmeegotouchcore0
Description: Application tests applauncherd reexec for new files in /usr/lib
This application is used to test that installation of new files in /usr/lib
triggers reexec in applauncherd
#Package: applauncherd-usrlib-test-dbg
#Architecture: devel
#Depends: ${shlibs:Depends}, ${misc:Depends}, libqt4-core, libqtgui4, applauncherd, libmeegotouchcore0, applauncherd-usrlib-test (= ${binary:Version})
#Description: Application tests applauncherd reexec for new files in /usr/lib
# This application is used to test that installation of new files in /usr/lib
# triggers reexec in applauncherd. - with debug symbols

@ -0,0 +1,16 @@
This work was packaged for Debian by:
Thyagarajan Balakrishnan <ext-thyagarajan.1.balakrishnan@nokia.com> Wed, 09 Nov 2011 16:05:43 +0200
Copyright:
Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
All rights reserved.
This software, including documentation, is protected by copyright
controlled by Nokia Corporation. All rights are reserved. Copying,
including reproducing, storing, adapting or translating, any or all
of this material requires the prior written consent of Nokia
Corporation. This material also contains confidential information
which may not be disclosed to others without the prior written
consent of Nokia.

@ -0,0 +1 @@
applauncherd-usrlib-test_1.1_armel.deb unknown extra

@ -0,0 +1,69 @@
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
CFLAGS = -Wall -g
APPNAME := applauncherd-usrlib-test
Makefile:
qmake-qt4
build: build-stamp
build-stamp: Makefile
dh_testdir
# Add here commands to compile the package.
$(MAKE)
touch $@
clean: Makefile
dh_testdir
dh_testroot
rm -f build-stamp
$(MAKE) clean
dh_clean
install:
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
# Add here commands to install the package into debian/your_appname
$(MAKE) INSTALL_ROOT=$(CURDIR)/debian/$(APPNAME) install
# Build architecture-independent files here.
binary-indep:
# We have nothing to do by default.
# Build architecture-dependent files here.
binary-arch: install
dh_testdir
dh_testroot
dh_installdocs
dh_installexamples
dh_installman
dh_link
# dh_strip --dbg-package=$(APPNAME)-dbg
dh_strip
dh_compress
dh_fixperms
dh_installdeb
dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure Makefile

@ -0,0 +1,9 @@
#include <QtCore/QCoreApplication>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
return a.exec();
}

@ -1007,6 +1007,83 @@ class launcher_tests (unittest.TestCase):
for pid in appList:
kill_process(apppid = pid[0])
def _test_reexec_remove_test_package(self, packageName):
st, op = commands.getstatusoutput('dpkg -r %s' %(packageName))
if st!=0 :
debug('Fail to remove "%s" package! Returned error code is: %s. '
'Check remove log:\n%s\n<<<<<<remove log.' %(packageName, st, op))
else :
debug('Uninstallation of "%s" was successful' %(packageName))
def _wait_and_check_for_new_boosters(self, oldBoosterPids, oldApplauncherPid):
wait_for_new_boosters(oldBoosterPids)
wait_for_single_applauncherd()
newBoosterPids = get_booster_pid()
num_of_same_pids = len(set(oldBoosterPids) & set(newBoosterPids))
self.assertEqual(num_of_same_pids, 0, "Boosters pids did not change")
newApplauncherPid = wait_for_single_applauncherd()
self.assertEqual(oldApplauncherPid, newApplauncherPid,
"applauncherd has crashed. Its pid has changed from "
"%s to %s." %(oldApplauncherPid, newApplauncherPid))
return (newApplauncherPid, newBoosterPids)
def test_reexec_when_file_in_usrlib_modified(self) :
"""
Checks that when a file is installed/modified/removed from /usr/lib
trigger is activated and sighup is send to applauncherd.
"""
packageFileName = '/usr/share/fala_images/applauncherd-usrlib-test_1.0_armel.deb'
updatePackageFileName = '/usr/share/fala_images/applauncherd-usrlib-test_1.1_armel.deb'
packageName = 'applauncherd-usrlib-test'
applauncherPid = wait_for_single_applauncherd()
boosterPids = get_booster_pid()
#check that test package is NOT installed
installed = isPackageInstalled(packageName)
if (installed) :
debug('Tested package "%s" is installed, removing it.' %(packageName))
self._test_reexec_remove_test_package(packageName)
wait_for_new_boosters(boosterPids)
applauncherPid = wait_for_single_applauncherd()
boosterPids = get_booster_pid()
try:
#real test starts here
debug('Installing test package "%s"...' %(packageName))
debug('This installs new file to /usr/lib/')
st, op = commands.getstatusoutput('dpkg -i %s' %(packageFileName))
self.assertEqual(st, 0, 'Installation of "%s" failed see:\n%s' %(packageName, op))
debug('...Installation was successful.')
applauncherPid, boosterPids = self._wait_and_check_for_new_boosters(boosterPids, applauncherPid)
debug('Upgrading test package to "%s"' % (updatePackageFileName))
debug('This modifies the file existing in /usr/lib/ to a new verison')
st, op = commands.getstatusoutput('dpkg -i %s' %(updatePackageFileName))
self.assertEqual(st, 0, 'Upgrading of "%s" failed see:\n%s' %(packageName, op))
debug('...Upgrading was successful.')
applauncherPid, boosterPids = self._wait_and_check_for_new_boosters(boosterPids, applauncherPid)
debug('Downgrading test package to "%s"' % (packageFileName))
debug('This modifies the file existing in /usr/lib/ to a old verison')
st, op = commands.getstatusoutput('dpkg -i %s' %(packageFileName))
self.assertEqual(st, 0, 'Downgrading of "%s" failed see:\n%s' %(packageName, op))
debug('...Downgrading was successful.')
applauncherPid, boosterPids = self._wait_and_check_for_new_boosters(boosterPids, applauncherPid)
except:
debug('Restoring system to initial state: removing test package after test was asserted.')
self._test_reexec_remove_test_package(packageName)
raise
# now remove the package
debug('Uninstalling test package "%s"...' %(packageName))
debug('This deletes the file from /usr/lib')
self._test_reexec_remove_test_package(packageName)
applauncherPid, boosterPids = self._wait_and_check_for_new_boosters(boosterPids, applauncherPid)
# main
if __name__ == '__main__':

@ -125,9 +125,10 @@ def run_cmd_as_user(cmnd, out = DEV_NULL, err = DEV_NULL):
stdout = out, stderr = err)
return p
def get_pid(appname):
def get_pid(appname, printdebug=True):
temp = basename(appname)[:14]
st, op = commands.getstatusoutput("pgrep %s" % temp)
if(printdebug):
debug("The Pid of %s is %s" %(appname, op))
if st == 0:
return op
@ -186,19 +187,17 @@ def wait_for_app(app = None, timeout = 40, sleep = 1):
return pid
def wait_for_single_applauncherd(timeout = 20, sleep = 1):
pid = get_pid('applauncherd')
pid = get_pid('applauncherd', False)
count = len(pid.split("\n"))
start = time.time()
while count > 1 and time.time() < start + timeout:
debug("waiting %s secs for single applauncherd" %sleep)
time.sleep(sleep)
pid = get_pid('applauncherd')
pid = get_pid('applauncherd', False)
count = len(pid.split("\n"))
if count == 1:
break
debug("got single applauncherd pid %s in %.1fs" % (pid, time.time()-start))
return pid
def get_booster_pid(timeout = 20):
@ -356,18 +355,17 @@ def get_groups_for_user():
return groups
def send_sighup_to_applauncherd():
#checks if there is a change in booster pids until 5 seconds
def wait_for_new_boosters(ref_pids):
boosterpids2 = ref_pids
def wait_for_new_boosters(old_booster_pids):
new_booster_pids = old_booster_pids
for count in range(4):
boosterpids2 = get_pid('booster')
if(ref_pids != boosterpids2):
new_booster_pids = get_pid('booster')
if(old_booster_pids != new_booster_pids):
break
time.sleep(1)
return boosterpids2
return new_booster_pids
def send_sighup_to_applauncherd():
wait_for_single_applauncherd()
(e1, d1, q1, m1) = get_booster_pid()
launcher_pid1 = get_oldest_pid('applauncherd')
@ -410,3 +408,11 @@ def wait_for_windows(windowName, minCount=1, timeout=20) :
op = None
return op
def isPackageInstalled(packageName):
st, op = commands.getstatusoutput("dpkg -l %s" % packageName)
if(st == 0): # success, check if version is "<none>" or a valid version
m = re.search('.*%s\s*(\S*)\s*.*'%packageName, op)
if(m and m.group(1).find("none")==-1): #m.group(1) contains version
return True
return False

Loading…
Cancel
Save