diff options
author | Pavel Šimerda <psimerda@redhat.com> | 2013-07-31 17:30:19 +0200 |
---|---|---|
committer | Pavel Šimerda <psimerda@redhat.com> | 2013-08-20 14:10:56 +0200 |
commit | 80a806d388555aca5d760ddfbcae2e8993ad15c2 (patch) | |
tree | 36e7bb55fc98ebc18eca1a776c5c6288303489ba | |
parent | 902a7e91eb351cf3360a55156d4d7115d9e27567 (diff) | |
download | NetworkManager-pavlix/devices.tar.gz |
WIP: core: add a proof-of-concept device testpavlix/devices
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/devices/Makefile.am | 1 | ||||
-rw-r--r-- | src/devices/tests/Makefile.am | 38 | ||||
-rw-r--r-- | src/devices/tests/test-device.c | 40 |
5 files changed, 83 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index 5ab5b38e16..963f2fdf96 100644 --- a/configure.ac +++ b/configure.ac @@ -700,11 +700,13 @@ src/settings/plugins/keyfile/tests/Makefile src/settings/plugins/keyfile/tests/keyfiles/Makefile src/settings/plugins/example/Makefile src/settings/tests/Makefile +src/devices/Makefile +src/devices/wimax/Makefile +src/devices/tests/Makefile src/platform/Makefile src/platform/tests/Makefile src/rdisc/Makefile src/rdisc/tests/Makefile -src/devices/wimax/Makefile libnm-util/libnm-util.pc libnm-util/Makefile libnm-util/tests/Makefile diff --git a/src/Makefile.am b/src/Makefile.am index 8370e5a068..7d2822eefc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -16,6 +16,7 @@ if ENABLE_TESTS SUBDIRS += \ config/tests \ dhcp-manager/tests \ + devices\ platform \ rdisc \ settings/tests \ diff --git a/src/devices/Makefile.am b/src/devices/Makefile.am new file mode 100644 index 0000000000..3c6155b9c6 --- /dev/null +++ b/src/devices/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = tests diff --git a/src/devices/tests/Makefile.am b/src/devices/tests/Makefile.am new file mode 100644 index 0000000000..66829f131d --- /dev/null +++ b/src/devices/tests/Makefile.am @@ -0,0 +1,38 @@ +AM_CPPFLAGS = \ + -I${top_srcdir} \ + -I${top_srcdir}/include \ + -I${top_srcdir}/src \ + -I${top_srcdir}/src/logging \ + -I${top_srcdir}/libnm-util \ + -I${srcdir}/.. \ + $(GLIB_CFLAGS) \ + $(DBUS_CFLAGS) \ + $(GUDEV_CFLAGS) \ + $(LIBNL_CFLAGS) + +includes = $(shell find $(top_builddir)/{src,libgsystem} -type d -not -path '*/tests' -not -path '*/tests/*') +AM_CPPFLAGS += $(foreach d, $(includes),-I$d) + +AM_CFLAGS = $(CODE_COVERAGE_CFLAGS) +AM_LDFLAGS = $(GLIB_LIBS) $(GUDEV_LIBS) $(LIBNL_LIBS) $(CODE_COVERAGE_LDFLAGS) + +@GNOME_CODE_COVERAGE_RULES@ + +noinst_PROGRAMS = \ + test-device + +test_device_SOURCES = test_device.c +test_device_LDADD = \ + $(top_builddir)/src/libNetworkManager.la \ + $(top_builddir)/libndp/libndp/.libs/libndp.a + +@VALGRIND_RULES@ +USERTESTS = test-device +ROOTTESTS = + +# If explicitly enabled, we can run the root tests +if RUN_ROOT_TESTS +TESTS = $(USERTESTS) $(ROOTTESTS) +else +TESTS = $(USERTESTS) +endif diff --git a/src/devices/tests/test-device.c b/src/devices/tests/test-device.c new file mode 100644 index 0000000000..522c9ae6b4 --- /dev/null +++ b/src/devices/tests/test-device.c @@ -0,0 +1,40 @@ +#include <stdlib.h> + +#include "gsystem-local-alloc.h" + +/* FIXME: Things we probably shouldn't need. */ +#include "nm-config.h" +#include "nm-linux-platform.h" + +#include "nm-device-ethernet.h" + +int +main (int argc, char **argv) +{ + GMainLoop *loop = g_main_loop_new (NULL, FALSE); + gs_unref_object NMDevice *device; + GArray *links = NULL; + GError *error = NULL; + int i; + + /* Read the config file and CLI overrides */ + nm_config_new (&error); + g_assert (!error); + nm_linux_platform_setup (); + + links = nm_platform_link_get_all (); + for (i = 0; i < links->len; i++) { + NMPlatformLink *item = &g_array_index (links, NMPlatformLink, i); + + if (item->type == NM_LINK_TYPE_ETHERNET) { + device = nm_device_ethernet_new (item); + break; + } + } + g_array_unref (links); + + g_idle_add ((GSourceFunc) g_main_loop_quit, loop); + g_main_loop_run (loop); + + return EXIT_SUCCESS; +} |