Merge lp:~thomir-deactivatedaccount/autopilot/add_lttng_tracepoint_emit into lp:autopilot

Proposed by Thomi Richards
Status: Merged
Approved by: Christopher Lee
Approved revision: 200
Merged at revision: 203
Proposed branch: lp:~thomir-deactivatedaccount/autopilot/add_lttng_tracepoint_emit
Merge into: lp:autopilot
Diff against target: 232 lines (+134/-2)
7 files modified
autopilot/testcase.py (+20/-0)
debian/control (+13/-0)
debian/python-autopilot-trace.install (+1/-0)
debian/rules (+3/-0)
lttng_module/autopilot_tracepoint.c (+52/-0)
lttng_module/autopilot_tracepoint.h (+37/-0)
setup.py (+8/-2)
To merge this branch: bzr merge lp:~thomir-deactivatedaccount/autopilot/add_lttng_tracepoint_emit
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Christopher Lee (community) Approve
Review via email: mp+162903@code.launchpad.net

Commit message

Add a package with the tracepoint module.

Description of the change

Add a package with the tracepoint module.

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
Christopher Lee (veebers) wrote :

Looks good to me

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'autopilot/testcase.py'
2--- autopilot/testcase.py 2013-05-01 17:50:26 +0000
3+++ autopilot/testcase.py 2013-05-09 00:06:26 +0000
4@@ -71,6 +71,11 @@
5 from autopilot.globals import on_test_started
6 from autopilot.keybindings import KeybindingsHelper
7 from autopilot.matchers import Eventually
8+try:
9+ from autopilot import tracepoint as tp
10+ HAVE_TRACEPOINT=True
11+except ImportError:
12+ HAVE_TRACEPOINT=False
13
14
15 logger = logging.getLogger(__name__)
16@@ -101,6 +106,18 @@
17 return result
18
19
20+def _lttng_trace_test_started(test_id):
21+ if HAVE_TRACEPOINT:
22+ tp.emit_test_started(test_id)
23+ else:
24+ logger.warning("No tracing available - install the python-autopilot-trace package!")
25+
26+
27+def _lttng_trace_test_ended(test_id):
28+ if HAVE_TRACEPOINT:
29+ tp.emit_test_ended(test_id)
30+
31+
32 class AutopilotTestCase(TestWithScenarios, TestCase, KeybindingsHelper):
33 """Wrapper around testtools.TestCase that adds significant functionality.
34
35@@ -114,6 +131,9 @@
36 super(AutopilotTestCase, self).setUp()
37 on_test_started(self)
38
39+ _lttng_trace_test_started(self.id())
40+ self.addCleanup(_lttng_trace_test_ended, self.id())
41+
42 self._process_manager = None
43 self._mouse = None
44 self._kb = None
45
46=== modified file 'debian/control'
47--- debian/control 2013-05-06 22:25:57 +0000
48+++ debian/control 2013-05-09 00:06:26 +0000
49@@ -9,6 +9,7 @@
50 gir1.2-gtk-2.0,
51 python (>= 2.6),
52 python-dbus,
53+ python-dev,
54 python-debian,
55 python-mock,
56 python-setuptools,
57@@ -17,6 +18,7 @@
58 python-testscenarios,
59 python-xlib,
60 python-zeitgeist,
61+ liblttng-ust-dev,
62 Standards-Version: 3.9.3
63 Homepage: https://launchpad.net/autopilot
64 Vcs-bzr: https://code.launchpad.net/+branch/ubuntu/autopilot
65@@ -38,6 +40,17 @@
66 keyboard. It also provides a lot of utilities linked to the X server
67 and detecting applications.
68
69+Package: python-autopilot-trace
70+Architecture: any
71+Depends: ${misc:Depends},
72+ ${shlibs:Depends},
73+ python-autopilot,
74+Description: Support for tracing in autopilot
75+ This package contains the binary lttng trace point for tracing
76+ autopilot tests. This is useful when using autopilot to exercise
77+ an instrumented application.
78+
79+
80 Package: autopilot-touch
81 Architecture: all
82 Section: metapackages
83
84=== added file 'debian/python-autopilot-trace.install'
85--- debian/python-autopilot-trace.install 1970-01-01 00:00:00 +0000
86+++ debian/python-autopilot-trace.install 2013-05-09 00:06:26 +0000
87@@ -0,0 +1,1 @@
88+usr/lib/python2.7/dist-packages/autopilot/tracepoint.so
89
90=== modified file 'debian/rules' (properties changed: +x to -x)
91--- debian/rules 2013-05-05 02:56:11 +0000
92+++ debian/rules 2013-05-09 00:06:26 +0000
93@@ -13,3 +13,6 @@
94
95 override_dh_auto_test:
96 python -m testtools.run discover autopilot.tests.unit
97+
98+override_dh_install:
99+ dh_install --list-missing
100
101=== added directory 'lttng_module'
102=== added file 'lttng_module/autopilot_tracepoint.c'
103--- lttng_module/autopilot_tracepoint.c 1970-01-01 00:00:00 +0000
104+++ lttng_module/autopilot_tracepoint.c 2013-05-09 00:06:26 +0000
105@@ -0,0 +1,52 @@
106+
107+#define TRACEPOINT_CREATE_PROBES
108+/*
109+ * The header containing our TRACEPOINT_EVENTs.
110+ */
111+#define TRACEPOINT_DEFINE
112+#include "autopilot_tracepoint.h"
113+
114+/// Python module stuff below here:
115+
116+#include <Python.h>
117+
118+static PyObject *
119+emit_test_started(PyObject *self, PyObject *args)
120+{
121+ const char *mesg_text;
122+
123+ if(!PyArg_ParseTuple(args, "s", &mesg_text))
124+ {
125+ return NULL;
126+ }
127+ tracepoint(com_canonical_autopilot, test_event, "started", mesg_text);
128+
129+ Py_RETURN_NONE;
130+}
131+
132+static PyObject *
133+emit_test_ended(PyObject *self, PyObject *args)
134+{
135+ const char *mesg_text;
136+
137+ if(!PyArg_ParseTuple(args, "s", &mesg_text))
138+ {
139+ return NULL;
140+ }
141+ tracepoint(com_canonical_autopilot, test_event, "ended", mesg_text);
142+
143+ Py_RETURN_NONE;
144+}
145+
146+static PyMethodDef TracepointMethods[] = {
147+ {"emit_test_started", emit_test_started, METH_VARARGS, "Generate a tracepoint for test started."},
148+ {"emit_test_ended", emit_test_ended, METH_VARARGS, "Generate a tracepoint for test started."},
149+ {NULL, NULL, 0, NULL} /* Sentinel */
150+};
151+
152+
153+PyMODINIT_FUNC
154+inittracepoint(void)
155+{
156+ (void) Py_InitModule("tracepoint", TracepointMethods);
157+}
158
159=== added file 'lttng_module/autopilot_tracepoint.h'
160--- lttng_module/autopilot_tracepoint.h 1970-01-01 00:00:00 +0000
161+++ lttng_module/autopilot_tracepoint.h 2013-05-09 00:06:26 +0000
162@@ -0,0 +1,37 @@
163+
164+#undef TRACEPOINT_PROVIDER
165+#define TRACEPOINT_PROVIDER com_canonical_autopilot
166+
167+#undef TRACEPOINT_INCLUDE
168+#define TRACEPOINT_INCLUDE "./autopilot_tracepoint.h"
169+
170+#ifdef __cplusplus
171+extern "C"{
172+#endif /* __cplusplus */
173+
174+
175+#if !defined(AUTOPILOT_TRACEPOINT_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
176+#define AUTOPILOT_TRACEPOINT_H
177+
178+#include <lttng/tracepoint.h>
179+
180+
181+TRACEPOINT_EVENT(
182+ com_canonical_autopilot,
183+ test_event,
184+ TP_ARGS(const char *, started_or_stopped, const char *, test_id),
185+ /* Next are the fields */
186+ TP_FIELDS(
187+ ctf_string(started_or_stopped, started_or_stopped)
188+ ctf_string(test_id, test_id)
189+ )
190+)
191+
192+#endif /* AUTOPILOT_TRACEPOINT_H */
193+
194+#include <lttng/tracepoint-event.h>
195+
196+#ifdef __cplusplus
197+}
198+#endif /* __cplusplus */
199+
200
201=== modified file 'setup.py'
202--- setup.py 2013-04-23 04:15:54 +0000
203+++ setup.py 2013-05-09 00:06:26 +0000
204@@ -18,8 +18,8 @@
205 # along with this program. If not, see <http://www.gnu.org/licenses/>.
206 #
207
208-from distutils.core import setup
209-from setuptools import find_packages
210+
211+from setuptools import find_packages, setup, Extension
212
213 try:
214 from debian import changelog
215@@ -29,6 +29,11 @@
216 # If we don't have python-debian installed, guess a coarse-grained version string
217 version = '1.3'
218
219+autopilot_tracepoint = Extension('autopilot.tracepoint',
220+ libraries=['lttng-ust'],
221+ include_dirs=['lttng_module'],
222+ sources = ['lttng_module/autopilot_tracepoint.c'])
223+
224 setup(
225 name='autopilot',
226 version=version,
227@@ -40,5 +45,6 @@
228 packages=find_packages(),
229 test_suite='autopilot.tests',
230 scripts=['bin/autopilot',],
231+ ext_modules=[autopilot_tracepoint],
232 )
233

Subscribers

People subscribed via source and target branches