Merge lp:~dobey/url-dispatcher/use-libwhoopsie into lp:url-dispatcher

Proposed by dobey
Status: Merged
Approved by: Ted Gould
Approved revision: 115
Merged at revision: 119
Proposed branch: lp:~dobey/url-dispatcher/use-libwhoopsie
Merge into: lp:url-dispatcher
Diff against target: 416 lines (+23/-217)
10 files modified
CMakeLists.txt (+3/-0)
debian/control (+1/-0)
service/CMakeLists.txt (+5/-4)
service/dispatcher.c (+3/-3)
service/recoverable-problem.c (+0/-171)
service/recoverable-problem.h (+0/-26)
service/update-directory.c (+5/-5)
service/url-overlay/CMakeLists.txt (+2/-2)
service/url-overlay/exec-tool.c (+3/-4)
tests/recoverable-problem-mock.c (+1/-2)
To merge this branch: bzr merge lp:~dobey/url-dispatcher/use-libwhoopsie
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
unity-api-1-bot continuous-integration Needs Fixing
Review via email: mp+320088@code.launchpad.net

Commit message

Use libwhoopsie for reporting recoverable problems.

To post a comment you must log in.
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

FAILED: Continuous integration, rev:115
https://jenkins.canonical.com/unity-api-1/job/lp-url-dispatcher-ci/51/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build/1793/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/1800
    ABORTED: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1576/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1576
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1576/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1576
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1576/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1576
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1576/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1576
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1576/artifact/output/*zip*/output.zip
    ABORTED: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1576/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-url-dispatcher-ci/51/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Ted Gould (ted) wrote :

Woot! Deleting code is the easiest way to increase test coverage! ;-)

review: Approve

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 2017-03-06 19:28:41 +0000
3+++ CMakeLists.txt 2017-03-16 17:00:40 +0000
4@@ -78,6 +78,9 @@
5 pkg_check_modules(APPARMOR REQUIRED libapparmor)
6 include_directories(${APPARMOR_INCLUDE_DIRS})
7
8+pkg_check_modules(WHOOPSIE REQUIRED libwhoopsie)
9+include_directories(${WHOOPSIE_INCLUDE_DIRS})
10+
11 if(${LOCAL_INSTALL})
12 set(DBUSSERVICEDIR "${CMAKE_INSTALL_DATADIR}/dbus-1/services/")
13 else()
14
15=== modified file 'debian/control'
16--- debian/control 2017-03-14 14:34:06 +0000
17+++ debian/control 2017-03-16 17:00:40 +0000
18@@ -21,6 +21,7 @@
19 libsqlite3-dev,
20 libubuntu-app-launch3-dev (>= 0.5),
21 libunity-scopes-dev,
22+ libwhoopsie-dev (>= 0.2.52),
23 python3:any,
24 python3-dbusmock <!cross>,
25 python3-fixtures <!cross>,
26
27=== modified file 'service/CMakeLists.txt'
28--- service/CMakeLists.txt 2017-03-06 19:28:41 +0000
29+++ service/CMakeLists.txt 2017-03-16 17:00:40 +0000
30@@ -53,6 +53,7 @@
31 ${SCOPES_LIBRARIES}
32 ${SQLITE_LIBRARIES}
33 ${UBUNTU_APP_LAUNCH_LIBRARIES}
34+ ${WHOOPSIE_LIBRARIES}
35 )
36
37 ###########################
38@@ -86,19 +87,19 @@
39
40 include_directories(${CMAKE_CURRENT_BINARY_DIR})
41
42-add_executable(service-exec service.c recoverable-problem.h recoverable-problem.c)
43+add_executable(service-exec service.c)
44
45 set_target_properties(service-exec PROPERTIES OUTPUT_NAME "url-dispatcher")
46
47-target_link_libraries(service-exec dispatcher-lib)
48+target_link_libraries(service-exec ${WHOOPSIE_LIBRARIES} dispatcher-lib)
49
50 ###########################
51 # Update Directory
52 ###########################
53
54-add_executable(update-directory update-directory.c recoverable-problem.c)
55+add_executable(update-directory update-directory.c)
56 set_target_properties(update-directory PROPERTIES OUTPUT_NAME "update-directory")
57-target_link_libraries(update-directory ${GIO2_LIBRARIES} ${JSONGLIB_LIBRARIES} url-db-lib)
58+target_link_libraries(update-directory ${GIO2_LIBRARIES} ${JSONGLIB_LIBRARIES} ${WHOOPSIE_LIBRARIES} url-db-lib)
59
60 ###########################
61 # Coverage
62
63=== modified file 'service/dispatcher.c'
64--- service/dispatcher.c 2017-03-09 22:21:52 +0000
65+++ service/dispatcher.c 2017-03-16 17:00:40 +0000
66@@ -1,5 +1,5 @@
67 /**
68- * Copyright (C) 2013 Canonical, Ltd.
69+ * Copyright (C) 2013-2017 Canonical, Ltd.
70 *
71 * This program is free software: you can redistribute it and/or modify it under
72 * the terms of the GNU Lesser General Public License version 3, as published by
73@@ -18,10 +18,10 @@
74 */
75
76 #include <gio/gio.h>
77+#include <libwhoopsie/recoverable-problem.h>
78 #include <ubuntu-app-launch.h>
79 #include "dispatcher.h"
80 #include "service-iface.h"
81-#include "recoverable-problem.h"
82 #include "scope-checker.h"
83 #include "url-db.h"
84
85@@ -84,7 +84,7 @@
86 NULL
87 };
88
89- report_recoverable_problem("url-dispatcher-bad-url", pid, FALSE, additional);
90+ whoopsie_report_recoverable_problem("url-dispatcher-bad-url", pid, FALSE, additional);
91
92 g_free(badurl);
93
94
95=== removed file 'service/recoverable-problem.c'
96--- service/recoverable-problem.c 2015-05-18 17:46:38 +0000
97+++ service/recoverable-problem.c 1970-01-01 00:00:00 +0000
98@@ -1,171 +0,0 @@
99-/*
100- * Copyright 2013 Canonical Ltd.
101- *
102- * This program is free software: you can redistribute it and/or modify it
103- * under the terms of the GNU General Public License version 3, as published
104- * by the Free Software Foundation.
105- *
106- * This program is distributed in the hope that it will be useful, but
107- * WITHOUT ANY WARRANTY; without even the implied warranties of
108- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
109- * PURPOSE. See the GNU General Public License for more details.
110- *
111- * You should have received a copy of the GNU General Public License along
112- * with this program. If not, see <http://www.gnu.org/licenses/>.
113- *
114- * Authors:
115- * Ted Gould <ted.gould@canonical.com>
116- */
117-
118-#include "recoverable-problem.h"
119-#include <glib/gstdio.h>
120-#include <string.h>
121-#include <errno.h>
122-
123-/* Helpers to ensure we write nicely */
124-static void
125-write_string (int fd,
126- const gchar *string)
127-{
128- int res;
129- do
130- res = write (fd, string, strlen (string));
131- while (G_UNLIKELY (res == -1 && errno == EINTR));
132-}
133-
134-/* Make NULLs fast and fun! */
135-static void
136-write_null (int fd)
137-{
138- int res;
139- do
140- res = write (fd, "", 1);
141- while (G_UNLIKELY (res == -1 && errno == EINTR));
142-}
143-
144-/* Child watcher */
145-static gboolean
146-apport_child_watch (GPid pid, gint status, gpointer user_data)
147-{
148- g_main_loop_quit((GMainLoop *)user_data);
149- return FALSE;
150-}
151-
152-static gboolean
153-apport_child_timeout (gpointer user_data)
154-{
155- g_warning("Recoverable Error Reporter Timeout");
156- g_main_loop_quit((GMainLoop *)user_data);
157- return FALSE;
158-}
159-
160-/* Code to report an error */
161-void
162-report_recoverable_problem (const gchar * signature, GPid report_pid, gboolean wait, const gchar * additional_properties[])
163-{
164- /* Allow disabling for testing, we don't want to report bugs on
165- our tests ;-) */
166- if (G_UNLIKELY(g_getenv("URL_DISPATCHER_DISABLE_RECOVERABLE_ERROR") != NULL)) {
167- return;
168- }
169-
170- GError * error = NULL;
171- gint error_stdin = 0;
172- GPid pid = 0;
173- gchar * pid_str = NULL;
174- gchar ** argv = NULL;
175- gchar * argv_nopid[2] = {
176- "/usr/share/apport/recoverable_problem",
177- NULL
178- };
179- gchar * argv_pid[4] = {
180- "/usr/share/apport/recoverable_problem",
181- "-p",
182- NULL, /* put pid_str when allocated here */
183- NULL
184- };
185-
186-
187- argv = (gchar **)argv_nopid;
188-
189- if (report_pid != 0) {
190- pid_str = g_strdup_printf("%d", report_pid);
191- argv_pid[2] = pid_str;
192- argv = (gchar**)argv_pid;
193- }
194-
195- GSpawnFlags flags = G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL;
196- if (wait) {
197- flags |= G_SPAWN_DO_NOT_REAP_CHILD;
198- }
199-
200- g_spawn_async_with_pipes(NULL, /* cwd */
201- argv,
202- NULL, /* envp */
203- flags,
204- NULL, NULL, /* child setup func */
205- &pid,
206- &error_stdin,
207- NULL, /* stdout */
208- NULL, /* stderr */
209- &error);
210-
211- if (error != NULL) {
212- g_warning("Unable to report a recoverable error: %s", error->message);
213- g_error_free(error);
214- }
215-
216- gboolean first = TRUE;
217-
218- if (error_stdin != 0 && signature != NULL) {
219- write_string(error_stdin, "DuplicateSignature");
220- write_null(error_stdin);
221- write_string(error_stdin, signature);
222-
223- first = FALSE;
224- }
225-
226- if (error_stdin != 0 && additional_properties != NULL) {
227- gint i;
228- for (i = 0; additional_properties[i] != NULL; i++) {
229- if (!first) {
230- write_null(error_stdin);
231- } else {
232- first = FALSE;
233- }
234-
235- write_string(error_stdin, additional_properties[i]);
236- }
237- }
238-
239- if (error_stdin != 0) {
240- close(error_stdin);
241- }
242-
243- if (wait && pid != 0) {
244- GSource * child_source, * timeout_source;
245- GMainContext * context = g_main_context_new();
246- GMainLoop * loop = g_main_loop_new(context, FALSE);
247-
248- child_source = g_child_watch_source_new(pid);
249- g_source_attach(child_source, context);
250- g_source_set_callback(child_source, (GSourceFunc)apport_child_watch, loop, NULL);
251-
252- timeout_source = g_timeout_source_new_seconds(5);
253- g_source_attach(timeout_source, context);
254- g_source_set_callback(timeout_source, apport_child_timeout, loop, NULL);
255-
256- g_main_loop_run(loop);
257-
258- g_source_destroy(timeout_source);
259- g_source_destroy(child_source);
260- g_main_loop_unref(loop);
261- g_main_context_unref(context);
262-
263- g_spawn_close_pid(pid);
264- }
265-
266- g_free(pid_str);
267-
268- return;
269-}
270
271=== removed file 'service/recoverable-problem.h'
272--- service/recoverable-problem.h 2014-05-27 16:51:53 +0000
273+++ service/recoverable-problem.h 1970-01-01 00:00:00 +0000
274@@ -1,26 +0,0 @@
275-/*
276- * Copyright 2013 Canonical Ltd.
277- *
278- * This program is free software: you can redistribute it and/or modify it
279- * under the terms of the GNU General Public License version 3, as published
280- * by the Free Software Foundation.
281- *
282- * This program is distributed in the hope that it will be useful, but
283- * WITHOUT ANY WARRANTY; without even the implied warranties of
284- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
285- * PURPOSE. See the GNU General Public License for more details.
286- *
287- * You should have received a copy of the GNU General Public License along
288- * with this program. If not, see <http://www.gnu.org/licenses/>.
289- *
290- * Authors:
291- * Ted Gould <ted.gould@canonical.com>
292- */
293-
294-#include <gio/gio.h>
295-
296-void report_recoverable_problem (const gchar * signature,
297- GPid report_pid,
298- gboolean wait,
299- const gchar * additional_properties[]);
300-
301
302=== modified file 'service/update-directory.c'
303--- service/update-directory.c 2015-01-09 16:11:45 +0000
304+++ service/update-directory.c 2017-03-16 17:00:40 +0000
305@@ -19,8 +19,8 @@
306
307 #include <gio/gio.h>
308 #include <json-glib/json-glib.h>
309+#include <libwhoopsie/recoverable-problem.h>
310 #include "url-db.h"
311-#include "recoverable-problem.h"
312
313 typedef struct {
314 const gchar * filename;
315@@ -79,7 +79,7 @@
316 additional[3] = protocol;
317 additional[5] = suffix;
318
319- report_recoverable_problem("url-dispatcher-update-sqlite-insert-error", 0, TRUE, additional);
320+ whoopsie_report_recoverable_problem("url-dispatcher-update-sqlite-insert-error", 0, TRUE, additional);
321 }
322 }
323
324@@ -148,7 +148,7 @@
325 };
326 additional[1] = filename;
327
328- report_recoverable_problem("url-dispatcher-update-sqlite-fileupdate-error", 0, TRUE, additional);
329+ whoopsie_report_recoverable_problem("url-dispatcher-update-sqlite-fileupdate-error", 0, TRUE, additional);
330 return FALSE;
331 }
332
333@@ -170,7 +170,7 @@
334 };
335 additional[1] = filename;
336
337- report_recoverable_problem("url-dispatcher-update-remove-file-error", 0, TRUE, additional);
338+ whoopsie_report_recoverable_problem("url-dispatcher-update-remove-file-error", 0, TRUE, additional);
339 }
340 }
341
342@@ -249,7 +249,7 @@
343 gchar * status = g_strdup_printf("%d", close_status);
344 additional[1] = status;
345
346- report_recoverable_problem("url-dispatcher-sqlite-close-error", 0, TRUE, additional);
347+ whoopsie_report_recoverable_problem("url-dispatcher-sqlite-close-error", 0, TRUE, additional);
348 g_free(status);
349 }
350
351
352=== modified file 'service/url-overlay/CMakeLists.txt'
353--- service/url-overlay/CMakeLists.txt 2017-02-28 21:49:38 +0000
354+++ service/url-overlay/CMakeLists.txt 2017-03-16 17:00:40 +0000
355@@ -3,9 +3,9 @@
356 # URL Overlay Exec Tool
357 ###########################
358
359-add_executable(url-overlay-exec-tool exec-tool.c ../recoverable-problem.c)
360+add_executable(url-overlay-exec-tool exec-tool.c)
361 set_target_properties(url-overlay-exec-tool PROPERTIES OUTPUT_NAME "exec-tool")
362-target_link_libraries(url-overlay-exec-tool ${GIO2_LIBRARIES} ${UBUNTU_APP_LAUNCH_LIBRARIES})
363+target_link_libraries(url-overlay-exec-tool ${GIO2_LIBRARIES} ${UBUNTU_APP_LAUNCH_LIBRARIES} ${WHOOPSIE_LIBRARIES})
364
365 install(
366 TARGETS url-overlay-exec-tool
367
368=== modified file 'service/url-overlay/exec-tool.c'
369--- service/url-overlay/exec-tool.c 2017-02-28 21:49:38 +0000
370+++ service/url-overlay/exec-tool.c 2017-03-16 17:00:40 +0000
371@@ -18,10 +18,9 @@
372 */
373
374 #include <glib.h>
375+#include <libwhoopsie/recoverable-problem.h>
376 #include <ubuntu-app-launch.h>
377
378-#include "recoverable-problem.h"
379-
380 gchar *
381 build_exec (const gchar * appid, const gchar * directory)
382 {
383@@ -80,7 +79,7 @@
384 /* Build up our exec */
385 const gchar * appid = g_getenv("APP_ID");
386 if (appid == NULL) {
387- report_recoverable_problem("url-dispatcher-url-overlay-no-appid", 0, TRUE, NULL);
388+ whoopsie_report_recoverable_problem("url-dispatcher-url-overlay-no-appid", 0, TRUE, NULL);
389 return -1;
390 }
391
392@@ -104,7 +103,7 @@
393 NULL
394 };
395
396- report_recoverable_problem("url-dispatcher-url-overlay-bad-appid", 0, TRUE, props);
397+ whoopsie_report_recoverable_problem("url-dispatcher-url-overlay-bad-appid", 0, TRUE, props);
398 return -1;
399 }
400
401
402=== modified file 'tests/recoverable-problem-mock.c'
403--- tests/recoverable-problem-mock.c 2014-06-04 16:03:26 +0000
404+++ tests/recoverable-problem-mock.c 2017-03-16 17:00:40 +0000
405@@ -18,10 +18,9 @@
406 */
407
408 #include <gio/gio.h>
409-#include "recoverable-problem.h"
410
411 void
412-report_recoverable_problem (const gchar * signature, GPid report_pid, gboolean wait, const gchar * additional_properties[])
413+whoopsie_report_recoverable_problem (const gchar * signature, GPid report_pid, gboolean wait, const gchar * additional_properties[])
414 {
415
416 return;

Subscribers

People subscribed via source and target branches