diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.am | 10 | ||||
-rw-r--r-- | test/nm-set-fallback | 27 | ||||
-rw-r--r-- | test/nmtestdevices.c | 287 | ||||
-rw-r--r-- | test/test-common/.cvsignore | 2 | ||||
-rw-r--r-- | test/test-common/Makefile.am | 18 | ||||
-rw-r--r-- | test/test-common/test-common.c | 63 | ||||
-rw-r--r-- | test/test-common/test-common.h | 41 |
7 files changed, 1 insertions, 447 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index e16e26fd7a..b0cb1aa678 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,5 +1,3 @@ -SUBDIRS=test-common - INCLUDES = -I${top_srcdir} \ -I${top_srcdir}/libnm-util \ -I${top_srcdir}/libnm-glib \ @@ -17,9 +15,7 @@ AM_CPPFLAGS = \ bin_PROGRAMS = nm-tool -noinst_PROGRAMS = nm-online \ - nmtestdevices \ - libnm_glib_test +noinst_PROGRAMS = nm-online libnm_glib_test nm_tool_SOURCES = nm-tool.c nm_tool_LDADD = $(DBUS_LIBS) $(GTHREAD_LIBS) $(HAL_LIBS) \ @@ -30,10 +26,6 @@ nm_online_SOURCES = nm-online.c nm_online_LDADD = $(DBUS_LIBS) $(GTHREAD_LIBS) $(HAL_LIBS) \ $(top_builddir)/libnm-util/libnm-util.la -nmtestdevices_SOURCES = nmtestdevices.c -nmtestdevices_LDADD = $(DBUS_LIBS) $(GTHREAD_LIBS) \ - $(top_builddir)/libnm-util/libnm-util.la - libnm_glib_test_SOURCES = libnm_glib_test.c libnm_glib_test_LDADD = $(DBUS_LIBS) $(GTHREAD_LIBS) \ $(top_builddir)/libnm-glib/libnm_glib.la \ diff --git a/test/nm-set-fallback b/test/nm-set-fallback deleted file mode 100644 index cc560a8ba8..0000000000 --- a/test/nm-set-fallback +++ /dev/null @@ -1,27 +0,0 @@ -#! /bin/sh -# -# nm-set-fallback - mark a network as fallback -# -# Robert Love - -BIN=`which gconftool-2` - -if [ "x$1" == "x" ]; then - echo "usage: $0 <network> <true|false>" - exit 1 -fi - -if [ "x$2" != "xtrue" -a "x$2" != "xfalse" ]; then - echo "usage: $0 <network> <true|false>" - exit 2 -fi - -KEY="/system/networking/wireless/networks/${1}/fallback" -CURRENT=`$BIN --get $KEY 2>/dev/null` - -if [ "x$CURRENT" != "xtrue" -a "x$CURRENT" != "xfalse" ]; then - echo "Network '$1' is not valid" - exit 3 -fi - -$BIN --set --type=bool $KEY ${2} diff --git a/test/nmtestdevices.c b/test/nmtestdevices.c deleted file mode 100644 index 089efb7191..0000000000 --- a/test/nmtestdevices.c +++ /dev/null @@ -1,287 +0,0 @@ -/* nmtestdevices - Tool to create/delete/modify test devices for NetworkManager - * (use when you are on a plane, don't have a wireless card, etc) - * - * Dan Williams <dcbw@redhat.com> - * - * 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. - * - * (C) Copyright 2004 Red Hat, Inc. - */ - -#include <glib.h> -#include <dbus/dbus.h> -#include <dbus/dbus-glib.h> -#include <stdio.h> -#include <stdlib.h> -#include <getopt.h> -#include <string.h> - -#include "NetworkManager.h" - -static void create_device (DBusConnection *connection, NMDeviceType type) -{ - DBusMessage *message; - DBusMessage *reply; - DBusError error; - char *string; - - g_return_if_fail (connection != NULL); - g_return_if_fail (((type == NM_DEVICE_TYPE_ETHERNET) || (type == NM_DEVICE_TYPE_WIFI))); - - message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "createTestDevice"); - if (message == NULL) - { - fprintf (stderr, "Couldn't allocate the dbus message\n"); - return; - } - - dbus_error_init (&error); - dbus_message_append_args (message, DBUS_TYPE_INT32, type, DBUS_TYPE_INVALID); - reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error); - dbus_message_unref (message); - if (dbus_error_is_set (&error)) - { - fprintf (stderr, "%s raised:\n %s\n\n", error.name, error.message); - dbus_error_free (&error); - return; - } - - if (reply == NULL) - { - fprintf( stderr, "dbus reply message was NULL\n" ); - return; - } - - dbus_error_init (&error); - if (!dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &string, DBUS_TYPE_INVALID) || !string) - { - fprintf (stderr, "NetworkManager returned a NULL test device ID, test device could not be created." ); - dbus_message_unref (reply); - if (dbus_error_is_set (&error)) - dbus_error_free (&error); - return; - } - - fprintf (stderr, "New test device ID: '%s'\n", string ); - - dbus_message_unref (reply); - dbus_free (string); -} - - -static void destroy_device (DBusConnection *connection, char *dev) -{ - DBusMessage *message; - DBusMessage *reply; - DBusError error; - - g_return_if_fail (connection != NULL); - g_return_if_fail (dev != NULL); - - message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "removeTestDevice"); - if (message == NULL) - { - fprintf (stderr, "Couldn't allocate the dbus message\n"); - return; - } - - dbus_error_init (&error); - dbus_message_append_args (message, DBUS_TYPE_STRING, dev, DBUS_TYPE_INVALID); - reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error); - if (dbus_error_is_set (&error)) - { - fprintf (stderr, "%s raised:\n %s\n\n", error.name, error.message); - dbus_error_free (&error); - dbus_message_unref (message); - return; - } - - if (reply == NULL) - { - fprintf( stderr, "dbus reply message was NULL\n" ); - dbus_message_unref (message); - return; - } - - dbus_message_unref (message); - dbus_message_unref (reply); -} - - -static void set_link_active (DBusConnection *connection, char *dev, gboolean active) -{ - DBusMessage *message; - DBusMessage *reply; - DBusError error; - - g_return_if_fail (connection != NULL); - g_return_if_fail (dev != NULL); - - message = dbus_message_new_method_call (NM_DBUS_SERVICE, dev, NM_DBUS_INTERFACE_DEVICE, "setLinkActive"); - if (message == NULL) - { - fprintf (stderr, "Couldn't allocate the dbus message\n"); - return; - } - - dbus_message_append_args (message, DBUS_TYPE_BOOLEAN, active, DBUS_TYPE_INVALID); - - dbus_error_init (&error); - reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error); - if (dbus_error_is_set (&error)) - { - fprintf (stderr, "%s raised:\n %s\n\n", error.name, error.message); - dbus_error_free (&error); - dbus_message_unref (message); - return; - } - - if (reply == NULL) - { - fprintf( stderr, "dbus reply message was NULL\n" ); - dbus_message_unref (message); - return; - } - - dbus_message_unref (message); - dbus_message_unref (reply); -} - - -static void print_usage (void) -{ - fprintf (stderr, "\n" "usage : nmtestdevices [options] [--help]\n"); - fprintf (stderr, - "\n" - " --create-device <wired | wireless> Creates a test device, returns the new device ID\n" - " --remove-device <ID> Remove a test device (cannot remove real devices)\n" - " --make-link-active <ID> Switch a test device's link ON\n" - " --make-link-inactive <ID> Switch a test device's link OFF\n" - " --help Show this information and exit\n" - "\n" - "This tool allows you to tell NetworkManager to create and manipulate fake 'test' devices. This\n" - "is useful in sitation where you may not have a particular device but still want to test\n" - "NetworkManager out with it (For example, you forgot your wireless card at home and now you're\n" - "taking a trip and want to hack on NM, and you're on a plane so you couldn't use the wireless\n" - "card anyway).\n" - "\n"); -} - - -int main( int argc, char *argv[] ) -{ - DBusConnection *connection; - DBusError error; - char *dev = NULL; - gboolean create = FALSE; - gboolean destroy = FALSE; - gboolean make_link_active = FALSE; - gboolean make_link_inactive = FALSE; - NMDeviceType dev_type = NM_DEVICE_TYPE_UNKNOWN; - - if (argc < 2) { - print_usage (); - exit (0); - } - - /* Parse options */ - while (1) - { - int c; - int option_index = 0; - const char *opt; - - static struct option options[] = { - {"create-device", 1, NULL, 0}, - {"remove-device", 1, NULL, 0}, - {"make-link-active", 1, NULL, 0}, - {"make-link-inactive", 1, NULL, 0}, - {"help", 0, NULL, 0}, - {NULL, 0, NULL, 0} - }; - - c = getopt_long (argc, argv, "", options, &option_index); - if (c == -1) - break; - - switch (c) - { - case 0: - opt = options[option_index].name; - if (strcmp (opt, "help") == 0) - { - print_usage (); - exit (0); - } - else if (strcmp (opt, "create-device") == 0) - { - create = TRUE; - if (optarg) - { - if (strcmp (optarg, "wired") == 0) - dev_type = NM_DEVICE_TYPE_ETHERNET; - else if (strcmp (optarg, "wireless") == 0) - dev_type = NM_DEVICE_TYPE_WIFI; - } - } - else if (strcmp (opt, "remove-device") == 0) - { - destroy = TRUE; - if (optarg) - dev = g_strdup (optarg); - } - else if (strcmp (opt, "make-link-active") == 0) - { - make_link_active = TRUE; - if (optarg) - dev = g_strdup (optarg); - } - else if (strcmp (opt, "make-link-inactive") == 0) - { - make_link_inactive = TRUE; - if (optarg) - dev = g_strdup (optarg); - } - break; - - default: - print_usage (); - exit (1); - break; - } - } - - g_type_init (); - - dbus_error_init (&error); - connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error); - if (connection == NULL) - { - fprintf (stderr, "Error connecting to system bus: %s\n", error.message); - dbus_error_free (&error); - return 1; - } - - if (create) - create_device (connection, dev_type); - else if (destroy) - destroy_device (connection, dev); - else if (make_link_active) - set_link_active (connection, dev, TRUE); - else if (make_link_inactive) - set_link_active (connection, dev, FALSE); - - return 0; -} diff --git a/test/test-common/.cvsignore b/test/test-common/.cvsignore deleted file mode 100644 index 282522db03..0000000000 --- a/test/test-common/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -Makefile.in diff --git a/test/test-common/Makefile.am b/test/test-common/Makefile.am deleted file mode 100644 index 1c2eee3f42..0000000000 --- a/test/test-common/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -INCLUDES = -I${top_srcdir} \ - -I${top_srcdir}/include \ - -I${top_srcdir}/libnm-util \ - -I${top_srcdir}/test - -noinst_LTLIBRARIES=libtest-common.la - - -libtest_common_la_SOURCES= \ - test-common.c \ - test-common.h - -libtest_common_la_CPPFLAGS = \ - $(GLIB_CFLAGS) \ - -DG_DISABLE_DEPRECATED - -libtest_common_la_LIBADD = $(GLIB_LIBS) - diff --git a/test/test-common/test-common.c b/test/test-common/test-common.c deleted file mode 100644 index 5fc9dd9e8d..0000000000 --- a/test/test-common/test-common.c +++ /dev/null @@ -1,63 +0,0 @@ -/* NetworkManager -- Forget about your network - * - * Dan Williams <dcbw@redhat.com> - * - * 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. - * - * (C) Copyright 2005 Red Hat, Inc. - */ - - -#include <glib.h> -#include <stdlib.h> -#include <stdio.h> - -#include "test-common.h" - - -void -test_result (const char *progname, - const char *test, - TestResult result, - const char *format, - ...) -{ - va_list args; - char * errmsg = NULL; - char * full_msg = NULL; - char * result_string = NULL; - - if (format) - { - errmsg = g_malloc0 (257); - va_start (args, format); - vsnprintf (errmsg, 256, format, args); - va_end (args); - } - - if (result == TEST_FAIL) - result_string = "FAIL"; - else - result_string = "SUCCEED"; - - full_msg = g_strdup_printf ("%s: (%s) %s %s\n", progname, test, result_string, errmsg ? errmsg : ""); - fprintf (stderr, "%s", full_msg); - g_free (full_msg); - g_free (errmsg); - - if (result == TEST_FAIL) - exit (-1); -} - diff --git a/test/test-common/test-common.h b/test/test-common/test-common.h deleted file mode 100644 index a9366f61de..0000000000 --- a/test/test-common/test-common.h +++ /dev/null @@ -1,41 +0,0 @@ -/* NetworkManager -- Forget about your network - * - * Dan Williams <dcbw@redhat.com> - * - * 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. - * - * (C) Copyright 2005 Red Hat, Inc. - */ - -#ifndef TEST_COMMON_H -#define TEST_COMMON_H - -#include <glib.h> -#include <stdlib.h> -#include <stdio.h> - -typedef enum TestResult -{ - TEST_FAIL = 0, - TEST_SUCCEED -} TestResult; - -void test_result (const char *progname, - const char *test, - TestResult result, - const char *format, - ...); - -#endif /* TEST_COMMON_H */ |