Skip to content

Commit c431f59

Browse files
committed
Add tests for new ConsoleKit XDG_RUNTIME_DIR support
1 parent 64193ad commit c431f59

File tree

5 files changed

+66
-2
lines changed

5 files changed

+66
-2
lines changed

tests/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ TESTS = \
199199
test-audit-autologin \
200200
test-no-accounts-service \
201201
test-console-kit \
202+
test-console-kit-no-xdg-runtime \
202203
test-no-console-kit \
203204
test-no-login1 \
204205
test-no-console-kit-or-login1 \
@@ -422,6 +423,7 @@ EXTRA_DIST = \
422423
scripts/change-authentication.conf \
423424
scripts/cancel-authentication.conf \
424425
scripts/console-kit.conf \
426+
scripts/console-kit-no-xdg-runtime.conf \
425427
scripts/corrupt-xauthority.conf \
426428
scripts/crash-authenticate.conf \
427429
scripts/cred-error.conf \
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#
2+
# Check ConsoleKit works when GetXDGRuntime is not supported
3+
#
4+
5+
[test-runner-config]
6+
disable-login1=true
7+
ck-no-xdg-runtime=true
8+
9+
[Seat:*]
10+
autologin-user=have-password1
11+
user-session=default
12+
13+
#?*START-DAEMON
14+
#?RUNNER DAEMON-START
15+
16+
# X server starts
17+
#?XSERVER-0 START VT=7 SEAT=seat0
18+
19+
# Daemon connects when X server is ready
20+
#?*XSERVER-0 INDICATE-READY
21+
#?XSERVER-0 INDICATE-READY
22+
#?XSERVER-0 ACCEPT-CONNECT
23+
24+
# Session starts
25+
#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/have-password1 XDG_SESSION_COOKIE=ck-cookie-x:0 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=have-password1
26+
#?CONSOLE-KIT ACTIVATE-SESSION SESSION=ck-cookie-x:0
27+
#?XSERVER-0 ACCEPT-CONNECT
28+
#?SESSION-X-0 CONNECT-XSERVER
29+
30+
# Check XDG_RUNTIME_DIR is NOT set
31+
#?*SESSION-X-0 READ-ENV NAME=XDG_RUNTIME_DIR
32+
#?SESSION-X-0 READ-ENV NAME=XDG_RUNTIME_DIR VALUE=
33+
34+
# Cleanup
35+
#?*STOP-DAEMON
36+
#?SESSION-X-0 TERMINATE SIGNAL=15
37+
#?XSERVER-0 TERMINATE SIGNAL=15
38+
#?RUNNER DAEMON-EXIT STATUS=0

tests/scripts/console-kit.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ user-session=default
2626
#?XSERVER-0 ACCEPT-CONNECT
2727
#?SESSION-X-0 CONNECT-XSERVER
2828

29+
# Check XDG_RUNTIME_DIR is set
30+
#?*SESSION-X-0 READ-ENV NAME=XDG_RUNTIME_DIR
31+
#?SESSION-X-0 READ-ENV NAME=XDG_RUNTIME_DIR VALUE=/run/console-kit
32+
2933
# Cleanup
3034
#?*STOP-DAEMON
3135
#?SESSION-X-0 TERMINATE SIGNAL=15

tests/src/test-runner.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,7 +1395,11 @@ handle_ck_session_call (GDBusConnection *connection,
13951395
{
13961396
CKSession *session = user_data;
13971397

1398-
if (strcmp (method_name, "Lock") == 0)
1398+
if (strcmp (method_name, "GetXDGRuntimeDir") == 0 && !g_key_file_get_boolean (config, "test-runner-config", "ck-no-xdg-runtime", NULL))
1399+
{
1400+
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", "/run/console-kit"));
1401+
}
1402+
else if (strcmp (method_name, "Lock") == 0)
13991403
{
14001404
if (!session->locked)
14011405
check_status ("CONSOLE-KIT LOCK-SESSION");
@@ -1464,9 +1468,20 @@ ck_name_acquired_cb (GDBusConnection *connection,
14641468
{
14651469
handle_ck_call,
14661470
};
1471+
const gchar *ck_session_interface_old =
1472+
"<node>"
1473+
" <interface name='org.freedesktop.ConsoleKit.Session'>"
1474+
" <method name='Lock'/>"
1475+
" <method name='Unlock'/>"
1476+
" <method name='Activate'/>"
1477+
" </interface>"
1478+
"</node>";
14671479
const gchar *ck_session_interface =
14681480
"<node>"
14691481
" <interface name='org.freedesktop.ConsoleKit.Session'>"
1482+
" <method name='GetXDGRuntimeDir'>"
1483+
" <arg name='dir' direction='out' type='s'/>"
1484+
" </method>"
14701485
" <method name='Lock'/>"
14711486
" <method name='Unlock'/>"
14721487
" <method name='Activate'/>"
@@ -1481,7 +1496,10 @@ ck_name_acquired_cb (GDBusConnection *connection,
14811496
g_clear_error (&error);
14821497
if (!ck_info)
14831498
return;
1484-
ck_session_info = g_dbus_node_info_new_for_xml (ck_session_interface, &error);
1499+
if (g_key_file_get_boolean (config, "test-runner-config", "ck-no-xdg-runtime", NULL))
1500+
ck_session_info = g_dbus_node_info_new_for_xml (ck_session_interface_old, &error);
1501+
else
1502+
ck_session_info = g_dbus_node_info_new_for_xml (ck_session_interface, &error);
14851503
if (error)
14861504
g_warning ("Failed to parse D-Bus interface: %s", error->message);
14871505
g_clear_error (&error);

tests/test-console-kit-no-xdg-runtime

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
./src/dbus-env ./src/test-runner console-kit-no-xdg-runtime test-gobject-greeter

0 commit comments

Comments
 (0)