bazzite/spec_files/upower/0002-Revert-Remove-polkit-tests.patch
2024-09-17 11:16:18 -07:00

89 lines
2.2 KiB
Diff

From f55641cd4335997bffd2a662de84c69a45ce9394 Mon Sep 17 00:00:00 2001
From: Kate Hsuan <hpa@redhat.com>
Date: Thu, 22 Aug 2024 20:43:43 +0800
Subject: [PATCH 2/9] Revert "Remove polkit tests"
This reverts commit bddc559713ed3e8d790231139b21c8277931b5d0.
Changes:
- Removed Makefile
- Removed test for UpWakeups
---
README | 1 +
src/up-self-test.c | 26 ++++++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/README b/README
index dd2a18c..d7f325e 100644
--- a/README
+++ b/README
@@ -8,6 +8,7 @@ Requirements:
gio-2.0 >= 2.16.1
gudev-1.0 >= 235 (Linux)
libimobiledevice-1.0 >= 0.9.7 (optional)
+ polkit-gobject-1 >= 124
UPower is an abstraction for enumerating power devices,
listening to device events and querying history and statistics.
diff --git a/src/up-self-test.c b/src/up-self-test.c
index f60618f..a60f5f2 100644
--- a/src/up-self-test.c
+++ b/src/up-self-test.c
@@ -33,6 +33,7 @@
#include "up-device-list.h"
#include "up-history.h"
#include "up-native.h"
+#include "up-polkit.h"
gchar *history_dir = NULL;
@@ -64,6 +65,12 @@ up_test_daemon_func (void)
{
UpDaemon *daemon;
+ /* needs polkit, which only listens to the system bus */
+ if (!g_file_test (DBUS_SYSTEM_SOCKET, G_FILE_TEST_EXISTS)) {
+ puts("No system D-BUS running, skipping test");
+ return;
+ }
+
daemon = up_daemon_new ();
g_assert (daemon != NULL);
@@ -274,6 +281,24 @@ up_test_history_func (void)
rmdir (history_dir);
}
+static void
+up_test_polkit_func (void)
+{
+ UpPolkit *polkit;
+
+ /* polkit only listens to the system bus */
+ if (!g_file_test (DBUS_SYSTEM_SOCKET, G_FILE_TEST_EXISTS)) {
+ puts("No system D-BUS running, skipping test");
+ return;
+ }
+
+ polkit = up_polkit_new ();
+ g_assert (polkit != NULL);
+
+ /* unref */
+ g_object_unref (polkit);
+}
+
int
main (int argc, char **argv)
{
@@ -290,6 +315,7 @@ main (int argc, char **argv)
g_test_add_func ("/power/device_list", up_test_device_list_func);
g_test_add_func ("/power/history", up_test_history_func);
g_test_add_func ("/power/native", up_test_native_func);
+ g_test_add_func ("/power/polkit", up_test_polkit_func);
g_test_add_func ("/power/daemon", up_test_daemon_func);
return g_test_run ();
--
2.46.0