Merge lp:~autopilot/autopilot-qt/magic-driver-loading-awesomeness into lp:autopilot-qt

Proposed by Thomi Richards
Status: Merged
Approved by: Juhapekka Piiroinen
Approved revision: 44
Merged at revision: 34
Proposed branch: lp:~autopilot/autopilot-qt/magic-driver-loading-awesomeness
Merge into: lp:autopilot-qt
Diff against target: 354 lines (+170/-67)
13 files modified
autopilot-qt.pro (+7/-2)
debian/autopilot-qt.install (+0/-1)
debian/autopilot-qt5.install (+0/-1)
debian/changelog (+2/-2)
debian/control (+12/-17)
debian/copyright (+1/-1)
debian/libautopilot-qt.install (+1/-0)
debian/lintian-overrides (+1/-1)
debian/rules (+5/-5)
driver/driver.pro (+38/-0)
lib/lib.pro (+0/-37)
lib/qttestability.cpp (+87/-0)
lib/qttestability.h (+16/-0)
To merge this branch: bzr merge lp:~autopilot/autopilot-qt/magic-driver-loading-awesomeness
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Juhapekka Piiroinen (community) Approve
Omer Akram (community) Approve
Review via email: mp+142826@code.launchpad.net

Commit message

autopilot-qt is now a single package with drivers that load correctly for each supported Qt version.

Description of the change

This branch changes the way autopilot-qt works. Instead of creatinbg multiple binary packages for each version of qt, we create a small driver library that links to nothing. This gets loaded by the Qt app the user wants to test. This small library works out which version of Qt the app that loaded it is linked to, and loads the appropriate autopilot driver library.

Things that still need to be done before this branch can merge (mostly packaging stuff):

1) The binary package name should be renamed to 'libautopilot-qt' to make it in line with the gtk plugin.
2) The package ends up depending on all the Qt4 and Qt5 packages - I think this is '${shlibs:Depends}' in action. We don't want that, since it forces users to install Qt5 whenever they're testing a Qt4 app, and vice versa. We can be assured that they have the correct Qt libraries installed anyway, since our driver library was loaded by Qt. So we need to find a way around this - possibly just remove '${shlibs:Depends}' (but then remember to depend on libxpathselect).
3) Currently the driver library (libqt_testability) is built twice - once in the qt4 and once in the qt5 directory. Ideally we'd just build it once.

Over to you....

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

1) The binary package name should be renamed to 'libautopilot-qt' to make it in line with the gtk plugin.

Done.

2) The package ends up depending on all the Qt4 and Qt5 packages - I think this is '${shlibs:Depends}' in action. We don't want that, since it forces users to install Qt5 whenever they're testing a Qt4 app, and vice versa. We can be assured that they have the correct Qt libraries installed anyway, since our driver library was loaded by Qt. So we need to find a way around this - possibly just remove '${shlibs:Depends}' (but then remember to depend on libxpathselect).

Done.

3) Currently the driver library (libqt_testability) is built twice - once in the qt4 and once in the qt5 directory. Ideally we'd just build it once.

Done. For now, I kinda workarounded it and only build the main lib with the Qt5 build run. A probably cleaner solution would be to split the projects up and build them indeoendently. However, this produces just the same result and causes less maintainance efforts.

Revision history for this message
Omer Akram (om26er) wrote :

builds fine for me, replaces autopilot-qt and -qt5 as it should. Also my autopilot tests work.

review: Approve
Revision history for this message
Juhapekka Piiroinen (juhapekka-piiroinen) wrote :

looks great to me :)

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Autolanding.
Approved revid is not set in launchpad (maybe a permission problem?).
http://s-jenkins:8080/job/autopilot-qt-autolanding/18/
Executed test runs:
    SUCCESS: http://s-jenkins:8080/job/autopilot-qt-autolanding/./build=pbuilder,distribution=quantal,flavor=amd64/18/console

review: Needs Fixing (continuous-integration)
Revision history for this message
Juhapekka Piiroinen (juhapekka-piiroinen) wrote :

I withdrawed the Approved, Could somebody check if the Description is still valid and update it accordingly: "Things that still need to be done before this branch can merge (mostly packaging stuff):"

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'autopilot-qt.pro'
2--- autopilot-qt.pro 2012-07-30 15:14:44 +0000
3+++ autopilot-qt.pro 2013-01-14 13:13:22 +0000
4@@ -1,3 +1,8 @@
5-
6 TEMPLATE = subdirs
7-SUBDIRS = lib # test
8+
9+# only build the main lib once, with the qt5 driver
10+contains(QT_VERSION, ^5\\..\\..*) {
11+ SUBDIRS += lib
12+}
13+
14+SUBDIRS += driver
15
16=== removed file 'debian/autopilot-qt.install'
17--- debian/autopilot-qt.install 2012-10-09 16:21:50 +0000
18+++ debian/autopilot-qt.install 1970-01-01 00:00:00 +0000
19@@ -1,1 +0,0 @@
20-usr/lib/lib*.so.*
21
22=== removed file 'debian/autopilot-qt5.install'
23--- debian/autopilot-qt5.install 2012-10-09 16:21:50 +0000
24+++ debian/autopilot-qt5.install 1970-01-01 00:00:00 +0000
25@@ -1,1 +0,0 @@
26-opt/qt5/lib/lib*.so.*
27
28=== modified file 'debian/changelog'
29--- debian/changelog 2012-11-14 15:57:58 +0000
30+++ debian/changelog 2013-01-14 13:13:22 +0000
31@@ -1,10 +1,10 @@
32-autopilot-qt (0.2) quantal; urgency=low
33+libautopilot-qt (0.2) quantal; urgency=low
34
35 * Release
36
37 -- Michael Zanetti <michael.zanetti@canonical.com> Wed, 14 Nov 2012 16:55:45 +0100
38
39-autopilot-qt (0.1) quantal; urgency=low
40+libautopilot-qt (0.1) quantal; urgency=low
41
42 * Initial release
43
44
45=== modified file 'debian/control'
46--- debian/control 2012-11-19 17:18:59 +0000
47+++ debian/control 2013-01-14 13:13:22 +0000
48@@ -1,4 +1,4 @@
49-Source: autopilot-qt
50+Source: libautopilot-qt
51 Priority: extra
52 Maintainer: Michael Zanetti <michael.zanetti@canonical.com>
53 Build-Depends: debhelper (>= 8.0.0), libindicate-qt-dev, pkg-config, qt4-qmake, libqt4-dev, qtbase, qtdeclarative, libxpathselect-dev, mesa-common-dev, libgl1-mesa-dev, libgles2-mesa-dev
54@@ -6,20 +6,15 @@
55 Section: libs
56 Homepage: https://launchpad.net/autopilot-qt
57
58-Package: autopilot-qt
59-Section: libs
60-Architecture: any
61-Depends: ${shlibs:Depends}, ${misc:Depends}
62-Recommends: python-autopilot
63-Description: This project makes Qt4 applications introspectable by autopilot.
64- This allows autopilot to test any existing Qt4 application,
65- without having to rebuild the application under test.
66-
67-Package: autopilot-qt5
68-Section: libs
69-Architecture: any
70-Depends: ${shlibs:Depends}, ${misc:Depends}
71-Recommends: python-autopilot
72-Description: This project makes Qt5 applications introspectable by autopilot.
73- This allows autopilot to test any existing Qt5 application,
74+Package: libautopilot-qt
75+Section: libs
76+Architecture: any
77+Depends: ${misc:Depends},
78+ libxpathselect1.1,
79+Replaces: autopilot-qt, autopilot-qt5
80+Conflicts: autopilot-qt, autopilot-qt5
81+Provides: autopilot-qt, autopilot-qt5
82+Recommends: python-autopilot
83+Description: This project makes Qt applications introspectable by autopilot.
84+ This allows autopilot to test any existing Qt4 or Qt5 application,
85 without having to rebuild the application under test.
86
87=== modified file 'debian/copyright'
88--- debian/copyright 2012-10-09 16:21:50 +0000
89+++ debian/copyright 2013-01-14 13:13:22 +0000
90@@ -1,5 +1,5 @@
91 Format: http://dep.debian.net/deps/dep5
92-Upstream-Name: autopilot-qt
93+Upstream-Name: libautopilot-qt
94 Source: https://code.launchpad.net/~private-ps-quality-team/autopilot-qt/trunk
95
96 Files: *
97
98=== added file 'debian/libautopilot-qt.install'
99--- debian/libautopilot-qt.install 1970-01-01 00:00:00 +0000
100+++ debian/libautopilot-qt.install 2013-01-14 13:13:22 +0000
101@@ -0,0 +1,1 @@
102+usr/lib/lib*.so.*
103
104=== modified file 'debian/lintian-overrides'
105--- debian/lintian-overrides 2012-10-10 07:42:18 +0000
106+++ debian/lintian-overrides 2013-01-14 13:13:22 +0000
107@@ -1,1 +1,1 @@
108-autopilot-qt binary: non-dev-pkg-with-shlib-symlink
109+libautopilot-qt binary: non-dev-pkg-with-shlib-symlink
110
111=== modified file 'debian/rules'
112--- debian/rules 2012-10-09 16:21:50 +0000
113+++ debian/rules 2013-01-14 13:13:22 +0000
114@@ -10,7 +10,7 @@
115 export DH_VERBOSE=1
116
117 %:
118- dh $@
119+ dh $@
120
121 override_dh_auto_configure:
122 mkdir qt4
123@@ -28,7 +28,7 @@
124 rm -rf qt5
125
126 override_dh_install:
127- mkdir -p $(CURDIR)/debian/autopilot-qt/usr/lib/
128- mkdir -p $(CURDIR)/debian/autopilot-qt5/opt/qt5/lib/
129- cp -pP qt4/libqttestability* $(CURDIR)/debian/autopilot-qt/usr/lib/
130- cp -pP qt5/libqttestability* $(CURDIR)/debian/autopilot-qt5/opt/qt5/lib/
131+ mkdir -p $(CURDIR)/debian/libautopilot-qt/usr/lib/
132+ mkdir -p $(CURDIR)/debian/libautopilot-qt5/opt/qt5/lib/
133+ cp -pP qt4/*.so* $(CURDIR)/debian/libautopilot-qt/usr/lib/
134+ cp -pP qt5/*.so* $(CURDIR)/debian/libautopilot-qt/usr/lib/
135
136=== renamed directory 'lib' => 'driver'
137=== added file 'driver/driver.pro'
138--- driver/driver.pro 1970-01-01 00:00:00 +0000
139+++ driver/driver.pro 2013-01-14 13:13:22 +0000
140@@ -0,0 +1,38 @@
141+TEMPLATE = lib
142+
143+#version check qt
144+contains(QT_VERSION, ^5\\..\\..*) {
145+ DEFINES += QT5_SUPPORT
146+ TARGET = autopilot_driver_qt5
147+} else {
148+ TARGET = autopilot_driver_qt4
149+}
150+
151+DESTDIR=..
152+QT = core gui dbus quick widgets testlib
153+CONFIG += link_pkgconfig
154+PKGCONFIG += xpathselect
155+QMAKE_CXXFLAGS += -std=c++0x -Wl,--no-undefined
156+
157+SOURCES = qttestability.cpp \
158+ dbus_adaptor.cpp \
159+ dbus_object.cpp \
160+ introspection.cpp \
161+ rootnode.cpp \
162+ qtnode.cpp \
163+ dbus_adaptor_qt.cpp
164+
165+HEADERS = qttestability.h \
166+ dbus_adaptor.h \
167+ dbus_object.h \
168+ introspection.h \
169+ rootnode.h \
170+ qtnode.h \
171+ introspection.h \
172+ dbus_adaptor_qt.h
173+
174+target.file = libtestability*
175+
176+
177+target.path = /usr/lib
178+INSTALLS += target
179
180=== added directory 'lib'
181=== added file 'lib/lib.pro'
182--- lib/lib.pro 1970-01-01 00:00:00 +0000
183+++ lib/lib.pro 2013-01-14 13:13:22 +0000
184@@ -0,0 +1,15 @@
185+TEMPLATE = lib
186+TARGET = qttestability
187+DESTDIR=..
188+
189+# disable qt includes and linkage (core and gui are enabled per default with Qt4)
190+QT -= core gui
191+
192+QMAKE_CXXFLAGS += -std=c++0x -Wl,--no-undefined
193+QMAKE_CXXFLAGS -= -pedantic
194+
195+SOURCES = qttestability.cpp
196+HEADERS = qttestability.h
197+
198+target.file = libtestability*
199+INSTALLS += target
200
201=== removed file 'lib/lib.pro'
202--- lib/lib.pro 2012-11-06 14:28:41 +0000
203+++ lib/lib.pro 1970-01-01 00:00:00 +0000
204@@ -1,37 +0,0 @@
205-
206-TEMPLATE = lib
207-TARGET = qttestability
208-DESTDIR=..
209-QT = core gui dbus quick widgets testlib
210-CONFIG += link_pkgconfig
211-PKGCONFIG += xpathselect
212-QMAKE_CXXFLAGS += -std=c++0x -Wl,--no-undefined
213-
214-SOURCES = qttestability.cpp \
215- dbus_adaptor.cpp \
216- dbus_object.cpp \
217- introspection.cpp \
218- rootnode.cpp \
219- qtnode.cpp \
220- dbus_adaptor_qt.cpp
221-
222-HEADERS = qttestability.h \
223- dbus_adaptor.h \
224- dbus_object.h \
225- introspection.h \
226- rootnode.h \
227- qtnode.h \
228- introspection.h \
229- dbus_adaptor_qt.h
230-
231-target.file = libtestability*
232-
233-#version check qt
234-contains(QT_VERSION, ^5\\..\\..*) {
235- DEFINES += QT5_SUPPORT
236- target.path = /opt/qt5/lib
237-} else {
238- target.path = /usr/lib
239-}
240-
241-INSTALLS += target
242
243=== added file 'lib/qttestability.cpp'
244--- lib/qttestability.cpp 1970-01-01 00:00:00 +0000
245+++ lib/qttestability.cpp 2013-01-14 13:13:22 +0000
246@@ -0,0 +1,87 @@
247+/*
248+Copyright 2012 Canonical
249+
250+This program is free software: you can redistribute it and/or modify it
251+under the terms of the GNU General Public License version 3, as published
252+by the Free Software Foundation.
253+*/
254+
255+#include "qttestability.h"
256+
257+#include <link.h>
258+#include <string>
259+#include <iostream>
260+
261+typedef enum
262+{
263+ QT_VERSION_4,
264+ QT_VERSION_5,
265+ QT_VERSION_UNKNOWN
266+} QtVersion;
267+
268+static int
269+callback(struct dl_phdr_info *info, size_t size, void *data)
270+{
271+ (void) size;
272+ QtVersion *v = (QtVersion*) data;
273+
274+ if (*v == QT_VERSION_UNKNOWN)
275+ {
276+ std::string lib_path(info->dlpi_name);
277+ if (lib_path.rfind("libQtCore.so.4") != std::string::npos)
278+ {
279+ *v = QT_VERSION_4;
280+ }
281+ else if (lib_path.rfind("libQtCore.so.5") != std::string::npos)
282+ {
283+ *v = QT_VERSION_5;
284+ }
285+ }
286+
287+ return 0;
288+}
289+
290+void qt_testability_init(void)
291+{
292+ QtVersion version = QT_VERSION_UNKNOWN;
293+ dl_iterate_phdr(callback, &version);
294+
295+ std::string driver_name;
296+ if (version == QT_VERSION_4)
297+ {
298+ driver_name = "libautopilot_driver_qt4.so.1";
299+ }
300+ else if (version == QT_VERSION_5)
301+ {
302+ driver_name = "libautopilot_driver_qt5.so.1";
303+ }
304+ else
305+ {
306+ std::cerr << "We don't seem to link to version 4 or 5 of QtCore." << std::endl
307+ << "Unable to determine which autopilot driver to load." << std::endl
308+ << "Autopilot introspection will not be available for this process." << std::endl;
309+ return;
310+ }
311+
312+ void* driver = dlopen(driver_name.c_str(), RTLD_LAZY);
313+ if (!driver)
314+ {
315+ std::cerr << "Cannot load library: " << dlerror() << std::endl
316+ << "Autopilot introspection will not be available for this process." << std::endl;
317+ return;
318+ }
319+
320+ // load the entry point function for the actual driver:
321+ typedef void (*entry_t)();
322+ // clear errors:
323+ dlerror();
324+ entry_t entry_point = (entry_t) dlsym(driver, "qt_testability_init");
325+ const char* err = dlerror();
326+ if (err)
327+ {
328+ std::cerr << "Cannot load library entry point symbol: " << err << std::endl
329+ << "Autopilot introspection will not be available for this process." << std::endl;
330+ return;
331+ }
332+ entry_point();
333+}
334
335=== added file 'lib/qttestability.h'
336--- lib/qttestability.h 1970-01-01 00:00:00 +0000
337+++ lib/qttestability.h 2013-01-14 13:13:22 +0000
338@@ -0,0 +1,16 @@
339+/*
340+Copyright 2012 Canonical
341+
342+This program is free software: you can redistribute it and/or modify it
343+under the terms of the GNU General Public License version 3, as published
344+by the Free Software Foundation.
345+*/
346+
347+#ifndef QTTESTABILITY_H
348+#define QTTESTABILITY_H
349+
350+extern "C" void qt_testability_init(void);
351+
352+
353+#endif
354+

Subscribers

People subscribed via source and target branches

to all changes: