Merge lp:~compiz-team/compiz/compiz.fix_1120009.3 into lp:compiz/0.9.9

Proposed by Sam Spilsbury
Status: Superseded
Proposed branch: lp:~compiz-team/compiz/compiz.fix_1120009.3
Merge into: lp:compiz/0.9.9
Diff against target: 918 lines (+469/-145)
19 files modified
CMakeLists.txt (+38/-38)
cmake/CompizCommon.cmake (+18/-1)
cmake/FindGoogleTest.cmake (+46/-0)
cmake/FindXorgGTest.cmake (+43/-0)
cmake/GoogleTest.cmake (+20/-0)
cmake/XorgGTest.cmake (+14/-0)
cmake/src/compiz/CMakeLists.txt (+4/-0)
cmake/src/compiz/compiz_discover_gtest_tests.cpp (+36/-9)
debian/changelog (+20/-0)
debian/control (+3/-0)
debian/patches/ccp_plugin.patch (+49/-5)
debian/patches/ubuntu-config.patch (+24/-0)
tests/system/xorg-gtest/CMakeLists.txt (+3/-31)
tests/system/xorg-gtest/tests/CMakeLists.txt (+3/-3)
tests/system/xorg-gtest/tests/compiz_xorg_gtest_icccm.cpp (+0/-7)
tests/xorg-gtest/CMakeLists.txt (+52/-0)
tests/xorg-gtest/src/CMakeLists.txt (+2/-51)
tests/xorg-gtest/src/compiz-xorg-gtest.cpp (+1/-0)
tests/xorg-gtest/src/xorg_gtest_wrapper.cpp (+93/-0)
To merge this branch: bzr merge lp:~compiz-team/compiz/compiz.fix_1120009.3
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
MC Return Pending
Brandon Schaefer Pending
Review via email: mp+148729@code.launchpad.net

This proposal supersedes a proposal from 2013-02-15.

This proposal has been superseded by a proposal from 2013-02-15.

Commit message

Enable xorg-gtest tests by default and build in CI.

This change also refactors a number of parts of the code to find and build the tests. It puts the logic to find Google Test and Xorg GTest in their own cmake files, and also splits the find logic with the build logic. Finally, it makes the xorg-gtest variables available to all subdirectories and not just the ones under tests/.

This change also refreshes some distro patches. A new option was added to not auto-load the ccp plugin, and also modifies one of the tests depending on a modified setting value.

(LP: #1120009)

Description of the change

Enable xorg-gtest tests by default and build in CI.

This change also refactors a number of parts of the code to find and build the tests. It puts the logic to find Google Test and Xorg GTest in their own cmake files, and also splits the find logic with the build logic. Finally, it makes the xorg-gtest variables available to all subdirectories and not just the ones under tests/

This change also refreshes some distro patches. A new option was added to not auto-load the ccp plugin, and also modifies one of the tests depending on a modified setting value.

(LP: #1120009)

To post a comment you must log in.
Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

More useful tests can only be good.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote : Posted in a previous version of this proposal

Cool, looks good to me. Yay for fixing that mis leading warning message

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Argh. I thought we upgraded xorg-gtest in the distro to 0.8.

I'll have to leave this as WIP until that happens.

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Okay, I've been informed that we have 0.7 in the distro, and that is only in raring. I've bumped the required version and mmrazik has bumped the distro in CI.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Seems like the tests are failing because the xserver isn't sending back the events we expect. Debugging this now.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Okay, I think the cause of the failures was the ccp-autoloading distro patch. That was just causing problems with the child process, but our test framework doesn't handle the case of a crashing compiz yet. I've filed bug 1124843 about that.

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

(Resubmitted with the correct candidate branch)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Martin Mrazik (mrazik) wrote : Posted in a previous version of this proposal

I killed the previous job and triggered a new one to check if disabling tests on clang works.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

No problem, thanks for the update.

On Thu, Feb 14, 2013 at 4:46 PM, Martin Mrazik
<email address hidden> wrote:
> I killed the previous job and triggered a new one to check if disabling tests on clang works.
> --
> https://code.launchpad.net/~compiz-team/compiz/compiz.fix_1120009.3/+merge/148371
> Your team Compiz Maintainers is subscribed to branch lp:compiz.

--
Sam Spilsbury

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Okay, I've really gone thermonuclear on this. There was a race condition causing the memchecked tests to fail more often, and it turns out the XOpenDisplay here is inherently racey for some reason. So I've added a method to brute-force until we get a connection rather than just dying randomly. Its ugly, but it'll do. Also if you close the stdout weird stuff happens, so we're running the tests through a wrapper to not do that.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

The good news is that the xorg-gtest tests are now passing. Corrected a small error in the non xorg-gtest case.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
3568. By Sam Spilsbury

Let us know if we're running without ccp

3569. By Sam Spilsbury

Re-add the connection re-try logic

3570. By Sam Spilsbury

We already auto-add the ccp plugin in the source, no need for it to be
in the default plugins

3571. By Sam Spilsbury

Don't build xorg-gtest on ARM for now, as it doesn't compile

3572. By Sam Spilsbury

Merge lp:compiz

3573. By Sam Spilsbury

Also link in xext

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2013-02-13 13:55:52 +0000
3+++ CMakeLists.txt 2013-02-15 23:28:21 +0000
4@@ -22,6 +22,10 @@
5 # GSettings schema recompilation
6 include (CompizGSettings)
7
8+# Google Test and Xorg-GTest
9+include (GoogleTest)
10+include (XorgGTest)
11+
12 include (cmake/base.cmake)
13 # Check if specific function is present in library.
14 include (CheckFunctionExists)
15@@ -137,45 +141,41 @@
16
17 if (COMPIZ_BUILD_TESTING)
18
19- # Build Google Test and make its headers known
20- find_package (GTest)
21-
22- if (NOT GTEST_FOUND)
23-
24- # Check for google test and build it locally
25- set (GTEST_ROOT_DIR
26- "/usr/src/gtest" # Default value, adjustable by user with e.g., ccmake
27- CACHE
28- PATH
29- "Path to Google Test srcs"
30- FORCE
31- )
32-
33- find_path (GTEST_INCLUDE_DIR gtest/gtest.h)
34-
35- if (GTEST_INCLUDE_DIR)
36- add_subdirectory (${GTEST_ROOT_DIR}
37- gtest)
38- endif (GTEST_INCLUDE_DIR)
39-
40- set (GTEST_BOTH_LIBRARIES gtest gtest_main)
41- set (GTEST_FOUND TRUE)
42-
43- endif (NOT GTEST_FOUND)
44-
45- find_library (GMOCK_LIBRARY gmock)
46- find_library (GMOCK_MAIN_LIBRARY gmock_main)
47-
48- if (NOT GMOCK_LIBRARY OR NOT GMOCK_MAIN_LIBRARY OR NOT GTEST_FOUND)
49-
50- message ("Google Mock and Google Test not found - cannot build tests!")
51+ find_package (GoogleTest)
52+
53+ if (GOOGLE_TEST_AND_MOCK_FOUND)
54+
55+ build_google_test_locally (${CMAKE_BINARY_DIR}/__gtest)
56+
57+ if (BUILD_XORG_GTEST)
58+
59+ find_package (XorgGTest)
60+
61+ set (COMPIZ_XORG_GTEST_DIR ${CMAKE_BINARY_DIR}/__xorg_gtest CACHE PATH "Path to Xorg GTest build dir" FORCE)
62+ set (COMPIZ_XORG_GTEST_WRAPPER ${COMPIZ_XORG_GTEST_DIR}/xorg_gtest_wrapper CACHE PATH "Path to Xorg GTest wrapper" FORCE)
63+
64+ if (XORG_GTEST_FOUND)
65+
66+ build_xorg_gtest_locally (${CMAKE_BINARY_DIR}/__xorg_gtest)
67+
68+ else (XORG_GTEST_FOUND)
69+
70+ set (BUILD_XORG_GTEST FALSE)
71+
72+ endif (XORG_GTEST_FOUND)
73+
74+ endif (BUILD_XORG_GTEST)
75+
76+ else (GOOGLE_TEST_AND_MOCK_FOUND)
77+
78 set (COMPIZ_BUILD_TESTING OFF CACHE BOOL "" FORCE)
79-
80- else (NOT GMOCK_LIBRARY OR NOT GMOCK_MAIN_LIBRARY OR NOT GTEST_FOUND)
81-
82- include_directories (${GTEST_INCLUDE_DIRS})
83-
84- endif (NOT GMOCK_LIBRARY OR NOT GMOCK_MAIN_LIBRARY OR NOT GTEST_FOUND)
85+ set (BUILD_XORG_GTEST OFF CACHE BOOL "" FORCE)
86+
87+ endif (GOOGLE_TEST_AND_MOCK_FOUND)
88+
89+else (COMPIZ_BUILD_TESTING)
90+
91+ set (BUILD_XORG_GTEST OFF CACHE BOOL "" FORCE)
92
93 endif (COMPIZ_BUILD_TESTING)
94
95
96=== modified file 'cmake/CompizCommon.cmake'
97--- cmake/CompizCommon.cmake 2013-01-04 04:46:01 +0000
98+++ cmake/CompizCommon.cmake 2013-02-15 23:28:21 +0000
99@@ -31,6 +31,7 @@
100 option (COMPIZ_RUN_LDCONFIG "Leave OFF unless you need to run ldconfig after install")
101 option (COMPIZ_PACKAGING_ENABLED "Enable to manually set prefix, exec_prefix, libdir, includedir, datadir" OFF)
102 option (COMPIZ_BUILD_TESTING "Build Unit Tests" ON)
103+option (BUILD_XORG_GTEST "Build Xorg GTest integration tests" ON)
104
105 set (COMPIZ_DATADIR ${CMAKE_INSTALL_PREFIX}/share)
106 set (COMPIZ_METADATADIR ${CMAKE_INSTALL_PREFIX}/share/compiz)
107@@ -240,9 +241,25 @@
108 endforeach ()
109 endif (${COVERAGE_BUILD_TYPE} MATCHES "coverage")
110
111+ set (XORG_GTEST_WRAPPER_REQUIRED 0)
112+
113+ foreach (ARG ${ARGN})
114+ if (${ARG} STREQUAL "WITH_XORG_GTEST")
115+ set (XORG_GTEST_WRAPPER_REQUIRED 1)
116+ endif (${ARG} STREQUAL "WITH_XORG_GTEST")
117+ endforeach ()
118+
119+ set (COMPIZ_DISCOVER_TESTS_CMD
120+ ${CMAKE_BINARY_DIR}/compiz_gtest/compiz_discover_gtest_tests ${CMAKE_CURRENT_BINARY_DIR}/${EXECUTABLE})
121+
122+ if (XORG_GTEST_WRAPPER_REQUIRED)
123+ set (COMPIZ_DISCOVER_TESTS_CMD ${COMPIZ_DISCOVER_TESTS_CMD} --wrapper ${COMPIZ_XORG_GTEST_WRAPPER})
124+ endif (XORG_GTEST_WRAPPER_REQUIRED)
125+
126 add_custom_command (TARGET ${EXECUTABLE}
127 POST_BUILD
128- COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${EXECUTABLE} --gtest_list_tests | ${CMAKE_BINARY_DIR}/compiz_gtest/compiz_discover_gtest_tests ${CMAKE_CURRENT_BINARY_DIR}/${EXECUTABLE}
129+ COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${EXECUTABLE}
130+ --gtest_list_tests | ${COMPIZ_DISCOVER_TESTS_CMD}
131 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
132 COMMENT "Discovering Tests in ${EXECUTABLE}"
133 VERBATIM)
134
135=== added file 'cmake/FindGoogleTest.cmake'
136--- cmake/FindGoogleTest.cmake 1970-01-01 00:00:00 +0000
137+++ cmake/FindGoogleTest.cmake 2013-02-15 23:28:21 +0000
138@@ -0,0 +1,46 @@
139+# Find Google Test and Google Mock, either with pkg-config or by
140+# searching the system install paths. This sets:
141+#
142+# GOOGLE_TEST_AND_MOCK_FOUND
143+# GTEST_INCLUDE_DIR
144+# GTEST_ROOT_DIR
145+# GMOCK_LIBRARY
146+# GMOCK_MAIN_LIBRARY
147+
148+find_package (GTest)
149+
150+if (NOT GTEST_FOUND)
151+
152+ # Check for google test and build it locally
153+ set (GTEST_ROOT_DIR
154+ "/usr/src/gtest" # Default value, adjustable by user with e.g., ccmake
155+ CACHE
156+ PATH
157+ "Path to Google Test srcs"
158+ FORCE)
159+
160+ find_path (GTEST_INCLUDE_DIR gtest/gtest.h)
161+
162+ set (GTEST_BOTH_LIBRARIES gtest gtest_main)
163+ set (GTEST_FOUND TRUE)
164+ set (GTEST_LOCAL_BUILD_REQUIRED TRUE)
165+
166+else (NOT GTEST_FOUND)
167+
168+ set (GTEST_LOCAL_BUILD_REQUIRED FALSE)
169+
170+endif (NOT GTEST_FOUND)
171+
172+find_library (GMOCK_LIBRARY gmock)
173+find_library (GMOCK_MAIN_LIBRARY gmock_main)
174+
175+if (NOT GMOCK_LIBRARY OR NOT GMOCK_MAIN_LIBRARY OR NOT GTEST_FOUND)
176+
177+ message ("Google Mock and Google Test not found - cannot build tests!")
178+ set (GOOGLE_TEST_AND_MOCK_FOUND OFF CACHE BOOL "" FORCE)
179+
180+else (NOT GMOCK_LIBRARY OR NOT GMOCK_MAIN_LIBRARY OR NOT GTEST_FOUND)
181+
182+ set (GOOGLE_TEST_AND_MOCK_FOUND ON CACHE BOOL "" FORCE)
183+
184+endif (NOT GMOCK_LIBRARY OR NOT GMOCK_MAIN_LIBRARY OR NOT GTEST_FOUND)
185
186=== added file 'cmake/FindXorgGTest.cmake'
187--- cmake/FindXorgGTest.cmake 1970-01-01 00:00:00 +0000
188+++ cmake/FindXorgGTest.cmake 2013-02-15 23:28:21 +0000
189@@ -0,0 +1,43 @@
190+# Find xorg-gtest,with pkg-config. This sets:
191+#
192+# XORG_GTEST_FOUND
193+# XORG_SERVER_INCLUDE_XORG_GTEST
194+# XORG_SERVER_GTEST_SRC
195+
196+# xorg-gtest
197+pkg_check_modules (XORG_SERVER
198+ xorg-gtest>=0.7.0
199+ xorg-server
200+ x11
201+ xi)
202+
203+if (XORG_SERVER_FOUND)
204+
205+ execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=prefix xorg-gtest OUTPUT_VARIABLE _xorg_gtest_prefix)
206+ execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=includedir xorg-gtest OUTPUT_VARIABLE _xorg_gtest_include_dir)
207+ execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=sourcedir xorg-gtest OUTPUT_VARIABLE _xorg_gtest_source_dir)
208+ execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=CPPflags xorg-gtest OUTPUT_VARIABLE _xorg_gtest_cflags)
209+
210+ string (STRIP ${_xorg_gtest_prefix} _xorg_gtest_prefix)
211+ string (STRIP ${_xorg_gtest_include_dir} _xorg_gtest_include_dir)
212+ string (STRIP ${_xorg_gtest_source_dir} _xorg_gtest_source_dir)
213+ string (STRIP ${_xorg_gtest_cflags} _xorg_gtest_cflags)
214+
215+ set (XORG_SERVER_GTEST_INCLUDES ${XORG_SERVER_INCLUDE_DIRS})
216+ set (XORG_SERVER_GTEST_LIBRARY_DIRS ${XORG_SERVER_LIBRARIES})
217+ set (XORG_SERVER_GTEST_LIBRARIES} ${XORG_SERVER_LIBRARIES})
218+ set (XORG_SERVER_INCLUDE_XORG_GTEST ${_xorg_gtest_include_dir} CACHE PATH "Path to Xorg GTest Headers")
219+ set (XORG_SERVER_GTEST_SRC ${_xorg_gtest_source_dir} CACHE PATH "Path to Xorg GTest Sources")
220+ set (XORG_SERVER_GTEST_CFLAGS ${_xorg_gtest_cflags})
221+ set (XORG_SERVER_GTEST_ROOT ${CMAKE_SOURCE_DIR}/tests/xorg-gtest CACHE PATH "Path to Xorg GTest CMake sources")
222+ set (COMPIZ_XORG_SYSTEM_TEST_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/tests/xorg-gtest/include CACHE PATH "Path to Compiz Xorg GTest Headers")
223+
224+ message (STATUS "Found xorg-gtest sources at " ${XORG_SERVER_GTEST_SRC})
225+ set (XORG_GTEST_FOUND ON)
226+
227+else (XORG_SERVER_FOUND)
228+
229+ message (WARNING "Could not found xorg-gtest, can't build xserver tests")
230+ set (XORG_GTEST_FOUND OFF)
231+
232+endif (XORG_SERVER_FOUND)
233
234=== added file 'cmake/GoogleTest.cmake'
235--- cmake/GoogleTest.cmake 1970-01-01 00:00:00 +0000
236+++ cmake/GoogleTest.cmake 2013-02-15 23:28:21 +0000
237@@ -0,0 +1,20 @@
238+# GoogleTest.cmake
239+# build_google_test_locally (dir) takes a subdirectory
240+# and builds Google Test in there locally if required
241+
242+function (build_google_test_locally build_directory)
243+
244+ if (GOOGLE_TEST_AND_MOCK_FOUND)
245+
246+ if (GTEST_LOCAL_BUILD_REQUIRED)
247+
248+ add_subdirectory (${GTEST_ROOT_DIR}
249+ ${build_directory})
250+
251+ endif (GTEST_LOCAL_BUILD_REQUIRED)
252+
253+ include_directories (${GTEST_INCLUDE_DIRS})
254+
255+ endif (GOOGLE_TEST_AND_MOCK_FOUND)
256+
257+endfunction ()
258
259=== added file 'cmake/XorgGTest.cmake'
260--- cmake/XorgGTest.cmake 1970-01-01 00:00:00 +0000
261+++ cmake/XorgGTest.cmake 2013-02-15 23:28:21 +0000
262@@ -0,0 +1,14 @@
263+# XorgGTest.cmake
264+#
265+# build_xorg_gtest_locally (dir) specifies a subdirectory to
266+# build xorg-gtest in locally
267+
268+function (build_xorg_gtest_locally build_directory)
269+
270+ if (XORG_GTEST_FOUND)
271+
272+ add_subdirectory (${XORG_SERVER_GTEST_ROOT} ${build_directory})
273+
274+ endif (XORG_GTEST_FOUND)
275+
276+endfunction ()
277
278=== modified file 'cmake/src/compiz/CMakeLists.txt'
279--- cmake/src/compiz/CMakeLists.txt 2012-07-02 07:00:18 +0000
280+++ cmake/src/compiz/CMakeLists.txt 2013-02-15 23:28:21 +0000
281@@ -2,5 +2,9 @@
282 EXCLUDE_FROM_ALL
283 ${CMAKE_CURRENT_SOURCE_DIR}/compiz_discover_gtest_tests.cpp)
284
285+if (BUILD_XORG_GTEST)
286+ add_dependencies (compiz_discover_gtest_tests xorg_gtest_wrapper)
287+endif (BUILD_XORG_GTEST)
288+
289 set_target_properties (compiz_discover_gtest_tests PROPERTIES
290 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/compiz_gtest)
291
292=== modified file 'cmake/src/compiz/compiz_discover_gtest_tests.cpp'
293--- cmake/src/compiz/compiz_discover_gtest_tests.cpp 2012-07-30 12:41:24 +0000
294+++ cmake/src/compiz/compiz_discover_gtest_tests.cpp 2013-02-15 23:28:21 +0000
295@@ -6,19 +6,33 @@
296 #include <fstream>
297 #include <iterator>
298 #include <iostream>
299+#include <sstream>
300 #include <libgen.h>
301
302 using namespace std;
303
304+int usage ()
305+{
306+ cout << "Usage: PATH_TO_TEST_BINARY --gtest_list_tests | ./build_test_cases PATH_TO_TEST_BINARY --wrapper PATH_TO_WRAPPER";
307+ return 1;
308+}
309+
310 int main (int argc, char **argv)
311 {
312+ string testBinary;
313+ string wrapperBinary;
314 cin >> noskipws;
315
316- if (argc < 2)
317+ if (argc == 2)
318+ testBinary = string (argv[1]);
319+ else if (argc == 4 &&
320+ string (argv[2]) == "--wrapper")
321 {
322- cout << "Usage: PATH_TO_TEST_BINARY --gtest_list_tests | ./build_test_cases PATH_TO_TEST_BINARY";
323- return 1;
324+ testBinary = string (argv[1]);
325+ wrapperBinary = string (argv[3]);
326 }
327+ else
328+ return usage ();
329
330 map<string, vector<string> > testCases;
331 string line;
332@@ -50,12 +64,25 @@
333 {
334 if (testfilecmake.good ())
335 {
336- string addTest ("ADD_TEST (");
337- string testExec (" \"" + string (argv[1]) + "\"");
338- string gTestFilter ("\"--gtest_filter=");
339- string endParen ("\")");
340-
341- testfilecmake << addTest << *jt << testExec << gTestFilter << *jt << endParen << endl;
342+ stringstream addTest, escapedWrapper, escapedTest, testExec, gTestFilter, endParen;
343+
344+ addTest << "ADD_TEST (";
345+ if (wrapperBinary.size ())
346+ escapedWrapper << " \"" << wrapperBinary << "\"";
347+
348+ escapedTest << " \"" << testBinary << "\"";
349+ testExec << escapedWrapper.str () << escapedTest.str ();
350+ gTestFilter << " \"--gtest_filter=";
351+ endParen << "\")";
352+
353+ testfilecmake <<
354+ addTest.str () <<
355+ *jt <<
356+ testExec.str () <<
357+ gTestFilter.str () <<
358+ *jt <<
359+ endParen.str () <<
360+ endl;
361 }
362 }
363 }
364
365=== modified file 'debian/changelog'
366--- debian/changelog 2013-02-08 04:01:48 +0000
367+++ debian/changelog 2013-02-15 23:28:21 +0000
368@@ -1,5 +1,25 @@
369 compiz (1:0.9.9~daily13.02.08-0ubuntu1) raring; urgency=low
370
371+ * debian/ccp_plugin.patch:
372+ - Also adjust test framework to pass the new option
373+
374+ -- Sam Spilsbury <smspillaz@interpol> Thu, 14 Feb 2013 12:49:11 +0800
375+
376+compiz (1:0.9.9~daily13.02.08-0ubuntu2) raring; urgency=low
377+
378+ * debian/control:
379+ - Add xorg-gtest, xserver-xorg-dev, libxi-dev as build-deps
380+ * debian/ubuntu_config.patch:
381+ - Adjust EWMH test for new value
382+ * debian/ccp_plugin.patch:
383+ - Added new option --no-auto-load-ccp to prevent the ccp
384+ plugin from autoloading. Useful for tests where having
385+ this behaviour just causes problems from unwanted side-effects
386+
387+ -- Sam Spilsbury <smspillaz@gmail.com> Thu, 14 Feb 2013 12:45:17 +0800
388+
389+compiz (1:0.9.9~daily13.02.08-0ubuntu1) raring; urgency=low
390+
391 [ MC Return ]
392 * thumbnail.xml.in needs some love (LP: #1113459)
393 * Thumbnail plugin: Window title text is rendered into transparency
394
395=== modified file 'debian/control'
396--- debian/control 2012-11-05 21:35:41 +0000
397+++ debian/control 2013-02-15 23:28:21 +0000
398@@ -34,8 +34,10 @@
399 libxext-dev,
400 libxdamage-dev (>=1:1.0.3),
401 libxfixes-dev (>= 1:4.0.1),
402+ libxi-dev,
403 libxinerama-dev,
404 libxml-parser-perl,
405+ libxorg-gtest-dev,
406 libxrandr-dev (>= 2:1.1.0.2),
407 libxrender-dev (>= 1:0.9.1),
408 libxcursor-dev,
409@@ -54,6 +56,7 @@
410 python-pyrex,
411 gnome-control-center-dev,
412 gsettings-desktop-schemas-dev,
413+ xserver-xorg-dev (>= 0.7.0),
414 Standards-Version: 3.9.3
415 # If you aren't a member of ~compiz-team but need to upload packaging changes,
416 # just go ahead. ~compiz-team will notice and sync up the code again.
417
418=== modified file 'debian/patches/ccp_plugin.patch'
419--- debian/patches/ccp_plugin.patch 2012-06-19 11:22:48 +0000
420+++ debian/patches/ccp_plugin.patch 2013-02-15 23:28:21 +0000
421@@ -1,8 +1,40 @@
422-Index: compiz-0.9.8/src/main.cpp
423+Index: compiz.fix_1120009/src/main.cpp
424 ===================================================================
425---- compiz-0.9.8.orig/src/main.cpp 2012-05-29 12:09:56.000000000 +0200
426-+++ compiz-0.9.8/src/main.cpp 2012-05-30 16:29:24.940570174 +0200
427-@@ -146,23 +146,25 @@
428+--- compiz.fix_1120009.orig/src/main.cpp 2013-02-16 07:24:30.941138049 +0800
429++++ compiz.fix_1120009/src/main.cpp 2013-02-16 07:25:16.549364207 +0800
430+@@ -38,6 +38,11 @@
431+ #include "privatescreen.h"
432+ #include "privatestackdebugger.h"
433+
434++namespace
435++{
436++bool autoAddCCP = true;
437++}
438++
439+ void
440+ CompManager::usage ()
441+ {
442+@@ -52,6 +57,7 @@
443+ " --debug Enable debug mode\n"
444+ " --version Show the program version\n"
445+ " --help Show this summary\n"
446++ " --no-auto-add-ccp Do not automatically load the ccp plugin\n"
447+ , programName);
448+ }
449+
450+@@ -116,6 +122,11 @@
451+ if (i + 1 < argc)
452+ clientId = argv[++i];
453+ }
454++ else if (!strcmp (argv[i], "--no-auto-add-ccp"))
455++ {
456++ compLogMessage ("core", CompLogLevelInfo, "running the ccp plugin, no settings will be loaded");
457++ autoAddCCP = false;
458++ }
459+ else if (*argv[i] == '-')
460+ {
461+ compLogMessage ("core", CompLogLevelWarn,
462+@@ -151,23 +162,25 @@
463
464 modHandler = new ModifierHandler ();
465
466@@ -22,7 +54,7 @@
467 list.push_back (value);
468 }
469 + }
470-+ else
471++ else if (autoAddCCP)
472 + list.push_back ("ccp");
473
474 value.set (CompOption::TypeString, list);
475@@ -33,3 +65,15 @@
476
477 if (!screen->init (displayName))
478 return false;
479+Index: compiz.fix_1120009/tests/xorg-gtest/src/compiz-xorg-gtest.cpp
480+===================================================================
481+--- compiz.fix_1120009.orig/tests/xorg-gtest/src/compiz-xorg-gtest.cpp 2013-02-16 07:24:30.941138049 +0800
482++++ compiz.fix_1120009/tests/xorg-gtest/src/compiz-xorg-gtest.cpp 2013-02-16 07:24:30.941138049 +0800
483+@@ -390,6 +390,7 @@
484+ if (flags & ct::CompizProcess::ReplaceCurrentWM)
485+ args.push_back ("--replace");
486+
487++ args.push_back ("--no-auto-add-ccp");
488+ args.push_back ("--send-startup-message");
489+
490+ priv->mProcess.Start (compizBinaryPath, args);
491
492=== modified file 'debian/patches/ubuntu-config.patch'
493--- debian/patches/ubuntu-config.patch 2013-02-01 19:03:51 +0000
494+++ debian/patches/ubuntu-config.patch 2013-02-15 23:28:21 +0000
495@@ -204,6 +204,7 @@
496 <min>0</min>
497 <max>1</max>
498 <precision>0.01</precision>
499+
500 --- a/plugins/decor/decor.xml.in
501 +++ b/plugins/decor/decor.xml.in
502 @@ -31,7 +31,7 @@
503@@ -242,6 +243,7 @@
504 </option>
505 <option name="mipmap" type="bool">
506 <_short>Mipmap</_short>
507+
508 --- a/plugins/expo/expo.xml.in
509 +++ b/plugins/expo/expo.xml.in
510 @@ -17,6 +17,7 @@
511@@ -355,6 +357,7 @@
512 <min>0.0</min>
513 <max>2.0</max>
514 <precision>0.01</precision>
515+
516 --- a/plugins/ezoom/ezoom.xml.in
517 +++ b/plugins/ezoom/ezoom.xml.in
518 @@ -29,7 +29,6 @@
519@@ -390,6 +393,7 @@
520 </option>
521 </subgroup>
522 </group>
523+
524 --- a/plugins/fade/fade.xml.in
525 +++ b/plugins/fade/fade.xml.in
526 @@ -10,6 +10,7 @@
527@@ -409,6 +413,7 @@
528 </option>
529 <option name="visual_bell" type="bell">
530 <_short>Visual Bell</_short>
531+
532 --- a/plugins/gnomecompat/gnomecompat.xml.in
533 +++ b/plugins/gnomecompat/gnomecompat.xml.in
534 @@ -53,6 +53,7 @@
535@@ -419,6 +424,7 @@
536 </option>
537 </group>
538 </options>
539+
540 --- a/plugins/grid/grid.xml.in
541 +++ b/plugins/grid/grid.xml.in
542 @@ -23,17 +23,16 @@
543@@ -449,6 +455,7 @@
544 </option>
545 <option name="put_restore_key" type="key">
546 <_short>Restore</_short>
547+
548 --- a/plugins/place/place.xml.in
549 +++ b/plugins/place/place.xml.in
550 @@ -20,8 +20,8 @@
551@@ -462,6 +469,7 @@
552 <max>5</max>
553 <desc>
554 <value>0</value>
555+
556 --- a/plugins/resize/resize.xml.in
557 +++ b/plugins/resize/resize.xml.in
558 @@ -28,7 +28,7 @@
559@@ -508,6 +516,7 @@
560 </default>
561 </option>
562 <subgroup>
563+
564 --- a/plugins/scale/scale.xml.in
565 +++ b/plugins/scale/scale.xml.in
566 @@ -19,14 +19,14 @@
567@@ -598,6 +607,7 @@
568 </option>
569 </group>
570 </options>
571+
572 --- a/plugins/staticswitcher/staticswitcher.xml.in
573 +++ b/plugins/staticswitcher/staticswitcher.xml.in
574 @@ -11,7 +11,6 @@
575@@ -676,6 +686,7 @@
576 <desc>
577 <value>0</value>
578 <_name>None</_name>
579+
580 --- a/plugins/vpswitch/vpswitch.xml.in
581 +++ b/plugins/vpswitch/vpswitch.xml.in
582 @@ -95,13 +95,11 @@
583@@ -692,6 +703,7 @@
584 <internal/>
585 </option>
586 <option name="initiate_button" type="button">
587+
588 --- a/plugins/wall/wall.xml.in
589 +++ b/plugins/wall/wall.xml.in
590 @@ -31,12 +31,12 @@
591@@ -841,3 +853,15 @@
592 </option>
593 <option name="edgeflip_dnd" type="bool">
594 <_short>Edge Flip DnD</_short>
595+
596+--- a/tests/system/xorg-gtest/tests/compiz_xorg_gtest_ewmh.cpp
597++++ b/tests/system/xorg-gtest/tests/compiz_xorg_gtest_ewmh.cpp
598+@@ -46,7 +46,7 @@
599+
600+ namespace
601+ {
602+-unsigned int DEFAULT_VIEWPORT_WIDTH = 4;
603++unsigned int DEFAULT_VIEWPORT_WIDTH = 1;
604+ unsigned int DEFAULT_VIEWPORT_HEIGHT = 1;
605+
606+ bool Advance (Display *d, bool r)
607
608=== modified file 'tests/system/xorg-gtest/CMakeLists.txt'
609--- tests/system/xorg-gtest/CMakeLists.txt 2012-11-28 14:33:20 +0000
610+++ tests/system/xorg-gtest/CMakeLists.txt 2013-02-15 23:28:21 +0000
611@@ -1,33 +1,5 @@
612-include (FindPkgConfig)
613-
614-pkg_check_modules (XORG_SERVER xorg-gtest xorg-server x11)
615-
616-option (BUILD_XORG_GTEST "Build Xorg GTest integration tests" OFF)
617-
618-if (XORG_SERVER_FOUND AND BUILD_XORG_GTEST)
619-
620- execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=prefix xorg-gtest OUTPUT_VARIABLE _xorg_gtest_prefix)
621- execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=includedir xorg-gtest OUTPUT_VARIABLE _xorg_gtest_include_dir)
622- execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=sourcedir xorg-gtest OUTPUT_VARIABLE _xorg_gtest_source_dir)
623- execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=CPPflags xorg-gtest OUTPUT_VARIABLE _xorg_gtest_cflags)
624-
625- string (STRIP ${_xorg_gtest_prefix} _xorg_gtest_prefix)
626- string (STRIP ${_xorg_gtest_include_dir} _xorg_gtest_include_dir)
627- string (STRIP ${_xorg_gtest_source_dir} _xorg_gtest_source_dir)
628- string (STRIP ${_xorg_gtest_cflags} _xorg_gtest_cflags)
629-
630- set (XORG_SERVER_INCLUDE_XORG_GTEST ${_xorg_gtest_include_dir} CACHE PATH "Path to Xorg GTest Headers")
631- set (XORG_SERVER_GTEST_SRC ${_xorg_gtest_source_dir} CACHE PATH "Path to Xorg GTest Sources")
632- set (COMPIZ_XORG_SYSTEM_TEST_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include CACHE PATH "Path to Compiz Xorg GTest Headers")
633-
634- message (STATUS "Found xorg-gtest sources at " ${XORG_SERVER_GTEST_SRC})
635-
636- add_subdirectory (src)
637+if (BUILD_XORG_GTEST)
638+
639 add_subdirectory (tests)
640
641-else (XORG_SERVER_FOUND AND BUILD_XORG_GTEST)
642-
643- message (WARNING "Could not found xorg-gtest, not building system tests")
644- set (BUILD_XORG_GTEST OFF)
645-
646-endif (XORG_SERVER_FOUND AND BUILD_XORG_GTEST)
647+endif (BUILD_XORG_GTEST)
648
649=== modified file 'tests/system/xorg-gtest/tests/CMakeLists.txt'
650--- tests/system/xorg-gtest/tests/CMakeLists.txt 2013-01-11 07:57:32 +0000
651+++ tests/system/xorg-gtest/tests/CMakeLists.txt 2013-02-15 23:28:21 +0000
652@@ -33,17 +33,17 @@
653 target_link_libraries (compiz_xorg_gtest_test_window_stacking
654 ${COMPIZ_XORG_GTEST_LIBRARIES})
655
656- compiz_discover_tests (compiz_xorg_gtest_test_window_stacking)
657+ compiz_discover_tests (compiz_xorg_gtest_test_window_stacking WITH_XORG_GTEST)
658
659 target_link_libraries (compiz_xorg_gtest_test_icccm
660 compiz_gtest_shared_async_task
661 ${COMPIZ_XORG_GTEST_LIBRARIES})
662
663- compiz_discover_tests (compiz_xorg_gtest_test_icccm)
664+ compiz_discover_tests (compiz_xorg_gtest_test_icccm WITH_XORG_GTEST)
665
666 target_link_libraries (compiz_xorg_gtest_test_ewmh
667 ${COMPIZ_XORG_GTEST_LIBRARIES})
668
669- compiz_discover_tests (compiz_xorg_gtest_test_ewmh)
670+ compiz_discover_tests (compiz_xorg_gtest_test_ewmh WITH_XORG_GTEST)
671
672 endif (BUILD_XORG_GTEST AND X11_XI_FOUND)
673
674=== modified file 'tests/system/xorg-gtest/tests/compiz_xorg_gtest_icccm.cpp'
675--- tests/system/xorg-gtest/tests/compiz_xorg_gtest_icccm.cpp 2012-12-05 16:31:25 +0000
676+++ tests/system/xorg-gtest/tests/compiz_xorg_gtest_icccm.cpp 2013-02-15 23:28:21 +0000
677@@ -113,13 +113,6 @@
678
679 TEST_F (CompizXorgSystemICCCM, SomeoneElseHasSubstructureRedirectMask)
680 {
681- /* XXX: This is a bit stupid, but we have to do it.
682- * It seems as though closing the child stdout or
683- * stderr will cause the client to hang indefinitely
684- * when the child calls XSync (and that can happen
685- * implicitly, eg XCloseDisplay) */
686- TmpEnv env ("XORG_GTEST_CHILD_STDOUT", "1");
687-
688 StartCompiz (static_cast <ct::CompizProcess::StartupFlags> (
689 ct::CompizProcess::ExpectStartupFailure |
690 ct::CompizProcess::ReplaceCurrentWM |
691
692=== added directory 'tests/xorg-gtest'
693=== added file 'tests/xorg-gtest/CMakeLists.txt'
694--- tests/xorg-gtest/CMakeLists.txt 1970-01-01 00:00:00 +0000
695+++ tests/xorg-gtest/CMakeLists.txt 2013-02-15 23:28:21 +0000
696@@ -0,0 +1,52 @@
697+set (COMPIZ_LD_LIBRARY_PATH ${CMAKE_BINARY_DIR}/src CACHE STRING "" FORCE)
698+set (COMPIZ_BINARY ${CMAKE_BINARY_DIR}/src/compiz CACHE STRING "" FORCE)
699+
700+configure_file (${CMAKE_CURRENT_SOURCE_DIR}/src/compiz-xorg-gtest-config.h.in
701+ ${CMAKE_CURRENT_BINARY_DIR}/src/compiz-xorg-gtest-config.h
702+ @ONLY)
703+
704+include_directories (${XORG_SERVER_INCLUDE_XORG_GTEST}
705+ ${XORG_SERVER_GTEST_INCLUDES}
706+ ${COMPIZ_XORG_SYSTEM_TEST_INCLUDE_DIR}
707+ ${CMAKE_CURRENT_BINARY_DIR}/src
708+ ${compiz_SOURCE_DIR}/tests/shared)
709+
710+link_directories (${XORG_SERVER_LIBRARY_DIRS})
711+
712+add_definitions (${XORG_SERVER_GTEST_CFLAGS})
713+
714+set (_xorg_gtest_all_srcs
715+ ${XORG_SERVER_GTEST_SRC}/src/xorg-gtest-all.cpp)
716+
717+set (_xorg_gtest_main_srcs
718+ ${XORG_SERVER_GTEST_SRC}/src/xorg-gtest_main.cpp)
719+
720+add_library (xorg_gtest_all STATIC
721+ ${_xorg_gtest_all_srcs})
722+
723+add_library (xorg_gtest_main STATIC
724+ ${_xorg_gtest_main_srcs})
725+
726+add_library (compiz_xorg_gtest_system_test STATIC
727+ ${CMAKE_CURRENT_SOURCE_DIR}/src/compiz-xorg-gtest.cpp)
728+
729+add_executable (xorg_gtest_wrapper
730+ ${CMAKE_CURRENT_SOURCE_DIR}/src/xorg_gtest_wrapper.cpp)
731+
732+target_link_libraries (xorg_gtest_all
733+ ${GTEST_BOTH_LIBRARIES}
734+ ${CMAKE_THREAD_LIBS_INIT}
735+ ${XORG_SERVER_GTEST_LIBRARIES})
736+
737+target_link_libraries (xorg_gtest_main
738+ ${GTEST_BOTH_LIBRARIES}
739+ ${CMAKE_THREAD_LIBS_INIT}
740+ ${XORG_SERVER_GTEST_LIBRARIES})
741+
742+target_link_libraries (compiz_xorg_gtest_system_test
743+ xorg_gtest_all
744+ xorg_gtest_main
745+ ${GTEST_BOTH_LIBRARIES}
746+ ${CMAKE_THREAD_LIBS_INIT}
747+ ${XORG_SERVER_LIBRARIES}
748+ ${X11_XI_LIBRARIES})
749
750=== renamed directory 'tests/system/xorg-gtest/include' => 'tests/xorg-gtest/include'
751=== renamed directory 'tests/system/xorg-gtest/src' => 'tests/xorg-gtest/src'
752=== modified file 'tests/xorg-gtest/src/CMakeLists.txt'
753--- tests/system/xorg-gtest/src/CMakeLists.txt 2012-09-18 13:17:09 +0000
754+++ tests/xorg-gtest/src/CMakeLists.txt 2013-02-15 23:28:21 +0000
755@@ -1,51 +1,2 @@
756-set (COMPIZ_LD_LIBRARY_PATH ${CMAKE_BINARY_DIR}/src CACHE STRING "" FORCE)
757-set (COMPIZ_BINARY ${CMAKE_BINARY_DIR}/src/compiz CACHE STRING "" FORCE)
758-
759-configure_file (${CMAKE_CURRENT_SOURCE_DIR}/compiz-xorg-gtest-config.h.in
760- ${CMAKE_CURRENT_BINARY_DIR}/compiz-xorg-gtest-config.h
761- @ONLY)
762-
763-add_definitions (${_xorg_gtest_cflags})
764-
765-include_directories (${COMPIZ_XORG_SYSTEM_TEST_INCLUDE_DIR}
766- ${XORG_SERVER_INCLUDE_DIRS}
767- ${GTEST_INCLUDE_DIRS}
768- ${XORG_SERVER_INCLUDE_XORG_GTEST}
769- ${XORG_SERVER_GTEST_SRC}
770- ${CMAKE_CURRENT_BINARY_DIR})
771-
772-link_directories (${XORG_SERVER_LIBRARY_DIRS})
773-
774-# This actually includes xorg-gtest-all and the defines
775-set (_xorg_gtest_all_srcs
776- ${XORG_SERVER_GTEST_SRC}/src/xorg-gtest-all.cpp)
777-
778-set (_xorg_gtest_main_srcs
779- ${XORG_SERVER_GTEST_SRC}/src/xorg-gtest_main.cpp)
780-
781-add_library (xorg_gtest_all STATIC
782- ${_xorg_gtest_all_srcs})
783-
784-add_library (xorg_gtest_main STATIC
785- ${_xorg_gtest_main_srcs})
786-
787-add_library (compiz_xorg_gtest_system_test STATIC
788- ${CMAKE_CURRENT_SOURCE_DIR}/compiz-xorg-gtest.cpp)
789-
790-target_link_libraries (xorg_gtest_all
791- ${GTEST_BOTH_LIBRARIES}
792- ${CMAKE_THREAD_LIBS_INIT}
793- ${XORG_SERVER_LIBRARIES})
794-
795-target_link_libraries (xorg_gtest_main
796- ${GTEST_BOTH_LIBRARIES}
797- ${CMAKE_THREAD_LIBS_INIT}
798- ${XORG_SERVER_LIBRARIES})
799-
800-target_link_libraries (compiz_xorg_gtest_system_test
801- xorg_gtest_all
802- xorg_gtest_main
803- ${GTEST_BOTH_LIBRARIES}
804- ${CMAKE_THREAD_LIBS_INIT}
805- ${XORG_SERVER_LIBRARIES}
806- ${X11_XI_LIBRARIES})
807+add_executable (xorg_gtest_wrapper
808+ ${CMAKE_CURRENT_SOURCE_DIR}/xorg_gtest_wrapper.cpp)
809
810=== modified file 'tests/xorg-gtest/src/compiz-xorg-gtest.cpp'
811--- tests/system/xorg-gtest/src/compiz-xorg-gtest.cpp 2012-12-05 16:01:37 +0000
812+++ tests/xorg-gtest/src/compiz-xorg-gtest.cpp 2013-02-15 23:28:21 +0000
813@@ -28,6 +28,7 @@
814 #include <boost/shared_ptr.hpp>
815 #include <xorg/gtest/xorg-gtest.h>
816 #include <compiz-xorg-gtest.h>
817+#include <gtest_shared_tmpenv.h>
818 #include <X11/Xlib.h>
819 #include <X11/Xatom.h>
820
821
822=== added file 'tests/xorg-gtest/src/xorg_gtest_wrapper.cpp'
823--- tests/xorg-gtest/src/xorg_gtest_wrapper.cpp 1970-01-01 00:00:00 +0000
824+++ tests/xorg-gtest/src/xorg_gtest_wrapper.cpp 2013-02-15 23:28:21 +0000
825@@ -0,0 +1,93 @@
826+/*
827+ * Compiz XOrg GTest Wrapper
828+ *
829+ * Copyright (C) 2013 Canonical Ltd.
830+ *
831+ * This library is free software; you can redistribute it and/or
832+ * modify it under the terms of the GNU Lesser General Public
833+ * License as published by the Free Software Foundation; either
834+ * version 2.1 of the License, or (at your option) any later version.
835+
836+ * This library is distributed in the hope that it will be useful,
837+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
838+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
839+ * Lesser General Public License for more details.
840+
841+ * You should have received a copy of the GNU Lesser General Public
842+ * License along with this library; if not, write to the Free Software
843+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
844+ *
845+ * Authored By:
846+ * Sam Spilsbury <smspillaz@gmail.com>
847+ */
848+#ifndef _GNU_SOURCE
849+#define _GNU_SOURCE
850+#endif
851+#include <stdio.h>
852+#include <stdlib.h>
853+#include <sys/types.h>
854+#include <sys/wait.h>
855+#include <unistd.h>
856+
857+int usage ()
858+{
859+ printf ("usage: xorg_gtest_wrapper EXECUTABLE ARGUMENTS\n");
860+ return 1;
861+}
862+
863+int main (int argc, char **argv)
864+{
865+ if (argc < 2)
866+ return usage ();
867+
868+ /* We need to force the child stdout to remain open here.
869+ *
870+ * This is ugly, but the X Server and clients seem to
871+ * have some real trouble when you close their stdin/stdout.
872+ * It isn't really clear why, but at having a noisy test is
873+ * better than having a test that fails randomly. Without it,
874+ * the tests will occasionally hang in _XReply (), or the servers
875+ * will hang in other areas, probably in an IPC area or syscall
876+ */
877+ setenv ("XORG_GTEST_CHILD_STDOUT", "1", 1);
878+
879+ char * const *exec_args = const_cast <char * const *> (&argv[1]);
880+
881+ /* Fork and spawn the new process */
882+ pid_t test = fork ();
883+
884+ if (test == -1)
885+ {
886+ perror ("fork");
887+ return 1;
888+ }
889+
890+ if (test == 0)
891+ {
892+ if (execvp (argv[1], exec_args) == -1)
893+ {
894+ perror ("execvp");
895+ return 1;
896+ }
897+ }
898+
899+ int status = 0;
900+
901+ /* Make sure it exited normally */
902+ do
903+ {
904+ pid_t child = waitpid (test, &status, 0);
905+ if (test == child)
906+ {
907+ if (WIFSIGNALED (status))
908+ return 1;
909+ }
910+ else
911+ {
912+ perror ("waitpid");
913+ return 1;
914+ }
915+ } while (!WIFEXITED (status) && !WIFSIGNALED (status));
916+
917+ return 0;
918+}

Subscribers

People subscribed via source and target branches