diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/Makefile.gnulib | 67 | ||||
| -rw-r--r-- | tests/Makefile.in | 222 | ||||
| -rw-r--r-- | tests/error.c | 16 | ||||
| -rw-r--r-- | tests/fcntl.in.h | 144 | ||||
| -rw-r--r-- | tests/locale.in.h | 5 | ||||
| -rw-r--r-- | tests/open.c | 137 | ||||
| -rw-r--r-- | tests/test-dup2.c | 121 | ||||
| -rw-r--r-- | tests/test-fcntl.c | 35 | ||||
| -rw-r--r-- | tests/test-open.c | 47 | ||||
| -rw-r--r-- | tests/test-stddef.c | 38 | ||||
| -rw-r--r-- | tests/test-wchar.c | 8 | ||||
| -rw-r--r-- | tests/uniconv/test-u16-conv-from-enc.c | 2 | ||||
| -rw-r--r-- | tests/uniconv/test-u16-strconv-from-enc.c | 4 | ||||
| -rw-r--r-- | tests/uniconv/test-u32-conv-from-enc.c | 2 | ||||
| -rw-r--r-- | tests/uniconv/test-u32-strconv-from-enc.c | 4 | ||||
| -rw-r--r-- | tests/uniconv/test-u8-conv-from-enc.c | 2 | ||||
| -rw-r--r-- | tests/uniconv/test-u8-strconv-from-enc.c | 4 | 
17 files changed, 774 insertions, 84 deletions
| diff --git a/tests/Makefile.gnulib b/tests/Makefile.gnulib index 454cfe7d..f86db501 100644 --- a/tests/Makefile.gnulib +++ b/tests/Makefile.gnulib @@ -77,6 +77,14 @@ EXTRA_DIST += test-c-strcase.sh test-c-strcasecmp.c test-c-strncasecmp.c  ## end   gnulib module c-strcase-tests +## begin gnulib module dup2-tests + +TESTS += test-dup2 +check_PROGRAMS += test-dup2 +EXTRA_DIST += test-dup2.c + +## end   gnulib module dup2-tests +  ## begin gnulib module environ-tests  TESTS += test-environ @@ -113,6 +121,38 @@ EXTRA_libtests_a_SOURCES += exitfail.c  ## end   gnulib module exitfail +## begin gnulib module fcntl + +BUILT_SOURCES += $(FCNTL_H) + +# We need the following in order to create <fcntl.h> when the system +# doesn't have one that works with the given compiler. +fcntl.h: fcntl.in.h +	rm -f $@-t $@ +	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ +	  sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ +	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ +	      -e 's|@''NEXT_FCNTL_H''@|$(NEXT_FCNTL_H)|g' \ +	      -e 's|@''GNULIB_OPEN''@|$(GNULIB_OPEN)|g' \ +	      -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \ +	      < $(srcdir)/fcntl.in.h; \ +	} > $@-t +	mv $@-t $@ +MOSTLYCLEANFILES += fcntl.h fcntl.h-t + +EXTRA_DIST += fcntl.in.h + +## end   gnulib module fcntl + +## begin gnulib module fcntl-tests + +TESTS += test-fcntl +check_PROGRAMS += test-fcntl + +EXTRA_DIST += test-fcntl.c + +## end   gnulib module fcntl-tests +  ## begin gnulib module frexpl-nolibm-tests  TESTS += test-frexpl-nolibm @@ -273,6 +313,24 @@ EXTRA_DIST += test-memchr.c zerosize-ptr.h  ## end   gnulib module memchr-tests +## begin gnulib module open + + +EXTRA_DIST += open.c + +EXTRA_libtests_a_SOURCES += open.c + +## end   gnulib module open + +## begin gnulib module open-tests + +TESTS += test-open +check_PROGRAMS += test-open + +EXTRA_DIST += test-open.c + +## end   gnulib module open-tests +  ## begin gnulib module printf-frexp-tests  TESTS += test-printf-frexp @@ -324,6 +382,15 @@ EXTRA_DIST += test-stdbool.c  ## end   gnulib module stdbool-tests +## begin gnulib module stddef-tests + +TESTS += test-stddef +check_PROGRAMS += test-stddef + +EXTRA_DIST += test-stddef.c + +## end   gnulib module stddef-tests +  ## begin gnulib module stdint-tests  TESTS += test-stdint diff --git a/tests/Makefile.in b/tests/Makefile.in index fa734572..b1d9e4a7 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -49,42 +49,43 @@ host_triplet = @host@  DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \  	$(srcdir)/Makefile.gnulib $(srcdir)/Makefile.in  TESTS = test-alloca-opt$(EXEEXT) test-array-mergesort$(EXEEXT) \ -	test-c-ctype$(EXEEXT) test-c-strcase.sh test-environ$(EXEEXT) \ -	test-errno$(EXEEXT) test-frexpl-nolibm$(EXEEXT) \ -	test-fseterr$(EXEEXT) test-iconv$(EXEEXT) \ -	test-isnand-nolibm$(EXEEXT) test-isnanf-nolibm$(EXEEXT) \ -	test-isnanl-nolibm$(EXEEXT) test-locale$(EXEEXT) \ -	test-localename$(EXEEXT) test-malloca$(EXEEXT) \ -	test-math$(EXEEXT) test-mbrtowc1.sh test-mbrtowc2.sh \ -	test-mbrtowc3.sh test-mbrtowc4.sh test-mbsinit.sh \ -	test-memchr$(EXEEXT) test-printf-frexp$(EXEEXT) \ -	test-printf-frexpl$(EXEEXT) test-signbit$(EXEEXT) \ -	test-stdbool$(EXEEXT) test-stdint$(EXEEXT) \ -	test-stdlib$(EXEEXT) test-strerror$(EXEEXT) \ -	test-striconveh$(EXEEXT) test-striconveha$(EXEEXT) \ -	test-string$(EXEEXT) test-cased$(EXEEXT) \ -	test-ignorable$(EXEEXT) unicase/test-locale-language.sh \ -	test-uc_tolower$(EXEEXT) test-uc_totitle$(EXEEXT) \ -	test-uc_toupper$(EXEEXT) test-u16-casecmp$(EXEEXT) \ -	test-u16-casecoll$(EXEEXT) test-u16-casefold$(EXEEXT) \ -	test-u16-is-cased$(EXEEXT) test-u16-is-casefolded$(EXEEXT) \ -	test-u16-is-lowercase$(EXEEXT) test-u16-is-titlecase$(EXEEXT) \ -	test-u16-is-uppercase$(EXEEXT) test-u16-tolower$(EXEEXT) \ -	test-u16-totitle$(EXEEXT) test-u16-toupper$(EXEEXT) \ -	test-u32-casecmp$(EXEEXT) test-u32-casecoll$(EXEEXT) \ -	test-u32-casefold$(EXEEXT) test-u32-is-cased$(EXEEXT) \ -	test-u32-is-casefolded$(EXEEXT) test-u32-is-lowercase$(EXEEXT) \ -	test-u32-is-titlecase$(EXEEXT) test-u32-is-uppercase$(EXEEXT) \ -	test-u32-tolower$(EXEEXT) test-u32-totitle$(EXEEXT) \ -	test-u32-toupper$(EXEEXT) test-u8-casecmp$(EXEEXT) \ -	test-u8-casecoll$(EXEEXT) test-u8-casefold$(EXEEXT) \ -	test-u8-is-cased$(EXEEXT) test-u8-is-casefolded$(EXEEXT) \ -	test-u8-is-lowercase$(EXEEXT) test-u8-is-titlecase$(EXEEXT) \ -	test-u8-is-uppercase$(EXEEXT) test-u8-tolower$(EXEEXT) \ -	test-u8-totitle$(EXEEXT) test-u8-toupper$(EXEEXT) \ -	unicase/test-ulc-casecmp1.sh unicase/test-ulc-casecmp2.sh \ -	unicase/test-ulc-casecoll1.sh unicase/test-ulc-casecoll2.sh \ -	test-u16-conv-from-enc$(EXEEXT) test-u16-conv-to-enc$(EXEEXT) \ +	test-c-ctype$(EXEEXT) test-c-strcase.sh test-dup2$(EXEEXT) \ +	test-environ$(EXEEXT) test-errno$(EXEEXT) test-fcntl$(EXEEXT) \ +	test-frexpl-nolibm$(EXEEXT) test-fseterr$(EXEEXT) \ +	test-iconv$(EXEEXT) test-isnand-nolibm$(EXEEXT) \ +	test-isnanf-nolibm$(EXEEXT) test-isnanl-nolibm$(EXEEXT) \ +	test-locale$(EXEEXT) test-localename$(EXEEXT) \ +	test-malloca$(EXEEXT) test-math$(EXEEXT) test-mbrtowc1.sh \ +	test-mbrtowc2.sh test-mbrtowc3.sh test-mbrtowc4.sh \ +	test-mbsinit.sh test-memchr$(EXEEXT) test-open$(EXEEXT) \ +	test-printf-frexp$(EXEEXT) test-printf-frexpl$(EXEEXT) \ +	test-signbit$(EXEEXT) test-stdbool$(EXEEXT) \ +	test-stddef$(EXEEXT) test-stdint$(EXEEXT) test-stdlib$(EXEEXT) \ +	test-strerror$(EXEEXT) test-striconveh$(EXEEXT) \ +	test-striconveha$(EXEEXT) test-string$(EXEEXT) \ +	test-cased$(EXEEXT) test-ignorable$(EXEEXT) \ +	unicase/test-locale-language.sh test-uc_tolower$(EXEEXT) \ +	test-uc_totitle$(EXEEXT) test-uc_toupper$(EXEEXT) \ +	test-u16-casecmp$(EXEEXT) test-u16-casecoll$(EXEEXT) \ +	test-u16-casefold$(EXEEXT) test-u16-is-cased$(EXEEXT) \ +	test-u16-is-casefolded$(EXEEXT) test-u16-is-lowercase$(EXEEXT) \ +	test-u16-is-titlecase$(EXEEXT) test-u16-is-uppercase$(EXEEXT) \ +	test-u16-tolower$(EXEEXT) test-u16-totitle$(EXEEXT) \ +	test-u16-toupper$(EXEEXT) test-u32-casecmp$(EXEEXT) \ +	test-u32-casecoll$(EXEEXT) test-u32-casefold$(EXEEXT) \ +	test-u32-is-cased$(EXEEXT) test-u32-is-casefolded$(EXEEXT) \ +	test-u32-is-lowercase$(EXEEXT) test-u32-is-titlecase$(EXEEXT) \ +	test-u32-is-uppercase$(EXEEXT) test-u32-tolower$(EXEEXT) \ +	test-u32-totitle$(EXEEXT) test-u32-toupper$(EXEEXT) \ +	test-u8-casecmp$(EXEEXT) test-u8-casecoll$(EXEEXT) \ +	test-u8-casefold$(EXEEXT) test-u8-is-cased$(EXEEXT) \ +	test-u8-is-casefolded$(EXEEXT) test-u8-is-lowercase$(EXEEXT) \ +	test-u8-is-titlecase$(EXEEXT) test-u8-is-uppercase$(EXEEXT) \ +	test-u8-tolower$(EXEEXT) test-u8-totitle$(EXEEXT) \ +	test-u8-toupper$(EXEEXT) unicase/test-ulc-casecmp1.sh \ +	unicase/test-ulc-casecmp2.sh unicase/test-ulc-casecoll1.sh \ +	unicase/test-ulc-casecoll2.sh test-u16-conv-from-enc$(EXEEXT) \ +	test-u16-conv-to-enc$(EXEEXT) \  	test-u16-strconv-from-enc$(EXEEXT) \  	test-u16-strconv-to-enc$(EXEEXT) \  	test-u32-conv-from-enc$(EXEEXT) test-u32-conv-to-enc$(EXEEXT) \ @@ -234,16 +235,17 @@ noinst_PROGRAMS =  check_PROGRAMS = test-alloca-opt$(EXEEXT) \  	test-array-mergesort$(EXEEXT) test-c-ctype$(EXEEXT) \  	test-c-strcasecmp$(EXEEXT) test-c-strncasecmp$(EXEEXT) \ -	test-environ$(EXEEXT) test-errno$(EXEEXT) \ -	test-frexpl-nolibm$(EXEEXT) test-fseterr$(EXEEXT) \ -	test-iconv$(EXEEXT) test-isnand-nolibm$(EXEEXT) \ -	test-isnanf-nolibm$(EXEEXT) test-isnanl-nolibm$(EXEEXT) \ -	test-locale$(EXEEXT) test-localename$(EXEEXT) \ -	test-malloca$(EXEEXT) test-math$(EXEEXT) test-mbrtowc$(EXEEXT) \ -	test-mbsinit$(EXEEXT) test-memchr$(EXEEXT) \ +	test-dup2$(EXEEXT) test-environ$(EXEEXT) test-errno$(EXEEXT) \ +	test-fcntl$(EXEEXT) test-frexpl-nolibm$(EXEEXT) \ +	test-fseterr$(EXEEXT) test-iconv$(EXEEXT) \ +	test-isnand-nolibm$(EXEEXT) test-isnanf-nolibm$(EXEEXT) \ +	test-isnanl-nolibm$(EXEEXT) test-locale$(EXEEXT) \ +	test-localename$(EXEEXT) test-malloca$(EXEEXT) \ +	test-math$(EXEEXT) test-mbrtowc$(EXEEXT) test-mbsinit$(EXEEXT) \ +	test-memchr$(EXEEXT) test-open$(EXEEXT) \  	test-printf-frexp$(EXEEXT) test-printf-frexpl$(EXEEXT) \  	test-signbit$(EXEEXT) test-stdbool$(EXEEXT) \ -	test-stdint$(EXEEXT) test-stdlib$(EXEEXT) \ +	test-stddef$(EXEEXT) test-stdint$(EXEEXT) test-stdlib$(EXEEXT) \  	test-strerror$(EXEEXT) test-striconveh$(EXEEXT) \  	test-striconveha$(EXEEXT) test-string$(EXEEXT) \  	test-cased$(EXEEXT) test-ignorable$(EXEEXT) \ @@ -418,6 +420,7 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4  am__aclocal_m4_deps = $(top_srcdir)/gnulib-m4/00gnulib.m4 \  	$(top_srcdir)/gnulib-m4/alloca.m4 \  	$(top_srcdir)/gnulib-m4/codeset.m4 \ +	$(top_srcdir)/gnulib-m4/dup2.m4 \  	$(top_srcdir)/gnulib-m4/eealloc.m4 \  	$(top_srcdir)/gnulib-m4/environ.m4 \  	$(top_srcdir)/gnulib-m4/errno_h.m4 \ @@ -427,6 +430,7 @@ am__aclocal_m4_deps = $(top_srcdir)/gnulib-m4/00gnulib.m4 \  	$(top_srcdir)/gnulib-m4/exponentf.m4 \  	$(top_srcdir)/gnulib-m4/exponentl.m4 \  	$(top_srcdir)/gnulib-m4/extensions.m4 \ +	$(top_srcdir)/gnulib-m4/fcntl_h.m4 \  	$(top_srcdir)/gnulib-m4/float_h.m4 \  	$(top_srcdir)/gnulib-m4/fpieee.m4 \  	$(top_srcdir)/gnulib-m4/frexp.m4 \ @@ -470,8 +474,10 @@ am__aclocal_m4_deps = $(top_srcdir)/gnulib-m4/00gnulib.m4 \  	$(top_srcdir)/gnulib-m4/memchr.m4 \  	$(top_srcdir)/gnulib-m4/minmax.m4 \  	$(top_srcdir)/gnulib-m4/mmap-anon.m4 \ +	$(top_srcdir)/gnulib-m4/mode_t.m4 \  	$(top_srcdir)/gnulib-m4/multiarch.m4 \  	$(top_srcdir)/gnulib-m4/nocrash.m4 \ +	$(top_srcdir)/gnulib-m4/open.m4 \  	$(top_srcdir)/gnulib-m4/printf-frexp.m4 \  	$(top_srcdir)/gnulib-m4/printf-frexpl.m4 \  	$(top_srcdir)/gnulib-m4/printf.m4 \ @@ -480,6 +486,7 @@ am__aclocal_m4_deps = $(top_srcdir)/gnulib-m4/00gnulib.m4 \  	$(top_srcdir)/gnulib-m4/signbit.m4 \  	$(top_srcdir)/gnulib-m4/size_max.m4 \  	$(top_srcdir)/gnulib-m4/stdbool.m4 \ +	$(top_srcdir)/gnulib-m4/stddef_h.m4 \  	$(top_srcdir)/gnulib-m4/stdint.m4 \  	$(top_srcdir)/gnulib-m4/stdint_h.m4 \  	$(top_srcdir)/gnulib-m4/stdlib_h.m4 \ @@ -923,6 +930,11 @@ test_digit_OBJECTS = $(am_test_digit_OBJECTS)  test_digit_LDADD = $(LDADD)  test_digit_DEPENDENCIES = libtests.a ../lib/libunistring.la libtests.a \  	$(am__DEPENDENCIES_1) +test_dup2_SOURCES = test-dup2.c +test_dup2_OBJECTS = test-dup2.$(OBJEXT) +test_dup2_LDADD = $(LDADD) +test_dup2_DEPENDENCIES = libtests.a ../lib/libunistring.la libtests.a \ +	$(am__DEPENDENCIES_1)  test_environ_SOURCES = test-environ.c  test_environ_OBJECTS = test-environ.$(OBJEXT)  test_environ_LDADD = $(LDADD) @@ -933,6 +945,11 @@ test_errno_OBJECTS = test-errno.$(OBJEXT)  test_errno_LDADD = $(LDADD)  test_errno_DEPENDENCIES = libtests.a ../lib/libunistring.la libtests.a \  	$(am__DEPENDENCIES_1) +test_fcntl_SOURCES = test-fcntl.c +test_fcntl_OBJECTS = test-fcntl.$(OBJEXT) +test_fcntl_LDADD = $(LDADD) +test_fcntl_DEPENDENCIES = libtests.a ../lib/libunistring.la libtests.a \ +	$(am__DEPENDENCIES_1)  am_test_frexpl_nolibm_OBJECTS = test-frexpl.$(OBJEXT)  test_frexpl_nolibm_OBJECTS = $(am_test_frexpl_nolibm_OBJECTS)  test_frexpl_nolibm_LDADD = $(LDADD) @@ -1043,6 +1060,11 @@ test_numeric_OBJECTS = $(am_test_numeric_OBJECTS)  test_numeric_LDADD = $(LDADD)  test_numeric_DEPENDENCIES = libtests.a ../lib/libunistring.la \  	libtests.a $(am__DEPENDENCIES_1) +test_open_SOURCES = test-open.c +test_open_OBJECTS = test-open.$(OBJEXT) +test_open_LDADD = $(LDADD) +test_open_DEPENDENCIES = libtests.a ../lib/libunistring.la libtests.a \ +	$(am__DEPENDENCIES_1)  am_test_pr_alphabetic_OBJECTS = unictype/test-pr_alphabetic.$(OBJEXT)  test_pr_alphabetic_OBJECTS = $(am_test_pr_alphabetic_OBJECTS)  test_pr_alphabetic_LDADD = $(LDADD) @@ -1568,6 +1590,11 @@ test_stdbool_OBJECTS = test-stdbool.$(OBJEXT)  test_stdbool_LDADD = $(LDADD)  test_stdbool_DEPENDENCIES = libtests.a ../lib/libunistring.la \  	libtests.a $(am__DEPENDENCIES_1) +test_stddef_SOURCES = test-stddef.c +test_stddef_OBJECTS = test-stddef.$(OBJEXT) +test_stddef_LDADD = $(LDADD) +test_stddef_DEPENDENCIES = libtests.a ../lib/libunistring.la \ +	libtests.a $(am__DEPENDENCIES_1)  test_stdint_SOURCES = test-stdint.c  test_stdint_OBJECTS = test-stdint.$(OBJEXT)  test_stdint_LDADD = $(LDADD) @@ -2211,15 +2238,16 @@ SOURCES = $(libtests_a_SOURCES) $(EXTRA_libtests_a_SOURCES) \  	$(test_ctype_space_SOURCES) $(test_ctype_upper_SOURCES) \  	$(test_ctype_xdigit_SOURCES) $(test_decdigit_SOURCES) \  	$(test_decomposing_form_SOURCES) $(test_decomposition_SOURCES) \ -	$(test_digit_SOURCES) test-environ.c test-errno.c \ -	$(test_frexpl_nolibm_SOURCES) test-fseterr.c test-iconv.c \ -	$(test_ignorable_SOURCES) test-isnand-nolibm.c \ +	$(test_digit_SOURCES) test-dup2.c test-environ.c test-errno.c \ +	test-fcntl.c $(test_frexpl_nolibm_SOURCES) test-fseterr.c \ +	test-iconv.c $(test_ignorable_SOURCES) test-isnand-nolibm.c \  	test-isnanf-nolibm.c test-isnanl-nolibm.c test-locale.c \  	$(test_locale_language_SOURCES) test-localename.c \  	test-malloca.c test-math.c test-mbrtowc.c test-mbsinit.c \  	test-memchr.c $(test_mirror_SOURCES) $(test_nfc_SOURCES) \  	$(test_nfd_SOURCES) $(test_nfkc_SOURCES) $(test_nfkd_SOURCES) \ -	$(test_numeric_SOURCES) $(test_pr_alphabetic_SOURCES) \ +	$(test_numeric_SOURCES) test-open.c \ +	$(test_pr_alphabetic_SOURCES) \  	$(test_pr_ascii_hex_digit_SOURCES) \  	$(test_pr_bidi_arabic_digit_SOURCES) \  	$(test_pr_bidi_arabic_right_to_left_SOURCES) \ @@ -2285,9 +2313,10 @@ SOURCES = $(libtests_a_SOURCES) $(EXTRA_libtests_a_SOURCES) \  	$(test_pr_xid_start_SOURCES) $(test_pr_zero_width_SOURCES) \  	test-printf-frexp.c test-printf-frexpl.c \  	$(test_scripts_SOURCES) test-signbit.c test-stdbool.c \ -	test-stdint.c test-stdlib.c test-strerror.c test-striconveh.c \ -	test-striconveha.c test-string.c $(test_sy_c_ident_SOURCES) \ -	$(test_sy_c_whitespace_SOURCES) $(test_sy_java_ident_SOURCES) \ +	test-stddef.c test-stdint.c test-stdlib.c test-strerror.c \ +	test-striconveh.c test-striconveha.c test-string.c \ +	$(test_sy_c_ident_SOURCES) $(test_sy_c_whitespace_SOURCES) \ +	$(test_sy_java_ident_SOURCES) \  	$(test_sy_java_whitespace_SOURCES) \  	$(test_u16_asnprintf1_SOURCES) $(test_u16_casecmp_SOURCES) \  	$(test_u16_casecoll_SOURCES) $(test_u16_casefold_SOURCES) \ @@ -2400,15 +2429,16 @@ DIST_SOURCES = $(libtests_a_SOURCES) $(EXTRA_libtests_a_SOURCES) \  	$(test_ctype_space_SOURCES) $(test_ctype_upper_SOURCES) \  	$(test_ctype_xdigit_SOURCES) $(test_decdigit_SOURCES) \  	$(test_decomposing_form_SOURCES) $(test_decomposition_SOURCES) \ -	$(test_digit_SOURCES) test-environ.c test-errno.c \ -	$(test_frexpl_nolibm_SOURCES) test-fseterr.c test-iconv.c \ -	$(test_ignorable_SOURCES) test-isnand-nolibm.c \ +	$(test_digit_SOURCES) test-dup2.c test-environ.c test-errno.c \ +	test-fcntl.c $(test_frexpl_nolibm_SOURCES) test-fseterr.c \ +	test-iconv.c $(test_ignorable_SOURCES) test-isnand-nolibm.c \  	test-isnanf-nolibm.c test-isnanl-nolibm.c test-locale.c \  	$(test_locale_language_SOURCES) test-localename.c \  	test-malloca.c test-math.c test-mbrtowc.c test-mbsinit.c \  	test-memchr.c $(test_mirror_SOURCES) $(test_nfc_SOURCES) \  	$(test_nfd_SOURCES) $(test_nfkc_SOURCES) $(test_nfkd_SOURCES) \ -	$(test_numeric_SOURCES) $(test_pr_alphabetic_SOURCES) \ +	$(test_numeric_SOURCES) test-open.c \ +	$(test_pr_alphabetic_SOURCES) \  	$(test_pr_ascii_hex_digit_SOURCES) \  	$(test_pr_bidi_arabic_digit_SOURCES) \  	$(test_pr_bidi_arabic_right_to_left_SOURCES) \ @@ -2474,9 +2504,10 @@ DIST_SOURCES = $(libtests_a_SOURCES) $(EXTRA_libtests_a_SOURCES) \  	$(test_pr_xid_start_SOURCES) $(test_pr_zero_width_SOURCES) \  	test-printf-frexp.c test-printf-frexpl.c \  	$(test_scripts_SOURCES) test-signbit.c test-stdbool.c \ -	test-stdint.c test-stdlib.c test-strerror.c test-striconveh.c \ -	test-striconveha.c test-string.c $(test_sy_c_ident_SOURCES) \ -	$(test_sy_c_whitespace_SOURCES) $(test_sy_java_ident_SOURCES) \ +	test-stddef.c test-stdint.c test-stdlib.c test-strerror.c \ +	test-striconveh.c test-striconveha.c test-string.c \ +	$(test_sy_c_ident_SOURCES) $(test_sy_c_whitespace_SOURCES) \ +	$(test_sy_java_ident_SOURCES) \  	$(test_sy_java_whitespace_SOURCES) \  	$(test_u16_asnprintf1_SOURCES) $(test_u16_casecmp_SOURCES) \  	$(test_u16_casecoll_SOURCES) $(test_u16_casefold_SOURCES) \ @@ -2649,6 +2680,7 @@ EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@  EOVERFLOW_VALUE = @EOVERFLOW_VALUE@  ERRNO_H = @ERRNO_H@  EXEEXT = @EXEEXT@ +FCNTL_H = @FCNTL_H@  FGREP = @FGREP@  FLOAT_H = @FLOAT_H@  GLIBC21 = @GLIBC21@ @@ -2716,6 +2748,7 @@ GNULIB_MEMPCPY = @GNULIB_MEMPCPY@  GNULIB_MEMRCHR = @GNULIB_MEMRCHR@  GNULIB_MKDTEMP = @GNULIB_MKDTEMP@  GNULIB_MKSTEMP = @GNULIB_MKSTEMP@ +GNULIB_OPEN = @GNULIB_OPEN@  GNULIB_PUTENV = @GNULIB_PUTENV@  GNULIB_RANDOM_R = @GNULIB_RANDOM_R@  GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@ @@ -2748,6 +2781,7 @@ GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@  GNULIB_TRUNC = @GNULIB_TRUNC@  GNULIB_TRUNCF = @GNULIB_TRUNCF@  GNULIB_TRUNCL = @GNULIB_TRUNCL@ +GNULIB_UNISTD_H_GETOPT = @GNULIB_UNISTD_H_GETOPT@  GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@  GNULIB_UNSETENV = @GNULIB_UNSETENV@  GNULIB_WCRTOMB = @GNULIB_WCRTOMB@ @@ -2846,6 +2880,7 @@ HAVE_UNISTD_H = @HAVE_UNISTD_H@  HAVE_UNSETENV = @HAVE_UNSETENV@  HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@  HAVE_WCHAR_H = @HAVE_WCHAR_H@ +HAVE_WCHAR_T = @HAVE_WCHAR_T@  HAVE_WCRTOMB = @HAVE_WCRTOMB@  HAVE_WCSNRTOMBS = @HAVE_WCSNRTOMBS@  HAVE_WCSRTOMBS = @HAVE_WCSRTOMBS@ @@ -2886,10 +2921,12 @@ MAKEINFO = @MAKEINFO@  MKDIR_P = @MKDIR_P@  NAMESPACING = @NAMESPACING@  NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = @NEXT_AS_FIRST_DIRECTIVE_ERRNO_H@ +NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@  NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = @NEXT_AS_FIRST_DIRECTIVE_FLOAT_H@  NEXT_AS_FIRST_DIRECTIVE_ICONV_H = @NEXT_AS_FIRST_DIRECTIVE_ICONV_H@  NEXT_AS_FIRST_DIRECTIVE_LOCALE_H = @NEXT_AS_FIRST_DIRECTIVE_LOCALE_H@  NEXT_AS_FIRST_DIRECTIVE_MATH_H = @NEXT_AS_FIRST_DIRECTIVE_MATH_H@ +NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@  NEXT_AS_FIRST_DIRECTIVE_STDINT_H = @NEXT_AS_FIRST_DIRECTIVE_STDINT_H@  NEXT_AS_FIRST_DIRECTIVE_STDLIB_H = @NEXT_AS_FIRST_DIRECTIVE_STDLIB_H@  NEXT_AS_FIRST_DIRECTIVE_STRING_H = @NEXT_AS_FIRST_DIRECTIVE_STRING_H@ @@ -2897,10 +2934,12 @@ NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@  NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@  NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H@  NEXT_ERRNO_H = @NEXT_ERRNO_H@ +NEXT_FCNTL_H = @NEXT_FCNTL_H@  NEXT_FLOAT_H = @NEXT_FLOAT_H@  NEXT_ICONV_H = @NEXT_ICONV_H@  NEXT_LOCALE_H = @NEXT_LOCALE_H@  NEXT_MATH_H = @NEXT_MATH_H@ +NEXT_STDDEF_H = @NEXT_STDDEF_H@  NEXT_STDINT_H = @NEXT_STDINT_H@  NEXT_STDLIB_H = @NEXT_STDLIB_H@  NEXT_STRING_H = @NEXT_STRING_H@ @@ -2918,6 +2957,7 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@  PACKAGE_NAME = @PACKAGE_NAME@  PACKAGE_STRING = @PACKAGE_STRING@  PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@  PACKAGE_VERSION = @PACKAGE_VERSION@  PATH_SEPARATOR = @PATH_SEPARATOR@  PERL = @PERL@ @@ -2931,6 +2971,7 @@ REPLACE_CEILF = @REPLACE_CEILF@  REPLACE_CEILL = @REPLACE_CEILL@  REPLACE_CHOWN = @REPLACE_CHOWN@  REPLACE_CLOSE = @REPLACE_CLOSE@ +REPLACE_DUP2 = @REPLACE_DUP2@  REPLACE_FCHDIR = @REPLACE_FCHDIR@  REPLACE_FLOORF = @REPLACE_FLOORF@  REPLACE_FLOORL = @REPLACE_FLOORL@ @@ -2959,6 +3000,8 @@ REPLACE_MEMCHR = @REPLACE_MEMCHR@  REPLACE_MEMMEM = @REPLACE_MEMMEM@  REPLACE_MKSTEMP = @REPLACE_MKSTEMP@  REPLACE_NAN = @REPLACE_NAN@ +REPLACE_NULL = @REPLACE_NULL@ +REPLACE_OPEN = @REPLACE_OPEN@  REPLACE_PUTENV = @REPLACE_PUTENV@  REPLACE_ROUND = @REPLACE_ROUND@  REPLACE_ROUNDF = @REPLACE_ROUNDF@ @@ -2984,10 +3027,12 @@ SHELL = @SHELL@  SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@  SIZE_T_SUFFIX = @SIZE_T_SUFFIX@  STDBOOL_H = @STDBOOL_H@ +STDDEF_H = @STDDEF_H@  STDINT_H = @STDINT_H@  STRIP = @STRIP@  TEXI2DVI = @TEXI2DVI@  UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@ +UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@  VERSION = @VERSION@  VOID_UNSETENV = @VOID_UNSETENV@  WCHAR_H = @WCHAR_H@ @@ -3084,16 +3129,17 @@ noinst_LIBRARIES =  check_LIBRARIES = libtests.a  EXTRA_DIST = test-alloca-opt.c test-array-mergesort.c test-c-ctype.c \  	test-c-strcase.sh test-c-strcasecmp.c test-c-strncasecmp.c \ -	test-environ.c test-errno.c error.c error.h exitfail.c \ -	exitfail.h test-frexpl.c test-fseterr.c test-iconv.c \ -	intprops.h test-isnand-nolibm.c test-isnand.h nan.h \ -	test-isnanf-nolibm.c test-isnanf.h nan.h test-isnanl-nolibm.c \ -	test-isnanl.h nan.h locale.in.h test-locale.c \ -	test-localename.c test-malloca.c test-math.c test-mbrtowc1.sh \ -	test-mbrtowc2.sh test-mbrtowc3.sh test-mbrtowc4.sh \ -	test-mbrtowc.c test-mbsinit.sh test-mbsinit.c test-memchr.c \ -	zerosize-ptr.h test-printf-frexp.c test-printf-frexpl.c \ -	setenv.c test-signbit.c test-stdbool.c test-stdint.c \ +	test-dup2.c test-environ.c test-errno.c error.c error.h \ +	exitfail.c exitfail.h fcntl.in.h test-fcntl.c test-frexpl.c \ +	test-fseterr.c test-iconv.c intprops.h test-isnand-nolibm.c \ +	test-isnand.h nan.h test-isnanf-nolibm.c test-isnanf.h nan.h \ +	test-isnanl-nolibm.c test-isnanl.h nan.h locale.in.h \ +	test-locale.c test-localename.c test-malloca.c test-math.c \ +	test-mbrtowc1.sh test-mbrtowc2.sh test-mbrtowc3.sh \ +	test-mbrtowc4.sh test-mbrtowc.c test-mbsinit.sh test-mbsinit.c \ +	test-memchr.c zerosize-ptr.h open.c test-open.c \ +	test-printf-frexp.c test-printf-frexpl.c setenv.c \ +	test-signbit.c test-stdbool.c test-stddef.c test-stdint.c \  	test-stdlib.c strerror.c test-strerror.c test-striconveh.c \  	test-striconveha.c test-string.c unicase/test-cased.c \  	unicase/test-predicate-part1.h unicase/test-predicate-part2.h \ @@ -3550,9 +3596,10 @@ EXTRA_DIST = test-alloca-opt.c test-array-mergesort.c test-c-ctype.c \  	uniwidth/test-uc_width.c uniwidth/test-uc_width2.c \  	uniwidth/test-uc_width2.sh unsetenv.c test-wchar.c wctob.c \  	test-wctype.c test-wcwidth.c xalloc.h xmalloc.c -BUILT_SOURCES = $(LOCALE_H) +BUILT_SOURCES = $(FCNTL_H) $(LOCALE_H)  SUFFIXES =  -MOSTLYCLEANFILES = core *.stackdump locale.h locale.h-t +MOSTLYCLEANFILES = core *.stackdump fcntl.h fcntl.h-t locale.h \ +	locale.h-t  MOSTLYCLEANDIRS =   CLEANFILES =   DISTCLEANFILES =  @@ -3566,8 +3613,8 @@ LDADD = libtests.a ../lib/libunistring.la libtests.a $(LIBTESTS_LIBDEPS)  libtests_a_SOURCES = gettext.h progname.h progname.c xalloc-die.c  libtests_a_LIBADD = $(gltests_LIBOBJS)  libtests_a_DEPENDENCIES = $(gltests_LIBOBJS) -EXTRA_libtests_a_SOURCES = error.c exitfail.c setenv.c strerror.c \ -	unsetenv.c wctob.c xmalloc.c +EXTRA_libtests_a_SOURCES = error.c exitfail.c open.c setenv.c \ +	strerror.c unsetenv.c wctob.c xmalloc.c  AM_LIBTOOLFLAGS = --preserve-dup-deps  test_frexpl_nolibm_SOURCES = test-frexpl.c  test_iconv_LDADD = $(LDADD) @LIBICONV@ @@ -4411,12 +4458,18 @@ unictype/test-digit.$(OBJEXT): unictype/$(am__dirstamp) \  test-digit$(EXEEXT): $(test_digit_OBJECTS) $(test_digit_DEPENDENCIES)   	@rm -f test-digit$(EXEEXT)  	$(AM_V_CCLD)$(LINK) $(test_digit_OBJECTS) $(test_digit_LDADD) $(LIBS) +test-dup2$(EXEEXT): $(test_dup2_OBJECTS) $(test_dup2_DEPENDENCIES)  +	@rm -f test-dup2$(EXEEXT) +	$(AM_V_CCLD)$(LINK) $(test_dup2_OBJECTS) $(test_dup2_LDADD) $(LIBS)  test-environ$(EXEEXT): $(test_environ_OBJECTS) $(test_environ_DEPENDENCIES)   	@rm -f test-environ$(EXEEXT)  	$(AM_V_CCLD)$(LINK) $(test_environ_OBJECTS) $(test_environ_LDADD) $(LIBS)  test-errno$(EXEEXT): $(test_errno_OBJECTS) $(test_errno_DEPENDENCIES)   	@rm -f test-errno$(EXEEXT)  	$(AM_V_CCLD)$(LINK) $(test_errno_OBJECTS) $(test_errno_LDADD) $(LIBS) +test-fcntl$(EXEEXT): $(test_fcntl_OBJECTS) $(test_fcntl_DEPENDENCIES)  +	@rm -f test-fcntl$(EXEEXT) +	$(AM_V_CCLD)$(LINK) $(test_fcntl_OBJECTS) $(test_fcntl_LDADD) $(LIBS)  test-frexpl-nolibm$(EXEEXT): $(test_frexpl_nolibm_OBJECTS) $(test_frexpl_nolibm_DEPENDENCIES)   	@rm -f test-frexpl-nolibm$(EXEEXT)  	$(AM_V_CCLD)$(LINK) $(test_frexpl_nolibm_OBJECTS) $(test_frexpl_nolibm_LDADD) $(LIBS) @@ -4520,6 +4573,9 @@ unictype/test-numeric.$(OBJEXT): unictype/$(am__dirstamp) \  test-numeric$(EXEEXT): $(test_numeric_OBJECTS) $(test_numeric_DEPENDENCIES)   	@rm -f test-numeric$(EXEEXT)  	$(AM_V_CCLD)$(LINK) $(test_numeric_OBJECTS) $(test_numeric_LDADD) $(LIBS) +test-open$(EXEEXT): $(test_open_OBJECTS) $(test_open_DEPENDENCIES)  +	@rm -f test-open$(EXEEXT) +	$(AM_V_CCLD)$(LINK) $(test_open_OBJECTS) $(test_open_LDADD) $(LIBS)  unictype/test-pr_alphabetic.$(OBJEXT): unictype/$(am__dirstamp) \  	unictype/$(DEPDIR)/$(am__dirstamp)  test-pr_alphabetic$(EXEEXT): $(test_pr_alphabetic_OBJECTS) $(test_pr_alphabetic_DEPENDENCIES)  @@ -4942,6 +4998,9 @@ test-signbit$(EXEEXT): $(test_signbit_OBJECTS) $(test_signbit_DEPENDENCIES)  test-stdbool$(EXEEXT): $(test_stdbool_OBJECTS) $(test_stdbool_DEPENDENCIES)   	@rm -f test-stdbool$(EXEEXT)  	$(AM_V_CCLD)$(LINK) $(test_stdbool_OBJECTS) $(test_stdbool_LDADD) $(LIBS) +test-stddef$(EXEEXT): $(test_stddef_OBJECTS) $(test_stddef_DEPENDENCIES)  +	@rm -f test-stddef$(EXEEXT) +	$(AM_V_CCLD)$(LINK) $(test_stddef_OBJECTS) $(test_stddef_LDADD) $(LIBS)  test-stdint$(EXEEXT): $(test_stdint_OBJECTS) $(test_stdint_DEPENDENCIES)   	@rm -f test-stdint$(EXEEXT)  	$(AM_V_CCLD)$(LINK) $(test_stdint_OBJECTS) $(test_stdint_LDADD) $(LIBS) @@ -5879,6 +5938,7 @@ distclean-compile:  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error.Po@am__quote@  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exitfail.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/open.Po@am__quote@  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/progname.Po@am__quote@  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/setenv.Po@am__quote@  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strerror.Po@am__quote@ @@ -5887,8 +5947,10 @@ distclean-compile:  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-c-ctype.Po@am__quote@  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-c-strcasecmp.Po@am__quote@  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-c-strncasecmp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-dup2.Po@am__quote@  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-environ.Po@am__quote@  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-errno.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fcntl.Po@am__quote@  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-frexpl.Po@am__quote@  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fseterr.Po@am__quote@  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-iconv.Po@am__quote@ @@ -5902,10 +5964,12 @@ distclean-compile:  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-mbrtowc.Po@am__quote@  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-mbsinit.Po@am__quote@  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-memchr.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-open.Po@am__quote@  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-printf-frexp.Po@am__quote@  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-printf-frexpl.Po@am__quote@  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-signbit.Po@am__quote@  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-stdbool.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-stddef.Po@am__quote@  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-stdint.Po@am__quote@  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-stdlib.Po@am__quote@  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-strerror.Po@am__quote@ @@ -6680,6 +6744,20 @@ uninstall-am:  	tags-recursive uninstall uninstall-am +# We need the following in order to create <fcntl.h> when the system +# doesn't have one that works with the given compiler. +fcntl.h: fcntl.in.h +	rm -f $@-t $@ +	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ +	  sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ +	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ +	      -e 's|@''NEXT_FCNTL_H''@|$(NEXT_FCNTL_H)|g' \ +	      -e 's|@''GNULIB_OPEN''@|$(GNULIB_OPEN)|g' \ +	      -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \ +	      < $(srcdir)/fcntl.in.h; \ +	} > $@-t +	mv $@-t $@ +  # We need the following in order to create <locale.h> when the system  # doesn't have one that provides all definitions.  locale.h: locale.in.h diff --git a/tests/error.c b/tests/error.c index 3177bd5d..af2287b2 100644 --- a/tests/error.c +++ b/tests/error.c @@ -1,5 +1,5 @@  /* Error handler for noninteractive utilities -   Copyright (C) 1990-1998, 2000-2007 Free Software Foundation, Inc. +   Copyright (C) 1990-1998, 2000-2007, 2009 Free Software Foundation, Inc.     This file is part of the GNU C Library.     This program is free software: you can redistribute it and/or modify @@ -85,6 +85,8 @@ extern void __error_at_line (int status, int errnum, const char *file_name,  #else /* not _LIBC */ +# include <fcntl.h> +  # if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P  #  ifndef HAVE_DECL_STRERROR_R  "this configure-time declaration test was not run" @@ -236,6 +238,12 @@ error (int status, int errnum, const char *message, ...)  		   0);  #endif +#if !_LIBC && defined F_GETFL +  /* POSIX states that fflush (stdout) after fclose is unspecified; it +     is safe in glibc, but not on all other platforms.  fflush (NULL) +     is always defined, but too draconian.  */ +  if (0 <= fcntl (1, F_GETFL)) +#endif    fflush (stdout);  #ifdef _LIBC    _IO_flockfile (stderr); @@ -295,6 +303,12 @@ error_at_line (int status, int errnum, const char *file_name,  		   0);  #endif +#if !_LIBC && defined F_GETFL +  /* POSIX states that fflush (stdout) after fclose is unspecified; it +     is safe in glibc, but not on all other platforms.  fflush (NULL) +     is always defined, but too draconian.  */ +  if (0 <= fcntl (1, F_GETFL)) +#endif    fflush (stdout);  #ifdef _LIBC    _IO_flockfile (stderr); diff --git a/tests/fcntl.in.h b/tests/fcntl.in.h new file mode 100644 index 00000000..fd7520e8 --- /dev/null +++ b/tests/fcntl.in.h @@ -0,0 +1,144 @@ +/* Like <fcntl.h>, but with non-working flags defined to 0. + +   Copyright (C) 2006-2008 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 Paul Eggert */ + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif + +#if defined __need_system_fcntl_h +/* Special invocation convention.  */ + +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#@INCLUDE_NEXT@ @NEXT_FCNTL_H@ + +#else +/* Normal invocation convention.  */ + +#ifndef _GL_FCNTL_H + +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +/* The include_next requires a split double-inclusion guard.  */ +#@INCLUDE_NEXT@ @NEXT_FCNTL_H@ + +#ifndef _GL_FCNTL_H +#define _GL_FCNTL_H + + +/* Declare overridden functions.  */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if @GNULIB_OPEN@ +# if @REPLACE_OPEN@ +#  undef open +#  define open rpl_open +extern int open (const char *filename, int flags, ...); +# endif +#endif + +#ifdef FCHDIR_REPLACEMENT +/* gnulib internal function.  */ +extern void _gl_register_fd (int fd, const char *filename); +#endif + +#ifdef __cplusplus +} +#endif + + +/* Fix up the O_* macros.  */ + +#if !defined O_DIRECT && defined O_DIRECTIO +/* Tru64 spells it `O_DIRECTIO'.  */ +# define O_DIRECT O_DIRECTIO +#endif + +#ifndef O_DIRECT +# define O_DIRECT 0 +#endif + +#ifndef O_DIRECTORY +# define O_DIRECTORY 0 +#endif + +#ifndef O_DSYNC +# define O_DSYNC 0 +#endif + +#ifndef O_NDELAY +# define O_NDELAY 0 +#endif + +#ifndef O_NOATIME +# define O_NOATIME 0 +#endif + +#ifndef O_NONBLOCK +# define O_NONBLOCK O_NDELAY +#endif + +#ifndef O_NOCTTY +# define O_NOCTTY 0 +#endif + +#ifndef O_NOFOLLOW +# define O_NOFOLLOW 0 +#endif + +#ifndef O_NOLINKS +# define O_NOLINKS 0 +#endif + +#ifndef O_RSYNC +# define O_RSYNC 0 +#endif + +#ifndef O_SYNC +# define O_SYNC 0 +#endif + +/* For systems that distinguish between text and binary I/O. +   O_BINARY is usually declared in fcntl.h  */ +#if !defined O_BINARY && defined _O_BINARY +  /* For MSC-compatible compilers.  */ +# define O_BINARY _O_BINARY +# define O_TEXT _O_TEXT +#endif + +#if defined __BEOS__ || defined __HAIKU__ +  /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect.  */ +# undef O_BINARY +# undef O_TEXT +#endif + +#ifndef O_BINARY +# define O_BINARY 0 +# define O_TEXT 0 +#endif + + +#endif /* _GL_FCNTL_H */ +#endif /* _GL_FCNTL_H */ +#endif diff --git a/tests/locale.in.h b/tests/locale.in.h index 10629f6c..0557c9f1 100644 --- a/tests/locale.in.h +++ b/tests/locale.in.h @@ -1,5 +1,5 @@  /* A POSIX <locale.h>. -   Copyright (C) 2007-2008 Free Software Foundation, Inc. +   Copyright (C) 2007-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 @@ -26,6 +26,9 @@  #ifndef _GL_LOCALE_H  #define _GL_LOCALE_H +/* NetBSD 5.0 mis-defines NULL.  */ +#include <stddef.h> +  /* The LC_MESSAGES locale category is specified in POSIX, but not in ISO C.     On systems that don't define it, use the same value as GNU libintl.  */  #if !defined LC_MESSAGES diff --git a/tests/open.c b/tests/open.c new file mode 100644 index 00000000..326e6d15 --- /dev/null +++ b/tests/open.c @@ -0,0 +1,137 @@ +/* Open a descriptor to a file. +   Copyright (C) 2007-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>, 2007.  */ + +#include <config.h> + +/* Get the original definition of open.  It might be defined as a macro.  */ +#define __need_system_fcntl_h +#include <fcntl.h> +#undef __need_system_fcntl_h +#include <sys/types.h> + +static inline int +orig_open (const char *filename, int flags, mode_t mode) +{ +  return open (filename, flags, mode); +} + +/* Specification.  */ +#include <fcntl.h> + +#include <errno.h> +#include <stdarg.h> +#include <string.h> +#include <sys/types.h> +#include <sys/stat.h> + +int +open (const char *filename, int flags, ...) +{ +  mode_t mode; +  int fd; + +  mode = 0; +  if (flags & O_CREAT) +    { +      va_list arg; +      va_start (arg, flags); + +      /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4 +	 creates crashing code when 'mode_t' is smaller than 'int'.  */ +      mode = va_arg (arg, PROMOTED_MODE_T); + +      va_end (arg); +    } + +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +  if (strcmp (filename, "/dev/null") == 0) +    filename = "NUL"; +#endif + +#if OPEN_TRAILING_SLASH_BUG +  /* If the filename ends in a slash and one of O_CREAT, O_WRONLY, O_RDWR +     is specified, then fail. +     Rationale: POSIX <http://www.opengroup.org/susv3/basedefs/xbd_chap04.html> +     says that +       "A pathname that contains at least one non-slash character and that +        ends with one or more trailing slashes shall be resolved as if a +        single dot character ( '.' ) were appended to the pathname." +     and +       "The special filename dot shall refer to the directory specified by +        its predecessor." +     If the named file already exists as a directory, then +       - if O_CREAT is specified, open() must fail because of the semantics +         of O_CREAT, +       - if O_WRONLY or O_RDWR is specified, open() must fail because POSIX +         <http://www.opengroup.org/susv3/functions/open.html> says that it +         fails with errno = EISDIR in this case. +     If the named file does not exist or does not name a directory, then +       - if O_CREAT is specified, open() must fail since open() cannot create +         directories, +       - if O_WRONLY or O_RDWR is specified, open() must fail because the +         file does not contain a '.' directory.  */ +  if (flags & (O_CREAT | O_WRONLY | O_RDWR)) +    { +      size_t len = strlen (filename); +      if (len > 0 && filename[len - 1] == '/') +	{ +	  errno = EISDIR; +	  return -1; +	} +    } +#endif + +  fd = orig_open (filename, flags, mode); + +#if OPEN_TRAILING_SLASH_BUG +  /* If the filename ends in a slash and fd does not refer to a directory, +     then fail. +     Rationale: POSIX <http://www.opengroup.org/susv3/basedefs/xbd_chap04.html> +     says that +       "A pathname that contains at least one non-slash character and that +        ends with one or more trailing slashes shall be resolved as if a +        single dot character ( '.' ) were appended to the pathname." +     and +       "The special filename dot shall refer to the directory specified by +        its predecessor." +     If the named file without the slash is not a directory, open() must fail +     with ENOTDIR.  */ +  if (fd >= 0) +    { +      size_t len = strlen (filename); +      if (len > 0 && filename[len - 1] == '/') +	{ +	  struct stat statbuf; + +	  if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode)) +	    { +	      close (fd); +	      errno = ENOTDIR; +	      return -1; +	    } +	} +    } +#endif + +#ifdef FCHDIR_REPLACEMENT +  if (fd >= 0) +    _gl_register_fd (fd, filename); +#endif + +  return fd; +} diff --git a/tests/test-dup2.c b/tests/test-dup2.c new file mode 100644 index 00000000..2009aaa2 --- /dev/null +++ b/tests/test-dup2.c @@ -0,0 +1,121 @@ +/* Test duplicating file descriptors. +   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 Eric Blake <ebb9@byu.net>, 2009.  */ + +#include <config.h> + +#include <unistd.h> + +#include <errno.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> + +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +/* Get declarations of the Win32 API functions.  */ +# define WIN32_LEAN_AND_MEAN +# include <windows.h> +#endif + +#define ASSERT(expr) \ +  do									     \ +    {									     \ +      if (!(expr))							     \ +        {								     \ +          fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ +          fflush (stderr);						     \ +          abort ();							     \ +        }								     \ +    }									     \ +  while (0) + +/* Return non-zero if FD is open.  */ +static int +is_open (int fd) +{ +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +  /* On Win32, the initial state of unassigned standard file +     descriptors is that they are open but point to an +     INVALID_HANDLE_VALUE, and there is no fcntl.  */ +  return (HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE; +#else +# ifndef F_GETFL +#  error Please port fcntl to your platform +# endif +  return 0 <= fcntl (fd, F_GETFL); +#endif +} + +int +main () +{ +  const char *file = "test-dup2.tmp"; +  char buffer[1]; +  int fd = open (file, O_CREAT | O_RDWR, 0600); + +  /* Assume std descriptors were provided by invoker.  */ +  ASSERT (STDERR_FILENO < fd); +  ASSERT (is_open (fd)); +  /* Ignore any other fd's leaked into this process.  */ +  close (fd + 1); +  close (fd + 2); +  ASSERT (!is_open (fd + 1)); +  ASSERT (!is_open (fd + 2)); + +  /* Assigning to self must be a no-op.  */ +  ASSERT (dup2 (fd, fd) == fd); +  ASSERT (is_open (fd)); + +  /* If the source is not open, then the destination is unaffected.  */ +  errno = 0; +  ASSERT (dup2 (fd + 1, fd + 1) == -1); +  ASSERT (errno == EBADF); +  ASSERT (!is_open (fd + 1)); +  errno = 0; +  ASSERT (dup2 (fd + 1, fd) == -1); +  ASSERT (errno == EBADF); +  ASSERT (is_open (fd)); + +  /* The destination must be valid.  */ +  errno = 0; +  ASSERT (dup2 (fd, -2) == -1); +  ASSERT (errno == EBADF); + +  /* Using dup2 can skip fds.  */ +  ASSERT (dup2 (fd, fd + 2) == fd + 2); +  ASSERT (is_open (fd)); +  ASSERT (!is_open (fd + 1)); +  ASSERT (is_open (fd + 2)); + +  /* Prove that dup2 closes the previous occupant of a fd.  */ +  ASSERT (open ("/dev/null", O_WRONLY, 0600) == fd + 1); +  ASSERT (dup2 (fd + 1, fd) == fd); +  ASSERT (close (fd + 1) == 0); +  ASSERT (write (fd, "1", 1) == 1); +  ASSERT (dup2 (fd + 2, fd) == fd); +  ASSERT (write (fd + 2, "2", 1) == 1); +  ASSERT (lseek (fd, SEEK_SET, 0) == 0); +  ASSERT (read (fd, buffer, 1) == 1); +  ASSERT (*buffer == '2'); + +  /* Clean up.  */ +  ASSERT (close (fd + 2) == 0); +  ASSERT (close (fd) == 0); +  ASSERT (unlink (file) == 0); + +  return 0; +} diff --git a/tests/test-fcntl.c b/tests/test-fcntl.c new file mode 100644 index 00000000..449984c8 --- /dev/null +++ b/tests/test-fcntl.c @@ -0,0 +1,35 @@ +/* Test of <fcntl.h> substitute. +   Copyright (C) 2007 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>, 2007.  */ + +#include <config.h> + +#include <fcntl.h> + +/* Check that the various O_* macros are defined.  */ +int o = O_DIRECT | O_DIRECTORY | O_DSYNC | O_NDELAY | O_NOATIME | O_NONBLOCK +	| O_NOCTTY | O_NOFOLLOW | O_NOLINKS | O_RSYNC | O_SYNC +	| O_BINARY | O_TEXT; + +/* Check that the various SEEK_* macros are defined.  */ +int sk[] = { SEEK_CUR, SEEK_END, SEEK_SET }; + +int +main () +{ +  return 0; +} diff --git a/tests/test-open.c b/tests/test-open.c new file mode 100644 index 00000000..f7bb5436 --- /dev/null +++ b/tests/test-open.c @@ -0,0 +1,47 @@ +/* Test of opening a file descriptor. +   Copyright (C) 2007-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>, 2007.  */ + +#include <config.h> + +#include <fcntl.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 () +{ +  ASSERT (open ("nonexist.ent/", O_CREAT | O_RDONLY, 0600) < 0); +  ASSERT (open ("/dev/null/", O_RDONLY) < 0); + +  ASSERT (open ("/dev/null", O_RDONLY) >= 0); + +  return 0; +} diff --git a/tests/test-stddef.c b/tests/test-stddef.c new file mode 100644 index 00000000..f8484987 --- /dev/null +++ b/tests/test-stddef.c @@ -0,0 +1,38 @@ +/* Test of <stddef.h> substitute. +   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 Eric Blake <ebb9@byu.net>, 2009.  */ + +#include <config.h> + +#include <stddef.h> + +#include "verify.h" + +/* Check that appropriate types are defined.  */ +wchar_t a = 'c'; +ptrdiff_t b = 1; +size_t c = 2; + +/* Check that NULL can be passed through varargs as a pointer type, +   per POSIX 2008.  */ +verify (sizeof NULL == sizeof (void *)); + +int +main () +{ +  return 0; +} diff --git a/tests/test-wchar.c b/tests/test-wchar.c index 19da7d93..28660688 100644 --- a/tests/test-wchar.c +++ b/tests/test-wchar.c @@ -1,5 +1,5 @@  /* Test of <wchar.h> substitute. -   Copyright (C) 2007-2008 Free Software Foundation, Inc. +   Copyright (C) 2007-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 @@ -20,10 +20,16 @@  #include <wchar.h> +#include "verify.h" +  /* Check that the types wchar_t and wint_t are defined.  */  wchar_t a = 'c';  wint_t b = 'x'; +/* Check that NULL can be passed through varargs as a pointer type, +   per POSIX 2008.  */ +verify (sizeof NULL == sizeof (void *)); +  int  main ()  { diff --git a/tests/uniconv/test-u16-conv-from-enc.c b/tests/uniconv/test-u16-conv-from-enc.c index ac7617b3..1d1594eb 100644 --- a/tests/uniconv/test-u16-conv-from-enc.c +++ b/tests/uniconv/test-u16-conv-from-enc.c @@ -129,7 +129,7 @@ main ()      }    /* autodetect_jp is only supported when iconv() support ISO-2022-JP-2.  */ -# if defined _LIBICONV_VERSION || !(defined _AIX || defined __sgi || defined __hpux || defined __osf__) +# if defined _LIBICONV_VERSION || !(defined _AIX || defined __sgi || defined __hpux || defined __osf__ || defined __sun)    /* Test conversions from autodetect_jp to UTF-16.  */    for (h = 0; h < SIZEOF (handlers); h++)      { diff --git a/tests/uniconv/test-u16-strconv-from-enc.c b/tests/uniconv/test-u16-strconv-from-enc.c index f2f173a8..492898d0 100644 --- a/tests/uniconv/test-u16-strconv-from-enc.c +++ b/tests/uniconv/test-u16-strconv-from-enc.c @@ -1,5 +1,5 @@  /* Test of conversion to UTF-16 from legacy encodings. -   Copyright (C) 2007-2008 Free Software Foundation, Inc. +   Copyright (C) 2007-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 @@ -83,7 +83,7 @@ main ()      }    /* autodetect_jp is only supported when iconv() support ISO-2022-JP-2.  */ -# if defined _LIBICONV_VERSION || !(defined _AIX || defined __sgi || defined __hpux || defined __osf__) +# if defined _LIBICONV_VERSION || !(defined _AIX || defined __sgi || defined __hpux || defined __osf__ || defined __sun)    /* Test conversions from autodetect_jp to UTF-16.  */    for (h = 0; h < SIZEOF (handlers); h++)      { diff --git a/tests/uniconv/test-u32-conv-from-enc.c b/tests/uniconv/test-u32-conv-from-enc.c index 8f709f18..34640841 100644 --- a/tests/uniconv/test-u32-conv-from-enc.c +++ b/tests/uniconv/test-u32-conv-from-enc.c @@ -129,7 +129,7 @@ main ()      }    /* autodetect_jp is only supported when iconv() support ISO-2022-JP-2.  */ -# if defined _LIBICONV_VERSION || !(defined _AIX || defined __sgi || defined __hpux || defined __osf__) +# if defined _LIBICONV_VERSION || !(defined _AIX || defined __sgi || defined __hpux || defined __osf__ || defined __sun)    /* Test conversions from autodetect_jp to UTF-16.  */    for (h = 0; h < SIZEOF (handlers); h++)      { diff --git a/tests/uniconv/test-u32-strconv-from-enc.c b/tests/uniconv/test-u32-strconv-from-enc.c index 96af7385..2c0e04bf 100644 --- a/tests/uniconv/test-u32-strconv-from-enc.c +++ b/tests/uniconv/test-u32-strconv-from-enc.c @@ -1,5 +1,5 @@  /* Test of conversion to UTF-32 from legacy encodings. -   Copyright (C) 2007-2008 Free Software Foundation, Inc. +   Copyright (C) 2007-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 @@ -83,7 +83,7 @@ main ()      }    /* autodetect_jp is only supported when iconv() support ISO-2022-JP-2.  */ -# if defined _LIBICONV_VERSION || !(defined _AIX || defined __sgi || defined __hpux || defined __osf__) +# if defined _LIBICONV_VERSION || !(defined _AIX || defined __sgi || defined __hpux || defined __osf__ || defined __sun)    /* Test conversions from autodetect_jp to UTF-16.  */    for (h = 0; h < SIZEOF (handlers); h++)      { diff --git a/tests/uniconv/test-u8-conv-from-enc.c b/tests/uniconv/test-u8-conv-from-enc.c index 0768be63..ec8703cc 100644 --- a/tests/uniconv/test-u8-conv-from-enc.c +++ b/tests/uniconv/test-u8-conv-from-enc.c @@ -124,7 +124,7 @@ main ()      }    /* autodetect_jp is only supported when iconv() support ISO-2022-JP-2.  */ -# if defined _LIBICONV_VERSION || !(defined _AIX || defined __sgi || defined __hpux || defined __osf__) +# if defined _LIBICONV_VERSION || !(defined _AIX || defined __sgi || defined __hpux || defined __osf__ || defined __sun)    /* Test conversions from autodetect_jp to UTF-8.  */    for (h = 0; h < SIZEOF (handlers); h++)      { diff --git a/tests/uniconv/test-u8-strconv-from-enc.c b/tests/uniconv/test-u8-strconv-from-enc.c index 7f70c297..8c32ee68 100644 --- a/tests/uniconv/test-u8-strconv-from-enc.c +++ b/tests/uniconv/test-u8-strconv-from-enc.c @@ -1,5 +1,5 @@  /* Test of conversion to UTF-8 from legacy encodings. -   Copyright (C) 2007-2008 Free Software Foundation, Inc. +   Copyright (C) 2007-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 @@ -74,7 +74,7 @@ main ()      }    /* autodetect_jp is only supported when iconv() support ISO-2022-JP-2.  */ -# if defined _LIBICONV_VERSION || !(defined _AIX || defined __sgi || defined __hpux || defined __osf__) +# if defined _LIBICONV_VERSION || !(defined _AIX || defined __sgi || defined __hpux || defined __osf__ || defined __sun)    /* Test conversions from autodetect_jp to UTF-8.  */    for (h = 0; h < SIZEOF (handlers); h++)      { | 
