Merge lp:~gerboland/unity-2d/fix-unit-tests into lp:unity-2d

Proposed by Gerry Boland
Status: Merged
Approved by: Tiago Salem Herrmann
Approved revision: 803
Merged at revision: 793
Proposed branch: lp:~gerboland/unity-2d/fix-unit-tests
Merge into: lp:unity-2d
Diff against target: 134 lines (+54/-10)
5 files modified
launcher/tests/CMakeLists.txt (+5/-2)
libunity-2d-private/tests/CMakeLists.txt (+26/-7)
libunity-2d-private/tests/unity2dtrtest.sh.in (+1/-0)
panel/tests/CMakeLists.txt (+3/-1)
tests/run-with-xvfb.sh (+19/-0)
To merge this branch: bzr merge lp:~gerboland/unity-2d/fix-unit-tests
Reviewer Review Type Date Requested Status
Tiago Salem Herrmann (community) Approve
Review via email: mp+83294@code.launchpad.net

Commit message

[tests] Run Unit Tests with Xvfb, disabling those who will not work with this configuration

Description of the change

[tests] Run Unit Tests with Xvfb, disabling those who will not work with this configuration:

- paneltest - Xvfb appears to not support Struts, so it fails
- gnomesessiontest - needs to be rewritten to use a mock gnome-session dbus object with dbus-test-runner

To post a comment you must log in.
Revision history for this message
Gerry Boland (gerboland) wrote :

Note that LauncherViewTest will hang, see bug:894380. There is a separate MR in the queue which proposes a fix for this, and causes "make check" to succeed.

Revision history for this message
Tiago Salem Herrmann (tiagosh) wrote :

some tests:

salem@salem-linux:/tmp/fix-unit-tests/build$ /usr/bin/ctest --force-new-ctest-process
Test project /tmp/fix-unit-tests/build
    Start 1: gconnectortest
1/8 Test #1: gconnectortest ................... Passed 0.09 sec
    Start 2: keyboardmodifiersmonitortest
2/8 Test #2: keyboardmodifiersmonitortest ..... Passed 1.81 sec
    Start 3: launchermenutest
3/8 Test #3: launchermenutest ................. Passed 0.14 sec
    Start 4: listaggregatormodeltest
4/8 Test #4: listaggregatormodeltest .......... Passed 0.10 sec
    Start 5: qsortfilterproxymodeltest
5/8 Test #5: qsortfilterproxymodeltest ........ Passed 0.09 sec
    Start 6: focuspathtest
6/8 Test #6: focuspathtest .................... Passed 0.24 sec
    Start 7: unity2dtrtest_check
7/8 Test #7: unity2dtrtest_check ..............***Failed 0.00 sec
    Start 8: launcherviewtest

unity2dtrtest_check fails and launcherviewtest is not exiting.

Revision history for this message
Gerry Boland (gerboland) wrote :

Unity2dtrtest fixed.
Launcherviewtest hang is known condition, see first comment

I forgot to say, please make sure you test the Xvfb part. You must install Xvfb, then run

DISPLAY= make check

to make the test run headless, i.e.pretend there is no Xserver.

Revision history for this message
Tiago Salem Herrmann (tiagosh) wrote :

Now it works fine. Thanks.

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity-2d/1/console reported an error when processing this lp:~gerboland/unity-2d/fix-unit-tests branch.
Not merging it.

800. By Gerry Boland

Merged latest trunk

801. By Gerry Boland

[tests] Add LANG variable to unity2dtrtest to fix test on Jenkins

802. By Gerry Boland

[tests] Disable LauncherViewTest, need to add a mock dbus-server so that it works with Jenkins

Revision history for this message
Gerry Boland (gerboland) wrote :

Branch fixed to work with Jenkins as follows:
- unity2dtr was not called with correct environment variable LANG
- disabling LauncherViewTest as it needs a mock dbus-server object to run.

803. By Gerry Boland

[tests] Disable unity2dtr test as it fails on Jenkins

Jenkins' chroot does not have any language support installed, so this test fails.

Revision history for this message
Tiago Salem Herrmann (tiagosh) wrote :

looks ok. A quick test of "make check" in my environment worked fine also.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/tests/CMakeLists.txt'
2--- launcher/tests/CMakeLists.txt 2011-11-18 12:27:01 +0000
3+++ launcher/tests/CMakeLists.txt 2011-11-28 14:11:27 +0000
4@@ -1,7 +1,9 @@
5 macro(launcher_tests)
6 set(_test_list "")
7 foreach(_test ${ARGN})
8- add_test(${_test} ${_test})
9+ add_test(NAME ${_test}
10+ COMMAND /bin/bash ${CMAKE_SOURCE_DIR}/tests/run-with-xvfb.sh ./${_test}
11+ )
12 add_executable(${_test} ${_test}.cpp ${_test}.moc)
13 qt4_generate_moc(${_test}.cpp ${_test}.moc)
14 target_link_libraries(${_test}
15@@ -21,6 +23,7 @@
16 )
17
18 launcher_tests(
19- launcherviewtest
20+# FIXME: test need a mock dbus object to message with via dbus-test-runner
21+# launcherviewtest
22 )
23
24
25=== modified file 'libunity-2d-private/tests/CMakeLists.txt'
26--- libunity-2d-private/tests/CMakeLists.txt 2011-11-23 14:04:19 +0000
27+++ libunity-2d-private/tests/CMakeLists.txt 2011-11-28 14:11:27 +0000
28@@ -12,11 +12,13 @@
29
30 set(LIBUNITY_2D_TEST_DIR ${libunity-2d-private_BINARY_DIR}/tests)
31
32-# Unit-tests
33+# Unit-tests (all run with Xvfb)
34 macro(libunity_2d_tests)
35 set(_test_list "")
36 foreach(_test ${ARGN})
37- add_test(${_test} ${_test})
38+ add_test(NAME ${_test}
39+ COMMAND /bin/bash ${CMAKE_SOURCE_DIR}/tests/run-with-xvfb.sh ./${_test}
40+ )
41 add_executable(${_test} ${_test}.cpp ${_test}.moc)
42 qt4_generate_moc(${_test}.cpp ${_test}.moc)
43 target_link_libraries(${_test}
44@@ -31,13 +33,29 @@
45 libunity_2d_tests(
46 gconnectortest
47 keyboardmodifiersmonitortest
48- paneltest
49- unity2dtrtest
50 launchermenutest
51 listaggregatormodeltest
52 qsortfilterproxymodeltest
53 focuspathtest
54 )
55+
56+# unity2dtrtest - FIXME
57+#add_test(NAME unity2dtrtest_check
58+# COMMAND /bin/sh unity2dtrtest.sh
59+# )
60+add_executable(unity2dtrtest
61+ unity2dtrtest.cpp unity2dtrtest.moc
62+ )
63+qt4_generate_moc(unity2dtrtest.cpp
64+ unity2dtrtest.moc
65+ )
66+target_link_libraries(unity2dtrtest
67+ ${QT_QTTEST_LIBRARIES}
68+ unity-2d-private
69+ unity-2d-private-qml
70+ )
71+configure_file(unity2dtrtest.sh.in
72+ unity2dtrtest.sh @ONLY)
73
74 add_custom_target(unity2dtr_po COMMAND
75 mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/locale/fr/LC_MESSAGES/
76@@ -60,9 +78,10 @@
77 configure_file(gnomesessionclienttest.sh.in
78 gnomesessionclienttest.sh @ONLY)
79
80-add_test(NAME gnomesessionclient_check
81- COMMAND /bin/sh gnomesessionclienttest.sh
82- )
83+#FIXME: rewrite this using dbus-test-runner to fake gnome-session messaging
84+#add_test(NAME gnomesessionclient_check
85+# COMMAND /bin/sh gnomesessionclienttest.sh
86+# )
87
88 # mouseareademo
89 add_executable(mouseareademo
90
91=== added file 'libunity-2d-private/tests/unity2dtrtest.sh.in'
92--- libunity-2d-private/tests/unity2dtrtest.sh.in 1970-01-01 00:00:00 +0000
93+++ libunity-2d-private/tests/unity2dtrtest.sh.in 2011-11-28 14:11:27 +0000
94@@ -0,0 +1,1 @@
95+LANG=fr_FR.UTF-8 LANGUAGE=fr_FR ./unity2dtrtest
96
97=== modified file 'panel/tests/CMakeLists.txt'
98--- panel/tests/CMakeLists.txt 2011-11-18 12:27:01 +0000
99+++ panel/tests/CMakeLists.txt 2011-11-28 14:11:27 +0000
100@@ -1,7 +1,9 @@
101 macro(panel_tests)
102 set(_test_list "")
103 foreach(_test ${ARGN})
104- add_test(${_test} ${_test})
105+ add_test(NAME ${_test}
106+ COMMAND /bin/bash ${CMAKE_SOURCE_DIR}/tests/run-with-xvfb.sh ${_test}
107+ )
108 add_executable(${_test} ${_test}.cpp ${_test}.moc)
109 qt4_generate_moc(${_test}.cpp ${_test}.moc)
110 target_link_libraries(${_test}
111
112=== added file 'tests/run-with-xvfb.sh'
113--- tests/run-with-xvfb.sh 1970-01-01 00:00:00 +0000
114+++ tests/run-with-xvfb.sh 2011-11-28 14:11:27 +0000
115@@ -0,0 +1,19 @@
116+#!/bin/bash
117+# Usage: /bin/bash run-with-xvfb.sh <program>
118+#
119+# Creates Xvfb instance and runs program in that instance. Shuts down Xvfb when done.
120+
121+if [ $# -ne 1 ]; then
122+ echo "Usage /bin/bash run-with-xvfb.sh <program>"
123+ exit 1
124+fi
125+
126+if [ "x$DISPLAY" == "x" ]; then
127+ Xvfb -ac -noreset -screen 0 1024x768x16 -help 2>/dev/null 1>&2
128+ XID=`for id in 101 102 103 104 105 106 107 197 199 211 223 227 293 307 308 309 310 311 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 4703 4721 4723 4729 4733 4751 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 ; do test -e /tmp/.X$id-lock || { echo $id; exit 0; }; done; echo "No Display ports available, quit."; exit 1`
129+ { Xvfb -ac -noreset -screen 0 1024x768x16 :$XID -screen 0 1024x768x16 -nolisten tcp -auth /dev/null >/dev/null 2>&1 & trap "kill -15 $! " 0 HUP INT QUIT TRAP USR1 PIPE TERM ; } || { echo "Gtk+Tests:ERROR: Failed to start Xvfb environment for X11 target tests."; exit 1; }
130+ DISPLAY=:$XID $1
131+else
132+ echo "Note: You are already running an Xserver."
133+ $1
134+fi

Subscribers

People subscribed via source and target branches