Merge lp:~ted/policykit-unity8/testsuite-fix into lp:policykit-unity8

Proposed by Ted Gould
Status: Merged
Approved by: Charles Kerr
Approved revision: 21
Merged at revision: 13
Proposed branch: lp:~ted/policykit-unity8/testsuite-fix
Merge into: lp:policykit-unity8
Prerequisite: lp:~ted/policykit-unity8/cmake-extras-formatting
Diff against target: 309 lines (+148/-26)
7 files modified
CMakeLists.txt (+1/-1)
debian/rules (+1/-1)
service/agent.cpp (+1/-1)
tests/CMakeLists.txt (+9/-1)
tests/agent-test.cpp (+2/-0)
tests/policykit-mock.h (+41/-22)
tests/polkit-lib-mock.cpp (+93/-0)
To merge this branch: bzr merge lp:~ted/policykit-unity8/testsuite-fix
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
unity-api-1-bot continuous-integration Approve
Review via email: mp+304284@code.launchpad.net

Commit message

Fix test suite and make it run on package build

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:20
https://jenkins.canonical.com/unity-api-1/job/lp-policykit-unity8-ci/6/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build/520/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/526
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=vivid+overlay/431
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=xenial+overlay/431
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=yakkety/431
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/361/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/361
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/361/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/361
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/361/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/361/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/361/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/361
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/361/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/361/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/361
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/361/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/361
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/361/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-policykit-unity8-ci/6/rebuild

review: Needs Fixing (continuous-integration)
21. By Ted Gould

Drop format code test as it fails on vivid :-(

Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

PASSED: Continuous integration, rev:21
https://jenkins.canonical.com/unity-api-1/job/lp-policykit-unity8-ci/7/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build/521
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/527
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=vivid+overlay/432
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=xenial+overlay/432
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=yakkety/432
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/362
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/362/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/362
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/362/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/362
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/362/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/362
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/362/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/362
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/362/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/362
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/362/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/362
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/362/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/362
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/362/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/362
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/362/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-policykit-unity8-ci/7/rebuild

review: Approve (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

Looks great. Nice work!

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 2016-08-29 19:14:44 +0000
3+++ CMakeLists.txt 2016-08-29 19:14:44 +0000
4@@ -82,4 +82,4 @@
5 get_property(FORMAT_SOURCES_LOCAL GLOBAL PROPERTY FORMAT_SOURCES)
6 message(STATUS "Formatting sources: ${FORMAT_SOURCES_LOCAL}")
7 add_formatcode_target(${FORMAT_SOURCES_LOCAL} STYLE_NAME unity-api)
8-add_formatcode_test(${FORMAT_SOURCES_LOCAL} STYLE_NAME unity-api)
9+#add_formatcode_test(${FORMAT_SOURCES_LOCAL} STYLE_NAME unity-api)
10
11=== modified file 'debian/rules'
12--- debian/rules 2016-04-21 17:54:23 +0000
13+++ debian/rules 2016-08-29 19:14:44 +0000
14@@ -7,7 +7,7 @@
15 include /usr/share/dpkg/default.mk
16
17 override_dh_auto_configure:
18- dh_auto_configure -- -DCMAKE_INSTALL_LIBEXECDIR=/usr/lib/$(DEB_HOST_MULTIARCH)/policykit-unity8 -Denable_tests=OFF
19+ dh_auto_configure -- -DCMAKE_INSTALL_LIBEXECDIR=/usr/lib/$(DEB_HOST_MULTIARCH)/policykit-unity8
20
21 %:
22 dh $@ --parallel --fail-missing
23
24=== modified file 'service/agent.cpp'
25--- service/agent.cpp 2016-08-29 19:14:44 +0000
26+++ service/agent.cpp 2016-08-29 19:14:44 +0000
27@@ -49,7 +49,7 @@
28 g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
29 /* Makes us the fallback agent so that system settings can override
30 when it is setting multiple password settings all at once. */
31- g_variant_builder_add_parsed(&builder, "{'fallback', true}");
32+ g_variant_builder_add_parsed(&builder, "{'fallback', <true>}");
33
34 /* Register it */
35 GError* registererror = nullptr;
36
37=== modified file 'tests/CMakeLists.txt'
38--- tests/CMakeLists.txt 2016-08-29 19:14:44 +0000
39+++ tests/CMakeLists.txt 2016-08-29 19:14:44 +0000
40@@ -3,6 +3,9 @@
41 include_directories(${GIO_INCLUDE_DIRS})
42 include_directories(${NOTIFY_INCLUDE_DIRS})
43
44+include_directories(${POLICYKIT_INCLUDE_DIRS})
45+add_definitions(-DPOLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE)
46+
47 ##############
48 # Google Test
49 ##############
50@@ -27,6 +30,7 @@
51
52 add_executable (agent-test
53 agent-test.cpp
54+ polkit-lib-mock.cpp
55 )
56
57 target_link_libraries(agent-test
58@@ -39,7 +43,11 @@
59 COMMAND agent-test
60 )
61
62-set_property(GLOBAL APPEND PROPERTY FORMAT_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/agent-test.cpp")
63+set_property(GLOBAL APPEND PROPERTY FORMAT_SOURCES
64+ "${CMAKE_CURRENT_SOURCE_DIR}/agent-test.cpp"
65+ "${CMAKE_CURRENT_SOURCE_DIR}/polkit-lib-mock.cpp"
66+ "${CMAKE_CURRENT_SOURCE_DIR}/policykit-mock.h"
67+)
68
69 ##############
70 # AuthManager
71
72=== modified file 'tests/agent-test.cpp'
73--- tests/agent-test.cpp 2016-08-29 19:14:44 +0000
74+++ tests/agent-test.cpp 2016-08-29 19:14:44 +0000
75@@ -230,6 +230,8 @@
76 auto managermock = std::make_shared<AuthManagerMock>();
77
78 Agent agent(managermock);
79+
80+ EXPECT_TRUE(policykit->checkRegistration());
81 }
82
83 /* Checking that we can start an authentication setup
84
85=== modified file 'tests/policykit-mock.h'
86--- tests/policykit-mock.h 2016-05-09 19:29:12 +0000
87+++ tests/policykit-mock.h 2016-08-29 19:14:44 +0000
88@@ -32,8 +32,8 @@
89
90 class PolicyKitMock
91 {
92- DbusTestDbusMock *mock = nullptr;
93- DbusTestDbusMockObject *baseobj = nullptr;
94+ DbusTestDbusMock* mock = nullptr;
95+ DbusTestDbusMockObject* baseobj = nullptr;
96 GLib::ContextThread thread;
97
98 public:
99@@ -65,16 +65,16 @@
100 operator std::shared_ptr<DbusTestTask>()
101 {
102 std::shared_ptr<DbusTestTask> retval(DBUS_TEST_TASK(g_object_ref(mock)),
103- [](DbusTestTask *task) { g_clear_object(&task); });
104+ [](DbusTestTask* task) { g_clear_object(&task); });
105 return retval;
106 }
107
108- operator DbusTestTask *()
109+ operator DbusTestTask*()
110 {
111 return DBUS_TEST_TASK(mock);
112 }
113
114- operator DbusTestDbusMock *()
115+ operator DbusTestDbusMock*()
116 {
117 return mock;
118 }
119@@ -88,19 +88,19 @@
120 }
121
122 std::future<bool> beginAuthentication(
123- const std::string &dbusAddress,
124- const std::string &dbusPath,
125- const std::string &action_id,
126- const std::string &message,
127- const std::string &icon_name,
128- const std::list<std::pair<std::string, std::string>> &details,
129- const std::string &cookie,
130- const std::list<std::pair<std::string, std::map<std::string, std::shared_ptr<GVariant>>>> &identities)
131+ const std::string& dbusAddress,
132+ const std::string& dbusPath,
133+ const std::string& action_id,
134+ const std::string& message,
135+ const std::string& icon_name,
136+ const std::list<std::pair<std::string, std::string>>& details,
137+ const std::string& cookie,
138+ const std::list<std::pair<std::string, std::map<std::string, std::shared_ptr<GVariant>>>>& identities)
139 {
140
141 return thread.executeOnThread<std::future<bool>>(
142 [dbusAddress, dbusPath, action_id, message, icon_name, details, cookie, identities]() {
143- std::promise<bool> *promise = new std::promise<bool>();
144+ std::promise<bool>* promise = new std::promise<bool>();
145
146 GVariantBuilder builder;
147 g_variant_builder_init(&builder, G_VARIANT_TYPE_TUPLE);
148@@ -166,12 +166,12 @@
149 });
150 }
151
152- std::future<bool> cancelAuthentication(const std::string &dbusAddress,
153- const std::string &dbusPath,
154- const std::string &cookie)
155+ std::future<bool> cancelAuthentication(const std::string& dbusAddress,
156+ const std::string& dbusPath,
157+ const std::string& cookie)
158 {
159 return thread.executeOnThread<std::future<bool>>([dbusAddress, dbusPath, cookie]() {
160- std::promise<bool> *promise = new std::promise<bool>();
161+ std::promise<bool>* promise = new std::promise<bool>();
162
163 GVariantBuilder builder;
164 g_variant_builder_init(&builder, G_VARIANT_TYPE_TUPLE);
165@@ -203,12 +203,12 @@
166 });
167 }
168
169- static void dbusMessageCallback(GObject *source_object, GAsyncResult *res, gpointer user_data)
170+ static void dbusMessageCallback(GObject* source_object, GAsyncResult* res, gpointer user_data)
171 {
172- auto promise = reinterpret_cast<std::promise<bool> *>(user_data);
173- GError *error = nullptr;
174+ auto promise = reinterpret_cast<std::promise<bool>*>(user_data);
175+ GError* error = nullptr;
176
177- auto var = g_dbus_connection_call_finish(reinterpret_cast<GDBusConnection *>(source_object), res, &error);
178+ auto var = g_dbus_connection_call_finish(reinterpret_cast<GDBusConnection*>(source_object), res, &error);
179
180 if (error != nullptr)
181 {
182@@ -220,10 +220,29 @@
183 {
184 g_debug("DBus Message complete");
185 if (var != nullptr)
186+ {
187 g_variant_unref(var);
188+ }
189 promise->set_value(true);
190 }
191
192 delete promise;
193 }
194+
195+ bool checkRegistration()
196+ {
197+ return thread.executeOnThread<bool>([this]() {
198+ guint len = 0;
199+ dbus_test_dbus_mock_object_get_method_calls(mock, baseobj, "RegisterAuthenticationAgentWithOptions", &len,
200+ nullptr);
201+
202+ return len > 0;
203+ });
204+ }
205+
206+ bool clearRegistration()
207+ {
208+ return thread.executeOnThread<bool>(
209+ [this]() { return dbus_test_dbus_mock_object_clear_method_calls(mock, baseobj, nullptr); });
210+ }
211 };
212
213=== added file 'tests/polkit-lib-mock.cpp'
214--- tests/polkit-lib-mock.cpp 1970-01-01 00:00:00 +0000
215+++ tests/polkit-lib-mock.cpp 2016-08-29 19:14:44 +0000
216@@ -0,0 +1,93 @@
217+/*
218+ * Copyright © 2016 Canonical Ltd.
219+ *
220+ * This program is free software: you can redistribute it and/or modify it
221+ * under the terms of the GNU General Public License version 3, as published
222+ * by the Free Software Foundation.
223+ *
224+ * This program is distributed in the hope that it will be useful, but
225+ * WITHOUT ANY WARRANTY; without even the implied warranties of
226+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
227+ * PURPOSE. See the GNU General Public License for more details.
228+ *
229+ * You should have received a copy of the GNU General Public License along
230+ * with this program. If not, see <http://www.gnu.org/licenses/>.
231+ *
232+ * Authors:
233+ * Ted Gould <ted.gould@canonical.com>
234+ */
235+
236+#include <polkitagent/polkitagent.h>
237+
238+#define POLKIT_MOCK_SUBJECT_TYPE (polkit_mock_subject_get_type())
239+#define POLKIT_MOCK_SUBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), POLKIT_MOCK_SUBJECT_TYPE, PolkitMockSubject))
240+#define POLKIT_MOCK_SUBJECT_CLASS(klass) \
241+ (G_TYPE_CHECK_CLASS_CAST((klass), POLKIT_MOCK_SUBJECT_TYPE, PolkitMockSubjectClass))
242+#define IS_POLKIT_MOCK_SUBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), POLKIT_MOCK_SUBJECT_TYPE))
243+#define IS_POLKIT_MOCK_SUBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), POLKIT_MOCK_SUBJECT_TYPE))
244+#define POLKIT_MOCK_SUBJECT_GET_CLASS(obj) \
245+ (G_TYPE_INSTANCE_GET_CLASS((obj), POLKIT_MOCK_SUBJECT_TYPE, PolkitMockSubjectClass))
246+
247+typedef struct _PolkitMockSubject PolkitMockSubject;
248+typedef struct _PolkitMockSubjectClass PolkitMockSubjectClass;
249+
250+struct _PolkitMockSubjectClass
251+{
252+ GObjectClass parent_class;
253+};
254+
255+struct _PolkitMockSubject
256+{
257+ GObject parent;
258+};
259+
260+GType polkit_mock_subject_get_type(void);
261+
262+typedef struct _PolkitMockSubjectPrivate PolkitMockSubjectPrivate;
263+
264+struct _PolkitMockSubjectPrivate
265+{
266+ int dummy;
267+};
268+
269+#define POLKIT_MOCK_SUBJECT_GET_PRIVATE(o) \
270+ (G_TYPE_INSTANCE_GET_PRIVATE((o), POLKIT_MOCK_SUBJECT_TYPE, PolkitMockSubjectPrivate))
271+
272+static void polkit_mock_subject_class_init(PolkitMockSubjectClass* klass);
273+static void polkit_mock_subject_init(PolkitMockSubject* self);
274+static void polkit_mock_subject_dispose(GObject* object);
275+static void polkit_mock_subject_finalize(GObject* object);
276+
277+G_DEFINE_TYPE_WITH_CODE(PolkitMockSubject,
278+ polkit_mock_subject,
279+ G_TYPE_OBJECT,
280+ G_IMPLEMENT_INTERFACE(POLKIT_TYPE_SUBJECT, nullptr));
281+
282+static void polkit_mock_subject_class_init(PolkitMockSubjectClass* klass)
283+{
284+ GObjectClass* object_class = G_OBJECT_CLASS(klass);
285+
286+ g_type_class_add_private(klass, sizeof(PolkitMockSubjectPrivate));
287+
288+ object_class->dispose = polkit_mock_subject_dispose;
289+ object_class->finalize = polkit_mock_subject_finalize;
290+}
291+
292+static void polkit_mock_subject_init(PolkitMockSubject* self)
293+{
294+}
295+
296+static void polkit_mock_subject_dispose(GObject* object)
297+{
298+ G_OBJECT_CLASS(polkit_mock_subject_parent_class)->dispose(object);
299+}
300+
301+static void polkit_mock_subject_finalize(GObject* object)
302+{
303+ G_OBJECT_CLASS(polkit_mock_subject_parent_class)->finalize(object);
304+}
305+
306+PolkitSubject* polkit_unix_session_new_for_process_sync(gint pid, GCancellable* cancel, GError** error)
307+{
308+ return (PolkitSubject*)g_object_new(POLKIT_MOCK_SUBJECT_TYPE, nullptr);
309+}

Subscribers

People subscribed via source and target branches

to all changes: