summaryrefslogtreecommitdiff
path: root/gl
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2009-11-05 14:44:12 +0100
committerSimon Josefsson <simon@josefsson.org>2009-11-05 14:44:12 +0100
commitd400854a11f2460ddabc313e9983cde9544efedc (patch)
tree9795ff7cfb48bb368e860870fcce18c923ca7a7d /gl
parent65e184ffdcf0441b51cd447f519d929376f7e06b (diff)
downloadgnutls-d400854a11f2460ddabc313e9983cde9544efedc.tar.gz
Update gnulib files.
Diffstat (limited to 'gl')
-rw-r--r--gl/m4/gnulib-comp.m44
-rw-r--r--gl/m4/inet_ntop.m44
-rw-r--r--gl/m4/inet_pton.m44
-rw-r--r--gl/tests/Makefile.am18
-rw-r--r--gl/tests/test-inet_ntop.c64
-rw-r--r--gl/tests/test-inet_pton.c67
-rw-r--r--gl/tests/test-sys_socket.c2
7 files changed, 158 insertions, 5 deletions
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4
index 669e6d8b1d..f4bf32e54a 100644
--- a/gl/m4/gnulib-comp.m4
+++ b/gl/m4/gnulib-comp.m4
@@ -237,6 +237,8 @@ AC_SUBST([LTALLOCA])
gl_source_base='gl/tests'
gl_FUNC_UNGETC_WORKS
gl_FUNC_GETTIMEOFDAY
+ AC_C_BIGENDIAN
+ AC_C_BIGENDIAN
AC_REQUIRE([gl_HEADER_SYS_SOCKET])
if test "$ac_cv_header_winsock2_h" = yes; then
dnl Even if the 'socket' module is not used here, another part of the
@@ -527,6 +529,8 @@ AC_DEFUN([gl_FILE_LIST], [
tests/test-getdelim.c
tests/test-getline.c
tests/test-gettimeofday.c
+ tests/test-inet_ntop.c
+ tests/test-inet_pton.c
tests/test-lseek.c
tests/test-lseek.sh
tests/test-memchr.c
diff --git a/gl/m4/inet_ntop.m4 b/gl/m4/inet_ntop.m4
index ea645f242f..2a8ff20515 100644
--- a/gl/m4/inet_ntop.m4
+++ b/gl/m4/inet_ntop.m4
@@ -1,4 +1,4 @@
-# inet_ntop.m4 serial 10
+# inet_ntop.m4 serial 11
dnl Copyright (C) 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -18,7 +18,7 @@ AC_DEFUN([gl_INET_NTOP],
[AC_REPLACE_FUNCS([inet_ntop])])
LIBS=$gl_save_LIBS
INET_NTOP_LIB=
- if test "$ac_cv_search_inet_ntop" != "none needed" &&
+ if test "$ac_cv_search_inet_ntop" != "no" &&
test "$ac_cv_search_inet_ntop" != "none required"; then
INET_NTOP_LIB="$ac_cv_search_inet_ntop"
fi
diff --git a/gl/m4/inet_pton.m4 b/gl/m4/inet_pton.m4
index 068deee628..e890b9b7a0 100644
--- a/gl/m4/inet_pton.m4
+++ b/gl/m4/inet_pton.m4
@@ -1,4 +1,4 @@
-# inet_pton.m4 serial 8
+# inet_pton.m4 serial 9
dnl Copyright (C) 2006, 2008, 2009 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -18,7 +18,7 @@ AC_DEFUN([gl_INET_PTON],
[AC_REPLACE_FUNCS([inet_pton])])
LIBS=$gl_save_LIBS
INET_PTON_LIB=
- if test "$ac_cv_search_inet_pton" != "none needed" &&
+ if test "$ac_cv_search_inet_pton" != "no" &&
test "$ac_cv_search_inet_pton" != "none required"; then
INET_PTON_LIB="$ac_cv_search_inet_pton"
fi
diff --git a/gl/tests/Makefile.am b/gl/tests/Makefile.am
index 94918936fc..cd2ebd9591 100644
--- a/gl/tests/Makefile.am
+++ b/gl/tests/Makefile.am
@@ -142,6 +142,24 @@ EXTRA_DIST += test-gettimeofday.c
## end gnulib module gettimeofday-tests
+## begin gnulib module inet_ntop-tests
+
+TESTS += test-inet_ntop
+check_PROGRAMS += test-inet_ntop
+test_inet_ntop_LDADD = $(LDADD) @INET_NTOP_LIB@
+EXTRA_DIST += test-inet_ntop.c
+
+## end gnulib module inet_ntop-tests
+
+## begin gnulib module inet_pton-tests
+
+TESTS += test-inet_pton
+check_PROGRAMS += test-inet_pton
+test_inet_pton_LDADD = $(LDADD) @INET_PTON_LIB@
+EXTRA_DIST += test-inet_pton.c
+
+## end gnulib module inet_pton-tests
+
## begin gnulib module ioctl
diff --git a/gl/tests/test-inet_ntop.c b/gl/tests/test-inet_ntop.c
new file mode 100644
index 0000000000..71ba5c31ef
--- /dev/null
+++ b/gl/tests/test-inet_ntop.c
@@ -0,0 +1,64 @@
+/* Test of inet_ntop function.
+ Copyright (C) 2009 Free Software Foundation, Inc.
+
+ 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 3 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, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2009. */
+
+#include <config.h>
+
+#include <arpa/inet.h>
+
+#include <netinet/in.h>
+#include <sys/socket.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ fflush (stderr); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+int
+main (void)
+{
+#if defined AF_INET /* HAVE_IPV4 */
+ {
+ struct in_addr internal;
+ char printable[16];
+ const char *result;
+
+ /* This machine was for a long time known as
+ ma2s2.mathematik.uni-karlsruhe.de. */
+# ifdef WORDS_BIGENDIAN
+ internal.s_addr = 0x810D7302;
+# else
+ internal.s_addr = 0x02730D81;
+# endif
+ result = inet_ntop (AF_INET, &internal, printable, sizeof (printable));
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "129.13.115.2") == 0);
+ }
+#endif
+
+ return 0;
+}
diff --git a/gl/tests/test-inet_pton.c b/gl/tests/test-inet_pton.c
new file mode 100644
index 0000000000..b6c3ab2985
--- /dev/null
+++ b/gl/tests/test-inet_pton.c
@@ -0,0 +1,67 @@
+/* Test of inet_pton function.
+ Copyright (C) 2009 Free Software Foundation, Inc.
+
+ 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 3 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, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2009. */
+
+#include <config.h>
+
+#include <arpa/inet.h>
+
+#include <netinet/in.h>
+#include <sys/socket.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ fflush (stderr); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+int
+main (void)
+{
+#if defined AF_INET /* HAVE_IPV4 */
+ {
+ /* This machine was for a long time known as
+ ma2s2.mathematik.uni-karlsruhe.de. */
+ const char printable[] = "129.13.115.2";
+ struct in_addr internal;
+ int ret;
+
+ ret = inet_pton (AF_INET, printable, &internal);
+ ASSERT (ret == 1);
+ /* Verify that internal is filled in network byte order. */
+ ASSERT (((unsigned char *) &internal)[0] == 0x81);
+ ASSERT (((unsigned char *) &internal)[1] == 0x0D);
+ ASSERT (((unsigned char *) &internal)[2] == 0x73);
+ ASSERT (((unsigned char *) &internal)[3] == 0x02);
+# ifdef WORDS_BIGENDIAN
+ ASSERT (internal.s_addr == 0x810D7302);
+# else
+ ASSERT (internal.s_addr == 0x02730D81);
+# endif
+ }
+#endif
+
+ return 0;
+}
diff --git a/gl/tests/test-sys_socket.c b/gl/tests/test-sys_socket.c
index ddb491b312..606708dc1a 100644
--- a/gl/tests/test-sys_socket.c
+++ b/gl/tests/test-sys_socket.c
@@ -47,7 +47,7 @@ main (void)
}
x.ss_family = 42;
- i = 4711;
+ i = 42;
return 0;
}