diff options
author | Richard Hughes <richard@hughsie.com> | 2010-06-05 17:00:34 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2010-06-05 17:00:34 +0100 |
commit | 6ba86292e9e86601365c23a8f7f89f05a43ccd33 (patch) | |
tree | 5d5e16e197415a043ad21f6c98eafc84ea52aa5b /src | |
parent | 82a6a882d03c145625edbe23dade65bc14f85e73 (diff) |
Port to GTest
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 8 | ||||
-rw-r--r-- | src/dummy/Makefile.am | 2 | ||||
-rw-r--r-- | src/dummy/up-backend.c | 27 | ||||
-rw-r--r-- | src/dummy/up-native.c | 24 | ||||
-rw-r--r-- | src/egg-test.c | 360 | ||||
-rw-r--r-- | src/egg-test.h | 48 | ||||
-rw-r--r-- | src/freebsd/up-backend.c | 27 | ||||
-rw-r--r-- | src/up-daemon.c | 27 | ||||
-rw-r--r-- | src/up-device-list.c | 52 | ||||
-rw-r--r-- | src/up-device.c | 27 | ||||
-rw-r--r-- | src/up-history.c | 27 | ||||
-rw-r--r-- | src/up-polkit.c | 27 | ||||
-rw-r--r-- | src/up-qos.c | 27 | ||||
-rw-r--r-- | src/up-self-test.c | 154 | ||||
-rw-r--r-- | src/up-wakeups.c | 27 |
15 files changed, 143 insertions, 721 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 7853172..5ee559a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -117,13 +117,12 @@ upowerd_CFLAGS = \ $(WARNINGFLAGS_C) \ $(NULL) -if EGG_BUILD_TESTS +if UP_BUILD_TESTS + check_PROGRAMS = \ up-self-test up_self_test_SOURCES = \ - egg-test.h \ - egg-test.c \ egg-debug.c \ egg-debug.h \ up-self-test.c \ @@ -154,9 +153,10 @@ up_self_test_LDADD = \ $(POLKIT_LIBS) \ $(UPOWER_LIBS) -up_self_test_CFLAGS = -DEGG_TEST $(AM_CFLAGS) $(WARNINGFLAGS_C) +up_self_test_CFLAGS = $(AM_CFLAGS) $(WARNINGFLAGS_C) TESTS = up-self-test + endif servicedir = $(datadir)/dbus-1/system-services diff --git a/src/dummy/Makefile.am b/src/dummy/Makefile.am index 71c094a..053d295 100644 --- a/src/dummy/Makefile.am +++ b/src/dummy/Makefile.am @@ -19,7 +19,7 @@ libupshared_la_SOURCES = \ up-native.c \ $(BUILT_SOURCES) -if EGG_BUILD_TESTS +if UP_BUILD_TESTS noinst_LTLIBRARIES += libuptest.la libuptest_la_CFLAGS = -DEGG_TEST libuptest_la_SOURCES = $(libupshared_la_SOURCES) diff --git a/src/dummy/up-backend.c b/src/dummy/up-backend.c index 48b2b40..1eef5ca 100644 --- a/src/dummy/up-backend.c +++ b/src/dummy/up-backend.c @@ -291,30 +291,3 @@ up_backend_get_hibernate_command (UpBackend *backend) return "/bin/true"; } -/*************************************************************************** - *** MAKE CHECK TESTS *** - ***************************************************************************/ -#ifdef EGG_TEST -#include "egg-test.h" - -void -up_backend_test (gpointer user_data) -{ - EggTest *test = (EggTest *) user_data; - UpBackend *backend; - - if (!egg_test_start (test, "UpBackend")) - return; - - /************************************************************/ - egg_test_title (test, "get instance"); - backend = up_backend_new (); - egg_test_assert (test, backend != NULL); - - /* unref */ - g_object_unref (backend); - - egg_test_end (test); -} -#endif - diff --git a/src/dummy/up-native.c b/src/dummy/up-native.c index a0daefb..3392f83 100644 --- a/src/dummy/up-native.c +++ b/src/dummy/up-native.c @@ -38,27 +38,3 @@ up_native_get_native_path (GObject *object) return "/sys/dummy"; } -/*************************************************************************** - *** MAKE CHECK TESTS *** - ***************************************************************************/ -#ifdef EGG_TEST -#include "egg-test.h" - -void -up_native_test (gpointer user_data) -{ - EggTest *test = (EggTest *) user_data; - const gchar *path; - - if (!egg_test_start (test, "UpNative")) - return; - - /************************************************************/ - egg_test_title (test, "get instance"); - path = up_native_get_native_path (NULL); - egg_test_assert (test, (g_strcmp0 (path, "/sys/dummy") == 0)); - - egg_test_end (test); -} -#endif - diff --git a/src/egg-test.c b/src/egg-test.c deleted file mode 100644 index af00059..0000000 --- a/src/egg-test.c +++ /dev/null @@ -1,360 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2007-2008 Richard Hughes <richard@hughsie.com> - * - * Licensed under the GNU General Public License Version 2 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <stdlib.h> -#include <glib.h> -#include <string.h> -#include <glib/gprintf.h> - -#include "egg-test.h" - -struct EggTest { - guint total; - guint succeeded; - gboolean started; - gboolean titled; - gchar *type; - GTimer *timer; - GMainLoop *loop; - guint hang_loop_id; - gpointer user_data; -}; - -/** - * egg_test_init: - **/ -EggTest * -egg_test_init () -{ - EggTest *test; - test = g_new (EggTest, 1); - test->total = 0; - test->succeeded = 0; - test->type = NULL; - test->started = FALSE; - test->titled = FALSE; - test->timer = g_timer_new (); - test->loop = g_main_loop_new (NULL, FALSE); - test->hang_loop_id = 0; - return test; -} - -/** - * egg_test_loop_quit: - **/ -void -egg_test_loop_quit (EggTest *test) -{ - /* disable the loop watch */ - if (test->hang_loop_id != 0) { - g_source_remove (test->hang_loop_id); - test->hang_loop_id = 0; - } - g_main_loop_quit (test->loop); -} - -/** - * egg_test_hang_check: - **/ -static gboolean -egg_test_hang_check (gpointer data) -{ - EggTest *test = (EggTest *) data; - g_main_loop_quit (test->loop); - return FALSE; -} - -/** - * egg_test_loop_wait: - **/ -void -egg_test_loop_wait (EggTest *test, guint timeout) -{ - test->hang_loop_id = g_timeout_add (timeout, egg_test_hang_check, test); -#if GLIB_CHECK_VERSION(2,25,8) - g_source_set_name_by_id (test->hang_loop_id, "[EggTest] check"); -#endif - g_main_loop_run (test->loop); -} - -/** - * egg_test_loop_check: - **/ -void -egg_test_loop_check (EggTest *test) -{ - guint elapsed = egg_test_elapsed (test); - egg_test_title (test, "did we timeout out of the loop"); - if (test->hang_loop_id == 0) { - egg_test_success (test, "loop blocked for %ims", elapsed); - } else { - egg_test_failed (test, "hangcheck saved us after %ims", elapsed); - } -} - -/** - * egg_test_set_user_data: - **/ -void -egg_test_set_user_data (EggTest *test, gpointer user_data) -{ - test->user_data = user_data; -} - -/** - * egg_test_get_user_data: - **/ -gpointer -egg_test_get_user_data (EggTest *test) -{ - return test->user_data; -} - -/** - * egg_test_finish: - **/ -gint -egg_test_finish (EggTest *test) -{ - gint retval; - g_print ("test passes (%u/%u) : ", test->succeeded, test->total); - if (test->succeeded == test->total) { - g_print ("ALL OKAY\n"); - retval = 0; - } else { - g_print ("%u FAILURE(S)\n", test->total - test->succeeded); - retval = 1; - } - - g_timer_destroy (test->timer); - g_main_loop_unref (test->loop); - g_free (test); - - return retval; -} - -/** - * egg_test_elapsed: - * - * Returns: time in ms - **/ -guint -egg_test_elapsed (EggTest *test) -{ - gdouble time_s; - time_s = g_timer_elapsed (test->timer, NULL); - return (guint) (time_s * 1000.0f); -} - -/** - * egg_test_start: - **/ -gboolean -egg_test_start (EggTest *test, const gchar *name) -{ - if (test->started) { - g_print ("Not ended test! Cannot start!\n"); - exit (1); - } - test->type = g_strdup (name); - test->started = TRUE; - return TRUE; -} - -/** - * egg_test_end: - **/ -void -egg_test_end (EggTest *test) -{ - if (test->started == FALSE) { - g_print ("Not started test! Cannot finish!\n"); - exit (1); - } - - /* disable hang check */ - if (test->hang_loop_id != 0) { - g_source_remove (test->hang_loop_id); - test->hang_loop_id = 0; - } - - /* remove all the test callbacks */ - while (g_source_remove_by_user_data (test)) - g_print ("WARNING: removed callback for test module"); - - /* check we don't have any pending iterations */ - if (g_main_context_pending (NULL)) { - g_print ("WARNING: Pending event in context! Running to completion... "); - while (g_main_context_pending (NULL)) - g_main_context_iteration (NULL, TRUE); - g_print ("Done!\n"); - } - - test->started = FALSE; - g_free (test->type); -} - -/** - * egg_test_title: - **/ -void -egg_test_title (EggTest *test, const gchar *format, ...) -{ - va_list args; - gchar *va_args_buffer = NULL; - - /* already titled? */ - if (test->titled) { - g_print ("Already titled!\n"); - exit (1); - } - - /* reset the value egg_test_elapsed replies with */ - g_timer_reset (test->timer); - - va_start (args, format); - g_vasprintf (&va_args_buffer, format, args); - va_end (args); - g_print ("> check #%u\t%s: \t%s...", test->total+1, test->type, va_args_buffer); - g_free (va_args_buffer); - - test->titled = TRUE; - test->total++; -} - -/** - * egg_test_success: - **/ -void -egg_test_success (EggTest *test, const gchar *format, ...) -{ - va_list args; - gchar *va_args_buffer = NULL; - - /* not titled? */ - if (!test->titled) { - g_print ("Not titled!\n"); - exit (1); - } - if (format == NULL) { - g_print ("...OK\n"); - goto finish; - } - va_start (args, format); - g_vasprintf (&va_args_buffer, format, args); - va_end (args); - g_print ("...OK [%s]\n", va_args_buffer); - g_free (va_args_buffer); -finish: - test->titled = FALSE; - test->succeeded++; -} - -/** - * egg_test_failed: - **/ -void -egg_test_failed (EggTest *test, const gchar *format, ...) -{ - va_list args; - gchar *va_args_buffer = NULL; - - /* not titled? */ - if (!test->titled) { - g_print ("Not titled!\n"); - exit (1); - } - if (format == NULL) { - g_print ("FAILED\n"); - goto failed; - } - va_start (args, format); - g_vasprintf (&va_args_buffer, format, args); - va_end (args); - g_print ("FAILED [%s]\n", va_args_buffer); - g_free (va_args_buffer); -failed: - exit (1); -} - -/** - * egg_test_assert: - **/ -void -egg_test_assert (EggTest *test, gboolean value) -{ - if (value) - egg_test_success (test, NULL); - else - egg_test_failed (test, NULL); -} - -/** - * egg_test_title_assert: - **/ -void -egg_test_title_assert (EggTest *test, const gchar *text, gboolean value) -{ - egg_test_title (test, "%s", text); - if (value) - egg_test_success (test, NULL); - else - egg_test_failed (test, NULL); -} - -/** - * egg_test_get_data_file: - **/ -gchar * -egg_test_get_data_file (const gchar *filename) -{ - gboolean ret; - gchar *full; - - /* check to see if we are being run in the build root */ - full = g_build_filename ("..", "data", "tests", filename, NULL); - ret = g_file_test (full, G_FILE_TEST_EXISTS); - if (ret) - return full; - g_free (full); - - /* check to see if we are being run in the build root */ - full = g_build_filename ("..", "..", "data", "tests", filename, NULL); - ret = g_file_test (full, G_FILE_TEST_EXISTS); - if (ret) - return full; - g_free (full); - - /* check to see if we are being run in make check */ - full = g_build_filename ("..", "..", "data", "tests", filename, NULL); - ret = g_file_test (full, G_FILE_TEST_EXISTS); - if (ret) - return full; - g_free (full); - full = g_build_filename ("..", "..", "..", "data", "tests", filename, NULL); - ret = g_file_test (full, G_FILE_TEST_EXISTS); - if (ret) - return full; - g_print ("[WARN] failed to find '%s'\n", full); - g_free (full); - return NULL; -} - diff --git a/src/egg-test.h b/src/egg-test.h deleted file mode 100644 index 1b05092..0000000 --- a/src/egg-test.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2007-2008 Richard Hughes <richard@hughsie.com> - * - * Licensed under the GNU General Public License Version 2 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __EGG_TEST_H -#define __EGG_TEST_H - -#include <glib.h> -#include <string.h> - -typedef struct EggTest EggTest; - -gboolean egg_test_start (EggTest *test, const gchar *name); -void egg_test_end (EggTest *test); -void egg_test_title (EggTest *test, const gchar *format, ...); -void egg_test_title_assert (EggTest *test, const gchar *text, gboolean value); -void egg_test_assert (EggTest *test, gboolean value); -void egg_test_success (EggTest *test, const gchar *format, ...); -void egg_test_failed (EggTest *test, const gchar *format, ...) G_GNUC_NORETURN; -EggTest *egg_test_init (void); -gint egg_test_finish (EggTest *test); -guint egg_test_elapsed (EggTest *test); -void egg_test_loop_quit (EggTest *test); -void egg_test_loop_wait (EggTest *test, guint timeout); -void egg_test_loop_check (EggTest *test); -void egg_test_set_user_data (EggTest *test, gpointer user_data); -gpointer egg_test_get_user_data (EggTest *test); -gchar *egg_test_get_data_file (const gchar *filename); - -#endif /* __EGG_TEST_H */ - diff --git a/src/freebsd/up-backend.c b/src/freebsd/up-backend.c index 4f5e918..01465e2 100644 --- a/src/freebsd/up-backend.c +++ b/src/freebsd/up-backend.c @@ -484,30 +484,3 @@ up_backend_new (void) return UP_BACKEND (backend); } -/*************************************************************************** - *** MAKE CHECK TESTS *** - ***************************************************************************/ -#ifdef EGG_TEST -#include "egg-test.h" - -void -up_backend_test (gpointer user_data) -{ - EggTest *test = (EggTest *) user_data; - UpBackend *backend; - - if (!egg_test_start (test, "UpBackend")) - return; - - /************************************************************/ - egg_test_title (test, "get instance"); - backend = up_backend_new (); - egg_test_assert (test, backend != NULL); - - /* unref */ - g_object_unref (backend); - - egg_test_end (test); -} -#endif - diff --git a/src/up-daemon.c b/src/up-daemon.c index 19d23fe..cd5872b 100644 --- a/src/up-daemon.c +++ b/src/up-daemon.c @@ -1262,30 +1262,3 @@ up_daemon_new (void) return daemon; } -/*************************************************************************** - *** MAKE CHECK TESTS *** - ***************************************************************************/ -#ifdef EGG_TEST -#include "egg-test.h" - -void -up_daemon_test (gpointer user_data) -{ - EggTest *test = (EggTest *) user_data; - UpDaemon *daemon; - - if (!egg_test_start (test, "UpDaemon")) - return; - - /************************************************************/ - egg_test_title (test, "get instance"); - daemon = up_daemon_new (); - egg_test_assert (test, daemon != NULL); - - /* unref */ - g_object_unref (daemon); - - egg_test_end (test); -} -#endif - diff --git a/src/up-device-list.c b/src/up-device-list.c index d255d26..8e22881 100644 --- a/src/up-device-list.c +++ b/src/up-device-list.c @@ -201,55 +201,3 @@ up_device_list_new (void) return UP_DEVICE_LIST (list); } - -/*************************************************************************** - *** MAKE CHECK TESTS *** - ***************************************************************************/ -#ifdef EGG_TEST -#include "egg-test.h" - -void -up_device_list_test (gpointer user_data) -{ - EggTest *test = (EggTest *) user_data; - UpDeviceList *list; - GObject *native; - GObject *device; - GObject *found; - gboolean ret; - - if (!egg_test_start (test, "UpDeviceList")) - return; - - /************************************************************/ - egg_test_title (test, "get instance"); - list = up_device_list_new (); - egg_test_assert (test, list != NULL); - - /************************************************************/ - egg_test_title (test, "add device"); - native = g_object_new (G_TYPE_OBJECT, NULL); - device = g_object_new (G_TYPE_OBJECT, NULL); - ret = up_device_list_insert (list, native, device); - egg_test_assert (test, ret); - - /************************************************************/ - egg_test_title (test, "find device"); - found = up_device_list_lookup (list, native); - egg_test_assert (test, (found != NULL)); - g_object_unref (found); - - /************************************************************/ - egg_test_title (test, "remove device"); - ret = up_device_list_remove (list, device); - egg_test_assert (test, ret); - - /* unref */ - g_object_unref (native); - g_object_unref (device); - g_object_unref (list); - - egg_test_end (test); -} -#endif - diff --git a/src/up-device.c b/src/up-device.c index 51abdbc..a6de925 100644 --- a/src/up-device.c +++ b/src/up-device.c @@ -1197,30 +1197,3 @@ up_device_new (void) return device; } -/*************************************************************************** - *** MAKE CHECK TESTS *** - ***************************************************************************/ -#ifdef EGG_TEST -#include "egg-test.h" - -void -up_device_test (gpointer user_data) -{ - EggTest *test = (EggTest *) user_data; - UpDevice *device; - - if (!egg_test_start (test, "UpDevice")) - return; - - /************************************************************/ - egg_test_title (test, "get instance"); - device = up_device_new (); - egg_test_assert (test, device != NULL); - - /* unref */ - g_object_unref (device); - - egg_test_end (test); -} -#endif - diff --git a/src/up-history.c b/src/up-history.c index 762495d..ef8e542 100644 --- a/src/up-history.c +++ b/src/up-history.c @@ -888,30 +888,3 @@ up_history_new (void) return UP_HISTORY (history); } -/*************************************************************************** - *** MAKE CHECK TESTS *** - ***************************************************************************/ -#ifdef EGG_TEST -#include "egg-test.h" - -void -up_history_test (gpointer user_data) -{ - EggTest *test = (EggTest *) user_data; - UpHistory *history; - - if (!egg_test_start (test, "UpHistory")) - return; - - /************************************************************/ - egg_test_title (test, "get instance"); - history = up_history_new (); - egg_test_assert (test, history != NULL); - - /* unref */ - g_object_unref (history); - - egg_test_end (test); -} -#endif - diff --git a/src/up-polkit.c b/src/up-polkit.c index 8d89dfe..3611afb 100644 --- a/src/up-polkit.c +++ b/src/up-polkit.c @@ -261,30 +261,3 @@ up_polkit_new (void) return UP_POLKIT (up_polkit_object); } -/*************************************************************************** - *** MAKE CHECK TESTS *** - ***************************************************************************/ -#ifdef EGG_TEST -#include "egg-test.h" - -void -up_polkit_test (gpointer user_data) -{ - EggTest *test = (EggTest *) user_data; - UpPolkit *polkit; - - if (!egg_test_start (test, "UpPolkit")) - return; - - /************************************************************/ - egg_test_title (test, "get instance"); - polkit = up_polkit_new (); - egg_test_assert (test, polkit != NULL); - - /* unref */ - g_object_unref (polkit); - - egg_test_end (test); -} -#endif - diff --git a/src/up-qos.c b/src/up-qos.c index 81fbce9..0ce3eea 100644 --- a/src/up-qos.c +++ b/src/up-qos.c @@ -627,30 +627,3 @@ up_qos_new (void) return UP_QOS (qos); } -/*************************************************************************** - *** MAKE CHECK TESTS *** - ***************************************************************************/ -#ifdef EGG_TEST -#include "egg-test.h" - -void -up_qos_test (gpointer user_data) -{ - EggTest *test = (EggTest *) user_data; - UpQos *qos; - - if (!egg_test_start (test, "UpQos")) - return; - - /************************************************************/ - egg_test_title (test, "get instance"); - qos = up_qos_new (); - egg_test_assert (test, qos != NULL); - - /* unref */ - g_object_unref (qos); - - egg_test_end (test); -} -#endif - diff --git a/src/up-self-test.c b/src/up-self-test.c index cbaeb0a..dfcb202 100644 --- a/src/up-self-test.c +++ b/src/up-self-test.c @@ -22,7 +22,6 @@ #include "config.h" #include <glib-object.h> -#include "egg-test.h" #include "egg-debug.h" #include "up-backend.h" @@ -35,26 +34,149 @@ #include "up-qos.h" #include "up-wakeups.h" +static void +up_test_native_func (void) +{ + const gchar *path; + + path = up_native_get_native_path (NULL); + g_assert_cmpstr (path, ==, "/sys/dummy"); +} + +static void +up_test_backend_func (void) +{ + UpBackend *backend; + + backend = up_backend_new (); + g_assert (backend != NULL); + + /* unref */ + g_object_unref (backend); +} + +static void +up_test_daemon_func (void) +{ + UpDaemon *daemon; + + daemon = up_daemon_new (); + g_assert (daemon != NULL); + + /* unref */ + g_object_unref (daemon); +} + +static void +up_test_device_func (void) +{ + UpDevice *device; + + device = up_device_new (); + g_assert (device != NULL); + + /* unref */ + g_object_unref (device); +} + +static void +up_test_device_list_func (void) +{ + UpDeviceList *list; + GObject *native; + GObject *device; + GObject *found; + gboolean ret; + + list = up_device_list_new (); + g_assert (list != NULL); + + /* add device */ + native = g_object_new (G_TYPE_OBJECT, NULL); + device = g_object_new (G_TYPE_OBJECT, NULL); + ret = up_device_list_insert (list, native, device); + g_assert (ret); + + /* find device */ + found = up_device_list_lookup (list, native); + g_assert (found != NULL); + g_object_unref (found); + + /* remove device */ + ret = up_device_list_remove (list, device); + g_assert (ret); + + /* unref */ + g_object_unref (native); + g_object_unref (device); + g_object_unref (list); +} + +static void +up_test_history_func (void) +{ + UpHistory *history; + + history = up_history_new (); + g_assert (history != NULL); + + /* unref */ + g_object_unref (history); +} + +static void +up_test_polkit_func (void) +{ + UpPolkit *polkit; + + polkit = up_polkit_new (); + g_assert (polkit != NULL); + + /* unref */ + g_object_unref (polkit); +} + +static void +up_test_qos_func (void) +{ + UpQos *qos; + + qos = up_qos_new (); + g_assert (qos != NULL); + + /* unref */ + g_object_unref (qos); +} + +static void +up_test_wakeups_func (void) +{ + UpWakeups *wakeups; + + wakeups = up_wakeups_new (); + g_assert (wakeups != NULL); + + /* unref */ + g_object_unref (wakeups); +} + int main (int argc, char **argv) { - EggTest *test; - g_type_init (); - test = egg_test_init (); - egg_debug_init (&argc, &argv); + g_test_init (&argc, &argv, NULL); /* tests go here */ - up_backend_test (test); - up_device_test (test); - up_device_list_test (test); - up_history_test (test); - up_native_test (test); - up_polkit_test (test); - up_qos_test (test); - up_wakeups_test (test); - up_daemon_test (test); - - return (egg_test_finish (test)); + g_test_add_func ("/power/backend", up_test_backend_func); + g_test_add_func ("/power/device", up_test_device_func); + 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/qos", up_test_qos_func); + g_test_add_func ("/power/wakeups", up_test_wakeups_func); + g_test_add_func ("/power/daemon", up_test_daemon_func); + + return g_test_run (); } diff --git a/src/up-wakeups.c b/src/up-wakeups.c index 122c213..f6daa32 100644 --- a/src/up-wakeups.c +++ b/src/up-wakeups.c @@ -795,30 +795,3 @@ up_wakeups_new (void) return UP_WAKEUPS (wakeups); } -/*************************************************************************** - *** MAKE CHECK TESTS *** - ***************************************************************************/ -#ifdef EGG_TEST -#include "egg-test.h" - -void -up_wakeups_test (gpointer user_data) -{ - EggTest *test = (EggTest *) user_data; - UpWakeups *wakeups; - - if (!egg_test_start (test, "UpWakeups")) - return; - - /************************************************************/ - egg_test_title (test, "get instance"); - wakeups = up_wakeups_new (); - egg_test_assert (test, wakeups != NULL); - - /* unref */ - g_object_unref (wakeups); - - egg_test_end (test); -} -#endif - |