summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2010-03-26 06:27:03 +0100
committerMartin Pitt <martin.pitt@ubuntu.com>2010-03-26 11:17:49 +0100
commit37a56ea0da2e53be880ea5216e5be41b16dc1880 (patch)
tree3301adfa3847749e7cc9f5c48d1f5d66e9c7371e
parent9f26b3f866513ba6b2cdd286c52c7f87262f754e (diff)
Make dummy backend usable for architectures without a native backend
Currently, the dummy backend is mostly used to run the unit tests. We want to make it usable though on architectures, like GNU/Hurd, which dont't have a native backend yet. Compile two different flavours of the dummy backend: one with the TEST code enabled and which is used by up_self_test, and one without the TEST code, used by upowerd when the dummy backend is selected. Patch is based on work by Pino Toscano. Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
-rw-r--r--src/Makefile.am2
-rw-r--r--src/dummy/Makefile.am13
-rw-r--r--src/dummy/up-backend.c12
3 files changed, 24 insertions, 3 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 7b6f954..74fa3b7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -148,7 +148,7 @@ up_self_test_SOURCES = \
up_self_test_LDADD = \
-lm \
- dummy/libupshared.la \
+ dummy/libuptest.la \
$(GLIB_LIBS) \
$(GIO_CFLAGS) \
$(DBUS_GLIB_LIBS) \
diff --git a/src/dummy/Makefile.am b/src/dummy/Makefile.am
index 548b891..71c094a 100644
--- a/src/dummy/Makefile.am
+++ b/src/dummy/Makefile.am
@@ -3,19 +3,28 @@
INCLUDES = \
-I$(top_builddir)/src -I$(top_srcdir)/src \
-DUP_COMPILATION \
- -DEGG_TEST \
-I$(top_srcdir)/libupower-glib \
$(DBUS_GLIB_CFLAGS) \
$(POLKIT_CFLAGS) \
$(GLIB_CFLAGS)
-noinst_LTLIBRARIES = libupshared.la
+noinst_LTLIBRARIES =
+
+if BACKEND_TYPE_DUMMY
+noinst_LTLIBRARIES += libupshared.la
+endif
libupshared_la_SOURCES = \
up-backend.c \
up-native.c \
$(BUILT_SOURCES)
+if EGG_BUILD_TESTS
+noinst_LTLIBRARIES += libuptest.la
+libuptest_la_CFLAGS = -DEGG_TEST
+libuptest_la_SOURCES = $(libupshared_la_SOURCES)
+endif
+
clean-local :
rm -f *~
diff --git a/src/dummy/up-backend.c b/src/dummy/up-backend.c
index 02909e9..8c99359 100644
--- a/src/dummy/up-backend.c
+++ b/src/dummy/up-backend.c
@@ -43,9 +43,13 @@ static void up_backend_finalize (GObject *object);
struct UpBackendPrivate
{
UpDaemon *daemon;
+#ifdef EGG_TEST
UpDevice *device;
+#endif
UpDeviceList *device_list; /* unused */
+#ifdef EGG_TEST
GObject *native;
+#endif
};
enum {
@@ -58,6 +62,7 @@ static guint signals [SIGNAL_LAST] = { 0 };
G_DEFINE_TYPE (UpBackend, up_backend, G_TYPE_OBJECT)
+#ifdef EGG_TEST
/**
* up_backend_changed_time_cb:
**/
@@ -99,6 +104,7 @@ up_backend_add_cb (UpBackend *backend)
out:
return FALSE;
}
+#endif
/**
* up_backend_coldplug:
@@ -116,8 +122,10 @@ up_backend_coldplug (UpBackend *backend, UpDaemon *daemon)
backend->priv->daemon = g_object_ref (daemon);
backend->priv->device_list = up_daemon_get_device_list (daemon);
+#ifdef EGG_TEST
/* small delay until first device is added */
g_timeout_add_seconds (1, (GSourceFunc) up_backend_add_cb, backend);
+#endif
return TRUE;
}
@@ -157,6 +165,7 @@ up_backend_init (UpBackend *backend)
backend->priv = UP_BACKEND_GET_PRIVATE (backend);
backend->priv->daemon = NULL;
backend->priv->device_list = NULL;
+#ifdef EGG_TEST
backend->priv->native = g_object_new (UP_TYPE_DEVICE, NULL);
backend->priv->device = up_device_new ();
@@ -181,6 +190,7 @@ up_backend_init (UpBackend *backend)
"energy-rate", 5.0f,
"percentage", 50.0f,
NULL);
+#endif
}
/**
@@ -200,8 +210,10 @@ up_backend_finalize (GObject *object)
if (backend->priv->device_list != NULL)
g_object_unref (backend->priv->device_list);
+#ifdef EGG_TEST
g_object_unref (backend->priv->native);
g_object_unref (backend->priv->device);
+#endif
G_OBJECT_CLASS (up_backend_parent_class)->finalize (object);
}