Merge lp:~thomas-voss/platform-api/support-null-backend into lp:platform-api

Proposed by Thomas Voß
Status: Merged
Approved by: Alexandros Frantzis
Approved revision: 328
Merged at revision: 326
Proposed branch: lp:~thomas-voss/platform-api/support-null-backend
Merge into: lp:platform-api
Diff against target: 61 lines (+11/-4)
3 files modified
src/ubuntu/application/base_module.h (+9/-2)
src/ubuntu/application/ubuntu_application_api.cpp (+1/-1)
tests/test_ua_sensors_mock.cpp (+1/-1)
To merge this branch: bzr merge lp:~thomas-voss/platform-api/support-null-backend
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+301707@code.launchpad.net

Commit message

Do not fallback to test backend automatically.
Instead, handle the NULL case more gracefully in case of ctor implementations.

Description of the change

Do not fallback to test backend automatically.
Instead, handle the NULL case more gracefully in case of ctor implementations.

To post a comment you must log in.
327. By Thomas Voß

Render test more robust.

328. By Thomas Voß

Ensure we return NULL for all symbol resolutions when we don't have a valid lib handle.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ubuntu/application/base_module.h'
2--- src/ubuntu/application/base_module.h 2015-03-25 23:13:33 +0000
3+++ src/ubuntu/application/base_module.h 2016-08-02 11:25:56 +0000
4@@ -64,8 +64,8 @@
5 }
6 if (cache == NULL) {
7 // No module available, use dummy.
8- fprintf(stderr, "Unable to select module, using dummy.\n");
9- strcpy(path, override_path());
10+ fprintf(stderr, "Unable to select module, using null backend.\n");
11+ return NULL;
12 } else {
13 strcpy(path, "libubuntu_application_api_");
14
15@@ -103,6 +103,11 @@
16
17 static void* dlopen_fn(const char* path, int flags)
18 {
19+ // We take a NULL path as an indication that we are running with a
20+ // null backend.
21+ if (not path)
22+ return NULL;
23+
24 void *handle = dlopen(path, flags);
25 if (handle == NULL) {
26 fprintf(stderr, "Unable to load selected module, using dummy.\n");
27@@ -117,6 +122,8 @@
28
29 static void* dlsym_fn(void* handle, const char* symbol)
30 {
31+ if (not handle)
32+ return NULL;
33 return dlsym(handle, symbol);
34 }
35 };
36
37=== modified file 'src/ubuntu/application/ubuntu_application_api.cpp'
38--- src/ubuntu/application/ubuntu_application_api.cpp 2015-09-29 12:21:55 +0000
39+++ src/ubuntu/application/ubuntu_application_api.cpp 2016-08-02 11:25:56 +0000
40@@ -50,7 +50,7 @@
41 IMPLEMENT_VOID_FUNCTION0(init, u_application_finish);
42
43 // Lifecycle helpers
44-IMPLEMENT_FUNCTION0(lifecycle, UApplicationLifecycleDelegate*, u_application_lifecycle_delegate_new);
45+IMPLEMENT_CTOR0(lifecycle, UApplicationLifecycleDelegate*, u_application_lifecycle_delegate_new);
46 IMPLEMENT_VOID_FUNCTION2(lifecycle, u_application_lifecycle_delegate_set_context, UApplicationLifecycleDelegate*, void*);
47 IMPLEMENT_VOID_FUNCTION1(lifecycle, u_application_lifecycle_delegate_ref, UApplicationLifecycleDelegate*);
48 IMPLEMENT_VOID_FUNCTION1(lifecycle, u_application_lifecycle_delegate_unref, UApplicationLifecycleDelegate*);
49
50=== modified file 'tests/test_ua_sensors_mock.cpp'
51--- tests/test_ua_sensors_mock.cpp 2014-05-20 15:11:27 +0000
52+++ tests/test_ua_sensors_mock.cpp 2016-08-02 11:25:56 +0000
53@@ -225,7 +225,7 @@
54 event_time = time_point_system_ns(std::chrono::nanoseconds(e.timestamp));
55 delay = chrono::duration_cast<chrono::milliseconds>(event_time - start_time).count();
56 EXPECT_GE(delay, 91);
57- EXPECT_LE(delay, 111);
58+ EXPECT_LE(delay, 112);
59 })
60
61 TESTP_F(SimBackendTest, AccelEvents, {

Subscribers

People subscribed via source and target branches