summaryrefslogtreecommitdiff
path: root/gl/tests
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2013-10-29 18:29:16 +0100
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2013-10-29 18:29:16 +0100
commitb9db38d7f5451c281f7ba345cc3f71e2240ba23a (patch)
tree685a8ac3cc59fcdc513382396c6bdb5627f0f80c /gl/tests
parent3327d943c46afad17f64b5500663b80059d39aa3 (diff)
downloadgnutls-b9db38d7f5451c281f7ba345cc3f71e2240ba23a.tar.gz
updated gnulib.
Diffstat (limited to 'gl/tests')
-rw-r--r--gl/tests/Makefile.am1
-rw-r--r--gl/tests/binary-io.h3
-rw-r--r--gl/tests/getdtablesize.c33
-rw-r--r--gl/tests/inttypes.in.h16
-rw-r--r--gl/tests/macros.h4
-rw-r--r--gl/tests/strerror-override.h2
-rw-r--r--gl/tests/test-dup2.c9
-rw-r--r--gl/tests/test-getdtablesize.c2
-rw-r--r--gl/tests/test-sys_select.c5
-rw-r--r--gl/tests/test-sys_time.c5
10 files changed, 64 insertions, 16 deletions
diff --git a/gl/tests/Makefile.am b/gl/tests/Makefile.am
index f4c8b3df2a..f20087cf59 100644
--- a/gl/tests/Makefile.am
+++ b/gl/tests/Makefile.am
@@ -523,6 +523,7 @@ inttypes.h: inttypes.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_U
-e 's/@''HAVE_DECL_STRTOIMAX''@/$(HAVE_DECL_STRTOIMAX)/g' \
-e 's/@''HAVE_DECL_STRTOUMAX''@/$(HAVE_DECL_STRTOUMAX)/g' \
-e 's/@''REPLACE_STRTOIMAX''@/$(REPLACE_STRTOIMAX)/g' \
+ -e 's/@''REPLACE_STRTOUMAX''@/$(REPLACE_STRTOUMAX)/g' \
-e 's/@''INT32_MAX_LT_INTMAX_MAX''@/$(INT32_MAX_LT_INTMAX_MAX)/g' \
-e 's/@''INT64_MAX_EQ_LONG_MAX''@/$(INT64_MAX_EQ_LONG_MAX)/g' \
-e 's/@''UINT32_MAX_LT_UINTMAX_MAX''@/$(UINT32_MAX_LT_UINTMAX_MAX)/g' \
diff --git a/gl/tests/binary-io.h b/gl/tests/binary-io.h
index 317fe3d3c2..423c2ae3ff 100644
--- a/gl/tests/binary-io.h
+++ b/gl/tests/binary-io.h
@@ -25,6 +25,9 @@
so we include it here first. */
#include <stdio.h>
+#ifndef _GL_INLINE_HEADER_BEGIN
+ #error "Please include config.h first."
+#endif
_GL_INLINE_HEADER_BEGIN
#ifndef BINARY_IO_INLINE
# define BINARY_IO_INLINE _GL_INLINE
diff --git a/gl/tests/getdtablesize.c b/gl/tests/getdtablesize.c
index 9947405af6..355c17e3b9 100644
--- a/gl/tests/getdtablesize.c
+++ b/gl/tests/getdtablesize.c
@@ -22,11 +22,11 @@
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-#include <stdio.h>
+# include <stdio.h>
-#include "msvc-inval.h"
+# include "msvc-inval.h"
-#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
static int
_setmaxstdio_nothrow (int newmax)
{
@@ -44,10 +44,11 @@ _setmaxstdio_nothrow (int newmax)
return result;
}
-# define _setmaxstdio _setmaxstdio_nothrow
-#endif
+# define _setmaxstdio _setmaxstdio_nothrow
+# endif
-/* Cache for the previous getdtablesize () result. */
+/* Cache for the previous getdtablesize () result. Safe to cache because
+ Windows also lacks setrlimit. */
static int dtablesize;
int
@@ -83,4 +84,24 @@ getdtablesize (void)
return dtablesize;
}
+#elif HAVE_GETDTABLESIZE
+
+# include <sys/resource.h>
+# undef getdtablesize
+
+int
+rpl_getdtablesize(void)
+{
+ /* To date, this replacement is only compiled for Cygwin 1.7.25,
+ which auto-increased the RLIMIT_NOFILE soft limit until it
+ hits the compile-time constant hard limit of 3200. Although
+ that version of cygwin supported a child process inheriting
+ a smaller soft limit, the smaller limit is not enforced, so
+ we might as well just report the hard limit. */
+ struct rlimit lim;
+ if (!getrlimit (RLIMIT_NOFILE, &lim) && lim.rlim_max != RLIM_INFINITY)
+ return lim.rlim_max;
+ return getdtablesize ();
+}
+
#endif
diff --git a/gl/tests/inttypes.in.h b/gl/tests/inttypes.in.h
index 1893f5569d..05a22fff79 100644
--- a/gl/tests/inttypes.in.h
+++ b/gl/tests/inttypes.in.h
@@ -1105,12 +1105,22 @@ _GL_WARN_ON_USE (strtoimax, "strtoimax is unportable - "
#endif
#if @GNULIB_STRTOUMAX@
-# if !@HAVE_DECL_STRTOUMAX@
-# undef strtoumax
+# if @REPLACE_STRTOUMAX@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef strtoumax
+# define strtoumax rpl_strtoumax
+# endif
+_GL_FUNCDECL_RPL (strtoumax, uintmax_t,
+ (const char *, char **, int) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (strtoumax, uintmax_t, (const char *, char **, int));
+# else
+# if !@HAVE_DECL_STRTOUMAX@
+# undef strtoumax
_GL_FUNCDECL_SYS (strtoumax, uintmax_t,
(const char *, char **, int) _GL_ARG_NONNULL ((1)));
-# endif
+# endif
_GL_CXXALIAS_SYS (strtoumax, uintmax_t, (const char *, char **, int));
+# endif
_GL_CXXALIASWARN (strtoumax);
#elif defined GNULIB_POSIXCHECK
# undef strtoumax
diff --git a/gl/tests/macros.h b/gl/tests/macros.h
index 60ba894d89..1ceb815116 100644
--- a/gl/tests/macros.h
+++ b/gl/tests/macros.h
@@ -48,8 +48,8 @@
{ \
if (!(expr)) \
{ \
- fprintf (ASSERT_STREAM, "%s:%d: assertion failed\n", \
- __FILE__, __LINE__); \
+ fprintf (ASSERT_STREAM, "%s:%d: assertion '%s' failed\n", \
+ __FILE__, __LINE__, #expr); \
fflush (ASSERT_STREAM); \
abort (); \
} \
diff --git a/gl/tests/strerror-override.h b/gl/tests/strerror-override.h
index 3b8f24b995..0d086b873b 100644
--- a/gl/tests/strerror-override.h
+++ b/gl/tests/strerror-override.h
@@ -48,7 +48,7 @@
|| GNULIB_defined_EOWNERDEAD \
|| GNULIB_defined_ENOTRECOVERABLE \
|| GNULIB_defined_EILSEQ
-extern const char *strerror_override (int errnum);
+extern const char *strerror_override (int errnum) _GL_ATTRIBUTE_CONST;
# else
# define strerror_override(ignored) NULL
# endif
diff --git a/gl/tests/test-dup2.c b/gl/tests/test-dup2.c
index ecb2692d2a..44039f102b 100644
--- a/gl/tests/test-dup2.c
+++ b/gl/tests/test-dup2.c
@@ -150,6 +150,15 @@ main (void)
errno = 0;
ASSERT (dup2 (fd, -2) == -1);
ASSERT (errno == EBADF);
+ if (bad_fd > 256)
+ {
+ ASSERT (dup2 (fd, 255) == 255);
+ ASSERT (dup2 (fd, 256) == 256);
+ ASSERT (close (255) == 0);
+ ASSERT (close (256) == 0);
+ }
+ ASSERT (dup2 (fd, bad_fd - 1) == bad_fd - 1);
+ ASSERT (close (bad_fd - 1) == 0);
errno = 0;
ASSERT (dup2 (fd, bad_fd) == -1);
ASSERT (errno == EBADF);
diff --git a/gl/tests/test-getdtablesize.c b/gl/tests/test-getdtablesize.c
index 7046481ba3..b371ccf0d4 100644
--- a/gl/tests/test-getdtablesize.c
+++ b/gl/tests/test-getdtablesize.c
@@ -29,6 +29,8 @@ int
main (int argc, char *argv[])
{
ASSERT (getdtablesize () >= 3);
+ ASSERT (dup2 (0, getdtablesize() - 1) == getdtablesize () - 1);
+ ASSERT (dup2 (0, getdtablesize()) == -1);
return 0;
}
diff --git a/gl/tests/test-sys_select.c b/gl/tests/test-sys_select.c
index cd84c0103b..1604699879 100644
--- a/gl/tests/test-sys_select.c
+++ b/gl/tests/test-sys_select.c
@@ -40,8 +40,9 @@ SIGNATURE_CHECK (FD_ZERO, void, (fd_set *));
/* Check that the 'struct timeval' type is defined. */
struct timeval a;
-/* Check that &a.tv_sec is a 'time_t *', ignoring signedness issues. */
-typedef int verify_tv_sec_type[sizeof (a.tv_sec) == sizeof (time_t) ? 1 : -1];
+/* Check that a.tv_sec is wide enough to hold a time_t, ignoring
+ signedness issues. */
+typedef int verify_tv_sec_type[sizeof (time_t) <= sizeof (a.tv_sec) ? 1 : -1];
/* Check that sigset_t is defined. */
sigset_t t2;
diff --git a/gl/tests/test-sys_time.c b/gl/tests/test-sys_time.c
index 1389b52008..80628423e1 100644
--- a/gl/tests/test-sys_time.c
+++ b/gl/tests/test-sys_time.c
@@ -23,8 +23,9 @@
/* Check that the 'struct timeval' type is defined. */
struct timeval a;
-/* Check that &a.tv_sec is a 'time_t *', ignoring signedness issues. */
-typedef int verify_tv_sec_type[sizeof (a.tv_sec) == sizeof (time_t) ? 1 : -1];
+/* Check that a.tv_sec is wide enough to hold a time_t, ignoring
+ signedness issues. */
+typedef int verify_tv_sec_type[sizeof (time_t) <= sizeof (a.tv_sec) ? 1 : -1];
int
main (void)