Page Menu
Home
ClusterLabs Projects
Search
Configure Global Search
Log In
Files
F3152379
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/libnozzle/tests/Makefile.am b/libnozzle/tests/Makefile.am
index a9e2006f..50d1f37a 100644
--- a/libnozzle/tests/Makefile.am
+++ b/libnozzle/tests/Makefile.am
@@ -1,82 +1,86 @@
#
# Copyright (C) 2017-2018 Red Hat, Inc. All rights reserved.
#
# Author: Fabio M. Di Nitto <fabbione@kronosnet.org>
#
# This software licensed under GPL-2.0+, LGPL-2.0+
#
MAINTAINERCLEANFILES = Makefile.in
include $(top_srcdir)/build-aux/check.mk
EXTRA_DIST = \
tap_updown_bad \
tap_updown_good \
api-test-coverage
noinst_HEADERS = \
test-common.h
if BUILD_LIBNOZZLE
check_PROGRAMS = \
api_nozzle_open_test \
api_nozzle_close_test \
api_nozzle_set_up_test \
api_nozzle_set_down_test \
api_nozzle_get_mtu_test \
api_nozzle_set_mtu_test \
api_nozzle_get_mac_test \
api_nozzle_set_mac_test \
+ api_nozzle_get_handle_by_name_test \
nozzle_test
noinst_PROGRAMS = $(check_PROGRAMS)
noinst_SCRIPTS = \
api-test-coverage
TESTS = $(check_PROGRAMS)
check-local: check-api-test-coverage
check-api-test-coverage:
chmod u+x $(top_srcdir)/libnozzle/tests/api-test-coverage
$(top_srcdir)/libnozzle/tests/api-test-coverage $(top_srcdir) $(top_builddir)
AM_CPPFLAGS = -I$(top_srcdir)/libnozzle -DABSBUILDDIR=\"$(abs_builddir)\"
AM_CFLAGS += $(PTHREAD_CFLAGS) $(libnl_CFLAGS)
LIBS += $(top_builddir)/libnozzle/libnozzle.la $(PTHREAD_LIBS) $(libnl_LIBS)
api_nozzle_open_test_SOURCES = api_nozzle_open.c \
test-common.c
api_nozzle_close_test_SOURCES = api_nozzle_close.c \
test-common.c
api_nozzle_set_up_test_SOURCES = api_nozzle_set_up.c \
test-common.c \
../internals.c
api_nozzle_set_down_test_SOURCES = api_nozzle_set_down.c \
test-common.c \
../internals.c
api_nozzle_get_mtu_test_SOURCES = api_nozzle_get_mtu.c \
test-common.c
api_nozzle_set_mtu_test_SOURCES = api_nozzle_set_mtu.c \
test-common.c \
../internals.c
api_nozzle_get_mac_test_SOURCES = api_nozzle_get_mac.c \
test-common.c
api_nozzle_set_mac_test_SOURCES = api_nozzle_set_mac.c \
test-common.c
+api_nozzle_get_handle_by_name_test_SOURCES = api_nozzle_get_handle_by_name.c \
+ test-common.c
+
nozzle_test_SOURCES = nozzle_test.c \
test-common.c \
../internals.c
endif
diff --git a/libnozzle/tests/api_nozzle_get_handle_by_name.c b/libnozzle/tests/api_nozzle_get_handle_by_name.c
new file mode 100644
index 00000000..0abc1bab
--- /dev/null
+++ b/libnozzle/tests/api_nozzle_get_handle_by_name.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2018 Red Hat, Inc. All rights reserved.
+ *
+ * Author: Fabio M. Di Nitto <fabbione@kronosnet.org>
+ *
+ * This software licensed under GPL-2.0+, LGPL-2.0+
+ */
+
+#include "config.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <limits.h>
+
+#include "test-common.h"
+
+static int test(void)
+{
+ char device_name[2*IFNAMSIZ];
+ size_t size = IFNAMSIZ;
+ nozzle_t nozzle, nozzle_tmp;
+ int err = 0;
+
+ printf("Testing get handle by name\n");
+
+ memset(device_name, 0, size);
+ nozzle = nozzle_open(device_name, size, NULL);
+ if (!nozzle) {
+ printf("Unable to init %s\n", device_name);
+ return -1;
+ }
+
+ nozzle_tmp = nozzle_get_handle_by_name(device_name);
+ if ((!nozzle_tmp) && (errno != ENOENT)) {
+ printf("Unable to get handle by name\n");
+ err = -1;
+ goto out_clean;
+ }
+
+ if (nozzle != nozzle_tmp) {
+ printf("get handle by name returned wrong handle!\n");
+ err = -1;
+ goto out_clean;
+ }
+
+ printf("Testing error conditions\n");
+
+ printf("Testing with NULL device name\n");
+
+ nozzle_tmp = nozzle_get_handle_by_name(NULL);
+
+ if ((nozzle_tmp) || (errno != EINVAL)) {
+ printf("get handle by name returned wrong error\n");
+ err = -1;
+ goto out_clean;
+ }
+
+ printf("Testing with device name longer than IFNAMSIZ\n");
+
+ nozzle_tmp = nozzle_get_handle_by_name("antanisupercazzolaunpotapioca");
+ if ((nozzle_tmp) || (errno != EINVAL)) {
+ printf("get handle by name returned wrong error\n");
+ err = -1;
+ goto out_clean;
+ }
+
+out_clean:
+
+ if (nozzle) {
+ nozzle_close(nozzle);
+ }
+
+ return err;
+}
+
+int main(void)
+{
+ need_root();
+
+ if (test() < 0)
+ return FAIL;
+
+ return PASS;
+}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Feb 24, 9:15 PM (12 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1464460
Default Alt Text
(4 KB)
Attached To
Mode
rK kronosnet
Attached
Detach File
Event Timeline
Log In to Comment