diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 17:39:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 17:39:29 +0000 |
commit | 8ffec2a3aba6f114784e11f89ef1d57a096ae540 (patch) | |
tree | ccebcbad06203e8241a8e7249f8e6c478a3682ea /gnulib-tests | |
parent | Initial commit. (diff) | |
download | coreutils-upstream.tar.xz coreutils-upstream.zip |
Adding upstream version 8.32.upstream/8.32upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
503 files changed, 79341 insertions, 0 deletions
diff --git a/gnulib-tests/Makefile.am b/gnulib-tests/Makefile.am new file mode 100644 index 0000000..edaa0a7 --- /dev/null +++ b/gnulib-tests/Makefile.am @@ -0,0 +1,20 @@ +include gnulib.mk + +AM_CFLAGS = $(GNULIB_TEST_WARN_CFLAGS) $(WERROR_CFLAGS) + +# A few tests are inherently warning-evoking. +# In the typical case where we use -Werror, exempt the few offenders. + +# test-xvasprintf.c: In function 'test_xasprintf': +# test-xvasprintf.c:100: error: format not a string literal and no \ +# format arguments [-Wformat-security] +test_xvasprintf_CFLAGS = $(AM_CFLAGS) \ + `test -n '$(WERROR_CFLAGS)' && echo ' -Wno-format-security'` + +# test-lock.c: In function 'lock_mutator_thread': +# test-lock.c:148: error: cast from function call of type 'pthread_t' to \ +# non-matching type 'void *' [-Wbad-function-cast] +test_lock_CFLAGS = $(AM_CFLAGS) \ + `test -n '$(WERROR_CFLAGS)' && echo ' -Wno-bad-function-cast'` +test_tls_CFLAGS = $(AM_CFLAGS) \ + `test -n '$(WERROR_CFLAGS)' && echo ' -Wno-bad-function-cast'` diff --git a/gnulib-tests/Makefile.in b/gnulib-tests/Makefile.in new file mode 100644 index 0000000..ff8589b --- /dev/null +++ b/gnulib-tests/Makefile.in @@ -0,0 +1,10267 @@ +# Makefile.in generated by automake 1.16.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2018 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Copyright (C) 2002-2020 Free Software Foundation, Inc. +# +# This file 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 file 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 file. If not, see <https://www.gnu.org/licenses/>. +# +# As a special exception to the GNU General Public License, +# this file may be distributed as part of a program that +# contains a configuration script generated by Autoconf, under +# the same distribution terms as the rest of that program. +# +# Generated by gnulib-tool. + + + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +TESTS = test-accept$(EXEEXT) test-set-mode-acl.sh \ + test-set-mode-acl-1.sh test-set-mode-acl-2.sh test-copy-acl.sh \ + test-copy-acl-1.sh test-copy-acl-2.sh test-alignof$(EXEEXT) \ + test-alloca-opt$(EXEEXT) test-areadlink$(EXEEXT) \ + test-areadlink-with-size$(EXEEXT) test-areadlinkat$(EXEEXT) \ + test-argmatch$(EXEEXT) test-argv-iter$(EXEEXT) \ + test-arpa_inet$(EXEEXT) test-base32$(EXEEXT) \ + test-base64$(EXEEXT) test-binary-io.sh test-bind$(EXEEXT) \ + test-bitrotate$(EXEEXT) test-btowc1.sh test-btowc2.sh \ + test-byteswap$(EXEEXT) test-c-ctype$(EXEEXT) test-c-strcase.sh \ + test-calloc-gnu$(EXEEXT) test-canonicalize$(EXEEXT) \ + test-chdir$(EXEEXT) test-chown$(EXEEXT) test-cloexec$(EXEEXT) \ + test-close$(EXEEXT) test-closein.sh test-connect$(EXEEXT) \ + test-count-leading-zeros$(EXEEXT) test-md5$(EXEEXT) \ + test-sha1$(EXEEXT) test-sha256$(EXEEXT) test-sha512$(EXEEXT) \ + test-ctype$(EXEEXT) test-di-set$(EXEEXT) \ + test-dirent-safer$(EXEEXT) test-dirent$(EXEEXT) \ + test-dirname$(EXEEXT) test-dup$(EXEEXT) test-dup2$(EXEEXT) \ + test-environ$(EXEEXT) test-errno$(EXEEXT) test-exclude1.sh \ + test-exclude2.sh test-exclude3.sh test-exclude4.sh \ + test-exclude5.sh test-exclude6.sh test-exclude7.sh \ + test-exclude8.sh test-faccessat$(EXEEXT) test-fadvise$(EXEEXT) \ + test-fchdir$(EXEEXT) test-fchmodat$(EXEEXT) \ + test-fchownat$(EXEEXT) test-fclose$(EXEEXT) \ + test-fcntl-h$(EXEEXT) test-fcntl-safer$(EXEEXT) \ + test-fcntl$(EXEEXT) test-fdatasync$(EXEEXT) \ + test-fdopen$(EXEEXT) test-fdopendir$(EXEEXT) \ + test-fdutimensat$(EXEEXT) test-fflush$(EXEEXT) test-fflush2.sh \ + test-fgetc$(EXEEXT) test-file-has-acl.sh \ + test-file-has-acl-1.sh test-file-has-acl-2.sh \ + test-filenamecat$(EXEEXT) test-filevercmp$(EXEEXT) \ + test-float$(EXEEXT) test-fnmatch-h$(EXEEXT) \ + test-fnmatch$(EXEEXT) test-fopen-safer$(EXEEXT) \ + test-fopen$(EXEEXT) test-fpending.sh test-fpurge$(EXEEXT) \ + test-fputc$(EXEEXT) test-fread$(EXEEXT) test-freadahead.sh \ + test-freading$(EXEEXT) test-freadptr.sh test-freadptr2.sh \ + test-freadseek.sh test-freopen-safer$(EXEEXT) \ + test-freopen$(EXEEXT) test-frexp-nolibm$(EXEEXT) \ + test-frexpl-nolibm$(EXEEXT) test-fseek.sh test-fseek2.sh \ + test-fseeko.sh test-fseeko2.sh test-fseeko3.sh test-fseeko4.sh \ + test-fseterr$(EXEEXT) test-fstat$(EXEEXT) \ + test-fstatat$(EXEEXT) test-fsync$(EXEEXT) test-ftell.sh \ + test-ftell2.sh test-ftell3$(EXEEXT) test-ftello.sh \ + test-ftello2.sh test-ftello3$(EXEEXT) test-ftello4.sh \ + test-ftruncate.sh test-futimens$(EXEEXT) test-fwrite$(EXEEXT) \ + test-getaddrinfo$(EXEEXT) test-getcwd-lgpl$(EXEEXT) \ + test-getcwd.sh test-getdelim$(EXEEXT) \ + test-getdtablesize$(EXEEXT) test-getgroups$(EXEEXT) \ + test-gethostname$(EXEEXT) test-getline$(EXEEXT) \ + test-getloadavg$(EXEEXT) test-getlogin$(EXEEXT) \ + test-getndelim2$(EXEEXT) test-getopt-gnu$(EXEEXT) \ + test-getopt-posix$(EXEEXT) test-getprogname$(EXEEXT) \ + test-getrusage$(EXEEXT) test-gettimeofday$(EXEEXT) \ + test-hard-locale$(EXEEXT) test-hash$(EXEEXT) \ + test-i-ring$(EXEEXT) test-iconv-h$(EXEEXT) test-iconv$(EXEEXT) \ + test-ignore-value$(EXEEXT) test-inet_ntop$(EXEEXT) \ + test-inet_pton$(EXEEXT) test-ino-map$(EXEEXT) \ + test-intprops$(EXEEXT) test-inttostr$(EXEEXT) \ + test-inttypes$(EXEEXT) test-ioctl$(EXEEXT) \ + test-isatty$(EXEEXT) test-isblank$(EXEEXT) \ + test-isnand-nolibm$(EXEEXT) test-isnanf-nolibm$(EXEEXT) \ + test-isnanl-nolibm$(EXEEXT) test-iswblank$(EXEEXT) \ + test-iswdigit.sh test-iswxdigit.sh test-langinfo$(EXEEXT) \ + test-lchmod$(EXEEXT) test-lchown$(EXEEXT) \ + test-limits-h$(EXEEXT) test-link$(EXEEXT) test-linkat$(EXEEXT) \ + test-listen$(EXEEXT) test-locale$(EXEEXT) \ + test-localeconv$(EXEEXT) test-localename$(EXEEXT) \ + test-rwlock1$(EXEEXT) test-lock$(EXEEXT) test-once1$(EXEEXT) \ + test-once2$(EXEEXT) test-lseek.sh test-lstat$(EXEEXT) \ + test-malloc-gnu$(EXEEXT) test-malloca$(EXEEXT) \ + test-math$(EXEEXT) test-mbrtowc1.sh test-mbrtowc2.sh \ + test-mbrtowc3.sh test-mbrtowc4.sh test-mbrtowc5.sh \ + test-mbrtowc-w32-1.sh test-mbrtowc-w32-2.sh \ + test-mbrtowc-w32-3.sh test-mbrtowc-w32-4.sh \ + test-mbrtowc-w32-5.sh test-mbrtowc-w32-6.sh \ + test-mbrtowc-w32-7.sh test-mbsalign$(EXEEXT) \ + test-mbscasecmp.sh test-mbschr.sh test-mbsinit.sh \ + test-mbsrtowcs1.sh test-mbsrtowcs2.sh test-mbsrtowcs3.sh \ + test-mbsrtowcs4.sh test-mbsstr1$(EXEEXT) test-mbsstr2.sh \ + test-mbsstr3.sh test-memcasecmp$(EXEEXT) test-memchr$(EXEEXT) \ + test-memchr2$(EXEEXT) test-memcoll$(EXEEXT) \ + test-memrchr$(EXEEXT) test-mkdir$(EXEEXT) test-mkfifo$(EXEEXT) \ + test-mknod$(EXEEXT) test-nanosleep$(EXEEXT) \ + test-netdb$(EXEEXT) test-netinet_in$(EXEEXT) \ + test-nl_langinfo.sh test-nl_langinfo-mt$(EXEEXT) \ + test-nstrftime$(EXEEXT) test-open$(EXEEXT) \ + test-openat-safer$(EXEEXT) test-openat$(EXEEXT) \ + test-parse-datetime$(EXEEXT) test-pathmax$(EXEEXT) \ + test-perror.sh test-perror2$(EXEEXT) test-pipe$(EXEEXT) \ + test-pipe2$(EXEEXT) test-posixtm$(EXEEXT) \ + test-printf-frexp$(EXEEXT) test-printf-frexpl$(EXEEXT) \ + test-priv-set$(EXEEXT) test-pthread-cond$(EXEEXT) \ + test-pthread$(EXEEXT) test-pthread-mutex$(EXEEXT) \ + test-pthread-thread$(EXEEXT) test-pthread_sigmask1$(EXEEXT) \ + test-pthread_sigmask2$(EXEEXT) test-quotearg-simple$(EXEEXT) \ + test-raise$(EXEEXT) test-rand-isaac$(EXEEXT) \ + test-read-file$(EXEEXT) test-read$(EXEEXT) \ + test-readlink$(EXEEXT) test-readlinkat$(EXEEXT) \ + test-readtokens.sh test-realloc-gnu$(EXEEXT) \ + test-regex$(EXEEXT) test-remove$(EXEEXT) test-rename$(EXEEXT) \ + test-renameat$(EXEEXT) test-renameatu$(EXEEXT) \ + test-rmdir$(EXEEXT) test-sched$(EXEEXT) test-select$(EXEEXT) \ + test-select-in.sh test-select-out.sh test-setenv$(EXEEXT) \ + test-setlocale_null$(EXEEXT) \ + test-setlocale_null-mt-one$(EXEEXT) \ + test-setlocale_null-mt-all$(EXEEXT) test-setlocale1.sh \ + test-setlocale2.sh test-setsockopt$(EXEEXT) \ + test-sigaction$(EXEEXT) test-signal-h$(EXEEXT) \ + test-signbit$(EXEEXT) test-sigprocmask$(EXEEXT) \ + test-sleep$(EXEEXT) test-snprintf$(EXEEXT) \ + test-sockets$(EXEEXT) test-stat$(EXEEXT) \ + test-stat-time$(EXEEXT) test-statat$(EXEEXT) \ + test-stdalign$(EXEEXT) test-stdbool$(EXEEXT) \ + test-stddef$(EXEEXT) test-stdint$(EXEEXT) test-stdio$(EXEEXT) \ + test-stdlib$(EXEEXT) test-strerror$(EXEEXT) \ + test-strerror_r$(EXEEXT) test-striconv$(EXEEXT) \ + test-string$(EXEEXT) test-strncat$(EXEEXT) \ + test-strnlen$(EXEEXT) test-strsignal$(EXEEXT) \ + test-strtod$(EXEEXT) test-strtod1.sh test-strtoimax$(EXEEXT) \ + test-strtold$(EXEEXT) test-strtold1.sh test-strtoll$(EXEEXT) \ + test-strtoull$(EXEEXT) test-strtoumax$(EXEEXT) \ + test-symlink$(EXEEXT) test-symlinkat$(EXEEXT) \ + test-sys_ioctl$(EXEEXT) test-sys_resource$(EXEEXT) \ + test-sys_select$(EXEEXT) test-sys_socket$(EXEEXT) \ + test-sys_stat$(EXEEXT) test-sys_time$(EXEEXT) \ + test-sys_types$(EXEEXT) test-sys_uio$(EXEEXT) \ + test-sys_utsname$(EXEEXT) test-sys_wait$(EXEEXT) \ + test-termios$(EXEEXT) test-init.sh test-thread_self$(EXEEXT) \ + test-thread_create$(EXEEXT) test-time$(EXEEXT) \ + test-timespec$(EXEEXT) test-tls$(EXEEXT) test-u64$(EXEEXT) \ + test-uname$(EXEEXT) test-dup-safer$(EXEEXT) \ + test-unistd$(EXEEXT) test-u8-mbtoucr$(EXEEXT) \ + test-u8-uctomb$(EXEEXT) test-uc_width$(EXEEXT) \ + uniwidth/test-uc_width2.sh test-unlink$(EXEEXT) \ + test-unlinkat$(EXEEXT) test-unsetenv$(EXEEXT) \ + test-update-copyright.sh test-userspec$(EXEEXT) \ + test-usleep$(EXEEXT) test-utime-h$(EXEEXT) test-utime$(EXEEXT) \ + test-utimens$(EXEEXT) test-utimensat$(EXEEXT) \ + test-vasnprintf$(EXEEXT) test-vasprintf-posix$(EXEEXT) \ + test-vasprintf$(EXEEXT) test-vc-list-files-git.sh \ + test-vc-list-files-cvs.sh test-verify$(EXEEXT) test-verify.sh \ + test-version-etc.sh test-vfprintf-posix.sh \ + test-vprintf-posix.sh test-wchar$(EXEEXT) test-wcrtomb.sh \ + test-wcrtomb-w32-1.sh test-wcrtomb-w32-2.sh \ + test-wcrtomb-w32-3.sh test-wcrtomb-w32-4.sh \ + test-wcrtomb-w32-5.sh test-wcrtomb-w32-6.sh \ + test-wcrtomb-w32-7.sh test-wctype-h$(EXEEXT) \ + test-wcwidth$(EXEEXT) test-write$(EXEEXT) test-xalloc-die.sh \ + test-xprintf-posix.sh test-xstrtoimax.sh test-xstrtol.sh \ + test-xstrtoumax.sh test-xvasprintf$(EXEEXT) test-yesno.sh +XFAIL_TESTS = +noinst_PROGRAMS = bench-md5$(EXEEXT) bench-sha1$(EXEEXT) \ + bench-sha224$(EXEEXT) bench-sha256$(EXEEXT) \ + bench-sha384$(EXEEXT) bench-sha512$(EXEEXT) \ + current-locale$(EXEEXT) test-localcharset$(EXEEXT) +check_PROGRAMS = test-accept$(EXEEXT) test-set-mode-acl$(EXEEXT) \ + test-copy-acl$(EXEEXT) test-sameacls$(EXEEXT) \ + test-alignof$(EXEEXT) test-alloca-opt$(EXEEXT) \ + test-areadlink$(EXEEXT) test-areadlink-with-size$(EXEEXT) \ + test-areadlinkat$(EXEEXT) test-argmatch$(EXEEXT) \ + test-argv-iter$(EXEEXT) test-arpa_inet$(EXEEXT) \ + test-base32$(EXEEXT) test-base64$(EXEEXT) \ + test-binary-io$(EXEEXT) test-bind$(EXEEXT) \ + test-bitrotate$(EXEEXT) test-btowc$(EXEEXT) \ + test-byteswap$(EXEEXT) test-c-ctype$(EXEEXT) \ + test-c-strcasecmp$(EXEEXT) test-c-strncasecmp$(EXEEXT) \ + test-calloc-gnu$(EXEEXT) test-canonicalize$(EXEEXT) \ + test-chdir$(EXEEXT) test-chown$(EXEEXT) test-cloexec$(EXEEXT) \ + test-close$(EXEEXT) test-closein$(EXEEXT) \ + test-connect$(EXEEXT) test-count-leading-zeros$(EXEEXT) \ + test-md5$(EXEEXT) test-sha1$(EXEEXT) test-sha256$(EXEEXT) \ + test-sha512$(EXEEXT) test-ctype$(EXEEXT) test-di-set$(EXEEXT) \ + test-dirent-safer$(EXEEXT) test-dirent$(EXEEXT) \ + test-dirname$(EXEEXT) test-dup$(EXEEXT) test-dup2$(EXEEXT) \ + test-environ$(EXEEXT) test-errno$(EXEEXT) \ + test-exclude$(EXEEXT) test-faccessat$(EXEEXT) \ + test-fadvise$(EXEEXT) test-fchdir$(EXEEXT) \ + test-fchmodat$(EXEEXT) test-fchownat$(EXEEXT) \ + test-fclose$(EXEEXT) test-fcntl-h$(EXEEXT) \ + test-fcntl-safer$(EXEEXT) test-fcntl$(EXEEXT) \ + test-fdatasync$(EXEEXT) test-fdopen$(EXEEXT) \ + test-fdopendir$(EXEEXT) test-fdutimensat$(EXEEXT) \ + test-fflush$(EXEEXT) test-fflush2$(EXEEXT) test-fgetc$(EXEEXT) \ + test-file-has-acl$(EXEEXT) test-filenamecat$(EXEEXT) \ + test-filevercmp$(EXEEXT) test-float$(EXEEXT) \ + test-fnmatch-h$(EXEEXT) test-fnmatch$(EXEEXT) \ + test-fopen-safer$(EXEEXT) test-fopen$(EXEEXT) \ + test-fpending$(EXEEXT) test-fpurge$(EXEEXT) \ + test-fputc$(EXEEXT) test-fread$(EXEEXT) \ + test-freadahead$(EXEEXT) test-freading$(EXEEXT) \ + test-freadptr$(EXEEXT) test-freadptr2$(EXEEXT) \ + test-freadseek$(EXEEXT) test-freopen-safer$(EXEEXT) \ + test-freopen$(EXEEXT) test-frexp-nolibm$(EXEEXT) \ + test-frexpl-nolibm$(EXEEXT) test-fseek$(EXEEXT) \ + test-fseeko$(EXEEXT) test-fseeko3$(EXEEXT) \ + test-fseeko4$(EXEEXT) test-fseterr$(EXEEXT) \ + test-fstat$(EXEEXT) test-fstatat$(EXEEXT) test-fsync$(EXEEXT) \ + test-ftell$(EXEEXT) test-ftell3$(EXEEXT) test-ftello$(EXEEXT) \ + test-ftello3$(EXEEXT) test-ftello4$(EXEEXT) \ + test-ftruncate$(EXEEXT) test-futimens$(EXEEXT) \ + test-fwrite$(EXEEXT) test-getaddrinfo$(EXEEXT) \ + test-getcwd-lgpl$(EXEEXT) test-getcwd$(EXEEXT) \ + test-getdelim$(EXEEXT) test-getdtablesize$(EXEEXT) \ + test-getgroups$(EXEEXT) test-gethostname$(EXEEXT) \ + test-getline$(EXEEXT) test-getloadavg$(EXEEXT) \ + test-getlogin$(EXEEXT) test-getndelim2$(EXEEXT) \ + test-getopt-gnu$(EXEEXT) test-getopt-posix$(EXEEXT) \ + test-getprogname$(EXEEXT) test-getrusage$(EXEEXT) \ + test-gettimeofday$(EXEEXT) test-hard-locale$(EXEEXT) \ + test-hash$(EXEEXT) test-i-ring$(EXEEXT) test-iconv-h$(EXEEXT) \ + test-iconv$(EXEEXT) test-ignore-value$(EXEEXT) \ + test-inet_ntop$(EXEEXT) test-inet_pton$(EXEEXT) \ + test-ino-map$(EXEEXT) test-intprops$(EXEEXT) \ + test-inttostr$(EXEEXT) test-inttypes$(EXEEXT) \ + test-ioctl$(EXEEXT) test-isatty$(EXEEXT) test-isblank$(EXEEXT) \ + test-isnand-nolibm$(EXEEXT) test-isnanf-nolibm$(EXEEXT) \ + test-isnanl-nolibm$(EXEEXT) test-iswblank$(EXEEXT) \ + test-iswdigit$(EXEEXT) test-iswxdigit$(EXEEXT) \ + test-langinfo$(EXEEXT) test-lchmod$(EXEEXT) \ + test-lchown$(EXEEXT) test-limits-h$(EXEEXT) test-link$(EXEEXT) \ + test-linkat$(EXEEXT) test-listen$(EXEEXT) test-locale$(EXEEXT) \ + test-localeconv$(EXEEXT) test-localename$(EXEEXT) \ + test-rwlock1$(EXEEXT) test-lock$(EXEEXT) test-once1$(EXEEXT) \ + test-once2$(EXEEXT) test-lseek$(EXEEXT) test-lstat$(EXEEXT) \ + test-malloc-gnu$(EXEEXT) test-malloca$(EXEEXT) \ + test-math$(EXEEXT) test-mbrtowc$(EXEEXT) \ + test-mbrtowc-w32$(EXEEXT) test-mbsalign$(EXEEXT) \ + test-mbscasecmp$(EXEEXT) test-mbschr$(EXEEXT) \ + test-mbsinit$(EXEEXT) test-mbsrtowcs$(EXEEXT) \ + test-mbsstr1$(EXEEXT) test-mbsstr2$(EXEEXT) \ + test-mbsstr3$(EXEEXT) test-memcasecmp$(EXEEXT) \ + test-memchr$(EXEEXT) test-memchr2$(EXEEXT) \ + test-memcoll$(EXEEXT) test-memrchr$(EXEEXT) \ + test-mkdir$(EXEEXT) test-mkfifo$(EXEEXT) test-mknod$(EXEEXT) \ + test-nanosleep$(EXEEXT) test-netdb$(EXEEXT) \ + test-netinet_in$(EXEEXT) test-nl_langinfo$(EXEEXT) \ + test-nl_langinfo-mt$(EXEEXT) test-nstrftime$(EXEEXT) \ + test-open$(EXEEXT) test-openat-safer$(EXEEXT) \ + test-openat$(EXEEXT) test-parse-datetime$(EXEEXT) \ + test-pathmax$(EXEEXT) test-perror$(EXEEXT) \ + test-perror2$(EXEEXT) test-pipe$(EXEEXT) test-pipe2$(EXEEXT) \ + test-posixtm$(EXEEXT) test-printf-frexp$(EXEEXT) \ + test-printf-frexpl$(EXEEXT) test-priv-set$(EXEEXT) \ + test-pthread-cond$(EXEEXT) test-pthread$(EXEEXT) \ + test-pthread-mutex$(EXEEXT) test-pthread-thread$(EXEEXT) \ + test-pthread_sigmask1$(EXEEXT) test-pthread_sigmask2$(EXEEXT) \ + test-quotearg-simple$(EXEEXT) test-raise$(EXEEXT) \ + test-rand-isaac$(EXEEXT) test-read-file$(EXEEXT) \ + test-read$(EXEEXT) test-readlink$(EXEEXT) \ + test-readlinkat$(EXEEXT) test-readtokens$(EXEEXT) \ + test-realloc-gnu$(EXEEXT) test-regex$(EXEEXT) \ + test-remove$(EXEEXT) test-rename$(EXEEXT) \ + test-renameat$(EXEEXT) test-renameatu$(EXEEXT) \ + test-rmdir$(EXEEXT) test-sched$(EXEEXT) test-select$(EXEEXT) \ + test-select-fd$(EXEEXT) test-select-stdin$(EXEEXT) \ + test-setenv$(EXEEXT) test-setlocale_null$(EXEEXT) \ + test-setlocale_null-mt-one$(EXEEXT) \ + test-setlocale_null-mt-all$(EXEEXT) test-setlocale1$(EXEEXT) \ + test-setlocale2$(EXEEXT) test-setsockopt$(EXEEXT) \ + test-sigaction$(EXEEXT) test-signal-h$(EXEEXT) \ + test-signbit$(EXEEXT) test-sigprocmask$(EXEEXT) \ + test-sleep$(EXEEXT) test-snprintf$(EXEEXT) \ + test-sockets$(EXEEXT) test-stat$(EXEEXT) \ + test-stat-time$(EXEEXT) test-statat$(EXEEXT) \ + test-stdalign$(EXEEXT) test-stdbool$(EXEEXT) \ + test-stddef$(EXEEXT) test-stdint$(EXEEXT) test-stdio$(EXEEXT) \ + test-stdlib$(EXEEXT) test-strerror$(EXEEXT) \ + test-strerror_r$(EXEEXT) test-striconv$(EXEEXT) \ + test-string$(EXEEXT) test-strncat$(EXEEXT) \ + test-strnlen$(EXEEXT) test-strsignal$(EXEEXT) \ + test-strtod$(EXEEXT) test-strtod1$(EXEEXT) \ + test-strtoimax$(EXEEXT) test-strtold$(EXEEXT) \ + test-strtold1$(EXEEXT) test-strtoll$(EXEEXT) \ + test-strtoull$(EXEEXT) test-strtoumax$(EXEEXT) \ + test-symlink$(EXEEXT) test-symlinkat$(EXEEXT) \ + test-sys_ioctl$(EXEEXT) test-sys_resource$(EXEEXT) \ + test-sys_select$(EXEEXT) test-sys_socket$(EXEEXT) \ + test-sys_stat$(EXEEXT) test-sys_time$(EXEEXT) \ + test-sys_types$(EXEEXT) test-sys_uio$(EXEEXT) \ + test-sys_utsname$(EXEEXT) test-sys_wait$(EXEEXT) \ + test-termios$(EXEEXT) test-thread_self$(EXEEXT) \ + test-thread_create$(EXEEXT) test-time$(EXEEXT) \ + test-timespec$(EXEEXT) test-tls$(EXEEXT) test-u64$(EXEEXT) \ + test-uname$(EXEEXT) test-dup-safer$(EXEEXT) \ + test-unistd$(EXEEXT) test-u8-mbtoucr$(EXEEXT) \ + test-u8-uctomb$(EXEEXT) test-uc_width$(EXEEXT) \ + test-uc_width2$(EXEEXT) test-unlink$(EXEEXT) \ + test-unlinkat$(EXEEXT) test-unsetenv$(EXEEXT) \ + test-userspec$(EXEEXT) test-usleep$(EXEEXT) \ + test-utime-h$(EXEEXT) test-utime$(EXEEXT) \ + test-utimens$(EXEEXT) test-utimensat$(EXEEXT) \ + test-vasnprintf$(EXEEXT) test-vasprintf-posix$(EXEEXT) \ + test-vasprintf$(EXEEXT) test-verify$(EXEEXT) \ + test-version-etc$(EXEEXT) test-vfprintf-posix$(EXEEXT) \ + test-vprintf-posix$(EXEEXT) test-wchar$(EXEEXT) \ + test-wcrtomb$(EXEEXT) test-wcrtomb-w32$(EXEEXT) \ + test-wctype-h$(EXEEXT) test-wcwidth$(EXEEXT) \ + test-write$(EXEEXT) test-xalloc-die$(EXEEXT) \ + test-xfprintf-posix$(EXEEXT) test-xprintf-posix$(EXEEXT) \ + test-xstrtoimax$(EXEEXT) test-xstrtol$(EXEEXT) \ + test-xstrtoul$(EXEEXT) test-xstrtoumax$(EXEEXT) \ + test-xvasprintf$(EXEEXT) test-yesno$(EXEEXT) +EXTRA_PROGRAMS = test-verify-try$(EXEEXT) +subdir = gnulib-tests +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ + $(top_srcdir)/m4/__inline.m4 \ + $(top_srcdir)/m4/absolute-header.m4 $(top_srcdir)/m4/acl.m4 \ + $(top_srcdir)/m4/af_alg.m4 $(top_srcdir)/m4/alloca.m4 \ + $(top_srcdir)/m4/arpa_inet_h.m4 $(top_srcdir)/m4/assert.m4 \ + $(top_srcdir)/m4/autobuild.m4 $(top_srcdir)/m4/backupfile.m4 \ + $(top_srcdir)/m4/base32.m4 $(top_srcdir)/m4/base64.m4 \ + $(top_srcdir)/m4/bison.m4 $(top_srcdir)/m4/boottime.m4 \ + $(top_srcdir)/m4/btowc.m4 $(top_srcdir)/m4/builtin-expect.m4 \ + $(top_srcdir)/m4/byteswap.m4 $(top_srcdir)/m4/c-strtod.m4 \ + $(top_srcdir)/m4/calloc.m4 $(top_srcdir)/m4/canon-host.m4 \ + $(top_srcdir)/m4/canonicalize.m4 \ + $(top_srcdir)/m4/chdir-long.m4 $(top_srcdir)/m4/check-decl.m4 \ + $(top_srcdir)/m4/chown.m4 $(top_srcdir)/m4/clock_time.m4 \ + $(top_srcdir)/m4/close.m4 $(top_srcdir)/m4/closedir.m4 \ + $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/config-h.m4 \ + $(top_srcdir)/m4/configmake.m4 $(top_srcdir)/m4/ctype.m4 \ + $(top_srcdir)/m4/cycle-check.m4 $(top_srcdir)/m4/d-ino.m4 \ + $(top_srcdir)/m4/d-type.m4 $(top_srcdir)/m4/dirent-safer.m4 \ + $(top_srcdir)/m4/dirent_h.m4 $(top_srcdir)/m4/dirfd.m4 \ + $(top_srcdir)/m4/dirname.m4 \ + $(top_srcdir)/m4/double-slash-root.m4 $(top_srcdir)/m4/dup.m4 \ + $(top_srcdir)/m4/dup2.m4 $(top_srcdir)/m4/eealloc.m4 \ + $(top_srcdir)/m4/environ.m4 $(top_srcdir)/m4/errno_h.m4 \ + $(top_srcdir)/m4/error.m4 $(top_srcdir)/m4/euidaccess.m4 \ + $(top_srcdir)/m4/explicit_bzero.m4 \ + $(top_srcdir)/m4/exponentd.m4 $(top_srcdir)/m4/exponentf.m4 \ + $(top_srcdir)/m4/exponentl.m4 $(top_srcdir)/m4/extensions.m4 \ + $(top_srcdir)/m4/extern-inline.m4 \ + $(top_srcdir)/m4/faccessat.m4 $(top_srcdir)/m4/fchdir.m4 \ + $(top_srcdir)/m4/fchmodat.m4 $(top_srcdir)/m4/fchownat.m4 \ + $(top_srcdir)/m4/fclose.m4 $(top_srcdir)/m4/fcntl-o.m4 \ + $(top_srcdir)/m4/fcntl-safer.m4 $(top_srcdir)/m4/fcntl.m4 \ + $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/fdatasync.m4 \ + $(top_srcdir)/m4/fdopen.m4 $(top_srcdir)/m4/fdopendir.m4 \ + $(top_srcdir)/m4/fflush.m4 $(top_srcdir)/m4/fileblocks.m4 \ + $(top_srcdir)/m4/filemode.m4 $(top_srcdir)/m4/filenamecat.m4 \ + $(top_srcdir)/m4/flexmember.m4 $(top_srcdir)/m4/float_h.m4 \ + $(top_srcdir)/m4/fnmatch.m4 $(top_srcdir)/m4/fnmatch_h.m4 \ + $(top_srcdir)/m4/fopen.m4 $(top_srcdir)/m4/fpending.m4 \ + $(top_srcdir)/m4/fpieee.m4 $(top_srcdir)/m4/fpurge.m4 \ + $(top_srcdir)/m4/freadahead.m4 $(top_srcdir)/m4/freading.m4 \ + $(top_srcdir)/m4/freadptr.m4 $(top_srcdir)/m4/freadseek.m4 \ + $(top_srcdir)/m4/freopen.m4 $(top_srcdir)/m4/frexp.m4 \ + $(top_srcdir)/m4/frexpl.m4 $(top_srcdir)/m4/fseek.m4 \ + $(top_srcdir)/m4/fseeko.m4 $(top_srcdir)/m4/fseterr.m4 \ + $(top_srcdir)/m4/fstat.m4 $(top_srcdir)/m4/fstatat.m4 \ + $(top_srcdir)/m4/fstypename.m4 $(top_srcdir)/m4/fsusage.m4 \ + $(top_srcdir)/m4/fsync.m4 $(top_srcdir)/m4/ftell.m4 \ + $(top_srcdir)/m4/ftello.m4 $(top_srcdir)/m4/ftruncate.m4 \ + $(top_srcdir)/m4/fts.m4 $(top_srcdir)/m4/futimens.m4 \ + $(top_srcdir)/m4/getaddrinfo.m4 \ + $(top_srcdir)/m4/getcwd-abort-bug.m4 \ + $(top_srcdir)/m4/getcwd-path-max.m4 $(top_srcdir)/m4/getcwd.m4 \ + $(top_srcdir)/m4/getdelim.m4 $(top_srcdir)/m4/getdtablesize.m4 \ + $(top_srcdir)/m4/getgroups.m4 $(top_srcdir)/m4/gethostname.m4 \ + $(top_srcdir)/m4/gethrxtime.m4 $(top_srcdir)/m4/getline.m4 \ + $(top_srcdir)/m4/getloadavg.m4 $(top_srcdir)/m4/getlogin.m4 \ + $(top_srcdir)/m4/getndelim2.m4 $(top_srcdir)/m4/getopt.m4 \ + $(top_srcdir)/m4/getpagesize.m4 $(top_srcdir)/m4/getpass.m4 \ + $(top_srcdir)/m4/getprogname.m4 $(top_srcdir)/m4/getrusage.m4 \ + $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/gettime.m4 \ + $(top_srcdir)/m4/gettimeofday.m4 \ + $(top_srcdir)/m4/getugroups.m4 \ + $(top_srcdir)/m4/getusershell.m4 \ + $(top_srcdir)/m4/gl-openssl.m4 $(top_srcdir)/m4/glibc21.m4 \ + $(top_srcdir)/m4/gmp.m4 $(top_srcdir)/m4/gnu-make.m4 \ + $(top_srcdir)/m4/gnulib-common.m4 \ + $(top_srcdir)/m4/gnulib-comp.m4 \ + $(top_srcdir)/m4/group-member.m4 \ + $(top_srcdir)/m4/host-cpu-c-abi.m4 $(top_srcdir)/m4/host-os.m4 \ + $(top_srcdir)/m4/hostent.m4 $(top_srcdir)/m4/human.m4 \ + $(top_srcdir)/m4/i-ring.m4 $(top_srcdir)/m4/iconv.m4 \ + $(top_srcdir)/m4/iconv_h.m4 $(top_srcdir)/m4/iconv_open.m4 \ + $(top_srcdir)/m4/idcache.m4 \ + $(top_srcdir)/m4/include-exclude-prog.m4 \ + $(top_srcdir)/m4/include_next.m4 $(top_srcdir)/m4/inet_ntop.m4 \ + $(top_srcdir)/m4/inet_pton.m4 $(top_srcdir)/m4/inline.m4 \ + $(top_srcdir)/m4/intl-thread-locale.m4 \ + $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intmax_t.m4 \ + $(top_srcdir)/m4/inttostr.m4 $(top_srcdir)/m4/inttypes-pri.m4 \ + $(top_srcdir)/m4/inttypes.m4 $(top_srcdir)/m4/inttypes_h.m4 \ + $(top_srcdir)/m4/ioctl.m4 $(top_srcdir)/m4/isapipe.m4 \ + $(top_srcdir)/m4/isatty.m4 $(top_srcdir)/m4/isblank.m4 \ + $(top_srcdir)/m4/isnand.m4 $(top_srcdir)/m4/isnanf.m4 \ + $(top_srcdir)/m4/isnanl.m4 $(top_srcdir)/m4/iswblank.m4 \ + $(top_srcdir)/m4/iswdigit.m4 $(top_srcdir)/m4/iswxdigit.m4 \ + $(top_srcdir)/m4/jm-macros.m4 $(top_srcdir)/m4/jm-winsz1.m4 \ + $(top_srcdir)/m4/jm-winsz2.m4 $(top_srcdir)/m4/langinfo_h.m4 \ + $(top_srcdir)/m4/largefile.m4 $(top_srcdir)/m4/lchmod.m4 \ + $(top_srcdir)/m4/lchown.m4 $(top_srcdir)/m4/lcmessage.m4 \ + $(top_srcdir)/m4/ldexp.m4 $(top_srcdir)/m4/ldexpl.m4 \ + $(top_srcdir)/m4/lib-ignore.m4 $(top_srcdir)/m4/lib-ld.m4 \ + $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ + $(top_srcdir)/m4/libunistring-base.m4 \ + $(top_srcdir)/m4/limits-h.m4 $(top_srcdir)/m4/link-follow.m4 \ + $(top_srcdir)/m4/link.m4 $(top_srcdir)/m4/linkat.m4 \ + $(top_srcdir)/m4/localcharset.m4 $(top_srcdir)/m4/locale-fr.m4 \ + $(top_srcdir)/m4/locale-ja.m4 $(top_srcdir)/m4/locale-tr.m4 \ + $(top_srcdir)/m4/locale-zh.m4 $(top_srcdir)/m4/locale_h.m4 \ + $(top_srcdir)/m4/localeconv.m4 $(top_srcdir)/m4/localename.m4 \ + $(top_srcdir)/m4/localtime-buffer.m4 $(top_srcdir)/m4/lock.m4 \ + $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/lseek.m4 \ + $(top_srcdir)/m4/lstat.m4 $(top_srcdir)/m4/malloc.m4 \ + $(top_srcdir)/m4/malloca.m4 $(top_srcdir)/m4/manywarnings.m4 \ + $(top_srcdir)/m4/math_h.m4 $(top_srcdir)/m4/mbchar.m4 \ + $(top_srcdir)/m4/mbiter.m4 $(top_srcdir)/m4/mbrlen.m4 \ + $(top_srcdir)/m4/mbrtowc.m4 $(top_srcdir)/m4/mbsinit.m4 \ + $(top_srcdir)/m4/mbslen.m4 $(top_srcdir)/m4/mbsrtowcs.m4 \ + $(top_srcdir)/m4/mbstate_t.m4 $(top_srcdir)/m4/mbswidth.m4 \ + $(top_srcdir)/m4/mbtowc.m4 $(top_srcdir)/m4/md5.m4 \ + $(top_srcdir)/m4/memcasecmp.m4 $(top_srcdir)/m4/memchr.m4 \ + $(top_srcdir)/m4/memcoll.m4 $(top_srcdir)/m4/mempcpy.m4 \ + $(top_srcdir)/m4/memrchr.m4 $(top_srcdir)/m4/mgetgroups.m4 \ + $(top_srcdir)/m4/minmax.m4 $(top_srcdir)/m4/mkancesdirs.m4 \ + $(top_srcdir)/m4/mkdir-p.m4 $(top_srcdir)/m4/mkdir.m4 \ + $(top_srcdir)/m4/mkfifo.m4 $(top_srcdir)/m4/mknod.m4 \ + $(top_srcdir)/m4/mkostemp.m4 $(top_srcdir)/m4/mkstemp.m4 \ + $(top_srcdir)/m4/mktime.m4 $(top_srcdir)/m4/mmap-anon.m4 \ + $(top_srcdir)/m4/mode_t.m4 $(top_srcdir)/m4/modechange.m4 \ + $(top_srcdir)/m4/mountlist.m4 $(top_srcdir)/m4/mpsort.m4 \ + $(top_srcdir)/m4/msvc-inval.m4 \ + $(top_srcdir)/m4/msvc-nothrow.m4 $(top_srcdir)/m4/multiarch.m4 \ + $(top_srcdir)/m4/musl.m4 $(top_srcdir)/m4/nanosleep.m4 \ + $(top_srcdir)/m4/netdb_h.m4 $(top_srcdir)/m4/netinet_in_h.m4 \ + $(top_srcdir)/m4/nl_langinfo.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/nocrash.m4 \ + $(top_srcdir)/m4/non-recursive-gnulib-prefix-hack.m4 \ + $(top_srcdir)/m4/nproc.m4 $(top_srcdir)/m4/nstrftime.m4 \ + $(top_srcdir)/m4/obstack.m4 $(top_srcdir)/m4/off_t.m4 \ + $(top_srcdir)/m4/open-cloexec.m4 \ + $(top_srcdir)/m4/open-slash.m4 $(top_srcdir)/m4/open.m4 \ + $(top_srcdir)/m4/openat.m4 $(top_srcdir)/m4/opendir.m4 \ + $(top_srcdir)/m4/parse-datetime.m4 $(top_srcdir)/m4/pathmax.m4 \ + $(top_srcdir)/m4/perl.m4 $(top_srcdir)/m4/perror.m4 \ + $(top_srcdir)/m4/physmem.m4 $(top_srcdir)/m4/pipe.m4 \ + $(top_srcdir)/m4/pipe2.m4 $(top_srcdir)/m4/po.m4 \ + $(top_srcdir)/m4/posix-shell.m4 $(top_srcdir)/m4/posixtm.m4 \ + $(top_srcdir)/m4/posixver.m4 $(top_srcdir)/m4/prereq.m4 \ + $(top_srcdir)/m4/printf-frexp.m4 \ + $(top_srcdir)/m4/printf-frexpl.m4 $(top_srcdir)/m4/printf.m4 \ + $(top_srcdir)/m4/priv-set.m4 $(top_srcdir)/m4/progtest.m4 \ + $(top_srcdir)/m4/pthread-cond.m4 \ + $(top_srcdir)/m4/pthread-mutex.m4 \ + $(top_srcdir)/m4/pthread-thread.m4 \ + $(top_srcdir)/m4/pthread_h.m4 \ + $(top_srcdir)/m4/pthread_mutex_timedlock.m4 \ + $(top_srcdir)/m4/pthread_rwlock_rdlock.m4 \ + $(top_srcdir)/m4/pthread_sigmask.m4 $(top_srcdir)/m4/putenv.m4 \ + $(top_srcdir)/m4/quote.m4 $(top_srcdir)/m4/quotearg.m4 \ + $(top_srcdir)/m4/raise.m4 $(top_srcdir)/m4/read-file.m4 \ + $(top_srcdir)/m4/read.m4 $(top_srcdir)/m4/readdir.m4 \ + $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/readlinkat.m4 \ + $(top_srcdir)/m4/readtokens.m4 $(top_srcdir)/m4/readutmp.m4 \ + $(top_srcdir)/m4/realloc.m4 $(top_srcdir)/m4/regex.m4 \ + $(top_srcdir)/m4/remove.m4 $(top_srcdir)/m4/rename.m4 \ + $(top_srcdir)/m4/renameat.m4 $(top_srcdir)/m4/rewinddir.m4 \ + $(top_srcdir)/m4/rmdir.m4 $(top_srcdir)/m4/rpmatch.m4 \ + $(top_srcdir)/m4/safe-read.m4 $(top_srcdir)/m4/safe-write.m4 \ + $(top_srcdir)/m4/same.m4 $(top_srcdir)/m4/save-cwd.m4 \ + $(top_srcdir)/m4/savedir.m4 $(top_srcdir)/m4/savewd.m4 \ + $(top_srcdir)/m4/sched_h.m4 $(top_srcdir)/m4/sched_yield.m4 \ + $(top_srcdir)/m4/secure_getenv.m4 $(top_srcdir)/m4/select.m4 \ + $(top_srcdir)/m4/selinux-context-h.m4 \ + $(top_srcdir)/m4/selinux-selinux-h.m4 \ + $(top_srcdir)/m4/semaphore.m4 $(top_srcdir)/m4/servent.m4 \ + $(top_srcdir)/m4/setenv.m4 $(top_srcdir)/m4/setlocale.m4 \ + $(top_srcdir)/m4/setlocale_null.m4 $(top_srcdir)/m4/settime.m4 \ + $(top_srcdir)/m4/sha1.m4 $(top_srcdir)/m4/sha256.m4 \ + $(top_srcdir)/m4/sha512.m4 $(top_srcdir)/m4/sig2str.m4 \ + $(top_srcdir)/m4/sigaction.m4 $(top_srcdir)/m4/signal_h.m4 \ + $(top_srcdir)/m4/signalblocking.m4 $(top_srcdir)/m4/signbit.m4 \ + $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/sleep.m4 \ + $(top_srcdir)/m4/snprintf.m4 $(top_srcdir)/m4/socketlib.m4 \ + $(top_srcdir)/m4/sockets.m4 $(top_srcdir)/m4/socklen.m4 \ + $(top_srcdir)/m4/sockpfaf.m4 $(top_srcdir)/m4/ssize_t.m4 \ + $(top_srcdir)/m4/st_dm_mode.m4 $(top_srcdir)/m4/stat-prog.m4 \ + $(top_srcdir)/m4/stat-size.m4 $(top_srcdir)/m4/stat-time.m4 \ + $(top_srcdir)/m4/stat.m4 $(top_srcdir)/m4/std-gnu11.m4 \ + $(top_srcdir)/m4/stdalign.m4 $(top_srcdir)/m4/stdarg.m4 \ + $(top_srcdir)/m4/stdbool.m4 $(top_srcdir)/m4/stddef_h.m4 \ + $(top_srcdir)/m4/stdint.m4 $(top_srcdir)/m4/stdint_h.m4 \ + $(top_srcdir)/m4/stdio_h.m4 $(top_srcdir)/m4/stdlib_h.m4 \ + $(top_srcdir)/m4/stpcpy.m4 $(top_srcdir)/m4/stpncpy.m4 \ + $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \ + $(top_srcdir)/m4/strerror_r.m4 $(top_srcdir)/m4/string_h.m4 \ + $(top_srcdir)/m4/strncat.m4 $(top_srcdir)/m4/strndup.m4 \ + $(top_srcdir)/m4/strnlen.m4 $(top_srcdir)/m4/strsignal.m4 \ + $(top_srcdir)/m4/strstr.m4 $(top_srcdir)/m4/strtod.m4 \ + $(top_srcdir)/m4/strtoimax.m4 $(top_srcdir)/m4/strtold.m4 \ + $(top_srcdir)/m4/strtoll.m4 $(top_srcdir)/m4/strtoull.m4 \ + $(top_srcdir)/m4/strtoumax.m4 $(top_srcdir)/m4/symlink.m4 \ + $(top_srcdir)/m4/symlinkat.m4 $(top_srcdir)/m4/sys_ioctl_h.m4 \ + $(top_srcdir)/m4/sys_resource_h.m4 \ + $(top_srcdir)/m4/sys_select_h.m4 \ + $(top_srcdir)/m4/sys_socket_h.m4 \ + $(top_srcdir)/m4/sys_stat_h.m4 $(top_srcdir)/m4/sys_time_h.m4 \ + $(top_srcdir)/m4/sys_types_h.m4 $(top_srcdir)/m4/sys_uio_h.m4 \ + $(top_srcdir)/m4/sys_utsname_h.m4 \ + $(top_srcdir)/m4/sys_wait_h.m4 $(top_srcdir)/m4/tempname.m4 \ + $(top_srcdir)/m4/termios_h.m4 $(top_srcdir)/m4/thread.m4 \ + $(top_srcdir)/m4/threadlib.m4 $(top_srcdir)/m4/time_h.m4 \ + $(top_srcdir)/m4/time_r.m4 $(top_srcdir)/m4/time_rz.m4 \ + $(top_srcdir)/m4/timegm.m4 $(top_srcdir)/m4/timer_time.m4 \ + $(top_srcdir)/m4/timespec.m4 $(top_srcdir)/m4/tls.m4 \ + $(top_srcdir)/m4/tm_gmtoff.m4 $(top_srcdir)/m4/tmpdir.m4 \ + $(top_srcdir)/m4/tmpfile.m4 $(top_srcdir)/m4/tzset.m4 \ + $(top_srcdir)/m4/uname.m4 $(top_srcdir)/m4/ungetc.m4 \ + $(top_srcdir)/m4/unicodeio.m4 $(top_srcdir)/m4/unistd-safer.m4 \ + $(top_srcdir)/m4/unistd_h.m4 $(top_srcdir)/m4/unlink-busy.m4 \ + $(top_srcdir)/m4/unlink.m4 $(top_srcdir)/m4/unlinkat.m4 \ + $(top_srcdir)/m4/unlinkdir.m4 $(top_srcdir)/m4/unlocked-io.m4 \ + $(top_srcdir)/m4/uptime.m4 $(top_srcdir)/m4/userspec.m4 \ + $(top_srcdir)/m4/usleep.m4 $(top_srcdir)/m4/utime.m4 \ + $(top_srcdir)/m4/utime_h.m4 $(top_srcdir)/m4/utimecmp.m4 \ + $(top_srcdir)/m4/utimens.m4 $(top_srcdir)/m4/utimensat.m4 \ + $(top_srcdir)/m4/utimes.m4 $(top_srcdir)/m4/vasnprintf.m4 \ + $(top_srcdir)/m4/vasprintf-posix.m4 \ + $(top_srcdir)/m4/vasprintf.m4 $(top_srcdir)/m4/version-etc.m4 \ + $(top_srcdir)/m4/vfprintf-posix.m4 \ + $(top_srcdir)/m4/visibility.m4 \ + $(top_srcdir)/m4/vprintf-posix.m4 $(top_srcdir)/m4/warnings.m4 \ + $(top_srcdir)/m4/wchar_h.m4 $(top_srcdir)/m4/wchar_t.m4 \ + $(top_srcdir)/m4/wcrtomb.m4 $(top_srcdir)/m4/wcswidth.m4 \ + $(top_srcdir)/m4/wctob.m4 $(top_srcdir)/m4/wctomb.m4 \ + $(top_srcdir)/m4/wctype_h.m4 $(top_srcdir)/m4/wcwidth.m4 \ + $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/write-any-file.m4 \ + $(top_srcdir)/m4/write.m4 $(top_srcdir)/m4/xalloc.m4 \ + $(top_srcdir)/m4/xattr.m4 $(top_srcdir)/m4/xgetcwd.m4 \ + $(top_srcdir)/m4/xnanosleep.m4 $(top_srcdir)/m4/xsize.m4 \ + $(top_srcdir)/m4/xstrndup.m4 $(top_srcdir)/m4/xstrtod.m4 \ + $(top_srcdir)/m4/xstrtol.m4 $(top_srcdir)/m4/xvasprintf.m4 \ + $(top_srcdir)/m4/year2038.m4 $(top_srcdir)/m4/yesno.m4 \ + $(top_srcdir)/m4/yield.m4 $(top_srcdir)/m4/zzgnulib.m4 \ + $(top_srcdir)/m4/cu-progs.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \ + $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/lib/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkglibexecdir)" \ + "$(DESTDIR)$(man1dir)" +PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) $(pkglibexec_PROGRAMS) +LIBRARIES = $(noinst_LIBRARIES) +AM_V_AR = $(am__v_AR_@AM_V@) +am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@) +am__v_AR_0 = @echo " AR " $@; +am__v_AR_1 = +libtests_a_AR = $(AR) $(ARFLAGS) +am__DEPENDENCIES_1 = +am__dirstamp = $(am__leading_dot)dirstamp +am_libtests_a_OBJECTS = localename.$(OBJEXT) \ + localename-table.$(OBJEXT) glthread/thread.$(OBJEXT) \ + timespec-add.$(OBJEXT) timespec-sub.$(OBJEXT) tmpdir.$(OBJEXT) +libtests_a_OBJECTS = $(am_libtests_a_OBJECTS) +bench_md5_SOURCES = bench-md5.c +bench_md5_OBJECTS = bench-md5.$(OBJEXT) +am__DEPENDENCIES_2 = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +bench_md5_DEPENDENCIES = $(am__DEPENDENCIES_2) +bench_sha1_SOURCES = bench-sha1.c +bench_sha1_OBJECTS = bench-sha1.$(OBJEXT) +bench_sha1_DEPENDENCIES = $(am__DEPENDENCIES_2) +bench_sha224_SOURCES = bench-sha224.c +bench_sha224_OBJECTS = bench-sha224.$(OBJEXT) +bench_sha224_DEPENDENCIES = $(am__DEPENDENCIES_2) +bench_sha256_SOURCES = bench-sha256.c +bench_sha256_OBJECTS = bench-sha256.$(OBJEXT) +bench_sha256_DEPENDENCIES = $(am__DEPENDENCIES_2) +bench_sha384_SOURCES = bench-sha384.c +bench_sha384_OBJECTS = bench-sha384.$(OBJEXT) +bench_sha384_DEPENDENCIES = $(am__DEPENDENCIES_2) +bench_sha512_SOURCES = bench-sha512.c +bench_sha512_OBJECTS = bench-sha512.$(OBJEXT) +bench_sha512_DEPENDENCIES = $(am__DEPENDENCIES_2) +am_current_locale_OBJECTS = locale.$(OBJEXT) +current_locale_OBJECTS = $(am_current_locale_OBJECTS) +current_locale_LDADD = $(LDADD) +current_locale_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_accept_SOURCES = test-accept.c +test_accept_OBJECTS = test-accept.$(OBJEXT) +test_accept_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_alignof_SOURCES = test-alignof.c +test_alignof_OBJECTS = test-alignof.$(OBJEXT) +test_alignof_LDADD = $(LDADD) +test_alignof_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_alloca_opt_SOURCES = test-alloca-opt.c +test_alloca_opt_OBJECTS = test-alloca-opt.$(OBJEXT) +test_alloca_opt_LDADD = $(LDADD) +test_alloca_opt_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_areadlink_SOURCES = test-areadlink.c +test_areadlink_OBJECTS = test-areadlink.$(OBJEXT) +test_areadlink_LDADD = $(LDADD) +test_areadlink_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_areadlink_with_size_SOURCES = test-areadlink-with-size.c +test_areadlink_with_size_OBJECTS = test-areadlink-with-size.$(OBJEXT) +test_areadlink_with_size_LDADD = $(LDADD) +test_areadlink_with_size_DEPENDENCIES = libtests.a \ + ../lib/libcoreutils.a libtests.a $(am__DEPENDENCIES_1) +test_areadlinkat_SOURCES = test-areadlinkat.c +test_areadlinkat_OBJECTS = test-areadlinkat.$(OBJEXT) +test_areadlinkat_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_argmatch_SOURCES = test-argmatch.c +test_argmatch_OBJECTS = test-argmatch.$(OBJEXT) +test_argmatch_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_argv_iter_SOURCES = test-argv-iter.c +test_argv_iter_OBJECTS = test-argv-iter.$(OBJEXT) +test_argv_iter_LDADD = $(LDADD) +test_argv_iter_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_arpa_inet_SOURCES = test-arpa_inet.c +test_arpa_inet_OBJECTS = test-arpa_inet.$(OBJEXT) +test_arpa_inet_LDADD = $(LDADD) +test_arpa_inet_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_base32_SOURCES = test-base32.c +test_base32_OBJECTS = test-base32.$(OBJEXT) +test_base32_LDADD = $(LDADD) +test_base32_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_base64_SOURCES = test-base64.c +test_base64_OBJECTS = test-base64.$(OBJEXT) +test_base64_LDADD = $(LDADD) +test_base64_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_binary_io_SOURCES = test-binary-io.c +test_binary_io_OBJECTS = test-binary-io.$(OBJEXT) +test_binary_io_LDADD = $(LDADD) +test_binary_io_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_bind_SOURCES = test-bind.c +test_bind_OBJECTS = test-bind.$(OBJEXT) +test_bind_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) +test_bitrotate_SOURCES = test-bitrotate.c +test_bitrotate_OBJECTS = test-bitrotate.$(OBJEXT) +test_bitrotate_LDADD = $(LDADD) +test_bitrotate_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_btowc_SOURCES = test-btowc.c +test_btowc_OBJECTS = test-btowc.$(OBJEXT) +test_btowc_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) +test_byteswap_SOURCES = test-byteswap.c +test_byteswap_OBJECTS = test-byteswap.$(OBJEXT) +test_byteswap_LDADD = $(LDADD) +test_byteswap_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_c_ctype_SOURCES = test-c-ctype.c +test_c_ctype_OBJECTS = test-c-ctype.$(OBJEXT) +test_c_ctype_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_c_strcasecmp_SOURCES = test-c-strcasecmp.c +test_c_strcasecmp_OBJECTS = test-c-strcasecmp.$(OBJEXT) +test_c_strcasecmp_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_c_strncasecmp_SOURCES = test-c-strncasecmp.c +test_c_strncasecmp_OBJECTS = test-c-strncasecmp.$(OBJEXT) +test_c_strncasecmp_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_calloc_gnu_SOURCES = test-calloc-gnu.c +test_calloc_gnu_OBJECTS = test-calloc-gnu.$(OBJEXT) +test_calloc_gnu_LDADD = $(LDADD) +test_calloc_gnu_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_canonicalize_SOURCES = test-canonicalize.c +test_canonicalize_OBJECTS = test-canonicalize.$(OBJEXT) +test_canonicalize_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_chdir_SOURCES = test-chdir.c +test_chdir_OBJECTS = test-chdir.$(OBJEXT) +test_chdir_LDADD = $(LDADD) +test_chdir_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_chown_SOURCES = test-chown.c +test_chown_OBJECTS = test-chown.$(OBJEXT) +test_chown_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) +test_cloexec_SOURCES = test-cloexec.c +test_cloexec_OBJECTS = test-cloexec.$(OBJEXT) +test_cloexec_LDADD = $(LDADD) +test_cloexec_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_close_SOURCES = test-close.c +test_close_OBJECTS = test-close.$(OBJEXT) +test_close_LDADD = $(LDADD) +test_close_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_closein_SOURCES = test-closein.c +test_closein_OBJECTS = test-closein.$(OBJEXT) +test_closein_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_connect_SOURCES = test-connect.c +test_connect_OBJECTS = test-connect.$(OBJEXT) +test_connect_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_copy_acl_SOURCES = test-copy-acl.c +test_copy_acl_OBJECTS = test-copy-acl.$(OBJEXT) +test_copy_acl_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +test_count_leading_zeros_SOURCES = test-count-leading-zeros.c +test_count_leading_zeros_OBJECTS = test-count-leading-zeros.$(OBJEXT) +test_count_leading_zeros_LDADD = $(LDADD) +test_count_leading_zeros_DEPENDENCIES = libtests.a \ + ../lib/libcoreutils.a libtests.a $(am__DEPENDENCIES_1) +test_ctype_SOURCES = test-ctype.c +test_ctype_OBJECTS = test-ctype.$(OBJEXT) +test_ctype_LDADD = $(LDADD) +test_ctype_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_di_set_SOURCES = test-di-set.c +test_di_set_OBJECTS = test-di-set.$(OBJEXT) +test_di_set_LDADD = $(LDADD) +test_di_set_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_dirent_SOURCES = test-dirent.c +test_dirent_OBJECTS = test-dirent.$(OBJEXT) +test_dirent_LDADD = $(LDADD) +test_dirent_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_dirent_safer_SOURCES = test-dirent-safer.c +test_dirent_safer_OBJECTS = test-dirent-safer.$(OBJEXT) +test_dirent_safer_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_dirname_SOURCES = test-dirname.c +test_dirname_OBJECTS = test-dirname.$(OBJEXT) +test_dirname_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_dup_SOURCES = test-dup.c +test_dup_OBJECTS = test-dup.$(OBJEXT) +test_dup_LDADD = $(LDADD) +test_dup_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_dup_safer_SOURCES = test-dup-safer.c +test_dup_safer_OBJECTS = test-dup-safer.$(OBJEXT) +test_dup_safer_LDADD = $(LDADD) +test_dup_safer_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + 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/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_environ_SOURCES = test-environ.c +test_environ_OBJECTS = test-environ.$(OBJEXT) +test_environ_LDADD = $(LDADD) +test_environ_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_errno_SOURCES = test-errno.c +test_errno_OBJECTS = test-errno.$(OBJEXT) +test_errno_LDADD = $(LDADD) +test_errno_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_exclude_SOURCES = test-exclude.c +test_exclude_OBJECTS = test-exclude.$(OBJEXT) +test_exclude_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +test_faccessat_SOURCES = test-faccessat.c +test_faccessat_OBJECTS = test-faccessat.$(OBJEXT) +test_faccessat_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_fadvise_SOURCES = test-fadvise.c +test_fadvise_OBJECTS = test-fadvise.$(OBJEXT) +test_fadvise_LDADD = $(LDADD) +test_fadvise_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_fchdir_SOURCES = test-fchdir.c +test_fchdir_OBJECTS = test-fchdir.$(OBJEXT) +test_fchdir_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) +test_fchmodat_SOURCES = test-fchmodat.c +test_fchmodat_OBJECTS = test-fchmodat.$(OBJEXT) +test_fchmodat_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_fchownat_SOURCES = test-fchownat.c +test_fchownat_OBJECTS = test-fchownat.$(OBJEXT) +test_fchownat_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_fclose_SOURCES = test-fclose.c +test_fclose_OBJECTS = test-fclose.$(OBJEXT) +test_fclose_LDADD = $(LDADD) +test_fclose_DEPENDENCIES = libtests.a ../lib/libcoreutils.a 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/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_fcntl_h_SOURCES = test-fcntl-h.c +test_fcntl_h_OBJECTS = test-fcntl-h.$(OBJEXT) +test_fcntl_h_LDADD = $(LDADD) +test_fcntl_h_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_fcntl_safer_SOURCES = test-fcntl-safer.c +test_fcntl_safer_OBJECTS = test-fcntl-safer.$(OBJEXT) +test_fcntl_safer_LDADD = $(LDADD) +test_fcntl_safer_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_fdatasync_SOURCES = test-fdatasync.c +test_fdatasync_OBJECTS = test-fdatasync.$(OBJEXT) +test_fdatasync_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_fdopen_SOURCES = test-fdopen.c +test_fdopen_OBJECTS = test-fdopen.$(OBJEXT) +test_fdopen_LDADD = $(LDADD) +test_fdopen_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_fdopendir_SOURCES = test-fdopendir.c +test_fdopendir_OBJECTS = test-fdopendir.$(OBJEXT) +test_fdopendir_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_fdutimensat_SOURCES = test-fdutimensat.c +test_fdutimensat_OBJECTS = test-fdutimensat.$(OBJEXT) +test_fdutimensat_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +test_fflush_SOURCES = test-fflush.c +test_fflush_OBJECTS = test-fflush.$(OBJEXT) +test_fflush_LDADD = $(LDADD) +test_fflush_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_fflush2_SOURCES = test-fflush2.c +test_fflush2_OBJECTS = test-fflush2.$(OBJEXT) +test_fflush2_LDADD = $(LDADD) +test_fflush2_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_fgetc_SOURCES = test-fgetc.c +test_fgetc_OBJECTS = test-fgetc.$(OBJEXT) +test_fgetc_LDADD = $(LDADD) +test_fgetc_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_file_has_acl_SOURCES = test-file-has-acl.c +test_file_has_acl_OBJECTS = test-file-has-acl.$(OBJEXT) +test_file_has_acl_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_filenamecat_SOURCES = test-filenamecat.c +test_filenamecat_OBJECTS = test-filenamecat.$(OBJEXT) +test_filenamecat_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_filevercmp_SOURCES = test-filevercmp.c +test_filevercmp_OBJECTS = test-filevercmp.$(OBJEXT) +test_filevercmp_LDADD = $(LDADD) +test_filevercmp_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_float_SOURCES = test-float.c +test_float_OBJECTS = test-float.$(OBJEXT) +test_float_LDADD = $(LDADD) +test_float_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_fnmatch_SOURCES = test-fnmatch.c +test_fnmatch_OBJECTS = test-fnmatch.$(OBJEXT) +test_fnmatch_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_fnmatch_h_SOURCES = test-fnmatch-h.c +test_fnmatch_h_OBJECTS = test-fnmatch-h.$(OBJEXT) +test_fnmatch_h_LDADD = $(LDADD) +test_fnmatch_h_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_fopen_SOURCES = test-fopen.c +test_fopen_OBJECTS = test-fopen.$(OBJEXT) +test_fopen_LDADD = $(LDADD) +test_fopen_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_fopen_safer_SOURCES = test-fopen-safer.c +test_fopen_safer_OBJECTS = test-fopen-safer.$(OBJEXT) +test_fopen_safer_LDADD = $(LDADD) +test_fopen_safer_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_fpending_SOURCES = test-fpending.c +test_fpending_OBJECTS = test-fpending.$(OBJEXT) +test_fpending_LDADD = $(LDADD) +test_fpending_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_fpurge_SOURCES = test-fpurge.c +test_fpurge_OBJECTS = test-fpurge.$(OBJEXT) +test_fpurge_LDADD = $(LDADD) +test_fpurge_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_fputc_SOURCES = test-fputc.c +test_fputc_OBJECTS = test-fputc.$(OBJEXT) +test_fputc_LDADD = $(LDADD) +test_fputc_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_fread_SOURCES = test-fread.c +test_fread_OBJECTS = test-fread.$(OBJEXT) +test_fread_LDADD = $(LDADD) +test_fread_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_freadahead_SOURCES = test-freadahead.c +test_freadahead_OBJECTS = test-freadahead.$(OBJEXT) +test_freadahead_LDADD = $(LDADD) +test_freadahead_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_freading_SOURCES = test-freading.c +test_freading_OBJECTS = test-freading.$(OBJEXT) +test_freading_LDADD = $(LDADD) +test_freading_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_freadptr_SOURCES = test-freadptr.c +test_freadptr_OBJECTS = test-freadptr.$(OBJEXT) +test_freadptr_LDADD = $(LDADD) +test_freadptr_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_freadptr2_SOURCES = test-freadptr2.c +test_freadptr2_OBJECTS = test-freadptr2.$(OBJEXT) +test_freadptr2_LDADD = $(LDADD) +test_freadptr2_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_freadseek_SOURCES = test-freadseek.c +test_freadseek_OBJECTS = test-freadseek.$(OBJEXT) +test_freadseek_LDADD = $(LDADD) +test_freadseek_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_freopen_SOURCES = test-freopen.c +test_freopen_OBJECTS = test-freopen.$(OBJEXT) +test_freopen_LDADD = $(LDADD) +test_freopen_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_freopen_safer_SOURCES = test-freopen-safer.c +test_freopen_safer_OBJECTS = test-freopen-safer.$(OBJEXT) +test_freopen_safer_LDADD = $(LDADD) +test_freopen_safer_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +am_test_frexp_nolibm_OBJECTS = test-frexp.$(OBJEXT) randomd.$(OBJEXT) +test_frexp_nolibm_OBJECTS = $(am_test_frexp_nolibm_OBJECTS) +test_frexp_nolibm_LDADD = $(LDADD) +test_frexp_nolibm_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +am_test_frexpl_nolibm_OBJECTS = test-frexpl.$(OBJEXT) \ + randoml.$(OBJEXT) +test_frexpl_nolibm_OBJECTS = $(am_test_frexpl_nolibm_OBJECTS) +test_frexpl_nolibm_LDADD = $(LDADD) +test_frexpl_nolibm_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_fseek_SOURCES = test-fseek.c +test_fseek_OBJECTS = test-fseek.$(OBJEXT) +test_fseek_LDADD = $(LDADD) +test_fseek_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_fseeko_SOURCES = test-fseeko.c +test_fseeko_OBJECTS = test-fseeko.$(OBJEXT) +test_fseeko_LDADD = $(LDADD) +test_fseeko_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_fseeko3_SOURCES = test-fseeko3.c +test_fseeko3_OBJECTS = test-fseeko3.$(OBJEXT) +test_fseeko3_LDADD = $(LDADD) +test_fseeko3_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_fseeko4_SOURCES = test-fseeko4.c +test_fseeko4_OBJECTS = test-fseeko4.$(OBJEXT) +test_fseeko4_LDADD = $(LDADD) +test_fseeko4_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_fseterr_SOURCES = test-fseterr.c +test_fseterr_OBJECTS = test-fseterr.$(OBJEXT) +test_fseterr_LDADD = $(LDADD) +test_fseterr_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_fstat_SOURCES = test-fstat.c +test_fstat_OBJECTS = test-fstat.$(OBJEXT) +test_fstat_LDADD = $(LDADD) +test_fstat_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_fstatat_SOURCES = test-fstatat.c +test_fstatat_OBJECTS = test-fstatat.$(OBJEXT) +test_fstatat_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_fsync_SOURCES = test-fsync.c +test_fsync_OBJECTS = test-fsync.$(OBJEXT) +test_fsync_LDADD = $(LDADD) +test_fsync_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_ftell_SOURCES = test-ftell.c +test_ftell_OBJECTS = test-ftell.$(OBJEXT) +test_ftell_LDADD = $(LDADD) +test_ftell_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_ftell3_SOURCES = test-ftell3.c +test_ftell3_OBJECTS = test-ftell3.$(OBJEXT) +test_ftell3_LDADD = $(LDADD) +test_ftell3_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_ftello_SOURCES = test-ftello.c +test_ftello_OBJECTS = test-ftello.$(OBJEXT) +test_ftello_LDADD = $(LDADD) +test_ftello_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_ftello3_SOURCES = test-ftello3.c +test_ftello3_OBJECTS = test-ftello3.$(OBJEXT) +test_ftello3_LDADD = $(LDADD) +test_ftello3_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_ftello4_SOURCES = test-ftello4.c +test_ftello4_OBJECTS = test-ftello4.$(OBJEXT) +test_ftello4_LDADD = $(LDADD) +test_ftello4_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_ftruncate_SOURCES = test-ftruncate.c +test_ftruncate_OBJECTS = test-ftruncate.$(OBJEXT) +test_ftruncate_LDADD = $(LDADD) +test_ftruncate_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_futimens_SOURCES = test-futimens.c +test_futimens_OBJECTS = test-futimens.$(OBJEXT) +test_futimens_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +test_fwrite_SOURCES = test-fwrite.c +test_fwrite_OBJECTS = test-fwrite.$(OBJEXT) +test_fwrite_LDADD = $(LDADD) +test_fwrite_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_getaddrinfo_SOURCES = test-getaddrinfo.c +test_getaddrinfo_OBJECTS = test-getaddrinfo.$(OBJEXT) +test_getaddrinfo_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_getcwd_SOURCES = test-getcwd.c +test_getcwd_OBJECTS = test-getcwd.$(OBJEXT) +test_getcwd_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_getcwd_lgpl_SOURCES = test-getcwd-lgpl.c +test_getcwd_lgpl_OBJECTS = test-getcwd-lgpl.$(OBJEXT) +test_getcwd_lgpl_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_getdelim_SOURCES = test-getdelim.c +test_getdelim_OBJECTS = test-getdelim.$(OBJEXT) +test_getdelim_LDADD = $(LDADD) +test_getdelim_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_getdtablesize_SOURCES = test-getdtablesize.c +test_getdtablesize_OBJECTS = test-getdtablesize.$(OBJEXT) +test_getdtablesize_LDADD = $(LDADD) +test_getdtablesize_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_getgroups_SOURCES = test-getgroups.c +test_getgroups_OBJECTS = test-getgroups.$(OBJEXT) +test_getgroups_LDADD = $(LDADD) +test_getgroups_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_gethostname_SOURCES = test-gethostname.c +test_gethostname_OBJECTS = test-gethostname.$(OBJEXT) +test_gethostname_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_getline_SOURCES = test-getline.c +test_getline_OBJECTS = test-getline.$(OBJEXT) +test_getline_LDADD = $(LDADD) +test_getline_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_getloadavg_SOURCES = test-getloadavg.c +test_getloadavg_OBJECTS = test-getloadavg.$(OBJEXT) +test_getloadavg_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_getlogin_SOURCES = test-getlogin.c +test_getlogin_OBJECTS = test-getlogin.$(OBJEXT) +test_getlogin_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_getndelim2_SOURCES = test-getndelim2.c +test_getndelim2_OBJECTS = test-getndelim2.$(OBJEXT) +test_getndelim2_LDADD = $(LDADD) +test_getndelim2_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_getopt_gnu_SOURCES = test-getopt-gnu.c +test_getopt_gnu_OBJECTS = test-getopt-gnu.$(OBJEXT) +test_getopt_gnu_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_getopt_posix_SOURCES = test-getopt-posix.c +test_getopt_posix_OBJECTS = test-getopt-posix.$(OBJEXT) +test_getopt_posix_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_getprogname_SOURCES = test-getprogname.c +test_getprogname_OBJECTS = test-getprogname.$(OBJEXT) +test_getprogname_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_getrusage_SOURCES = test-getrusage.c +test_getrusage_OBJECTS = test-getrusage.$(OBJEXT) +test_getrusage_LDADD = $(LDADD) +test_getrusage_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_gettimeofday_SOURCES = test-gettimeofday.c +test_gettimeofday_OBJECTS = test-gettimeofday.$(OBJEXT) +test_gettimeofday_LDADD = $(LDADD) +test_gettimeofday_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_hard_locale_SOURCES = test-hard-locale.c +test_hard_locale_OBJECTS = test-hard-locale.$(OBJEXT) +test_hard_locale_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_hash_SOURCES = test-hash.c +test_hash_OBJECTS = test-hash.$(OBJEXT) +test_hash_LDADD = $(LDADD) +test_hash_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_i_ring_SOURCES = test-i-ring.c +test_i_ring_OBJECTS = test-i-ring.$(OBJEXT) +test_i_ring_LDADD = $(LDADD) +test_i_ring_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_iconv_SOURCES = test-iconv.c +test_iconv_OBJECTS = test-iconv.$(OBJEXT) +test_iconv_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_iconv_h_SOURCES = test-iconv-h.c +test_iconv_h_OBJECTS = test-iconv-h.$(OBJEXT) +test_iconv_h_LDADD = $(LDADD) +test_iconv_h_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_ignore_value_SOURCES = test-ignore-value.c +test_ignore_value_OBJECTS = test-ignore-value.$(OBJEXT) +test_ignore_value_LDADD = $(LDADD) +test_ignore_value_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_inet_ntop_SOURCES = test-inet_ntop.c +test_inet_ntop_OBJECTS = test-inet_ntop.$(OBJEXT) +test_inet_ntop_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_inet_pton_SOURCES = test-inet_pton.c +test_inet_pton_OBJECTS = test-inet_pton.$(OBJEXT) +test_inet_pton_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_ino_map_SOURCES = test-ino-map.c +test_ino_map_OBJECTS = test-ino-map.$(OBJEXT) +test_ino_map_LDADD = $(LDADD) +test_ino_map_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_intprops_SOURCES = test-intprops.c +test_intprops_OBJECTS = test-intprops.$(OBJEXT) +test_intprops_LDADD = $(LDADD) +test_intprops_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_inttostr_SOURCES = test-inttostr.c +test_inttostr_OBJECTS = test-inttostr.$(OBJEXT) +test_inttostr_LDADD = $(LDADD) +test_inttostr_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_inttypes_SOURCES = test-inttypes.c +test_inttypes_OBJECTS = test-inttypes.$(OBJEXT) +test_inttypes_LDADD = $(LDADD) +test_inttypes_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_ioctl_SOURCES = test-ioctl.c +test_ioctl_OBJECTS = test-ioctl.$(OBJEXT) +test_ioctl_LDADD = $(LDADD) +test_ioctl_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_isatty_SOURCES = test-isatty.c +test_isatty_OBJECTS = test-isatty.$(OBJEXT) +test_isatty_LDADD = $(LDADD) +test_isatty_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_isblank_SOURCES = test-isblank.c +test_isblank_OBJECTS = test-isblank.$(OBJEXT) +test_isblank_LDADD = $(LDADD) +test_isblank_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_isnand_nolibm_SOURCES = test-isnand-nolibm.c +test_isnand_nolibm_OBJECTS = test-isnand-nolibm.$(OBJEXT) +test_isnand_nolibm_LDADD = $(LDADD) +test_isnand_nolibm_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_isnanf_nolibm_SOURCES = test-isnanf-nolibm.c +test_isnanf_nolibm_OBJECTS = test-isnanf-nolibm.$(OBJEXT) +test_isnanf_nolibm_LDADD = $(LDADD) +test_isnanf_nolibm_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_isnanl_nolibm_SOURCES = test-isnanl-nolibm.c +test_isnanl_nolibm_OBJECTS = test-isnanl-nolibm.$(OBJEXT) +test_isnanl_nolibm_LDADD = $(LDADD) +test_isnanl_nolibm_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_iswblank_SOURCES = test-iswblank.c +test_iswblank_OBJECTS = test-iswblank.$(OBJEXT) +test_iswblank_LDADD = $(LDADD) +test_iswblank_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_iswdigit_SOURCES = test-iswdigit.c +test_iswdigit_OBJECTS = test-iswdigit.$(OBJEXT) +test_iswdigit_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +test_iswxdigit_SOURCES = test-iswxdigit.c +test_iswxdigit_OBJECTS = test-iswxdigit.$(OBJEXT) +test_iswxdigit_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +test_langinfo_SOURCES = test-langinfo.c +test_langinfo_OBJECTS = test-langinfo.$(OBJEXT) +test_langinfo_LDADD = $(LDADD) +test_langinfo_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_lchmod_SOURCES = test-lchmod.c +test_lchmod_OBJECTS = test-lchmod.$(OBJEXT) +test_lchmod_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_lchown_SOURCES = test-lchown.c +test_lchown_OBJECTS = test-lchown.$(OBJEXT) +test_lchown_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) +test_limits_h_SOURCES = test-limits-h.c +test_limits_h_OBJECTS = test-limits-h.$(OBJEXT) +test_limits_h_LDADD = $(LDADD) +test_limits_h_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_link_SOURCES = test-link.c +test_link_OBJECTS = test-link.$(OBJEXT) +test_link_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_linkat_SOURCES = test-linkat.c +test_linkat_OBJECTS = test-linkat.$(OBJEXT) +test_linkat_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_listen_SOURCES = test-listen.c +test_listen_OBJECTS = test-listen.$(OBJEXT) +test_listen_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_localcharset_SOURCES = test-localcharset.c +test_localcharset_OBJECTS = test-localcharset.$(OBJEXT) +test_localcharset_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_locale_SOURCES = test-locale.c +test_locale_OBJECTS = test-locale.$(OBJEXT) +test_locale_LDADD = $(LDADD) +test_locale_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_localeconv_SOURCES = test-localeconv.c +test_localeconv_OBJECTS = test-localeconv.$(OBJEXT) +test_localeconv_LDADD = $(LDADD) +test_localeconv_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_localename_SOURCES = test-localename.c +test_localename_OBJECTS = test-localename.$(OBJEXT) +test_localename_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +test_lock_SOURCES = test-lock.c +test_lock_OBJECTS = test_lock-test-lock.$(OBJEXT) +test_lock_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_lock_LINK = $(CCLD) $(test_lock_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +test_lseek_SOURCES = test-lseek.c +test_lseek_OBJECTS = test-lseek.$(OBJEXT) +test_lseek_LDADD = $(LDADD) +test_lseek_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_lstat_SOURCES = test-lstat.c +test_lstat_OBJECTS = test-lstat.$(OBJEXT) +test_lstat_LDADD = $(LDADD) +test_lstat_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_malloc_gnu_SOURCES = test-malloc-gnu.c +test_malloc_gnu_OBJECTS = test-malloc-gnu.$(OBJEXT) +test_malloc_gnu_LDADD = $(LDADD) +test_malloc_gnu_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_malloca_SOURCES = test-malloca.c +test_malloca_OBJECTS = test-malloca.$(OBJEXT) +test_malloca_LDADD = $(LDADD) +test_malloca_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_math_SOURCES = test-math.c +test_math_OBJECTS = test-math.$(OBJEXT) +test_math_LDADD = $(LDADD) +test_math_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_mbrtowc_SOURCES = test-mbrtowc.c +test_mbrtowc_OBJECTS = test-mbrtowc.$(OBJEXT) +test_mbrtowc_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +test_mbrtowc_w32_SOURCES = test-mbrtowc-w32.c +test_mbrtowc_w32_OBJECTS = test-mbrtowc-w32.$(OBJEXT) +test_mbrtowc_w32_LDADD = $(LDADD) +test_mbrtowc_w32_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_mbsalign_SOURCES = test-mbsalign.c +test_mbsalign_OBJECTS = test-mbsalign.$(OBJEXT) +test_mbsalign_LDADD = $(LDADD) +test_mbsalign_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_mbscasecmp_SOURCES = test-mbscasecmp.c +test_mbscasecmp_OBJECTS = test-mbscasecmp.$(OBJEXT) +test_mbscasecmp_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +test_mbschr_SOURCES = test-mbschr.c +test_mbschr_OBJECTS = test-mbschr.$(OBJEXT) +test_mbschr_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +test_mbsinit_SOURCES = test-mbsinit.c +test_mbsinit_OBJECTS = test-mbsinit.$(OBJEXT) +test_mbsinit_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +test_mbsrtowcs_SOURCES = test-mbsrtowcs.c +test_mbsrtowcs_OBJECTS = test-mbsrtowcs.$(OBJEXT) +test_mbsrtowcs_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +test_mbsstr1_SOURCES = test-mbsstr1.c +test_mbsstr1_OBJECTS = test-mbsstr1.$(OBJEXT) +test_mbsstr1_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_mbsstr2_SOURCES = test-mbsstr2.c +test_mbsstr2_OBJECTS = test-mbsstr2.$(OBJEXT) +test_mbsstr2_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +test_mbsstr3_SOURCES = test-mbsstr3.c +test_mbsstr3_OBJECTS = test-mbsstr3.$(OBJEXT) +test_mbsstr3_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +test_md5_SOURCES = test-md5.c +test_md5_OBJECTS = test-md5.$(OBJEXT) +test_md5_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_memcasecmp_SOURCES = test-memcasecmp.c +test_memcasecmp_OBJECTS = test-memcasecmp.$(OBJEXT) +test_memcasecmp_LDADD = $(LDADD) +test_memcasecmp_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_memchr_SOURCES = test-memchr.c +test_memchr_OBJECTS = test-memchr.$(OBJEXT) +test_memchr_LDADD = $(LDADD) +test_memchr_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_memchr2_SOURCES = test-memchr2.c +test_memchr2_OBJECTS = test-memchr2.$(OBJEXT) +test_memchr2_LDADD = $(LDADD) +test_memchr2_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_memcoll_SOURCES = test-memcoll.c +test_memcoll_OBJECTS = test-memcoll.$(OBJEXT) +test_memcoll_LDADD = $(LDADD) +test_memcoll_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_memrchr_SOURCES = test-memrchr.c +test_memrchr_OBJECTS = test-memrchr.$(OBJEXT) +test_memrchr_LDADD = $(LDADD) +test_memrchr_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_mkdir_SOURCES = test-mkdir.c +test_mkdir_OBJECTS = test-mkdir.$(OBJEXT) +test_mkdir_LDADD = $(LDADD) +test_mkdir_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_mkfifo_SOURCES = test-mkfifo.c +test_mkfifo_OBJECTS = test-mkfifo.$(OBJEXT) +test_mkfifo_LDADD = $(LDADD) +test_mkfifo_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_mknod_SOURCES = test-mknod.c +test_mknod_OBJECTS = test-mknod.$(OBJEXT) +test_mknod_LDADD = $(LDADD) +test_mknod_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_nanosleep_SOURCES = test-nanosleep.c +test_nanosleep_OBJECTS = test-nanosleep.$(OBJEXT) +test_nanosleep_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_netdb_SOURCES = test-netdb.c +test_netdb_OBJECTS = test-netdb.$(OBJEXT) +test_netdb_LDADD = $(LDADD) +test_netdb_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_netinet_in_SOURCES = test-netinet_in.c +test_netinet_in_OBJECTS = test-netinet_in.$(OBJEXT) +test_netinet_in_LDADD = $(LDADD) +test_netinet_in_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_nl_langinfo_SOURCES = test-nl_langinfo.c +test_nl_langinfo_OBJECTS = test-nl_langinfo.$(OBJEXT) +test_nl_langinfo_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_nl_langinfo_mt_SOURCES = test-nl_langinfo-mt.c +test_nl_langinfo_mt_OBJECTS = test-nl_langinfo-mt.$(OBJEXT) +test_nl_langinfo_mt_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +test_nstrftime_SOURCES = test-nstrftime.c +test_nstrftime_OBJECTS = test-nstrftime.$(OBJEXT) +test_nstrftime_LDADD = $(LDADD) +test_nstrftime_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +am_test_once1_OBJECTS = test-once.$(OBJEXT) +test_once1_OBJECTS = $(am_test_once1_OBJECTS) +test_once1_DEPENDENCIES = $(am__DEPENDENCIES_2) +am_test_once2_OBJECTS = test-once.$(OBJEXT) +test_once2_OBJECTS = $(am_test_once2_OBJECTS) +test_once2_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_open_SOURCES = test-open.c +test_open_OBJECTS = test-open.$(OBJEXT) +test_open_LDADD = $(LDADD) +test_open_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_openat_SOURCES = test-openat.c +test_openat_OBJECTS = test-openat.$(OBJEXT) +test_openat_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_openat_safer_SOURCES = test-openat-safer.c +test_openat_safer_OBJECTS = test-openat-safer.$(OBJEXT) +test_openat_safer_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_parse_datetime_SOURCES = test-parse-datetime.c +test_parse_datetime_OBJECTS = test-parse-datetime.$(OBJEXT) +test_parse_datetime_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_pathmax_SOURCES = test-pathmax.c +test_pathmax_OBJECTS = test-pathmax.$(OBJEXT) +test_pathmax_LDADD = $(LDADD) +test_pathmax_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_perror_SOURCES = test-perror.c +test_perror_OBJECTS = test-perror.$(OBJEXT) +test_perror_LDADD = $(LDADD) +test_perror_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_perror2_SOURCES = test-perror2.c +test_perror2_OBJECTS = test-perror2.$(OBJEXT) +test_perror2_LDADD = $(LDADD) +test_perror2_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_pipe_SOURCES = test-pipe.c +test_pipe_OBJECTS = test-pipe.$(OBJEXT) +test_pipe_LDADD = $(LDADD) +test_pipe_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_pipe2_SOURCES = test-pipe2.c +test_pipe2_OBJECTS = test-pipe2.$(OBJEXT) +test_pipe2_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) +test_posixtm_SOURCES = test-posixtm.c +test_posixtm_OBJECTS = test-posixtm.$(OBJEXT) +test_posixtm_LDADD = $(LDADD) +test_posixtm_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_printf_frexp_SOURCES = test-printf-frexp.c +test_printf_frexp_OBJECTS = test-printf-frexp.$(OBJEXT) +test_printf_frexp_LDADD = $(LDADD) +test_printf_frexp_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_printf_frexpl_SOURCES = test-printf-frexpl.c +test_printf_frexpl_OBJECTS = test-printf-frexpl.$(OBJEXT) +test_printf_frexpl_LDADD = $(LDADD) +test_printf_frexpl_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_priv_set_SOURCES = test-priv-set.c +test_priv_set_OBJECTS = test-priv-set.$(OBJEXT) +test_priv_set_LDADD = $(LDADD) +test_priv_set_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_pthread_SOURCES = test-pthread.c +test_pthread_OBJECTS = test-pthread.$(OBJEXT) +test_pthread_LDADD = $(LDADD) +test_pthread_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_pthread_cond_SOURCES = test-pthread-cond.c +test_pthread_cond_OBJECTS = test-pthread-cond.$(OBJEXT) +test_pthread_cond_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_pthread_mutex_SOURCES = test-pthread-mutex.c +test_pthread_mutex_OBJECTS = test-pthread-mutex.$(OBJEXT) +test_pthread_mutex_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_pthread_thread_SOURCES = test-pthread-thread.c +test_pthread_thread_OBJECTS = test-pthread-thread.$(OBJEXT) +test_pthread_thread_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_pthread_sigmask1_SOURCES = test-pthread_sigmask1.c +test_pthread_sigmask1_OBJECTS = test-pthread_sigmask1.$(OBJEXT) +test_pthread_sigmask1_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_pthread_sigmask2_SOURCES = test-pthread_sigmask2.c +test_pthread_sigmask2_OBJECTS = test-pthread_sigmask2.$(OBJEXT) +test_pthread_sigmask2_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_quotearg_simple_SOURCES = test-quotearg-simple.c +test_quotearg_simple_OBJECTS = test-quotearg-simple.$(OBJEXT) +test_quotearg_simple_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_raise_SOURCES = test-raise.c +test_raise_OBJECTS = test-raise.$(OBJEXT) +test_raise_LDADD = $(LDADD) +test_raise_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_rand_isaac_SOURCES = test-rand-isaac.c +test_rand_isaac_OBJECTS = test-rand-isaac.$(OBJEXT) +test_rand_isaac_LDADD = $(LDADD) +test_rand_isaac_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_read_SOURCES = test-read.c +test_read_OBJECTS = test-read.$(OBJEXT) +test_read_LDADD = $(LDADD) +test_read_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_read_file_SOURCES = test-read-file.c +test_read_file_OBJECTS = test-read-file.$(OBJEXT) +test_read_file_LDADD = $(LDADD) +test_read_file_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_readlink_SOURCES = test-readlink.c +test_readlink_OBJECTS = test-readlink.$(OBJEXT) +test_readlink_LDADD = $(LDADD) +test_readlink_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_readlinkat_SOURCES = test-readlinkat.c +test_readlinkat_OBJECTS = test-readlinkat.$(OBJEXT) +test_readlinkat_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_readtokens_SOURCES = test-readtokens.c +test_readtokens_OBJECTS = test-readtokens.$(OBJEXT) +test_readtokens_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_realloc_gnu_SOURCES = test-realloc-gnu.c +test_realloc_gnu_OBJECTS = test-realloc-gnu.$(OBJEXT) +test_realloc_gnu_LDADD = $(LDADD) +test_realloc_gnu_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_regex_SOURCES = test-regex.c +test_regex_OBJECTS = test-regex.$(OBJEXT) +test_regex_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +test_remove_SOURCES = test-remove.c +test_remove_OBJECTS = test-remove.$(OBJEXT) +test_remove_LDADD = $(LDADD) +test_remove_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_rename_SOURCES = test-rename.c +test_rename_OBJECTS = test-rename.$(OBJEXT) +test_rename_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_renameat_SOURCES = test-renameat.c +test_renameat_OBJECTS = test-renameat.$(OBJEXT) +test_renameat_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_renameatu_SOURCES = test-renameatu.c +test_renameatu_OBJECTS = test-renameatu.$(OBJEXT) +test_renameatu_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_rmdir_SOURCES = test-rmdir.c +test_rmdir_OBJECTS = test-rmdir.$(OBJEXT) +test_rmdir_LDADD = $(LDADD) +test_rmdir_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_rwlock1_SOURCES = test-rwlock1.c +test_rwlock1_OBJECTS = test-rwlock1.$(OBJEXT) +test_rwlock1_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_sameacls_SOURCES = test-sameacls.c +test_sameacls_OBJECTS = test-sameacls.$(OBJEXT) +test_sameacls_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +test_sched_SOURCES = test-sched.c +test_sched_OBJECTS = test-sched.$(OBJEXT) +test_sched_LDADD = $(LDADD) +test_sched_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_select_SOURCES = test-select.c +test_select_OBJECTS = test-select.$(OBJEXT) +test_select_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) +test_select_fd_SOURCES = test-select-fd.c +test_select_fd_OBJECTS = test-select-fd.$(OBJEXT) +test_select_fd_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_select_stdin_SOURCES = test-select-stdin.c +test_select_stdin_OBJECTS = test-select-stdin.$(OBJEXT) +test_select_stdin_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_set_mode_acl_SOURCES = test-set-mode-acl.c +test_set_mode_acl_OBJECTS = test-set-mode-acl.$(OBJEXT) +test_set_mode_acl_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +test_setenv_SOURCES = test-setenv.c +test_setenv_OBJECTS = test-setenv.$(OBJEXT) +test_setenv_LDADD = $(LDADD) +test_setenv_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_setlocale1_SOURCES = test-setlocale1.c +test_setlocale1_OBJECTS = test-setlocale1.$(OBJEXT) +test_setlocale1_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_setlocale2_SOURCES = test-setlocale2.c +test_setlocale2_OBJECTS = test-setlocale2.$(OBJEXT) +test_setlocale2_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_setlocale_null_SOURCES = test-setlocale_null.c +test_setlocale_null_OBJECTS = test-setlocale_null.$(OBJEXT) +test_setlocale_null_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_setlocale_null_mt_all_SOURCES = test-setlocale_null-mt-all.c +test_setlocale_null_mt_all_OBJECTS = \ + test-setlocale_null-mt-all.$(OBJEXT) +test_setlocale_null_mt_all_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +test_setlocale_null_mt_one_SOURCES = test-setlocale_null-mt-one.c +test_setlocale_null_mt_one_OBJECTS = \ + test-setlocale_null-mt-one.$(OBJEXT) +test_setlocale_null_mt_one_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +test_setsockopt_SOURCES = test-setsockopt.c +test_setsockopt_OBJECTS = test-setsockopt.$(OBJEXT) +test_setsockopt_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_sha1_SOURCES = test-sha1.c +test_sha1_OBJECTS = test-sha1.$(OBJEXT) +test_sha1_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_sha256_SOURCES = test-sha256.c +test_sha256_OBJECTS = test-sha256.$(OBJEXT) +test_sha256_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_sha512_SOURCES = test-sha512.c +test_sha512_OBJECTS = test-sha512.$(OBJEXT) +test_sha512_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_sigaction_SOURCES = test-sigaction.c +test_sigaction_OBJECTS = test-sigaction.$(OBJEXT) +test_sigaction_LDADD = $(LDADD) +test_sigaction_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_signal_h_SOURCES = test-signal-h.c +test_signal_h_OBJECTS = test-signal-h.$(OBJEXT) +test_signal_h_LDADD = $(LDADD) +test_signal_h_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_signbit_SOURCES = test-signbit.c +test_signbit_OBJECTS = test-signbit.$(OBJEXT) +test_signbit_LDADD = $(LDADD) +test_signbit_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_sigprocmask_SOURCES = test-sigprocmask.c +test_sigprocmask_OBJECTS = test-sigprocmask.$(OBJEXT) +test_sigprocmask_LDADD = $(LDADD) +test_sigprocmask_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_sleep_SOURCES = test-sleep.c +test_sleep_OBJECTS = test-sleep.$(OBJEXT) +test_sleep_LDADD = $(LDADD) +test_sleep_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_snprintf_SOURCES = test-snprintf.c +test_snprintf_OBJECTS = test-snprintf.$(OBJEXT) +test_snprintf_LDADD = $(LDADD) +test_snprintf_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_sockets_SOURCES = test-sockets.c +test_sockets_OBJECTS = test-sockets.$(OBJEXT) +test_sockets_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_stat_SOURCES = test-stat.c +test_stat_OBJECTS = test-stat.$(OBJEXT) +test_stat_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) +test_stat_time_SOURCES = test-stat-time.c +test_stat_time_OBJECTS = test-stat-time.$(OBJEXT) +test_stat_time_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_statat_SOURCES = test-statat.c +test_statat_OBJECTS = test-statat.$(OBJEXT) +test_statat_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_stdalign_SOURCES = test-stdalign.c +test_stdalign_OBJECTS = test-stdalign.$(OBJEXT) +test_stdalign_LDADD = $(LDADD) +test_stdalign_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_stdbool_SOURCES = test-stdbool.c +test_stdbool_OBJECTS = test-stdbool.$(OBJEXT) +test_stdbool_LDADD = $(LDADD) +test_stdbool_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + 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/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_stdint_SOURCES = test-stdint.c +test_stdint_OBJECTS = test-stdint.$(OBJEXT) +test_stdint_LDADD = $(LDADD) +test_stdint_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_stdio_SOURCES = test-stdio.c +test_stdio_OBJECTS = test-stdio.$(OBJEXT) +test_stdio_LDADD = $(LDADD) +test_stdio_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_stdlib_SOURCES = test-stdlib.c +test_stdlib_OBJECTS = test-stdlib.$(OBJEXT) +test_stdlib_LDADD = $(LDADD) +test_stdlib_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_strerror_SOURCES = test-strerror.c +test_strerror_OBJECTS = test-strerror.$(OBJEXT) +test_strerror_LDADD = $(LDADD) +test_strerror_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_strerror_r_SOURCES = test-strerror_r.c +test_strerror_r_OBJECTS = test-strerror_r.$(OBJEXT) +test_strerror_r_LDADD = $(LDADD) +test_strerror_r_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_striconv_SOURCES = test-striconv.c +test_striconv_OBJECTS = test-striconv.$(OBJEXT) +test_striconv_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_string_SOURCES = test-string.c +test_string_OBJECTS = test-string.$(OBJEXT) +test_string_LDADD = $(LDADD) +test_string_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_strncat_SOURCES = test-strncat.c +test_strncat_OBJECTS = test-strncat.$(OBJEXT) +test_strncat_LDADD = $(LDADD) +test_strncat_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_strnlen_SOURCES = test-strnlen.c +test_strnlen_OBJECTS = test-strnlen.$(OBJEXT) +test_strnlen_LDADD = $(LDADD) +test_strnlen_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_strsignal_SOURCES = test-strsignal.c +test_strsignal_OBJECTS = test-strsignal.$(OBJEXT) +test_strsignal_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_strtod_SOURCES = test-strtod.c +test_strtod_OBJECTS = test-strtod.$(OBJEXT) +test_strtod_LDADD = $(LDADD) +test_strtod_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_strtod1_SOURCES = test-strtod1.c +test_strtod1_OBJECTS = test-strtod1.$(OBJEXT) +test_strtod1_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_strtoimax_SOURCES = test-strtoimax.c +test_strtoimax_OBJECTS = test-strtoimax.$(OBJEXT) +test_strtoimax_LDADD = $(LDADD) +test_strtoimax_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_strtold_SOURCES = test-strtold.c +test_strtold_OBJECTS = test-strtold.$(OBJEXT) +test_strtold_LDADD = $(LDADD) +test_strtold_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_strtold1_SOURCES = test-strtold1.c +test_strtold1_OBJECTS = test-strtold1.$(OBJEXT) +test_strtold1_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_strtoll_SOURCES = test-strtoll.c +test_strtoll_OBJECTS = test-strtoll.$(OBJEXT) +test_strtoll_LDADD = $(LDADD) +test_strtoll_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_strtoull_SOURCES = test-strtoull.c +test_strtoull_OBJECTS = test-strtoull.$(OBJEXT) +test_strtoull_LDADD = $(LDADD) +test_strtoull_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_strtoumax_SOURCES = test-strtoumax.c +test_strtoumax_OBJECTS = test-strtoumax.$(OBJEXT) +test_strtoumax_LDADD = $(LDADD) +test_strtoumax_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_symlink_SOURCES = test-symlink.c +test_symlink_OBJECTS = test-symlink.$(OBJEXT) +test_symlink_LDADD = $(LDADD) +test_symlink_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_symlinkat_SOURCES = test-symlinkat.c +test_symlinkat_OBJECTS = test-symlinkat.$(OBJEXT) +test_symlinkat_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_sys_ioctl_SOURCES = test-sys_ioctl.c +test_sys_ioctl_OBJECTS = test-sys_ioctl.$(OBJEXT) +test_sys_ioctl_LDADD = $(LDADD) +test_sys_ioctl_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_sys_resource_SOURCES = test-sys_resource.c +test_sys_resource_OBJECTS = test-sys_resource.$(OBJEXT) +test_sys_resource_LDADD = $(LDADD) +test_sys_resource_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_sys_select_SOURCES = test-sys_select.c +test_sys_select_OBJECTS = test-sys_select.$(OBJEXT) +test_sys_select_LDADD = $(LDADD) +test_sys_select_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_sys_socket_SOURCES = test-sys_socket.c +test_sys_socket_OBJECTS = test-sys_socket.$(OBJEXT) +test_sys_socket_LDADD = $(LDADD) +test_sys_socket_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_sys_stat_SOURCES = test-sys_stat.c +test_sys_stat_OBJECTS = test-sys_stat.$(OBJEXT) +test_sys_stat_LDADD = $(LDADD) +test_sys_stat_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_sys_time_SOURCES = test-sys_time.c +test_sys_time_OBJECTS = test-sys_time.$(OBJEXT) +test_sys_time_LDADD = $(LDADD) +test_sys_time_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_sys_types_SOURCES = test-sys_types.c +test_sys_types_OBJECTS = test-sys_types.$(OBJEXT) +test_sys_types_LDADD = $(LDADD) +test_sys_types_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_sys_uio_SOURCES = test-sys_uio.c +test_sys_uio_OBJECTS = test-sys_uio.$(OBJEXT) +test_sys_uio_LDADD = $(LDADD) +test_sys_uio_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_sys_utsname_SOURCES = test-sys_utsname.c +test_sys_utsname_OBJECTS = test-sys_utsname.$(OBJEXT) +test_sys_utsname_LDADD = $(LDADD) +test_sys_utsname_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_sys_wait_SOURCES = test-sys_wait.c +test_sys_wait_OBJECTS = test-sys_wait.$(OBJEXT) +test_sys_wait_LDADD = $(LDADD) +test_sys_wait_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_termios_SOURCES = test-termios.c +test_termios_OBJECTS = test-termios.$(OBJEXT) +test_termios_LDADD = $(LDADD) +test_termios_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_thread_create_SOURCES = test-thread_create.c +test_thread_create_OBJECTS = test-thread_create.$(OBJEXT) +test_thread_create_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_thread_self_SOURCES = test-thread_self.c +test_thread_self_OBJECTS = test-thread_self.$(OBJEXT) +test_thread_self_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_time_SOURCES = test-time.c +test_time_OBJECTS = test-time.$(OBJEXT) +test_time_LDADD = $(LDADD) +test_time_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_timespec_SOURCES = test-timespec.c +test_timespec_OBJECTS = test-timespec.$(OBJEXT) +test_timespec_LDADD = $(LDADD) +test_timespec_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_tls_SOURCES = test-tls.c +test_tls_OBJECTS = test_tls-test-tls.$(OBJEXT) +test_tls_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_tls_LINK = $(CCLD) $(test_tls_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +test_u64_SOURCES = test-u64.c +test_u64_OBJECTS = test-u64.$(OBJEXT) +test_u64_LDADD = $(LDADD) +test_u64_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +am_test_u8_mbtoucr_OBJECTS = unistr/test-u8-mbtoucr.$(OBJEXT) +test_u8_mbtoucr_OBJECTS = $(am_test_u8_mbtoucr_OBJECTS) +test_u8_mbtoucr_DEPENDENCIES = $(am__DEPENDENCIES_2) +am_test_u8_uctomb_OBJECTS = unistr/test-u8-uctomb.$(OBJEXT) +test_u8_uctomb_OBJECTS = $(am_test_u8_uctomb_OBJECTS) +test_u8_uctomb_DEPENDENCIES = $(am__DEPENDENCIES_2) +am_test_uc_width_OBJECTS = uniwidth/test-uc_width.$(OBJEXT) +test_uc_width_OBJECTS = $(am_test_uc_width_OBJECTS) +test_uc_width_DEPENDENCIES = $(am__DEPENDENCIES_2) +am_test_uc_width2_OBJECTS = uniwidth/test-uc_width2.$(OBJEXT) +test_uc_width2_OBJECTS = $(am_test_uc_width2_OBJECTS) +test_uc_width2_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_uname_SOURCES = test-uname.c +test_uname_OBJECTS = test-uname.$(OBJEXT) +test_uname_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_unistd_SOURCES = test-unistd.c +test_unistd_OBJECTS = test-unistd.$(OBJEXT) +test_unistd_LDADD = $(LDADD) +test_unistd_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_unlink_SOURCES = test-unlink.c +test_unlink_OBJECTS = test-unlink.$(OBJEXT) +test_unlink_LDADD = $(LDADD) +test_unlink_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_unlinkat_SOURCES = test-unlinkat.c +test_unlinkat_OBJECTS = test-unlinkat.$(OBJEXT) +test_unlinkat_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_unsetenv_SOURCES = test-unsetenv.c +test_unsetenv_OBJECTS = test-unsetenv.$(OBJEXT) +test_unsetenv_LDADD = $(LDADD) +test_unsetenv_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_userspec_SOURCES = test-userspec.c +test_userspec_OBJECTS = test-userspec.$(OBJEXT) +test_userspec_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_usleep_SOURCES = test-usleep.c +test_usleep_OBJECTS = test-usleep.$(OBJEXT) +test_usleep_LDADD = $(LDADD) +test_usleep_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_utime_SOURCES = test-utime.c +test_utime_OBJECTS = test-utime.$(OBJEXT) +test_utime_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +test_utime_h_SOURCES = test-utime-h.c +test_utime_h_OBJECTS = test-utime-h.$(OBJEXT) +test_utime_h_LDADD = $(LDADD) +test_utime_h_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_utimens_SOURCES = test-utimens.c +test_utimens_OBJECTS = test-utimens.$(OBJEXT) +test_utimens_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +test_utimensat_SOURCES = test-utimensat.c +test_utimensat_OBJECTS = test-utimensat.$(OBJEXT) +test_utimensat_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +test_vasnprintf_SOURCES = test-vasnprintf.c +test_vasnprintf_OBJECTS = test-vasnprintf.$(OBJEXT) +test_vasnprintf_LDADD = $(LDADD) +test_vasnprintf_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_vasprintf_SOURCES = test-vasprintf.c +test_vasprintf_OBJECTS = test-vasprintf.$(OBJEXT) +test_vasprintf_LDADD = $(LDADD) +test_vasprintf_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_vasprintf_posix_SOURCES = test-vasprintf-posix.c +test_vasprintf_posix_OBJECTS = test-vasprintf-posix.$(OBJEXT) +test_vasprintf_posix_LDADD = $(LDADD) +test_vasprintf_posix_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_verify_SOURCES = test-verify.c +test_verify_OBJECTS = test-verify.$(OBJEXT) +test_verify_LDADD = $(LDADD) +test_verify_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_verify_try_SOURCES = test-verify-try.c +test_verify_try_OBJECTS = test-verify-try.$(OBJEXT) +test_verify_try_LDADD = $(LDADD) +test_verify_try_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_version_etc_SOURCES = test-version-etc.c +test_version_etc_OBJECTS = test-version-etc.$(OBJEXT) +test_version_etc_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_vfprintf_posix_SOURCES = test-vfprintf-posix.c +test_vfprintf_posix_OBJECTS = test-vfprintf-posix.$(OBJEXT) +test_vfprintf_posix_LDADD = $(LDADD) +test_vfprintf_posix_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_vprintf_posix_SOURCES = test-vprintf-posix.c +test_vprintf_posix_OBJECTS = test-vprintf-posix.$(OBJEXT) +test_vprintf_posix_LDADD = $(LDADD) +test_vprintf_posix_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_wchar_SOURCES = test-wchar.c +test_wchar_OBJECTS = test-wchar.$(OBJEXT) +test_wchar_LDADD = $(LDADD) +test_wchar_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_wcrtomb_SOURCES = test-wcrtomb.c +test_wcrtomb_OBJECTS = test-wcrtomb.$(OBJEXT) +test_wcrtomb_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_wcrtomb_w32_SOURCES = test-wcrtomb-w32.c +test_wcrtomb_w32_OBJECTS = test-wcrtomb-w32.$(OBJEXT) +test_wcrtomb_w32_LDADD = $(LDADD) +test_wcrtomb_w32_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_wctype_h_SOURCES = test-wctype-h.c +test_wctype_h_OBJECTS = test-wctype-h.$(OBJEXT) +test_wctype_h_LDADD = $(LDADD) +test_wctype_h_DEPENDENCIES = libtests.a ../lib/libcoreutils.a \ + libtests.a $(am__DEPENDENCIES_1) +test_wcwidth_SOURCES = test-wcwidth.c +test_wcwidth_OBJECTS = test-wcwidth.$(OBJEXT) +test_wcwidth_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_1) +test_write_SOURCES = test-write.c +test_write_OBJECTS = test-write.$(OBJEXT) +test_write_LDADD = $(LDADD) +test_write_DEPENDENCIES = libtests.a ../lib/libcoreutils.a libtests.a \ + $(am__DEPENDENCIES_1) +test_xalloc_die_SOURCES = test-xalloc-die.c +test_xalloc_die_OBJECTS = test-xalloc-die.$(OBJEXT) +test_xalloc_die_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_xfprintf_posix_SOURCES = test-xfprintf-posix.c +test_xfprintf_posix_OBJECTS = test-xfprintf-posix.$(OBJEXT) +test_xfprintf_posix_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_xprintf_posix_SOURCES = test-xprintf-posix.c +test_xprintf_posix_OBJECTS = test-xprintf-posix.$(OBJEXT) +test_xprintf_posix_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_xstrtoimax_SOURCES = test-xstrtoimax.c +test_xstrtoimax_OBJECTS = test-xstrtoimax.$(OBJEXT) +test_xstrtoimax_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_xstrtol_SOURCES = test-xstrtol.c +test_xstrtol_OBJECTS = test-xstrtol.$(OBJEXT) +test_xstrtol_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_xstrtoul_SOURCES = test-xstrtoul.c +test_xstrtoul_OBJECTS = test-xstrtoul.$(OBJEXT) +test_xstrtoul_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_xstrtoumax_SOURCES = test-xstrtoumax.c +test_xstrtoumax_OBJECTS = test-xstrtoumax.$(OBJEXT) +test_xstrtoumax_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_xvasprintf_SOURCES = test-xvasprintf.c +test_xvasprintf_OBJECTS = test_xvasprintf-test-xvasprintf.$(OBJEXT) +test_xvasprintf_DEPENDENCIES = $(am__DEPENDENCIES_2) +test_xvasprintf_LINK = $(CCLD) $(test_xvasprintf_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +test_yesno_SOURCES = test-yesno.c +test_yesno_OBJECTS = test-yesno.$(OBJEXT) +test_yesno_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/lib +depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/accept.Po ./$(DEPDIR)/bench-md5.Po \ + ./$(DEPDIR)/bench-sha1.Po ./$(DEPDIR)/bench-sha224.Po \ + ./$(DEPDIR)/bench-sha256.Po ./$(DEPDIR)/bench-sha384.Po \ + ./$(DEPDIR)/bench-sha512.Po ./$(DEPDIR)/bind.Po \ + ./$(DEPDIR)/connect.Po ./$(DEPDIR)/getrusage.Po \ + ./$(DEPDIR)/inet_pton.Po ./$(DEPDIR)/ioctl.Po \ + ./$(DEPDIR)/listen.Po ./$(DEPDIR)/locale.Po \ + ./$(DEPDIR)/localename-table.Po ./$(DEPDIR)/localename.Po \ + ./$(DEPDIR)/perror.Po ./$(DEPDIR)/randomd.Po \ + ./$(DEPDIR)/randoml.Po ./$(DEPDIR)/sched_yield.Po \ + ./$(DEPDIR)/secure_getenv.Po ./$(DEPDIR)/setlocale.Po \ + ./$(DEPDIR)/setsockopt.Po ./$(DEPDIR)/sleep.Po \ + ./$(DEPDIR)/socket.Po ./$(DEPDIR)/strerror_r.Po \ + ./$(DEPDIR)/test-accept.Po ./$(DEPDIR)/test-alignof.Po \ + ./$(DEPDIR)/test-alloca-opt.Po \ + ./$(DEPDIR)/test-areadlink-with-size.Po \ + ./$(DEPDIR)/test-areadlink.Po ./$(DEPDIR)/test-areadlinkat.Po \ + ./$(DEPDIR)/test-argmatch.Po ./$(DEPDIR)/test-argv-iter.Po \ + ./$(DEPDIR)/test-arpa_inet.Po ./$(DEPDIR)/test-base32.Po \ + ./$(DEPDIR)/test-base64.Po ./$(DEPDIR)/test-binary-io.Po \ + ./$(DEPDIR)/test-bind.Po ./$(DEPDIR)/test-bitrotate.Po \ + ./$(DEPDIR)/test-btowc.Po ./$(DEPDIR)/test-byteswap.Po \ + ./$(DEPDIR)/test-c-ctype.Po ./$(DEPDIR)/test-c-strcasecmp.Po \ + ./$(DEPDIR)/test-c-strncasecmp.Po \ + ./$(DEPDIR)/test-calloc-gnu.Po \ + ./$(DEPDIR)/test-canonicalize.Po ./$(DEPDIR)/test-chdir.Po \ + ./$(DEPDIR)/test-chown.Po ./$(DEPDIR)/test-cloexec.Po \ + ./$(DEPDIR)/test-close.Po ./$(DEPDIR)/test-closein.Po \ + ./$(DEPDIR)/test-connect.Po ./$(DEPDIR)/test-copy-acl.Po \ + ./$(DEPDIR)/test-count-leading-zeros.Po \ + ./$(DEPDIR)/test-ctype.Po ./$(DEPDIR)/test-di-set.Po \ + ./$(DEPDIR)/test-dirent-safer.Po ./$(DEPDIR)/test-dirent.Po \ + ./$(DEPDIR)/test-dirname.Po ./$(DEPDIR)/test-dup-safer.Po \ + ./$(DEPDIR)/test-dup.Po ./$(DEPDIR)/test-dup2.Po \ + ./$(DEPDIR)/test-environ.Po ./$(DEPDIR)/test-errno.Po \ + ./$(DEPDIR)/test-exclude.Po ./$(DEPDIR)/test-faccessat.Po \ + ./$(DEPDIR)/test-fadvise.Po ./$(DEPDIR)/test-fchdir.Po \ + ./$(DEPDIR)/test-fchmodat.Po ./$(DEPDIR)/test-fchownat.Po \ + ./$(DEPDIR)/test-fclose.Po ./$(DEPDIR)/test-fcntl-h.Po \ + ./$(DEPDIR)/test-fcntl-safer.Po ./$(DEPDIR)/test-fcntl.Po \ + ./$(DEPDIR)/test-fdatasync.Po ./$(DEPDIR)/test-fdopen.Po \ + ./$(DEPDIR)/test-fdopendir.Po ./$(DEPDIR)/test-fdutimensat.Po \ + ./$(DEPDIR)/test-fflush.Po ./$(DEPDIR)/test-fflush2.Po \ + ./$(DEPDIR)/test-fgetc.Po ./$(DEPDIR)/test-file-has-acl.Po \ + ./$(DEPDIR)/test-filenamecat.Po ./$(DEPDIR)/test-filevercmp.Po \ + ./$(DEPDIR)/test-float.Po ./$(DEPDIR)/test-fnmatch-h.Po \ + ./$(DEPDIR)/test-fnmatch.Po ./$(DEPDIR)/test-fopen-safer.Po \ + ./$(DEPDIR)/test-fopen.Po ./$(DEPDIR)/test-fpending.Po \ + ./$(DEPDIR)/test-fpurge.Po ./$(DEPDIR)/test-fputc.Po \ + ./$(DEPDIR)/test-fread.Po ./$(DEPDIR)/test-freadahead.Po \ + ./$(DEPDIR)/test-freading.Po ./$(DEPDIR)/test-freadptr.Po \ + ./$(DEPDIR)/test-freadptr2.Po ./$(DEPDIR)/test-freadseek.Po \ + ./$(DEPDIR)/test-freopen-safer.Po ./$(DEPDIR)/test-freopen.Po \ + ./$(DEPDIR)/test-frexp.Po ./$(DEPDIR)/test-frexpl.Po \ + ./$(DEPDIR)/test-fseek.Po ./$(DEPDIR)/test-fseeko.Po \ + ./$(DEPDIR)/test-fseeko3.Po ./$(DEPDIR)/test-fseeko4.Po \ + ./$(DEPDIR)/test-fseterr.Po ./$(DEPDIR)/test-fstat.Po \ + ./$(DEPDIR)/test-fstatat.Po ./$(DEPDIR)/test-fsync.Po \ + ./$(DEPDIR)/test-ftell.Po ./$(DEPDIR)/test-ftell3.Po \ + ./$(DEPDIR)/test-ftello.Po ./$(DEPDIR)/test-ftello3.Po \ + ./$(DEPDIR)/test-ftello4.Po ./$(DEPDIR)/test-ftruncate.Po \ + ./$(DEPDIR)/test-futimens.Po ./$(DEPDIR)/test-fwrite.Po \ + ./$(DEPDIR)/test-getaddrinfo.Po \ + ./$(DEPDIR)/test-getcwd-lgpl.Po ./$(DEPDIR)/test-getcwd.Po \ + ./$(DEPDIR)/test-getdelim.Po ./$(DEPDIR)/test-getdtablesize.Po \ + ./$(DEPDIR)/test-getgroups.Po ./$(DEPDIR)/test-gethostname.Po \ + ./$(DEPDIR)/test-getline.Po ./$(DEPDIR)/test-getloadavg.Po \ + ./$(DEPDIR)/test-getlogin.Po ./$(DEPDIR)/test-getndelim2.Po \ + ./$(DEPDIR)/test-getopt-gnu.Po \ + ./$(DEPDIR)/test-getopt-posix.Po \ + ./$(DEPDIR)/test-getprogname.Po ./$(DEPDIR)/test-getrusage.Po \ + ./$(DEPDIR)/test-gettimeofday.Po \ + ./$(DEPDIR)/test-hard-locale.Po ./$(DEPDIR)/test-hash.Po \ + ./$(DEPDIR)/test-i-ring.Po ./$(DEPDIR)/test-iconv-h.Po \ + ./$(DEPDIR)/test-iconv.Po ./$(DEPDIR)/test-ignore-value.Po \ + ./$(DEPDIR)/test-inet_ntop.Po ./$(DEPDIR)/test-inet_pton.Po \ + ./$(DEPDIR)/test-ino-map.Po ./$(DEPDIR)/test-intprops.Po \ + ./$(DEPDIR)/test-inttostr.Po ./$(DEPDIR)/test-inttypes.Po \ + ./$(DEPDIR)/test-ioctl.Po ./$(DEPDIR)/test-isatty.Po \ + ./$(DEPDIR)/test-isblank.Po ./$(DEPDIR)/test-isnand-nolibm.Po \ + ./$(DEPDIR)/test-isnanf-nolibm.Po \ + ./$(DEPDIR)/test-isnanl-nolibm.Po ./$(DEPDIR)/test-iswblank.Po \ + ./$(DEPDIR)/test-iswdigit.Po ./$(DEPDIR)/test-iswxdigit.Po \ + ./$(DEPDIR)/test-langinfo.Po ./$(DEPDIR)/test-lchmod.Po \ + ./$(DEPDIR)/test-lchown.Po ./$(DEPDIR)/test-limits-h.Po \ + ./$(DEPDIR)/test-link.Po ./$(DEPDIR)/test-linkat.Po \ + ./$(DEPDIR)/test-listen.Po ./$(DEPDIR)/test-localcharset.Po \ + ./$(DEPDIR)/test-locale.Po ./$(DEPDIR)/test-localeconv.Po \ + ./$(DEPDIR)/test-localename.Po ./$(DEPDIR)/test-lseek.Po \ + ./$(DEPDIR)/test-lstat.Po ./$(DEPDIR)/test-malloc-gnu.Po \ + ./$(DEPDIR)/test-malloca.Po ./$(DEPDIR)/test-math.Po \ + ./$(DEPDIR)/test-mbrtowc-w32.Po ./$(DEPDIR)/test-mbrtowc.Po \ + ./$(DEPDIR)/test-mbsalign.Po ./$(DEPDIR)/test-mbscasecmp.Po \ + ./$(DEPDIR)/test-mbschr.Po ./$(DEPDIR)/test-mbsinit.Po \ + ./$(DEPDIR)/test-mbsrtowcs.Po ./$(DEPDIR)/test-mbsstr1.Po \ + ./$(DEPDIR)/test-mbsstr2.Po ./$(DEPDIR)/test-mbsstr3.Po \ + ./$(DEPDIR)/test-md5.Po ./$(DEPDIR)/test-memcasecmp.Po \ + ./$(DEPDIR)/test-memchr.Po ./$(DEPDIR)/test-memchr2.Po \ + ./$(DEPDIR)/test-memcoll.Po ./$(DEPDIR)/test-memrchr.Po \ + ./$(DEPDIR)/test-mkdir.Po ./$(DEPDIR)/test-mkfifo.Po \ + ./$(DEPDIR)/test-mknod.Po ./$(DEPDIR)/test-nanosleep.Po \ + ./$(DEPDIR)/test-netdb.Po ./$(DEPDIR)/test-netinet_in.Po \ + ./$(DEPDIR)/test-nl_langinfo-mt.Po \ + ./$(DEPDIR)/test-nl_langinfo.Po ./$(DEPDIR)/test-nstrftime.Po \ + ./$(DEPDIR)/test-once.Po ./$(DEPDIR)/test-open.Po \ + ./$(DEPDIR)/test-openat-safer.Po ./$(DEPDIR)/test-openat.Po \ + ./$(DEPDIR)/test-parse-datetime.Po ./$(DEPDIR)/test-pathmax.Po \ + ./$(DEPDIR)/test-perror.Po ./$(DEPDIR)/test-perror2.Po \ + ./$(DEPDIR)/test-pipe.Po ./$(DEPDIR)/test-pipe2.Po \ + ./$(DEPDIR)/test-posixtm.Po ./$(DEPDIR)/test-printf-frexp.Po \ + ./$(DEPDIR)/test-printf-frexpl.Po ./$(DEPDIR)/test-priv-set.Po \ + ./$(DEPDIR)/test-pthread-cond.Po \ + ./$(DEPDIR)/test-pthread-mutex.Po \ + ./$(DEPDIR)/test-pthread-thread.Po ./$(DEPDIR)/test-pthread.Po \ + ./$(DEPDIR)/test-pthread_sigmask1.Po \ + ./$(DEPDIR)/test-pthread_sigmask2.Po \ + ./$(DEPDIR)/test-quotearg-simple.Po ./$(DEPDIR)/test-raise.Po \ + ./$(DEPDIR)/test-rand-isaac.Po ./$(DEPDIR)/test-read-file.Po \ + ./$(DEPDIR)/test-read.Po ./$(DEPDIR)/test-readlink.Po \ + ./$(DEPDIR)/test-readlinkat.Po ./$(DEPDIR)/test-readtokens.Po \ + ./$(DEPDIR)/test-realloc-gnu.Po ./$(DEPDIR)/test-regex.Po \ + ./$(DEPDIR)/test-remove.Po ./$(DEPDIR)/test-rename.Po \ + ./$(DEPDIR)/test-renameat.Po ./$(DEPDIR)/test-renameatu.Po \ + ./$(DEPDIR)/test-rmdir.Po ./$(DEPDIR)/test-rwlock1.Po \ + ./$(DEPDIR)/test-sameacls.Po ./$(DEPDIR)/test-sched.Po \ + ./$(DEPDIR)/test-select-fd.Po ./$(DEPDIR)/test-select-stdin.Po \ + ./$(DEPDIR)/test-select.Po ./$(DEPDIR)/test-set-mode-acl.Po \ + ./$(DEPDIR)/test-setenv.Po ./$(DEPDIR)/test-setlocale1.Po \ + ./$(DEPDIR)/test-setlocale2.Po \ + ./$(DEPDIR)/test-setlocale_null-mt-all.Po \ + ./$(DEPDIR)/test-setlocale_null-mt-one.Po \ + ./$(DEPDIR)/test-setlocale_null.Po \ + ./$(DEPDIR)/test-setsockopt.Po ./$(DEPDIR)/test-sha1.Po \ + ./$(DEPDIR)/test-sha256.Po ./$(DEPDIR)/test-sha512.Po \ + ./$(DEPDIR)/test-sigaction.Po ./$(DEPDIR)/test-signal-h.Po \ + ./$(DEPDIR)/test-signbit.Po ./$(DEPDIR)/test-sigprocmask.Po \ + ./$(DEPDIR)/test-sleep.Po ./$(DEPDIR)/test-snprintf.Po \ + ./$(DEPDIR)/test-sockets.Po ./$(DEPDIR)/test-stat-time.Po \ + ./$(DEPDIR)/test-stat.Po ./$(DEPDIR)/test-statat.Po \ + ./$(DEPDIR)/test-stdalign.Po ./$(DEPDIR)/test-stdbool.Po \ + ./$(DEPDIR)/test-stddef.Po ./$(DEPDIR)/test-stdint.Po \ + ./$(DEPDIR)/test-stdio.Po ./$(DEPDIR)/test-stdlib.Po \ + ./$(DEPDIR)/test-strerror.Po ./$(DEPDIR)/test-strerror_r.Po \ + ./$(DEPDIR)/test-striconv.Po ./$(DEPDIR)/test-string.Po \ + ./$(DEPDIR)/test-strncat.Po ./$(DEPDIR)/test-strnlen.Po \ + ./$(DEPDIR)/test-strsignal.Po ./$(DEPDIR)/test-strtod.Po \ + ./$(DEPDIR)/test-strtod1.Po ./$(DEPDIR)/test-strtoimax.Po \ + ./$(DEPDIR)/test-strtold.Po ./$(DEPDIR)/test-strtold1.Po \ + ./$(DEPDIR)/test-strtoll.Po ./$(DEPDIR)/test-strtoull.Po \ + ./$(DEPDIR)/test-strtoumax.Po ./$(DEPDIR)/test-symlink.Po \ + ./$(DEPDIR)/test-symlinkat.Po ./$(DEPDIR)/test-sys_ioctl.Po \ + ./$(DEPDIR)/test-sys_resource.Po \ + ./$(DEPDIR)/test-sys_select.Po ./$(DEPDIR)/test-sys_socket.Po \ + ./$(DEPDIR)/test-sys_stat.Po ./$(DEPDIR)/test-sys_time.Po \ + ./$(DEPDIR)/test-sys_types.Po ./$(DEPDIR)/test-sys_uio.Po \ + ./$(DEPDIR)/test-sys_utsname.Po ./$(DEPDIR)/test-sys_wait.Po \ + ./$(DEPDIR)/test-termios.Po ./$(DEPDIR)/test-thread_create.Po \ + ./$(DEPDIR)/test-thread_self.Po ./$(DEPDIR)/test-time.Po \ + ./$(DEPDIR)/test-timespec.Po ./$(DEPDIR)/test-u64.Po \ + ./$(DEPDIR)/test-uname.Po ./$(DEPDIR)/test-unistd.Po \ + ./$(DEPDIR)/test-unlink.Po ./$(DEPDIR)/test-unlinkat.Po \ + ./$(DEPDIR)/test-unsetenv.Po ./$(DEPDIR)/test-userspec.Po \ + ./$(DEPDIR)/test-usleep.Po ./$(DEPDIR)/test-utime-h.Po \ + ./$(DEPDIR)/test-utime.Po ./$(DEPDIR)/test-utimens.Po \ + ./$(DEPDIR)/test-utimensat.Po ./$(DEPDIR)/test-vasnprintf.Po \ + ./$(DEPDIR)/test-vasprintf-posix.Po \ + ./$(DEPDIR)/test-vasprintf.Po ./$(DEPDIR)/test-verify-try.Po \ + ./$(DEPDIR)/test-verify.Po ./$(DEPDIR)/test-version-etc.Po \ + ./$(DEPDIR)/test-vfprintf-posix.Po \ + ./$(DEPDIR)/test-vprintf-posix.Po ./$(DEPDIR)/test-wchar.Po \ + ./$(DEPDIR)/test-wcrtomb-w32.Po ./$(DEPDIR)/test-wcrtomb.Po \ + ./$(DEPDIR)/test-wctype-h.Po ./$(DEPDIR)/test-wcwidth.Po \ + ./$(DEPDIR)/test-write.Po ./$(DEPDIR)/test-xalloc-die.Po \ + ./$(DEPDIR)/test-xfprintf-posix.Po \ + ./$(DEPDIR)/test-xprintf-posix.Po \ + ./$(DEPDIR)/test-xstrtoimax.Po ./$(DEPDIR)/test-xstrtol.Po \ + ./$(DEPDIR)/test-xstrtoul.Po ./$(DEPDIR)/test-xstrtoumax.Po \ + ./$(DEPDIR)/test-yesno.Po ./$(DEPDIR)/test_lock-test-lock.Po \ + ./$(DEPDIR)/test_tls-test-tls.Po \ + ./$(DEPDIR)/test_xvasprintf-test-xvasprintf.Po \ + ./$(DEPDIR)/timespec-add.Po ./$(DEPDIR)/timespec-sub.Po \ + ./$(DEPDIR)/tmpdir.Po ./$(DEPDIR)/tmpfile.Po \ + ./$(DEPDIR)/usleep.Po ./$(DEPDIR)/wctob.Po \ + ./$(DEPDIR)/wctomb.Po glthread/$(DEPDIR)/thread.Po \ + unistr/$(DEPDIR)/test-u8-mbtoucr.Po \ + unistr/$(DEPDIR)/test-u8-uctomb.Po \ + uniwidth/$(DEPDIR)/test-uc_width.Po \ + uniwidth/$(DEPDIR)/test-uc_width2.Po +am__mv = mv -f +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(libtests_a_SOURCES) $(EXTRA_libtests_a_SOURCES) \ + bench-md5.c bench-sha1.c bench-sha224.c bench-sha256.c \ + bench-sha384.c bench-sha512.c $(current_locale_SOURCES) \ + test-accept.c test-alignof.c test-alloca-opt.c \ + test-areadlink.c test-areadlink-with-size.c test-areadlinkat.c \ + test-argmatch.c test-argv-iter.c test-arpa_inet.c \ + test-base32.c test-base64.c test-binary-io.c test-bind.c \ + test-bitrotate.c test-btowc.c test-byteswap.c test-c-ctype.c \ + test-c-strcasecmp.c test-c-strncasecmp.c test-calloc-gnu.c \ + test-canonicalize.c test-chdir.c test-chown.c test-cloexec.c \ + test-close.c test-closein.c test-connect.c test-copy-acl.c \ + test-count-leading-zeros.c test-ctype.c test-di-set.c \ + test-dirent.c test-dirent-safer.c test-dirname.c test-dup.c \ + test-dup-safer.c test-dup2.c test-environ.c test-errno.c \ + test-exclude.c test-faccessat.c test-fadvise.c test-fchdir.c \ + test-fchmodat.c test-fchownat.c test-fclose.c test-fcntl.c \ + test-fcntl-h.c test-fcntl-safer.c test-fdatasync.c \ + test-fdopen.c test-fdopendir.c test-fdutimensat.c \ + test-fflush.c test-fflush2.c test-fgetc.c test-file-has-acl.c \ + test-filenamecat.c test-filevercmp.c test-float.c \ + test-fnmatch.c test-fnmatch-h.c test-fopen.c \ + test-fopen-safer.c test-fpending.c test-fpurge.c test-fputc.c \ + test-fread.c test-freadahead.c test-freading.c test-freadptr.c \ + test-freadptr2.c test-freadseek.c test-freopen.c \ + test-freopen-safer.c $(test_frexp_nolibm_SOURCES) \ + $(test_frexpl_nolibm_SOURCES) test-fseek.c test-fseeko.c \ + test-fseeko3.c test-fseeko4.c test-fseterr.c test-fstat.c \ + test-fstatat.c test-fsync.c test-ftell.c test-ftell3.c \ + test-ftello.c test-ftello3.c test-ftello4.c test-ftruncate.c \ + test-futimens.c test-fwrite.c test-getaddrinfo.c test-getcwd.c \ + test-getcwd-lgpl.c test-getdelim.c test-getdtablesize.c \ + test-getgroups.c test-gethostname.c test-getline.c \ + test-getloadavg.c test-getlogin.c test-getndelim2.c \ + test-getopt-gnu.c test-getopt-posix.c test-getprogname.c \ + test-getrusage.c test-gettimeofday.c test-hard-locale.c \ + test-hash.c test-i-ring.c test-iconv.c test-iconv-h.c \ + test-ignore-value.c test-inet_ntop.c test-inet_pton.c \ + test-ino-map.c test-intprops.c test-inttostr.c test-inttypes.c \ + test-ioctl.c test-isatty.c test-isblank.c test-isnand-nolibm.c \ + test-isnanf-nolibm.c test-isnanl-nolibm.c test-iswblank.c \ + test-iswdigit.c test-iswxdigit.c test-langinfo.c test-lchmod.c \ + test-lchown.c test-limits-h.c test-link.c test-linkat.c \ + test-listen.c test-localcharset.c test-locale.c \ + test-localeconv.c test-localename.c test-lock.c test-lseek.c \ + test-lstat.c test-malloc-gnu.c test-malloca.c test-math.c \ + test-mbrtowc.c test-mbrtowc-w32.c test-mbsalign.c \ + test-mbscasecmp.c test-mbschr.c test-mbsinit.c \ + test-mbsrtowcs.c test-mbsstr1.c test-mbsstr2.c test-mbsstr3.c \ + test-md5.c test-memcasecmp.c test-memchr.c test-memchr2.c \ + test-memcoll.c test-memrchr.c test-mkdir.c test-mkfifo.c \ + test-mknod.c test-nanosleep.c test-netdb.c test-netinet_in.c \ + test-nl_langinfo.c test-nl_langinfo-mt.c test-nstrftime.c \ + $(test_once1_SOURCES) $(test_once2_SOURCES) test-open.c \ + test-openat.c test-openat-safer.c test-parse-datetime.c \ + test-pathmax.c test-perror.c test-perror2.c test-pipe.c \ + test-pipe2.c test-posixtm.c test-printf-frexp.c \ + test-printf-frexpl.c test-priv-set.c test-pthread.c \ + test-pthread-cond.c test-pthread-mutex.c test-pthread-thread.c \ + test-pthread_sigmask1.c test-pthread_sigmask2.c \ + test-quotearg-simple.c test-raise.c test-rand-isaac.c \ + test-read.c test-read-file.c test-readlink.c test-readlinkat.c \ + test-readtokens.c test-realloc-gnu.c test-regex.c \ + test-remove.c test-rename.c test-renameat.c test-renameatu.c \ + test-rmdir.c test-rwlock1.c test-sameacls.c test-sched.c \ + test-select.c test-select-fd.c test-select-stdin.c \ + test-set-mode-acl.c test-setenv.c test-setlocale1.c \ + test-setlocale2.c test-setlocale_null.c \ + test-setlocale_null-mt-all.c test-setlocale_null-mt-one.c \ + test-setsockopt.c test-sha1.c test-sha256.c test-sha512.c \ + test-sigaction.c test-signal-h.c test-signbit.c \ + test-sigprocmask.c test-sleep.c test-snprintf.c test-sockets.c \ + test-stat.c test-stat-time.c test-statat.c test-stdalign.c \ + test-stdbool.c test-stddef.c test-stdint.c test-stdio.c \ + test-stdlib.c test-strerror.c test-strerror_r.c \ + test-striconv.c test-string.c test-strncat.c test-strnlen.c \ + test-strsignal.c test-strtod.c test-strtod1.c test-strtoimax.c \ + test-strtold.c test-strtold1.c test-strtoll.c test-strtoull.c \ + test-strtoumax.c test-symlink.c test-symlinkat.c \ + test-sys_ioctl.c test-sys_resource.c test-sys_select.c \ + test-sys_socket.c test-sys_stat.c test-sys_time.c \ + test-sys_types.c test-sys_uio.c test-sys_utsname.c \ + test-sys_wait.c test-termios.c test-thread_create.c \ + test-thread_self.c test-time.c test-timespec.c test-tls.c \ + test-u64.c $(test_u8_mbtoucr_SOURCES) \ + $(test_u8_uctomb_SOURCES) $(test_uc_width_SOURCES) \ + $(test_uc_width2_SOURCES) test-uname.c test-unistd.c \ + test-unlink.c test-unlinkat.c test-unsetenv.c test-userspec.c \ + test-usleep.c test-utime.c test-utime-h.c test-utimens.c \ + test-utimensat.c test-vasnprintf.c test-vasprintf.c \ + test-vasprintf-posix.c test-verify.c test-verify-try.c \ + test-version-etc.c test-vfprintf-posix.c test-vprintf-posix.c \ + test-wchar.c test-wcrtomb.c test-wcrtomb-w32.c test-wctype-h.c \ + test-wcwidth.c test-write.c test-xalloc-die.c \ + test-xfprintf-posix.c test-xprintf-posix.c test-xstrtoimax.c \ + test-xstrtol.c test-xstrtoul.c test-xstrtoumax.c \ + test-xvasprintf.c test-yesno.c +DIST_SOURCES = $(libtests_a_SOURCES) $(EXTRA_libtests_a_SOURCES) \ + bench-md5.c bench-sha1.c bench-sha224.c bench-sha256.c \ + bench-sha384.c bench-sha512.c $(current_locale_SOURCES) \ + test-accept.c test-alignof.c test-alloca-opt.c \ + test-areadlink.c test-areadlink-with-size.c test-areadlinkat.c \ + test-argmatch.c test-argv-iter.c test-arpa_inet.c \ + test-base32.c test-base64.c test-binary-io.c test-bind.c \ + test-bitrotate.c test-btowc.c test-byteswap.c test-c-ctype.c \ + test-c-strcasecmp.c test-c-strncasecmp.c test-calloc-gnu.c \ + test-canonicalize.c test-chdir.c test-chown.c test-cloexec.c \ + test-close.c test-closein.c test-connect.c test-copy-acl.c \ + test-count-leading-zeros.c test-ctype.c test-di-set.c \ + test-dirent.c test-dirent-safer.c test-dirname.c test-dup.c \ + test-dup-safer.c test-dup2.c test-environ.c test-errno.c \ + test-exclude.c test-faccessat.c test-fadvise.c test-fchdir.c \ + test-fchmodat.c test-fchownat.c test-fclose.c test-fcntl.c \ + test-fcntl-h.c test-fcntl-safer.c test-fdatasync.c \ + test-fdopen.c test-fdopendir.c test-fdutimensat.c \ + test-fflush.c test-fflush2.c test-fgetc.c test-file-has-acl.c \ + test-filenamecat.c test-filevercmp.c test-float.c \ + test-fnmatch.c test-fnmatch-h.c test-fopen.c \ + test-fopen-safer.c test-fpending.c test-fpurge.c test-fputc.c \ + test-fread.c test-freadahead.c test-freading.c test-freadptr.c \ + test-freadptr2.c test-freadseek.c test-freopen.c \ + test-freopen-safer.c $(test_frexp_nolibm_SOURCES) \ + $(test_frexpl_nolibm_SOURCES) test-fseek.c test-fseeko.c \ + test-fseeko3.c test-fseeko4.c test-fseterr.c test-fstat.c \ + test-fstatat.c test-fsync.c test-ftell.c test-ftell3.c \ + test-ftello.c test-ftello3.c test-ftello4.c test-ftruncate.c \ + test-futimens.c test-fwrite.c test-getaddrinfo.c test-getcwd.c \ + test-getcwd-lgpl.c test-getdelim.c test-getdtablesize.c \ + test-getgroups.c test-gethostname.c test-getline.c \ + test-getloadavg.c test-getlogin.c test-getndelim2.c \ + test-getopt-gnu.c test-getopt-posix.c test-getprogname.c \ + test-getrusage.c test-gettimeofday.c test-hard-locale.c \ + test-hash.c test-i-ring.c test-iconv.c test-iconv-h.c \ + test-ignore-value.c test-inet_ntop.c test-inet_pton.c \ + test-ino-map.c test-intprops.c test-inttostr.c test-inttypes.c \ + test-ioctl.c test-isatty.c test-isblank.c test-isnand-nolibm.c \ + test-isnanf-nolibm.c test-isnanl-nolibm.c test-iswblank.c \ + test-iswdigit.c test-iswxdigit.c test-langinfo.c test-lchmod.c \ + test-lchown.c test-limits-h.c test-link.c test-linkat.c \ + test-listen.c test-localcharset.c test-locale.c \ + test-localeconv.c test-localename.c test-lock.c test-lseek.c \ + test-lstat.c test-malloc-gnu.c test-malloca.c test-math.c \ + test-mbrtowc.c test-mbrtowc-w32.c test-mbsalign.c \ + test-mbscasecmp.c test-mbschr.c test-mbsinit.c \ + test-mbsrtowcs.c test-mbsstr1.c test-mbsstr2.c test-mbsstr3.c \ + test-md5.c test-memcasecmp.c test-memchr.c test-memchr2.c \ + test-memcoll.c test-memrchr.c test-mkdir.c test-mkfifo.c \ + test-mknod.c test-nanosleep.c test-netdb.c test-netinet_in.c \ + test-nl_langinfo.c test-nl_langinfo-mt.c test-nstrftime.c \ + $(test_once1_SOURCES) $(test_once2_SOURCES) test-open.c \ + test-openat.c test-openat-safer.c test-parse-datetime.c \ + test-pathmax.c test-perror.c test-perror2.c test-pipe.c \ + test-pipe2.c test-posixtm.c test-printf-frexp.c \ + test-printf-frexpl.c test-priv-set.c test-pthread.c \ + test-pthread-cond.c test-pthread-mutex.c test-pthread-thread.c \ + test-pthread_sigmask1.c test-pthread_sigmask2.c \ + test-quotearg-simple.c test-raise.c test-rand-isaac.c \ + test-read.c test-read-file.c test-readlink.c test-readlinkat.c \ + test-readtokens.c test-realloc-gnu.c test-regex.c \ + test-remove.c test-rename.c test-renameat.c test-renameatu.c \ + test-rmdir.c test-rwlock1.c test-sameacls.c test-sched.c \ + test-select.c test-select-fd.c test-select-stdin.c \ + test-set-mode-acl.c test-setenv.c test-setlocale1.c \ + test-setlocale2.c test-setlocale_null.c \ + test-setlocale_null-mt-all.c test-setlocale_null-mt-one.c \ + test-setsockopt.c test-sha1.c test-sha256.c test-sha512.c \ + test-sigaction.c test-signal-h.c test-signbit.c \ + test-sigprocmask.c test-sleep.c test-snprintf.c test-sockets.c \ + test-stat.c test-stat-time.c test-statat.c test-stdalign.c \ + test-stdbool.c test-stddef.c test-stdint.c test-stdio.c \ + test-stdlib.c test-strerror.c test-strerror_r.c \ + test-striconv.c test-string.c test-strncat.c test-strnlen.c \ + test-strsignal.c test-strtod.c test-strtod1.c test-strtoimax.c \ + test-strtold.c test-strtold1.c test-strtoll.c test-strtoull.c \ + test-strtoumax.c test-symlink.c test-symlinkat.c \ + test-sys_ioctl.c test-sys_resource.c test-sys_select.c \ + test-sys_socket.c test-sys_stat.c test-sys_time.c \ + test-sys_types.c test-sys_uio.c test-sys_utsname.c \ + test-sys_wait.c test-termios.c test-thread_create.c \ + test-thread_self.c test-time.c test-timespec.c test-tls.c \ + test-u64.c $(test_u8_mbtoucr_SOURCES) \ + $(test_u8_uctomb_SOURCES) $(test_uc_width_SOURCES) \ + $(test_uc_width2_SOURCES) test-uname.c test-unistd.c \ + test-unlink.c test-unlinkat.c test-unsetenv.c test-userspec.c \ + test-usleep.c test-utime.c test-utime-h.c test-utimens.c \ + test-utimensat.c test-vasnprintf.c test-vasprintf.c \ + test-vasprintf-posix.c test-verify.c test-verify-try.c \ + test-version-etc.c test-vfprintf-posix.c test-vprintf-posix.c \ + test-wchar.c test-wcrtomb.c test-wcrtomb-w32.c test-wctype-h.c \ + test-wcwidth.c test-write.c test-xalloc-die.c \ + test-xfprintf-posix.c test-xprintf-posix.c test-xstrtoimax.c \ + test-xstrtol.c test-xstrtoul.c test-xstrtoumax.c \ + test-xvasprintf.c test-yesno.c +RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ + ctags-recursive dvi-recursive html-recursive info-recursive \ + install-data-recursive install-dvi-recursive \ + install-exec-recursive install-html-recursive \ + install-info-recursive install-pdf-recursive \ + install-ps-recursive install-recursive installcheck-recursive \ + installdirs-recursive pdf-recursive ps-recursive \ + tags-recursive uninstall-recursive +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +man1dir = $(mandir)/man1 +NROFF = nroff +MANS = $(man1_MANS) +HEADERS = $(noinst_HEADERS) +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +am__recursive_targets = \ + $(RECURSIVE_TARGETS) \ + $(RECURSIVE_CLEAN_TARGETS) \ + $(am__extra_recursive_targets) +AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ + check recheck distdir distdir-am +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +am__tty_colors_dummy = \ + mgn= red= grn= lgn= blu= brg= std=; \ + am__color_tests=no +am__tty_colors = { \ + $(am__tty_colors_dummy); \ + if test "X$(AM_COLOR_TESTS)" = Xno; then \ + am__color_tests=no; \ + elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ + am__color_tests=yes; \ + elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ + am__color_tests=yes; \ + fi; \ + if test $$am__color_tests = yes; then \ + red='[0;31m'; \ + grn='[0;32m'; \ + lgn='[1;32m'; \ + blu='[1;34m'; \ + mgn='[0;35m'; \ + brg='[1m'; \ + std='[m'; \ + fi; \ +} +am__recheck_rx = ^[ ]*:recheck:[ ]* +am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* +am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* +# A command that, given a newline-separated list of test names on the +# standard input, print the name of the tests that are to be re-run +# upon "make recheck". +am__list_recheck_tests = $(AWK) '{ \ + recheck = 1; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + { \ + if ((getline line2 < ($$0 ".log")) < 0) \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ + { \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ + { \ + break; \ + } \ + }; \ + if (recheck) \ + print $$0; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# A command that, given a newline-separated list of test names on the +# standard input, create the global log from their .trs and .log files. +am__create_global_log = $(AWK) ' \ +function fatal(msg) \ +{ \ + print "fatal: making $@: " msg | "cat >&2"; \ + exit 1; \ +} \ +function rst_section(header) \ +{ \ + print header; \ + len = length(header); \ + for (i = 1; i <= len; i = i + 1) \ + printf "="; \ + printf "\n\n"; \ +} \ +{ \ + copy_in_global_log = 1; \ + global_test_result = "RUN"; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".trs"); \ + if (line ~ /$(am__global_test_result_rx)/) \ + { \ + sub("$(am__global_test_result_rx)", "", line); \ + sub("[ ]*$$", "", line); \ + global_test_result = line; \ + } \ + else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ + copy_in_global_log = 0; \ + }; \ + if (copy_in_global_log) \ + { \ + rst_section(global_test_result ": " $$0); \ + while ((rc = (getline line < ($$0 ".log"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".log"); \ + print line; \ + }; \ + printf "\n"; \ + }; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# Restructured Text title. +am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } +# Solaris 10 'make', and several other traditional 'make' implementations, +# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it +# by disabling -e (using the XSI extension "set +e") if it's set. +am__sh_e_setup = case $$- in *e*) set +e;; esac +# Default flags passed to test drivers. +am__common_driver_flags = \ + --color-tests "$$am__color_tests" \ + --enable-hard-errors "$$am__enable_hard_errors" \ + --expect-failure "$$am__expect_failure" +# To be inserted before the command running the test. Creates the +# directory for the log if needed. Stores in $dir the directory +# containing $f, in $tst the test, in $log the log. Executes the +# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and +# passes TESTS_ENVIRONMENT. Set up options for the wrapper that +# will run the test scripts (or their associated LOG_COMPILER, if +# thy have one). +am__check_pre = \ +$(am__sh_e_setup); \ +$(am__vpath_adj_setup) $(am__vpath_adj) \ +$(am__tty_colors); \ +srcdir=$(srcdir); export srcdir; \ +case "$@" in \ + */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ + *) am__odir=.;; \ +esac; \ +test "x$$am__odir" = x"." || test -d "$$am__odir" \ + || $(MKDIR_P) "$$am__odir" || exit $$?; \ +if test -f "./$$f"; then dir=./; \ +elif test -f "$$f"; then dir=; \ +else dir="$(srcdir)/"; fi; \ +tst=$$dir$$f; log='$@'; \ +if test -n '$(DISABLE_HARD_ERRORS)'; then \ + am__enable_hard_errors=no; \ +else \ + am__enable_hard_errors=yes; \ +fi; \ +case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ + am__expect_failure=yes;; \ + *) \ + am__expect_failure=no;; \ +esac; \ +$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) +# A shell command to get the names of the tests scripts with any registered +# extension removed (i.e., equivalently, the names of the test logs, with +# the '.log' extension removed). The result is saved in the shell variable +# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, +# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", +# since that might cause problem with VPATH rewrites for suffix-less tests. +# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. +am__set_TESTS_bases = \ + bases='$(TEST_LOGS)'; \ + bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ + bases=`echo $$bases` +RECHECK_LOGS = $(TEST_LOGS) +TEST_SUITE_LOG = test-suite.log +TEST_EXTENSIONS = @EXEEXT@ .test +LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver +LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) +am__set_b = \ + case '$@' in \ + */*) \ + case '$*' in \ + */*) b='$*';; \ + *) b=`echo '$@' | sed 's/\.log$$//'`; \ + esac;; \ + *) \ + b='$*';; \ + esac +am__test_logs1 = $(TESTS:=.log) +am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) +TEST_LOGS = $(am__test_logs2:.test.log=.log) +TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver +TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ + $(TEST_LOG_FLAGS) +DIST_SUBDIRS = $(SUBDIRS) +am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/gnulib.mk \ + $(top_srcdir)/build-aux/depcomp \ + $(top_srcdir)/build-aux/test-driver +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +am__relativize = \ + dir0=`pwd`; \ + sed_first='s,^\([^/]*\)/.*$$,\1,'; \ + sed_rest='s,^[^/]*/*,,'; \ + sed_last='s,^.*/\([^/]*\)$$,\1,'; \ + sed_butlast='s,/*[^/]*$$,,'; \ + while test -n "$$dir1"; do \ + first=`echo "$$dir1" | sed -e "$$sed_first"`; \ + if test "$$first" != "."; then \ + if test "$$first" = ".."; then \ + dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ + dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ + else \ + first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ + if test "$$first2" = "$$first"; then \ + dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ + else \ + dir2="../$$dir2"; \ + fi; \ + dir0="$$dir0"/"$$first"; \ + fi; \ + fi; \ + dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ + done; \ + reldir="$$dir2" +pkglibexecdir = @pkglibexecdir@ +ACLOCAL = @ACLOCAL@ +ALLOCA = @ALLOCA@ +ALLOCA_H = @ALLOCA_H@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@ +AR = @AR@ +ARFLAGS = @ARFLAGS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BITSIZEOF_PTRDIFF_T = @BITSIZEOF_PTRDIFF_T@ +BITSIZEOF_SIG_ATOMIC_T = @BITSIZEOF_SIG_ATOMIC_T@ +BITSIZEOF_SIZE_T = @BITSIZEOF_SIZE_T@ +BITSIZEOF_WCHAR_T = @BITSIZEOF_WCHAR_T@ +BITSIZEOF_WINT_T = @BITSIZEOF_WINT_T@ +BYTESWAP_H = @BYTESWAP_H@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CFLAG_VISIBILITY = @CFLAG_VISIBILITY@ +CONFIG_INCLUDE = @CONFIG_INCLUDE@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFAULT_POSIX2_VERSION = @DEFAULT_POSIX2_VERSION@ +DEFS = @DEFS@ -DEXEEXT=\"@EXEEXT@\" +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EMULTIHOP_HIDDEN = @EMULTIHOP_HIDDEN@ +EMULTIHOP_VALUE = @EMULTIHOP_VALUE@ +ENOLINK_HIDDEN = @ENOLINK_HIDDEN@ +ENOLINK_VALUE = @ENOLINK_VALUE@ +EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@ +EOVERFLOW_VALUE = @EOVERFLOW_VALUE@ +ERRNO_H = @ERRNO_H@ +EXEEXT = @EXEEXT@ +FLOAT_H = @FLOAT_H@ +FNMATCH_H = @FNMATCH_H@ +GETADDRINFO_LIB = @GETADDRINFO_LIB@ +GETHOSTNAME_LIB = @GETHOSTNAME_LIB@ +GETLOADAVG_LIBS = @GETLOADAVG_LIBS@ +GETOPT_CDEFS_H = @GETOPT_CDEFS_H@ +GETOPT_H = @GETOPT_H@ +GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ +GLIBC21 = @GLIBC21@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GNULIB_ACCEPT = @GNULIB_ACCEPT@ +GNULIB_ACCEPT4 = @GNULIB_ACCEPT4@ +GNULIB_ACCESS = @GNULIB_ACCESS@ +GNULIB_ACOSF = @GNULIB_ACOSF@ +GNULIB_ACOSL = @GNULIB_ACOSL@ +GNULIB_ALPHASORT = @GNULIB_ALPHASORT@ +GNULIB_ASINF = @GNULIB_ASINF@ +GNULIB_ASINL = @GNULIB_ASINL@ +GNULIB_ATAN2F = @GNULIB_ATAN2F@ +GNULIB_ATANF = @GNULIB_ATANF@ +GNULIB_ATANL = @GNULIB_ATANL@ +GNULIB_ATOLL = @GNULIB_ATOLL@ +GNULIB_BIND = @GNULIB_BIND@ +GNULIB_BTOWC = @GNULIB_BTOWC@ +GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@ +GNULIB_CANONICALIZE_FILE_NAME = @GNULIB_CANONICALIZE_FILE_NAME@ +GNULIB_CBRT = @GNULIB_CBRT@ +GNULIB_CBRTF = @GNULIB_CBRTF@ +GNULIB_CBRTL = @GNULIB_CBRTL@ +GNULIB_CEIL = @GNULIB_CEIL@ +GNULIB_CEILF = @GNULIB_CEILF@ +GNULIB_CEILL = @GNULIB_CEILL@ +GNULIB_CHDIR = @GNULIB_CHDIR@ +GNULIB_CHOWN = @GNULIB_CHOWN@ +GNULIB_CLOSE = @GNULIB_CLOSE@ +GNULIB_CLOSEDIR = @GNULIB_CLOSEDIR@ +GNULIB_CONNECT = @GNULIB_CONNECT@ +GNULIB_COPYSIGN = @GNULIB_COPYSIGN@ +GNULIB_COPYSIGNF = @GNULIB_COPYSIGNF@ +GNULIB_COPYSIGNL = @GNULIB_COPYSIGNL@ +GNULIB_COPY_FILE_RANGE = @GNULIB_COPY_FILE_RANGE@ +GNULIB_COSF = @GNULIB_COSF@ +GNULIB_COSHF = @GNULIB_COSHF@ +GNULIB_COSL = @GNULIB_COSL@ +GNULIB_CREAT = @GNULIB_CREAT@ +GNULIB_CTIME = @GNULIB_CTIME@ +GNULIB_DIRFD = @GNULIB_DIRFD@ +GNULIB_DPRINTF = @GNULIB_DPRINTF@ +GNULIB_DUP = @GNULIB_DUP@ +GNULIB_DUP2 = @GNULIB_DUP2@ +GNULIB_DUP3 = @GNULIB_DUP3@ +GNULIB_DUPLOCALE = @GNULIB_DUPLOCALE@ +GNULIB_ENVIRON = @GNULIB_ENVIRON@ +GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@ +GNULIB_EXP2 = @GNULIB_EXP2@ +GNULIB_EXP2F = @GNULIB_EXP2F@ +GNULIB_EXP2L = @GNULIB_EXP2L@ +GNULIB_EXPF = @GNULIB_EXPF@ +GNULIB_EXPL = @GNULIB_EXPL@ +GNULIB_EXPLICIT_BZERO = @GNULIB_EXPLICIT_BZERO@ +GNULIB_EXPM1 = @GNULIB_EXPM1@ +GNULIB_EXPM1F = @GNULIB_EXPM1F@ +GNULIB_EXPM1L = @GNULIB_EXPM1L@ +GNULIB_FABSF = @GNULIB_FABSF@ +GNULIB_FABSL = @GNULIB_FABSL@ +GNULIB_FACCESSAT = @GNULIB_FACCESSAT@ +GNULIB_FCHDIR = @GNULIB_FCHDIR@ +GNULIB_FCHMODAT = @GNULIB_FCHMODAT@ +GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@ +GNULIB_FCLOSE = @GNULIB_FCLOSE@ +GNULIB_FCNTL = @GNULIB_FCNTL@ +GNULIB_FDATASYNC = @GNULIB_FDATASYNC@ +GNULIB_FDOPEN = @GNULIB_FDOPEN@ +GNULIB_FDOPENDIR = @GNULIB_FDOPENDIR@ +GNULIB_FFLUSH = @GNULIB_FFLUSH@ +GNULIB_FFSL = @GNULIB_FFSL@ +GNULIB_FFSLL = @GNULIB_FFSLL@ +GNULIB_FGETC = @GNULIB_FGETC@ +GNULIB_FGETS = @GNULIB_FGETS@ +GNULIB_FLOOR = @GNULIB_FLOOR@ +GNULIB_FLOORF = @GNULIB_FLOORF@ +GNULIB_FLOORL = @GNULIB_FLOORL@ +GNULIB_FMA = @GNULIB_FMA@ +GNULIB_FMAF = @GNULIB_FMAF@ +GNULIB_FMAL = @GNULIB_FMAL@ +GNULIB_FMOD = @GNULIB_FMOD@ +GNULIB_FMODF = @GNULIB_FMODF@ +GNULIB_FMODL = @GNULIB_FMODL@ +GNULIB_FNMATCH = @GNULIB_FNMATCH@ +GNULIB_FOPEN = @GNULIB_FOPEN@ +GNULIB_FPRINTF = @GNULIB_FPRINTF@ +GNULIB_FPRINTF_POSIX = @GNULIB_FPRINTF_POSIX@ +GNULIB_FPURGE = @GNULIB_FPURGE@ +GNULIB_FPUTC = @GNULIB_FPUTC@ +GNULIB_FPUTS = @GNULIB_FPUTS@ +GNULIB_FREAD = @GNULIB_FREAD@ +GNULIB_FREOPEN = @GNULIB_FREOPEN@ +GNULIB_FREXP = @GNULIB_FREXP@ +GNULIB_FREXPF = @GNULIB_FREXPF@ +GNULIB_FREXPL = @GNULIB_FREXPL@ +GNULIB_FSCANF = @GNULIB_FSCANF@ +GNULIB_FSEEK = @GNULIB_FSEEK@ +GNULIB_FSEEKO = @GNULIB_FSEEKO@ +GNULIB_FSTAT = @GNULIB_FSTAT@ +GNULIB_FSTATAT = @GNULIB_FSTATAT@ +GNULIB_FSYNC = @GNULIB_FSYNC@ +GNULIB_FTELL = @GNULIB_FTELL@ +GNULIB_FTELLO = @GNULIB_FTELLO@ +GNULIB_FTRUNCATE = @GNULIB_FTRUNCATE@ +GNULIB_FUTIMENS = @GNULIB_FUTIMENS@ +GNULIB_FWRITE = @GNULIB_FWRITE@ +GNULIB_GETADDRINFO = @GNULIB_GETADDRINFO@ +GNULIB_GETC = @GNULIB_GETC@ +GNULIB_GETCHAR = @GNULIB_GETCHAR@ +GNULIB_GETCWD = @GNULIB_GETCWD@ +GNULIB_GETDELIM = @GNULIB_GETDELIM@ +GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@ +GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@ +GNULIB_GETGROUPS = @GNULIB_GETGROUPS@ +GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@ +GNULIB_GETLINE = @GNULIB_GETLINE@ +GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@ +GNULIB_GETLOGIN = @GNULIB_GETLOGIN@ +GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@ +GNULIB_GETOPT_POSIX = @GNULIB_GETOPT_POSIX@ +GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@ +GNULIB_GETPASS = @GNULIB_GETPASS@ +GNULIB_GETPEERNAME = @GNULIB_GETPEERNAME@ +GNULIB_GETRUSAGE = @GNULIB_GETRUSAGE@ +GNULIB_GETSOCKNAME = @GNULIB_GETSOCKNAME@ +GNULIB_GETSOCKOPT = @GNULIB_GETSOCKOPT@ +GNULIB_GETSUBOPT = @GNULIB_GETSUBOPT@ +GNULIB_GETTIMEOFDAY = @GNULIB_GETTIMEOFDAY@ +GNULIB_GETUSERSHELL = @GNULIB_GETUSERSHELL@ +GNULIB_GL_UNISTD_H_GETOPT = @GNULIB_GL_UNISTD_H_GETOPT@ +GNULIB_GRANTPT = @GNULIB_GRANTPT@ +GNULIB_GROUP_MEMBER = @GNULIB_GROUP_MEMBER@ +GNULIB_HYPOT = @GNULIB_HYPOT@ +GNULIB_HYPOTF = @GNULIB_HYPOTF@ +GNULIB_HYPOTL = @GNULIB_HYPOTL@ +GNULIB_ICONV = @GNULIB_ICONV@ +GNULIB_ILOGB = @GNULIB_ILOGB@ +GNULIB_ILOGBF = @GNULIB_ILOGBF@ +GNULIB_ILOGBL = @GNULIB_ILOGBL@ +GNULIB_IMAXABS = @GNULIB_IMAXABS@ +GNULIB_IMAXDIV = @GNULIB_IMAXDIV@ +GNULIB_INET_NTOP = @GNULIB_INET_NTOP@ +GNULIB_INET_PTON = @GNULIB_INET_PTON@ +GNULIB_IOCTL = @GNULIB_IOCTL@ +GNULIB_ISATTY = @GNULIB_ISATTY@ +GNULIB_ISBLANK = @GNULIB_ISBLANK@ +GNULIB_ISFINITE = @GNULIB_ISFINITE@ +GNULIB_ISINF = @GNULIB_ISINF@ +GNULIB_ISNAN = @GNULIB_ISNAN@ +GNULIB_ISNAND = @GNULIB_ISNAND@ +GNULIB_ISNANF = @GNULIB_ISNANF@ +GNULIB_ISNANL = @GNULIB_ISNANL@ +GNULIB_ISWBLANK = @GNULIB_ISWBLANK@ +GNULIB_ISWCTYPE = @GNULIB_ISWCTYPE@ +GNULIB_ISWDIGIT = @GNULIB_ISWDIGIT@ +GNULIB_ISWXDIGIT = @GNULIB_ISWXDIGIT@ +GNULIB_LCHMOD = @GNULIB_LCHMOD@ +GNULIB_LCHOWN = @GNULIB_LCHOWN@ +GNULIB_LDEXPF = @GNULIB_LDEXPF@ +GNULIB_LDEXPL = @GNULIB_LDEXPL@ +GNULIB_LINK = @GNULIB_LINK@ +GNULIB_LINKAT = @GNULIB_LINKAT@ +GNULIB_LISTEN = @GNULIB_LISTEN@ +GNULIB_LOCALECONV = @GNULIB_LOCALECONV@ +GNULIB_LOCALENAME = @GNULIB_LOCALENAME@ +GNULIB_LOCALTIME = @GNULIB_LOCALTIME@ +GNULIB_LOG = @GNULIB_LOG@ +GNULIB_LOG10 = @GNULIB_LOG10@ +GNULIB_LOG10F = @GNULIB_LOG10F@ +GNULIB_LOG10L = @GNULIB_LOG10L@ +GNULIB_LOG1P = @GNULIB_LOG1P@ +GNULIB_LOG1PF = @GNULIB_LOG1PF@ +GNULIB_LOG1PL = @GNULIB_LOG1PL@ +GNULIB_LOG2 = @GNULIB_LOG2@ +GNULIB_LOG2F = @GNULIB_LOG2F@ +GNULIB_LOG2L = @GNULIB_LOG2L@ +GNULIB_LOGB = @GNULIB_LOGB@ +GNULIB_LOGBF = @GNULIB_LOGBF@ +GNULIB_LOGBL = @GNULIB_LOGBL@ +GNULIB_LOGF = @GNULIB_LOGF@ +GNULIB_LOGL = @GNULIB_LOGL@ +GNULIB_LSEEK = @GNULIB_LSEEK@ +GNULIB_LSTAT = @GNULIB_LSTAT@ +GNULIB_MALLOC_POSIX = @GNULIB_MALLOC_POSIX@ +GNULIB_MBRLEN = @GNULIB_MBRLEN@ +GNULIB_MBRTOWC = @GNULIB_MBRTOWC@ +GNULIB_MBSCASECMP = @GNULIB_MBSCASECMP@ +GNULIB_MBSCASESTR = @GNULIB_MBSCASESTR@ +GNULIB_MBSCHR = @GNULIB_MBSCHR@ +GNULIB_MBSCSPN = @GNULIB_MBSCSPN@ +GNULIB_MBSINIT = @GNULIB_MBSINIT@ +GNULIB_MBSLEN = @GNULIB_MBSLEN@ +GNULIB_MBSNCASECMP = @GNULIB_MBSNCASECMP@ +GNULIB_MBSNLEN = @GNULIB_MBSNLEN@ +GNULIB_MBSNRTOWCS = @GNULIB_MBSNRTOWCS@ +GNULIB_MBSPBRK = @GNULIB_MBSPBRK@ +GNULIB_MBSPCASECMP = @GNULIB_MBSPCASECMP@ +GNULIB_MBSRCHR = @GNULIB_MBSRCHR@ +GNULIB_MBSRTOWCS = @GNULIB_MBSRTOWCS@ +GNULIB_MBSSEP = @GNULIB_MBSSEP@ +GNULIB_MBSSPN = @GNULIB_MBSSPN@ +GNULIB_MBSSTR = @GNULIB_MBSSTR@ +GNULIB_MBSTOK_R = @GNULIB_MBSTOK_R@ +GNULIB_MBTOWC = @GNULIB_MBTOWC@ +GNULIB_MEMCHR = @GNULIB_MEMCHR@ +GNULIB_MEMMEM = @GNULIB_MEMMEM@ +GNULIB_MEMPCPY = @GNULIB_MEMPCPY@ +GNULIB_MEMRCHR = @GNULIB_MEMRCHR@ +GNULIB_MKDIRAT = @GNULIB_MKDIRAT@ +GNULIB_MKDTEMP = @GNULIB_MKDTEMP@ +GNULIB_MKFIFO = @GNULIB_MKFIFO@ +GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@ +GNULIB_MKNOD = @GNULIB_MKNOD@ +GNULIB_MKNODAT = @GNULIB_MKNODAT@ +GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@ +GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@ +GNULIB_MKSTEMP = @GNULIB_MKSTEMP@ +GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@ +GNULIB_MKTIME = @GNULIB_MKTIME@ +GNULIB_MODF = @GNULIB_MODF@ +GNULIB_MODFF = @GNULIB_MODFF@ +GNULIB_MODFL = @GNULIB_MODFL@ +GNULIB_NANOSLEEP = @GNULIB_NANOSLEEP@ +GNULIB_NL_LANGINFO = @GNULIB_NL_LANGINFO@ +GNULIB_NONBLOCKING = @GNULIB_NONBLOCKING@ +GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@ +GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@ +GNULIB_OPEN = @GNULIB_OPEN@ +GNULIB_OPENAT = @GNULIB_OPENAT@ +GNULIB_OPENDIR = @GNULIB_OPENDIR@ +GNULIB_OVERRIDES_STRUCT_STAT = @GNULIB_OVERRIDES_STRUCT_STAT@ +GNULIB_OVERRIDES_WINT_T = @GNULIB_OVERRIDES_WINT_T@ +GNULIB_PCLOSE = @GNULIB_PCLOSE@ +GNULIB_PERROR = @GNULIB_PERROR@ +GNULIB_PIPE = @GNULIB_PIPE@ +GNULIB_PIPE2 = @GNULIB_PIPE2@ +GNULIB_POPEN = @GNULIB_POPEN@ +GNULIB_POSIX_OPENPT = @GNULIB_POSIX_OPENPT@ +GNULIB_POWF = @GNULIB_POWF@ +GNULIB_PREAD = @GNULIB_PREAD@ +GNULIB_PRINTF = @GNULIB_PRINTF@ +GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@ +GNULIB_PSELECT = @GNULIB_PSELECT@ +GNULIB_PTHREAD_COND = @GNULIB_PTHREAD_COND@ +GNULIB_PTHREAD_MUTEX = @GNULIB_PTHREAD_MUTEX@ +GNULIB_PTHREAD_MUTEX_TIMEDLOCK = @GNULIB_PTHREAD_MUTEX_TIMEDLOCK@ +GNULIB_PTHREAD_ONCE = @GNULIB_PTHREAD_ONCE@ +GNULIB_PTHREAD_RWLOCK = @GNULIB_PTHREAD_RWLOCK@ +GNULIB_PTHREAD_SIGMASK = @GNULIB_PTHREAD_SIGMASK@ +GNULIB_PTHREAD_SPIN = @GNULIB_PTHREAD_SPIN@ +GNULIB_PTHREAD_THREAD = @GNULIB_PTHREAD_THREAD@ +GNULIB_PTHREAD_TSS = @GNULIB_PTHREAD_TSS@ +GNULIB_PTSNAME = @GNULIB_PTSNAME@ +GNULIB_PTSNAME_R = @GNULIB_PTSNAME_R@ +GNULIB_PUTC = @GNULIB_PUTC@ +GNULIB_PUTCHAR = @GNULIB_PUTCHAR@ +GNULIB_PUTENV = @GNULIB_PUTENV@ +GNULIB_PUTS = @GNULIB_PUTS@ +GNULIB_PWRITE = @GNULIB_PWRITE@ +GNULIB_QSORT_R = @GNULIB_QSORT_R@ +GNULIB_RAISE = @GNULIB_RAISE@ +GNULIB_RANDOM = @GNULIB_RANDOM@ +GNULIB_RANDOM_R = @GNULIB_RANDOM_R@ +GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@ +GNULIB_READ = @GNULIB_READ@ +GNULIB_READDIR = @GNULIB_READDIR@ +GNULIB_READLINK = @GNULIB_READLINK@ +GNULIB_READLINKAT = @GNULIB_READLINKAT@ +GNULIB_REALLOCARRAY = @GNULIB_REALLOCARRAY@ +GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@ +GNULIB_REALPATH = @GNULIB_REALPATH@ +GNULIB_RECV = @GNULIB_RECV@ +GNULIB_RECVFROM = @GNULIB_RECVFROM@ +GNULIB_REMAINDER = @GNULIB_REMAINDER@ +GNULIB_REMAINDERF = @GNULIB_REMAINDERF@ +GNULIB_REMAINDERL = @GNULIB_REMAINDERL@ +GNULIB_REMOVE = @GNULIB_REMOVE@ +GNULIB_RENAME = @GNULIB_RENAME@ +GNULIB_RENAMEAT = @GNULIB_RENAMEAT@ +GNULIB_REWINDDIR = @GNULIB_REWINDDIR@ +GNULIB_RINT = @GNULIB_RINT@ +GNULIB_RINTF = @GNULIB_RINTF@ +GNULIB_RINTL = @GNULIB_RINTL@ +GNULIB_RMDIR = @GNULIB_RMDIR@ +GNULIB_ROUND = @GNULIB_ROUND@ +GNULIB_ROUNDF = @GNULIB_ROUNDF@ +GNULIB_ROUNDL = @GNULIB_ROUNDL@ +GNULIB_RPMATCH = @GNULIB_RPMATCH@ +GNULIB_SCANDIR = @GNULIB_SCANDIR@ +GNULIB_SCANF = @GNULIB_SCANF@ +GNULIB_SCHED_YIELD = @GNULIB_SCHED_YIELD@ +GNULIB_SECURE_GETENV = @GNULIB_SECURE_GETENV@ +GNULIB_SELECT = @GNULIB_SELECT@ +GNULIB_SEND = @GNULIB_SEND@ +GNULIB_SENDTO = @GNULIB_SENDTO@ +GNULIB_SETENV = @GNULIB_SETENV@ +GNULIB_SETHOSTNAME = @GNULIB_SETHOSTNAME@ +GNULIB_SETLOCALE = @GNULIB_SETLOCALE@ +GNULIB_SETLOCALE_NULL = @GNULIB_SETLOCALE_NULL@ +GNULIB_SETSOCKOPT = @GNULIB_SETSOCKOPT@ +GNULIB_SHUTDOWN = @GNULIB_SHUTDOWN@ +GNULIB_SIGACTION = @GNULIB_SIGACTION@ +GNULIB_SIGNAL_H_SIGPIPE = @GNULIB_SIGNAL_H_SIGPIPE@ +GNULIB_SIGNBIT = @GNULIB_SIGNBIT@ +GNULIB_SIGPROCMASK = @GNULIB_SIGPROCMASK@ +GNULIB_SINF = @GNULIB_SINF@ +GNULIB_SINHF = @GNULIB_SINHF@ +GNULIB_SINL = @GNULIB_SINL@ +GNULIB_SLEEP = @GNULIB_SLEEP@ +GNULIB_SNPRINTF = @GNULIB_SNPRINTF@ +GNULIB_SOCKET = @GNULIB_SOCKET@ +GNULIB_SPRINTF_POSIX = @GNULIB_SPRINTF_POSIX@ +GNULIB_SQRTF = @GNULIB_SQRTF@ +GNULIB_SQRTL = @GNULIB_SQRTL@ +GNULIB_STAT = @GNULIB_STAT@ +GNULIB_STDIO_H_NONBLOCKING = @GNULIB_STDIO_H_NONBLOCKING@ +GNULIB_STDIO_H_SIGPIPE = @GNULIB_STDIO_H_SIGPIPE@ +GNULIB_STPCPY = @GNULIB_STPCPY@ +GNULIB_STPNCPY = @GNULIB_STPNCPY@ +GNULIB_STRCASESTR = @GNULIB_STRCASESTR@ +GNULIB_STRCHRNUL = @GNULIB_STRCHRNUL@ +GNULIB_STRDUP = @GNULIB_STRDUP@ +GNULIB_STRERROR = @GNULIB_STRERROR@ +GNULIB_STRERROR_R = @GNULIB_STRERROR_R@ +GNULIB_STRFTIME = @GNULIB_STRFTIME@ +GNULIB_STRNCAT = @GNULIB_STRNCAT@ +GNULIB_STRNDUP = @GNULIB_STRNDUP@ +GNULIB_STRNLEN = @GNULIB_STRNLEN@ +GNULIB_STRPBRK = @GNULIB_STRPBRK@ +GNULIB_STRPTIME = @GNULIB_STRPTIME@ +GNULIB_STRSEP = @GNULIB_STRSEP@ +GNULIB_STRSIGNAL = @GNULIB_STRSIGNAL@ +GNULIB_STRSTR = @GNULIB_STRSTR@ +GNULIB_STRTOD = @GNULIB_STRTOD@ +GNULIB_STRTOIMAX = @GNULIB_STRTOIMAX@ +GNULIB_STRTOK_R = @GNULIB_STRTOK_R@ +GNULIB_STRTOLD = @GNULIB_STRTOLD@ +GNULIB_STRTOLL = @GNULIB_STRTOLL@ +GNULIB_STRTOULL = @GNULIB_STRTOULL@ +GNULIB_STRTOUMAX = @GNULIB_STRTOUMAX@ +GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@ +GNULIB_SYMLINK = @GNULIB_SYMLINK@ +GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@ +GNULIB_SYSTEM_POSIX = @GNULIB_SYSTEM_POSIX@ +GNULIB_TANF = @GNULIB_TANF@ +GNULIB_TANHF = @GNULIB_TANHF@ +GNULIB_TANL = @GNULIB_TANL@ +GNULIB_TCGETSID = @GNULIB_TCGETSID@ +GNULIB_TEST_WARN_CFLAGS = @GNULIB_TEST_WARN_CFLAGS@ +GNULIB_TIMEGM = @GNULIB_TIMEGM@ +GNULIB_TIME_R = @GNULIB_TIME_R@ +GNULIB_TIME_RZ = @GNULIB_TIME_RZ@ +GNULIB_TMPFILE = @GNULIB_TMPFILE@ +GNULIB_TOWCTRANS = @GNULIB_TOWCTRANS@ +GNULIB_TRUNC = @GNULIB_TRUNC@ +GNULIB_TRUNCATE = @GNULIB_TRUNCATE@ +GNULIB_TRUNCF = @GNULIB_TRUNCF@ +GNULIB_TRUNCL = @GNULIB_TRUNCL@ +GNULIB_TTYNAME_R = @GNULIB_TTYNAME_R@ +GNULIB_TZSET = @GNULIB_TZSET@ +GNULIB_UNAME = @GNULIB_UNAME@ +GNULIB_UNISTD_H_NONBLOCKING = @GNULIB_UNISTD_H_NONBLOCKING@ +GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@ +GNULIB_UNLINK = @GNULIB_UNLINK@ +GNULIB_UNLINKAT = @GNULIB_UNLINKAT@ +GNULIB_UNLOCKPT = @GNULIB_UNLOCKPT@ +GNULIB_UNSETENV = @GNULIB_UNSETENV@ +GNULIB_USLEEP = @GNULIB_USLEEP@ +GNULIB_UTIME = @GNULIB_UTIME@ +GNULIB_UTIMENSAT = @GNULIB_UTIMENSAT@ +GNULIB_VASPRINTF = @GNULIB_VASPRINTF@ +GNULIB_VDPRINTF = @GNULIB_VDPRINTF@ +GNULIB_VFPRINTF = @GNULIB_VFPRINTF@ +GNULIB_VFPRINTF_POSIX = @GNULIB_VFPRINTF_POSIX@ +GNULIB_VFSCANF = @GNULIB_VFSCANF@ +GNULIB_VPRINTF = @GNULIB_VPRINTF@ +GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@ +GNULIB_VSCANF = @GNULIB_VSCANF@ +GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@ +GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@ +GNULIB_WAITPID = @GNULIB_WAITPID@ +GNULIB_WARN_CFLAGS = @GNULIB_WARN_CFLAGS@ +GNULIB_WCPCPY = @GNULIB_WCPCPY@ +GNULIB_WCPNCPY = @GNULIB_WCPNCPY@ +GNULIB_WCRTOMB = @GNULIB_WCRTOMB@ +GNULIB_WCSCASECMP = @GNULIB_WCSCASECMP@ +GNULIB_WCSCAT = @GNULIB_WCSCAT@ +GNULIB_WCSCHR = @GNULIB_WCSCHR@ +GNULIB_WCSCMP = @GNULIB_WCSCMP@ +GNULIB_WCSCOLL = @GNULIB_WCSCOLL@ +GNULIB_WCSCPY = @GNULIB_WCSCPY@ +GNULIB_WCSCSPN = @GNULIB_WCSCSPN@ +GNULIB_WCSDUP = @GNULIB_WCSDUP@ +GNULIB_WCSFTIME = @GNULIB_WCSFTIME@ +GNULIB_WCSLEN = @GNULIB_WCSLEN@ +GNULIB_WCSNCASECMP = @GNULIB_WCSNCASECMP@ +GNULIB_WCSNCAT = @GNULIB_WCSNCAT@ +GNULIB_WCSNCMP = @GNULIB_WCSNCMP@ +GNULIB_WCSNCPY = @GNULIB_WCSNCPY@ +GNULIB_WCSNLEN = @GNULIB_WCSNLEN@ +GNULIB_WCSNRTOMBS = @GNULIB_WCSNRTOMBS@ +GNULIB_WCSPBRK = @GNULIB_WCSPBRK@ +GNULIB_WCSRCHR = @GNULIB_WCSRCHR@ +GNULIB_WCSRTOMBS = @GNULIB_WCSRTOMBS@ +GNULIB_WCSSPN = @GNULIB_WCSSPN@ +GNULIB_WCSSTR = @GNULIB_WCSSTR@ +GNULIB_WCSTOK = @GNULIB_WCSTOK@ +GNULIB_WCSWIDTH = @GNULIB_WCSWIDTH@ +GNULIB_WCSXFRM = @GNULIB_WCSXFRM@ +GNULIB_WCTOB = @GNULIB_WCTOB@ +GNULIB_WCTOMB = @GNULIB_WCTOMB@ +GNULIB_WCTRANS = @GNULIB_WCTRANS@ +GNULIB_WCTYPE = @GNULIB_WCTYPE@ +GNULIB_WCWIDTH = @GNULIB_WCWIDTH@ +GNULIB_WMEMCHR = @GNULIB_WMEMCHR@ +GNULIB_WMEMCMP = @GNULIB_WMEMCMP@ +GNULIB_WMEMCPY = @GNULIB_WMEMCPY@ +GNULIB_WMEMMOVE = @GNULIB_WMEMMOVE@ +GNULIB_WMEMSET = @GNULIB_WMEMSET@ +GNULIB_WRITE = @GNULIB_WRITE@ +GNULIB__EXIT = @GNULIB__EXIT@ +GREP = @GREP@ +HAVE_ACCEPT4 = @HAVE_ACCEPT4@ +HAVE_ACOSF = @HAVE_ACOSF@ +HAVE_ACOSL = @HAVE_ACOSL@ +HAVE_ALLOCA_H = @HAVE_ALLOCA_H@ +HAVE_ALPHASORT = @HAVE_ALPHASORT@ +HAVE_ARPA_INET_H = @HAVE_ARPA_INET_H@ +HAVE_ASINF = @HAVE_ASINF@ +HAVE_ASINL = @HAVE_ASINL@ +HAVE_ATAN2F = @HAVE_ATAN2F@ +HAVE_ATANF = @HAVE_ATANF@ +HAVE_ATANL = @HAVE_ATANL@ +HAVE_ATOLL = @HAVE_ATOLL@ +HAVE_BTOWC = @HAVE_BTOWC@ +HAVE_C99_STDINT_H = @HAVE_C99_STDINT_H@ +HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@ +HAVE_CBRT = @HAVE_CBRT@ +HAVE_CBRTF = @HAVE_CBRTF@ +HAVE_CBRTL = @HAVE_CBRTL@ +HAVE_CHOWN = @HAVE_CHOWN@ +HAVE_CLOSEDIR = @HAVE_CLOSEDIR@ +HAVE_COPYSIGN = @HAVE_COPYSIGN@ +HAVE_COPYSIGNL = @HAVE_COPYSIGNL@ +HAVE_COPY_FILE_RANGE = @HAVE_COPY_FILE_RANGE@ +HAVE_COSF = @HAVE_COSF@ +HAVE_COSHF = @HAVE_COSHF@ +HAVE_COSL = @HAVE_COSL@ +HAVE_CRTDEFS_H = @HAVE_CRTDEFS_H@ +HAVE_DECL_ACOSL = @HAVE_DECL_ACOSL@ +HAVE_DECL_ASINL = @HAVE_DECL_ASINL@ +HAVE_DECL_ATANL = @HAVE_DECL_ATANL@ +HAVE_DECL_CBRTF = @HAVE_DECL_CBRTF@ +HAVE_DECL_CBRTL = @HAVE_DECL_CBRTL@ +HAVE_DECL_CEILF = @HAVE_DECL_CEILF@ +HAVE_DECL_CEILL = @HAVE_DECL_CEILL@ +HAVE_DECL_COPYSIGNF = @HAVE_DECL_COPYSIGNF@ +HAVE_DECL_COSL = @HAVE_DECL_COSL@ +HAVE_DECL_DIRFD = @HAVE_DECL_DIRFD@ +HAVE_DECL_ENVIRON = @HAVE_DECL_ENVIRON@ +HAVE_DECL_EXP2 = @HAVE_DECL_EXP2@ +HAVE_DECL_EXP2F = @HAVE_DECL_EXP2F@ +HAVE_DECL_EXP2L = @HAVE_DECL_EXP2L@ +HAVE_DECL_EXPL = @HAVE_DECL_EXPL@ +HAVE_DECL_EXPM1L = @HAVE_DECL_EXPM1L@ +HAVE_DECL_FCHDIR = @HAVE_DECL_FCHDIR@ +HAVE_DECL_FDATASYNC = @HAVE_DECL_FDATASYNC@ +HAVE_DECL_FDOPENDIR = @HAVE_DECL_FDOPENDIR@ +HAVE_DECL_FLOORF = @HAVE_DECL_FLOORF@ +HAVE_DECL_FLOORL = @HAVE_DECL_FLOORL@ +HAVE_DECL_FPURGE = @HAVE_DECL_FPURGE@ +HAVE_DECL_FREEADDRINFO = @HAVE_DECL_FREEADDRINFO@ +HAVE_DECL_FREXPL = @HAVE_DECL_FREXPL@ +HAVE_DECL_FSEEKO = @HAVE_DECL_FSEEKO@ +HAVE_DECL_FTELLO = @HAVE_DECL_FTELLO@ +HAVE_DECL_GAI_STRERROR = @HAVE_DECL_GAI_STRERROR@ +HAVE_DECL_GETADDRINFO = @HAVE_DECL_GETADDRINFO@ +HAVE_DECL_GETDELIM = @HAVE_DECL_GETDELIM@ +HAVE_DECL_GETDOMAINNAME = @HAVE_DECL_GETDOMAINNAME@ +HAVE_DECL_GETLINE = @HAVE_DECL_GETLINE@ +HAVE_DECL_GETLOADAVG = @HAVE_DECL_GETLOADAVG@ +HAVE_DECL_GETLOGIN = @HAVE_DECL_GETLOGIN@ +HAVE_DECL_GETLOGIN_R = @HAVE_DECL_GETLOGIN_R@ +HAVE_DECL_GETNAMEINFO = @HAVE_DECL_GETNAMEINFO@ +HAVE_DECL_GETPAGESIZE = @HAVE_DECL_GETPAGESIZE@ +HAVE_DECL_GETUSERSHELL = @HAVE_DECL_GETUSERSHELL@ +HAVE_DECL_IMAXABS = @HAVE_DECL_IMAXABS@ +HAVE_DECL_IMAXDIV = @HAVE_DECL_IMAXDIV@ +HAVE_DECL_INET_NTOP = @HAVE_DECL_INET_NTOP@ +HAVE_DECL_INET_PTON = @HAVE_DECL_INET_PTON@ +HAVE_DECL_INITSTATE = @HAVE_DECL_INITSTATE@ +HAVE_DECL_LDEXPL = @HAVE_DECL_LDEXPL@ +HAVE_DECL_LOCALTIME_R = @HAVE_DECL_LOCALTIME_R@ +HAVE_DECL_LOG10L = @HAVE_DECL_LOG10L@ +HAVE_DECL_LOG2 = @HAVE_DECL_LOG2@ +HAVE_DECL_LOG2F = @HAVE_DECL_LOG2F@ +HAVE_DECL_LOG2L = @HAVE_DECL_LOG2L@ +HAVE_DECL_LOGB = @HAVE_DECL_LOGB@ +HAVE_DECL_LOGL = @HAVE_DECL_LOGL@ +HAVE_DECL_MEMMEM = @HAVE_DECL_MEMMEM@ +HAVE_DECL_MEMRCHR = @HAVE_DECL_MEMRCHR@ +HAVE_DECL_OBSTACK_PRINTF = @HAVE_DECL_OBSTACK_PRINTF@ +HAVE_DECL_REMAINDER = @HAVE_DECL_REMAINDER@ +HAVE_DECL_REMAINDERL = @HAVE_DECL_REMAINDERL@ +HAVE_DECL_RINTF = @HAVE_DECL_RINTF@ +HAVE_DECL_ROUND = @HAVE_DECL_ROUND@ +HAVE_DECL_ROUNDF = @HAVE_DECL_ROUNDF@ +HAVE_DECL_ROUNDL = @HAVE_DECL_ROUNDL@ +HAVE_DECL_SETENV = @HAVE_DECL_SETENV@ +HAVE_DECL_SETHOSTNAME = @HAVE_DECL_SETHOSTNAME@ +HAVE_DECL_SETSTATE = @HAVE_DECL_SETSTATE@ +HAVE_DECL_SINL = @HAVE_DECL_SINL@ +HAVE_DECL_SNPRINTF = @HAVE_DECL_SNPRINTF@ +HAVE_DECL_SQRTL = @HAVE_DECL_SQRTL@ +HAVE_DECL_STRDUP = @HAVE_DECL_STRDUP@ +HAVE_DECL_STRERROR_R = @HAVE_DECL_STRERROR_R@ +HAVE_DECL_STRNDUP = @HAVE_DECL_STRNDUP@ +HAVE_DECL_STRNLEN = @HAVE_DECL_STRNLEN@ +HAVE_DECL_STRSIGNAL = @HAVE_DECL_STRSIGNAL@ +HAVE_DECL_STRTOIMAX = @HAVE_DECL_STRTOIMAX@ +HAVE_DECL_STRTOK_R = @HAVE_DECL_STRTOK_R@ +HAVE_DECL_STRTOUMAX = @HAVE_DECL_STRTOUMAX@ +HAVE_DECL_TANL = @HAVE_DECL_TANL@ +HAVE_DECL_TCGETSID = @HAVE_DECL_TCGETSID@ +HAVE_DECL_TRUNC = @HAVE_DECL_TRUNC@ +HAVE_DECL_TRUNCATE = @HAVE_DECL_TRUNCATE@ +HAVE_DECL_TRUNCF = @HAVE_DECL_TRUNCF@ +HAVE_DECL_TRUNCL = @HAVE_DECL_TRUNCL@ +HAVE_DECL_TTYNAME_R = @HAVE_DECL_TTYNAME_R@ +HAVE_DECL_UNSETENV = @HAVE_DECL_UNSETENV@ +HAVE_DECL_VSNPRINTF = @HAVE_DECL_VSNPRINTF@ +HAVE_DECL_WCTOB = @HAVE_DECL_WCTOB@ +HAVE_DECL_WCWIDTH = @HAVE_DECL_WCWIDTH@ +HAVE_DIRENT_H = @HAVE_DIRENT_H@ +HAVE_DPRINTF = @HAVE_DPRINTF@ +HAVE_DUP2 = @HAVE_DUP2@ +HAVE_DUP3 = @HAVE_DUP3@ +HAVE_DUPLOCALE = @HAVE_DUPLOCALE@ +HAVE_EUIDACCESS = @HAVE_EUIDACCESS@ +HAVE_EXPF = @HAVE_EXPF@ +HAVE_EXPL = @HAVE_EXPL@ +HAVE_EXPLICIT_BZERO = @HAVE_EXPLICIT_BZERO@ +HAVE_EXPM1 = @HAVE_EXPM1@ +HAVE_EXPM1F = @HAVE_EXPM1F@ +HAVE_FABSF = @HAVE_FABSF@ +HAVE_FABSL = @HAVE_FABSL@ +HAVE_FACCESSAT = @HAVE_FACCESSAT@ +HAVE_FCHDIR = @HAVE_FCHDIR@ +HAVE_FCHMODAT = @HAVE_FCHMODAT@ +HAVE_FCHOWNAT = @HAVE_FCHOWNAT@ +HAVE_FCNTL = @HAVE_FCNTL@ +HAVE_FDATASYNC = @HAVE_FDATASYNC@ +HAVE_FDOPENDIR = @HAVE_FDOPENDIR@ +HAVE_FEATURES_H = @HAVE_FEATURES_H@ +HAVE_FFSL = @HAVE_FFSL@ +HAVE_FFSLL = @HAVE_FFSLL@ +HAVE_FMA = @HAVE_FMA@ +HAVE_FMAF = @HAVE_FMAF@ +HAVE_FMAL = @HAVE_FMAL@ +HAVE_FMODF = @HAVE_FMODF@ +HAVE_FMODL = @HAVE_FMODL@ +HAVE_FNMATCH = @HAVE_FNMATCH@ +HAVE_FNMATCH_H = @HAVE_FNMATCH_H@ +HAVE_FREELOCALE = @HAVE_FREELOCALE@ +HAVE_FREXPF = @HAVE_FREXPF@ +HAVE_FSEEKO = @HAVE_FSEEKO@ +HAVE_FSTATAT = @HAVE_FSTATAT@ +HAVE_FSYNC = @HAVE_FSYNC@ +HAVE_FTELLO = @HAVE_FTELLO@ +HAVE_FTRUNCATE = @HAVE_FTRUNCATE@ +HAVE_FUTIMENS = @HAVE_FUTIMENS@ +HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@ +HAVE_GETGROUPS = @HAVE_GETGROUPS@ +HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@ +HAVE_GETLOGIN = @HAVE_GETLOGIN@ +HAVE_GETOPT_H = @HAVE_GETOPT_H@ +HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@ +HAVE_GETPASS = @HAVE_GETPASS@ +HAVE_GETRUSAGE = @HAVE_GETRUSAGE@ +HAVE_GETSUBOPT = @HAVE_GETSUBOPT@ +HAVE_GETTIMEOFDAY = @HAVE_GETTIMEOFDAY@ +HAVE_GRANTPT = @HAVE_GRANTPT@ +HAVE_GROUP_MEMBER = @HAVE_GROUP_MEMBER@ +HAVE_HYPOTF = @HAVE_HYPOTF@ +HAVE_HYPOTL = @HAVE_HYPOTL@ +HAVE_ILOGB = @HAVE_ILOGB@ +HAVE_ILOGBF = @HAVE_ILOGBF@ +HAVE_ILOGBL = @HAVE_ILOGBL@ +HAVE_IMAXDIV_T = @HAVE_IMAXDIV_T@ +HAVE_INITSTATE = @HAVE_INITSTATE@ +HAVE_INTTYPES_H = @HAVE_INTTYPES_H@ +HAVE_ISBLANK = @HAVE_ISBLANK@ +HAVE_ISNAND = @HAVE_ISNAND@ +HAVE_ISNANF = @HAVE_ISNANF@ +HAVE_ISNANL = @HAVE_ISNANL@ +HAVE_ISWBLANK = @HAVE_ISWBLANK@ +HAVE_ISWCNTRL = @HAVE_ISWCNTRL@ +HAVE_LANGINFO_ALTMON = @HAVE_LANGINFO_ALTMON@ +HAVE_LANGINFO_CODESET = @HAVE_LANGINFO_CODESET@ +HAVE_LANGINFO_ERA = @HAVE_LANGINFO_ERA@ +HAVE_LANGINFO_H = @HAVE_LANGINFO_H@ +HAVE_LANGINFO_T_FMT_AMPM = @HAVE_LANGINFO_T_FMT_AMPM@ +HAVE_LANGINFO_YESEXPR = @HAVE_LANGINFO_YESEXPR@ +HAVE_LCHMOD = @HAVE_LCHMOD@ +HAVE_LCHOWN = @HAVE_LCHOWN@ +HAVE_LDEXPF = @HAVE_LDEXPF@ +HAVE_LINK = @HAVE_LINK@ +HAVE_LINKAT = @HAVE_LINKAT@ +HAVE_LOG10F = @HAVE_LOG10F@ +HAVE_LOG10L = @HAVE_LOG10L@ +HAVE_LOG1P = @HAVE_LOG1P@ +HAVE_LOG1PF = @HAVE_LOG1PF@ +HAVE_LOG1PL = @HAVE_LOG1PL@ +HAVE_LOGBF = @HAVE_LOGBF@ +HAVE_LOGBL = @HAVE_LOGBL@ +HAVE_LOGF = @HAVE_LOGF@ +HAVE_LOGL = @HAVE_LOGL@ +HAVE_LSTAT = @HAVE_LSTAT@ +HAVE_MAX_ALIGN_T = @HAVE_MAX_ALIGN_T@ +HAVE_MBRLEN = @HAVE_MBRLEN@ +HAVE_MBRTOWC = @HAVE_MBRTOWC@ +HAVE_MBSINIT = @HAVE_MBSINIT@ +HAVE_MBSLEN = @HAVE_MBSLEN@ +HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@ +HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@ +HAVE_MBTOWC = @HAVE_MBTOWC@ +HAVE_MEMCHR = @HAVE_MEMCHR@ +HAVE_MEMPCPY = @HAVE_MEMPCPY@ +HAVE_MKDIRAT = @HAVE_MKDIRAT@ +HAVE_MKDTEMP = @HAVE_MKDTEMP@ +HAVE_MKFIFO = @HAVE_MKFIFO@ +HAVE_MKFIFOAT = @HAVE_MKFIFOAT@ +HAVE_MKNOD = @HAVE_MKNOD@ +HAVE_MKNODAT = @HAVE_MKNODAT@ +HAVE_MKOSTEMP = @HAVE_MKOSTEMP@ +HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@ +HAVE_MKSTEMP = @HAVE_MKSTEMP@ +HAVE_MKSTEMPS = @HAVE_MKSTEMPS@ +HAVE_MODFF = @HAVE_MODFF@ +HAVE_MODFL = @HAVE_MODFL@ +HAVE_MSVC_INVALID_PARAMETER_HANDLER = @HAVE_MSVC_INVALID_PARAMETER_HANDLER@ +HAVE_NANOSLEEP = @HAVE_NANOSLEEP@ +HAVE_NETDB_H = @HAVE_NETDB_H@ +HAVE_NETINET_IN_H = @HAVE_NETINET_IN_H@ +HAVE_NEWLOCALE = @HAVE_NEWLOCALE@ +HAVE_NL_LANGINFO = @HAVE_NL_LANGINFO@ +HAVE_OPENAT = @HAVE_OPENAT@ +HAVE_OPENDIR = @HAVE_OPENDIR@ +HAVE_OS_H = @HAVE_OS_H@ +HAVE_PCLOSE = @HAVE_PCLOSE@ +HAVE_PIPE = @HAVE_PIPE@ +HAVE_PIPE2 = @HAVE_PIPE2@ +HAVE_POPEN = @HAVE_POPEN@ +HAVE_POSIX_OPENPT = @HAVE_POSIX_OPENPT@ +HAVE_POSIX_SIGNALBLOCKING = @HAVE_POSIX_SIGNALBLOCKING@ +HAVE_POWF = @HAVE_POWF@ +HAVE_PREAD = @HAVE_PREAD@ +HAVE_PSELECT = @HAVE_PSELECT@ +HAVE_PTHREAD_ATTR_DESTROY = @HAVE_PTHREAD_ATTR_DESTROY@ +HAVE_PTHREAD_ATTR_GETDETACHSTATE = @HAVE_PTHREAD_ATTR_GETDETACHSTATE@ +HAVE_PTHREAD_ATTR_INIT = @HAVE_PTHREAD_ATTR_INIT@ +HAVE_PTHREAD_ATTR_SETDETACHSTATE = @HAVE_PTHREAD_ATTR_SETDETACHSTATE@ +HAVE_PTHREAD_CONDATTR_DESTROY = @HAVE_PTHREAD_CONDATTR_DESTROY@ +HAVE_PTHREAD_CONDATTR_INIT = @HAVE_PTHREAD_CONDATTR_INIT@ +HAVE_PTHREAD_COND_BROADCAST = @HAVE_PTHREAD_COND_BROADCAST@ +HAVE_PTHREAD_COND_DESTROY = @HAVE_PTHREAD_COND_DESTROY@ +HAVE_PTHREAD_COND_INIT = @HAVE_PTHREAD_COND_INIT@ +HAVE_PTHREAD_COND_SIGNAL = @HAVE_PTHREAD_COND_SIGNAL@ +HAVE_PTHREAD_COND_TIMEDWAIT = @HAVE_PTHREAD_COND_TIMEDWAIT@ +HAVE_PTHREAD_COND_WAIT = @HAVE_PTHREAD_COND_WAIT@ +HAVE_PTHREAD_CREATE = @HAVE_PTHREAD_CREATE@ +HAVE_PTHREAD_CREATE_DETACHED = @HAVE_PTHREAD_CREATE_DETACHED@ +HAVE_PTHREAD_DETACH = @HAVE_PTHREAD_DETACH@ +HAVE_PTHREAD_EQUAL = @HAVE_PTHREAD_EQUAL@ +HAVE_PTHREAD_EXIT = @HAVE_PTHREAD_EXIT@ +HAVE_PTHREAD_GETSPECIFIC = @HAVE_PTHREAD_GETSPECIFIC@ +HAVE_PTHREAD_H = @HAVE_PTHREAD_H@ +HAVE_PTHREAD_JOIN = @HAVE_PTHREAD_JOIN@ +HAVE_PTHREAD_KEY_CREATE = @HAVE_PTHREAD_KEY_CREATE@ +HAVE_PTHREAD_KEY_DELETE = @HAVE_PTHREAD_KEY_DELETE@ +HAVE_PTHREAD_MUTEXATTR_DESTROY = @HAVE_PTHREAD_MUTEXATTR_DESTROY@ +HAVE_PTHREAD_MUTEXATTR_GETROBUST = @HAVE_PTHREAD_MUTEXATTR_GETROBUST@ +HAVE_PTHREAD_MUTEXATTR_GETTYPE = @HAVE_PTHREAD_MUTEXATTR_GETTYPE@ +HAVE_PTHREAD_MUTEXATTR_INIT = @HAVE_PTHREAD_MUTEXATTR_INIT@ +HAVE_PTHREAD_MUTEXATTR_SETROBUST = @HAVE_PTHREAD_MUTEXATTR_SETROBUST@ +HAVE_PTHREAD_MUTEXATTR_SETTYPE = @HAVE_PTHREAD_MUTEXATTR_SETTYPE@ +HAVE_PTHREAD_MUTEX_DESTROY = @HAVE_PTHREAD_MUTEX_DESTROY@ +HAVE_PTHREAD_MUTEX_INIT = @HAVE_PTHREAD_MUTEX_INIT@ +HAVE_PTHREAD_MUTEX_LOCK = @HAVE_PTHREAD_MUTEX_LOCK@ +HAVE_PTHREAD_MUTEX_RECURSIVE = @HAVE_PTHREAD_MUTEX_RECURSIVE@ +HAVE_PTHREAD_MUTEX_ROBUST = @HAVE_PTHREAD_MUTEX_ROBUST@ +HAVE_PTHREAD_MUTEX_TIMEDLOCK = @HAVE_PTHREAD_MUTEX_TIMEDLOCK@ +HAVE_PTHREAD_MUTEX_TRYLOCK = @HAVE_PTHREAD_MUTEX_TRYLOCK@ +HAVE_PTHREAD_MUTEX_UNLOCK = @HAVE_PTHREAD_MUTEX_UNLOCK@ +HAVE_PTHREAD_ONCE = @HAVE_PTHREAD_ONCE@ +HAVE_PTHREAD_PROCESS_SHARED = @HAVE_PTHREAD_PROCESS_SHARED@ +HAVE_PTHREAD_RWLOCKATTR_DESTROY = @HAVE_PTHREAD_RWLOCKATTR_DESTROY@ +HAVE_PTHREAD_RWLOCKATTR_INIT = @HAVE_PTHREAD_RWLOCKATTR_INIT@ +HAVE_PTHREAD_RWLOCK_DESTROY = @HAVE_PTHREAD_RWLOCK_DESTROY@ +HAVE_PTHREAD_RWLOCK_INIT = @HAVE_PTHREAD_RWLOCK_INIT@ +HAVE_PTHREAD_RWLOCK_RDLOCK = @HAVE_PTHREAD_RWLOCK_RDLOCK@ +HAVE_PTHREAD_RWLOCK_TIMEDRDLOCK = @HAVE_PTHREAD_RWLOCK_TIMEDRDLOCK@ +HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK = @HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK@ +HAVE_PTHREAD_RWLOCK_TRYRDLOCK = @HAVE_PTHREAD_RWLOCK_TRYRDLOCK@ +HAVE_PTHREAD_RWLOCK_TRYWRLOCK = @HAVE_PTHREAD_RWLOCK_TRYWRLOCK@ +HAVE_PTHREAD_RWLOCK_UNLOCK = @HAVE_PTHREAD_RWLOCK_UNLOCK@ +HAVE_PTHREAD_RWLOCK_WRLOCK = @HAVE_PTHREAD_RWLOCK_WRLOCK@ +HAVE_PTHREAD_SELF = @HAVE_PTHREAD_SELF@ +HAVE_PTHREAD_SETSPECIFIC = @HAVE_PTHREAD_SETSPECIFIC@ +HAVE_PTHREAD_SIGMASK = @HAVE_PTHREAD_SIGMASK@ +HAVE_PTHREAD_SPINLOCK_T = @HAVE_PTHREAD_SPINLOCK_T@ +HAVE_PTHREAD_SPIN_DESTROY = @HAVE_PTHREAD_SPIN_DESTROY@ +HAVE_PTHREAD_SPIN_INIT = @HAVE_PTHREAD_SPIN_INIT@ +HAVE_PTHREAD_SPIN_LOCK = @HAVE_PTHREAD_SPIN_LOCK@ +HAVE_PTHREAD_SPIN_TRYLOCK = @HAVE_PTHREAD_SPIN_TRYLOCK@ +HAVE_PTHREAD_SPIN_UNLOCK = @HAVE_PTHREAD_SPIN_UNLOCK@ +HAVE_PTHREAD_T = @HAVE_PTHREAD_T@ +HAVE_PTSNAME = @HAVE_PTSNAME@ +HAVE_PTSNAME_R = @HAVE_PTSNAME_R@ +HAVE_PWRITE = @HAVE_PWRITE@ +HAVE_QSORT_R = @HAVE_QSORT_R@ +HAVE_RAISE = @HAVE_RAISE@ +HAVE_RANDOM = @HAVE_RANDOM@ +HAVE_RANDOM_H = @HAVE_RANDOM_H@ +HAVE_RANDOM_R = @HAVE_RANDOM_R@ +HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@ +HAVE_READDIR = @HAVE_READDIR@ +HAVE_READLINK = @HAVE_READLINK@ +HAVE_READLINKAT = @HAVE_READLINKAT@ +HAVE_REALLOCARRAY = @HAVE_REALLOCARRAY@ +HAVE_REALPATH = @HAVE_REALPATH@ +HAVE_REMAINDER = @HAVE_REMAINDER@ +HAVE_REMAINDERF = @HAVE_REMAINDERF@ +HAVE_RENAMEAT = @HAVE_RENAMEAT@ +HAVE_REWINDDIR = @HAVE_REWINDDIR@ +HAVE_RINT = @HAVE_RINT@ +HAVE_RINTL = @HAVE_RINTL@ +HAVE_RPMATCH = @HAVE_RPMATCH@ +HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = @HAVE_SAME_LONG_DOUBLE_AS_DOUBLE@ +HAVE_SA_FAMILY_T = @HAVE_SA_FAMILY_T@ +HAVE_SCANDIR = @HAVE_SCANDIR@ +HAVE_SCHED_H = @HAVE_SCHED_H@ +HAVE_SCHED_YIELD = @HAVE_SCHED_YIELD@ +HAVE_SECURE_GETENV = @HAVE_SECURE_GETENV@ +HAVE_SETENV = @HAVE_SETENV@ +HAVE_SETHOSTNAME = @HAVE_SETHOSTNAME@ +HAVE_SETSTATE = @HAVE_SETSTATE@ +HAVE_SIGACTION = @HAVE_SIGACTION@ +HAVE_SIGHANDLER_T = @HAVE_SIGHANDLER_T@ +HAVE_SIGINFO_T = @HAVE_SIGINFO_T@ +HAVE_SIGNED_SIG_ATOMIC_T = @HAVE_SIGNED_SIG_ATOMIC_T@ +HAVE_SIGNED_WCHAR_T = @HAVE_SIGNED_WCHAR_T@ +HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@ +HAVE_SIGSET_T = @HAVE_SIGSET_T@ +HAVE_SINF = @HAVE_SINF@ +HAVE_SINHF = @HAVE_SINHF@ +HAVE_SINL = @HAVE_SINL@ +HAVE_SLEEP = @HAVE_SLEEP@ +HAVE_SQRTF = @HAVE_SQRTF@ +HAVE_SQRTL = @HAVE_SQRTL@ +HAVE_STDINT_H = @HAVE_STDINT_H@ +HAVE_STPCPY = @HAVE_STPCPY@ +HAVE_STPNCPY = @HAVE_STPNCPY@ +HAVE_STRCASESTR = @HAVE_STRCASESTR@ +HAVE_STRCHRNUL = @HAVE_STRCHRNUL@ +HAVE_STRPBRK = @HAVE_STRPBRK@ +HAVE_STRPTIME = @HAVE_STRPTIME@ +HAVE_STRSEP = @HAVE_STRSEP@ +HAVE_STRTOD = @HAVE_STRTOD@ +HAVE_STRTOLD = @HAVE_STRTOLD@ +HAVE_STRTOLL = @HAVE_STRTOLL@ +HAVE_STRTOULL = @HAVE_STRTOULL@ +HAVE_STRUCT_ADDRINFO = @HAVE_STRUCT_ADDRINFO@ +HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@ +HAVE_STRUCT_SCHED_PARAM = @HAVE_STRUCT_SCHED_PARAM@ +HAVE_STRUCT_SIGACTION_SA_SIGACTION = @HAVE_STRUCT_SIGACTION_SA_SIGACTION@ +HAVE_STRUCT_SOCKADDR_STORAGE = @HAVE_STRUCT_SOCKADDR_STORAGE@ +HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY = @HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY@ +HAVE_STRUCT_TIMEVAL = @HAVE_STRUCT_TIMEVAL@ +HAVE_STRUCT_UTSNAME = @HAVE_STRUCT_UTSNAME@ +HAVE_STRVERSCMP = @HAVE_STRVERSCMP@ +HAVE_SYMLINK = @HAVE_SYMLINK@ +HAVE_SYMLINKAT = @HAVE_SYMLINKAT@ +HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@ +HAVE_SYS_CDEFS_H = @HAVE_SYS_CDEFS_H@ +HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@ +HAVE_SYS_IOCTL_H = @HAVE_SYS_IOCTL_H@ +HAVE_SYS_LOADAVG_H = @HAVE_SYS_LOADAVG_H@ +HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@ +HAVE_SYS_RESOURCE_H = @HAVE_SYS_RESOURCE_H@ +HAVE_SYS_SELECT_H = @HAVE_SYS_SELECT_H@ +HAVE_SYS_SOCKET_H = @HAVE_SYS_SOCKET_H@ +HAVE_SYS_TIME_H = @HAVE_SYS_TIME_H@ +HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@ +HAVE_SYS_UIO_H = @HAVE_SYS_UIO_H@ +HAVE_SYS_UTSNAME_H = @HAVE_SYS_UTSNAME_H@ +HAVE_TANF = @HAVE_TANF@ +HAVE_TANHF = @HAVE_TANHF@ +HAVE_TANL = @HAVE_TANL@ +HAVE_TERMIOS_H = @HAVE_TERMIOS_H@ +HAVE_TIMEGM = @HAVE_TIMEGM@ +HAVE_TIMEZONE_T = @HAVE_TIMEZONE_T@ +HAVE_TYPE_VOLATILE_SIG_ATOMIC_T = @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@ +HAVE_TZSET = @HAVE_TZSET@ +HAVE_UNAME = @HAVE_UNAME@ +HAVE_UNISTD_H = @HAVE_UNISTD_H@ +HAVE_UNLINKAT = @HAVE_UNLINKAT@ +HAVE_UNLOCKPT = @HAVE_UNLOCKPT@ +HAVE_USLEEP = @HAVE_USLEEP@ +HAVE_UTIME = @HAVE_UTIME@ +HAVE_UTIMENSAT = @HAVE_UTIMENSAT@ +HAVE_UTIME_H = @HAVE_UTIME_H@ +HAVE_VASPRINTF = @HAVE_VASPRINTF@ +HAVE_VDPRINTF = @HAVE_VDPRINTF@ +HAVE_VISIBILITY = @HAVE_VISIBILITY@ +HAVE_WCHAR_H = @HAVE_WCHAR_H@ +HAVE_WCHAR_T = @HAVE_WCHAR_T@ +HAVE_WCPCPY = @HAVE_WCPCPY@ +HAVE_WCPNCPY = @HAVE_WCPNCPY@ +HAVE_WCRTOMB = @HAVE_WCRTOMB@ +HAVE_WCSCASECMP = @HAVE_WCSCASECMP@ +HAVE_WCSCAT = @HAVE_WCSCAT@ +HAVE_WCSCHR = @HAVE_WCSCHR@ +HAVE_WCSCMP = @HAVE_WCSCMP@ +HAVE_WCSCOLL = @HAVE_WCSCOLL@ +HAVE_WCSCPY = @HAVE_WCSCPY@ +HAVE_WCSCSPN = @HAVE_WCSCSPN@ +HAVE_WCSDUP = @HAVE_WCSDUP@ +HAVE_WCSFTIME = @HAVE_WCSFTIME@ +HAVE_WCSLEN = @HAVE_WCSLEN@ +HAVE_WCSNCASECMP = @HAVE_WCSNCASECMP@ +HAVE_WCSNCAT = @HAVE_WCSNCAT@ +HAVE_WCSNCMP = @HAVE_WCSNCMP@ +HAVE_WCSNCPY = @HAVE_WCSNCPY@ +HAVE_WCSNLEN = @HAVE_WCSNLEN@ +HAVE_WCSNRTOMBS = @HAVE_WCSNRTOMBS@ +HAVE_WCSPBRK = @HAVE_WCSPBRK@ +HAVE_WCSRCHR = @HAVE_WCSRCHR@ +HAVE_WCSRTOMBS = @HAVE_WCSRTOMBS@ +HAVE_WCSSPN = @HAVE_WCSSPN@ +HAVE_WCSSTR = @HAVE_WCSSTR@ +HAVE_WCSTOK = @HAVE_WCSTOK@ +HAVE_WCSWIDTH = @HAVE_WCSWIDTH@ +HAVE_WCSXFRM = @HAVE_WCSXFRM@ +HAVE_WCTRANS_T = @HAVE_WCTRANS_T@ +HAVE_WCTYPE_H = @HAVE_WCTYPE_H@ +HAVE_WCTYPE_T = @HAVE_WCTYPE_T@ +HAVE_WINSOCK2_H = @HAVE_WINSOCK2_H@ +HAVE_WINT_T = @HAVE_WINT_T@ +HAVE_WMEMCHR = @HAVE_WMEMCHR@ +HAVE_WMEMCMP = @HAVE_WMEMCMP@ +HAVE_WMEMCPY = @HAVE_WMEMCPY@ +HAVE_WMEMMOVE = @HAVE_WMEMMOVE@ +HAVE_WMEMSET = @HAVE_WMEMSET@ +HAVE_WS2TCPIP_H = @HAVE_WS2TCPIP_H@ +HAVE_XLOCALE_H = @HAVE_XLOCALE_H@ +HAVE__BOOL = @HAVE__BOOL@ +HAVE__EXIT = @HAVE__EXIT@ +HELP2MAN = @HELP2MAN@ +HOSTENT_LIB = @HOSTENT_LIB@ +ICONV_CONST = @ICONV_CONST@ +ICONV_H = @ICONV_H@ +IGNORE_UNUSED_LIBRARIES_CFLAGS = @IGNORE_UNUSED_LIBRARIES_CFLAGS@ +INCLUDE_NEXT = @INCLUDE_NEXT@ +INCLUDE_NEXT_AS_FIRST_DIRECTIVE = @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ +INET_NTOP_LIB = @INET_NTOP_LIB@ +INET_PTON_LIB = @INET_PTON_LIB@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INT32_MAX_LT_INTMAX_MAX = @INT32_MAX_LT_INTMAX_MAX@ +INT64_MAX_EQ_LONG_MAX = @INT64_MAX_EQ_LONG_MAX@ +INTLLIBS = @INTLLIBS@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +LDFLAGS = @LDFLAGS@ +LIBCOREUTILS_LIBDEPS = @LIBCOREUTILS_LIBDEPS@ +LIBCOREUTILS_LTLIBDEPS = @LIBCOREUTILS_LTLIBDEPS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBMULTITHREAD = @LIBMULTITHREAD@ +LIBOBJS = @LIBOBJS@ +LIBPMULTITHREAD = @LIBPMULTITHREAD@ +LIBPTHREAD = @LIBPTHREAD@ +LIBS = @LIBS@ +LIBSOCKET = @LIBSOCKET@ +LIBSTDTHREAD = @LIBSTDTHREAD@ +LIBTESTS_LIBDEPS = @LIBTESTS_LIBDEPS@ +LIBTHREAD = @LIBTHREAD@ +LIBUNISTRING_UNISTR_H = @LIBUNISTRING_UNISTR_H@ +LIBUNISTRING_UNITYPES_H = @LIBUNISTRING_UNITYPES_H@ +LIBUNISTRING_UNIWIDTH_H = @LIBUNISTRING_UNIWIDTH_H@ +LIB_ACL = @LIB_ACL@ +LIB_CAP = @LIB_CAP@ +LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@ +LIB_CRYPTO = @LIB_CRYPTO@ +LIB_EACCESS = @LIB_EACCESS@ +LIB_FDATASYNC = @LIB_FDATASYNC@ +LIB_GETHRXTIME = @LIB_GETHRXTIME@ +LIB_GETLOGIN = @LIB_GETLOGIN@ +LIB_GMP = @LIB_GMP@ +LIB_HARD_LOCALE = @LIB_HARD_LOCALE@ +LIB_HAS_ACL = @LIB_HAS_ACL@ +LIB_MBRTOWC = @LIB_MBRTOWC@ +LIB_NANOSLEEP = @LIB_NANOSLEEP@ +LIB_NL_LANGINFO = @LIB_NL_LANGINFO@ +LIB_NVPAIR = @LIB_NVPAIR@ +LIB_PTHREAD = @LIB_PTHREAD@ +LIB_PTHREAD_SIGMASK = @LIB_PTHREAD_SIGMASK@ +LIB_SCHED_YIELD = @LIB_SCHED_YIELD@ +LIB_SELECT = @LIB_SELECT@ +LIB_SELINUX = @LIB_SELINUX@ +LIB_SEMAPHORE = @LIB_SEMAPHORE@ +LIB_SETLOCALE = @LIB_SETLOCALE@ +LIB_SETLOCALE_NULL = @LIB_SETLOCALE_NULL@ +LIB_SMACK = @LIB_SMACK@ +LIB_TIMER_TIME = @LIB_TIMER_TIME@ +LIB_XATTR = @LIB_XATTR@ +LIMITS_H = @LIMITS_H@ +LN_S = @LN_S@ +LOCALCHARSET_TESTS_ENVIRONMENT = @LOCALCHARSET_TESTS_ENVIRONMENT@ +LOCALE_FR = @LOCALE_FR@ +LOCALE_FR_UTF8 = @LOCALE_FR_UTF8@ +LOCALE_JA = @LOCALE_JA@ +LOCALE_TR_UTF8 = @LOCALE_TR_UTF8@ +LOCALE_ZH_CN = @LOCALE_ZH_CN@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBMULTITHREAD = @LTLIBMULTITHREAD@ +LTLIBOBJS = @LTLIBOBJS@ +LTLIBTHREAD = @LTLIBTHREAD@ +MAKEINFO = @MAKEINFO@ +MAN = @MAN@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGMERGE = @MSGMERGE@ +NETINET_IN_H = @NETINET_IN_H@ +NEXT_ARPA_INET_H = @NEXT_ARPA_INET_H@ +NEXT_AS_FIRST_DIRECTIVE_ARPA_INET_H = @NEXT_AS_FIRST_DIRECTIVE_ARPA_INET_H@ +NEXT_AS_FIRST_DIRECTIVE_CTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_CTYPE_H@ +NEXT_AS_FIRST_DIRECTIVE_DIRENT_H = @NEXT_AS_FIRST_DIRECTIVE_DIRENT_H@ +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_FNMATCH_H = @NEXT_AS_FIRST_DIRECTIVE_FNMATCH_H@ +NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@ +NEXT_AS_FIRST_DIRECTIVE_ICONV_H = @NEXT_AS_FIRST_DIRECTIVE_ICONV_H@ +NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H = @NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H@ +NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H = @NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H@ +NEXT_AS_FIRST_DIRECTIVE_LIMITS_H = @NEXT_AS_FIRST_DIRECTIVE_LIMITS_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_NETDB_H = @NEXT_AS_FIRST_DIRECTIVE_NETDB_H@ +NEXT_AS_FIRST_DIRECTIVE_NETINET_IN_H = @NEXT_AS_FIRST_DIRECTIVE_NETINET_IN_H@ +NEXT_AS_FIRST_DIRECTIVE_PTHREAD_H = @NEXT_AS_FIRST_DIRECTIVE_PTHREAD_H@ +NEXT_AS_FIRST_DIRECTIVE_SCHED_H = @NEXT_AS_FIRST_DIRECTIVE_SCHED_H@ +NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H = @NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H@ +NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H = @NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H@ +NEXT_AS_FIRST_DIRECTIVE_STDARG_H = @NEXT_AS_FIRST_DIRECTIVE_STDARG_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_STDIO_H = @NEXT_AS_FIRST_DIRECTIVE_STDIO_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@ +NEXT_AS_FIRST_DIRECTIVE_SYS_IOCTL_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_IOCTL_H@ +NEXT_AS_FIRST_DIRECTIVE_SYS_RESOURCE_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_RESOURCE_H@ +NEXT_AS_FIRST_DIRECTIVE_SYS_SELECT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_SELECT_H@ +NEXT_AS_FIRST_DIRECTIVE_SYS_SOCKET_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_SOCKET_H@ +NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H@ +NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H@ +NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H@ +NEXT_AS_FIRST_DIRECTIVE_SYS_UIO_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_UIO_H@ +NEXT_AS_FIRST_DIRECTIVE_SYS_UTSNAME_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_UTSNAME_H@ +NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H@ +NEXT_AS_FIRST_DIRECTIVE_TERMIOS_H = @NEXT_AS_FIRST_DIRECTIVE_TERMIOS_H@ +NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@ +NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@ +NEXT_AS_FIRST_DIRECTIVE_UTIME_H = @NEXT_AS_FIRST_DIRECTIVE_UTIME_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_CTYPE_H = @NEXT_CTYPE_H@ +NEXT_DIRENT_H = @NEXT_DIRENT_H@ +NEXT_ERRNO_H = @NEXT_ERRNO_H@ +NEXT_FCNTL_H = @NEXT_FCNTL_H@ +NEXT_FLOAT_H = @NEXT_FLOAT_H@ +NEXT_FNMATCH_H = @NEXT_FNMATCH_H@ +NEXT_GETOPT_H = @NEXT_GETOPT_H@ +NEXT_ICONV_H = @NEXT_ICONV_H@ +NEXT_INTTYPES_H = @NEXT_INTTYPES_H@ +NEXT_LANGINFO_H = @NEXT_LANGINFO_H@ +NEXT_LIMITS_H = @NEXT_LIMITS_H@ +NEXT_LOCALE_H = @NEXT_LOCALE_H@ +NEXT_MATH_H = @NEXT_MATH_H@ +NEXT_NETDB_H = @NEXT_NETDB_H@ +NEXT_NETINET_IN_H = @NEXT_NETINET_IN_H@ +NEXT_PTHREAD_H = @NEXT_PTHREAD_H@ +NEXT_SCHED_H = @NEXT_SCHED_H@ +NEXT_SELINUX_SELINUX_H = @NEXT_SELINUX_SELINUX_H@ +NEXT_SIGNAL_H = @NEXT_SIGNAL_H@ +NEXT_STDARG_H = @NEXT_STDARG_H@ +NEXT_STDDEF_H = @NEXT_STDDEF_H@ +NEXT_STDINT_H = @NEXT_STDINT_H@ +NEXT_STDIO_H = @NEXT_STDIO_H@ +NEXT_STDLIB_H = @NEXT_STDLIB_H@ +NEXT_STRING_H = @NEXT_STRING_H@ +NEXT_SYS_IOCTL_H = @NEXT_SYS_IOCTL_H@ +NEXT_SYS_RESOURCE_H = @NEXT_SYS_RESOURCE_H@ +NEXT_SYS_SELECT_H = @NEXT_SYS_SELECT_H@ +NEXT_SYS_SOCKET_H = @NEXT_SYS_SOCKET_H@ +NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@ +NEXT_SYS_TIME_H = @NEXT_SYS_TIME_H@ +NEXT_SYS_TYPES_H = @NEXT_SYS_TYPES_H@ +NEXT_SYS_UIO_H = @NEXT_SYS_UIO_H@ +NEXT_SYS_UTSNAME_H = @NEXT_SYS_UTSNAME_H@ +NEXT_SYS_WAIT_H = @NEXT_SYS_WAIT_H@ +NEXT_TERMIOS_H = @NEXT_TERMIOS_H@ +NEXT_TIME_H = @NEXT_TIME_H@ +NEXT_UNISTD_H = @NEXT_UNISTD_H@ +NEXT_UTIME_H = @NEXT_UTIME_H@ +NEXT_WCHAR_H = @NEXT_WCHAR_H@ +NEXT_WCTYPE_H = @NEXT_WCTYPE_H@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PARSE_DATETIME_BISON = @PARSE_DATETIME_BISON@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +POSIX_SHELL = @POSIX_SHELL@ +POSUB = @POSUB@ +PRAGMA_COLUMNS = @PRAGMA_COLUMNS@ +PRAGMA_SYSTEM_HEADER = @PRAGMA_SYSTEM_HEADER@ +PREFERABLY_POSIX_SHELL = @PREFERABLY_POSIX_SHELL@ +PRIPTR_PREFIX = @PRIPTR_PREFIX@ +PRI_MACROS_BROKEN = @PRI_MACROS_BROKEN@ +PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@ +PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@ +RANLIB = @RANLIB@ +REPLACE_ACCESS = @REPLACE_ACCESS@ +REPLACE_ACOSF = @REPLACE_ACOSF@ +REPLACE_ASINF = @REPLACE_ASINF@ +REPLACE_ATAN2F = @REPLACE_ATAN2F@ +REPLACE_ATANF = @REPLACE_ATANF@ +REPLACE_BTOWC = @REPLACE_BTOWC@ +REPLACE_CALLOC = @REPLACE_CALLOC@ +REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@ +REPLACE_CBRTF = @REPLACE_CBRTF@ +REPLACE_CBRTL = @REPLACE_CBRTL@ +REPLACE_CEIL = @REPLACE_CEIL@ +REPLACE_CEILF = @REPLACE_CEILF@ +REPLACE_CEILL = @REPLACE_CEILL@ +REPLACE_CHOWN = @REPLACE_CHOWN@ +REPLACE_CLOSE = @REPLACE_CLOSE@ +REPLACE_CLOSEDIR = @REPLACE_CLOSEDIR@ +REPLACE_COSF = @REPLACE_COSF@ +REPLACE_COSHF = @REPLACE_COSHF@ +REPLACE_CREAT = @REPLACE_CREAT@ +REPLACE_CTIME = @REPLACE_CTIME@ +REPLACE_DIRFD = @REPLACE_DIRFD@ +REPLACE_DPRINTF = @REPLACE_DPRINTF@ +REPLACE_DUP = @REPLACE_DUP@ +REPLACE_DUP2 = @REPLACE_DUP2@ +REPLACE_DUPLOCALE = @REPLACE_DUPLOCALE@ +REPLACE_EXP2 = @REPLACE_EXP2@ +REPLACE_EXP2L = @REPLACE_EXP2L@ +REPLACE_EXPF = @REPLACE_EXPF@ +REPLACE_EXPL = @REPLACE_EXPL@ +REPLACE_EXPM1 = @REPLACE_EXPM1@ +REPLACE_EXPM1F = @REPLACE_EXPM1F@ +REPLACE_EXPM1L = @REPLACE_EXPM1L@ +REPLACE_FABSL = @REPLACE_FABSL@ +REPLACE_FACCESSAT = @REPLACE_FACCESSAT@ +REPLACE_FCHMODAT = @REPLACE_FCHMODAT@ +REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@ +REPLACE_FCLOSE = @REPLACE_FCLOSE@ +REPLACE_FCNTL = @REPLACE_FCNTL@ +REPLACE_FDOPEN = @REPLACE_FDOPEN@ +REPLACE_FDOPENDIR = @REPLACE_FDOPENDIR@ +REPLACE_FFLUSH = @REPLACE_FFLUSH@ +REPLACE_FLOOR = @REPLACE_FLOOR@ +REPLACE_FLOORF = @REPLACE_FLOORF@ +REPLACE_FLOORL = @REPLACE_FLOORL@ +REPLACE_FMA = @REPLACE_FMA@ +REPLACE_FMAF = @REPLACE_FMAF@ +REPLACE_FMAL = @REPLACE_FMAL@ +REPLACE_FMOD = @REPLACE_FMOD@ +REPLACE_FMODF = @REPLACE_FMODF@ +REPLACE_FMODL = @REPLACE_FMODL@ +REPLACE_FNMATCH = @REPLACE_FNMATCH@ +REPLACE_FOPEN = @REPLACE_FOPEN@ +REPLACE_FPRINTF = @REPLACE_FPRINTF@ +REPLACE_FPURGE = @REPLACE_FPURGE@ +REPLACE_FREELOCALE = @REPLACE_FREELOCALE@ +REPLACE_FREOPEN = @REPLACE_FREOPEN@ +REPLACE_FREXP = @REPLACE_FREXP@ +REPLACE_FREXPF = @REPLACE_FREXPF@ +REPLACE_FREXPL = @REPLACE_FREXPL@ +REPLACE_FSEEK = @REPLACE_FSEEK@ +REPLACE_FSEEKO = @REPLACE_FSEEKO@ +REPLACE_FSTAT = @REPLACE_FSTAT@ +REPLACE_FSTATAT = @REPLACE_FSTATAT@ +REPLACE_FTELL = @REPLACE_FTELL@ +REPLACE_FTELLO = @REPLACE_FTELLO@ +REPLACE_FTRUNCATE = @REPLACE_FTRUNCATE@ +REPLACE_FUTIMENS = @REPLACE_FUTIMENS@ +REPLACE_GAI_STRERROR = @REPLACE_GAI_STRERROR@ +REPLACE_GETADDRINFO = @REPLACE_GETADDRINFO@ +REPLACE_GETCWD = @REPLACE_GETCWD@ +REPLACE_GETDELIM = @REPLACE_GETDELIM@ +REPLACE_GETDOMAINNAME = @REPLACE_GETDOMAINNAME@ +REPLACE_GETDTABLESIZE = @REPLACE_GETDTABLESIZE@ +REPLACE_GETGROUPS = @REPLACE_GETGROUPS@ +REPLACE_GETLINE = @REPLACE_GETLINE@ +REPLACE_GETLOGIN_R = @REPLACE_GETLOGIN_R@ +REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@ +REPLACE_GETPASS = @REPLACE_GETPASS@ +REPLACE_GETTIMEOFDAY = @REPLACE_GETTIMEOFDAY@ +REPLACE_GMTIME = @REPLACE_GMTIME@ +REPLACE_HUGE_VAL = @REPLACE_HUGE_VAL@ +REPLACE_HYPOT = @REPLACE_HYPOT@ +REPLACE_HYPOTF = @REPLACE_HYPOTF@ +REPLACE_HYPOTL = @REPLACE_HYPOTL@ +REPLACE_ICONV = @REPLACE_ICONV@ +REPLACE_ICONV_OPEN = @REPLACE_ICONV_OPEN@ +REPLACE_ICONV_UTF = @REPLACE_ICONV_UTF@ +REPLACE_ILOGB = @REPLACE_ILOGB@ +REPLACE_ILOGBF = @REPLACE_ILOGBF@ +REPLACE_ILOGBL = @REPLACE_ILOGBL@ +REPLACE_INET_NTOP = @REPLACE_INET_NTOP@ +REPLACE_INET_PTON = @REPLACE_INET_PTON@ +REPLACE_INITSTATE = @REPLACE_INITSTATE@ +REPLACE_IOCTL = @REPLACE_IOCTL@ +REPLACE_ISATTY = @REPLACE_ISATTY@ +REPLACE_ISFINITE = @REPLACE_ISFINITE@ +REPLACE_ISINF = @REPLACE_ISINF@ +REPLACE_ISNAN = @REPLACE_ISNAN@ +REPLACE_ISWBLANK = @REPLACE_ISWBLANK@ +REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@ +REPLACE_ISWDIGIT = @REPLACE_ISWDIGIT@ +REPLACE_ISWXDIGIT = @REPLACE_ISWXDIGIT@ +REPLACE_ITOLD = @REPLACE_ITOLD@ +REPLACE_LCHOWN = @REPLACE_LCHOWN@ +REPLACE_LDEXPL = @REPLACE_LDEXPL@ +REPLACE_LINK = @REPLACE_LINK@ +REPLACE_LINKAT = @REPLACE_LINKAT@ +REPLACE_LOCALECONV = @REPLACE_LOCALECONV@ +REPLACE_LOCALTIME = @REPLACE_LOCALTIME@ +REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@ +REPLACE_LOG = @REPLACE_LOG@ +REPLACE_LOG10 = @REPLACE_LOG10@ +REPLACE_LOG10F = @REPLACE_LOG10F@ +REPLACE_LOG10L = @REPLACE_LOG10L@ +REPLACE_LOG1P = @REPLACE_LOG1P@ +REPLACE_LOG1PF = @REPLACE_LOG1PF@ +REPLACE_LOG1PL = @REPLACE_LOG1PL@ +REPLACE_LOG2 = @REPLACE_LOG2@ +REPLACE_LOG2F = @REPLACE_LOG2F@ +REPLACE_LOG2L = @REPLACE_LOG2L@ +REPLACE_LOGB = @REPLACE_LOGB@ +REPLACE_LOGBF = @REPLACE_LOGBF@ +REPLACE_LOGBL = @REPLACE_LOGBL@ +REPLACE_LOGF = @REPLACE_LOGF@ +REPLACE_LOGL = @REPLACE_LOGL@ +REPLACE_LSEEK = @REPLACE_LSEEK@ +REPLACE_LSTAT = @REPLACE_LSTAT@ +REPLACE_MALLOC = @REPLACE_MALLOC@ +REPLACE_MBRLEN = @REPLACE_MBRLEN@ +REPLACE_MBRTOWC = @REPLACE_MBRTOWC@ +REPLACE_MBSINIT = @REPLACE_MBSINIT@ +REPLACE_MBSNRTOWCS = @REPLACE_MBSNRTOWCS@ +REPLACE_MBSRTOWCS = @REPLACE_MBSRTOWCS@ +REPLACE_MBSTATE_T = @REPLACE_MBSTATE_T@ +REPLACE_MBTOWC = @REPLACE_MBTOWC@ +REPLACE_MEMCHR = @REPLACE_MEMCHR@ +REPLACE_MEMMEM = @REPLACE_MEMMEM@ +REPLACE_MKDIR = @REPLACE_MKDIR@ +REPLACE_MKFIFO = @REPLACE_MKFIFO@ +REPLACE_MKNOD = @REPLACE_MKNOD@ +REPLACE_MKSTEMP = @REPLACE_MKSTEMP@ +REPLACE_MKTIME = @REPLACE_MKTIME@ +REPLACE_MODF = @REPLACE_MODF@ +REPLACE_MODFF = @REPLACE_MODFF@ +REPLACE_MODFL = @REPLACE_MODFL@ +REPLACE_NAN = @REPLACE_NAN@ +REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@ +REPLACE_NEWLOCALE = @REPLACE_NEWLOCALE@ +REPLACE_NL_LANGINFO = @REPLACE_NL_LANGINFO@ +REPLACE_NULL = @REPLACE_NULL@ +REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@ +REPLACE_OPEN = @REPLACE_OPEN@ +REPLACE_OPENAT = @REPLACE_OPENAT@ +REPLACE_OPENDIR = @REPLACE_OPENDIR@ +REPLACE_PERROR = @REPLACE_PERROR@ +REPLACE_POPEN = @REPLACE_POPEN@ +REPLACE_PREAD = @REPLACE_PREAD@ +REPLACE_PRINTF = @REPLACE_PRINTF@ +REPLACE_PSELECT = @REPLACE_PSELECT@ +REPLACE_PTHREAD_ATTR_DESTROY = @REPLACE_PTHREAD_ATTR_DESTROY@ +REPLACE_PTHREAD_ATTR_GETDETACHSTATE = @REPLACE_PTHREAD_ATTR_GETDETACHSTATE@ +REPLACE_PTHREAD_ATTR_INIT = @REPLACE_PTHREAD_ATTR_INIT@ +REPLACE_PTHREAD_ATTR_SETDETACHSTATE = @REPLACE_PTHREAD_ATTR_SETDETACHSTATE@ +REPLACE_PTHREAD_CONDATTR_DESTROY = @REPLACE_PTHREAD_CONDATTR_DESTROY@ +REPLACE_PTHREAD_CONDATTR_INIT = @REPLACE_PTHREAD_CONDATTR_INIT@ +REPLACE_PTHREAD_COND_BROADCAST = @REPLACE_PTHREAD_COND_BROADCAST@ +REPLACE_PTHREAD_COND_DESTROY = @REPLACE_PTHREAD_COND_DESTROY@ +REPLACE_PTHREAD_COND_INIT = @REPLACE_PTHREAD_COND_INIT@ +REPLACE_PTHREAD_COND_SIGNAL = @REPLACE_PTHREAD_COND_SIGNAL@ +REPLACE_PTHREAD_COND_TIMEDWAIT = @REPLACE_PTHREAD_COND_TIMEDWAIT@ +REPLACE_PTHREAD_COND_WAIT = @REPLACE_PTHREAD_COND_WAIT@ +REPLACE_PTHREAD_CREATE = @REPLACE_PTHREAD_CREATE@ +REPLACE_PTHREAD_DETACH = @REPLACE_PTHREAD_DETACH@ +REPLACE_PTHREAD_EQUAL = @REPLACE_PTHREAD_EQUAL@ +REPLACE_PTHREAD_EXIT = @REPLACE_PTHREAD_EXIT@ +REPLACE_PTHREAD_GETSPECIFIC = @REPLACE_PTHREAD_GETSPECIFIC@ +REPLACE_PTHREAD_JOIN = @REPLACE_PTHREAD_JOIN@ +REPLACE_PTHREAD_KEY_CREATE = @REPLACE_PTHREAD_KEY_CREATE@ +REPLACE_PTHREAD_KEY_DELETE = @REPLACE_PTHREAD_KEY_DELETE@ +REPLACE_PTHREAD_MUTEXATTR_DESTROY = @REPLACE_PTHREAD_MUTEXATTR_DESTROY@ +REPLACE_PTHREAD_MUTEXATTR_GETROBUST = @REPLACE_PTHREAD_MUTEXATTR_GETROBUST@ +REPLACE_PTHREAD_MUTEXATTR_GETTYPE = @REPLACE_PTHREAD_MUTEXATTR_GETTYPE@ +REPLACE_PTHREAD_MUTEXATTR_INIT = @REPLACE_PTHREAD_MUTEXATTR_INIT@ +REPLACE_PTHREAD_MUTEXATTR_SETROBUST = @REPLACE_PTHREAD_MUTEXATTR_SETROBUST@ +REPLACE_PTHREAD_MUTEXATTR_SETTYPE = @REPLACE_PTHREAD_MUTEXATTR_SETTYPE@ +REPLACE_PTHREAD_MUTEX_DESTROY = @REPLACE_PTHREAD_MUTEX_DESTROY@ +REPLACE_PTHREAD_MUTEX_INIT = @REPLACE_PTHREAD_MUTEX_INIT@ +REPLACE_PTHREAD_MUTEX_LOCK = @REPLACE_PTHREAD_MUTEX_LOCK@ +REPLACE_PTHREAD_MUTEX_TIMEDLOCK = @REPLACE_PTHREAD_MUTEX_TIMEDLOCK@ +REPLACE_PTHREAD_MUTEX_TRYLOCK = @REPLACE_PTHREAD_MUTEX_TRYLOCK@ +REPLACE_PTHREAD_MUTEX_UNLOCK = @REPLACE_PTHREAD_MUTEX_UNLOCK@ +REPLACE_PTHREAD_ONCE = @REPLACE_PTHREAD_ONCE@ +REPLACE_PTHREAD_RWLOCKATTR_DESTROY = @REPLACE_PTHREAD_RWLOCKATTR_DESTROY@ +REPLACE_PTHREAD_RWLOCKATTR_INIT = @REPLACE_PTHREAD_RWLOCKATTR_INIT@ +REPLACE_PTHREAD_RWLOCK_DESTROY = @REPLACE_PTHREAD_RWLOCK_DESTROY@ +REPLACE_PTHREAD_RWLOCK_INIT = @REPLACE_PTHREAD_RWLOCK_INIT@ +REPLACE_PTHREAD_RWLOCK_RDLOCK = @REPLACE_PTHREAD_RWLOCK_RDLOCK@ +REPLACE_PTHREAD_RWLOCK_TIMEDRDLOCK = @REPLACE_PTHREAD_RWLOCK_TIMEDRDLOCK@ +REPLACE_PTHREAD_RWLOCK_TIMEDWRLOCK = @REPLACE_PTHREAD_RWLOCK_TIMEDWRLOCK@ +REPLACE_PTHREAD_RWLOCK_TRYRDLOCK = @REPLACE_PTHREAD_RWLOCK_TRYRDLOCK@ +REPLACE_PTHREAD_RWLOCK_TRYWRLOCK = @REPLACE_PTHREAD_RWLOCK_TRYWRLOCK@ +REPLACE_PTHREAD_RWLOCK_UNLOCK = @REPLACE_PTHREAD_RWLOCK_UNLOCK@ +REPLACE_PTHREAD_RWLOCK_WRLOCK = @REPLACE_PTHREAD_RWLOCK_WRLOCK@ +REPLACE_PTHREAD_SELF = @REPLACE_PTHREAD_SELF@ +REPLACE_PTHREAD_SETSPECIFIC = @REPLACE_PTHREAD_SETSPECIFIC@ +REPLACE_PTHREAD_SIGMASK = @REPLACE_PTHREAD_SIGMASK@ +REPLACE_PTHREAD_SPIN_DESTROY = @REPLACE_PTHREAD_SPIN_DESTROY@ +REPLACE_PTHREAD_SPIN_INIT = @REPLACE_PTHREAD_SPIN_INIT@ +REPLACE_PTHREAD_SPIN_LOCK = @REPLACE_PTHREAD_SPIN_LOCK@ +REPLACE_PTHREAD_SPIN_TRYLOCK = @REPLACE_PTHREAD_SPIN_TRYLOCK@ +REPLACE_PTHREAD_SPIN_UNLOCK = @REPLACE_PTHREAD_SPIN_UNLOCK@ +REPLACE_PTSNAME = @REPLACE_PTSNAME@ +REPLACE_PTSNAME_R = @REPLACE_PTSNAME_R@ +REPLACE_PUTENV = @REPLACE_PUTENV@ +REPLACE_PWRITE = @REPLACE_PWRITE@ +REPLACE_QSORT_R = @REPLACE_QSORT_R@ +REPLACE_RAISE = @REPLACE_RAISE@ +REPLACE_RANDOM = @REPLACE_RANDOM@ +REPLACE_RANDOM_R = @REPLACE_RANDOM_R@ +REPLACE_READ = @REPLACE_READ@ +REPLACE_READLINK = @REPLACE_READLINK@ +REPLACE_READLINKAT = @REPLACE_READLINKAT@ +REPLACE_REALLOC = @REPLACE_REALLOC@ +REPLACE_REALPATH = @REPLACE_REALPATH@ +REPLACE_REMAINDER = @REPLACE_REMAINDER@ +REPLACE_REMAINDERF = @REPLACE_REMAINDERF@ +REPLACE_REMAINDERL = @REPLACE_REMAINDERL@ +REPLACE_REMOVE = @REPLACE_REMOVE@ +REPLACE_RENAME = @REPLACE_RENAME@ +REPLACE_RENAMEAT = @REPLACE_RENAMEAT@ +REPLACE_RINTL = @REPLACE_RINTL@ +REPLACE_RMDIR = @REPLACE_RMDIR@ +REPLACE_ROUND = @REPLACE_ROUND@ +REPLACE_ROUNDF = @REPLACE_ROUNDF@ +REPLACE_ROUNDL = @REPLACE_ROUNDL@ +REPLACE_SCHED_YIELD = @REPLACE_SCHED_YIELD@ +REPLACE_SELECT = @REPLACE_SELECT@ +REPLACE_SETENV = @REPLACE_SETENV@ +REPLACE_SETLOCALE = @REPLACE_SETLOCALE@ +REPLACE_SETSTATE = @REPLACE_SETSTATE@ +REPLACE_SIGNBIT = @REPLACE_SIGNBIT@ +REPLACE_SIGNBIT_USING_GCC = @REPLACE_SIGNBIT_USING_GCC@ +REPLACE_SINF = @REPLACE_SINF@ +REPLACE_SINHF = @REPLACE_SINHF@ +REPLACE_SLEEP = @REPLACE_SLEEP@ +REPLACE_SNPRINTF = @REPLACE_SNPRINTF@ +REPLACE_SPRINTF = @REPLACE_SPRINTF@ +REPLACE_SQRTF = @REPLACE_SQRTF@ +REPLACE_SQRTL = @REPLACE_SQRTL@ +REPLACE_STAT = @REPLACE_STAT@ +REPLACE_STDIO_READ_FUNCS = @REPLACE_STDIO_READ_FUNCS@ +REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@ +REPLACE_STPNCPY = @REPLACE_STPNCPY@ +REPLACE_STRCASESTR = @REPLACE_STRCASESTR@ +REPLACE_STRCHRNUL = @REPLACE_STRCHRNUL@ +REPLACE_STRDUP = @REPLACE_STRDUP@ +REPLACE_STRERROR = @REPLACE_STRERROR@ +REPLACE_STRERROR_R = @REPLACE_STRERROR_R@ +REPLACE_STRFTIME = @REPLACE_STRFTIME@ +REPLACE_STRNCAT = @REPLACE_STRNCAT@ +REPLACE_STRNDUP = @REPLACE_STRNDUP@ +REPLACE_STRNLEN = @REPLACE_STRNLEN@ +REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@ +REPLACE_STRSTR = @REPLACE_STRSTR@ +REPLACE_STRTOD = @REPLACE_STRTOD@ +REPLACE_STRTOIMAX = @REPLACE_STRTOIMAX@ +REPLACE_STRTOK_R = @REPLACE_STRTOK_R@ +REPLACE_STRTOLD = @REPLACE_STRTOLD@ +REPLACE_STRTOUMAX = @REPLACE_STRTOUMAX@ +REPLACE_STRUCT_LCONV = @REPLACE_STRUCT_LCONV@ +REPLACE_STRUCT_TIMEVAL = @REPLACE_STRUCT_TIMEVAL@ +REPLACE_SYMLINK = @REPLACE_SYMLINK@ +REPLACE_SYMLINKAT = @REPLACE_SYMLINKAT@ +REPLACE_TANF = @REPLACE_TANF@ +REPLACE_TANHF = @REPLACE_TANHF@ +REPLACE_TIMEGM = @REPLACE_TIMEGM@ +REPLACE_TMPFILE = @REPLACE_TMPFILE@ +REPLACE_TOWLOWER = @REPLACE_TOWLOWER@ +REPLACE_TRUNC = @REPLACE_TRUNC@ +REPLACE_TRUNCATE = @REPLACE_TRUNCATE@ +REPLACE_TRUNCF = @REPLACE_TRUNCF@ +REPLACE_TRUNCL = @REPLACE_TRUNCL@ +REPLACE_TTYNAME_R = @REPLACE_TTYNAME_R@ +REPLACE_TZSET = @REPLACE_TZSET@ +REPLACE_UNLINK = @REPLACE_UNLINK@ +REPLACE_UNLINKAT = @REPLACE_UNLINKAT@ +REPLACE_UNSETENV = @REPLACE_UNSETENV@ +REPLACE_USLEEP = @REPLACE_USLEEP@ +REPLACE_UTIME = @REPLACE_UTIME@ +REPLACE_UTIMENSAT = @REPLACE_UTIMENSAT@ +REPLACE_VASPRINTF = @REPLACE_VASPRINTF@ +REPLACE_VDPRINTF = @REPLACE_VDPRINTF@ +REPLACE_VFPRINTF = @REPLACE_VFPRINTF@ +REPLACE_VPRINTF = @REPLACE_VPRINTF@ +REPLACE_VSNPRINTF = @REPLACE_VSNPRINTF@ +REPLACE_VSPRINTF = @REPLACE_VSPRINTF@ +REPLACE_WCRTOMB = @REPLACE_WCRTOMB@ +REPLACE_WCSFTIME = @REPLACE_WCSFTIME@ +REPLACE_WCSNRTOMBS = @REPLACE_WCSNRTOMBS@ +REPLACE_WCSRTOMBS = @REPLACE_WCSRTOMBS@ +REPLACE_WCSTOK = @REPLACE_WCSTOK@ +REPLACE_WCSWIDTH = @REPLACE_WCSWIDTH@ +REPLACE_WCTOB = @REPLACE_WCTOB@ +REPLACE_WCTOMB = @REPLACE_WCTOMB@ +REPLACE_WCWIDTH = @REPLACE_WCWIDTH@ +REPLACE_WRITE = @REPLACE_WRITE@ +SED = @SED@ +SELINUX_CONTEXT_H = @SELINUX_CONTEXT_H@ +SEQ_LIBM = @SEQ_LIBM@ +SERVENT_LIB = @SERVENT_LIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@ +SIZE_T_SUFFIX = @SIZE_T_SUFFIX@ +STDALIGN_H = @STDALIGN_H@ +STDARG_H = @STDARG_H@ +STDBOOL_H = @STDBOOL_H@ +STDDEF_H = @STDDEF_H@ +STDINT_H = @STDINT_H@ +STRIP = @STRIP@ +SYS_IOCTL_H_HAVE_WINSOCK2_H = @SYS_IOCTL_H_HAVE_WINSOCK2_H@ +SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ +SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ +TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@ +UINT32_MAX_LT_UINTMAX_MAX = @UINT32_MAX_LT_UINTMAX_MAX@ +UINT64_MAX_EQ_ULONG_MAX = @UINT64_MAX_EQ_ULONG_MAX@ +UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@ +UNISTD_H_DEFINES_STRUCT_TIMESPEC = @UNISTD_H_DEFINES_STRUCT_TIMESPEC@ +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@ +USE_ACL = @USE_ACL@ +USE_NLS = @USE_NLS@ +UTIME_H = @UTIME_H@ +VERSION = @VERSION@ +WARN_CFLAGS = @WARN_CFLAGS@ +WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@ +WERROR_CFLAGS = @WERROR_CFLAGS@ +WINDOWS_64_BIT_OFF_T = @WINDOWS_64_BIT_OFF_T@ +WINDOWS_64_BIT_ST_SIZE = @WINDOWS_64_BIT_ST_SIZE@ +WINDOWS_STAT_INODES = @WINDOWS_STAT_INODES@ +WINDOWS_STAT_TIMESPEC = @WINDOWS_STAT_TIMESPEC@ +WINT_T_SUFFIX = @WINT_T_SUFFIX@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +YIELD_LIB = @YIELD_LIB@ +abs_aux_dir = @abs_aux_dir@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +built_programs = @built_programs@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +gl_LIBOBJS = @gl_LIBOBJS@ +gl_LTLIBOBJS = @gl_LTLIBOBJS@ +gltests_LIBOBJS = @gltests_LIBOBJS@ +gltests_LTLIBOBJS = @gltests_LTLIBOBJS@ +gltests_WITNESS = @gltests_WITNESS@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +lispdir = @lispdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +single_binary_deps = @single_binary_deps@ +single_binary_install_type = @single_binary_install_type@ +single_binary_libs = @single_binary_libs@ +single_binary_progs = @single_binary_progs@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AUTOMAKE_OPTIONS = 1.11 foreign subdir-objects +SUBDIRS = . +TESTS_ENVIRONMENT = EXEEXT='@EXEEXT@' srcdir='$(srcdir)' \ + USE_ACL=$(USE_ACL) LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' LOCALE_FR='@LOCALE_FR@' \ + LOCALE_TR_UTF8='@LOCALE_TR_UTF8@' USE_ACL=$(USE_ACL) \ + LOCALE_FR='@LOCALE_FR@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' LOCALE_ZH_CN='@LOCALE_ZH_CN@' \ + LOCALE_FR='@LOCALE_FR@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' LOCALE_ZH_CN='@LOCALE_ZH_CN@' \ + LOCALE_FR='@LOCALE_FR@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' LOCALE_ZH_CN='@LOCALE_ZH_CN@' \ + LOCALE_TR_UTF8='@LOCALE_TR_UTF8@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' abs_aux_dir='$(abs_aux_dir)' \ + abs_aux_dir='$(abs_aux_dir)' MAKE='$(MAKE)' \ + LOCALE_FR='@LOCALE_FR@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' LOCALE_ZH_CN='@LOCALE_ZH_CN@' +noinst_HEADERS = +noinst_LIBRARIES = +check_LIBRARIES = libtests.a +EXTRA_DIST = accept.c w32sock.h test-accept.c signature.h macros.h \ + test-set-mode-acl.sh test-set-mode-acl-1.sh \ + test-set-mode-acl-2.sh test-copy-acl.sh test-copy-acl-1.sh \ + test-copy-acl-2.sh test-set-mode-acl.c test-copy-acl.c \ + test-sameacls.c macros.h test-alignof.c test-alloca-opt.c \ + test-areadlink.h test-areadlink.c macros.h test-areadlink.h \ + test-areadlink-with-size.c macros.h test-areadlink.h \ + test-areadlinkat.c macros.h test-argmatch.c macros.h \ + test-argv-iter.c macros.h test-arpa_inet.c test-base32.c \ + macros.h test-base64.c macros.h test-binary-io.sh \ + test-binary-io.c macros.h bind.c w32sock.h test-bind.c \ + signature.h macros.h test-bitrotate.c macros.h test-btowc1.sh \ + test-btowc2.sh test-btowc.c signature.h macros.h \ + test-byteswap.c macros.h test-c-ctype.c macros.h \ + test-c-strcase.sh test-c-strcasecmp.c test-c-strncasecmp.c \ + macros.h test-calloc-gnu.c test-canonicalize.c null-ptr.h \ + macros.h test-chdir.c signature.h macros.h nap.h test-chown.h \ + test-chown.c signature.h macros.h test-cloexec.c macros.h \ + test-close.c signature.h macros.h test-closein.sh \ + test-closein.c connect.c w32sock.h test-connect.c signature.h \ + macros.h test-count-leading-zeros.c macros.h test-md5.c \ + test-digest.h bench-md5.c bench-digest.h macros.h test-sha1.c \ + test-digest.h bench-sha1.c bench-digest.h macros.h \ + test-sha256.c test-digest.h bench-sha224.c bench-sha256.c \ + bench-digest.h macros.h test-sha512.c test-digest.h \ + bench-sha384.c bench-sha512.c bench-digest.h macros.h \ + test-ctype.c test-di-set.c macros.h test-dirent-safer.c \ + macros.h test-dirent.c test-dirname.c test-dup.c signature.h \ + macros.h test-dup2.c signature.h macros.h test-environ.c \ + test-errno.c test-exclude.c test-exclude1.sh test-exclude2.sh \ + test-exclude3.sh test-exclude4.sh test-exclude5.sh \ + test-exclude6.sh test-exclude7.sh test-exclude8.sh \ + test-faccessat.c signature.h macros.h test-fadvise.c \ + test-fchdir.c signature.h macros.h test-fchmodat.c signature.h \ + macros.h nap.h test-chown.h test-lchown.h test-fchownat.c \ + signature.h macros.h test-fclose.c test-fcntl-h.c test-open.h \ + test-fcntl-safer.c macros.h test-fcntl.c signature.h macros.h \ + test-fdatasync.c signature.h macros.h test-fdopen.c \ + signature.h macros.h test-fdopendir.c signature.h macros.h \ + nap.h test-futimens.h test-lutimens.h test-utimens.h \ + test-utimens-common.h test-fdutimensat.c macros.h \ + test-fflush.c test-fflush2.sh test-fflush2.c signature.h \ + macros.h test-fgetc.c signature.h macros.h \ + test-file-has-acl.sh test-file-has-acl-1.sh \ + test-file-has-acl-2.sh test-file-has-acl.c macros.h \ + test-filenamecat.c test-filevercmp.c macros.h test-float.c \ + macros.h test-fnmatch-h.c test-fnmatch.c signature.h macros.h \ + test-fopen.h test-fopen-safer.c macros.h test-fopen.h \ + test-fopen.c signature.h macros.h test-fpending.c \ + test-fpending.sh macros.h test-fpurge.c macros.h test-fputc.c \ + signature.h macros.h test-fread.c signature.h macros.h \ + test-freadahead.c test-freadahead.sh macros.h test-freading.c \ + macros.h test-freadptr.c test-freadptr.sh test-freadptr2.c \ + test-freadptr2.sh macros.h test-freadseek.c test-freadseek.sh \ + macros.h test-freopen-safer.c macros.h test-freopen.c \ + signature.h macros.h test-frexp.c test-frexp.h minus-zero.h \ + infinity.h nan.h signature.h macros.h randomd.c test-frexpl.c \ + test-frexp.h minus-zero.h infinity.h nan.h signature.h \ + macros.h randoml.c test-fseek.c test-fseek.sh test-fseek2.sh \ + signature.h macros.h test-fseeko.c test-fseeko.sh \ + test-fseeko2.sh test-fseeko3.c test-fseeko3.sh test-fseeko4.c \ + test-fseeko4.sh signature.h macros.h test-fseterr.c \ + test-fstat.c signature.h macros.h test-fstatat.c test-lstat.h \ + test-stat.h signature.h macros.h test-fsync.c signature.h \ + macros.h test-ftell.c test-ftell.sh test-ftell2.sh \ + test-ftell3.c signature.h macros.h test-ftello.c \ + test-ftello.sh test-ftello2.sh test-ftello3.c test-ftello4.c \ + test-ftello4.sh signature.h macros.h test-ftruncate.c \ + test-ftruncate.sh signature.h macros.h nap.h test-futimens.h \ + test-utimens-common.h test-futimens.c signature.h macros.h \ + test-fwrite.c signature.h macros.h signature.h \ + test-getaddrinfo.c test-getcwd-lgpl.c signature.h macros.h \ + test-getcwd.c test-getcwd.sh test-getdelim.c signature.h \ + macros.h test-getdtablesize.c signature.h macros.h \ + test-getgroups.c signature.h macros.h signature.h \ + test-gethostname.c test-getline.c signature.h macros.h \ + test-getloadavg.c signature.h test-getlogin.c test-getlogin.h \ + signature.h macros.h test-getndelim2.c macros.h macros.h \ + signature.h test-getopt-gnu.c test-getopt-main.h test-getopt.h \ + test-getopt_long.h macros.h signature.h test-getopt-posix.c \ + test-getopt-main.h test-getopt.h test-getprogname.c \ + getrusage.c test-getrusage.c signature.h macros.h signature.h \ + test-gettimeofday.c test-hard-locale.c locale.c test-hash.c \ + macros.h test-i-ring.c macros.h test-iconv-h.c test-iconv.c \ + signature.h macros.h test-ignore-value.c test-inet_ntop.c \ + signature.h macros.h inet_pton.c test-inet_pton.c signature.h \ + macros.h test-ino-map.c macros.h test-intprops.c macros.h \ + macros.h test-inttostr.c test-inttypes.c ioctl.c w32sock.h \ + test-ioctl.c signature.h macros.h test-isatty.c signature.h \ + macros.h test-isblank.c signature.h macros.h \ + test-isnand-nolibm.c test-isnand.h minus-zero.h infinity.h \ + nan.h macros.h test-isnanf-nolibm.c test-isnanf.h minus-zero.h \ + infinity.h nan.h macros.h test-isnanl-nolibm.c test-isnanl.h \ + minus-zero.h infinity.h nan.h macros.h test-iswblank.c \ + macros.h test-iswdigit.sh test-iswdigit.c signature.h macros.h \ + test-iswxdigit.sh test-iswxdigit.c signature.h macros.h \ + test-langinfo.c test-lchmod.c signature.h macros.h nap.h \ + test-lchown.h test-lchown.c signature.h macros.h \ + test-limits-h.c test-link.h test-link.c signature.h macros.h \ + test-link.h test-linkat.c signature.h macros.h listen.c \ + w32sock.h test-listen.c signature.h macros.h \ + test-localcharset.c test-locale.c test-localeconv.c \ + signature.h macros.h localename-table.h localename.h \ + test-localename.c macros.h test-rwlock1.c test-lock.c \ + test-once.c test-lseek.c test-lseek.sh signature.h macros.h \ + test-lstat.h test-lstat.c signature.h macros.h \ + test-malloc-gnu.c test-malloca.c test-math.c macros.h \ + test-mbrtowc1.sh test-mbrtowc2.sh test-mbrtowc3.sh \ + test-mbrtowc4.sh test-mbrtowc5.sh test-mbrtowc.c \ + test-mbrtowc-w32-1.sh test-mbrtowc-w32-2.sh \ + test-mbrtowc-w32-3.sh test-mbrtowc-w32-4.sh \ + test-mbrtowc-w32-5.sh test-mbrtowc-w32-6.sh \ + test-mbrtowc-w32-7.sh test-mbrtowc-w32.c signature.h macros.h \ + test-mbsalign.c macros.h test-mbscasecmp.sh test-mbscasecmp.c \ + macros.h test-mbschr.sh test-mbschr.c macros.h test-mbsinit.sh \ + test-mbsinit.c signature.h macros.h test-mbsrtowcs1.sh \ + test-mbsrtowcs2.sh test-mbsrtowcs3.sh test-mbsrtowcs4.sh \ + test-mbsrtowcs.c signature.h macros.h test-mbsstr1.c \ + test-mbsstr2.sh test-mbsstr2.c test-mbsstr3.sh test-mbsstr3.c \ + macros.h test-memcasecmp.c zerosize-ptr.h macros.h \ + test-memchr.c zerosize-ptr.h signature.h macros.h \ + test-memchr2.c zerosize-ptr.h macros.h test-memcoll.c macros.h \ + test-memrchr.c zerosize-ptr.h signature.h macros.h \ + test-mkdir.h test-mkdir.c signature.h macros.h test-mkfifo.h \ + test-mkfifo.c signature.h macros.h test-mkfifo.h test-mknod.c \ + signature.h macros.h test-nanosleep.c signature.h macros.h \ + test-netdb.c test-netinet_in.c test-nl_langinfo.sh \ + test-nl_langinfo.c test-nl_langinfo-mt.c signature.h macros.h \ + test-nstrftime.c macros.h test-open.h test-open.c signature.h \ + macros.h test-openat-safer.c macros.h test-openat.c \ + test-open.h signature.h macros.h test-parse-datetime.c \ + macros.h test-pathmax.c perror.c macros.h signature.h \ + test-perror.c test-perror2.c test-perror.sh test-pipe.c \ + signature.h macros.h test-pipe2.c signature.h macros.h \ + test-posixtm.c macros.h test-printf-frexp.c macros.h \ + test-printf-frexpl.c macros.h test-priv-set.c macros.h \ + test-pthread-cond.c macros.h test-pthread.c \ + test-pthread-mutex.c macros.h test-pthread-thread.c macros.h \ + test-pthread_sigmask1.c test-pthread_sigmask2.c signature.h \ + macros.h test-quotearg-simple.c test-quotearg.h macros.h \ + zerosize-ptr.h test-raise.c signature.h macros.h \ + test-rand-isaac.c macros.h test-read-file.c test-read.c \ + signature.h macros.h test-readlink.h test-readlink.c \ + signature.h macros.h test-readlink.h test-readlinkat.c \ + signature.h macros.h macros.h test-readtokens.c \ + test-readtokens.sh test-realloc-gnu.c test-regex.c macros.h \ + test-remove.c signature.h macros.h test-rename.h test-rename.c \ + signature.h macros.h test-rename.h test-renameat.c signature.h \ + macros.h test-rename.h test-renameatu.c signature.h macros.h \ + test-rmdir.h test-rmdir.c signature.h macros.h test-sched.c \ + sched_yield.c secure_getenv.c macros.h signature.h \ + test-select.c test-select.h test-select-fd.c test-select-in.sh \ + test-select-out.sh test-select-stdin.c test-setenv.c \ + signature.h macros.h setlocale.c test-setlocale_null.c \ + test-setlocale_null-mt-one.c test-setlocale_null-mt-all.c \ + test-setlocale1.sh test-setlocale1.c test-setlocale2.sh \ + test-setlocale2.c signature.h macros.h setsockopt.c w32sock.h \ + test-setsockopt.c signature.h macros.h test-sigaction.c \ + signature.h macros.h test-signal-h.c test-signbit.c \ + minus-zero.h infinity.h macros.h test-sigprocmask.c \ + signature.h macros.h sleep.c test-sleep.c signature.h macros.h \ + _Noreturn.h arg-nonnull.h c++defs.h unused-parameter.h \ + warn-on-use.h test-snprintf.c signature.h macros.h socket.c \ + w32sock.h test-sockets.c test-stat.h test-stat.c signature.h \ + macros.h test-stat-time.c macros.h nap.h test-statat.c \ + test-stdalign.c macros.h test-stdbool.c test-stddef.c \ + test-stdint.c test-stdio.c test-stdlib.c test-sys_wait.h \ + test-strerror.c signature.h macros.h strerror_r.c \ + test-strerror_r.c signature.h macros.h test-striconv.c \ + macros.h test-string.c test-strncat.c unistr/test-strncat.h \ + zerosize-ptr.h signature.h macros.h test-strnlen.c \ + zerosize-ptr.h signature.h macros.h test-strsignal.c \ + signature.h macros.h test-strtod.c test-strtod1.sh \ + test-strtod1.c signature.h minus-zero.h macros.h \ + test-strtoimax.c signature.h macros.h test-strtold.c \ + test-strtold1.sh test-strtold1.c signature.h minus-zero.h \ + macros.h test-strtoll.c signature.h macros.h test-strtoull.c \ + signature.h macros.h test-strtoumax.c signature.h macros.h \ + test-symlink.h test-symlink.c signature.h macros.h \ + test-symlink.h test-symlinkat.c signature.h macros.h \ + test-sys_ioctl.c test-sys_resource.c test-sys_select.c \ + signature.h test-sys_socket.c test-sys_stat.c test-sys_time.c \ + test-sys_types.c test-sys_uio.c test-sys_utsname.c \ + test-sys_wait.c test-sys_wait.h test-termios.c init.sh \ + test-init.sh test-thread_self.c test-thread_create.c macros.h \ + test-time.c test-timespec.c macros.h test-tls.c tmpfile.c \ + test-u64.c test-uname.c signature.h macros.h test-dup-safer.c \ + macros.h test-unistd.c unistr/test-u8-mbtoucr.c macros.h \ + unistr/test-u8-uctomb.c macros.h uniwidth/test-uc_width.c \ + uniwidth/test-uc_width2.c uniwidth/test-uc_width2.sh macros.h \ + test-unlink.h test-unlink.c signature.h macros.h \ + test-unlinkat.c test-rmdir.h test-unlink.h signature.h \ + macros.h test-unsetenv.c signature.h macros.h \ + test-update-copyright.sh test-userspec.c usleep.c \ + test-usleep.c signature.h macros.h test-utime-h.c test-utime.c \ + nap.h test-utimens-common.h macros.h nap.h test-futimens.h \ + test-lutimens.h test-utimens.h test-utimens-common.h \ + test-utimens.c macros.h nap.h test-lutimens.h test-utimens.h \ + test-utimens-common.h test-utimensat.c signature.h macros.h \ + test-vasnprintf.c macros.h test-vasprintf-posix.c minus-zero.h \ + infinity.h nan.h macros.h test-vasprintf.c signature.h \ + macros.h test-vc-list-files-git.sh test-vc-list-files-cvs.sh \ + test-verify.c test-verify-try.c test-verify.sh \ + test-version-etc.c test-version-etc.sh test-vfprintf-posix.sh \ + test-vfprintf-posix.c test-fprintf-posix.h \ + test-printf-posix.output infinity.h signature.h macros.h \ + test-vprintf-posix.sh test-vprintf-posix.c test-printf-posix.h \ + test-printf-posix.output infinity.h signature.h macros.h \ + test-wchar.c test-wcrtomb.sh test-wcrtomb.c \ + test-wcrtomb-w32-1.sh test-wcrtomb-w32-2.sh \ + test-wcrtomb-w32-3.sh test-wcrtomb-w32-4.sh \ + test-wcrtomb-w32-5.sh test-wcrtomb-w32-6.sh \ + test-wcrtomb-w32-7.sh test-wcrtomb-w32.c signature.h macros.h \ + wctob.c wctomb-impl.h wctomb.c test-wctype-h.c macros.h \ + test-wcwidth.c signature.h macros.h test-write.c signature.h \ + macros.h test-xalloc-die.c test-xalloc-die.sh \ + test-xprintf-posix.sh test-xfprintf-posix.c \ + test-xprintf-posix.c test-fprintf-posix.h test-printf-posix.h \ + test-printf-posix.output infinity.h macros.h test-xstrtoimax.c \ + test-xstrtoimax.sh test-xstrtol.c test-xstrtoul.c \ + test-xstrtol.sh test-xstrtoumax.c test-xstrtoumax.sh \ + test-xvasprintf.c macros.h test-yesno.c test-yesno.sh +BUILT_SOURCES = +SUFFIXES = + +# This test expects compilation of test-verify-try.c to fail, and +# each time it fails, the makefile rule does not perform the usual +# "mv -f $name.Tpo $name.po, so tell make clean to remove that file. +MOSTLYCLEANFILES = core *.stackdump test-fflush.txt test-fpending.t \ + t-fpurge.tmp t-freading.tmp t-ftell3.tmp t-ftello3.tmp \ + test-getdelim.txt test-getline.txt test-getndelim2.txt \ + .deps/test-verify-try.Tpo +MOSTLYCLEANDIRS = +CLEANFILES = +DISTCLEANFILES = +MAINTAINERCLEANFILES = +AM_CPPFLAGS = \ + -D@gltests_WITNESS@=1 \ + -I. -I$(srcdir) \ + -I.. -I$(srcdir)/.. \ + -I../lib -I$(srcdir)/../lib + +LDADD = libtests.a ../lib/libcoreutils.a libtests.a $(LIBTESTS_LIBDEPS) +libtests_a_SOURCES = localename.c localename-table.c glthread/thread.h \ + glthread/thread.c timespec-add.c timespec-sub.c tmpdir.h \ + tmpdir.c glthread/yield.h +libtests_a_LIBADD = $(gltests_LIBOBJS) +libtests_a_DEPENDENCIES = $(gltests_LIBOBJS) +EXTRA_libtests_a_SOURCES = accept.c bind.c connect.c getrusage.c \ + inet_pton.c ioctl.c listen.c perror.c sched_yield.c \ + secure_getenv.c setlocale.c setsockopt.c sleep.c socket.c \ + strerror_r.c tmpfile.c usleep.c wctob.c wctomb.c +AM_LIBTOOLFLAGS = --preserve-dup-deps +test_accept_LDADD = $(LDADD) @LIBSOCKET@ +test_set_mode_acl_LDADD = $(LDADD) $(LIB_ACL) @LIBINTL@ $(LIB_MBRTOWC) +test_copy_acl_LDADD = $(LDADD) $(LIB_ACL) @LIBINTL@ $(LIB_MBRTOWC) +test_sameacls_LDADD = $(LDADD) $(LIB_ACL) @LIBINTL@ $(LIB_MBRTOWC) +test_areadlinkat_LDADD = $(LDADD) @LIBINTL@ +test_argmatch_LDADD = $(LDADD) @LIBINTL@ $(LIB_MBRTOWC) +test_bind_LDADD = $(LDADD) @LIBSOCKET@ $(INET_PTON_LIB) +test_btowc_LDADD = $(LDADD) $(LIB_SETLOCALE) +test_c_ctype_LDADD = $(LDADD) $(LIB_SETLOCALE) +test_c_strcasecmp_LDADD = $(LDADD) $(LIB_SETLOCALE) +test_c_strncasecmp_LDADD = $(LDADD) $(LIB_SETLOCALE) +test_canonicalize_LDADD = $(LDADD) @LIBINTL@ +test_chown_LDADD = $(LDADD) $(LIB_NANOSLEEP) +test_closein_LDADD = $(LDADD) @LIBINTL@ $(LIB_MBRTOWC) +test_connect_LDADD = $(LDADD) @LIBSOCKET@ $(INET_PTON_LIB) +test_md5_LDADD = $(LDADD) @LIB_CRYPTO@ +bench_md5_LDADD = $(LDADD) @LIB_CRYPTO@ +test_sha1_LDADD = $(LDADD) @LIB_CRYPTO@ +bench_sha1_LDADD = $(LDADD) @LIB_CRYPTO@ +test_sha256_LDADD = $(LDADD) @LIB_CRYPTO@ +bench_sha224_LDADD = $(LDADD) @LIB_CRYPTO@ +bench_sha256_LDADD = $(LDADD) @LIB_CRYPTO@ +test_sha512_LDADD = $(LDADD) @LIB_CRYPTO@ +bench_sha384_LDADD = $(LDADD) @LIB_CRYPTO@ +bench_sha512_LDADD = $(LDADD) @LIB_CRYPTO@ +# Link with libintl when needed. dirent-safer uses fdopendir if it is present, +# and fdopendir indirectly depends on openat-die -> gettext-h. +test_dirent_safer_LDADD = $(LDADD) $(LIBINTL) +test_dirname_LDADD = $(LDADD) @LIBINTL@ +test_exclude_LDADD = $(LDADD) @LIBINTL@ $(LIB_MBRTOWC) $(LIBTHREAD) +test_faccessat_LDADD = $(LDADD) $(LIB_EACCESS) @LIBINTL@ +test_fchdir_LDADD = $(LDADD) $(LIBINTL) +test_fchmodat_LDADD = $(LDADD) @LIBINTL@ +test_fchownat_LDADD = $(LDADD) $(LIB_NANOSLEEP) @LIBINTL@ +test_fdatasync_LDADD = $(LDADD) $(LIB_FDATASYNC) +test_fdopendir_LDADD = $(LDADD) @LIBINTL@ +test_fdutimensat_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) \ + $(LIB_NANOSLEEP) @LIBINTL@ + +test_file_has_acl_LDADD = $(LDADD) $(LIB_HAS_ACL) +test_filenamecat_LDADD = $(LDADD) @LIBINTL@ +test_fnmatch_LDADD = $(LDADD) $(LIB_MBRTOWC) +test_frexp_nolibm_SOURCES = test-frexp.c randomd.c +test_frexpl_nolibm_SOURCES = test-frexpl.c randoml.c +test_fstatat_LDADD = $(LDADD) @LIBINTL@ +test_futimens_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_NANOSLEEP) @LIBINTL@ +test_getaddrinfo_LDADD = $(LDADD) @GETADDRINFO_LIB@ @LIBINTL@ +test_getcwd_lgpl_LDADD = $(LDADD) $(LIBINTL) +test_getcwd_LDADD = $(LDADD) @LIBINTL@ +test_gethostname_LDADD = $(LDADD) @GETHOSTNAME_LIB@ +test_getloadavg_LDADD = $(LDADD) @GETLOADAVG_LIBS@ +test_getlogin_LDADD = $(LDADD) $(LIB_GETLOGIN) +test_getopt_gnu_LDADD = $(LDADD) $(LIBINTL) +test_getopt_posix_LDADD = $(LDADD) $(LIBINTL) +test_getprogname_LDADD = $(LDADD) +GPERF = gperf +V_GPERF = $(V_GPERF_@AM_V@) +V_GPERF_ = $(V_GPERF_@AM_DEFAULT_V@) +V_GPERF_0 = @echo " GPERF " $@; +test_hard_locale_LDADD = $(LDADD) $(LIB_SETLOCALE) @LIB_HARD_LOCALE@ +current_locale_SOURCES = locale.c +test_iconv_LDADD = $(LDADD) @LIBICONV@ +test_inet_ntop_LDADD = $(LDADD) @INET_NTOP_LIB@ +test_inet_pton_LDADD = $(LDADD) @INET_PTON_LIB@ +test_iswdigit_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC) +test_iswxdigit_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC) +test_lchmod_LDADD = $(LDADD) @LIBINTL@ +test_lchown_LDADD = $(LDADD) $(LIB_NANOSLEEP) +test_link_LDADD = $(LDADD) @LIBINTL@ +test_linkat_LDADD = $(LDADD) @LIBINTL@ +test_listen_LDADD = $(LDADD) @LIBSOCKET@ +test_localcharset_LDADD = $(LDADD) $(LIB_SETLOCALE) +test_localename_LDADD = $(LDADD) $(LIB_SETLOCALE) @INTL_MACOSX_LIBS@ $(LIBTHREAD) +test_rwlock1_LDADD = $(LDADD) @LIBMULTITHREAD@ @YIELD_LIB@ +test_lock_LDADD = $(LDADD) @LIBMULTITHREAD@ @YIELD_LIB@ @LIB_SEMAPHORE@ +test_once1_SOURCES = test-once.c +test_once1_LDADD = $(LDADD) @LIBTHREAD@ +test_once2_SOURCES = test-once.c +test_once2_LDADD = $(LDADD) @LIBMULTITHREAD@ +test_mbrtowc_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC) +test_mbscasecmp_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC) +test_mbschr_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC) +test_mbsinit_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC) +test_mbsrtowcs_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC) +test_mbsstr1_LDADD = $(LDADD) $(LIB_MBRTOWC) +test_mbsstr2_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC) +test_mbsstr3_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC) +test_nanosleep_LDADD = $(LDADD) $(LIB_NANOSLEEP) +test_nl_langinfo_LDADD = $(LDADD) $(LIB_SETLOCALE) +test_nl_langinfo_mt_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBMULTITHREAD) $(LIB_NANOSLEEP) +test_openat_safer_LDADD = $(LDADD) @LIBINTL@ +test_openat_LDADD = $(LDADD) @LIBINTL@ +test_parse_datetime_LDADD = $(LDADD) @LIBINTL@ $(LIB_CLOCK_GETTIME) +test_pipe2_LDADD = $(LDADD) $(LIBSOCKET) +test_pthread_cond_LDADD = $(LDADD) @LIBPMULTITHREAD@ @LIB_SCHED_YIELD@ +test_pthread_mutex_LDADD = $(LDADD) @LIBPMULTITHREAD@ @LIB_SCHED_YIELD@ @LIB_SEMAPHORE@ +test_pthread_thread_LDADD = $(LDADD) @LIBPMULTITHREAD@ +test_pthread_sigmask1_LDADD = $(LDADD) @LIB_PTHREAD_SIGMASK@ +test_pthread_sigmask2_LDADD = $(LDADD) @LIB_PTHREAD_SIGMASK@ @LIBMULTITHREAD@ +test_quotearg_simple_LDADD = $(LDADD) @LIBINTL@ $(LIB_MBRTOWC) +test_readlinkat_LDADD = $(LDADD) @LIBINTL@ +test_readtokens_LDADD = $(LDADD) @LIBINTL@ $(LIB_MBRTOWC) +test_regex_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC) @LIBINTL@ $(LIBTHREAD) +test_rename_LDADD = $(LDADD) @LIBINTL@ +test_renameat_LDADD = $(LDADD) @LIBINTL@ +test_renameatu_LDADD = $(LDADD) @LIBINTL@ +test_select_LDADD = $(LDADD) @LIB_SELECT@ @LIBSOCKET@ $(INET_PTON_LIB) +test_select_fd_LDADD = $(LDADD) @LIB_SELECT@ +test_select_stdin_LDADD = $(LDADD) @LIB_SELECT@ +test_setlocale_null_LDADD = $(LDADD) @LIB_SETLOCALE_NULL@ +test_setlocale_null_mt_one_LDADD = $(LDADD) @LIB_SETLOCALE_NULL@ $(LIBMULTITHREAD) $(LIB_NANOSLEEP) +test_setlocale_null_mt_all_LDADD = $(LDADD) @LIB_SETLOCALE_NULL@ $(LIBMULTITHREAD) $(LIB_NANOSLEEP) +test_setlocale1_LDADD = $(LDADD) @LIB_SETLOCALE@ +test_setlocale2_LDADD = $(LDADD) @LIB_SETLOCALE@ +test_setsockopt_LDADD = $(LDADD) @LIBSOCKET@ + +# Because this Makefile snippet defines a variable used by other +# gnulib Makefile snippets, it must be present in all makefiles that +# need it. This is ensured by the applicability 'all' defined above. +_NORETURN_H = $(srcdir)/_Noreturn.h + +# Because this Makefile snippet defines a variable used by other +# gnulib Makefile snippets, it must be present in all makefiles that +# need it. This is ensured by the applicability 'all' defined above. +ARG_NONNULL_H = $(srcdir)/arg-nonnull.h + +# Because this Makefile snippet defines a variable used by other +# gnulib Makefile snippets, it must be present in all makefiles that +# need it. This is ensured by the applicability 'all' defined above. +CXXDEFS_H = $(srcdir)/c++defs.h + +# Because this Makefile snippet defines a variable used by other +# gnulib Makefile snippets, it must be present in all makefiles that +# need it. This is ensured by the applicability 'all' defined above. +UNUSED_PARAMETER_H = $(srcdir)/unused-parameter.h + +# Because this Makefile snippet defines a variable used by other +# gnulib Makefile snippets, it must be present in all makefiles that +# need it. This is ensured by the applicability 'all' defined above. +WARN_ON_USE_H = $(srcdir)/warn-on-use.h +test_sockets_LDADD = $(LDADD) @LIBSOCKET@ +test_stat_LDADD = $(LDADD) $(LIBINTL) +test_stat_time_LDADD = $(LDADD) $(LIB_NANOSLEEP) +test_statat_LDADD = $(LDADD) @LIBINTL@ +test_striconv_LDADD = $(LDADD) @LIBICONV@ +test_strsignal_LDADD = $(LDADD) @LIBINTL@ $(LIBTHREAD) +test_strtod1_LDADD = $(LDADD) $(LIB_SETLOCALE) +test_strtold1_LDADD = $(LDADD) $(LIB_SETLOCALE) +test_symlinkat_LDADD = $(LDADD) @LIBINTL@ +test_thread_self_LDADD = $(LDADD) @LIBTHREAD@ +test_thread_create_LDADD = $(LDADD) @LIBMULTITHREAD@ +test_tls_LDADD = $(LDADD) @LIBMULTITHREAD@ @YIELD_LIB@ +test_uname_LDADD = $(LDADD) @GETHOSTNAME_LIB@ +test_u8_mbtoucr_SOURCES = unistr/test-u8-mbtoucr.c +test_u8_mbtoucr_LDADD = $(LDADD) $(LIBUNISTRING) +test_u8_uctomb_SOURCES = unistr/test-u8-uctomb.c +test_u8_uctomb_LDADD = $(LDADD) $(LIBUNISTRING) +test_uc_width_SOURCES = uniwidth/test-uc_width.c +test_uc_width_LDADD = $(LDADD) $(LIBUNISTRING) +test_uc_width2_SOURCES = uniwidth/test-uc_width2.c +test_uc_width2_LDADD = $(LDADD) $(LIBUNISTRING) +test_unlinkat_LDADD = $(LDADD) @LIBINTL@ +test_userspec_LDADD = $(LDADD) @LIBINTL@ +test_utime_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_NANOSLEEP) @LIBINTL@ +test_utimens_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_NANOSLEEP) @LIBINTL@ +test_utimensat_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_NANOSLEEP) @LIBINTL@ +test_version_etc_LDADD = $(LDADD) @LIBINTL@ +test_wcrtomb_LDADD = $(LDADD) $(LIB_SETLOCALE) +test_wcwidth_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBUNISTRING) +test_xalloc_die_LDADD = $(LDADD) @LIBINTL@ +test_xfprintf_posix_LDADD = $(LDADD) @LIBINTL@ +test_xprintf_posix_LDADD = $(LDADD) @LIBINTL@ +test_xstrtoimax_LDADD = $(LDADD) @LIBINTL@ +test_xstrtol_LDADD = $(LDADD) @LIBINTL@ +test_xstrtoul_LDADD = $(LDADD) @LIBINTL@ +test_xstrtoumax_LDADD = $(LDADD) @LIBINTL@ +test_xvasprintf_LDADD = $(LDADD) @LIBINTL@ +test_yesno_LDADD = $(LDADD) @LIBINTL@ $(LIB_MBRTOWC) +AM_CFLAGS = $(GNULIB_TEST_WARN_CFLAGS) $(WERROR_CFLAGS) + +# A few tests are inherently warning-evoking. +# In the typical case where we use -Werror, exempt the few offenders. + +# test-xvasprintf.c: In function 'test_xasprintf': +# test-xvasprintf.c:100: error: format not a string literal and no \ +# format arguments [-Wformat-security] +test_xvasprintf_CFLAGS = $(AM_CFLAGS) \ + `test -n '$(WERROR_CFLAGS)' && echo ' -Wno-format-security'` + + +# test-lock.c: In function 'lock_mutator_thread': +# test-lock.c:148: error: cast from function call of type 'pthread_t' to \ +# non-matching type 'void *' [-Wbad-function-cast] +test_lock_CFLAGS = $(AM_CFLAGS) \ + `test -n '$(WERROR_CFLAGS)' && echo ' -Wno-bad-function-cast'` + +test_tls_CFLAGS = $(AM_CFLAGS) \ + `test -n '$(WERROR_CFLAGS)' && echo ' -Wno-bad-function-cast'` + +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +.SUFFIXES: +.SUFFIXES: .c .log .o .obj .test .test$(EXEEXT) .trs +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/gnulib.mk $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign gnulib-tests/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign gnulib-tests/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + esac; +$(srcdir)/gnulib.mk $(am__empty): + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p \ + ; then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' \ + -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' \ + `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) + +clean-checkPROGRAMS: + -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) + +clean-noinstPROGRAMS: + -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) +install-pkglibexecPROGRAMS: $(pkglibexec_PROGRAMS) + @$(NORMAL_INSTALL) + @list='$(pkglibexec_PROGRAMS)'; test -n "$(pkglibexecdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(pkglibexecdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(pkglibexecdir)" || exit 1; \ + fi; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p \ + ; then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' \ + -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(pkglibexecdir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(pkglibexecdir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-pkglibexecPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(pkglibexec_PROGRAMS)'; test -n "$(pkglibexecdir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' \ + `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(pkglibexecdir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(pkglibexecdir)" && rm -f $$files + +clean-pkglibexecPROGRAMS: + -test -z "$(pkglibexec_PROGRAMS)" || rm -f $(pkglibexec_PROGRAMS) + +clean-checkLIBRARIES: + -test -z "$(check_LIBRARIES)" || rm -f $(check_LIBRARIES) + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +glthread/$(am__dirstamp): + @$(MKDIR_P) glthread + @: > glthread/$(am__dirstamp) +glthread/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) glthread/$(DEPDIR) + @: > glthread/$(DEPDIR)/$(am__dirstamp) +glthread/thread.$(OBJEXT): glthread/$(am__dirstamp) \ + glthread/$(DEPDIR)/$(am__dirstamp) + +libtests.a: $(libtests_a_OBJECTS) $(libtests_a_DEPENDENCIES) $(EXTRA_libtests_a_DEPENDENCIES) + $(AM_V_at)-rm -f libtests.a + $(AM_V_AR)$(libtests_a_AR) libtests.a $(libtests_a_OBJECTS) $(libtests_a_LIBADD) + $(AM_V_at)$(RANLIB) libtests.a + +bench-md5$(EXEEXT): $(bench_md5_OBJECTS) $(bench_md5_DEPENDENCIES) $(EXTRA_bench_md5_DEPENDENCIES) + @rm -f bench-md5$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(bench_md5_OBJECTS) $(bench_md5_LDADD) $(LIBS) + +bench-sha1$(EXEEXT): $(bench_sha1_OBJECTS) $(bench_sha1_DEPENDENCIES) $(EXTRA_bench_sha1_DEPENDENCIES) + @rm -f bench-sha1$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(bench_sha1_OBJECTS) $(bench_sha1_LDADD) $(LIBS) + +bench-sha224$(EXEEXT): $(bench_sha224_OBJECTS) $(bench_sha224_DEPENDENCIES) $(EXTRA_bench_sha224_DEPENDENCIES) + @rm -f bench-sha224$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(bench_sha224_OBJECTS) $(bench_sha224_LDADD) $(LIBS) + +bench-sha256$(EXEEXT): $(bench_sha256_OBJECTS) $(bench_sha256_DEPENDENCIES) $(EXTRA_bench_sha256_DEPENDENCIES) + @rm -f bench-sha256$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(bench_sha256_OBJECTS) $(bench_sha256_LDADD) $(LIBS) + +bench-sha384$(EXEEXT): $(bench_sha384_OBJECTS) $(bench_sha384_DEPENDENCIES) $(EXTRA_bench_sha384_DEPENDENCIES) + @rm -f bench-sha384$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(bench_sha384_OBJECTS) $(bench_sha384_LDADD) $(LIBS) + +bench-sha512$(EXEEXT): $(bench_sha512_OBJECTS) $(bench_sha512_DEPENDENCIES) $(EXTRA_bench_sha512_DEPENDENCIES) + @rm -f bench-sha512$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(bench_sha512_OBJECTS) $(bench_sha512_LDADD) $(LIBS) + +current-locale$(EXEEXT): $(current_locale_OBJECTS) $(current_locale_DEPENDENCIES) $(EXTRA_current_locale_DEPENDENCIES) + @rm -f current-locale$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(current_locale_OBJECTS) $(current_locale_LDADD) $(LIBS) + +test-accept$(EXEEXT): $(test_accept_OBJECTS) $(test_accept_DEPENDENCIES) $(EXTRA_test_accept_DEPENDENCIES) + @rm -f test-accept$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_accept_OBJECTS) $(test_accept_LDADD) $(LIBS) + +test-alignof$(EXEEXT): $(test_alignof_OBJECTS) $(test_alignof_DEPENDENCIES) $(EXTRA_test_alignof_DEPENDENCIES) + @rm -f test-alignof$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_alignof_OBJECTS) $(test_alignof_LDADD) $(LIBS) + +test-alloca-opt$(EXEEXT): $(test_alloca_opt_OBJECTS) $(test_alloca_opt_DEPENDENCIES) $(EXTRA_test_alloca_opt_DEPENDENCIES) + @rm -f test-alloca-opt$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_alloca_opt_OBJECTS) $(test_alloca_opt_LDADD) $(LIBS) + +test-areadlink$(EXEEXT): $(test_areadlink_OBJECTS) $(test_areadlink_DEPENDENCIES) $(EXTRA_test_areadlink_DEPENDENCIES) + @rm -f test-areadlink$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_areadlink_OBJECTS) $(test_areadlink_LDADD) $(LIBS) + +test-areadlink-with-size$(EXEEXT): $(test_areadlink_with_size_OBJECTS) $(test_areadlink_with_size_DEPENDENCIES) $(EXTRA_test_areadlink_with_size_DEPENDENCIES) + @rm -f test-areadlink-with-size$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_areadlink_with_size_OBJECTS) $(test_areadlink_with_size_LDADD) $(LIBS) + +test-areadlinkat$(EXEEXT): $(test_areadlinkat_OBJECTS) $(test_areadlinkat_DEPENDENCIES) $(EXTRA_test_areadlinkat_DEPENDENCIES) + @rm -f test-areadlinkat$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_areadlinkat_OBJECTS) $(test_areadlinkat_LDADD) $(LIBS) + +test-argmatch$(EXEEXT): $(test_argmatch_OBJECTS) $(test_argmatch_DEPENDENCIES) $(EXTRA_test_argmatch_DEPENDENCIES) + @rm -f test-argmatch$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_argmatch_OBJECTS) $(test_argmatch_LDADD) $(LIBS) + +test-argv-iter$(EXEEXT): $(test_argv_iter_OBJECTS) $(test_argv_iter_DEPENDENCIES) $(EXTRA_test_argv_iter_DEPENDENCIES) + @rm -f test-argv-iter$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_argv_iter_OBJECTS) $(test_argv_iter_LDADD) $(LIBS) + +test-arpa_inet$(EXEEXT): $(test_arpa_inet_OBJECTS) $(test_arpa_inet_DEPENDENCIES) $(EXTRA_test_arpa_inet_DEPENDENCIES) + @rm -f test-arpa_inet$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_arpa_inet_OBJECTS) $(test_arpa_inet_LDADD) $(LIBS) + +test-base32$(EXEEXT): $(test_base32_OBJECTS) $(test_base32_DEPENDENCIES) $(EXTRA_test_base32_DEPENDENCIES) + @rm -f test-base32$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_base32_OBJECTS) $(test_base32_LDADD) $(LIBS) + +test-base64$(EXEEXT): $(test_base64_OBJECTS) $(test_base64_DEPENDENCIES) $(EXTRA_test_base64_DEPENDENCIES) + @rm -f test-base64$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_base64_OBJECTS) $(test_base64_LDADD) $(LIBS) + +test-binary-io$(EXEEXT): $(test_binary_io_OBJECTS) $(test_binary_io_DEPENDENCIES) $(EXTRA_test_binary_io_DEPENDENCIES) + @rm -f test-binary-io$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_binary_io_OBJECTS) $(test_binary_io_LDADD) $(LIBS) + +test-bind$(EXEEXT): $(test_bind_OBJECTS) $(test_bind_DEPENDENCIES) $(EXTRA_test_bind_DEPENDENCIES) + @rm -f test-bind$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_bind_OBJECTS) $(test_bind_LDADD) $(LIBS) + +test-bitrotate$(EXEEXT): $(test_bitrotate_OBJECTS) $(test_bitrotate_DEPENDENCIES) $(EXTRA_test_bitrotate_DEPENDENCIES) + @rm -f test-bitrotate$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_bitrotate_OBJECTS) $(test_bitrotate_LDADD) $(LIBS) + +test-btowc$(EXEEXT): $(test_btowc_OBJECTS) $(test_btowc_DEPENDENCIES) $(EXTRA_test_btowc_DEPENDENCIES) + @rm -f test-btowc$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_btowc_OBJECTS) $(test_btowc_LDADD) $(LIBS) + +test-byteswap$(EXEEXT): $(test_byteswap_OBJECTS) $(test_byteswap_DEPENDENCIES) $(EXTRA_test_byteswap_DEPENDENCIES) + @rm -f test-byteswap$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_byteswap_OBJECTS) $(test_byteswap_LDADD) $(LIBS) + +test-c-ctype$(EXEEXT): $(test_c_ctype_OBJECTS) $(test_c_ctype_DEPENDENCIES) $(EXTRA_test_c_ctype_DEPENDENCIES) + @rm -f test-c-ctype$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_c_ctype_OBJECTS) $(test_c_ctype_LDADD) $(LIBS) + +test-c-strcasecmp$(EXEEXT): $(test_c_strcasecmp_OBJECTS) $(test_c_strcasecmp_DEPENDENCIES) $(EXTRA_test_c_strcasecmp_DEPENDENCIES) + @rm -f test-c-strcasecmp$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_c_strcasecmp_OBJECTS) $(test_c_strcasecmp_LDADD) $(LIBS) + +test-c-strncasecmp$(EXEEXT): $(test_c_strncasecmp_OBJECTS) $(test_c_strncasecmp_DEPENDENCIES) $(EXTRA_test_c_strncasecmp_DEPENDENCIES) + @rm -f test-c-strncasecmp$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_c_strncasecmp_OBJECTS) $(test_c_strncasecmp_LDADD) $(LIBS) + +test-calloc-gnu$(EXEEXT): $(test_calloc_gnu_OBJECTS) $(test_calloc_gnu_DEPENDENCIES) $(EXTRA_test_calloc_gnu_DEPENDENCIES) + @rm -f test-calloc-gnu$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_calloc_gnu_OBJECTS) $(test_calloc_gnu_LDADD) $(LIBS) + +test-canonicalize$(EXEEXT): $(test_canonicalize_OBJECTS) $(test_canonicalize_DEPENDENCIES) $(EXTRA_test_canonicalize_DEPENDENCIES) + @rm -f test-canonicalize$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_canonicalize_OBJECTS) $(test_canonicalize_LDADD) $(LIBS) + +test-chdir$(EXEEXT): $(test_chdir_OBJECTS) $(test_chdir_DEPENDENCIES) $(EXTRA_test_chdir_DEPENDENCIES) + @rm -f test-chdir$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_chdir_OBJECTS) $(test_chdir_LDADD) $(LIBS) + +test-chown$(EXEEXT): $(test_chown_OBJECTS) $(test_chown_DEPENDENCIES) $(EXTRA_test_chown_DEPENDENCIES) + @rm -f test-chown$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_chown_OBJECTS) $(test_chown_LDADD) $(LIBS) + +test-cloexec$(EXEEXT): $(test_cloexec_OBJECTS) $(test_cloexec_DEPENDENCIES) $(EXTRA_test_cloexec_DEPENDENCIES) + @rm -f test-cloexec$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_cloexec_OBJECTS) $(test_cloexec_LDADD) $(LIBS) + +test-close$(EXEEXT): $(test_close_OBJECTS) $(test_close_DEPENDENCIES) $(EXTRA_test_close_DEPENDENCIES) + @rm -f test-close$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_close_OBJECTS) $(test_close_LDADD) $(LIBS) + +test-closein$(EXEEXT): $(test_closein_OBJECTS) $(test_closein_DEPENDENCIES) $(EXTRA_test_closein_DEPENDENCIES) + @rm -f test-closein$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_closein_OBJECTS) $(test_closein_LDADD) $(LIBS) + +test-connect$(EXEEXT): $(test_connect_OBJECTS) $(test_connect_DEPENDENCIES) $(EXTRA_test_connect_DEPENDENCIES) + @rm -f test-connect$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_connect_OBJECTS) $(test_connect_LDADD) $(LIBS) + +test-copy-acl$(EXEEXT): $(test_copy_acl_OBJECTS) $(test_copy_acl_DEPENDENCIES) $(EXTRA_test_copy_acl_DEPENDENCIES) + @rm -f test-copy-acl$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_copy_acl_OBJECTS) $(test_copy_acl_LDADD) $(LIBS) + +test-count-leading-zeros$(EXEEXT): $(test_count_leading_zeros_OBJECTS) $(test_count_leading_zeros_DEPENDENCIES) $(EXTRA_test_count_leading_zeros_DEPENDENCIES) + @rm -f test-count-leading-zeros$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_count_leading_zeros_OBJECTS) $(test_count_leading_zeros_LDADD) $(LIBS) + +test-ctype$(EXEEXT): $(test_ctype_OBJECTS) $(test_ctype_DEPENDENCIES) $(EXTRA_test_ctype_DEPENDENCIES) + @rm -f test-ctype$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_ctype_OBJECTS) $(test_ctype_LDADD) $(LIBS) + +test-di-set$(EXEEXT): $(test_di_set_OBJECTS) $(test_di_set_DEPENDENCIES) $(EXTRA_test_di_set_DEPENDENCIES) + @rm -f test-di-set$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_di_set_OBJECTS) $(test_di_set_LDADD) $(LIBS) + +test-dirent$(EXEEXT): $(test_dirent_OBJECTS) $(test_dirent_DEPENDENCIES) $(EXTRA_test_dirent_DEPENDENCIES) + @rm -f test-dirent$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_dirent_OBJECTS) $(test_dirent_LDADD) $(LIBS) + +test-dirent-safer$(EXEEXT): $(test_dirent_safer_OBJECTS) $(test_dirent_safer_DEPENDENCIES) $(EXTRA_test_dirent_safer_DEPENDENCIES) + @rm -f test-dirent-safer$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_dirent_safer_OBJECTS) $(test_dirent_safer_LDADD) $(LIBS) + +test-dirname$(EXEEXT): $(test_dirname_OBJECTS) $(test_dirname_DEPENDENCIES) $(EXTRA_test_dirname_DEPENDENCIES) + @rm -f test-dirname$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_dirname_OBJECTS) $(test_dirname_LDADD) $(LIBS) + +test-dup$(EXEEXT): $(test_dup_OBJECTS) $(test_dup_DEPENDENCIES) $(EXTRA_test_dup_DEPENDENCIES) + @rm -f test-dup$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_dup_OBJECTS) $(test_dup_LDADD) $(LIBS) + +test-dup-safer$(EXEEXT): $(test_dup_safer_OBJECTS) $(test_dup_safer_DEPENDENCIES) $(EXTRA_test_dup_safer_DEPENDENCIES) + @rm -f test-dup-safer$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_dup_safer_OBJECTS) $(test_dup_safer_LDADD) $(LIBS) + +test-dup2$(EXEEXT): $(test_dup2_OBJECTS) $(test_dup2_DEPENDENCIES) $(EXTRA_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) $(EXTRA_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) $(EXTRA_test_errno_DEPENDENCIES) + @rm -f test-errno$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_errno_OBJECTS) $(test_errno_LDADD) $(LIBS) + +test-exclude$(EXEEXT): $(test_exclude_OBJECTS) $(test_exclude_DEPENDENCIES) $(EXTRA_test_exclude_DEPENDENCIES) + @rm -f test-exclude$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_exclude_OBJECTS) $(test_exclude_LDADD) $(LIBS) + +test-faccessat$(EXEEXT): $(test_faccessat_OBJECTS) $(test_faccessat_DEPENDENCIES) $(EXTRA_test_faccessat_DEPENDENCIES) + @rm -f test-faccessat$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_faccessat_OBJECTS) $(test_faccessat_LDADD) $(LIBS) + +test-fadvise$(EXEEXT): $(test_fadvise_OBJECTS) $(test_fadvise_DEPENDENCIES) $(EXTRA_test_fadvise_DEPENDENCIES) + @rm -f test-fadvise$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fadvise_OBJECTS) $(test_fadvise_LDADD) $(LIBS) + +test-fchdir$(EXEEXT): $(test_fchdir_OBJECTS) $(test_fchdir_DEPENDENCIES) $(EXTRA_test_fchdir_DEPENDENCIES) + @rm -f test-fchdir$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fchdir_OBJECTS) $(test_fchdir_LDADD) $(LIBS) + +test-fchmodat$(EXEEXT): $(test_fchmodat_OBJECTS) $(test_fchmodat_DEPENDENCIES) $(EXTRA_test_fchmodat_DEPENDENCIES) + @rm -f test-fchmodat$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fchmodat_OBJECTS) $(test_fchmodat_LDADD) $(LIBS) + +test-fchownat$(EXEEXT): $(test_fchownat_OBJECTS) $(test_fchownat_DEPENDENCIES) $(EXTRA_test_fchownat_DEPENDENCIES) + @rm -f test-fchownat$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fchownat_OBJECTS) $(test_fchownat_LDADD) $(LIBS) + +test-fclose$(EXEEXT): $(test_fclose_OBJECTS) $(test_fclose_DEPENDENCIES) $(EXTRA_test_fclose_DEPENDENCIES) + @rm -f test-fclose$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fclose_OBJECTS) $(test_fclose_LDADD) $(LIBS) + +test-fcntl$(EXEEXT): $(test_fcntl_OBJECTS) $(test_fcntl_DEPENDENCIES) $(EXTRA_test_fcntl_DEPENDENCIES) + @rm -f test-fcntl$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fcntl_OBJECTS) $(test_fcntl_LDADD) $(LIBS) + +test-fcntl-h$(EXEEXT): $(test_fcntl_h_OBJECTS) $(test_fcntl_h_DEPENDENCIES) $(EXTRA_test_fcntl_h_DEPENDENCIES) + @rm -f test-fcntl-h$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fcntl_h_OBJECTS) $(test_fcntl_h_LDADD) $(LIBS) + +test-fcntl-safer$(EXEEXT): $(test_fcntl_safer_OBJECTS) $(test_fcntl_safer_DEPENDENCIES) $(EXTRA_test_fcntl_safer_DEPENDENCIES) + @rm -f test-fcntl-safer$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fcntl_safer_OBJECTS) $(test_fcntl_safer_LDADD) $(LIBS) + +test-fdatasync$(EXEEXT): $(test_fdatasync_OBJECTS) $(test_fdatasync_DEPENDENCIES) $(EXTRA_test_fdatasync_DEPENDENCIES) + @rm -f test-fdatasync$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fdatasync_OBJECTS) $(test_fdatasync_LDADD) $(LIBS) + +test-fdopen$(EXEEXT): $(test_fdopen_OBJECTS) $(test_fdopen_DEPENDENCIES) $(EXTRA_test_fdopen_DEPENDENCIES) + @rm -f test-fdopen$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fdopen_OBJECTS) $(test_fdopen_LDADD) $(LIBS) + +test-fdopendir$(EXEEXT): $(test_fdopendir_OBJECTS) $(test_fdopendir_DEPENDENCIES) $(EXTRA_test_fdopendir_DEPENDENCIES) + @rm -f test-fdopendir$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fdopendir_OBJECTS) $(test_fdopendir_LDADD) $(LIBS) + +test-fdutimensat$(EXEEXT): $(test_fdutimensat_OBJECTS) $(test_fdutimensat_DEPENDENCIES) $(EXTRA_test_fdutimensat_DEPENDENCIES) + @rm -f test-fdutimensat$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fdutimensat_OBJECTS) $(test_fdutimensat_LDADD) $(LIBS) + +test-fflush$(EXEEXT): $(test_fflush_OBJECTS) $(test_fflush_DEPENDENCIES) $(EXTRA_test_fflush_DEPENDENCIES) + @rm -f test-fflush$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fflush_OBJECTS) $(test_fflush_LDADD) $(LIBS) + +test-fflush2$(EXEEXT): $(test_fflush2_OBJECTS) $(test_fflush2_DEPENDENCIES) $(EXTRA_test_fflush2_DEPENDENCIES) + @rm -f test-fflush2$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fflush2_OBJECTS) $(test_fflush2_LDADD) $(LIBS) + +test-fgetc$(EXEEXT): $(test_fgetc_OBJECTS) $(test_fgetc_DEPENDENCIES) $(EXTRA_test_fgetc_DEPENDENCIES) + @rm -f test-fgetc$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fgetc_OBJECTS) $(test_fgetc_LDADD) $(LIBS) + +test-file-has-acl$(EXEEXT): $(test_file_has_acl_OBJECTS) $(test_file_has_acl_DEPENDENCIES) $(EXTRA_test_file_has_acl_DEPENDENCIES) + @rm -f test-file-has-acl$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_file_has_acl_OBJECTS) $(test_file_has_acl_LDADD) $(LIBS) + +test-filenamecat$(EXEEXT): $(test_filenamecat_OBJECTS) $(test_filenamecat_DEPENDENCIES) $(EXTRA_test_filenamecat_DEPENDENCIES) + @rm -f test-filenamecat$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_filenamecat_OBJECTS) $(test_filenamecat_LDADD) $(LIBS) + +test-filevercmp$(EXEEXT): $(test_filevercmp_OBJECTS) $(test_filevercmp_DEPENDENCIES) $(EXTRA_test_filevercmp_DEPENDENCIES) + @rm -f test-filevercmp$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_filevercmp_OBJECTS) $(test_filevercmp_LDADD) $(LIBS) + +test-float$(EXEEXT): $(test_float_OBJECTS) $(test_float_DEPENDENCIES) $(EXTRA_test_float_DEPENDENCIES) + @rm -f test-float$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_float_OBJECTS) $(test_float_LDADD) $(LIBS) + +test-fnmatch$(EXEEXT): $(test_fnmatch_OBJECTS) $(test_fnmatch_DEPENDENCIES) $(EXTRA_test_fnmatch_DEPENDENCIES) + @rm -f test-fnmatch$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fnmatch_OBJECTS) $(test_fnmatch_LDADD) $(LIBS) + +test-fnmatch-h$(EXEEXT): $(test_fnmatch_h_OBJECTS) $(test_fnmatch_h_DEPENDENCIES) $(EXTRA_test_fnmatch_h_DEPENDENCIES) + @rm -f test-fnmatch-h$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fnmatch_h_OBJECTS) $(test_fnmatch_h_LDADD) $(LIBS) + +test-fopen$(EXEEXT): $(test_fopen_OBJECTS) $(test_fopen_DEPENDENCIES) $(EXTRA_test_fopen_DEPENDENCIES) + @rm -f test-fopen$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fopen_OBJECTS) $(test_fopen_LDADD) $(LIBS) + +test-fopen-safer$(EXEEXT): $(test_fopen_safer_OBJECTS) $(test_fopen_safer_DEPENDENCIES) $(EXTRA_test_fopen_safer_DEPENDENCIES) + @rm -f test-fopen-safer$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fopen_safer_OBJECTS) $(test_fopen_safer_LDADD) $(LIBS) + +test-fpending$(EXEEXT): $(test_fpending_OBJECTS) $(test_fpending_DEPENDENCIES) $(EXTRA_test_fpending_DEPENDENCIES) + @rm -f test-fpending$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fpending_OBJECTS) $(test_fpending_LDADD) $(LIBS) + +test-fpurge$(EXEEXT): $(test_fpurge_OBJECTS) $(test_fpurge_DEPENDENCIES) $(EXTRA_test_fpurge_DEPENDENCIES) + @rm -f test-fpurge$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fpurge_OBJECTS) $(test_fpurge_LDADD) $(LIBS) + +test-fputc$(EXEEXT): $(test_fputc_OBJECTS) $(test_fputc_DEPENDENCIES) $(EXTRA_test_fputc_DEPENDENCIES) + @rm -f test-fputc$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fputc_OBJECTS) $(test_fputc_LDADD) $(LIBS) + +test-fread$(EXEEXT): $(test_fread_OBJECTS) $(test_fread_DEPENDENCIES) $(EXTRA_test_fread_DEPENDENCIES) + @rm -f test-fread$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fread_OBJECTS) $(test_fread_LDADD) $(LIBS) + +test-freadahead$(EXEEXT): $(test_freadahead_OBJECTS) $(test_freadahead_DEPENDENCIES) $(EXTRA_test_freadahead_DEPENDENCIES) + @rm -f test-freadahead$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_freadahead_OBJECTS) $(test_freadahead_LDADD) $(LIBS) + +test-freading$(EXEEXT): $(test_freading_OBJECTS) $(test_freading_DEPENDENCIES) $(EXTRA_test_freading_DEPENDENCIES) + @rm -f test-freading$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_freading_OBJECTS) $(test_freading_LDADD) $(LIBS) + +test-freadptr$(EXEEXT): $(test_freadptr_OBJECTS) $(test_freadptr_DEPENDENCIES) $(EXTRA_test_freadptr_DEPENDENCIES) + @rm -f test-freadptr$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_freadptr_OBJECTS) $(test_freadptr_LDADD) $(LIBS) + +test-freadptr2$(EXEEXT): $(test_freadptr2_OBJECTS) $(test_freadptr2_DEPENDENCIES) $(EXTRA_test_freadptr2_DEPENDENCIES) + @rm -f test-freadptr2$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_freadptr2_OBJECTS) $(test_freadptr2_LDADD) $(LIBS) + +test-freadseek$(EXEEXT): $(test_freadseek_OBJECTS) $(test_freadseek_DEPENDENCIES) $(EXTRA_test_freadseek_DEPENDENCIES) + @rm -f test-freadseek$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_freadseek_OBJECTS) $(test_freadseek_LDADD) $(LIBS) + +test-freopen$(EXEEXT): $(test_freopen_OBJECTS) $(test_freopen_DEPENDENCIES) $(EXTRA_test_freopen_DEPENDENCIES) + @rm -f test-freopen$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_freopen_OBJECTS) $(test_freopen_LDADD) $(LIBS) + +test-freopen-safer$(EXEEXT): $(test_freopen_safer_OBJECTS) $(test_freopen_safer_DEPENDENCIES) $(EXTRA_test_freopen_safer_DEPENDENCIES) + @rm -f test-freopen-safer$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_freopen_safer_OBJECTS) $(test_freopen_safer_LDADD) $(LIBS) + +test-frexp-nolibm$(EXEEXT): $(test_frexp_nolibm_OBJECTS) $(test_frexp_nolibm_DEPENDENCIES) $(EXTRA_test_frexp_nolibm_DEPENDENCIES) + @rm -f test-frexp-nolibm$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_frexp_nolibm_OBJECTS) $(test_frexp_nolibm_LDADD) $(LIBS) + +test-frexpl-nolibm$(EXEEXT): $(test_frexpl_nolibm_OBJECTS) $(test_frexpl_nolibm_DEPENDENCIES) $(EXTRA_test_frexpl_nolibm_DEPENDENCIES) + @rm -f test-frexpl-nolibm$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_frexpl_nolibm_OBJECTS) $(test_frexpl_nolibm_LDADD) $(LIBS) + +test-fseek$(EXEEXT): $(test_fseek_OBJECTS) $(test_fseek_DEPENDENCIES) $(EXTRA_test_fseek_DEPENDENCIES) + @rm -f test-fseek$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fseek_OBJECTS) $(test_fseek_LDADD) $(LIBS) + +test-fseeko$(EXEEXT): $(test_fseeko_OBJECTS) $(test_fseeko_DEPENDENCIES) $(EXTRA_test_fseeko_DEPENDENCIES) + @rm -f test-fseeko$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fseeko_OBJECTS) $(test_fseeko_LDADD) $(LIBS) + +test-fseeko3$(EXEEXT): $(test_fseeko3_OBJECTS) $(test_fseeko3_DEPENDENCIES) $(EXTRA_test_fseeko3_DEPENDENCIES) + @rm -f test-fseeko3$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fseeko3_OBJECTS) $(test_fseeko3_LDADD) $(LIBS) + +test-fseeko4$(EXEEXT): $(test_fseeko4_OBJECTS) $(test_fseeko4_DEPENDENCIES) $(EXTRA_test_fseeko4_DEPENDENCIES) + @rm -f test-fseeko4$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fseeko4_OBJECTS) $(test_fseeko4_LDADD) $(LIBS) + +test-fseterr$(EXEEXT): $(test_fseterr_OBJECTS) $(test_fseterr_DEPENDENCIES) $(EXTRA_test_fseterr_DEPENDENCIES) + @rm -f test-fseterr$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fseterr_OBJECTS) $(test_fseterr_LDADD) $(LIBS) + +test-fstat$(EXEEXT): $(test_fstat_OBJECTS) $(test_fstat_DEPENDENCIES) $(EXTRA_test_fstat_DEPENDENCIES) + @rm -f test-fstat$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fstat_OBJECTS) $(test_fstat_LDADD) $(LIBS) + +test-fstatat$(EXEEXT): $(test_fstatat_OBJECTS) $(test_fstatat_DEPENDENCIES) $(EXTRA_test_fstatat_DEPENDENCIES) + @rm -f test-fstatat$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fstatat_OBJECTS) $(test_fstatat_LDADD) $(LIBS) + +test-fsync$(EXEEXT): $(test_fsync_OBJECTS) $(test_fsync_DEPENDENCIES) $(EXTRA_test_fsync_DEPENDENCIES) + @rm -f test-fsync$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fsync_OBJECTS) $(test_fsync_LDADD) $(LIBS) + +test-ftell$(EXEEXT): $(test_ftell_OBJECTS) $(test_ftell_DEPENDENCIES) $(EXTRA_test_ftell_DEPENDENCIES) + @rm -f test-ftell$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_ftell_OBJECTS) $(test_ftell_LDADD) $(LIBS) + +test-ftell3$(EXEEXT): $(test_ftell3_OBJECTS) $(test_ftell3_DEPENDENCIES) $(EXTRA_test_ftell3_DEPENDENCIES) + @rm -f test-ftell3$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_ftell3_OBJECTS) $(test_ftell3_LDADD) $(LIBS) + +test-ftello$(EXEEXT): $(test_ftello_OBJECTS) $(test_ftello_DEPENDENCIES) $(EXTRA_test_ftello_DEPENDENCIES) + @rm -f test-ftello$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_ftello_OBJECTS) $(test_ftello_LDADD) $(LIBS) + +test-ftello3$(EXEEXT): $(test_ftello3_OBJECTS) $(test_ftello3_DEPENDENCIES) $(EXTRA_test_ftello3_DEPENDENCIES) + @rm -f test-ftello3$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_ftello3_OBJECTS) $(test_ftello3_LDADD) $(LIBS) + +test-ftello4$(EXEEXT): $(test_ftello4_OBJECTS) $(test_ftello4_DEPENDENCIES) $(EXTRA_test_ftello4_DEPENDENCIES) + @rm -f test-ftello4$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_ftello4_OBJECTS) $(test_ftello4_LDADD) $(LIBS) + +test-ftruncate$(EXEEXT): $(test_ftruncate_OBJECTS) $(test_ftruncate_DEPENDENCIES) $(EXTRA_test_ftruncate_DEPENDENCIES) + @rm -f test-ftruncate$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_ftruncate_OBJECTS) $(test_ftruncate_LDADD) $(LIBS) + +test-futimens$(EXEEXT): $(test_futimens_OBJECTS) $(test_futimens_DEPENDENCIES) $(EXTRA_test_futimens_DEPENDENCIES) + @rm -f test-futimens$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_futimens_OBJECTS) $(test_futimens_LDADD) $(LIBS) + +test-fwrite$(EXEEXT): $(test_fwrite_OBJECTS) $(test_fwrite_DEPENDENCIES) $(EXTRA_test_fwrite_DEPENDENCIES) + @rm -f test-fwrite$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_fwrite_OBJECTS) $(test_fwrite_LDADD) $(LIBS) + +test-getaddrinfo$(EXEEXT): $(test_getaddrinfo_OBJECTS) $(test_getaddrinfo_DEPENDENCIES) $(EXTRA_test_getaddrinfo_DEPENDENCIES) + @rm -f test-getaddrinfo$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_getaddrinfo_OBJECTS) $(test_getaddrinfo_LDADD) $(LIBS) + +test-getcwd$(EXEEXT): $(test_getcwd_OBJECTS) $(test_getcwd_DEPENDENCIES) $(EXTRA_test_getcwd_DEPENDENCIES) + @rm -f test-getcwd$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_getcwd_OBJECTS) $(test_getcwd_LDADD) $(LIBS) + +test-getcwd-lgpl$(EXEEXT): $(test_getcwd_lgpl_OBJECTS) $(test_getcwd_lgpl_DEPENDENCIES) $(EXTRA_test_getcwd_lgpl_DEPENDENCIES) + @rm -f test-getcwd-lgpl$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_getcwd_lgpl_OBJECTS) $(test_getcwd_lgpl_LDADD) $(LIBS) + +test-getdelim$(EXEEXT): $(test_getdelim_OBJECTS) $(test_getdelim_DEPENDENCIES) $(EXTRA_test_getdelim_DEPENDENCIES) + @rm -f test-getdelim$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_getdelim_OBJECTS) $(test_getdelim_LDADD) $(LIBS) + +test-getdtablesize$(EXEEXT): $(test_getdtablesize_OBJECTS) $(test_getdtablesize_DEPENDENCIES) $(EXTRA_test_getdtablesize_DEPENDENCIES) + @rm -f test-getdtablesize$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_getdtablesize_OBJECTS) $(test_getdtablesize_LDADD) $(LIBS) + +test-getgroups$(EXEEXT): $(test_getgroups_OBJECTS) $(test_getgroups_DEPENDENCIES) $(EXTRA_test_getgroups_DEPENDENCIES) + @rm -f test-getgroups$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_getgroups_OBJECTS) $(test_getgroups_LDADD) $(LIBS) + +test-gethostname$(EXEEXT): $(test_gethostname_OBJECTS) $(test_gethostname_DEPENDENCIES) $(EXTRA_test_gethostname_DEPENDENCIES) + @rm -f test-gethostname$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_gethostname_OBJECTS) $(test_gethostname_LDADD) $(LIBS) + +test-getline$(EXEEXT): $(test_getline_OBJECTS) $(test_getline_DEPENDENCIES) $(EXTRA_test_getline_DEPENDENCIES) + @rm -f test-getline$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_getline_OBJECTS) $(test_getline_LDADD) $(LIBS) + +test-getloadavg$(EXEEXT): $(test_getloadavg_OBJECTS) $(test_getloadavg_DEPENDENCIES) $(EXTRA_test_getloadavg_DEPENDENCIES) + @rm -f test-getloadavg$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_getloadavg_OBJECTS) $(test_getloadavg_LDADD) $(LIBS) + +test-getlogin$(EXEEXT): $(test_getlogin_OBJECTS) $(test_getlogin_DEPENDENCIES) $(EXTRA_test_getlogin_DEPENDENCIES) + @rm -f test-getlogin$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_getlogin_OBJECTS) $(test_getlogin_LDADD) $(LIBS) + +test-getndelim2$(EXEEXT): $(test_getndelim2_OBJECTS) $(test_getndelim2_DEPENDENCIES) $(EXTRA_test_getndelim2_DEPENDENCIES) + @rm -f test-getndelim2$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_getndelim2_OBJECTS) $(test_getndelim2_LDADD) $(LIBS) + +test-getopt-gnu$(EXEEXT): $(test_getopt_gnu_OBJECTS) $(test_getopt_gnu_DEPENDENCIES) $(EXTRA_test_getopt_gnu_DEPENDENCIES) + @rm -f test-getopt-gnu$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_getopt_gnu_OBJECTS) $(test_getopt_gnu_LDADD) $(LIBS) + +test-getopt-posix$(EXEEXT): $(test_getopt_posix_OBJECTS) $(test_getopt_posix_DEPENDENCIES) $(EXTRA_test_getopt_posix_DEPENDENCIES) + @rm -f test-getopt-posix$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_getopt_posix_OBJECTS) $(test_getopt_posix_LDADD) $(LIBS) + +test-getprogname$(EXEEXT): $(test_getprogname_OBJECTS) $(test_getprogname_DEPENDENCIES) $(EXTRA_test_getprogname_DEPENDENCIES) + @rm -f test-getprogname$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_getprogname_OBJECTS) $(test_getprogname_LDADD) $(LIBS) + +test-getrusage$(EXEEXT): $(test_getrusage_OBJECTS) $(test_getrusage_DEPENDENCIES) $(EXTRA_test_getrusage_DEPENDENCIES) + @rm -f test-getrusage$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_getrusage_OBJECTS) $(test_getrusage_LDADD) $(LIBS) + +test-gettimeofday$(EXEEXT): $(test_gettimeofday_OBJECTS) $(test_gettimeofday_DEPENDENCIES) $(EXTRA_test_gettimeofday_DEPENDENCIES) + @rm -f test-gettimeofday$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_gettimeofday_OBJECTS) $(test_gettimeofday_LDADD) $(LIBS) + +test-hard-locale$(EXEEXT): $(test_hard_locale_OBJECTS) $(test_hard_locale_DEPENDENCIES) $(EXTRA_test_hard_locale_DEPENDENCIES) + @rm -f test-hard-locale$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_hard_locale_OBJECTS) $(test_hard_locale_LDADD) $(LIBS) + +test-hash$(EXEEXT): $(test_hash_OBJECTS) $(test_hash_DEPENDENCIES) $(EXTRA_test_hash_DEPENDENCIES) + @rm -f test-hash$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_hash_OBJECTS) $(test_hash_LDADD) $(LIBS) + +test-i-ring$(EXEEXT): $(test_i_ring_OBJECTS) $(test_i_ring_DEPENDENCIES) $(EXTRA_test_i_ring_DEPENDENCIES) + @rm -f test-i-ring$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_i_ring_OBJECTS) $(test_i_ring_LDADD) $(LIBS) + +test-iconv$(EXEEXT): $(test_iconv_OBJECTS) $(test_iconv_DEPENDENCIES) $(EXTRA_test_iconv_DEPENDENCIES) + @rm -f test-iconv$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_iconv_OBJECTS) $(test_iconv_LDADD) $(LIBS) + +test-iconv-h$(EXEEXT): $(test_iconv_h_OBJECTS) $(test_iconv_h_DEPENDENCIES) $(EXTRA_test_iconv_h_DEPENDENCIES) + @rm -f test-iconv-h$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_iconv_h_OBJECTS) $(test_iconv_h_LDADD) $(LIBS) + +test-ignore-value$(EXEEXT): $(test_ignore_value_OBJECTS) $(test_ignore_value_DEPENDENCIES) $(EXTRA_test_ignore_value_DEPENDENCIES) + @rm -f test-ignore-value$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_ignore_value_OBJECTS) $(test_ignore_value_LDADD) $(LIBS) + +test-inet_ntop$(EXEEXT): $(test_inet_ntop_OBJECTS) $(test_inet_ntop_DEPENDENCIES) $(EXTRA_test_inet_ntop_DEPENDENCIES) + @rm -f test-inet_ntop$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_inet_ntop_OBJECTS) $(test_inet_ntop_LDADD) $(LIBS) + +test-inet_pton$(EXEEXT): $(test_inet_pton_OBJECTS) $(test_inet_pton_DEPENDENCIES) $(EXTRA_test_inet_pton_DEPENDENCIES) + @rm -f test-inet_pton$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_inet_pton_OBJECTS) $(test_inet_pton_LDADD) $(LIBS) + +test-ino-map$(EXEEXT): $(test_ino_map_OBJECTS) $(test_ino_map_DEPENDENCIES) $(EXTRA_test_ino_map_DEPENDENCIES) + @rm -f test-ino-map$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_ino_map_OBJECTS) $(test_ino_map_LDADD) $(LIBS) + +test-intprops$(EXEEXT): $(test_intprops_OBJECTS) $(test_intprops_DEPENDENCIES) $(EXTRA_test_intprops_DEPENDENCIES) + @rm -f test-intprops$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_intprops_OBJECTS) $(test_intprops_LDADD) $(LIBS) + +test-inttostr$(EXEEXT): $(test_inttostr_OBJECTS) $(test_inttostr_DEPENDENCIES) $(EXTRA_test_inttostr_DEPENDENCIES) + @rm -f test-inttostr$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_inttostr_OBJECTS) $(test_inttostr_LDADD) $(LIBS) + +test-inttypes$(EXEEXT): $(test_inttypes_OBJECTS) $(test_inttypes_DEPENDENCIES) $(EXTRA_test_inttypes_DEPENDENCIES) + @rm -f test-inttypes$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_inttypes_OBJECTS) $(test_inttypes_LDADD) $(LIBS) + +test-ioctl$(EXEEXT): $(test_ioctl_OBJECTS) $(test_ioctl_DEPENDENCIES) $(EXTRA_test_ioctl_DEPENDENCIES) + @rm -f test-ioctl$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_ioctl_OBJECTS) $(test_ioctl_LDADD) $(LIBS) + +test-isatty$(EXEEXT): $(test_isatty_OBJECTS) $(test_isatty_DEPENDENCIES) $(EXTRA_test_isatty_DEPENDENCIES) + @rm -f test-isatty$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_isatty_OBJECTS) $(test_isatty_LDADD) $(LIBS) + +test-isblank$(EXEEXT): $(test_isblank_OBJECTS) $(test_isblank_DEPENDENCIES) $(EXTRA_test_isblank_DEPENDENCIES) + @rm -f test-isblank$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_isblank_OBJECTS) $(test_isblank_LDADD) $(LIBS) + +test-isnand-nolibm$(EXEEXT): $(test_isnand_nolibm_OBJECTS) $(test_isnand_nolibm_DEPENDENCIES) $(EXTRA_test_isnand_nolibm_DEPENDENCIES) + @rm -f test-isnand-nolibm$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_isnand_nolibm_OBJECTS) $(test_isnand_nolibm_LDADD) $(LIBS) + +test-isnanf-nolibm$(EXEEXT): $(test_isnanf_nolibm_OBJECTS) $(test_isnanf_nolibm_DEPENDENCIES) $(EXTRA_test_isnanf_nolibm_DEPENDENCIES) + @rm -f test-isnanf-nolibm$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_isnanf_nolibm_OBJECTS) $(test_isnanf_nolibm_LDADD) $(LIBS) + +test-isnanl-nolibm$(EXEEXT): $(test_isnanl_nolibm_OBJECTS) $(test_isnanl_nolibm_DEPENDENCIES) $(EXTRA_test_isnanl_nolibm_DEPENDENCIES) + @rm -f test-isnanl-nolibm$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_isnanl_nolibm_OBJECTS) $(test_isnanl_nolibm_LDADD) $(LIBS) + +test-iswblank$(EXEEXT): $(test_iswblank_OBJECTS) $(test_iswblank_DEPENDENCIES) $(EXTRA_test_iswblank_DEPENDENCIES) + @rm -f test-iswblank$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_iswblank_OBJECTS) $(test_iswblank_LDADD) $(LIBS) + +test-iswdigit$(EXEEXT): $(test_iswdigit_OBJECTS) $(test_iswdigit_DEPENDENCIES) $(EXTRA_test_iswdigit_DEPENDENCIES) + @rm -f test-iswdigit$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_iswdigit_OBJECTS) $(test_iswdigit_LDADD) $(LIBS) + +test-iswxdigit$(EXEEXT): $(test_iswxdigit_OBJECTS) $(test_iswxdigit_DEPENDENCIES) $(EXTRA_test_iswxdigit_DEPENDENCIES) + @rm -f test-iswxdigit$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_iswxdigit_OBJECTS) $(test_iswxdigit_LDADD) $(LIBS) + +test-langinfo$(EXEEXT): $(test_langinfo_OBJECTS) $(test_langinfo_DEPENDENCIES) $(EXTRA_test_langinfo_DEPENDENCIES) + @rm -f test-langinfo$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_langinfo_OBJECTS) $(test_langinfo_LDADD) $(LIBS) + +test-lchmod$(EXEEXT): $(test_lchmod_OBJECTS) $(test_lchmod_DEPENDENCIES) $(EXTRA_test_lchmod_DEPENDENCIES) + @rm -f test-lchmod$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_lchmod_OBJECTS) $(test_lchmod_LDADD) $(LIBS) + +test-lchown$(EXEEXT): $(test_lchown_OBJECTS) $(test_lchown_DEPENDENCIES) $(EXTRA_test_lchown_DEPENDENCIES) + @rm -f test-lchown$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_lchown_OBJECTS) $(test_lchown_LDADD) $(LIBS) + +test-limits-h$(EXEEXT): $(test_limits_h_OBJECTS) $(test_limits_h_DEPENDENCIES) $(EXTRA_test_limits_h_DEPENDENCIES) + @rm -f test-limits-h$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_limits_h_OBJECTS) $(test_limits_h_LDADD) $(LIBS) + +test-link$(EXEEXT): $(test_link_OBJECTS) $(test_link_DEPENDENCIES) $(EXTRA_test_link_DEPENDENCIES) + @rm -f test-link$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_link_OBJECTS) $(test_link_LDADD) $(LIBS) + +test-linkat$(EXEEXT): $(test_linkat_OBJECTS) $(test_linkat_DEPENDENCIES) $(EXTRA_test_linkat_DEPENDENCIES) + @rm -f test-linkat$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_linkat_OBJECTS) $(test_linkat_LDADD) $(LIBS) + +test-listen$(EXEEXT): $(test_listen_OBJECTS) $(test_listen_DEPENDENCIES) $(EXTRA_test_listen_DEPENDENCIES) + @rm -f test-listen$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_listen_OBJECTS) $(test_listen_LDADD) $(LIBS) + +test-localcharset$(EXEEXT): $(test_localcharset_OBJECTS) $(test_localcharset_DEPENDENCIES) $(EXTRA_test_localcharset_DEPENDENCIES) + @rm -f test-localcharset$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_localcharset_OBJECTS) $(test_localcharset_LDADD) $(LIBS) + +test-locale$(EXEEXT): $(test_locale_OBJECTS) $(test_locale_DEPENDENCIES) $(EXTRA_test_locale_DEPENDENCIES) + @rm -f test-locale$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_locale_OBJECTS) $(test_locale_LDADD) $(LIBS) + +test-localeconv$(EXEEXT): $(test_localeconv_OBJECTS) $(test_localeconv_DEPENDENCIES) $(EXTRA_test_localeconv_DEPENDENCIES) + @rm -f test-localeconv$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_localeconv_OBJECTS) $(test_localeconv_LDADD) $(LIBS) + +test-localename$(EXEEXT): $(test_localename_OBJECTS) $(test_localename_DEPENDENCIES) $(EXTRA_test_localename_DEPENDENCIES) + @rm -f test-localename$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_localename_OBJECTS) $(test_localename_LDADD) $(LIBS) + +test-lock$(EXEEXT): $(test_lock_OBJECTS) $(test_lock_DEPENDENCIES) $(EXTRA_test_lock_DEPENDENCIES) + @rm -f test-lock$(EXEEXT) + $(AM_V_CCLD)$(test_lock_LINK) $(test_lock_OBJECTS) $(test_lock_LDADD) $(LIBS) + +test-lseek$(EXEEXT): $(test_lseek_OBJECTS) $(test_lseek_DEPENDENCIES) $(EXTRA_test_lseek_DEPENDENCIES) + @rm -f test-lseek$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_lseek_OBJECTS) $(test_lseek_LDADD) $(LIBS) + +test-lstat$(EXEEXT): $(test_lstat_OBJECTS) $(test_lstat_DEPENDENCIES) $(EXTRA_test_lstat_DEPENDENCIES) + @rm -f test-lstat$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_lstat_OBJECTS) $(test_lstat_LDADD) $(LIBS) + +test-malloc-gnu$(EXEEXT): $(test_malloc_gnu_OBJECTS) $(test_malloc_gnu_DEPENDENCIES) $(EXTRA_test_malloc_gnu_DEPENDENCIES) + @rm -f test-malloc-gnu$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_malloc_gnu_OBJECTS) $(test_malloc_gnu_LDADD) $(LIBS) + +test-malloca$(EXEEXT): $(test_malloca_OBJECTS) $(test_malloca_DEPENDENCIES) $(EXTRA_test_malloca_DEPENDENCIES) + @rm -f test-malloca$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_malloca_OBJECTS) $(test_malloca_LDADD) $(LIBS) + +test-math$(EXEEXT): $(test_math_OBJECTS) $(test_math_DEPENDENCIES) $(EXTRA_test_math_DEPENDENCIES) + @rm -f test-math$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_math_OBJECTS) $(test_math_LDADD) $(LIBS) + +test-mbrtowc$(EXEEXT): $(test_mbrtowc_OBJECTS) $(test_mbrtowc_DEPENDENCIES) $(EXTRA_test_mbrtowc_DEPENDENCIES) + @rm -f test-mbrtowc$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_mbrtowc_OBJECTS) $(test_mbrtowc_LDADD) $(LIBS) + +test-mbrtowc-w32$(EXEEXT): $(test_mbrtowc_w32_OBJECTS) $(test_mbrtowc_w32_DEPENDENCIES) $(EXTRA_test_mbrtowc_w32_DEPENDENCIES) + @rm -f test-mbrtowc-w32$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_mbrtowc_w32_OBJECTS) $(test_mbrtowc_w32_LDADD) $(LIBS) + +test-mbsalign$(EXEEXT): $(test_mbsalign_OBJECTS) $(test_mbsalign_DEPENDENCIES) $(EXTRA_test_mbsalign_DEPENDENCIES) + @rm -f test-mbsalign$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_mbsalign_OBJECTS) $(test_mbsalign_LDADD) $(LIBS) + +test-mbscasecmp$(EXEEXT): $(test_mbscasecmp_OBJECTS) $(test_mbscasecmp_DEPENDENCIES) $(EXTRA_test_mbscasecmp_DEPENDENCIES) + @rm -f test-mbscasecmp$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_mbscasecmp_OBJECTS) $(test_mbscasecmp_LDADD) $(LIBS) + +test-mbschr$(EXEEXT): $(test_mbschr_OBJECTS) $(test_mbschr_DEPENDENCIES) $(EXTRA_test_mbschr_DEPENDENCIES) + @rm -f test-mbschr$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_mbschr_OBJECTS) $(test_mbschr_LDADD) $(LIBS) + +test-mbsinit$(EXEEXT): $(test_mbsinit_OBJECTS) $(test_mbsinit_DEPENDENCIES) $(EXTRA_test_mbsinit_DEPENDENCIES) + @rm -f test-mbsinit$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_mbsinit_OBJECTS) $(test_mbsinit_LDADD) $(LIBS) + +test-mbsrtowcs$(EXEEXT): $(test_mbsrtowcs_OBJECTS) $(test_mbsrtowcs_DEPENDENCIES) $(EXTRA_test_mbsrtowcs_DEPENDENCIES) + @rm -f test-mbsrtowcs$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_mbsrtowcs_OBJECTS) $(test_mbsrtowcs_LDADD) $(LIBS) + +test-mbsstr1$(EXEEXT): $(test_mbsstr1_OBJECTS) $(test_mbsstr1_DEPENDENCIES) $(EXTRA_test_mbsstr1_DEPENDENCIES) + @rm -f test-mbsstr1$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_mbsstr1_OBJECTS) $(test_mbsstr1_LDADD) $(LIBS) + +test-mbsstr2$(EXEEXT): $(test_mbsstr2_OBJECTS) $(test_mbsstr2_DEPENDENCIES) $(EXTRA_test_mbsstr2_DEPENDENCIES) + @rm -f test-mbsstr2$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_mbsstr2_OBJECTS) $(test_mbsstr2_LDADD) $(LIBS) + +test-mbsstr3$(EXEEXT): $(test_mbsstr3_OBJECTS) $(test_mbsstr3_DEPENDENCIES) $(EXTRA_test_mbsstr3_DEPENDENCIES) + @rm -f test-mbsstr3$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_mbsstr3_OBJECTS) $(test_mbsstr3_LDADD) $(LIBS) + +test-md5$(EXEEXT): $(test_md5_OBJECTS) $(test_md5_DEPENDENCIES) $(EXTRA_test_md5_DEPENDENCIES) + @rm -f test-md5$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_md5_OBJECTS) $(test_md5_LDADD) $(LIBS) + +test-memcasecmp$(EXEEXT): $(test_memcasecmp_OBJECTS) $(test_memcasecmp_DEPENDENCIES) $(EXTRA_test_memcasecmp_DEPENDENCIES) + @rm -f test-memcasecmp$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_memcasecmp_OBJECTS) $(test_memcasecmp_LDADD) $(LIBS) + +test-memchr$(EXEEXT): $(test_memchr_OBJECTS) $(test_memchr_DEPENDENCIES) $(EXTRA_test_memchr_DEPENDENCIES) + @rm -f test-memchr$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_memchr_OBJECTS) $(test_memchr_LDADD) $(LIBS) + +test-memchr2$(EXEEXT): $(test_memchr2_OBJECTS) $(test_memchr2_DEPENDENCIES) $(EXTRA_test_memchr2_DEPENDENCIES) + @rm -f test-memchr2$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_memchr2_OBJECTS) $(test_memchr2_LDADD) $(LIBS) + +test-memcoll$(EXEEXT): $(test_memcoll_OBJECTS) $(test_memcoll_DEPENDENCIES) $(EXTRA_test_memcoll_DEPENDENCIES) + @rm -f test-memcoll$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_memcoll_OBJECTS) $(test_memcoll_LDADD) $(LIBS) + +test-memrchr$(EXEEXT): $(test_memrchr_OBJECTS) $(test_memrchr_DEPENDENCIES) $(EXTRA_test_memrchr_DEPENDENCIES) + @rm -f test-memrchr$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_memrchr_OBJECTS) $(test_memrchr_LDADD) $(LIBS) + +test-mkdir$(EXEEXT): $(test_mkdir_OBJECTS) $(test_mkdir_DEPENDENCIES) $(EXTRA_test_mkdir_DEPENDENCIES) + @rm -f test-mkdir$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_mkdir_OBJECTS) $(test_mkdir_LDADD) $(LIBS) + +test-mkfifo$(EXEEXT): $(test_mkfifo_OBJECTS) $(test_mkfifo_DEPENDENCIES) $(EXTRA_test_mkfifo_DEPENDENCIES) + @rm -f test-mkfifo$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_mkfifo_OBJECTS) $(test_mkfifo_LDADD) $(LIBS) + +test-mknod$(EXEEXT): $(test_mknod_OBJECTS) $(test_mknod_DEPENDENCIES) $(EXTRA_test_mknod_DEPENDENCIES) + @rm -f test-mknod$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_mknod_OBJECTS) $(test_mknod_LDADD) $(LIBS) + +test-nanosleep$(EXEEXT): $(test_nanosleep_OBJECTS) $(test_nanosleep_DEPENDENCIES) $(EXTRA_test_nanosleep_DEPENDENCIES) + @rm -f test-nanosleep$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_nanosleep_OBJECTS) $(test_nanosleep_LDADD) $(LIBS) + +test-netdb$(EXEEXT): $(test_netdb_OBJECTS) $(test_netdb_DEPENDENCIES) $(EXTRA_test_netdb_DEPENDENCIES) + @rm -f test-netdb$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_netdb_OBJECTS) $(test_netdb_LDADD) $(LIBS) + +test-netinet_in$(EXEEXT): $(test_netinet_in_OBJECTS) $(test_netinet_in_DEPENDENCIES) $(EXTRA_test_netinet_in_DEPENDENCIES) + @rm -f test-netinet_in$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_netinet_in_OBJECTS) $(test_netinet_in_LDADD) $(LIBS) + +test-nl_langinfo$(EXEEXT): $(test_nl_langinfo_OBJECTS) $(test_nl_langinfo_DEPENDENCIES) $(EXTRA_test_nl_langinfo_DEPENDENCIES) + @rm -f test-nl_langinfo$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_nl_langinfo_OBJECTS) $(test_nl_langinfo_LDADD) $(LIBS) + +test-nl_langinfo-mt$(EXEEXT): $(test_nl_langinfo_mt_OBJECTS) $(test_nl_langinfo_mt_DEPENDENCIES) $(EXTRA_test_nl_langinfo_mt_DEPENDENCIES) + @rm -f test-nl_langinfo-mt$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_nl_langinfo_mt_OBJECTS) $(test_nl_langinfo_mt_LDADD) $(LIBS) + +test-nstrftime$(EXEEXT): $(test_nstrftime_OBJECTS) $(test_nstrftime_DEPENDENCIES) $(EXTRA_test_nstrftime_DEPENDENCIES) + @rm -f test-nstrftime$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_nstrftime_OBJECTS) $(test_nstrftime_LDADD) $(LIBS) + +test-once1$(EXEEXT): $(test_once1_OBJECTS) $(test_once1_DEPENDENCIES) $(EXTRA_test_once1_DEPENDENCIES) + @rm -f test-once1$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_once1_OBJECTS) $(test_once1_LDADD) $(LIBS) + +test-once2$(EXEEXT): $(test_once2_OBJECTS) $(test_once2_DEPENDENCIES) $(EXTRA_test_once2_DEPENDENCIES) + @rm -f test-once2$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_once2_OBJECTS) $(test_once2_LDADD) $(LIBS) + +test-open$(EXEEXT): $(test_open_OBJECTS) $(test_open_DEPENDENCIES) $(EXTRA_test_open_DEPENDENCIES) + @rm -f test-open$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_open_OBJECTS) $(test_open_LDADD) $(LIBS) + +test-openat$(EXEEXT): $(test_openat_OBJECTS) $(test_openat_DEPENDENCIES) $(EXTRA_test_openat_DEPENDENCIES) + @rm -f test-openat$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_openat_OBJECTS) $(test_openat_LDADD) $(LIBS) + +test-openat-safer$(EXEEXT): $(test_openat_safer_OBJECTS) $(test_openat_safer_DEPENDENCIES) $(EXTRA_test_openat_safer_DEPENDENCIES) + @rm -f test-openat-safer$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_openat_safer_OBJECTS) $(test_openat_safer_LDADD) $(LIBS) + +test-parse-datetime$(EXEEXT): $(test_parse_datetime_OBJECTS) $(test_parse_datetime_DEPENDENCIES) $(EXTRA_test_parse_datetime_DEPENDENCIES) + @rm -f test-parse-datetime$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_parse_datetime_OBJECTS) $(test_parse_datetime_LDADD) $(LIBS) + +test-pathmax$(EXEEXT): $(test_pathmax_OBJECTS) $(test_pathmax_DEPENDENCIES) $(EXTRA_test_pathmax_DEPENDENCIES) + @rm -f test-pathmax$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_pathmax_OBJECTS) $(test_pathmax_LDADD) $(LIBS) + +test-perror$(EXEEXT): $(test_perror_OBJECTS) $(test_perror_DEPENDENCIES) $(EXTRA_test_perror_DEPENDENCIES) + @rm -f test-perror$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_perror_OBJECTS) $(test_perror_LDADD) $(LIBS) + +test-perror2$(EXEEXT): $(test_perror2_OBJECTS) $(test_perror2_DEPENDENCIES) $(EXTRA_test_perror2_DEPENDENCIES) + @rm -f test-perror2$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_perror2_OBJECTS) $(test_perror2_LDADD) $(LIBS) + +test-pipe$(EXEEXT): $(test_pipe_OBJECTS) $(test_pipe_DEPENDENCIES) $(EXTRA_test_pipe_DEPENDENCIES) + @rm -f test-pipe$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_pipe_OBJECTS) $(test_pipe_LDADD) $(LIBS) + +test-pipe2$(EXEEXT): $(test_pipe2_OBJECTS) $(test_pipe2_DEPENDENCIES) $(EXTRA_test_pipe2_DEPENDENCIES) + @rm -f test-pipe2$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_pipe2_OBJECTS) $(test_pipe2_LDADD) $(LIBS) + +test-posixtm$(EXEEXT): $(test_posixtm_OBJECTS) $(test_posixtm_DEPENDENCIES) $(EXTRA_test_posixtm_DEPENDENCIES) + @rm -f test-posixtm$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_posixtm_OBJECTS) $(test_posixtm_LDADD) $(LIBS) + +test-printf-frexp$(EXEEXT): $(test_printf_frexp_OBJECTS) $(test_printf_frexp_DEPENDENCIES) $(EXTRA_test_printf_frexp_DEPENDENCIES) + @rm -f test-printf-frexp$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_printf_frexp_OBJECTS) $(test_printf_frexp_LDADD) $(LIBS) + +test-printf-frexpl$(EXEEXT): $(test_printf_frexpl_OBJECTS) $(test_printf_frexpl_DEPENDENCIES) $(EXTRA_test_printf_frexpl_DEPENDENCIES) + @rm -f test-printf-frexpl$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_printf_frexpl_OBJECTS) $(test_printf_frexpl_LDADD) $(LIBS) + +test-priv-set$(EXEEXT): $(test_priv_set_OBJECTS) $(test_priv_set_DEPENDENCIES) $(EXTRA_test_priv_set_DEPENDENCIES) + @rm -f test-priv-set$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_priv_set_OBJECTS) $(test_priv_set_LDADD) $(LIBS) + +test-pthread$(EXEEXT): $(test_pthread_OBJECTS) $(test_pthread_DEPENDENCIES) $(EXTRA_test_pthread_DEPENDENCIES) + @rm -f test-pthread$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_pthread_OBJECTS) $(test_pthread_LDADD) $(LIBS) + +test-pthread-cond$(EXEEXT): $(test_pthread_cond_OBJECTS) $(test_pthread_cond_DEPENDENCIES) $(EXTRA_test_pthread_cond_DEPENDENCIES) + @rm -f test-pthread-cond$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_pthread_cond_OBJECTS) $(test_pthread_cond_LDADD) $(LIBS) + +test-pthread-mutex$(EXEEXT): $(test_pthread_mutex_OBJECTS) $(test_pthread_mutex_DEPENDENCIES) $(EXTRA_test_pthread_mutex_DEPENDENCIES) + @rm -f test-pthread-mutex$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_pthread_mutex_OBJECTS) $(test_pthread_mutex_LDADD) $(LIBS) + +test-pthread-thread$(EXEEXT): $(test_pthread_thread_OBJECTS) $(test_pthread_thread_DEPENDENCIES) $(EXTRA_test_pthread_thread_DEPENDENCIES) + @rm -f test-pthread-thread$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_pthread_thread_OBJECTS) $(test_pthread_thread_LDADD) $(LIBS) + +test-pthread_sigmask1$(EXEEXT): $(test_pthread_sigmask1_OBJECTS) $(test_pthread_sigmask1_DEPENDENCIES) $(EXTRA_test_pthread_sigmask1_DEPENDENCIES) + @rm -f test-pthread_sigmask1$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_pthread_sigmask1_OBJECTS) $(test_pthread_sigmask1_LDADD) $(LIBS) + +test-pthread_sigmask2$(EXEEXT): $(test_pthread_sigmask2_OBJECTS) $(test_pthread_sigmask2_DEPENDENCIES) $(EXTRA_test_pthread_sigmask2_DEPENDENCIES) + @rm -f test-pthread_sigmask2$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_pthread_sigmask2_OBJECTS) $(test_pthread_sigmask2_LDADD) $(LIBS) + +test-quotearg-simple$(EXEEXT): $(test_quotearg_simple_OBJECTS) $(test_quotearg_simple_DEPENDENCIES) $(EXTRA_test_quotearg_simple_DEPENDENCIES) + @rm -f test-quotearg-simple$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_quotearg_simple_OBJECTS) $(test_quotearg_simple_LDADD) $(LIBS) + +test-raise$(EXEEXT): $(test_raise_OBJECTS) $(test_raise_DEPENDENCIES) $(EXTRA_test_raise_DEPENDENCIES) + @rm -f test-raise$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_raise_OBJECTS) $(test_raise_LDADD) $(LIBS) + +test-rand-isaac$(EXEEXT): $(test_rand_isaac_OBJECTS) $(test_rand_isaac_DEPENDENCIES) $(EXTRA_test_rand_isaac_DEPENDENCIES) + @rm -f test-rand-isaac$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_rand_isaac_OBJECTS) $(test_rand_isaac_LDADD) $(LIBS) + +test-read$(EXEEXT): $(test_read_OBJECTS) $(test_read_DEPENDENCIES) $(EXTRA_test_read_DEPENDENCIES) + @rm -f test-read$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_read_OBJECTS) $(test_read_LDADD) $(LIBS) + +test-read-file$(EXEEXT): $(test_read_file_OBJECTS) $(test_read_file_DEPENDENCIES) $(EXTRA_test_read_file_DEPENDENCIES) + @rm -f test-read-file$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_read_file_OBJECTS) $(test_read_file_LDADD) $(LIBS) + +test-readlink$(EXEEXT): $(test_readlink_OBJECTS) $(test_readlink_DEPENDENCIES) $(EXTRA_test_readlink_DEPENDENCIES) + @rm -f test-readlink$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_readlink_OBJECTS) $(test_readlink_LDADD) $(LIBS) + +test-readlinkat$(EXEEXT): $(test_readlinkat_OBJECTS) $(test_readlinkat_DEPENDENCIES) $(EXTRA_test_readlinkat_DEPENDENCIES) + @rm -f test-readlinkat$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_readlinkat_OBJECTS) $(test_readlinkat_LDADD) $(LIBS) + +test-readtokens$(EXEEXT): $(test_readtokens_OBJECTS) $(test_readtokens_DEPENDENCIES) $(EXTRA_test_readtokens_DEPENDENCIES) + @rm -f test-readtokens$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_readtokens_OBJECTS) $(test_readtokens_LDADD) $(LIBS) + +test-realloc-gnu$(EXEEXT): $(test_realloc_gnu_OBJECTS) $(test_realloc_gnu_DEPENDENCIES) $(EXTRA_test_realloc_gnu_DEPENDENCIES) + @rm -f test-realloc-gnu$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_realloc_gnu_OBJECTS) $(test_realloc_gnu_LDADD) $(LIBS) + +test-regex$(EXEEXT): $(test_regex_OBJECTS) $(test_regex_DEPENDENCIES) $(EXTRA_test_regex_DEPENDENCIES) + @rm -f test-regex$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_regex_OBJECTS) $(test_regex_LDADD) $(LIBS) + +test-remove$(EXEEXT): $(test_remove_OBJECTS) $(test_remove_DEPENDENCIES) $(EXTRA_test_remove_DEPENDENCIES) + @rm -f test-remove$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_remove_OBJECTS) $(test_remove_LDADD) $(LIBS) + +test-rename$(EXEEXT): $(test_rename_OBJECTS) $(test_rename_DEPENDENCIES) $(EXTRA_test_rename_DEPENDENCIES) + @rm -f test-rename$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_rename_OBJECTS) $(test_rename_LDADD) $(LIBS) + +test-renameat$(EXEEXT): $(test_renameat_OBJECTS) $(test_renameat_DEPENDENCIES) $(EXTRA_test_renameat_DEPENDENCIES) + @rm -f test-renameat$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_renameat_OBJECTS) $(test_renameat_LDADD) $(LIBS) + +test-renameatu$(EXEEXT): $(test_renameatu_OBJECTS) $(test_renameatu_DEPENDENCIES) $(EXTRA_test_renameatu_DEPENDENCIES) + @rm -f test-renameatu$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_renameatu_OBJECTS) $(test_renameatu_LDADD) $(LIBS) + +test-rmdir$(EXEEXT): $(test_rmdir_OBJECTS) $(test_rmdir_DEPENDENCIES) $(EXTRA_test_rmdir_DEPENDENCIES) + @rm -f test-rmdir$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_rmdir_OBJECTS) $(test_rmdir_LDADD) $(LIBS) + +test-rwlock1$(EXEEXT): $(test_rwlock1_OBJECTS) $(test_rwlock1_DEPENDENCIES) $(EXTRA_test_rwlock1_DEPENDENCIES) + @rm -f test-rwlock1$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_rwlock1_OBJECTS) $(test_rwlock1_LDADD) $(LIBS) + +test-sameacls$(EXEEXT): $(test_sameacls_OBJECTS) $(test_sameacls_DEPENDENCIES) $(EXTRA_test_sameacls_DEPENDENCIES) + @rm -f test-sameacls$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_sameacls_OBJECTS) $(test_sameacls_LDADD) $(LIBS) + +test-sched$(EXEEXT): $(test_sched_OBJECTS) $(test_sched_DEPENDENCIES) $(EXTRA_test_sched_DEPENDENCIES) + @rm -f test-sched$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_sched_OBJECTS) $(test_sched_LDADD) $(LIBS) + +test-select$(EXEEXT): $(test_select_OBJECTS) $(test_select_DEPENDENCIES) $(EXTRA_test_select_DEPENDENCIES) + @rm -f test-select$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_select_OBJECTS) $(test_select_LDADD) $(LIBS) + +test-select-fd$(EXEEXT): $(test_select_fd_OBJECTS) $(test_select_fd_DEPENDENCIES) $(EXTRA_test_select_fd_DEPENDENCIES) + @rm -f test-select-fd$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_select_fd_OBJECTS) $(test_select_fd_LDADD) $(LIBS) + +test-select-stdin$(EXEEXT): $(test_select_stdin_OBJECTS) $(test_select_stdin_DEPENDENCIES) $(EXTRA_test_select_stdin_DEPENDENCIES) + @rm -f test-select-stdin$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_select_stdin_OBJECTS) $(test_select_stdin_LDADD) $(LIBS) + +test-set-mode-acl$(EXEEXT): $(test_set_mode_acl_OBJECTS) $(test_set_mode_acl_DEPENDENCIES) $(EXTRA_test_set_mode_acl_DEPENDENCIES) + @rm -f test-set-mode-acl$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_set_mode_acl_OBJECTS) $(test_set_mode_acl_LDADD) $(LIBS) + +test-setenv$(EXEEXT): $(test_setenv_OBJECTS) $(test_setenv_DEPENDENCIES) $(EXTRA_test_setenv_DEPENDENCIES) + @rm -f test-setenv$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_setenv_OBJECTS) $(test_setenv_LDADD) $(LIBS) + +test-setlocale1$(EXEEXT): $(test_setlocale1_OBJECTS) $(test_setlocale1_DEPENDENCIES) $(EXTRA_test_setlocale1_DEPENDENCIES) + @rm -f test-setlocale1$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_setlocale1_OBJECTS) $(test_setlocale1_LDADD) $(LIBS) + +test-setlocale2$(EXEEXT): $(test_setlocale2_OBJECTS) $(test_setlocale2_DEPENDENCIES) $(EXTRA_test_setlocale2_DEPENDENCIES) + @rm -f test-setlocale2$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_setlocale2_OBJECTS) $(test_setlocale2_LDADD) $(LIBS) + +test-setlocale_null$(EXEEXT): $(test_setlocale_null_OBJECTS) $(test_setlocale_null_DEPENDENCIES) $(EXTRA_test_setlocale_null_DEPENDENCIES) + @rm -f test-setlocale_null$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_setlocale_null_OBJECTS) $(test_setlocale_null_LDADD) $(LIBS) + +test-setlocale_null-mt-all$(EXEEXT): $(test_setlocale_null_mt_all_OBJECTS) $(test_setlocale_null_mt_all_DEPENDENCIES) $(EXTRA_test_setlocale_null_mt_all_DEPENDENCIES) + @rm -f test-setlocale_null-mt-all$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_setlocale_null_mt_all_OBJECTS) $(test_setlocale_null_mt_all_LDADD) $(LIBS) + +test-setlocale_null-mt-one$(EXEEXT): $(test_setlocale_null_mt_one_OBJECTS) $(test_setlocale_null_mt_one_DEPENDENCIES) $(EXTRA_test_setlocale_null_mt_one_DEPENDENCIES) + @rm -f test-setlocale_null-mt-one$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_setlocale_null_mt_one_OBJECTS) $(test_setlocale_null_mt_one_LDADD) $(LIBS) + +test-setsockopt$(EXEEXT): $(test_setsockopt_OBJECTS) $(test_setsockopt_DEPENDENCIES) $(EXTRA_test_setsockopt_DEPENDENCIES) + @rm -f test-setsockopt$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_setsockopt_OBJECTS) $(test_setsockopt_LDADD) $(LIBS) + +test-sha1$(EXEEXT): $(test_sha1_OBJECTS) $(test_sha1_DEPENDENCIES) $(EXTRA_test_sha1_DEPENDENCIES) + @rm -f test-sha1$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_sha1_OBJECTS) $(test_sha1_LDADD) $(LIBS) + +test-sha256$(EXEEXT): $(test_sha256_OBJECTS) $(test_sha256_DEPENDENCIES) $(EXTRA_test_sha256_DEPENDENCIES) + @rm -f test-sha256$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_sha256_OBJECTS) $(test_sha256_LDADD) $(LIBS) + +test-sha512$(EXEEXT): $(test_sha512_OBJECTS) $(test_sha512_DEPENDENCIES) $(EXTRA_test_sha512_DEPENDENCIES) + @rm -f test-sha512$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_sha512_OBJECTS) $(test_sha512_LDADD) $(LIBS) + +test-sigaction$(EXEEXT): $(test_sigaction_OBJECTS) $(test_sigaction_DEPENDENCIES) $(EXTRA_test_sigaction_DEPENDENCIES) + @rm -f test-sigaction$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_sigaction_OBJECTS) $(test_sigaction_LDADD) $(LIBS) + +test-signal-h$(EXEEXT): $(test_signal_h_OBJECTS) $(test_signal_h_DEPENDENCIES) $(EXTRA_test_signal_h_DEPENDENCIES) + @rm -f test-signal-h$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_signal_h_OBJECTS) $(test_signal_h_LDADD) $(LIBS) + +test-signbit$(EXEEXT): $(test_signbit_OBJECTS) $(test_signbit_DEPENDENCIES) $(EXTRA_test_signbit_DEPENDENCIES) + @rm -f test-signbit$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_signbit_OBJECTS) $(test_signbit_LDADD) $(LIBS) + +test-sigprocmask$(EXEEXT): $(test_sigprocmask_OBJECTS) $(test_sigprocmask_DEPENDENCIES) $(EXTRA_test_sigprocmask_DEPENDENCIES) + @rm -f test-sigprocmask$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_sigprocmask_OBJECTS) $(test_sigprocmask_LDADD) $(LIBS) + +test-sleep$(EXEEXT): $(test_sleep_OBJECTS) $(test_sleep_DEPENDENCIES) $(EXTRA_test_sleep_DEPENDENCIES) + @rm -f test-sleep$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_sleep_OBJECTS) $(test_sleep_LDADD) $(LIBS) + +test-snprintf$(EXEEXT): $(test_snprintf_OBJECTS) $(test_snprintf_DEPENDENCIES) $(EXTRA_test_snprintf_DEPENDENCIES) + @rm -f test-snprintf$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_snprintf_OBJECTS) $(test_snprintf_LDADD) $(LIBS) + +test-sockets$(EXEEXT): $(test_sockets_OBJECTS) $(test_sockets_DEPENDENCIES) $(EXTRA_test_sockets_DEPENDENCIES) + @rm -f test-sockets$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_sockets_OBJECTS) $(test_sockets_LDADD) $(LIBS) + +test-stat$(EXEEXT): $(test_stat_OBJECTS) $(test_stat_DEPENDENCIES) $(EXTRA_test_stat_DEPENDENCIES) + @rm -f test-stat$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_stat_OBJECTS) $(test_stat_LDADD) $(LIBS) + +test-stat-time$(EXEEXT): $(test_stat_time_OBJECTS) $(test_stat_time_DEPENDENCIES) $(EXTRA_test_stat_time_DEPENDENCIES) + @rm -f test-stat-time$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_stat_time_OBJECTS) $(test_stat_time_LDADD) $(LIBS) + +test-statat$(EXEEXT): $(test_statat_OBJECTS) $(test_statat_DEPENDENCIES) $(EXTRA_test_statat_DEPENDENCIES) + @rm -f test-statat$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_statat_OBJECTS) $(test_statat_LDADD) $(LIBS) + +test-stdalign$(EXEEXT): $(test_stdalign_OBJECTS) $(test_stdalign_DEPENDENCIES) $(EXTRA_test_stdalign_DEPENDENCIES) + @rm -f test-stdalign$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_stdalign_OBJECTS) $(test_stdalign_LDADD) $(LIBS) + +test-stdbool$(EXEEXT): $(test_stdbool_OBJECTS) $(test_stdbool_DEPENDENCIES) $(EXTRA_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) $(EXTRA_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) $(EXTRA_test_stdint_DEPENDENCIES) + @rm -f test-stdint$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_stdint_OBJECTS) $(test_stdint_LDADD) $(LIBS) + +test-stdio$(EXEEXT): $(test_stdio_OBJECTS) $(test_stdio_DEPENDENCIES) $(EXTRA_test_stdio_DEPENDENCIES) + @rm -f test-stdio$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_stdio_OBJECTS) $(test_stdio_LDADD) $(LIBS) + +test-stdlib$(EXEEXT): $(test_stdlib_OBJECTS) $(test_stdlib_DEPENDENCIES) $(EXTRA_test_stdlib_DEPENDENCIES) + @rm -f test-stdlib$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_stdlib_OBJECTS) $(test_stdlib_LDADD) $(LIBS) + +test-strerror$(EXEEXT): $(test_strerror_OBJECTS) $(test_strerror_DEPENDENCIES) $(EXTRA_test_strerror_DEPENDENCIES) + @rm -f test-strerror$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_strerror_OBJECTS) $(test_strerror_LDADD) $(LIBS) + +test-strerror_r$(EXEEXT): $(test_strerror_r_OBJECTS) $(test_strerror_r_DEPENDENCIES) $(EXTRA_test_strerror_r_DEPENDENCIES) + @rm -f test-strerror_r$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_strerror_r_OBJECTS) $(test_strerror_r_LDADD) $(LIBS) + +test-striconv$(EXEEXT): $(test_striconv_OBJECTS) $(test_striconv_DEPENDENCIES) $(EXTRA_test_striconv_DEPENDENCIES) + @rm -f test-striconv$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_striconv_OBJECTS) $(test_striconv_LDADD) $(LIBS) + +test-string$(EXEEXT): $(test_string_OBJECTS) $(test_string_DEPENDENCIES) $(EXTRA_test_string_DEPENDENCIES) + @rm -f test-string$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_string_OBJECTS) $(test_string_LDADD) $(LIBS) + +test-strncat$(EXEEXT): $(test_strncat_OBJECTS) $(test_strncat_DEPENDENCIES) $(EXTRA_test_strncat_DEPENDENCIES) + @rm -f test-strncat$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_strncat_OBJECTS) $(test_strncat_LDADD) $(LIBS) + +test-strnlen$(EXEEXT): $(test_strnlen_OBJECTS) $(test_strnlen_DEPENDENCIES) $(EXTRA_test_strnlen_DEPENDENCIES) + @rm -f test-strnlen$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_strnlen_OBJECTS) $(test_strnlen_LDADD) $(LIBS) + +test-strsignal$(EXEEXT): $(test_strsignal_OBJECTS) $(test_strsignal_DEPENDENCIES) $(EXTRA_test_strsignal_DEPENDENCIES) + @rm -f test-strsignal$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_strsignal_OBJECTS) $(test_strsignal_LDADD) $(LIBS) + +test-strtod$(EXEEXT): $(test_strtod_OBJECTS) $(test_strtod_DEPENDENCIES) $(EXTRA_test_strtod_DEPENDENCIES) + @rm -f test-strtod$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_strtod_OBJECTS) $(test_strtod_LDADD) $(LIBS) + +test-strtod1$(EXEEXT): $(test_strtod1_OBJECTS) $(test_strtod1_DEPENDENCIES) $(EXTRA_test_strtod1_DEPENDENCIES) + @rm -f test-strtod1$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_strtod1_OBJECTS) $(test_strtod1_LDADD) $(LIBS) + +test-strtoimax$(EXEEXT): $(test_strtoimax_OBJECTS) $(test_strtoimax_DEPENDENCIES) $(EXTRA_test_strtoimax_DEPENDENCIES) + @rm -f test-strtoimax$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_strtoimax_OBJECTS) $(test_strtoimax_LDADD) $(LIBS) + +test-strtold$(EXEEXT): $(test_strtold_OBJECTS) $(test_strtold_DEPENDENCIES) $(EXTRA_test_strtold_DEPENDENCIES) + @rm -f test-strtold$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_strtold_OBJECTS) $(test_strtold_LDADD) $(LIBS) + +test-strtold1$(EXEEXT): $(test_strtold1_OBJECTS) $(test_strtold1_DEPENDENCIES) $(EXTRA_test_strtold1_DEPENDENCIES) + @rm -f test-strtold1$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_strtold1_OBJECTS) $(test_strtold1_LDADD) $(LIBS) + +test-strtoll$(EXEEXT): $(test_strtoll_OBJECTS) $(test_strtoll_DEPENDENCIES) $(EXTRA_test_strtoll_DEPENDENCIES) + @rm -f test-strtoll$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_strtoll_OBJECTS) $(test_strtoll_LDADD) $(LIBS) + +test-strtoull$(EXEEXT): $(test_strtoull_OBJECTS) $(test_strtoull_DEPENDENCIES) $(EXTRA_test_strtoull_DEPENDENCIES) + @rm -f test-strtoull$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_strtoull_OBJECTS) $(test_strtoull_LDADD) $(LIBS) + +test-strtoumax$(EXEEXT): $(test_strtoumax_OBJECTS) $(test_strtoumax_DEPENDENCIES) $(EXTRA_test_strtoumax_DEPENDENCIES) + @rm -f test-strtoumax$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_strtoumax_OBJECTS) $(test_strtoumax_LDADD) $(LIBS) + +test-symlink$(EXEEXT): $(test_symlink_OBJECTS) $(test_symlink_DEPENDENCIES) $(EXTRA_test_symlink_DEPENDENCIES) + @rm -f test-symlink$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_symlink_OBJECTS) $(test_symlink_LDADD) $(LIBS) + +test-symlinkat$(EXEEXT): $(test_symlinkat_OBJECTS) $(test_symlinkat_DEPENDENCIES) $(EXTRA_test_symlinkat_DEPENDENCIES) + @rm -f test-symlinkat$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_symlinkat_OBJECTS) $(test_symlinkat_LDADD) $(LIBS) + +test-sys_ioctl$(EXEEXT): $(test_sys_ioctl_OBJECTS) $(test_sys_ioctl_DEPENDENCIES) $(EXTRA_test_sys_ioctl_DEPENDENCIES) + @rm -f test-sys_ioctl$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_sys_ioctl_OBJECTS) $(test_sys_ioctl_LDADD) $(LIBS) + +test-sys_resource$(EXEEXT): $(test_sys_resource_OBJECTS) $(test_sys_resource_DEPENDENCIES) $(EXTRA_test_sys_resource_DEPENDENCIES) + @rm -f test-sys_resource$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_sys_resource_OBJECTS) $(test_sys_resource_LDADD) $(LIBS) + +test-sys_select$(EXEEXT): $(test_sys_select_OBJECTS) $(test_sys_select_DEPENDENCIES) $(EXTRA_test_sys_select_DEPENDENCIES) + @rm -f test-sys_select$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_sys_select_OBJECTS) $(test_sys_select_LDADD) $(LIBS) + +test-sys_socket$(EXEEXT): $(test_sys_socket_OBJECTS) $(test_sys_socket_DEPENDENCIES) $(EXTRA_test_sys_socket_DEPENDENCIES) + @rm -f test-sys_socket$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_sys_socket_OBJECTS) $(test_sys_socket_LDADD) $(LIBS) + +test-sys_stat$(EXEEXT): $(test_sys_stat_OBJECTS) $(test_sys_stat_DEPENDENCIES) $(EXTRA_test_sys_stat_DEPENDENCIES) + @rm -f test-sys_stat$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_sys_stat_OBJECTS) $(test_sys_stat_LDADD) $(LIBS) + +test-sys_time$(EXEEXT): $(test_sys_time_OBJECTS) $(test_sys_time_DEPENDENCIES) $(EXTRA_test_sys_time_DEPENDENCIES) + @rm -f test-sys_time$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_sys_time_OBJECTS) $(test_sys_time_LDADD) $(LIBS) + +test-sys_types$(EXEEXT): $(test_sys_types_OBJECTS) $(test_sys_types_DEPENDENCIES) $(EXTRA_test_sys_types_DEPENDENCIES) + @rm -f test-sys_types$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_sys_types_OBJECTS) $(test_sys_types_LDADD) $(LIBS) + +test-sys_uio$(EXEEXT): $(test_sys_uio_OBJECTS) $(test_sys_uio_DEPENDENCIES) $(EXTRA_test_sys_uio_DEPENDENCIES) + @rm -f test-sys_uio$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_sys_uio_OBJECTS) $(test_sys_uio_LDADD) $(LIBS) + +test-sys_utsname$(EXEEXT): $(test_sys_utsname_OBJECTS) $(test_sys_utsname_DEPENDENCIES) $(EXTRA_test_sys_utsname_DEPENDENCIES) + @rm -f test-sys_utsname$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_sys_utsname_OBJECTS) $(test_sys_utsname_LDADD) $(LIBS) + +test-sys_wait$(EXEEXT): $(test_sys_wait_OBJECTS) $(test_sys_wait_DEPENDENCIES) $(EXTRA_test_sys_wait_DEPENDENCIES) + @rm -f test-sys_wait$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_sys_wait_OBJECTS) $(test_sys_wait_LDADD) $(LIBS) + +test-termios$(EXEEXT): $(test_termios_OBJECTS) $(test_termios_DEPENDENCIES) $(EXTRA_test_termios_DEPENDENCIES) + @rm -f test-termios$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_termios_OBJECTS) $(test_termios_LDADD) $(LIBS) + +test-thread_create$(EXEEXT): $(test_thread_create_OBJECTS) $(test_thread_create_DEPENDENCIES) $(EXTRA_test_thread_create_DEPENDENCIES) + @rm -f test-thread_create$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_thread_create_OBJECTS) $(test_thread_create_LDADD) $(LIBS) + +test-thread_self$(EXEEXT): $(test_thread_self_OBJECTS) $(test_thread_self_DEPENDENCIES) $(EXTRA_test_thread_self_DEPENDENCIES) + @rm -f test-thread_self$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_thread_self_OBJECTS) $(test_thread_self_LDADD) $(LIBS) + +test-time$(EXEEXT): $(test_time_OBJECTS) $(test_time_DEPENDENCIES) $(EXTRA_test_time_DEPENDENCIES) + @rm -f test-time$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_time_OBJECTS) $(test_time_LDADD) $(LIBS) + +test-timespec$(EXEEXT): $(test_timespec_OBJECTS) $(test_timespec_DEPENDENCIES) $(EXTRA_test_timespec_DEPENDENCIES) + @rm -f test-timespec$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_timespec_OBJECTS) $(test_timespec_LDADD) $(LIBS) + +test-tls$(EXEEXT): $(test_tls_OBJECTS) $(test_tls_DEPENDENCIES) $(EXTRA_test_tls_DEPENDENCIES) + @rm -f test-tls$(EXEEXT) + $(AM_V_CCLD)$(test_tls_LINK) $(test_tls_OBJECTS) $(test_tls_LDADD) $(LIBS) + +test-u64$(EXEEXT): $(test_u64_OBJECTS) $(test_u64_DEPENDENCIES) $(EXTRA_test_u64_DEPENDENCIES) + @rm -f test-u64$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_u64_OBJECTS) $(test_u64_LDADD) $(LIBS) +unistr/$(am__dirstamp): + @$(MKDIR_P) unistr + @: > unistr/$(am__dirstamp) +unistr/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) unistr/$(DEPDIR) + @: > unistr/$(DEPDIR)/$(am__dirstamp) +unistr/test-u8-mbtoucr.$(OBJEXT): unistr/$(am__dirstamp) \ + unistr/$(DEPDIR)/$(am__dirstamp) + +test-u8-mbtoucr$(EXEEXT): $(test_u8_mbtoucr_OBJECTS) $(test_u8_mbtoucr_DEPENDENCIES) $(EXTRA_test_u8_mbtoucr_DEPENDENCIES) + @rm -f test-u8-mbtoucr$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_u8_mbtoucr_OBJECTS) $(test_u8_mbtoucr_LDADD) $(LIBS) +unistr/test-u8-uctomb.$(OBJEXT): unistr/$(am__dirstamp) \ + unistr/$(DEPDIR)/$(am__dirstamp) + +test-u8-uctomb$(EXEEXT): $(test_u8_uctomb_OBJECTS) $(test_u8_uctomb_DEPENDENCIES) $(EXTRA_test_u8_uctomb_DEPENDENCIES) + @rm -f test-u8-uctomb$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_u8_uctomb_OBJECTS) $(test_u8_uctomb_LDADD) $(LIBS) +uniwidth/$(am__dirstamp): + @$(MKDIR_P) uniwidth + @: > uniwidth/$(am__dirstamp) +uniwidth/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) uniwidth/$(DEPDIR) + @: > uniwidth/$(DEPDIR)/$(am__dirstamp) +uniwidth/test-uc_width.$(OBJEXT): uniwidth/$(am__dirstamp) \ + uniwidth/$(DEPDIR)/$(am__dirstamp) + +test-uc_width$(EXEEXT): $(test_uc_width_OBJECTS) $(test_uc_width_DEPENDENCIES) $(EXTRA_test_uc_width_DEPENDENCIES) + @rm -f test-uc_width$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_uc_width_OBJECTS) $(test_uc_width_LDADD) $(LIBS) +uniwidth/test-uc_width2.$(OBJEXT): uniwidth/$(am__dirstamp) \ + uniwidth/$(DEPDIR)/$(am__dirstamp) + +test-uc_width2$(EXEEXT): $(test_uc_width2_OBJECTS) $(test_uc_width2_DEPENDENCIES) $(EXTRA_test_uc_width2_DEPENDENCIES) + @rm -f test-uc_width2$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_uc_width2_OBJECTS) $(test_uc_width2_LDADD) $(LIBS) + +test-uname$(EXEEXT): $(test_uname_OBJECTS) $(test_uname_DEPENDENCIES) $(EXTRA_test_uname_DEPENDENCIES) + @rm -f test-uname$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_uname_OBJECTS) $(test_uname_LDADD) $(LIBS) + +test-unistd$(EXEEXT): $(test_unistd_OBJECTS) $(test_unistd_DEPENDENCIES) $(EXTRA_test_unistd_DEPENDENCIES) + @rm -f test-unistd$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_unistd_OBJECTS) $(test_unistd_LDADD) $(LIBS) + +test-unlink$(EXEEXT): $(test_unlink_OBJECTS) $(test_unlink_DEPENDENCIES) $(EXTRA_test_unlink_DEPENDENCIES) + @rm -f test-unlink$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_unlink_OBJECTS) $(test_unlink_LDADD) $(LIBS) + +test-unlinkat$(EXEEXT): $(test_unlinkat_OBJECTS) $(test_unlinkat_DEPENDENCIES) $(EXTRA_test_unlinkat_DEPENDENCIES) + @rm -f test-unlinkat$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_unlinkat_OBJECTS) $(test_unlinkat_LDADD) $(LIBS) + +test-unsetenv$(EXEEXT): $(test_unsetenv_OBJECTS) $(test_unsetenv_DEPENDENCIES) $(EXTRA_test_unsetenv_DEPENDENCIES) + @rm -f test-unsetenv$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_unsetenv_OBJECTS) $(test_unsetenv_LDADD) $(LIBS) + +test-userspec$(EXEEXT): $(test_userspec_OBJECTS) $(test_userspec_DEPENDENCIES) $(EXTRA_test_userspec_DEPENDENCIES) + @rm -f test-userspec$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_userspec_OBJECTS) $(test_userspec_LDADD) $(LIBS) + +test-usleep$(EXEEXT): $(test_usleep_OBJECTS) $(test_usleep_DEPENDENCIES) $(EXTRA_test_usleep_DEPENDENCIES) + @rm -f test-usleep$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_usleep_OBJECTS) $(test_usleep_LDADD) $(LIBS) + +test-utime$(EXEEXT): $(test_utime_OBJECTS) $(test_utime_DEPENDENCIES) $(EXTRA_test_utime_DEPENDENCIES) + @rm -f test-utime$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_utime_OBJECTS) $(test_utime_LDADD) $(LIBS) + +test-utime-h$(EXEEXT): $(test_utime_h_OBJECTS) $(test_utime_h_DEPENDENCIES) $(EXTRA_test_utime_h_DEPENDENCIES) + @rm -f test-utime-h$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_utime_h_OBJECTS) $(test_utime_h_LDADD) $(LIBS) + +test-utimens$(EXEEXT): $(test_utimens_OBJECTS) $(test_utimens_DEPENDENCIES) $(EXTRA_test_utimens_DEPENDENCIES) + @rm -f test-utimens$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_utimens_OBJECTS) $(test_utimens_LDADD) $(LIBS) + +test-utimensat$(EXEEXT): $(test_utimensat_OBJECTS) $(test_utimensat_DEPENDENCIES) $(EXTRA_test_utimensat_DEPENDENCIES) + @rm -f test-utimensat$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_utimensat_OBJECTS) $(test_utimensat_LDADD) $(LIBS) + +test-vasnprintf$(EXEEXT): $(test_vasnprintf_OBJECTS) $(test_vasnprintf_DEPENDENCIES) $(EXTRA_test_vasnprintf_DEPENDENCIES) + @rm -f test-vasnprintf$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_vasnprintf_OBJECTS) $(test_vasnprintf_LDADD) $(LIBS) + +test-vasprintf$(EXEEXT): $(test_vasprintf_OBJECTS) $(test_vasprintf_DEPENDENCIES) $(EXTRA_test_vasprintf_DEPENDENCIES) + @rm -f test-vasprintf$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_vasprintf_OBJECTS) $(test_vasprintf_LDADD) $(LIBS) + +test-vasprintf-posix$(EXEEXT): $(test_vasprintf_posix_OBJECTS) $(test_vasprintf_posix_DEPENDENCIES) $(EXTRA_test_vasprintf_posix_DEPENDENCIES) + @rm -f test-vasprintf-posix$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_vasprintf_posix_OBJECTS) $(test_vasprintf_posix_LDADD) $(LIBS) + +test-verify$(EXEEXT): $(test_verify_OBJECTS) $(test_verify_DEPENDENCIES) $(EXTRA_test_verify_DEPENDENCIES) + @rm -f test-verify$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_verify_OBJECTS) $(test_verify_LDADD) $(LIBS) + +test-verify-try$(EXEEXT): $(test_verify_try_OBJECTS) $(test_verify_try_DEPENDENCIES) $(EXTRA_test_verify_try_DEPENDENCIES) + @rm -f test-verify-try$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_verify_try_OBJECTS) $(test_verify_try_LDADD) $(LIBS) + +test-version-etc$(EXEEXT): $(test_version_etc_OBJECTS) $(test_version_etc_DEPENDENCIES) $(EXTRA_test_version_etc_DEPENDENCIES) + @rm -f test-version-etc$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_version_etc_OBJECTS) $(test_version_etc_LDADD) $(LIBS) + +test-vfprintf-posix$(EXEEXT): $(test_vfprintf_posix_OBJECTS) $(test_vfprintf_posix_DEPENDENCIES) $(EXTRA_test_vfprintf_posix_DEPENDENCIES) + @rm -f test-vfprintf-posix$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_vfprintf_posix_OBJECTS) $(test_vfprintf_posix_LDADD) $(LIBS) + +test-vprintf-posix$(EXEEXT): $(test_vprintf_posix_OBJECTS) $(test_vprintf_posix_DEPENDENCIES) $(EXTRA_test_vprintf_posix_DEPENDENCIES) + @rm -f test-vprintf-posix$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_vprintf_posix_OBJECTS) $(test_vprintf_posix_LDADD) $(LIBS) + +test-wchar$(EXEEXT): $(test_wchar_OBJECTS) $(test_wchar_DEPENDENCIES) $(EXTRA_test_wchar_DEPENDENCIES) + @rm -f test-wchar$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_wchar_OBJECTS) $(test_wchar_LDADD) $(LIBS) + +test-wcrtomb$(EXEEXT): $(test_wcrtomb_OBJECTS) $(test_wcrtomb_DEPENDENCIES) $(EXTRA_test_wcrtomb_DEPENDENCIES) + @rm -f test-wcrtomb$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_wcrtomb_OBJECTS) $(test_wcrtomb_LDADD) $(LIBS) + +test-wcrtomb-w32$(EXEEXT): $(test_wcrtomb_w32_OBJECTS) $(test_wcrtomb_w32_DEPENDENCIES) $(EXTRA_test_wcrtomb_w32_DEPENDENCIES) + @rm -f test-wcrtomb-w32$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_wcrtomb_w32_OBJECTS) $(test_wcrtomb_w32_LDADD) $(LIBS) + +test-wctype-h$(EXEEXT): $(test_wctype_h_OBJECTS) $(test_wctype_h_DEPENDENCIES) $(EXTRA_test_wctype_h_DEPENDENCIES) + @rm -f test-wctype-h$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_wctype_h_OBJECTS) $(test_wctype_h_LDADD) $(LIBS) + +test-wcwidth$(EXEEXT): $(test_wcwidth_OBJECTS) $(test_wcwidth_DEPENDENCIES) $(EXTRA_test_wcwidth_DEPENDENCIES) + @rm -f test-wcwidth$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_wcwidth_OBJECTS) $(test_wcwidth_LDADD) $(LIBS) + +test-write$(EXEEXT): $(test_write_OBJECTS) $(test_write_DEPENDENCIES) $(EXTRA_test_write_DEPENDENCIES) + @rm -f test-write$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_write_OBJECTS) $(test_write_LDADD) $(LIBS) + +test-xalloc-die$(EXEEXT): $(test_xalloc_die_OBJECTS) $(test_xalloc_die_DEPENDENCIES) $(EXTRA_test_xalloc_die_DEPENDENCIES) + @rm -f test-xalloc-die$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_xalloc_die_OBJECTS) $(test_xalloc_die_LDADD) $(LIBS) + +test-xfprintf-posix$(EXEEXT): $(test_xfprintf_posix_OBJECTS) $(test_xfprintf_posix_DEPENDENCIES) $(EXTRA_test_xfprintf_posix_DEPENDENCIES) + @rm -f test-xfprintf-posix$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_xfprintf_posix_OBJECTS) $(test_xfprintf_posix_LDADD) $(LIBS) + +test-xprintf-posix$(EXEEXT): $(test_xprintf_posix_OBJECTS) $(test_xprintf_posix_DEPENDENCIES) $(EXTRA_test_xprintf_posix_DEPENDENCIES) + @rm -f test-xprintf-posix$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_xprintf_posix_OBJECTS) $(test_xprintf_posix_LDADD) $(LIBS) + +test-xstrtoimax$(EXEEXT): $(test_xstrtoimax_OBJECTS) $(test_xstrtoimax_DEPENDENCIES) $(EXTRA_test_xstrtoimax_DEPENDENCIES) + @rm -f test-xstrtoimax$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_xstrtoimax_OBJECTS) $(test_xstrtoimax_LDADD) $(LIBS) + +test-xstrtol$(EXEEXT): $(test_xstrtol_OBJECTS) $(test_xstrtol_DEPENDENCIES) $(EXTRA_test_xstrtol_DEPENDENCIES) + @rm -f test-xstrtol$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_xstrtol_OBJECTS) $(test_xstrtol_LDADD) $(LIBS) + +test-xstrtoul$(EXEEXT): $(test_xstrtoul_OBJECTS) $(test_xstrtoul_DEPENDENCIES) $(EXTRA_test_xstrtoul_DEPENDENCIES) + @rm -f test-xstrtoul$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_xstrtoul_OBJECTS) $(test_xstrtoul_LDADD) $(LIBS) + +test-xstrtoumax$(EXEEXT): $(test_xstrtoumax_OBJECTS) $(test_xstrtoumax_DEPENDENCIES) $(EXTRA_test_xstrtoumax_DEPENDENCIES) + @rm -f test-xstrtoumax$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_xstrtoumax_OBJECTS) $(test_xstrtoumax_LDADD) $(LIBS) + +test-xvasprintf$(EXEEXT): $(test_xvasprintf_OBJECTS) $(test_xvasprintf_DEPENDENCIES) $(EXTRA_test_xvasprintf_DEPENDENCIES) + @rm -f test-xvasprintf$(EXEEXT) + $(AM_V_CCLD)$(test_xvasprintf_LINK) $(test_xvasprintf_OBJECTS) $(test_xvasprintf_LDADD) $(LIBS) + +test-yesno$(EXEEXT): $(test_yesno_OBJECTS) $(test_yesno_DEPENDENCIES) $(EXTRA_test_yesno_DEPENDENCIES) + @rm -f test-yesno$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_yesno_OBJECTS) $(test_yesno_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + -rm -f glthread/*.$(OBJEXT) + -rm -f unistr/*.$(OBJEXT) + -rm -f uniwidth/*.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/accept.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bench-md5.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bench-sha1.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bench-sha224.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bench-sha256.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bench-sha384.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bench-sha512.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bind.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/connect.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getrusage.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inet_pton.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ioctl.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/listen.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/locale.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/localename-table.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/localename.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/perror.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/randomd.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/randoml.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sched_yield.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/secure_getenv.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/setlocale.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/setsockopt.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sleep.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/socket.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strerror_r.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-accept.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-alignof.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-alloca-opt.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-areadlink-with-size.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-areadlink.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-areadlinkat.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-argmatch.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-argv-iter.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-arpa_inet.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-base32.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-base64.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-binary-io.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-bind.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-bitrotate.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-btowc.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-byteswap.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-c-ctype.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-c-strcasecmp.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-c-strncasecmp.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-calloc-gnu.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-canonicalize.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-chdir.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-chown.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-cloexec.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-close.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-closein.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-connect.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-copy-acl.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-count-leading-zeros.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ctype.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-di-set.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-dirent-safer.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-dirent.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-dirname.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-dup-safer.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-dup.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-dup2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-environ.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-errno.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-exclude.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-faccessat.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fadvise.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fchdir.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fchmodat.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fchownat.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fclose.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fcntl-h.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fcntl-safer.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fcntl.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fdatasync.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fdopen.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fdopendir.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fdutimensat.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fflush.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fflush2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fgetc.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-file-has-acl.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-filenamecat.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-filevercmp.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-float.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fnmatch-h.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fnmatch.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fopen-safer.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fopen.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fpending.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fpurge.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fputc.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fread.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-freadahead.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-freading.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-freadptr.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-freadptr2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-freadseek.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-freopen-safer.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-freopen.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-frexp.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-frexpl.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fseek.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fseeko.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fseeko3.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fseeko4.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fseterr.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fstat.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fstatat.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fsync.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ftell.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ftell3.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ftello.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ftello3.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ftello4.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ftruncate.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-futimens.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fwrite.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-getaddrinfo.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-getcwd-lgpl.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-getcwd.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-getdelim.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-getdtablesize.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-getgroups.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-gethostname.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-getline.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-getloadavg.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-getlogin.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-getndelim2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-getopt-gnu.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-getopt-posix.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-getprogname.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-getrusage.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-gettimeofday.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-hard-locale.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-hash.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-i-ring.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-iconv-h.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-iconv.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ignore-value.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-inet_ntop.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-inet_pton.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ino-map.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-intprops.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-inttostr.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-inttypes.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ioctl.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-isatty.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-isblank.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-isnand-nolibm.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-isnanf-nolibm.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-isnanl-nolibm.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-iswblank.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-iswdigit.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-iswxdigit.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-langinfo.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-lchmod.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-lchown.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-limits-h.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-link.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-linkat.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-listen.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-localcharset.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-locale.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-localeconv.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-localename.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-lseek.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-lstat.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-malloc-gnu.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-malloca.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-math.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-mbrtowc-w32.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-mbrtowc.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-mbsalign.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-mbscasecmp.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-mbschr.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-mbsinit.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-mbsrtowcs.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-mbsstr1.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-mbsstr2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-mbsstr3.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-md5.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-memcasecmp.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-memchr.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-memchr2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-memcoll.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-memrchr.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-mkdir.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-mkfifo.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-mknod.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-nanosleep.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-netdb.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-netinet_in.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-nl_langinfo-mt.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-nl_langinfo.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-nstrftime.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-once.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-open.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-openat-safer.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-openat.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-parse-datetime.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-pathmax.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-perror.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-perror2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-pipe.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-pipe2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-posixtm.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-printf-frexp.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-printf-frexpl.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-priv-set.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-pthread-cond.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-pthread-mutex.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-pthread-thread.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-pthread.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-pthread_sigmask1.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-pthread_sigmask2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-quotearg-simple.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-raise.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-rand-isaac.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-read-file.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-read.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-readlink.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-readlinkat.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-readtokens.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-realloc-gnu.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-regex.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-remove.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-rename.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-renameat.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-renameatu.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-rmdir.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-rwlock1.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-sameacls.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-sched.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-select-fd.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-select-stdin.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-select.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-set-mode-acl.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-setenv.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-setlocale1.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-setlocale2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-setlocale_null-mt-all.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-setlocale_null-mt-one.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-setlocale_null.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-setsockopt.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-sha1.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-sha256.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-sha512.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-sigaction.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-signal-h.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-signbit.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-sigprocmask.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-sleep.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-snprintf.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-sockets.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-stat-time.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-stat.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-statat.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-stdalign.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-stdbool.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-stddef.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-stdint.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-stdio.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-stdlib.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-strerror.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-strerror_r.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-striconv.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-string.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-strncat.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-strnlen.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-strsignal.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-strtod.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-strtod1.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-strtoimax.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-strtold.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-strtold1.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-strtoll.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-strtoull.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-strtoumax.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-symlink.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-symlinkat.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-sys_ioctl.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-sys_resource.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-sys_select.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-sys_socket.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-sys_stat.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-sys_time.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-sys_types.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-sys_uio.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-sys_utsname.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-sys_wait.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-termios.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-thread_create.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-thread_self.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-time.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-timespec.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-u64.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-uname.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-unistd.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-unlink.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-unlinkat.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-unsetenv.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-userspec.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-usleep.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-utime-h.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-utime.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-utimens.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-utimensat.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-vasnprintf.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-vasprintf-posix.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-vasprintf.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-verify-try.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-verify.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-version-etc.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-vfprintf-posix.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-vprintf-posix.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-wchar.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-wcrtomb-w32.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-wcrtomb.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-wctype-h.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-wcwidth.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-write.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-xalloc-die.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-xfprintf-posix.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-xprintf-posix.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-xstrtoimax.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-xstrtol.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-xstrtoul.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-xstrtoumax.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-yesno.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_lock-test-lock.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_tls-test-tls.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_xvasprintf-test-xvasprintf.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timespec-add.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timespec-sub.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tmpdir.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tmpfile.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/usleep.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wctob.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wctomb.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@glthread/$(DEPDIR)/thread.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@unistr/$(DEPDIR)/test-u8-mbtoucr.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@unistr/$(DEPDIR)/test-u8-uctomb.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@uniwidth/$(DEPDIR)/test-uc_width.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@uniwidth/$(DEPDIR)/test-uc_width2.Po@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +test_lock-test-lock.o: test-lock.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_lock_CFLAGS) $(CFLAGS) -MT test_lock-test-lock.o -MD -MP -MF $(DEPDIR)/test_lock-test-lock.Tpo -c -o test_lock-test-lock.o `test -f 'test-lock.c' || echo '$(srcdir)/'`test-lock.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_lock-test-lock.Tpo $(DEPDIR)/test_lock-test-lock.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-lock.c' object='test_lock-test-lock.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_lock_CFLAGS) $(CFLAGS) -c -o test_lock-test-lock.o `test -f 'test-lock.c' || echo '$(srcdir)/'`test-lock.c + +test_lock-test-lock.obj: test-lock.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_lock_CFLAGS) $(CFLAGS) -MT test_lock-test-lock.obj -MD -MP -MF $(DEPDIR)/test_lock-test-lock.Tpo -c -o test_lock-test-lock.obj `if test -f 'test-lock.c'; then $(CYGPATH_W) 'test-lock.c'; else $(CYGPATH_W) '$(srcdir)/test-lock.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_lock-test-lock.Tpo $(DEPDIR)/test_lock-test-lock.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-lock.c' object='test_lock-test-lock.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_lock_CFLAGS) $(CFLAGS) -c -o test_lock-test-lock.obj `if test -f 'test-lock.c'; then $(CYGPATH_W) 'test-lock.c'; else $(CYGPATH_W) '$(srcdir)/test-lock.c'; fi` + +test_tls-test-tls.o: test-tls.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_tls_CFLAGS) $(CFLAGS) -MT test_tls-test-tls.o -MD -MP -MF $(DEPDIR)/test_tls-test-tls.Tpo -c -o test_tls-test-tls.o `test -f 'test-tls.c' || echo '$(srcdir)/'`test-tls.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_tls-test-tls.Tpo $(DEPDIR)/test_tls-test-tls.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-tls.c' object='test_tls-test-tls.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_tls_CFLAGS) $(CFLAGS) -c -o test_tls-test-tls.o `test -f 'test-tls.c' || echo '$(srcdir)/'`test-tls.c + +test_tls-test-tls.obj: test-tls.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_tls_CFLAGS) $(CFLAGS) -MT test_tls-test-tls.obj -MD -MP -MF $(DEPDIR)/test_tls-test-tls.Tpo -c -o test_tls-test-tls.obj `if test -f 'test-tls.c'; then $(CYGPATH_W) 'test-tls.c'; else $(CYGPATH_W) '$(srcdir)/test-tls.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_tls-test-tls.Tpo $(DEPDIR)/test_tls-test-tls.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-tls.c' object='test_tls-test-tls.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_tls_CFLAGS) $(CFLAGS) -c -o test_tls-test-tls.obj `if test -f 'test-tls.c'; then $(CYGPATH_W) 'test-tls.c'; else $(CYGPATH_W) '$(srcdir)/test-tls.c'; fi` + +test_xvasprintf-test-xvasprintf.o: test-xvasprintf.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_xvasprintf_CFLAGS) $(CFLAGS) -MT test_xvasprintf-test-xvasprintf.o -MD -MP -MF $(DEPDIR)/test_xvasprintf-test-xvasprintf.Tpo -c -o test_xvasprintf-test-xvasprintf.o `test -f 'test-xvasprintf.c' || echo '$(srcdir)/'`test-xvasprintf.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_xvasprintf-test-xvasprintf.Tpo $(DEPDIR)/test_xvasprintf-test-xvasprintf.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-xvasprintf.c' object='test_xvasprintf-test-xvasprintf.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_xvasprintf_CFLAGS) $(CFLAGS) -c -o test_xvasprintf-test-xvasprintf.o `test -f 'test-xvasprintf.c' || echo '$(srcdir)/'`test-xvasprintf.c + +test_xvasprintf-test-xvasprintf.obj: test-xvasprintf.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_xvasprintf_CFLAGS) $(CFLAGS) -MT test_xvasprintf-test-xvasprintf.obj -MD -MP -MF $(DEPDIR)/test_xvasprintf-test-xvasprintf.Tpo -c -o test_xvasprintf-test-xvasprintf.obj `if test -f 'test-xvasprintf.c'; then $(CYGPATH_W) 'test-xvasprintf.c'; else $(CYGPATH_W) '$(srcdir)/test-xvasprintf.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_xvasprintf-test-xvasprintf.Tpo $(DEPDIR)/test_xvasprintf-test-xvasprintf.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-xvasprintf.c' object='test_xvasprintf-test-xvasprintf.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_xvasprintf_CFLAGS) $(CFLAGS) -c -o test_xvasprintf-test-xvasprintf.obj `if test -f 'test-xvasprintf.c'; then $(CYGPATH_W) 'test-xvasprintf.c'; else $(CYGPATH_W) '$(srcdir)/test-xvasprintf.c'; fi` +install-man1: $(man1_MANS) + @$(NORMAL_INSTALL) + @list1='$(man1_MANS)'; \ + list2=''; \ + test -n "$(man1dir)" \ + && test -n "`echo $$list1$$list2`" \ + || exit 0; \ + echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \ + { for i in $$list1; do echo "$$i"; done; \ + if test -n "$$list2"; then \ + for i in $$list2; do echo "$$i"; done \ + | sed -n '/\.1[a-z]*$$/p'; \ + fi; \ + } | while read p; do \ + if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; echo "$$p"; \ + done | \ + sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ + sed 'N;N;s,\n, ,g' | { \ + list=; while read file base inst; do \ + if test "$$base" = "$$inst"; then list="$$list $$file"; else \ + echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ + fi; \ + done; \ + for i in $$list; do echo "$$i"; done | $(am__base_list) | \ + while read files; do \ + test -z "$$files" || { \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ + done; } + +uninstall-man1: + @$(NORMAL_UNINSTALL) + @list='$(man1_MANS)'; test -n "$(man1dir)" || exit 0; \ + files=`{ for i in $$list; do echo "$$i"; done; \ + } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ + dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir) + +# This directory's subdirectories are mostly independent; you can cd +# into them and run 'make' without going through this Makefile. +# To change the values of 'make' variables: instead of editing Makefiles, +# (1) if the variable is set in 'config.status', edit 'config.status' +# (which will cause the Makefiles to be regenerated when you run 'make'); +# (2) otherwise, pass the desired values on the 'make' command line. +$(am__recursive_targets): + @fail=; \ + if $(am__make_keepgoing); then \ + failcom='fail=yes'; \ + else \ + failcom='exit 1'; \ + fi; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-recursive +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-recursive + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-recursive + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +# Recover from deleted '.trs' file; this should ensure that +# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create +# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells +# to avoid problems with "make -n". +.log.trs: + rm -f $< $@ + $(MAKE) $(AM_MAKEFLAGS) $< + +# Leading 'am--fnord' is there to ensure the list of targets does not +# expand to empty, as could happen e.g. with make check TESTS=''. +am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) +am--force-recheck: + @: + +$(TEST_SUITE_LOG): $(TEST_LOGS) + @$(am__set_TESTS_bases); \ + am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ + redo_bases=`for i in $$bases; do \ + am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ + done`; \ + if test -n "$$redo_bases"; then \ + redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ + redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ + if $(am__make_dryrun); then :; else \ + rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ + fi; \ + fi; \ + if test -n "$$am__remaking_logs"; then \ + echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ + "recursion detected" >&2; \ + elif test -n "$$redo_logs"; then \ + am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ + fi; \ + if $(am__make_dryrun); then :; else \ + st=0; \ + errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ + for i in $$redo_bases; do \ + test -f $$i.trs && test -r $$i.trs \ + || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ + test -f $$i.log && test -r $$i.log \ + || { echo "$$errmsg $$i.log" >&2; st=1; }; \ + done; \ + test $$st -eq 0 || exit 1; \ + fi + @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ + ws='[ ]'; \ + results=`for b in $$bases; do echo $$b.trs; done`; \ + test -n "$$results" || results=/dev/null; \ + all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ + pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ + fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ + skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ + xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ + xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ + error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ + if test `expr $$fail + $$xpass + $$error` -eq 0; then \ + success=true; \ + else \ + success=false; \ + fi; \ + br='==================='; br=$$br$$br$$br$$br; \ + result_count () \ + { \ + if test x"$$1" = x"--maybe-color"; then \ + maybe_colorize=yes; \ + elif test x"$$1" = x"--no-color"; then \ + maybe_colorize=no; \ + else \ + echo "$@: invalid 'result_count' usage" >&2; exit 4; \ + fi; \ + shift; \ + desc=$$1 count=$$2; \ + if test $$maybe_colorize = yes && test $$count -gt 0; then \ + color_start=$$3 color_end=$$std; \ + else \ + color_start= color_end=; \ + fi; \ + echo "$${color_start}# $$desc $$count$${color_end}"; \ + }; \ + create_testsuite_report () \ + { \ + result_count $$1 "TOTAL:" $$all "$$brg"; \ + result_count $$1 "PASS: " $$pass "$$grn"; \ + result_count $$1 "SKIP: " $$skip "$$blu"; \ + result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ + result_count $$1 "FAIL: " $$fail "$$red"; \ + result_count $$1 "XPASS:" $$xpass "$$red"; \ + result_count $$1 "ERROR:" $$error "$$mgn"; \ + }; \ + { \ + echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ + $(am__rst_title); \ + create_testsuite_report --no-color; \ + echo; \ + echo ".. contents:: :depth: 2"; \ + echo; \ + for b in $$bases; do echo $$b; done \ + | $(am__create_global_log); \ + } >$(TEST_SUITE_LOG).tmp || exit 1; \ + mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ + if $$success; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ + fi; \ + echo "$${col}$$br$${std}"; \ + echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ + echo "$${col}$$br$${std}"; \ + create_testsuite_report --maybe-color; \ + echo "$$col$$br$$std"; \ + if $$success; then :; else \ + echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ + if test -n "$(PACKAGE_BUGREPORT)"; then \ + echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ + fi; \ + echo "$$col$$br$$std"; \ + fi; \ + $$success || exit 1 + +check-TESTS: $(check_PROGRAMS) $(check_LIBRARIES) + @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list + @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + trs_list=`for i in $$bases; do echo $$i.trs; done`; \ + log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ + exit $$?; +recheck: all $(check_PROGRAMS) $(check_LIBRARIES) + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + bases=`for i in $$bases; do echo $$i; done \ + | $(am__list_recheck_tests)` || exit 1; \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + log_list=`echo $$log_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ + am__force_recheck=am--force-recheck \ + TEST_LOGS="$$log_list"; \ + exit $$? +test-accept.log: test-accept$(EXEEXT) + @p='test-accept$(EXEEXT)'; \ + b='test-accept'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-set-mode-acl.sh.log: test-set-mode-acl.sh + @p='test-set-mode-acl.sh'; \ + b='test-set-mode-acl.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-set-mode-acl-1.sh.log: test-set-mode-acl-1.sh + @p='test-set-mode-acl-1.sh'; \ + b='test-set-mode-acl-1.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-set-mode-acl-2.sh.log: test-set-mode-acl-2.sh + @p='test-set-mode-acl-2.sh'; \ + b='test-set-mode-acl-2.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-copy-acl.sh.log: test-copy-acl.sh + @p='test-copy-acl.sh'; \ + b='test-copy-acl.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-copy-acl-1.sh.log: test-copy-acl-1.sh + @p='test-copy-acl-1.sh'; \ + b='test-copy-acl-1.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-copy-acl-2.sh.log: test-copy-acl-2.sh + @p='test-copy-acl-2.sh'; \ + b='test-copy-acl-2.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-alignof.log: test-alignof$(EXEEXT) + @p='test-alignof$(EXEEXT)'; \ + b='test-alignof'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-alloca-opt.log: test-alloca-opt$(EXEEXT) + @p='test-alloca-opt$(EXEEXT)'; \ + b='test-alloca-opt'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-areadlink.log: test-areadlink$(EXEEXT) + @p='test-areadlink$(EXEEXT)'; \ + b='test-areadlink'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-areadlink-with-size.log: test-areadlink-with-size$(EXEEXT) + @p='test-areadlink-with-size$(EXEEXT)'; \ + b='test-areadlink-with-size'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-areadlinkat.log: test-areadlinkat$(EXEEXT) + @p='test-areadlinkat$(EXEEXT)'; \ + b='test-areadlinkat'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-argmatch.log: test-argmatch$(EXEEXT) + @p='test-argmatch$(EXEEXT)'; \ + b='test-argmatch'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-argv-iter.log: test-argv-iter$(EXEEXT) + @p='test-argv-iter$(EXEEXT)'; \ + b='test-argv-iter'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-arpa_inet.log: test-arpa_inet$(EXEEXT) + @p='test-arpa_inet$(EXEEXT)'; \ + b='test-arpa_inet'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-base32.log: test-base32$(EXEEXT) + @p='test-base32$(EXEEXT)'; \ + b='test-base32'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-base64.log: test-base64$(EXEEXT) + @p='test-base64$(EXEEXT)'; \ + b='test-base64'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-binary-io.sh.log: test-binary-io.sh + @p='test-binary-io.sh'; \ + b='test-binary-io.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-bind.log: test-bind$(EXEEXT) + @p='test-bind$(EXEEXT)'; \ + b='test-bind'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-bitrotate.log: test-bitrotate$(EXEEXT) + @p='test-bitrotate$(EXEEXT)'; \ + b='test-bitrotate'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-btowc1.sh.log: test-btowc1.sh + @p='test-btowc1.sh'; \ + b='test-btowc1.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-btowc2.sh.log: test-btowc2.sh + @p='test-btowc2.sh'; \ + b='test-btowc2.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-byteswap.log: test-byteswap$(EXEEXT) + @p='test-byteswap$(EXEEXT)'; \ + b='test-byteswap'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-c-ctype.log: test-c-ctype$(EXEEXT) + @p='test-c-ctype$(EXEEXT)'; \ + b='test-c-ctype'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-c-strcase.sh.log: test-c-strcase.sh + @p='test-c-strcase.sh'; \ + b='test-c-strcase.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-calloc-gnu.log: test-calloc-gnu$(EXEEXT) + @p='test-calloc-gnu$(EXEEXT)'; \ + b='test-calloc-gnu'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-canonicalize.log: test-canonicalize$(EXEEXT) + @p='test-canonicalize$(EXEEXT)'; \ + b='test-canonicalize'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-chdir.log: test-chdir$(EXEEXT) + @p='test-chdir$(EXEEXT)'; \ + b='test-chdir'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-chown.log: test-chown$(EXEEXT) + @p='test-chown$(EXEEXT)'; \ + b='test-chown'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-cloexec.log: test-cloexec$(EXEEXT) + @p='test-cloexec$(EXEEXT)'; \ + b='test-cloexec'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-close.log: test-close$(EXEEXT) + @p='test-close$(EXEEXT)'; \ + b='test-close'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-closein.sh.log: test-closein.sh + @p='test-closein.sh'; \ + b='test-closein.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-connect.log: test-connect$(EXEEXT) + @p='test-connect$(EXEEXT)'; \ + b='test-connect'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-count-leading-zeros.log: test-count-leading-zeros$(EXEEXT) + @p='test-count-leading-zeros$(EXEEXT)'; \ + b='test-count-leading-zeros'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-md5.log: test-md5$(EXEEXT) + @p='test-md5$(EXEEXT)'; \ + b='test-md5'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-sha1.log: test-sha1$(EXEEXT) + @p='test-sha1$(EXEEXT)'; \ + b='test-sha1'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-sha256.log: test-sha256$(EXEEXT) + @p='test-sha256$(EXEEXT)'; \ + b='test-sha256'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-sha512.log: test-sha512$(EXEEXT) + @p='test-sha512$(EXEEXT)'; \ + b='test-sha512'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-ctype.log: test-ctype$(EXEEXT) + @p='test-ctype$(EXEEXT)'; \ + b='test-ctype'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-di-set.log: test-di-set$(EXEEXT) + @p='test-di-set$(EXEEXT)'; \ + b='test-di-set'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-dirent-safer.log: test-dirent-safer$(EXEEXT) + @p='test-dirent-safer$(EXEEXT)'; \ + b='test-dirent-safer'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-dirent.log: test-dirent$(EXEEXT) + @p='test-dirent$(EXEEXT)'; \ + b='test-dirent'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-dirname.log: test-dirname$(EXEEXT) + @p='test-dirname$(EXEEXT)'; \ + b='test-dirname'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-dup.log: test-dup$(EXEEXT) + @p='test-dup$(EXEEXT)'; \ + b='test-dup'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-dup2.log: test-dup2$(EXEEXT) + @p='test-dup2$(EXEEXT)'; \ + b='test-dup2'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-environ.log: test-environ$(EXEEXT) + @p='test-environ$(EXEEXT)'; \ + b='test-environ'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-errno.log: test-errno$(EXEEXT) + @p='test-errno$(EXEEXT)'; \ + b='test-errno'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-exclude1.sh.log: test-exclude1.sh + @p='test-exclude1.sh'; \ + b='test-exclude1.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-exclude2.sh.log: test-exclude2.sh + @p='test-exclude2.sh'; \ + b='test-exclude2.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-exclude3.sh.log: test-exclude3.sh + @p='test-exclude3.sh'; \ + b='test-exclude3.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-exclude4.sh.log: test-exclude4.sh + @p='test-exclude4.sh'; \ + b='test-exclude4.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-exclude5.sh.log: test-exclude5.sh + @p='test-exclude5.sh'; \ + b='test-exclude5.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-exclude6.sh.log: test-exclude6.sh + @p='test-exclude6.sh'; \ + b='test-exclude6.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-exclude7.sh.log: test-exclude7.sh + @p='test-exclude7.sh'; \ + b='test-exclude7.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-exclude8.sh.log: test-exclude8.sh + @p='test-exclude8.sh'; \ + b='test-exclude8.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-faccessat.log: test-faccessat$(EXEEXT) + @p='test-faccessat$(EXEEXT)'; \ + b='test-faccessat'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fadvise.log: test-fadvise$(EXEEXT) + @p='test-fadvise$(EXEEXT)'; \ + b='test-fadvise'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fchdir.log: test-fchdir$(EXEEXT) + @p='test-fchdir$(EXEEXT)'; \ + b='test-fchdir'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fchmodat.log: test-fchmodat$(EXEEXT) + @p='test-fchmodat$(EXEEXT)'; \ + b='test-fchmodat'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fchownat.log: test-fchownat$(EXEEXT) + @p='test-fchownat$(EXEEXT)'; \ + b='test-fchownat'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fclose.log: test-fclose$(EXEEXT) + @p='test-fclose$(EXEEXT)'; \ + b='test-fclose'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fcntl-h.log: test-fcntl-h$(EXEEXT) + @p='test-fcntl-h$(EXEEXT)'; \ + b='test-fcntl-h'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fcntl-safer.log: test-fcntl-safer$(EXEEXT) + @p='test-fcntl-safer$(EXEEXT)'; \ + b='test-fcntl-safer'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fcntl.log: test-fcntl$(EXEEXT) + @p='test-fcntl$(EXEEXT)'; \ + b='test-fcntl'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fdatasync.log: test-fdatasync$(EXEEXT) + @p='test-fdatasync$(EXEEXT)'; \ + b='test-fdatasync'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fdopen.log: test-fdopen$(EXEEXT) + @p='test-fdopen$(EXEEXT)'; \ + b='test-fdopen'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fdopendir.log: test-fdopendir$(EXEEXT) + @p='test-fdopendir$(EXEEXT)'; \ + b='test-fdopendir'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fdutimensat.log: test-fdutimensat$(EXEEXT) + @p='test-fdutimensat$(EXEEXT)'; \ + b='test-fdutimensat'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fflush.log: test-fflush$(EXEEXT) + @p='test-fflush$(EXEEXT)'; \ + b='test-fflush'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fflush2.sh.log: test-fflush2.sh + @p='test-fflush2.sh'; \ + b='test-fflush2.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fgetc.log: test-fgetc$(EXEEXT) + @p='test-fgetc$(EXEEXT)'; \ + b='test-fgetc'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-file-has-acl.sh.log: test-file-has-acl.sh + @p='test-file-has-acl.sh'; \ + b='test-file-has-acl.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-file-has-acl-1.sh.log: test-file-has-acl-1.sh + @p='test-file-has-acl-1.sh'; \ + b='test-file-has-acl-1.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-file-has-acl-2.sh.log: test-file-has-acl-2.sh + @p='test-file-has-acl-2.sh'; \ + b='test-file-has-acl-2.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-filenamecat.log: test-filenamecat$(EXEEXT) + @p='test-filenamecat$(EXEEXT)'; \ + b='test-filenamecat'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-filevercmp.log: test-filevercmp$(EXEEXT) + @p='test-filevercmp$(EXEEXT)'; \ + b='test-filevercmp'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-float.log: test-float$(EXEEXT) + @p='test-float$(EXEEXT)'; \ + b='test-float'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fnmatch-h.log: test-fnmatch-h$(EXEEXT) + @p='test-fnmatch-h$(EXEEXT)'; \ + b='test-fnmatch-h'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fnmatch.log: test-fnmatch$(EXEEXT) + @p='test-fnmatch$(EXEEXT)'; \ + b='test-fnmatch'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fopen-safer.log: test-fopen-safer$(EXEEXT) + @p='test-fopen-safer$(EXEEXT)'; \ + b='test-fopen-safer'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fopen.log: test-fopen$(EXEEXT) + @p='test-fopen$(EXEEXT)'; \ + b='test-fopen'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fpending.sh.log: test-fpending.sh + @p='test-fpending.sh'; \ + b='test-fpending.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fpurge.log: test-fpurge$(EXEEXT) + @p='test-fpurge$(EXEEXT)'; \ + b='test-fpurge'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fputc.log: test-fputc$(EXEEXT) + @p='test-fputc$(EXEEXT)'; \ + b='test-fputc'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fread.log: test-fread$(EXEEXT) + @p='test-fread$(EXEEXT)'; \ + b='test-fread'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-freadahead.sh.log: test-freadahead.sh + @p='test-freadahead.sh'; \ + b='test-freadahead.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-freading.log: test-freading$(EXEEXT) + @p='test-freading$(EXEEXT)'; \ + b='test-freading'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-freadptr.sh.log: test-freadptr.sh + @p='test-freadptr.sh'; \ + b='test-freadptr.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-freadptr2.sh.log: test-freadptr2.sh + @p='test-freadptr2.sh'; \ + b='test-freadptr2.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-freadseek.sh.log: test-freadseek.sh + @p='test-freadseek.sh'; \ + b='test-freadseek.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-freopen-safer.log: test-freopen-safer$(EXEEXT) + @p='test-freopen-safer$(EXEEXT)'; \ + b='test-freopen-safer'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-freopen.log: test-freopen$(EXEEXT) + @p='test-freopen$(EXEEXT)'; \ + b='test-freopen'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-frexp-nolibm.log: test-frexp-nolibm$(EXEEXT) + @p='test-frexp-nolibm$(EXEEXT)'; \ + b='test-frexp-nolibm'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-frexpl-nolibm.log: test-frexpl-nolibm$(EXEEXT) + @p='test-frexpl-nolibm$(EXEEXT)'; \ + b='test-frexpl-nolibm'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fseek.sh.log: test-fseek.sh + @p='test-fseek.sh'; \ + b='test-fseek.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fseek2.sh.log: test-fseek2.sh + @p='test-fseek2.sh'; \ + b='test-fseek2.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fseeko.sh.log: test-fseeko.sh + @p='test-fseeko.sh'; \ + b='test-fseeko.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fseeko2.sh.log: test-fseeko2.sh + @p='test-fseeko2.sh'; \ + b='test-fseeko2.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fseeko3.sh.log: test-fseeko3.sh + @p='test-fseeko3.sh'; \ + b='test-fseeko3.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fseeko4.sh.log: test-fseeko4.sh + @p='test-fseeko4.sh'; \ + b='test-fseeko4.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fseterr.log: test-fseterr$(EXEEXT) + @p='test-fseterr$(EXEEXT)'; \ + b='test-fseterr'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fstat.log: test-fstat$(EXEEXT) + @p='test-fstat$(EXEEXT)'; \ + b='test-fstat'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fstatat.log: test-fstatat$(EXEEXT) + @p='test-fstatat$(EXEEXT)'; \ + b='test-fstatat'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fsync.log: test-fsync$(EXEEXT) + @p='test-fsync$(EXEEXT)'; \ + b='test-fsync'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-ftell.sh.log: test-ftell.sh + @p='test-ftell.sh'; \ + b='test-ftell.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-ftell2.sh.log: test-ftell2.sh + @p='test-ftell2.sh'; \ + b='test-ftell2.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-ftell3.log: test-ftell3$(EXEEXT) + @p='test-ftell3$(EXEEXT)'; \ + b='test-ftell3'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-ftello.sh.log: test-ftello.sh + @p='test-ftello.sh'; \ + b='test-ftello.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-ftello2.sh.log: test-ftello2.sh + @p='test-ftello2.sh'; \ + b='test-ftello2.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-ftello3.log: test-ftello3$(EXEEXT) + @p='test-ftello3$(EXEEXT)'; \ + b='test-ftello3'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-ftello4.sh.log: test-ftello4.sh + @p='test-ftello4.sh'; \ + b='test-ftello4.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-ftruncate.sh.log: test-ftruncate.sh + @p='test-ftruncate.sh'; \ + b='test-ftruncate.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-futimens.log: test-futimens$(EXEEXT) + @p='test-futimens$(EXEEXT)'; \ + b='test-futimens'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-fwrite.log: test-fwrite$(EXEEXT) + @p='test-fwrite$(EXEEXT)'; \ + b='test-fwrite'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-getaddrinfo.log: test-getaddrinfo$(EXEEXT) + @p='test-getaddrinfo$(EXEEXT)'; \ + b='test-getaddrinfo'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-getcwd-lgpl.log: test-getcwd-lgpl$(EXEEXT) + @p='test-getcwd-lgpl$(EXEEXT)'; \ + b='test-getcwd-lgpl'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-getcwd.sh.log: test-getcwd.sh + @p='test-getcwd.sh'; \ + b='test-getcwd.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-getdelim.log: test-getdelim$(EXEEXT) + @p='test-getdelim$(EXEEXT)'; \ + b='test-getdelim'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-getdtablesize.log: test-getdtablesize$(EXEEXT) + @p='test-getdtablesize$(EXEEXT)'; \ + b='test-getdtablesize'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-getgroups.log: test-getgroups$(EXEEXT) + @p='test-getgroups$(EXEEXT)'; \ + b='test-getgroups'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-gethostname.log: test-gethostname$(EXEEXT) + @p='test-gethostname$(EXEEXT)'; \ + b='test-gethostname'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-getline.log: test-getline$(EXEEXT) + @p='test-getline$(EXEEXT)'; \ + b='test-getline'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-getloadavg.log: test-getloadavg$(EXEEXT) + @p='test-getloadavg$(EXEEXT)'; \ + b='test-getloadavg'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-getlogin.log: test-getlogin$(EXEEXT) + @p='test-getlogin$(EXEEXT)'; \ + b='test-getlogin'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-getndelim2.log: test-getndelim2$(EXEEXT) + @p='test-getndelim2$(EXEEXT)'; \ + b='test-getndelim2'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-getopt-gnu.log: test-getopt-gnu$(EXEEXT) + @p='test-getopt-gnu$(EXEEXT)'; \ + b='test-getopt-gnu'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-getopt-posix.log: test-getopt-posix$(EXEEXT) + @p='test-getopt-posix$(EXEEXT)'; \ + b='test-getopt-posix'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-getprogname.log: test-getprogname$(EXEEXT) + @p='test-getprogname$(EXEEXT)'; \ + b='test-getprogname'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-getrusage.log: test-getrusage$(EXEEXT) + @p='test-getrusage$(EXEEXT)'; \ + b='test-getrusage'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-gettimeofday.log: test-gettimeofday$(EXEEXT) + @p='test-gettimeofday$(EXEEXT)'; \ + b='test-gettimeofday'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-hard-locale.log: test-hard-locale$(EXEEXT) + @p='test-hard-locale$(EXEEXT)'; \ + b='test-hard-locale'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-hash.log: test-hash$(EXEEXT) + @p='test-hash$(EXEEXT)'; \ + b='test-hash'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-i-ring.log: test-i-ring$(EXEEXT) + @p='test-i-ring$(EXEEXT)'; \ + b='test-i-ring'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-iconv-h.log: test-iconv-h$(EXEEXT) + @p='test-iconv-h$(EXEEXT)'; \ + b='test-iconv-h'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-iconv.log: test-iconv$(EXEEXT) + @p='test-iconv$(EXEEXT)'; \ + b='test-iconv'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-ignore-value.log: test-ignore-value$(EXEEXT) + @p='test-ignore-value$(EXEEXT)'; \ + b='test-ignore-value'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-inet_ntop.log: test-inet_ntop$(EXEEXT) + @p='test-inet_ntop$(EXEEXT)'; \ + b='test-inet_ntop'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-inet_pton.log: test-inet_pton$(EXEEXT) + @p='test-inet_pton$(EXEEXT)'; \ + b='test-inet_pton'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-ino-map.log: test-ino-map$(EXEEXT) + @p='test-ino-map$(EXEEXT)'; \ + b='test-ino-map'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-intprops.log: test-intprops$(EXEEXT) + @p='test-intprops$(EXEEXT)'; \ + b='test-intprops'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-inttostr.log: test-inttostr$(EXEEXT) + @p='test-inttostr$(EXEEXT)'; \ + b='test-inttostr'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-inttypes.log: test-inttypes$(EXEEXT) + @p='test-inttypes$(EXEEXT)'; \ + b='test-inttypes'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-ioctl.log: test-ioctl$(EXEEXT) + @p='test-ioctl$(EXEEXT)'; \ + b='test-ioctl'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-isatty.log: test-isatty$(EXEEXT) + @p='test-isatty$(EXEEXT)'; \ + b='test-isatty'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-isblank.log: test-isblank$(EXEEXT) + @p='test-isblank$(EXEEXT)'; \ + b='test-isblank'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-isnand-nolibm.log: test-isnand-nolibm$(EXEEXT) + @p='test-isnand-nolibm$(EXEEXT)'; \ + b='test-isnand-nolibm'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-isnanf-nolibm.log: test-isnanf-nolibm$(EXEEXT) + @p='test-isnanf-nolibm$(EXEEXT)'; \ + b='test-isnanf-nolibm'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-isnanl-nolibm.log: test-isnanl-nolibm$(EXEEXT) + @p='test-isnanl-nolibm$(EXEEXT)'; \ + b='test-isnanl-nolibm'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-iswblank.log: test-iswblank$(EXEEXT) + @p='test-iswblank$(EXEEXT)'; \ + b='test-iswblank'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-iswdigit.sh.log: test-iswdigit.sh + @p='test-iswdigit.sh'; \ + b='test-iswdigit.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-iswxdigit.sh.log: test-iswxdigit.sh + @p='test-iswxdigit.sh'; \ + b='test-iswxdigit.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-langinfo.log: test-langinfo$(EXEEXT) + @p='test-langinfo$(EXEEXT)'; \ + b='test-langinfo'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-lchmod.log: test-lchmod$(EXEEXT) + @p='test-lchmod$(EXEEXT)'; \ + b='test-lchmod'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-lchown.log: test-lchown$(EXEEXT) + @p='test-lchown$(EXEEXT)'; \ + b='test-lchown'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-limits-h.log: test-limits-h$(EXEEXT) + @p='test-limits-h$(EXEEXT)'; \ + b='test-limits-h'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-link.log: test-link$(EXEEXT) + @p='test-link$(EXEEXT)'; \ + b='test-link'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-linkat.log: test-linkat$(EXEEXT) + @p='test-linkat$(EXEEXT)'; \ + b='test-linkat'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-listen.log: test-listen$(EXEEXT) + @p='test-listen$(EXEEXT)'; \ + b='test-listen'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-locale.log: test-locale$(EXEEXT) + @p='test-locale$(EXEEXT)'; \ + b='test-locale'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-localeconv.log: test-localeconv$(EXEEXT) + @p='test-localeconv$(EXEEXT)'; \ + b='test-localeconv'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-localename.log: test-localename$(EXEEXT) + @p='test-localename$(EXEEXT)'; \ + b='test-localename'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-rwlock1.log: test-rwlock1$(EXEEXT) + @p='test-rwlock1$(EXEEXT)'; \ + b='test-rwlock1'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-lock.log: test-lock$(EXEEXT) + @p='test-lock$(EXEEXT)'; \ + b='test-lock'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-once1.log: test-once1$(EXEEXT) + @p='test-once1$(EXEEXT)'; \ + b='test-once1'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-once2.log: test-once2$(EXEEXT) + @p='test-once2$(EXEEXT)'; \ + b='test-once2'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-lseek.sh.log: test-lseek.sh + @p='test-lseek.sh'; \ + b='test-lseek.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-lstat.log: test-lstat$(EXEEXT) + @p='test-lstat$(EXEEXT)'; \ + b='test-lstat'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-malloc-gnu.log: test-malloc-gnu$(EXEEXT) + @p='test-malloc-gnu$(EXEEXT)'; \ + b='test-malloc-gnu'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-malloca.log: test-malloca$(EXEEXT) + @p='test-malloca$(EXEEXT)'; \ + b='test-malloca'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-math.log: test-math$(EXEEXT) + @p='test-math$(EXEEXT)'; \ + b='test-math'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mbrtowc1.sh.log: test-mbrtowc1.sh + @p='test-mbrtowc1.sh'; \ + b='test-mbrtowc1.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mbrtowc2.sh.log: test-mbrtowc2.sh + @p='test-mbrtowc2.sh'; \ + b='test-mbrtowc2.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mbrtowc3.sh.log: test-mbrtowc3.sh + @p='test-mbrtowc3.sh'; \ + b='test-mbrtowc3.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mbrtowc4.sh.log: test-mbrtowc4.sh + @p='test-mbrtowc4.sh'; \ + b='test-mbrtowc4.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mbrtowc5.sh.log: test-mbrtowc5.sh + @p='test-mbrtowc5.sh'; \ + b='test-mbrtowc5.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mbrtowc-w32-1.sh.log: test-mbrtowc-w32-1.sh + @p='test-mbrtowc-w32-1.sh'; \ + b='test-mbrtowc-w32-1.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mbrtowc-w32-2.sh.log: test-mbrtowc-w32-2.sh + @p='test-mbrtowc-w32-2.sh'; \ + b='test-mbrtowc-w32-2.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mbrtowc-w32-3.sh.log: test-mbrtowc-w32-3.sh + @p='test-mbrtowc-w32-3.sh'; \ + b='test-mbrtowc-w32-3.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mbrtowc-w32-4.sh.log: test-mbrtowc-w32-4.sh + @p='test-mbrtowc-w32-4.sh'; \ + b='test-mbrtowc-w32-4.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mbrtowc-w32-5.sh.log: test-mbrtowc-w32-5.sh + @p='test-mbrtowc-w32-5.sh'; \ + b='test-mbrtowc-w32-5.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mbrtowc-w32-6.sh.log: test-mbrtowc-w32-6.sh + @p='test-mbrtowc-w32-6.sh'; \ + b='test-mbrtowc-w32-6.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mbrtowc-w32-7.sh.log: test-mbrtowc-w32-7.sh + @p='test-mbrtowc-w32-7.sh'; \ + b='test-mbrtowc-w32-7.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mbsalign.log: test-mbsalign$(EXEEXT) + @p='test-mbsalign$(EXEEXT)'; \ + b='test-mbsalign'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mbscasecmp.sh.log: test-mbscasecmp.sh + @p='test-mbscasecmp.sh'; \ + b='test-mbscasecmp.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mbschr.sh.log: test-mbschr.sh + @p='test-mbschr.sh'; \ + b='test-mbschr.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mbsinit.sh.log: test-mbsinit.sh + @p='test-mbsinit.sh'; \ + b='test-mbsinit.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mbsrtowcs1.sh.log: test-mbsrtowcs1.sh + @p='test-mbsrtowcs1.sh'; \ + b='test-mbsrtowcs1.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mbsrtowcs2.sh.log: test-mbsrtowcs2.sh + @p='test-mbsrtowcs2.sh'; \ + b='test-mbsrtowcs2.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mbsrtowcs3.sh.log: test-mbsrtowcs3.sh + @p='test-mbsrtowcs3.sh'; \ + b='test-mbsrtowcs3.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mbsrtowcs4.sh.log: test-mbsrtowcs4.sh + @p='test-mbsrtowcs4.sh'; \ + b='test-mbsrtowcs4.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mbsstr1.log: test-mbsstr1$(EXEEXT) + @p='test-mbsstr1$(EXEEXT)'; \ + b='test-mbsstr1'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mbsstr2.sh.log: test-mbsstr2.sh + @p='test-mbsstr2.sh'; \ + b='test-mbsstr2.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mbsstr3.sh.log: test-mbsstr3.sh + @p='test-mbsstr3.sh'; \ + b='test-mbsstr3.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-memcasecmp.log: test-memcasecmp$(EXEEXT) + @p='test-memcasecmp$(EXEEXT)'; \ + b='test-memcasecmp'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-memchr.log: test-memchr$(EXEEXT) + @p='test-memchr$(EXEEXT)'; \ + b='test-memchr'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-memchr2.log: test-memchr2$(EXEEXT) + @p='test-memchr2$(EXEEXT)'; \ + b='test-memchr2'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-memcoll.log: test-memcoll$(EXEEXT) + @p='test-memcoll$(EXEEXT)'; \ + b='test-memcoll'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-memrchr.log: test-memrchr$(EXEEXT) + @p='test-memrchr$(EXEEXT)'; \ + b='test-memrchr'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mkdir.log: test-mkdir$(EXEEXT) + @p='test-mkdir$(EXEEXT)'; \ + b='test-mkdir'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mkfifo.log: test-mkfifo$(EXEEXT) + @p='test-mkfifo$(EXEEXT)'; \ + b='test-mkfifo'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-mknod.log: test-mknod$(EXEEXT) + @p='test-mknod$(EXEEXT)'; \ + b='test-mknod'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-nanosleep.log: test-nanosleep$(EXEEXT) + @p='test-nanosleep$(EXEEXT)'; \ + b='test-nanosleep'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-netdb.log: test-netdb$(EXEEXT) + @p='test-netdb$(EXEEXT)'; \ + b='test-netdb'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-netinet_in.log: test-netinet_in$(EXEEXT) + @p='test-netinet_in$(EXEEXT)'; \ + b='test-netinet_in'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-nl_langinfo.sh.log: test-nl_langinfo.sh + @p='test-nl_langinfo.sh'; \ + b='test-nl_langinfo.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-nl_langinfo-mt.log: test-nl_langinfo-mt$(EXEEXT) + @p='test-nl_langinfo-mt$(EXEEXT)'; \ + b='test-nl_langinfo-mt'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-nstrftime.log: test-nstrftime$(EXEEXT) + @p='test-nstrftime$(EXEEXT)'; \ + b='test-nstrftime'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-open.log: test-open$(EXEEXT) + @p='test-open$(EXEEXT)'; \ + b='test-open'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-openat-safer.log: test-openat-safer$(EXEEXT) + @p='test-openat-safer$(EXEEXT)'; \ + b='test-openat-safer'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-openat.log: test-openat$(EXEEXT) + @p='test-openat$(EXEEXT)'; \ + b='test-openat'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-parse-datetime.log: test-parse-datetime$(EXEEXT) + @p='test-parse-datetime$(EXEEXT)'; \ + b='test-parse-datetime'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-pathmax.log: test-pathmax$(EXEEXT) + @p='test-pathmax$(EXEEXT)'; \ + b='test-pathmax'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-perror.sh.log: test-perror.sh + @p='test-perror.sh'; \ + b='test-perror.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-perror2.log: test-perror2$(EXEEXT) + @p='test-perror2$(EXEEXT)'; \ + b='test-perror2'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-pipe.log: test-pipe$(EXEEXT) + @p='test-pipe$(EXEEXT)'; \ + b='test-pipe'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-pipe2.log: test-pipe2$(EXEEXT) + @p='test-pipe2$(EXEEXT)'; \ + b='test-pipe2'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-posixtm.log: test-posixtm$(EXEEXT) + @p='test-posixtm$(EXEEXT)'; \ + b='test-posixtm'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-printf-frexp.log: test-printf-frexp$(EXEEXT) + @p='test-printf-frexp$(EXEEXT)'; \ + b='test-printf-frexp'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-printf-frexpl.log: test-printf-frexpl$(EXEEXT) + @p='test-printf-frexpl$(EXEEXT)'; \ + b='test-printf-frexpl'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-priv-set.log: test-priv-set$(EXEEXT) + @p='test-priv-set$(EXEEXT)'; \ + b='test-priv-set'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-pthread-cond.log: test-pthread-cond$(EXEEXT) + @p='test-pthread-cond$(EXEEXT)'; \ + b='test-pthread-cond'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-pthread.log: test-pthread$(EXEEXT) + @p='test-pthread$(EXEEXT)'; \ + b='test-pthread'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-pthread-mutex.log: test-pthread-mutex$(EXEEXT) + @p='test-pthread-mutex$(EXEEXT)'; \ + b='test-pthread-mutex'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-pthread-thread.log: test-pthread-thread$(EXEEXT) + @p='test-pthread-thread$(EXEEXT)'; \ + b='test-pthread-thread'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-pthread_sigmask1.log: test-pthread_sigmask1$(EXEEXT) + @p='test-pthread_sigmask1$(EXEEXT)'; \ + b='test-pthread_sigmask1'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-pthread_sigmask2.log: test-pthread_sigmask2$(EXEEXT) + @p='test-pthread_sigmask2$(EXEEXT)'; \ + b='test-pthread_sigmask2'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-quotearg-simple.log: test-quotearg-simple$(EXEEXT) + @p='test-quotearg-simple$(EXEEXT)'; \ + b='test-quotearg-simple'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-raise.log: test-raise$(EXEEXT) + @p='test-raise$(EXEEXT)'; \ + b='test-raise'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-rand-isaac.log: test-rand-isaac$(EXEEXT) + @p='test-rand-isaac$(EXEEXT)'; \ + b='test-rand-isaac'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-read-file.log: test-read-file$(EXEEXT) + @p='test-read-file$(EXEEXT)'; \ + b='test-read-file'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-read.log: test-read$(EXEEXT) + @p='test-read$(EXEEXT)'; \ + b='test-read'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-readlink.log: test-readlink$(EXEEXT) + @p='test-readlink$(EXEEXT)'; \ + b='test-readlink'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-readlinkat.log: test-readlinkat$(EXEEXT) + @p='test-readlinkat$(EXEEXT)'; \ + b='test-readlinkat'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-readtokens.sh.log: test-readtokens.sh + @p='test-readtokens.sh'; \ + b='test-readtokens.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-realloc-gnu.log: test-realloc-gnu$(EXEEXT) + @p='test-realloc-gnu$(EXEEXT)'; \ + b='test-realloc-gnu'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-regex.log: test-regex$(EXEEXT) + @p='test-regex$(EXEEXT)'; \ + b='test-regex'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-remove.log: test-remove$(EXEEXT) + @p='test-remove$(EXEEXT)'; \ + b='test-remove'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-rename.log: test-rename$(EXEEXT) + @p='test-rename$(EXEEXT)'; \ + b='test-rename'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-renameat.log: test-renameat$(EXEEXT) + @p='test-renameat$(EXEEXT)'; \ + b='test-renameat'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-renameatu.log: test-renameatu$(EXEEXT) + @p='test-renameatu$(EXEEXT)'; \ + b='test-renameatu'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-rmdir.log: test-rmdir$(EXEEXT) + @p='test-rmdir$(EXEEXT)'; \ + b='test-rmdir'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-sched.log: test-sched$(EXEEXT) + @p='test-sched$(EXEEXT)'; \ + b='test-sched'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-select.log: test-select$(EXEEXT) + @p='test-select$(EXEEXT)'; \ + b='test-select'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-select-in.sh.log: test-select-in.sh + @p='test-select-in.sh'; \ + b='test-select-in.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-select-out.sh.log: test-select-out.sh + @p='test-select-out.sh'; \ + b='test-select-out.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-setenv.log: test-setenv$(EXEEXT) + @p='test-setenv$(EXEEXT)'; \ + b='test-setenv'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-setlocale_null.log: test-setlocale_null$(EXEEXT) + @p='test-setlocale_null$(EXEEXT)'; \ + b='test-setlocale_null'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-setlocale_null-mt-one.log: test-setlocale_null-mt-one$(EXEEXT) + @p='test-setlocale_null-mt-one$(EXEEXT)'; \ + b='test-setlocale_null-mt-one'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-setlocale_null-mt-all.log: test-setlocale_null-mt-all$(EXEEXT) + @p='test-setlocale_null-mt-all$(EXEEXT)'; \ + b='test-setlocale_null-mt-all'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-setlocale1.sh.log: test-setlocale1.sh + @p='test-setlocale1.sh'; \ + b='test-setlocale1.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-setlocale2.sh.log: test-setlocale2.sh + @p='test-setlocale2.sh'; \ + b='test-setlocale2.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-setsockopt.log: test-setsockopt$(EXEEXT) + @p='test-setsockopt$(EXEEXT)'; \ + b='test-setsockopt'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-sigaction.log: test-sigaction$(EXEEXT) + @p='test-sigaction$(EXEEXT)'; \ + b='test-sigaction'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-signal-h.log: test-signal-h$(EXEEXT) + @p='test-signal-h$(EXEEXT)'; \ + b='test-signal-h'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-signbit.log: test-signbit$(EXEEXT) + @p='test-signbit$(EXEEXT)'; \ + b='test-signbit'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-sigprocmask.log: test-sigprocmask$(EXEEXT) + @p='test-sigprocmask$(EXEEXT)'; \ + b='test-sigprocmask'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-sleep.log: test-sleep$(EXEEXT) + @p='test-sleep$(EXEEXT)'; \ + b='test-sleep'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-snprintf.log: test-snprintf$(EXEEXT) + @p='test-snprintf$(EXEEXT)'; \ + b='test-snprintf'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-sockets.log: test-sockets$(EXEEXT) + @p='test-sockets$(EXEEXT)'; \ + b='test-sockets'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-stat.log: test-stat$(EXEEXT) + @p='test-stat$(EXEEXT)'; \ + b='test-stat'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-stat-time.log: test-stat-time$(EXEEXT) + @p='test-stat-time$(EXEEXT)'; \ + b='test-stat-time'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-statat.log: test-statat$(EXEEXT) + @p='test-statat$(EXEEXT)'; \ + b='test-statat'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-stdalign.log: test-stdalign$(EXEEXT) + @p='test-stdalign$(EXEEXT)'; \ + b='test-stdalign'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-stdbool.log: test-stdbool$(EXEEXT) + @p='test-stdbool$(EXEEXT)'; \ + b='test-stdbool'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-stddef.log: test-stddef$(EXEEXT) + @p='test-stddef$(EXEEXT)'; \ + b='test-stddef'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-stdint.log: test-stdint$(EXEEXT) + @p='test-stdint$(EXEEXT)'; \ + b='test-stdint'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-stdio.log: test-stdio$(EXEEXT) + @p='test-stdio$(EXEEXT)'; \ + b='test-stdio'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-stdlib.log: test-stdlib$(EXEEXT) + @p='test-stdlib$(EXEEXT)'; \ + b='test-stdlib'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-strerror.log: test-strerror$(EXEEXT) + @p='test-strerror$(EXEEXT)'; \ + b='test-strerror'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-strerror_r.log: test-strerror_r$(EXEEXT) + @p='test-strerror_r$(EXEEXT)'; \ + b='test-strerror_r'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-striconv.log: test-striconv$(EXEEXT) + @p='test-striconv$(EXEEXT)'; \ + b='test-striconv'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-string.log: test-string$(EXEEXT) + @p='test-string$(EXEEXT)'; \ + b='test-string'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-strncat.log: test-strncat$(EXEEXT) + @p='test-strncat$(EXEEXT)'; \ + b='test-strncat'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-strnlen.log: test-strnlen$(EXEEXT) + @p='test-strnlen$(EXEEXT)'; \ + b='test-strnlen'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-strsignal.log: test-strsignal$(EXEEXT) + @p='test-strsignal$(EXEEXT)'; \ + b='test-strsignal'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-strtod.log: test-strtod$(EXEEXT) + @p='test-strtod$(EXEEXT)'; \ + b='test-strtod'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-strtod1.sh.log: test-strtod1.sh + @p='test-strtod1.sh'; \ + b='test-strtod1.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-strtoimax.log: test-strtoimax$(EXEEXT) + @p='test-strtoimax$(EXEEXT)'; \ + b='test-strtoimax'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-strtold.log: test-strtold$(EXEEXT) + @p='test-strtold$(EXEEXT)'; \ + b='test-strtold'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-strtold1.sh.log: test-strtold1.sh + @p='test-strtold1.sh'; \ + b='test-strtold1.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-strtoll.log: test-strtoll$(EXEEXT) + @p='test-strtoll$(EXEEXT)'; \ + b='test-strtoll'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-strtoull.log: test-strtoull$(EXEEXT) + @p='test-strtoull$(EXEEXT)'; \ + b='test-strtoull'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-strtoumax.log: test-strtoumax$(EXEEXT) + @p='test-strtoumax$(EXEEXT)'; \ + b='test-strtoumax'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-symlink.log: test-symlink$(EXEEXT) + @p='test-symlink$(EXEEXT)'; \ + b='test-symlink'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-symlinkat.log: test-symlinkat$(EXEEXT) + @p='test-symlinkat$(EXEEXT)'; \ + b='test-symlinkat'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-sys_ioctl.log: test-sys_ioctl$(EXEEXT) + @p='test-sys_ioctl$(EXEEXT)'; \ + b='test-sys_ioctl'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-sys_resource.log: test-sys_resource$(EXEEXT) + @p='test-sys_resource$(EXEEXT)'; \ + b='test-sys_resource'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-sys_select.log: test-sys_select$(EXEEXT) + @p='test-sys_select$(EXEEXT)'; \ + b='test-sys_select'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-sys_socket.log: test-sys_socket$(EXEEXT) + @p='test-sys_socket$(EXEEXT)'; \ + b='test-sys_socket'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-sys_stat.log: test-sys_stat$(EXEEXT) + @p='test-sys_stat$(EXEEXT)'; \ + b='test-sys_stat'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-sys_time.log: test-sys_time$(EXEEXT) + @p='test-sys_time$(EXEEXT)'; \ + b='test-sys_time'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-sys_types.log: test-sys_types$(EXEEXT) + @p='test-sys_types$(EXEEXT)'; \ + b='test-sys_types'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-sys_uio.log: test-sys_uio$(EXEEXT) + @p='test-sys_uio$(EXEEXT)'; \ + b='test-sys_uio'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-sys_utsname.log: test-sys_utsname$(EXEEXT) + @p='test-sys_utsname$(EXEEXT)'; \ + b='test-sys_utsname'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-sys_wait.log: test-sys_wait$(EXEEXT) + @p='test-sys_wait$(EXEEXT)'; \ + b='test-sys_wait'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-termios.log: test-termios$(EXEEXT) + @p='test-termios$(EXEEXT)'; \ + b='test-termios'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-init.sh.log: test-init.sh + @p='test-init.sh'; \ + b='test-init.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-thread_self.log: test-thread_self$(EXEEXT) + @p='test-thread_self$(EXEEXT)'; \ + b='test-thread_self'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-thread_create.log: test-thread_create$(EXEEXT) + @p='test-thread_create$(EXEEXT)'; \ + b='test-thread_create'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-time.log: test-time$(EXEEXT) + @p='test-time$(EXEEXT)'; \ + b='test-time'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-timespec.log: test-timespec$(EXEEXT) + @p='test-timespec$(EXEEXT)'; \ + b='test-timespec'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-tls.log: test-tls$(EXEEXT) + @p='test-tls$(EXEEXT)'; \ + b='test-tls'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-u64.log: test-u64$(EXEEXT) + @p='test-u64$(EXEEXT)'; \ + b='test-u64'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-uname.log: test-uname$(EXEEXT) + @p='test-uname$(EXEEXT)'; \ + b='test-uname'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-dup-safer.log: test-dup-safer$(EXEEXT) + @p='test-dup-safer$(EXEEXT)'; \ + b='test-dup-safer'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-unistd.log: test-unistd$(EXEEXT) + @p='test-unistd$(EXEEXT)'; \ + b='test-unistd'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-u8-mbtoucr.log: test-u8-mbtoucr$(EXEEXT) + @p='test-u8-mbtoucr$(EXEEXT)'; \ + b='test-u8-mbtoucr'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-u8-uctomb.log: test-u8-uctomb$(EXEEXT) + @p='test-u8-uctomb$(EXEEXT)'; \ + b='test-u8-uctomb'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-uc_width.log: test-uc_width$(EXEEXT) + @p='test-uc_width$(EXEEXT)'; \ + b='test-uc_width'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +uniwidth/test-uc_width2.sh.log: uniwidth/test-uc_width2.sh + @p='uniwidth/test-uc_width2.sh'; \ + b='uniwidth/test-uc_width2.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-unlink.log: test-unlink$(EXEEXT) + @p='test-unlink$(EXEEXT)'; \ + b='test-unlink'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-unlinkat.log: test-unlinkat$(EXEEXT) + @p='test-unlinkat$(EXEEXT)'; \ + b='test-unlinkat'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-unsetenv.log: test-unsetenv$(EXEEXT) + @p='test-unsetenv$(EXEEXT)'; \ + b='test-unsetenv'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-update-copyright.sh.log: test-update-copyright.sh + @p='test-update-copyright.sh'; \ + b='test-update-copyright.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-userspec.log: test-userspec$(EXEEXT) + @p='test-userspec$(EXEEXT)'; \ + b='test-userspec'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-usleep.log: test-usleep$(EXEEXT) + @p='test-usleep$(EXEEXT)'; \ + b='test-usleep'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-utime-h.log: test-utime-h$(EXEEXT) + @p='test-utime-h$(EXEEXT)'; \ + b='test-utime-h'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-utime.log: test-utime$(EXEEXT) + @p='test-utime$(EXEEXT)'; \ + b='test-utime'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-utimens.log: test-utimens$(EXEEXT) + @p='test-utimens$(EXEEXT)'; \ + b='test-utimens'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-utimensat.log: test-utimensat$(EXEEXT) + @p='test-utimensat$(EXEEXT)'; \ + b='test-utimensat'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-vasnprintf.log: test-vasnprintf$(EXEEXT) + @p='test-vasnprintf$(EXEEXT)'; \ + b='test-vasnprintf'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-vasprintf-posix.log: test-vasprintf-posix$(EXEEXT) + @p='test-vasprintf-posix$(EXEEXT)'; \ + b='test-vasprintf-posix'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-vasprintf.log: test-vasprintf$(EXEEXT) + @p='test-vasprintf$(EXEEXT)'; \ + b='test-vasprintf'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-vc-list-files-git.sh.log: test-vc-list-files-git.sh + @p='test-vc-list-files-git.sh'; \ + b='test-vc-list-files-git.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-vc-list-files-cvs.sh.log: test-vc-list-files-cvs.sh + @p='test-vc-list-files-cvs.sh'; \ + b='test-vc-list-files-cvs.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-verify.log: test-verify$(EXEEXT) + @p='test-verify$(EXEEXT)'; \ + b='test-verify'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-verify.sh.log: test-verify.sh + @p='test-verify.sh'; \ + b='test-verify.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-version-etc.sh.log: test-version-etc.sh + @p='test-version-etc.sh'; \ + b='test-version-etc.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-vfprintf-posix.sh.log: test-vfprintf-posix.sh + @p='test-vfprintf-posix.sh'; \ + b='test-vfprintf-posix.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-vprintf-posix.sh.log: test-vprintf-posix.sh + @p='test-vprintf-posix.sh'; \ + b='test-vprintf-posix.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-wchar.log: test-wchar$(EXEEXT) + @p='test-wchar$(EXEEXT)'; \ + b='test-wchar'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-wcrtomb.sh.log: test-wcrtomb.sh + @p='test-wcrtomb.sh'; \ + b='test-wcrtomb.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-wcrtomb-w32-1.sh.log: test-wcrtomb-w32-1.sh + @p='test-wcrtomb-w32-1.sh'; \ + b='test-wcrtomb-w32-1.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-wcrtomb-w32-2.sh.log: test-wcrtomb-w32-2.sh + @p='test-wcrtomb-w32-2.sh'; \ + b='test-wcrtomb-w32-2.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-wcrtomb-w32-3.sh.log: test-wcrtomb-w32-3.sh + @p='test-wcrtomb-w32-3.sh'; \ + b='test-wcrtomb-w32-3.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-wcrtomb-w32-4.sh.log: test-wcrtomb-w32-4.sh + @p='test-wcrtomb-w32-4.sh'; \ + b='test-wcrtomb-w32-4.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-wcrtomb-w32-5.sh.log: test-wcrtomb-w32-5.sh + @p='test-wcrtomb-w32-5.sh'; \ + b='test-wcrtomb-w32-5.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-wcrtomb-w32-6.sh.log: test-wcrtomb-w32-6.sh + @p='test-wcrtomb-w32-6.sh'; \ + b='test-wcrtomb-w32-6.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-wcrtomb-w32-7.sh.log: test-wcrtomb-w32-7.sh + @p='test-wcrtomb-w32-7.sh'; \ + b='test-wcrtomb-w32-7.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-wctype-h.log: test-wctype-h$(EXEEXT) + @p='test-wctype-h$(EXEEXT)'; \ + b='test-wctype-h'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-wcwidth.log: test-wcwidth$(EXEEXT) + @p='test-wcwidth$(EXEEXT)'; \ + b='test-wcwidth'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-write.log: test-write$(EXEEXT) + @p='test-write$(EXEEXT)'; \ + b='test-write'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-xalloc-die.sh.log: test-xalloc-die.sh + @p='test-xalloc-die.sh'; \ + b='test-xalloc-die.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-xprintf-posix.sh.log: test-xprintf-posix.sh + @p='test-xprintf-posix.sh'; \ + b='test-xprintf-posix.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-xstrtoimax.sh.log: test-xstrtoimax.sh + @p='test-xstrtoimax.sh'; \ + b='test-xstrtoimax.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-xstrtol.sh.log: test-xstrtol.sh + @p='test-xstrtol.sh'; \ + b='test-xstrtol.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-xstrtoumax.sh.log: test-xstrtoumax.sh + @p='test-xstrtoumax.sh'; \ + b='test-xstrtoumax.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-xvasprintf.log: test-xvasprintf$(EXEEXT) + @p='test-xvasprintf$(EXEEXT)'; \ + b='test-xvasprintf'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-yesno.sh.log: test-yesno.sh + @p='test-yesno.sh'; \ + b='test-yesno.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +.test.log: + @p='$<'; \ + $(am__set_b); \ + $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +@am__EXEEXT_TRUE@.test$(EXEEXT).log: +@am__EXEEXT_TRUE@ @p='$<'; \ +@am__EXEEXT_TRUE@ $(am__set_b); \ +@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ +@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ +@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ +@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) + +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + $(am__make_dryrun) \ + || test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ + $(am__relativize); \ + new_distdir=$$reldir; \ + dir1=$$subdir; dir2="$(top_distdir)"; \ + $(am__relativize); \ + new_top_distdir=$$reldir; \ + echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ + echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ + ($(am__cd) $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$new_top_distdir" \ + distdir="$$new_distdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + am__skip_mode_fix=: \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(check_LIBRARIES) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-recursive +all-am: Makefile $(PROGRAMS) $(LIBRARIES) $(MANS) $(HEADERS) +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkglibexecdir)" "$(DESTDIR)$(man1dir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) + -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) + -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -rm -f glthread/$(DEPDIR)/$(am__dirstamp) + -rm -f glthread/$(am__dirstamp) + -rm -f unistr/$(DEPDIR)/$(am__dirstamp) + -rm -f unistr/$(am__dirstamp) + -rm -f uniwidth/$(DEPDIR)/$(am__dirstamp) + -rm -f uniwidth/$(am__dirstamp) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-recursive + +clean-am: clean-binPROGRAMS clean-checkLIBRARIES clean-checkPROGRAMS \ + clean-generic clean-local clean-noinstLIBRARIES \ + clean-noinstPROGRAMS clean-pkglibexecPROGRAMS mostlyclean-am + +distclean: distclean-recursive + -rm -f ./$(DEPDIR)/accept.Po + -rm -f ./$(DEPDIR)/bench-md5.Po + -rm -f ./$(DEPDIR)/bench-sha1.Po + -rm -f ./$(DEPDIR)/bench-sha224.Po + -rm -f ./$(DEPDIR)/bench-sha256.Po + -rm -f ./$(DEPDIR)/bench-sha384.Po + -rm -f ./$(DEPDIR)/bench-sha512.Po + -rm -f ./$(DEPDIR)/bind.Po + -rm -f ./$(DEPDIR)/connect.Po + -rm -f ./$(DEPDIR)/getrusage.Po + -rm -f ./$(DEPDIR)/inet_pton.Po + -rm -f ./$(DEPDIR)/ioctl.Po + -rm -f ./$(DEPDIR)/listen.Po + -rm -f ./$(DEPDIR)/locale.Po + -rm -f ./$(DEPDIR)/localename-table.Po + -rm -f ./$(DEPDIR)/localename.Po + -rm -f ./$(DEPDIR)/perror.Po + -rm -f ./$(DEPDIR)/randomd.Po + -rm -f ./$(DEPDIR)/randoml.Po + -rm -f ./$(DEPDIR)/sched_yield.Po + -rm -f ./$(DEPDIR)/secure_getenv.Po + -rm -f ./$(DEPDIR)/setlocale.Po + -rm -f ./$(DEPDIR)/setsockopt.Po + -rm -f ./$(DEPDIR)/sleep.Po + -rm -f ./$(DEPDIR)/socket.Po + -rm -f ./$(DEPDIR)/strerror_r.Po + -rm -f ./$(DEPDIR)/test-accept.Po + -rm -f ./$(DEPDIR)/test-alignof.Po + -rm -f ./$(DEPDIR)/test-alloca-opt.Po + -rm -f ./$(DEPDIR)/test-areadlink-with-size.Po + -rm -f ./$(DEPDIR)/test-areadlink.Po + -rm -f ./$(DEPDIR)/test-areadlinkat.Po + -rm -f ./$(DEPDIR)/test-argmatch.Po + -rm -f ./$(DEPDIR)/test-argv-iter.Po + -rm -f ./$(DEPDIR)/test-arpa_inet.Po + -rm -f ./$(DEPDIR)/test-base32.Po + -rm -f ./$(DEPDIR)/test-base64.Po + -rm -f ./$(DEPDIR)/test-binary-io.Po + -rm -f ./$(DEPDIR)/test-bind.Po + -rm -f ./$(DEPDIR)/test-bitrotate.Po + -rm -f ./$(DEPDIR)/test-btowc.Po + -rm -f ./$(DEPDIR)/test-byteswap.Po + -rm -f ./$(DEPDIR)/test-c-ctype.Po + -rm -f ./$(DEPDIR)/test-c-strcasecmp.Po + -rm -f ./$(DEPDIR)/test-c-strncasecmp.Po + -rm -f ./$(DEPDIR)/test-calloc-gnu.Po + -rm -f ./$(DEPDIR)/test-canonicalize.Po + -rm -f ./$(DEPDIR)/test-chdir.Po + -rm -f ./$(DEPDIR)/test-chown.Po + -rm -f ./$(DEPDIR)/test-cloexec.Po + -rm -f ./$(DEPDIR)/test-close.Po + -rm -f ./$(DEPDIR)/test-closein.Po + -rm -f ./$(DEPDIR)/test-connect.Po + -rm -f ./$(DEPDIR)/test-copy-acl.Po + -rm -f ./$(DEPDIR)/test-count-leading-zeros.Po + -rm -f ./$(DEPDIR)/test-ctype.Po + -rm -f ./$(DEPDIR)/test-di-set.Po + -rm -f ./$(DEPDIR)/test-dirent-safer.Po + -rm -f ./$(DEPDIR)/test-dirent.Po + -rm -f ./$(DEPDIR)/test-dirname.Po + -rm -f ./$(DEPDIR)/test-dup-safer.Po + -rm -f ./$(DEPDIR)/test-dup.Po + -rm -f ./$(DEPDIR)/test-dup2.Po + -rm -f ./$(DEPDIR)/test-environ.Po + -rm -f ./$(DEPDIR)/test-errno.Po + -rm -f ./$(DEPDIR)/test-exclude.Po + -rm -f ./$(DEPDIR)/test-faccessat.Po + -rm -f ./$(DEPDIR)/test-fadvise.Po + -rm -f ./$(DEPDIR)/test-fchdir.Po + -rm -f ./$(DEPDIR)/test-fchmodat.Po + -rm -f ./$(DEPDIR)/test-fchownat.Po + -rm -f ./$(DEPDIR)/test-fclose.Po + -rm -f ./$(DEPDIR)/test-fcntl-h.Po + -rm -f ./$(DEPDIR)/test-fcntl-safer.Po + -rm -f ./$(DEPDIR)/test-fcntl.Po + -rm -f ./$(DEPDIR)/test-fdatasync.Po + -rm -f ./$(DEPDIR)/test-fdopen.Po + -rm -f ./$(DEPDIR)/test-fdopendir.Po + -rm -f ./$(DEPDIR)/test-fdutimensat.Po + -rm -f ./$(DEPDIR)/test-fflush.Po + -rm -f ./$(DEPDIR)/test-fflush2.Po + -rm -f ./$(DEPDIR)/test-fgetc.Po + -rm -f ./$(DEPDIR)/test-file-has-acl.Po + -rm -f ./$(DEPDIR)/test-filenamecat.Po + -rm -f ./$(DEPDIR)/test-filevercmp.Po + -rm -f ./$(DEPDIR)/test-float.Po + -rm -f ./$(DEPDIR)/test-fnmatch-h.Po + -rm -f ./$(DEPDIR)/test-fnmatch.Po + -rm -f ./$(DEPDIR)/test-fopen-safer.Po + -rm -f ./$(DEPDIR)/test-fopen.Po + -rm -f ./$(DEPDIR)/test-fpending.Po + -rm -f ./$(DEPDIR)/test-fpurge.Po + -rm -f ./$(DEPDIR)/test-fputc.Po + -rm -f ./$(DEPDIR)/test-fread.Po + -rm -f ./$(DEPDIR)/test-freadahead.Po + -rm -f ./$(DEPDIR)/test-freading.Po + -rm -f ./$(DEPDIR)/test-freadptr.Po + -rm -f ./$(DEPDIR)/test-freadptr2.Po + -rm -f ./$(DEPDIR)/test-freadseek.Po + -rm -f ./$(DEPDIR)/test-freopen-safer.Po + -rm -f ./$(DEPDIR)/test-freopen.Po + -rm -f ./$(DEPDIR)/test-frexp.Po + -rm -f ./$(DEPDIR)/test-frexpl.Po + -rm -f ./$(DEPDIR)/test-fseek.Po + -rm -f ./$(DEPDIR)/test-fseeko.Po + -rm -f ./$(DEPDIR)/test-fseeko3.Po + -rm -f ./$(DEPDIR)/test-fseeko4.Po + -rm -f ./$(DEPDIR)/test-fseterr.Po + -rm -f ./$(DEPDIR)/test-fstat.Po + -rm -f ./$(DEPDIR)/test-fstatat.Po + -rm -f ./$(DEPDIR)/test-fsync.Po + -rm -f ./$(DEPDIR)/test-ftell.Po + -rm -f ./$(DEPDIR)/test-ftell3.Po + -rm -f ./$(DEPDIR)/test-ftello.Po + -rm -f ./$(DEPDIR)/test-ftello3.Po + -rm -f ./$(DEPDIR)/test-ftello4.Po + -rm -f ./$(DEPDIR)/test-ftruncate.Po + -rm -f ./$(DEPDIR)/test-futimens.Po + -rm -f ./$(DEPDIR)/test-fwrite.Po + -rm -f ./$(DEPDIR)/test-getaddrinfo.Po + -rm -f ./$(DEPDIR)/test-getcwd-lgpl.Po + -rm -f ./$(DEPDIR)/test-getcwd.Po + -rm -f ./$(DEPDIR)/test-getdelim.Po + -rm -f ./$(DEPDIR)/test-getdtablesize.Po + -rm -f ./$(DEPDIR)/test-getgroups.Po + -rm -f ./$(DEPDIR)/test-gethostname.Po + -rm -f ./$(DEPDIR)/test-getline.Po + -rm -f ./$(DEPDIR)/test-getloadavg.Po + -rm -f ./$(DEPDIR)/test-getlogin.Po + -rm -f ./$(DEPDIR)/test-getndelim2.Po + -rm -f ./$(DEPDIR)/test-getopt-gnu.Po + -rm -f ./$(DEPDIR)/test-getopt-posix.Po + -rm -f ./$(DEPDIR)/test-getprogname.Po + -rm -f ./$(DEPDIR)/test-getrusage.Po + -rm -f ./$(DEPDIR)/test-gettimeofday.Po + -rm -f ./$(DEPDIR)/test-hard-locale.Po + -rm -f ./$(DEPDIR)/test-hash.Po + -rm -f ./$(DEPDIR)/test-i-ring.Po + -rm -f ./$(DEPDIR)/test-iconv-h.Po + -rm -f ./$(DEPDIR)/test-iconv.Po + -rm -f ./$(DEPDIR)/test-ignore-value.Po + -rm -f ./$(DEPDIR)/test-inet_ntop.Po + -rm -f ./$(DEPDIR)/test-inet_pton.Po + -rm -f ./$(DEPDIR)/test-ino-map.Po + -rm -f ./$(DEPDIR)/test-intprops.Po + -rm -f ./$(DEPDIR)/test-inttostr.Po + -rm -f ./$(DEPDIR)/test-inttypes.Po + -rm -f ./$(DEPDIR)/test-ioctl.Po + -rm -f ./$(DEPDIR)/test-isatty.Po + -rm -f ./$(DEPDIR)/test-isblank.Po + -rm -f ./$(DEPDIR)/test-isnand-nolibm.Po + -rm -f ./$(DEPDIR)/test-isnanf-nolibm.Po + -rm -f ./$(DEPDIR)/test-isnanl-nolibm.Po + -rm -f ./$(DEPDIR)/test-iswblank.Po + -rm -f ./$(DEPDIR)/test-iswdigit.Po + -rm -f ./$(DEPDIR)/test-iswxdigit.Po + -rm -f ./$(DEPDIR)/test-langinfo.Po + -rm -f ./$(DEPDIR)/test-lchmod.Po + -rm -f ./$(DEPDIR)/test-lchown.Po + -rm -f ./$(DEPDIR)/test-limits-h.Po + -rm -f ./$(DEPDIR)/test-link.Po + -rm -f ./$(DEPDIR)/test-linkat.Po + -rm -f ./$(DEPDIR)/test-listen.Po + -rm -f ./$(DEPDIR)/test-localcharset.Po + -rm -f ./$(DEPDIR)/test-locale.Po + -rm -f ./$(DEPDIR)/test-localeconv.Po + -rm -f ./$(DEPDIR)/test-localename.Po + -rm -f ./$(DEPDIR)/test-lseek.Po + -rm -f ./$(DEPDIR)/test-lstat.Po + -rm -f ./$(DEPDIR)/test-malloc-gnu.Po + -rm -f ./$(DEPDIR)/test-malloca.Po + -rm -f ./$(DEPDIR)/test-math.Po + -rm -f ./$(DEPDIR)/test-mbrtowc-w32.Po + -rm -f ./$(DEPDIR)/test-mbrtowc.Po + -rm -f ./$(DEPDIR)/test-mbsalign.Po + -rm -f ./$(DEPDIR)/test-mbscasecmp.Po + -rm -f ./$(DEPDIR)/test-mbschr.Po + -rm -f ./$(DEPDIR)/test-mbsinit.Po + -rm -f ./$(DEPDIR)/test-mbsrtowcs.Po + -rm -f ./$(DEPDIR)/test-mbsstr1.Po + -rm -f ./$(DEPDIR)/test-mbsstr2.Po + -rm -f ./$(DEPDIR)/test-mbsstr3.Po + -rm -f ./$(DEPDIR)/test-md5.Po + -rm -f ./$(DEPDIR)/test-memcasecmp.Po + -rm -f ./$(DEPDIR)/test-memchr.Po + -rm -f ./$(DEPDIR)/test-memchr2.Po + -rm -f ./$(DEPDIR)/test-memcoll.Po + -rm -f ./$(DEPDIR)/test-memrchr.Po + -rm -f ./$(DEPDIR)/test-mkdir.Po + -rm -f ./$(DEPDIR)/test-mkfifo.Po + -rm -f ./$(DEPDIR)/test-mknod.Po + -rm -f ./$(DEPDIR)/test-nanosleep.Po + -rm -f ./$(DEPDIR)/test-netdb.Po + -rm -f ./$(DEPDIR)/test-netinet_in.Po + -rm -f ./$(DEPDIR)/test-nl_langinfo-mt.Po + -rm -f ./$(DEPDIR)/test-nl_langinfo.Po + -rm -f ./$(DEPDIR)/test-nstrftime.Po + -rm -f ./$(DEPDIR)/test-once.Po + -rm -f ./$(DEPDIR)/test-open.Po + -rm -f ./$(DEPDIR)/test-openat-safer.Po + -rm -f ./$(DEPDIR)/test-openat.Po + -rm -f ./$(DEPDIR)/test-parse-datetime.Po + -rm -f ./$(DEPDIR)/test-pathmax.Po + -rm -f ./$(DEPDIR)/test-perror.Po + -rm -f ./$(DEPDIR)/test-perror2.Po + -rm -f ./$(DEPDIR)/test-pipe.Po + -rm -f ./$(DEPDIR)/test-pipe2.Po + -rm -f ./$(DEPDIR)/test-posixtm.Po + -rm -f ./$(DEPDIR)/test-printf-frexp.Po + -rm -f ./$(DEPDIR)/test-printf-frexpl.Po + -rm -f ./$(DEPDIR)/test-priv-set.Po + -rm -f ./$(DEPDIR)/test-pthread-cond.Po + -rm -f ./$(DEPDIR)/test-pthread-mutex.Po + -rm -f ./$(DEPDIR)/test-pthread-thread.Po + -rm -f ./$(DEPDIR)/test-pthread.Po + -rm -f ./$(DEPDIR)/test-pthread_sigmask1.Po + -rm -f ./$(DEPDIR)/test-pthread_sigmask2.Po + -rm -f ./$(DEPDIR)/test-quotearg-simple.Po + -rm -f ./$(DEPDIR)/test-raise.Po + -rm -f ./$(DEPDIR)/test-rand-isaac.Po + -rm -f ./$(DEPDIR)/test-read-file.Po + -rm -f ./$(DEPDIR)/test-read.Po + -rm -f ./$(DEPDIR)/test-readlink.Po + -rm -f ./$(DEPDIR)/test-readlinkat.Po + -rm -f ./$(DEPDIR)/test-readtokens.Po + -rm -f ./$(DEPDIR)/test-realloc-gnu.Po + -rm -f ./$(DEPDIR)/test-regex.Po + -rm -f ./$(DEPDIR)/test-remove.Po + -rm -f ./$(DEPDIR)/test-rename.Po + -rm -f ./$(DEPDIR)/test-renameat.Po + -rm -f ./$(DEPDIR)/test-renameatu.Po + -rm -f ./$(DEPDIR)/test-rmdir.Po + -rm -f ./$(DEPDIR)/test-rwlock1.Po + -rm -f ./$(DEPDIR)/test-sameacls.Po + -rm -f ./$(DEPDIR)/test-sched.Po + -rm -f ./$(DEPDIR)/test-select-fd.Po + -rm -f ./$(DEPDIR)/test-select-stdin.Po + -rm -f ./$(DEPDIR)/test-select.Po + -rm -f ./$(DEPDIR)/test-set-mode-acl.Po + -rm -f ./$(DEPDIR)/test-setenv.Po + -rm -f ./$(DEPDIR)/test-setlocale1.Po + -rm -f ./$(DEPDIR)/test-setlocale2.Po + -rm -f ./$(DEPDIR)/test-setlocale_null-mt-all.Po + -rm -f ./$(DEPDIR)/test-setlocale_null-mt-one.Po + -rm -f ./$(DEPDIR)/test-setlocale_null.Po + -rm -f ./$(DEPDIR)/test-setsockopt.Po + -rm -f ./$(DEPDIR)/test-sha1.Po + -rm -f ./$(DEPDIR)/test-sha256.Po + -rm -f ./$(DEPDIR)/test-sha512.Po + -rm -f ./$(DEPDIR)/test-sigaction.Po + -rm -f ./$(DEPDIR)/test-signal-h.Po + -rm -f ./$(DEPDIR)/test-signbit.Po + -rm -f ./$(DEPDIR)/test-sigprocmask.Po + -rm -f ./$(DEPDIR)/test-sleep.Po + -rm -f ./$(DEPDIR)/test-snprintf.Po + -rm -f ./$(DEPDIR)/test-sockets.Po + -rm -f ./$(DEPDIR)/test-stat-time.Po + -rm -f ./$(DEPDIR)/test-stat.Po + -rm -f ./$(DEPDIR)/test-statat.Po + -rm -f ./$(DEPDIR)/test-stdalign.Po + -rm -f ./$(DEPDIR)/test-stdbool.Po + -rm -f ./$(DEPDIR)/test-stddef.Po + -rm -f ./$(DEPDIR)/test-stdint.Po + -rm -f ./$(DEPDIR)/test-stdio.Po + -rm -f ./$(DEPDIR)/test-stdlib.Po + -rm -f ./$(DEPDIR)/test-strerror.Po + -rm -f ./$(DEPDIR)/test-strerror_r.Po + -rm -f ./$(DEPDIR)/test-striconv.Po + -rm -f ./$(DEPDIR)/test-string.Po + -rm -f ./$(DEPDIR)/test-strncat.Po + -rm -f ./$(DEPDIR)/test-strnlen.Po + -rm -f ./$(DEPDIR)/test-strsignal.Po + -rm -f ./$(DEPDIR)/test-strtod.Po + -rm -f ./$(DEPDIR)/test-strtod1.Po + -rm -f ./$(DEPDIR)/test-strtoimax.Po + -rm -f ./$(DEPDIR)/test-strtold.Po + -rm -f ./$(DEPDIR)/test-strtold1.Po + -rm -f ./$(DEPDIR)/test-strtoll.Po + -rm -f ./$(DEPDIR)/test-strtoull.Po + -rm -f ./$(DEPDIR)/test-strtoumax.Po + -rm -f ./$(DEPDIR)/test-symlink.Po + -rm -f ./$(DEPDIR)/test-symlinkat.Po + -rm -f ./$(DEPDIR)/test-sys_ioctl.Po + -rm -f ./$(DEPDIR)/test-sys_resource.Po + -rm -f ./$(DEPDIR)/test-sys_select.Po + -rm -f ./$(DEPDIR)/test-sys_socket.Po + -rm -f ./$(DEPDIR)/test-sys_stat.Po + -rm -f ./$(DEPDIR)/test-sys_time.Po + -rm -f ./$(DEPDIR)/test-sys_types.Po + -rm -f ./$(DEPDIR)/test-sys_uio.Po + -rm -f ./$(DEPDIR)/test-sys_utsname.Po + -rm -f ./$(DEPDIR)/test-sys_wait.Po + -rm -f ./$(DEPDIR)/test-termios.Po + -rm -f ./$(DEPDIR)/test-thread_create.Po + -rm -f ./$(DEPDIR)/test-thread_self.Po + -rm -f ./$(DEPDIR)/test-time.Po + -rm -f ./$(DEPDIR)/test-timespec.Po + -rm -f ./$(DEPDIR)/test-u64.Po + -rm -f ./$(DEPDIR)/test-uname.Po + -rm -f ./$(DEPDIR)/test-unistd.Po + -rm -f ./$(DEPDIR)/test-unlink.Po + -rm -f ./$(DEPDIR)/test-unlinkat.Po + -rm -f ./$(DEPDIR)/test-unsetenv.Po + -rm -f ./$(DEPDIR)/test-userspec.Po + -rm -f ./$(DEPDIR)/test-usleep.Po + -rm -f ./$(DEPDIR)/test-utime-h.Po + -rm -f ./$(DEPDIR)/test-utime.Po + -rm -f ./$(DEPDIR)/test-utimens.Po + -rm -f ./$(DEPDIR)/test-utimensat.Po + -rm -f ./$(DEPDIR)/test-vasnprintf.Po + -rm -f ./$(DEPDIR)/test-vasprintf-posix.Po + -rm -f ./$(DEPDIR)/test-vasprintf.Po + -rm -f ./$(DEPDIR)/test-verify-try.Po + -rm -f ./$(DEPDIR)/test-verify.Po + -rm -f ./$(DEPDIR)/test-version-etc.Po + -rm -f ./$(DEPDIR)/test-vfprintf-posix.Po + -rm -f ./$(DEPDIR)/test-vprintf-posix.Po + -rm -f ./$(DEPDIR)/test-wchar.Po + -rm -f ./$(DEPDIR)/test-wcrtomb-w32.Po + -rm -f ./$(DEPDIR)/test-wcrtomb.Po + -rm -f ./$(DEPDIR)/test-wctype-h.Po + -rm -f ./$(DEPDIR)/test-wcwidth.Po + -rm -f ./$(DEPDIR)/test-write.Po + -rm -f ./$(DEPDIR)/test-xalloc-die.Po + -rm -f ./$(DEPDIR)/test-xfprintf-posix.Po + -rm -f ./$(DEPDIR)/test-xprintf-posix.Po + -rm -f ./$(DEPDIR)/test-xstrtoimax.Po + -rm -f ./$(DEPDIR)/test-xstrtol.Po + -rm -f ./$(DEPDIR)/test-xstrtoul.Po + -rm -f ./$(DEPDIR)/test-xstrtoumax.Po + -rm -f ./$(DEPDIR)/test-yesno.Po + -rm -f ./$(DEPDIR)/test_lock-test-lock.Po + -rm -f ./$(DEPDIR)/test_tls-test-tls.Po + -rm -f ./$(DEPDIR)/test_xvasprintf-test-xvasprintf.Po + -rm -f ./$(DEPDIR)/timespec-add.Po + -rm -f ./$(DEPDIR)/timespec-sub.Po + -rm -f ./$(DEPDIR)/tmpdir.Po + -rm -f ./$(DEPDIR)/tmpfile.Po + -rm -f ./$(DEPDIR)/usleep.Po + -rm -f ./$(DEPDIR)/wctob.Po + -rm -f ./$(DEPDIR)/wctomb.Po + -rm -f glthread/$(DEPDIR)/thread.Po + -rm -f unistr/$(DEPDIR)/test-u8-mbtoucr.Po + -rm -f unistr/$(DEPDIR)/test-u8-uctomb.Po + -rm -f uniwidth/$(DEPDIR)/test-uc_width.Po + -rm -f uniwidth/$(DEPDIR)/test-uc_width2.Po + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +html-am: + +info: info-recursive + +info-am: + +install-data-am: install-man + +install-dvi: install-dvi-recursive + +install-dvi-am: + +install-exec-am: install-binPROGRAMS install-pkglibexecPROGRAMS + +install-html: install-html-recursive + +install-html-am: + +install-info: install-info-recursive + +install-info-am: + +install-man: install-man1 + +install-pdf: install-pdf-recursive + +install-pdf-am: + +install-ps: install-ps-recursive + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f ./$(DEPDIR)/accept.Po + -rm -f ./$(DEPDIR)/bench-md5.Po + -rm -f ./$(DEPDIR)/bench-sha1.Po + -rm -f ./$(DEPDIR)/bench-sha224.Po + -rm -f ./$(DEPDIR)/bench-sha256.Po + -rm -f ./$(DEPDIR)/bench-sha384.Po + -rm -f ./$(DEPDIR)/bench-sha512.Po + -rm -f ./$(DEPDIR)/bind.Po + -rm -f ./$(DEPDIR)/connect.Po + -rm -f ./$(DEPDIR)/getrusage.Po + -rm -f ./$(DEPDIR)/inet_pton.Po + -rm -f ./$(DEPDIR)/ioctl.Po + -rm -f ./$(DEPDIR)/listen.Po + -rm -f ./$(DEPDIR)/locale.Po + -rm -f ./$(DEPDIR)/localename-table.Po + -rm -f ./$(DEPDIR)/localename.Po + -rm -f ./$(DEPDIR)/perror.Po + -rm -f ./$(DEPDIR)/randomd.Po + -rm -f ./$(DEPDIR)/randoml.Po + -rm -f ./$(DEPDIR)/sched_yield.Po + -rm -f ./$(DEPDIR)/secure_getenv.Po + -rm -f ./$(DEPDIR)/setlocale.Po + -rm -f ./$(DEPDIR)/setsockopt.Po + -rm -f ./$(DEPDIR)/sleep.Po + -rm -f ./$(DEPDIR)/socket.Po + -rm -f ./$(DEPDIR)/strerror_r.Po + -rm -f ./$(DEPDIR)/test-accept.Po + -rm -f ./$(DEPDIR)/test-alignof.Po + -rm -f ./$(DEPDIR)/test-alloca-opt.Po + -rm -f ./$(DEPDIR)/test-areadlink-with-size.Po + -rm -f ./$(DEPDIR)/test-areadlink.Po + -rm -f ./$(DEPDIR)/test-areadlinkat.Po + -rm -f ./$(DEPDIR)/test-argmatch.Po + -rm -f ./$(DEPDIR)/test-argv-iter.Po + -rm -f ./$(DEPDIR)/test-arpa_inet.Po + -rm -f ./$(DEPDIR)/test-base32.Po + -rm -f ./$(DEPDIR)/test-base64.Po + -rm -f ./$(DEPDIR)/test-binary-io.Po + -rm -f ./$(DEPDIR)/test-bind.Po + -rm -f ./$(DEPDIR)/test-bitrotate.Po + -rm -f ./$(DEPDIR)/test-btowc.Po + -rm -f ./$(DEPDIR)/test-byteswap.Po + -rm -f ./$(DEPDIR)/test-c-ctype.Po + -rm -f ./$(DEPDIR)/test-c-strcasecmp.Po + -rm -f ./$(DEPDIR)/test-c-strncasecmp.Po + -rm -f ./$(DEPDIR)/test-calloc-gnu.Po + -rm -f ./$(DEPDIR)/test-canonicalize.Po + -rm -f ./$(DEPDIR)/test-chdir.Po + -rm -f ./$(DEPDIR)/test-chown.Po + -rm -f ./$(DEPDIR)/test-cloexec.Po + -rm -f ./$(DEPDIR)/test-close.Po + -rm -f ./$(DEPDIR)/test-closein.Po + -rm -f ./$(DEPDIR)/test-connect.Po + -rm -f ./$(DEPDIR)/test-copy-acl.Po + -rm -f ./$(DEPDIR)/test-count-leading-zeros.Po + -rm -f ./$(DEPDIR)/test-ctype.Po + -rm -f ./$(DEPDIR)/test-di-set.Po + -rm -f ./$(DEPDIR)/test-dirent-safer.Po + -rm -f ./$(DEPDIR)/test-dirent.Po + -rm -f ./$(DEPDIR)/test-dirname.Po + -rm -f ./$(DEPDIR)/test-dup-safer.Po + -rm -f ./$(DEPDIR)/test-dup.Po + -rm -f ./$(DEPDIR)/test-dup2.Po + -rm -f ./$(DEPDIR)/test-environ.Po + -rm -f ./$(DEPDIR)/test-errno.Po + -rm -f ./$(DEPDIR)/test-exclude.Po + -rm -f ./$(DEPDIR)/test-faccessat.Po + -rm -f ./$(DEPDIR)/test-fadvise.Po + -rm -f ./$(DEPDIR)/test-fchdir.Po + -rm -f ./$(DEPDIR)/test-fchmodat.Po + -rm -f ./$(DEPDIR)/test-fchownat.Po + -rm -f ./$(DEPDIR)/test-fclose.Po + -rm -f ./$(DEPDIR)/test-fcntl-h.Po + -rm -f ./$(DEPDIR)/test-fcntl-safer.Po + -rm -f ./$(DEPDIR)/test-fcntl.Po + -rm -f ./$(DEPDIR)/test-fdatasync.Po + -rm -f ./$(DEPDIR)/test-fdopen.Po + -rm -f ./$(DEPDIR)/test-fdopendir.Po + -rm -f ./$(DEPDIR)/test-fdutimensat.Po + -rm -f ./$(DEPDIR)/test-fflush.Po + -rm -f ./$(DEPDIR)/test-fflush2.Po + -rm -f ./$(DEPDIR)/test-fgetc.Po + -rm -f ./$(DEPDIR)/test-file-has-acl.Po + -rm -f ./$(DEPDIR)/test-filenamecat.Po + -rm -f ./$(DEPDIR)/test-filevercmp.Po + -rm -f ./$(DEPDIR)/test-float.Po + -rm -f ./$(DEPDIR)/test-fnmatch-h.Po + -rm -f ./$(DEPDIR)/test-fnmatch.Po + -rm -f ./$(DEPDIR)/test-fopen-safer.Po + -rm -f ./$(DEPDIR)/test-fopen.Po + -rm -f ./$(DEPDIR)/test-fpending.Po + -rm -f ./$(DEPDIR)/test-fpurge.Po + -rm -f ./$(DEPDIR)/test-fputc.Po + -rm -f ./$(DEPDIR)/test-fread.Po + -rm -f ./$(DEPDIR)/test-freadahead.Po + -rm -f ./$(DEPDIR)/test-freading.Po + -rm -f ./$(DEPDIR)/test-freadptr.Po + -rm -f ./$(DEPDIR)/test-freadptr2.Po + -rm -f ./$(DEPDIR)/test-freadseek.Po + -rm -f ./$(DEPDIR)/test-freopen-safer.Po + -rm -f ./$(DEPDIR)/test-freopen.Po + -rm -f ./$(DEPDIR)/test-frexp.Po + -rm -f ./$(DEPDIR)/test-frexpl.Po + -rm -f ./$(DEPDIR)/test-fseek.Po + -rm -f ./$(DEPDIR)/test-fseeko.Po + -rm -f ./$(DEPDIR)/test-fseeko3.Po + -rm -f ./$(DEPDIR)/test-fseeko4.Po + -rm -f ./$(DEPDIR)/test-fseterr.Po + -rm -f ./$(DEPDIR)/test-fstat.Po + -rm -f ./$(DEPDIR)/test-fstatat.Po + -rm -f ./$(DEPDIR)/test-fsync.Po + -rm -f ./$(DEPDIR)/test-ftell.Po + -rm -f ./$(DEPDIR)/test-ftell3.Po + -rm -f ./$(DEPDIR)/test-ftello.Po + -rm -f ./$(DEPDIR)/test-ftello3.Po + -rm -f ./$(DEPDIR)/test-ftello4.Po + -rm -f ./$(DEPDIR)/test-ftruncate.Po + -rm -f ./$(DEPDIR)/test-futimens.Po + -rm -f ./$(DEPDIR)/test-fwrite.Po + -rm -f ./$(DEPDIR)/test-getaddrinfo.Po + -rm -f ./$(DEPDIR)/test-getcwd-lgpl.Po + -rm -f ./$(DEPDIR)/test-getcwd.Po + -rm -f ./$(DEPDIR)/test-getdelim.Po + -rm -f ./$(DEPDIR)/test-getdtablesize.Po + -rm -f ./$(DEPDIR)/test-getgroups.Po + -rm -f ./$(DEPDIR)/test-gethostname.Po + -rm -f ./$(DEPDIR)/test-getline.Po + -rm -f ./$(DEPDIR)/test-getloadavg.Po + -rm -f ./$(DEPDIR)/test-getlogin.Po + -rm -f ./$(DEPDIR)/test-getndelim2.Po + -rm -f ./$(DEPDIR)/test-getopt-gnu.Po + -rm -f ./$(DEPDIR)/test-getopt-posix.Po + -rm -f ./$(DEPDIR)/test-getprogname.Po + -rm -f ./$(DEPDIR)/test-getrusage.Po + -rm -f ./$(DEPDIR)/test-gettimeofday.Po + -rm -f ./$(DEPDIR)/test-hard-locale.Po + -rm -f ./$(DEPDIR)/test-hash.Po + -rm -f ./$(DEPDIR)/test-i-ring.Po + -rm -f ./$(DEPDIR)/test-iconv-h.Po + -rm -f ./$(DEPDIR)/test-iconv.Po + -rm -f ./$(DEPDIR)/test-ignore-value.Po + -rm -f ./$(DEPDIR)/test-inet_ntop.Po + -rm -f ./$(DEPDIR)/test-inet_pton.Po + -rm -f ./$(DEPDIR)/test-ino-map.Po + -rm -f ./$(DEPDIR)/test-intprops.Po + -rm -f ./$(DEPDIR)/test-inttostr.Po + -rm -f ./$(DEPDIR)/test-inttypes.Po + -rm -f ./$(DEPDIR)/test-ioctl.Po + -rm -f ./$(DEPDIR)/test-isatty.Po + -rm -f ./$(DEPDIR)/test-isblank.Po + -rm -f ./$(DEPDIR)/test-isnand-nolibm.Po + -rm -f ./$(DEPDIR)/test-isnanf-nolibm.Po + -rm -f ./$(DEPDIR)/test-isnanl-nolibm.Po + -rm -f ./$(DEPDIR)/test-iswblank.Po + -rm -f ./$(DEPDIR)/test-iswdigit.Po + -rm -f ./$(DEPDIR)/test-iswxdigit.Po + -rm -f ./$(DEPDIR)/test-langinfo.Po + -rm -f ./$(DEPDIR)/test-lchmod.Po + -rm -f ./$(DEPDIR)/test-lchown.Po + -rm -f ./$(DEPDIR)/test-limits-h.Po + -rm -f ./$(DEPDIR)/test-link.Po + -rm -f ./$(DEPDIR)/test-linkat.Po + -rm -f ./$(DEPDIR)/test-listen.Po + -rm -f ./$(DEPDIR)/test-localcharset.Po + -rm -f ./$(DEPDIR)/test-locale.Po + -rm -f ./$(DEPDIR)/test-localeconv.Po + -rm -f ./$(DEPDIR)/test-localename.Po + -rm -f ./$(DEPDIR)/test-lseek.Po + -rm -f ./$(DEPDIR)/test-lstat.Po + -rm -f ./$(DEPDIR)/test-malloc-gnu.Po + -rm -f ./$(DEPDIR)/test-malloca.Po + -rm -f ./$(DEPDIR)/test-math.Po + -rm -f ./$(DEPDIR)/test-mbrtowc-w32.Po + -rm -f ./$(DEPDIR)/test-mbrtowc.Po + -rm -f ./$(DEPDIR)/test-mbsalign.Po + -rm -f ./$(DEPDIR)/test-mbscasecmp.Po + -rm -f ./$(DEPDIR)/test-mbschr.Po + -rm -f ./$(DEPDIR)/test-mbsinit.Po + -rm -f ./$(DEPDIR)/test-mbsrtowcs.Po + -rm -f ./$(DEPDIR)/test-mbsstr1.Po + -rm -f ./$(DEPDIR)/test-mbsstr2.Po + -rm -f ./$(DEPDIR)/test-mbsstr3.Po + -rm -f ./$(DEPDIR)/test-md5.Po + -rm -f ./$(DEPDIR)/test-memcasecmp.Po + -rm -f ./$(DEPDIR)/test-memchr.Po + -rm -f ./$(DEPDIR)/test-memchr2.Po + -rm -f ./$(DEPDIR)/test-memcoll.Po + -rm -f ./$(DEPDIR)/test-memrchr.Po + -rm -f ./$(DEPDIR)/test-mkdir.Po + -rm -f ./$(DEPDIR)/test-mkfifo.Po + -rm -f ./$(DEPDIR)/test-mknod.Po + -rm -f ./$(DEPDIR)/test-nanosleep.Po + -rm -f ./$(DEPDIR)/test-netdb.Po + -rm -f ./$(DEPDIR)/test-netinet_in.Po + -rm -f ./$(DEPDIR)/test-nl_langinfo-mt.Po + -rm -f ./$(DEPDIR)/test-nl_langinfo.Po + -rm -f ./$(DEPDIR)/test-nstrftime.Po + -rm -f ./$(DEPDIR)/test-once.Po + -rm -f ./$(DEPDIR)/test-open.Po + -rm -f ./$(DEPDIR)/test-openat-safer.Po + -rm -f ./$(DEPDIR)/test-openat.Po + -rm -f ./$(DEPDIR)/test-parse-datetime.Po + -rm -f ./$(DEPDIR)/test-pathmax.Po + -rm -f ./$(DEPDIR)/test-perror.Po + -rm -f ./$(DEPDIR)/test-perror2.Po + -rm -f ./$(DEPDIR)/test-pipe.Po + -rm -f ./$(DEPDIR)/test-pipe2.Po + -rm -f ./$(DEPDIR)/test-posixtm.Po + -rm -f ./$(DEPDIR)/test-printf-frexp.Po + -rm -f ./$(DEPDIR)/test-printf-frexpl.Po + -rm -f ./$(DEPDIR)/test-priv-set.Po + -rm -f ./$(DEPDIR)/test-pthread-cond.Po + -rm -f ./$(DEPDIR)/test-pthread-mutex.Po + -rm -f ./$(DEPDIR)/test-pthread-thread.Po + -rm -f ./$(DEPDIR)/test-pthread.Po + -rm -f ./$(DEPDIR)/test-pthread_sigmask1.Po + -rm -f ./$(DEPDIR)/test-pthread_sigmask2.Po + -rm -f ./$(DEPDIR)/test-quotearg-simple.Po + -rm -f ./$(DEPDIR)/test-raise.Po + -rm -f ./$(DEPDIR)/test-rand-isaac.Po + -rm -f ./$(DEPDIR)/test-read-file.Po + -rm -f ./$(DEPDIR)/test-read.Po + -rm -f ./$(DEPDIR)/test-readlink.Po + -rm -f ./$(DEPDIR)/test-readlinkat.Po + -rm -f ./$(DEPDIR)/test-readtokens.Po + -rm -f ./$(DEPDIR)/test-realloc-gnu.Po + -rm -f ./$(DEPDIR)/test-regex.Po + -rm -f ./$(DEPDIR)/test-remove.Po + -rm -f ./$(DEPDIR)/test-rename.Po + -rm -f ./$(DEPDIR)/test-renameat.Po + -rm -f ./$(DEPDIR)/test-renameatu.Po + -rm -f ./$(DEPDIR)/test-rmdir.Po + -rm -f ./$(DEPDIR)/test-rwlock1.Po + -rm -f ./$(DEPDIR)/test-sameacls.Po + -rm -f ./$(DEPDIR)/test-sched.Po + -rm -f ./$(DEPDIR)/test-select-fd.Po + -rm -f ./$(DEPDIR)/test-select-stdin.Po + -rm -f ./$(DEPDIR)/test-select.Po + -rm -f ./$(DEPDIR)/test-set-mode-acl.Po + -rm -f ./$(DEPDIR)/test-setenv.Po + -rm -f ./$(DEPDIR)/test-setlocale1.Po + -rm -f ./$(DEPDIR)/test-setlocale2.Po + -rm -f ./$(DEPDIR)/test-setlocale_null-mt-all.Po + -rm -f ./$(DEPDIR)/test-setlocale_null-mt-one.Po + -rm -f ./$(DEPDIR)/test-setlocale_null.Po + -rm -f ./$(DEPDIR)/test-setsockopt.Po + -rm -f ./$(DEPDIR)/test-sha1.Po + -rm -f ./$(DEPDIR)/test-sha256.Po + -rm -f ./$(DEPDIR)/test-sha512.Po + -rm -f ./$(DEPDIR)/test-sigaction.Po + -rm -f ./$(DEPDIR)/test-signal-h.Po + -rm -f ./$(DEPDIR)/test-signbit.Po + -rm -f ./$(DEPDIR)/test-sigprocmask.Po + -rm -f ./$(DEPDIR)/test-sleep.Po + -rm -f ./$(DEPDIR)/test-snprintf.Po + -rm -f ./$(DEPDIR)/test-sockets.Po + -rm -f ./$(DEPDIR)/test-stat-time.Po + -rm -f ./$(DEPDIR)/test-stat.Po + -rm -f ./$(DEPDIR)/test-statat.Po + -rm -f ./$(DEPDIR)/test-stdalign.Po + -rm -f ./$(DEPDIR)/test-stdbool.Po + -rm -f ./$(DEPDIR)/test-stddef.Po + -rm -f ./$(DEPDIR)/test-stdint.Po + -rm -f ./$(DEPDIR)/test-stdio.Po + -rm -f ./$(DEPDIR)/test-stdlib.Po + -rm -f ./$(DEPDIR)/test-strerror.Po + -rm -f ./$(DEPDIR)/test-strerror_r.Po + -rm -f ./$(DEPDIR)/test-striconv.Po + -rm -f ./$(DEPDIR)/test-string.Po + -rm -f ./$(DEPDIR)/test-strncat.Po + -rm -f ./$(DEPDIR)/test-strnlen.Po + -rm -f ./$(DEPDIR)/test-strsignal.Po + -rm -f ./$(DEPDIR)/test-strtod.Po + -rm -f ./$(DEPDIR)/test-strtod1.Po + -rm -f ./$(DEPDIR)/test-strtoimax.Po + -rm -f ./$(DEPDIR)/test-strtold.Po + -rm -f ./$(DEPDIR)/test-strtold1.Po + -rm -f ./$(DEPDIR)/test-strtoll.Po + -rm -f ./$(DEPDIR)/test-strtoull.Po + -rm -f ./$(DEPDIR)/test-strtoumax.Po + -rm -f ./$(DEPDIR)/test-symlink.Po + -rm -f ./$(DEPDIR)/test-symlinkat.Po + -rm -f ./$(DEPDIR)/test-sys_ioctl.Po + -rm -f ./$(DEPDIR)/test-sys_resource.Po + -rm -f ./$(DEPDIR)/test-sys_select.Po + -rm -f ./$(DEPDIR)/test-sys_socket.Po + -rm -f ./$(DEPDIR)/test-sys_stat.Po + -rm -f ./$(DEPDIR)/test-sys_time.Po + -rm -f ./$(DEPDIR)/test-sys_types.Po + -rm -f ./$(DEPDIR)/test-sys_uio.Po + -rm -f ./$(DEPDIR)/test-sys_utsname.Po + -rm -f ./$(DEPDIR)/test-sys_wait.Po + -rm -f ./$(DEPDIR)/test-termios.Po + -rm -f ./$(DEPDIR)/test-thread_create.Po + -rm -f ./$(DEPDIR)/test-thread_self.Po + -rm -f ./$(DEPDIR)/test-time.Po + -rm -f ./$(DEPDIR)/test-timespec.Po + -rm -f ./$(DEPDIR)/test-u64.Po + -rm -f ./$(DEPDIR)/test-uname.Po + -rm -f ./$(DEPDIR)/test-unistd.Po + -rm -f ./$(DEPDIR)/test-unlink.Po + -rm -f ./$(DEPDIR)/test-unlinkat.Po + -rm -f ./$(DEPDIR)/test-unsetenv.Po + -rm -f ./$(DEPDIR)/test-userspec.Po + -rm -f ./$(DEPDIR)/test-usleep.Po + -rm -f ./$(DEPDIR)/test-utime-h.Po + -rm -f ./$(DEPDIR)/test-utime.Po + -rm -f ./$(DEPDIR)/test-utimens.Po + -rm -f ./$(DEPDIR)/test-utimensat.Po + -rm -f ./$(DEPDIR)/test-vasnprintf.Po + -rm -f ./$(DEPDIR)/test-vasprintf-posix.Po + -rm -f ./$(DEPDIR)/test-vasprintf.Po + -rm -f ./$(DEPDIR)/test-verify-try.Po + -rm -f ./$(DEPDIR)/test-verify.Po + -rm -f ./$(DEPDIR)/test-version-etc.Po + -rm -f ./$(DEPDIR)/test-vfprintf-posix.Po + -rm -f ./$(DEPDIR)/test-vprintf-posix.Po + -rm -f ./$(DEPDIR)/test-wchar.Po + -rm -f ./$(DEPDIR)/test-wcrtomb-w32.Po + -rm -f ./$(DEPDIR)/test-wcrtomb.Po + -rm -f ./$(DEPDIR)/test-wctype-h.Po + -rm -f ./$(DEPDIR)/test-wcwidth.Po + -rm -f ./$(DEPDIR)/test-write.Po + -rm -f ./$(DEPDIR)/test-xalloc-die.Po + -rm -f ./$(DEPDIR)/test-xfprintf-posix.Po + -rm -f ./$(DEPDIR)/test-xprintf-posix.Po + -rm -f ./$(DEPDIR)/test-xstrtoimax.Po + -rm -f ./$(DEPDIR)/test-xstrtol.Po + -rm -f ./$(DEPDIR)/test-xstrtoul.Po + -rm -f ./$(DEPDIR)/test-xstrtoumax.Po + -rm -f ./$(DEPDIR)/test-yesno.Po + -rm -f ./$(DEPDIR)/test_lock-test-lock.Po + -rm -f ./$(DEPDIR)/test_tls-test-tls.Po + -rm -f ./$(DEPDIR)/test_xvasprintf-test-xvasprintf.Po + -rm -f ./$(DEPDIR)/timespec-add.Po + -rm -f ./$(DEPDIR)/timespec-sub.Po + -rm -f ./$(DEPDIR)/tmpdir.Po + -rm -f ./$(DEPDIR)/tmpfile.Po + -rm -f ./$(DEPDIR)/usleep.Po + -rm -f ./$(DEPDIR)/wctob.Po + -rm -f ./$(DEPDIR)/wctomb.Po + -rm -f glthread/$(DEPDIR)/thread.Po + -rm -f unistr/$(DEPDIR)/test-u8-mbtoucr.Po + -rm -f unistr/$(DEPDIR)/test-u8-uctomb.Po + -rm -f uniwidth/$(DEPDIR)/test-uc_width.Po + -rm -f uniwidth/$(DEPDIR)/test-uc_width2.Po + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-local + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-man \ + uninstall-pkglibexecPROGRAMS + +uninstall-man: uninstall-man1 + +.MAKE: $(am__recursive_targets) all check check-am install install-am \ + install-strip + +.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ + am--depfiles check check-TESTS check-am clean \ + clean-binPROGRAMS clean-checkLIBRARIES clean-checkPROGRAMS \ + clean-generic clean-local clean-noinstLIBRARIES \ + clean-noinstPROGRAMS clean-pkglibexecPROGRAMS cscopelist-am \ + ctags ctags-am distclean distclean-compile distclean-generic \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-binPROGRAMS install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-man1 install-pdf \ + install-pdf-am install-pkglibexecPROGRAMS install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-local pdf pdf-am ps ps-am \ + recheck tags tags-am uninstall uninstall-am \ + uninstall-binPROGRAMS uninstall-man uninstall-man1 \ + uninstall-pkglibexecPROGRAMS + +.PRECIOUS: Makefile + + +# Clean up after Solaris cc. +clean-local: + rm -rf SunWS_cache + +mostlyclean-local: mostlyclean-generic + @for dir in '' $(MOSTLYCLEANDIRS); do \ + if test -n "$$dir" && test -d $$dir; then \ + echo "rmdir $$dir"; rmdir $$dir; \ + fi; \ + done; \ + : + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/gnulib-tests/_Noreturn.h b/gnulib-tests/_Noreturn.h new file mode 100644 index 0000000..394ca3c --- /dev/null +++ b/gnulib-tests/_Noreturn.h @@ -0,0 +1,43 @@ +/* A C macro for declaring that a function does not return. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#ifndef _Noreturn +# if (defined __cplusplus \ + && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \ + || (defined _MSC_VER && 1900 <= _MSC_VER)) \ + && 0) + /* [[noreturn]] is not practically usable, because with it the syntax + extern _Noreturn void func (...); + would not be valid; such a declaration would only be valid with 'extern' + and '_Noreturn' swapped, or without the 'extern' keyword. However, some + AIX system header files and several gnulib header files use precisely + this syntax with 'extern'. */ +# define _Noreturn [[noreturn]] +# elif ((!defined __cplusplus || defined __clang__) \ + && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ + || 4 < __GNUC__ + (7 <= __GNUC_MINOR__) \ + || (defined __apple_build_version__ \ + ? 6000000 <= __apple_build_version__ \ + : 3 < __clang_major__ + (5 <= __clang_minor__)))) + /* _Noreturn works as-is. */ +# elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C +# define _Noreturn __attribute__ ((__noreturn__)) +# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0) +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn +# endif +#endif diff --git a/gnulib-tests/accept.c b/gnulib-tests/accept.c new file mode 100644 index 0000000..9be0211 --- /dev/null +++ b/gnulib-tests/accept.c @@ -0,0 +1,52 @@ +/* accept.c --- wrappers for Windows accept function + + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Paolo Bonzini */ + +#include <config.h> + +#define WIN32_LEAN_AND_MEAN +/* Get winsock2.h. */ +#include <sys/socket.h> + +/* Get set_winsock_errno, FD_TO_SOCKET etc. */ +#include "w32sock.h" + +#undef accept + +int +rpl_accept (int fd, struct sockaddr *addr, socklen_t *addrlen) +{ + SOCKET sock = FD_TO_SOCKET (fd); + + if (sock == INVALID_SOCKET) + { + errno = EBADF; + return -1; + } + else + { + SOCKET fh = accept (sock, addr, addrlen); + if (fh == INVALID_SOCKET) + { + set_winsock_errno (); + return -1; + } + else + return SOCKET_TO_FD (fh); + } +} diff --git a/gnulib-tests/arg-nonnull.h b/gnulib-tests/arg-nonnull.h new file mode 100644 index 0000000..ac26ca8 --- /dev/null +++ b/gnulib-tests/arg-nonnull.h @@ -0,0 +1,26 @@ +/* A C macro for declaring that specific arguments must not be NULL. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools + that the values passed as arguments n, ..., m must be non-NULL pointers. + n = 1 stands for the first argument, n = 2 for the second argument etc. */ +#ifndef _GL_ARG_NONNULL +# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 +# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) +# else +# define _GL_ARG_NONNULL(params) +# endif +#endif diff --git a/gnulib-tests/bench-digest.h b/gnulib-tests/bench-digest.h new file mode 100644 index 0000000..c0a1cd9 --- /dev/null +++ b/gnulib-tests/bench-digest.h @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2018-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <stdio.h> +#include <stdlib.h> +#include <sys/resource.h> +#include <sys/time.h> + +struct timings_state +{ + /* Filled when the timings start. */ + struct timeval real_start; + struct timeval user_start; + struct timeval sys_start; + /* Filled when the timings end. */ + long real_usec; + long user_usec; + long sys_usec; +}; + +static void +timing_start (struct timings_state *ts) +{ + struct rusage usage; + + getrusage (RUSAGE_SELF, &usage); + ts->user_start = usage.ru_utime; + ts->sys_start = usage.ru_stime; + + gettimeofday (&ts->real_start, NULL); +} + +static void +timing_end (struct timings_state *ts) +{ + struct timeval real_end; + struct rusage usage; + + gettimeofday (&real_end, NULL); + + getrusage (RUSAGE_SELF, &usage); + + ts->real_usec = (real_end.tv_sec - ts->real_start.tv_sec) * 1000000 + + real_end.tv_usec - ts->real_start.tv_usec; + ts->user_usec = (usage.ru_utime.tv_sec - ts->user_start.tv_sec) * 1000000 + + usage.ru_utime.tv_usec - ts->user_start.tv_usec; + ts->sys_usec = (usage.ru_stime.tv_sec - ts->sys_start.tv_sec) * 1000000 + + usage.ru_stime.tv_usec - ts->sys_start.tv_usec; +} + +static void +timing_output (const struct timings_state *ts) +{ + printf ("real %10.6f\n", (double)ts->real_usec / 1000000.0); + printf ("user %7.3f\n", (double)ts->user_usec / 1000000.0); + printf ("sys %7.3f\n", (double)ts->sys_usec / 1000000.0); +} + +int +main (int argc, char *argv[]) +{ + if (argc != 3) + { + fprintf (stderr, "Usage: %s SIZE REPETITIONS\n", argv[0]); + exit (1); + } + + size_t size = atol (argv[1]); + int repeat = atoi (argv[2]); + + char *memblock = (char *) malloc (size); + + /* Fill the memory block. */ + { + size_t i; + for (i = 0; i < size; i++) + memblock[i] = + (unsigned char) (((i * (i-1) * (i-5)) >> 6) + (i % 499) + (i % 101)); + } + + struct timings_state ts; + timing_start (&ts); + + int count; + for (count = 0; count < repeat; count++) + { + char digest[64]; + FUNC (memblock, size, digest); + } + + timing_end (&ts); + timing_output (&ts); + + return 0; +} diff --git a/gnulib-tests/bench-md5.c b/gnulib-tests/bench-md5.c new file mode 100644 index 0000000..5e40f75 --- /dev/null +++ b/gnulib-tests/bench-md5.c @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2018-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Benchmark program for the md5_buffer function. */ + +#include <config.h> + +#include "md5.h" + +#define FUNC md5_buffer +#include "bench-digest.h" diff --git a/gnulib-tests/bench-sha1.c b/gnulib-tests/bench-sha1.c new file mode 100644 index 0000000..842ce05 --- /dev/null +++ b/gnulib-tests/bench-sha1.c @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2018-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Benchmark program for the sha1_buffer function. */ + +#include <config.h> + +#include "sha1.h" + +#define FUNC sha1_buffer +#include "bench-digest.h" diff --git a/gnulib-tests/bench-sha224.c b/gnulib-tests/bench-sha224.c new file mode 100644 index 0000000..d2519ec --- /dev/null +++ b/gnulib-tests/bench-sha224.c @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2018-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Benchmark program for the sha224_buffer function. */ + +#include <config.h> + +#include "sha256.h" + +#define FUNC sha224_buffer +#include "bench-digest.h" diff --git a/gnulib-tests/bench-sha256.c b/gnulib-tests/bench-sha256.c new file mode 100644 index 0000000..c2bf648 --- /dev/null +++ b/gnulib-tests/bench-sha256.c @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2018-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Benchmark program for the sha256_buffer function. */ + +#include <config.h> + +#include "sha256.h" + +#define FUNC sha256_buffer +#include "bench-digest.h" diff --git a/gnulib-tests/bench-sha384.c b/gnulib-tests/bench-sha384.c new file mode 100644 index 0000000..4397e0d --- /dev/null +++ b/gnulib-tests/bench-sha384.c @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2018-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Benchmark program for the sha384_buffer function. */ + +#include <config.h> + +#include "sha512.h" + +#define FUNC sha384_buffer +#include "bench-digest.h" diff --git a/gnulib-tests/bench-sha512.c b/gnulib-tests/bench-sha512.c new file mode 100644 index 0000000..513c69a --- /dev/null +++ b/gnulib-tests/bench-sha512.c @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2018-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Benchmark program for the sha512_buffer function. */ + +#include <config.h> + +#include "sha512.h" + +#define FUNC sha512_buffer +#include "bench-digest.h" diff --git a/gnulib-tests/bind.c b/gnulib-tests/bind.c new file mode 100644 index 0000000..3c60a76 --- /dev/null +++ b/gnulib-tests/bind.c @@ -0,0 +1,49 @@ +/* bind.c --- wrappers for Windows bind function + + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Paolo Bonzini */ + +#include <config.h> + +#define WIN32_LEAN_AND_MEAN +/* Get winsock2.h. */ +#include <sys/socket.h> + +/* Get set_winsock_errno, FD_TO_SOCKET etc. */ +#include "w32sock.h" + +#undef bind + +int +rpl_bind (int fd, const struct sockaddr *sockaddr, socklen_t len) +{ + SOCKET sock = FD_TO_SOCKET (fd); + + if (sock == INVALID_SOCKET) + { + errno = EBADF; + return -1; + } + else + { + int r = bind (sock, sockaddr, len); + if (r < 0) + set_winsock_errno (); + + return r; + } +} diff --git a/gnulib-tests/c++defs.h b/gnulib-tests/c++defs.h new file mode 100644 index 0000000..3e6aaab --- /dev/null +++ b/gnulib-tests/c++defs.h @@ -0,0 +1,313 @@ +/* C++ compatible function declaration macros. + Copyright (C) 2010-2020 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 <https://www.gnu.org/licenses/>. */ + +#ifndef _GL_CXXDEFS_H +#define _GL_CXXDEFS_H + +/* Begin/end the GNULIB_NAMESPACE namespace. */ +#if defined __cplusplus && defined GNULIB_NAMESPACE +# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE { +# define _GL_END_NAMESPACE } +#else +# define _GL_BEGIN_NAMESPACE +# define _GL_END_NAMESPACE +#endif + +/* The three most frequent use cases of these macros are: + + * For providing a substitute for a function that is missing on some + platforms, but is declared and works fine on the platforms on which + it exists: + + #if @GNULIB_FOO@ + # if !@HAVE_FOO@ + _GL_FUNCDECL_SYS (foo, ...); + # endif + _GL_CXXALIAS_SYS (foo, ...); + _GL_CXXALIASWARN (foo); + #elif defined GNULIB_POSIXCHECK + ... + #endif + + * For providing a replacement for a function that exists on all platforms, + but is broken/insufficient and needs to be replaced on some platforms: + + #if @GNULIB_FOO@ + # if @REPLACE_FOO@ + # if !(defined __cplusplus && defined GNULIB_NAMESPACE) + # undef foo + # define foo rpl_foo + # endif + _GL_FUNCDECL_RPL (foo, ...); + _GL_CXXALIAS_RPL (foo, ...); + # else + _GL_CXXALIAS_SYS (foo, ...); + # endif + _GL_CXXALIASWARN (foo); + #elif defined GNULIB_POSIXCHECK + ... + #endif + + * For providing a replacement for a function that exists on some platforms + but is broken/insufficient and needs to be replaced on some of them and + is additionally either missing or undeclared on some other platforms: + + #if @GNULIB_FOO@ + # if @REPLACE_FOO@ + # if !(defined __cplusplus && defined GNULIB_NAMESPACE) + # undef foo + # define foo rpl_foo + # endif + _GL_FUNCDECL_RPL (foo, ...); + _GL_CXXALIAS_RPL (foo, ...); + # else + # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ + _GL_FUNCDECL_SYS (foo, ...); + # endif + _GL_CXXALIAS_SYS (foo, ...); + # endif + _GL_CXXALIASWARN (foo); + #elif defined GNULIB_POSIXCHECK + ... + #endif +*/ + +/* _GL_EXTERN_C declaration; + performs the declaration with C linkage. */ +#if defined __cplusplus +# define _GL_EXTERN_C extern "C" +#else +# define _GL_EXTERN_C extern +#endif + +/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); + declares a replacement function, named rpl_func, with the given prototype, + consisting of return type, parameters, and attributes. + Example: + _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) + _GL_ARG_NONNULL ((1))); + */ +#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ + _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) +#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ + _GL_EXTERN_C rettype rpl_func parameters_and_attributes + +/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); + declares the system function, named func, with the given prototype, + consisting of return type, parameters, and attributes. + Example: + _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) + _GL_ARG_NONNULL ((1))); + */ +#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ + _GL_EXTERN_C rettype func parameters_and_attributes + +/* _GL_CXXALIAS_RPL (func, rettype, parameters); + declares a C++ alias called GNULIB_NAMESPACE::func + that redirects to rpl_func, if GNULIB_NAMESPACE is defined. + Example: + _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); + + Wrapping rpl_func in an object with an inline conversion operator + avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is + actually used in the program. */ +#define _GL_CXXALIAS_RPL(func,rettype,parameters) \ + _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) +#if defined __cplusplus && defined GNULIB_NAMESPACE +# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ + namespace GNULIB_NAMESPACE \ + { \ + static const struct _gl_ ## func ## _wrapper \ + { \ + typedef rettype (*type) parameters; \ + \ + inline operator type () const \ + { \ + return ::rpl_func; \ + } \ + } func = {}; \ + } \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#else +# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#endif + +/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); + is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); + except that the C function rpl_func may have a slightly different + declaration. A cast is used to silence the "invalid conversion" error + that would otherwise occur. */ +#if defined __cplusplus && defined GNULIB_NAMESPACE +# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ + namespace GNULIB_NAMESPACE \ + { \ + static const struct _gl_ ## func ## _wrapper \ + { \ + typedef rettype (*type) parameters; \ + \ + inline operator type () const \ + { \ + return reinterpret_cast<type>(::rpl_func); \ + } \ + } func = {}; \ + } \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#else +# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#endif + +/* _GL_CXXALIAS_SYS (func, rettype, parameters); + declares a C++ alias called GNULIB_NAMESPACE::func + that redirects to the system provided function func, if GNULIB_NAMESPACE + is defined. + Example: + _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); + + Wrapping func in an object with an inline conversion operator + avoids a reference to func unless GNULIB_NAMESPACE::func is + actually used in the program. */ +#if defined __cplusplus && defined GNULIB_NAMESPACE +# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ + namespace GNULIB_NAMESPACE \ + { \ + static const struct _gl_ ## func ## _wrapper \ + { \ + typedef rettype (*type) parameters; \ + \ + inline operator type () const \ + { \ + return ::func; \ + } \ + } func = {}; \ + } \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#else +# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#endif + +/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); + is like _GL_CXXALIAS_SYS (func, rettype, parameters); + except that the C function func may have a slightly different declaration. + A cast is used to silence the "invalid conversion" error that would + otherwise occur. */ +#if defined __cplusplus && defined GNULIB_NAMESPACE +# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ + namespace GNULIB_NAMESPACE \ + { \ + static const struct _gl_ ## func ## _wrapper \ + { \ + typedef rettype (*type) parameters; \ + \ + inline operator type () const \ + { \ + return reinterpret_cast<type>(::func); \ + } \ + } func = {}; \ + } \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#else +# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#endif + +/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); + is like _GL_CXXALIAS_SYS (func, rettype, parameters); + except that the C function is picked among a set of overloaded functions, + namely the one with rettype2 and parameters2. Two consecutive casts + are used to silence the "cannot find a match" and "invalid conversion" + errors that would otherwise occur. */ +#if defined __cplusplus && defined GNULIB_NAMESPACE + /* The outer cast must be a reinterpret_cast. + The inner cast: When the function is defined as a set of overloaded + functions, it works as a static_cast<>, choosing the designated variant. + When the function is defined as a single variant, it works as a + reinterpret_cast<>. The parenthesized cast syntax works both ways. */ +# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ + namespace GNULIB_NAMESPACE \ + { \ + static const struct _gl_ ## func ## _wrapper \ + { \ + typedef rettype (*type) parameters; \ + \ + inline operator type () const \ + { \ + return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \ + } \ + } func = {}; \ + } \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#else +# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#endif + +/* _GL_CXXALIASWARN (func); + causes a warning to be emitted when ::func is used but not when + GNULIB_NAMESPACE::func is used. func must be defined without overloaded + variants. */ +#if defined __cplusplus && defined GNULIB_NAMESPACE +# define _GL_CXXALIASWARN(func) \ + _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) +# define _GL_CXXALIASWARN_1(func,namespace) \ + _GL_CXXALIASWARN_2 (func, namespace) +/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, + we enable the warning only when not optimizing. */ +# if !__OPTIMIZE__ +# define _GL_CXXALIASWARN_2(func,namespace) \ + _GL_WARN_ON_USE (func, \ + "The symbol ::" #func " refers to the system function. " \ + "Use " #namespace "::" #func " instead.") +# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING +# define _GL_CXXALIASWARN_2(func,namespace) \ + extern __typeof__ (func) func +# else +# define _GL_CXXALIASWARN_2(func,namespace) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +# endif +#else +# define _GL_CXXALIASWARN(func) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#endif + +/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); + causes a warning to be emitted when the given overloaded variant of ::func + is used but not when GNULIB_NAMESPACE::func is used. */ +#if defined __cplusplus && defined GNULIB_NAMESPACE +# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ + _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ + GNULIB_NAMESPACE) +# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ + _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) +/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, + we enable the warning only when not optimizing. */ +# if !__OPTIMIZE__ +# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ + _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ + "The symbol ::" #func " refers to the system function. " \ + "Use " #namespace "::" #func " instead.") +# else +# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +# endif +#else +# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#endif + +#endif /* _GL_CXXDEFS_H */ diff --git a/gnulib-tests/connect.c b/gnulib-tests/connect.c new file mode 100644 index 0000000..aaf36c8 --- /dev/null +++ b/gnulib-tests/connect.c @@ -0,0 +1,56 @@ +/* connect.c --- wrappers for Windows connect function + + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Paolo Bonzini */ + +#include <config.h> + +#define WIN32_LEAN_AND_MEAN +/* Get winsock2.h. */ +#include <sys/socket.h> + +/* Get set_winsock_errno, FD_TO_SOCKET etc. */ +#include "w32sock.h" + +#undef connect + +int +rpl_connect (int fd, const struct sockaddr *sockaddr, socklen_t len) +{ + SOCKET sock = FD_TO_SOCKET (fd); + + if (sock == INVALID_SOCKET) + { + errno = EBADF; + return -1; + } + else + { + int r = connect (sock, sockaddr, len); + if (r < 0) + { + /* EINPROGRESS is not returned by WinSock 2.0; for backwards + compatibility, connect(2) uses EWOULDBLOCK. */ + if (WSAGetLastError () == WSAEWOULDBLOCK) + WSASetLastError (WSAEINPROGRESS); + + set_winsock_errno (); + } + + return r; + } +} diff --git a/gnulib-tests/getrusage.c b/gnulib-tests/getrusage.c new file mode 100644 index 0000000..5d302d5 --- /dev/null +++ b/gnulib-tests/getrusage.c @@ -0,0 +1,131 @@ +/* getrusage replacement for systems which lack it. + + Copyright (C) 2012-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible, 2012. */ + +#include <config.h> + +/* Specification. */ +#include <sys/resource.h> + +#include <errno.h> +#include <string.h> + +/* Get uint64_t. */ +#include <stdint.h> + +#if defined _WIN32 && ! defined __CYGWIN__ + +# define WIN32_LEAN_AND_MEAN +# include <windows.h> + +#else + +# include <sys/times.h> +# include <unistd.h> +#endif + +int +getrusage (int who, struct rusage *usage_p) +{ + if (who == RUSAGE_SELF || who == RUSAGE_CHILDREN) + { + /* Clear all unsupported members of 'struct rusage'. */ + memset (usage_p, '\0', sizeof (struct rusage)); + +#if defined _WIN32 && ! defined __CYGWIN__ + if (who == RUSAGE_SELF) + { + /* Fill in the ru_utime and ru_stime members. */ + FILETIME creation_time; + FILETIME exit_time; + FILETIME kernel_time; + FILETIME user_time; + + if (GetProcessTimes (GetCurrentProcess (), + &creation_time, &exit_time, + &kernel_time, &user_time)) + { + /* Convert to microseconds, rounding. */ + uint64_t kernel_usec = + ((((uint64_t) kernel_time.dwHighDateTime << 32) + | (uint64_t) kernel_time.dwLowDateTime) + + 5) / 10; + uint64_t user_usec = + ((((uint64_t) user_time.dwHighDateTime << 32) + | (uint64_t) user_time.dwLowDateTime) + + 5) / 10; + + usage_p->ru_utime.tv_sec = user_usec / 1000000U; + usage_p->ru_utime.tv_usec = user_usec % 1000000U; + usage_p->ru_stime.tv_sec = kernel_usec / 1000000U; + usage_p->ru_stime.tv_usec = kernel_usec % 1000000U; + } + } +#else + /* Fill in the ru_utime and ru_stime members. */ + { + struct tms time; + + if (times (&time) != (clock_t) -1) + { + /* Number of clock ticks per second. */ + unsigned int clocks_per_second = sysconf (_SC_CLK_TCK); + + if (clocks_per_second > 0) + { + clock_t user_ticks; + clock_t system_ticks; + + uint64_t user_usec; + uint64_t system_usec; + + if (who == RUSAGE_CHILDREN) + { + user_ticks = time.tms_cutime; + system_ticks = time.tms_cstime; + } + else + { + user_ticks = time.tms_utime; + system_ticks = time.tms_stime; + } + + user_usec = + (((uint64_t) user_ticks * (uint64_t) 1000000U) + + clocks_per_second / 2) / clocks_per_second; + system_usec = + (((uint64_t) system_ticks * (uint64_t) 1000000U) + + clocks_per_second / 2) / clocks_per_second; + + usage_p->ru_utime.tv_sec = user_usec / 1000000U; + usage_p->ru_utime.tv_usec = user_usec % 1000000U; + usage_p->ru_stime.tv_sec = system_usec / 1000000U; + usage_p->ru_stime.tv_usec = system_usec % 1000000U; + } + } + } +#endif + + return 0; + } + else + { + errno = EINVAL; + return -1; + } +} diff --git a/gnulib-tests/glthread/thread.c b/gnulib-tests/glthread/thread.c new file mode 100644 index 0000000..08ef339 --- /dev/null +++ b/gnulib-tests/glthread/thread.c @@ -0,0 +1,205 @@ +/* Creating and controlling threads. + Copyright (C) 2005-2020 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, 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2005. + Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-win32.h. */ + +#include <config.h> + +/* Specification. */ +# define _GLTHREAD_THREAD_INLINE _GL_EXTERN_INLINE +#include "glthread/thread.h" + +#include <stdlib.h> +#include "glthread/lock.h" + +/* ========================================================================= */ + +#if USE_ISOC_THREADS + +struct thrd_with_exitvalue +{ + thrd_t volatile tid; + void * volatile exitvalue; +}; + +/* The Thread-Specific Storage (TSS) key that allows to access each thread's + 'struct thrd_with_exitvalue *' pointer. */ +static tss_t thrd_with_exitvalue_key; + +/* Initializes thrd_with_exitvalue_key. + This function must only be called once. */ +static void +do_init_thrd_with_exitvalue_key (void) +{ + if (tss_create (&thrd_with_exitvalue_key, NULL) != thrd_success) + abort (); +} + +/* Initializes thrd_with_exitvalue_key. */ +static void +init_thrd_with_exitvalue_key (void) +{ + static once_flag once = ONCE_FLAG_INIT; + call_once (&once, do_init_thrd_with_exitvalue_key); +} + +typedef union + { + struct thrd_with_exitvalue t; + struct + { + thrd_t tid; /* reserve memory for t.tid */ + void *(*mainfunc) (void *); + void *arg; + } a; + } + main_arg_t; + +static int +thrd_main_func (void *pmarg) +{ + /* Unpack the object that combines mainfunc and arg. */ + main_arg_t *main_arg = (main_arg_t *) pmarg; + void *(*mainfunc) (void *) = main_arg->a.mainfunc; + void *arg = main_arg->a.arg; + + if (tss_set (thrd_with_exitvalue_key, &main_arg->t) != thrd_success) + abort (); + + /* Execute mainfunc, with arg as argument. */ + { + void *exitvalue = mainfunc (arg); + /* Store the exitvalue, for use by glthread_join(). */ + main_arg->t.exitvalue = exitvalue; + return 0; + } +} + +int +glthread_create (gl_thread_t *threadp, void *(*mainfunc) (void *), void *arg) +{ + init_thrd_with_exitvalue_key (); + { + /* Combine mainfunc and arg in a single object. + A stack-allocated object does not work, because it would be out of + existence when thrd_create returns before thrd_main_func is + entered. So, allocate it in the heap. */ + main_arg_t *main_arg = (main_arg_t *) malloc (sizeof (main_arg_t)); + if (main_arg == NULL) + return ENOMEM; + main_arg->a.mainfunc = mainfunc; + main_arg->a.arg = arg; + switch (thrd_create ((thrd_t *) &main_arg->t.tid, thrd_main_func, main_arg)) + { + case thrd_success: + break; + case thrd_nomem: + free (main_arg); + return ENOMEM; + default: + free (main_arg); + return EAGAIN; + } + *threadp = &main_arg->t; + return 0; + } +} + +gl_thread_t +gl_thread_self (void) +{ + init_thrd_with_exitvalue_key (); + { + gl_thread_t thread = + (struct thrd_with_exitvalue *) tss_get (thrd_with_exitvalue_key); + if (thread == NULL) + { + /* This happens only in threads that have not been created through + glthread_create(), such as the main thread. */ + for (;;) + { + thread = + (struct thrd_with_exitvalue *) + malloc (sizeof (struct thrd_with_exitvalue)); + if (thread != NULL) + break; + /* Memory allocation failed. There is not much we can do. Have to + busy-loop, waiting for the availability of memory. */ + { + struct timespec ts; + ts.tv_sec = 1; + ts.tv_nsec = 0; + thrd_sleep (&ts, NULL); + } + } + thread->tid = thrd_current (); + thread->exitvalue = NULL; /* just to be deterministic */ + if (tss_set (thrd_with_exitvalue_key, thread) != thrd_success) + abort (); + } + return thread; + } +} + +int +glthread_join (gl_thread_t thread, void **return_value_ptr) +{ + /* On Solaris 11.4, thrd_join crashes when the second argument we pass is + NULL. */ + int dummy; + + if (thread == gl_thread_self ()) + return EINVAL; + if (thrd_join (thread->tid, &dummy) != thrd_success) + return EINVAL; + if (return_value_ptr != NULL) + *return_value_ptr = thread->exitvalue; + free (thread); + return 0; +} + +_Noreturn void +gl_thread_exit (void *return_value) +{ + gl_thread_t thread = gl_thread_self (); + thread->exitvalue = return_value; + thrd_exit (0); +} + +#endif + +/* ========================================================================= */ + +#if USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS + +#include <pthread.h> + +#if defined PTW32_VERSION || defined __MVS__ + +const gl_thread_t gl_null_thread /* = { .p = NULL } */; + +#endif + +#endif + +/* ========================================================================= */ + +#if USE_WINDOWS_THREADS + +#endif + +/* ========================================================================= */ diff --git a/gnulib-tests/glthread/thread.h b/gnulib-tests/glthread/thread.h new file mode 100644 index 0000000..a980e65 --- /dev/null +++ b/gnulib-tests/glthread/thread.h @@ -0,0 +1,356 @@ +/* Creating and controlling threads. + Copyright (C) 2005-2020 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, 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2005. + Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-win32.h. */ + +/* This file contains primitives for creating and controlling threads. + + Thread data type: gl_thread_t. + + Creating a thread: + thread = gl_thread_create (func, arg); + Or with control of error handling: + err = glthread_create (&thread, func, arg); + extern int glthread_create (gl_thread_t *result, + void *(*func) (void *), void *arg); + + Querying and changing the signal mask of a thread (not supported on all + platforms): + gl_thread_sigmask (how, newmask, oldmask); + Or with control of error handling: + err = glthread_sigmask (how, newmask, oldmask); + extern int glthread_sigmask (int how, const sigset_t *newmask, sigset_t *oldmask); + + Waiting for termination of another thread: + gl_thread_join (thread, &return_value); + Or with control of error handling: + err = glthread_join (thread, &return_value); + extern int glthread_join (gl_thread_t thread, void **return_value_ptr); + + Getting a reference to the current thread: + current = gl_thread_self (); + extern gl_thread_t gl_thread_self (void); + + Getting a reference to the current thread as a pointer, for debugging: + ptr = gl_thread_self_pointer (); + extern void * gl_thread_self_pointer (void); + + Terminating the current thread: + gl_thread_exit (return_value); + extern _Noreturn void gl_thread_exit (void *return_value); + + Requesting custom code to be executed at fork() time (not supported on all + platforms): + gl_thread_atfork (prepare_func, parent_func, child_func); + Or with control of error handling: + err = glthread_atfork (prepare_func, parent_func, child_func); + extern int glthread_atfork (void (*prepare_func) (void), + void (*parent_func) (void), + void (*child_func) (void)); + Note that even on platforms where this is supported, use of fork() and + threads together is problematic, see + <https://lists.gnu.org/r/bug-gnulib/2008-08/msg00062.html> + */ + + +#ifndef _GLTHREAD_THREAD_H +#define _GLTHREAD_THREAD_H + +#include <errno.h> +#include <stdlib.h> + +#if !defined c11_threads_in_use +# if HAVE_THREADS_H && USE_POSIX_THREADS_WEAK +# include <threads.h> +# pragma weak thrd_exit +# define c11_threads_in_use() (thrd_exit != NULL) +# else +# define c11_threads_in_use() 0 +# endif +#endif + +#ifndef _GL_INLINE_HEADER_BEGIN + #error "Please include config.h first." +#endif +_GL_INLINE_HEADER_BEGIN +#ifndef _GLTHREAD_THREAD_INLINE +# define _GLTHREAD_THREAD_INLINE _GL_INLINE +#endif + +/* ========================================================================= */ + +#if USE_ISOC_THREADS + +/* Use the ISO C threads library. */ + +# include <threads.h> + +# ifdef __cplusplus +extern "C" { +# endif + +/* -------------------------- gl_thread_t datatype -------------------------- */ + +typedef struct thrd_with_exitvalue *gl_thread_t; +extern int glthread_create (gl_thread_t *threadp, + void *(*func) (void *), void *arg); +# define glthread_sigmask(HOW, SET, OSET) \ + pthread_sigmask (HOW, SET, OSET) +extern int glthread_join (gl_thread_t thread, void **return_value_ptr); +extern gl_thread_t gl_thread_self (void); +# define gl_thread_self_pointer() \ + (void *) gl_thread_self () +extern _Noreturn void gl_thread_exit (void *return_value); +# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0 + +# ifdef __cplusplus +} +# endif + +#endif + +/* ========================================================================= */ + +#if USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS + +/* Use the POSIX threads library. */ + +# include <pthread.h> + +/* On IRIX, pthread_atfork is declared in <unistd.h>, not in <pthread.h>. */ +# if defined __sgi +# include <unistd.h> +# endif + +# if USE_POSIX_THREADS_WEAK +/* Compilers other than GCC need to see the declaration of pthread_sigmask + before the "#pragma weak pthread_sigmask" below. */ +# include <signal.h> +# endif + +# ifdef __cplusplus +extern "C" { +# endif + +# if PTHREAD_IN_USE_DETECTION_HARD + +/* The pthread_in_use() detection needs to be done at runtime. */ +# define pthread_in_use() \ + glthread_in_use () +extern int glthread_in_use (void); + +# endif + +# if USE_POSIX_THREADS_WEAK + +/* Use weak references to the POSIX threads library. */ + +/* Weak references avoid dragging in external libraries if the other parts + of the program don't use them. Here we use them, because we don't want + every program that uses libintl to depend on libpthread. This assumes + that libpthread would not be loaded after libintl; i.e. if libintl is + loaded first, by an executable that does not depend on libpthread, and + then a module is dynamically loaded that depends on libpthread, libintl + will not be multithread-safe. */ + +/* The way to test at runtime whether libpthread is present is to test + whether a function pointer's value, such as &pthread_mutex_init, is + non-NULL. However, some versions of GCC have a bug through which, in + PIC mode, &foo != NULL always evaluates to true if there is a direct + call to foo(...) in the same function. To avoid this, we test the + address of a function in libpthread that we don't use. */ + +# ifndef pthread_sigmask /* Do not declare rpl_pthread_sigmask weak. */ +# pragma weak pthread_sigmask +# endif + +# pragma weak pthread_join +# ifndef pthread_self +# pragma weak pthread_self +# endif +# pragma weak pthread_exit +# if HAVE_PTHREAD_ATFORK +# pragma weak pthread_atfork +# endif + +# if !PTHREAD_IN_USE_DETECTION_HARD +# pragma weak pthread_mutexattr_gettype +# define pthread_in_use() \ + (pthread_mutexattr_gettype != NULL || c11_threads_in_use ()) +# endif + +# else + +# if !PTHREAD_IN_USE_DETECTION_HARD +# define pthread_in_use() 1 +# endif + +# endif + +/* -------------------------- gl_thread_t datatype -------------------------- */ + +/* This choice of gl_thread_t assumes that + pthread_equal (a, b) is equivalent to ((a) == (b)). + This is the case on all platforms in use in 2008. */ +typedef pthread_t gl_thread_t; +# define glthread_create(THREADP, FUNC, ARG) \ + (pthread_in_use () ? pthread_create (THREADP, NULL, FUNC, ARG) : ENOSYS) +# define glthread_sigmask(HOW, SET, OSET) \ + (pthread_in_use () ? pthread_sigmask (HOW, SET, OSET) : 0) +# define glthread_join(THREAD, RETVALP) \ + (pthread_in_use () ? pthread_join (THREAD, RETVALP) : 0) +# ifdef PTW32_VERSION + /* In pthreads-win32, pthread_t is a struct with a pointer field 'p' and + other fields. */ +# define gl_thread_self() \ + (pthread_in_use () ? pthread_self () : gl_null_thread) +# define gl_thread_self_pointer() \ + (pthread_in_use () ? pthread_self ().p : NULL) +extern const gl_thread_t gl_null_thread; +# elif defined __MVS__ + /* On IBM z/OS, pthread_t is a struct with an 8-byte '__' field. + The first three bytes of this field appear to uniquely identify a + pthread_t, though not necessarily representing a pointer. */ +# define gl_thread_self() \ + (pthread_in_use () ? pthread_self () : gl_null_thread) +# define gl_thread_self_pointer() \ + (pthread_in_use () ? *((void **) pthread_self ().__) : NULL) +extern const gl_thread_t gl_null_thread; +# else +# define gl_thread_self() \ + (pthread_in_use () ? pthread_self () : (pthread_t) NULL) +# define gl_thread_self_pointer() \ + (pthread_in_use () ? (void *) pthread_self () : NULL) +# endif +# define gl_thread_exit(RETVAL) \ + (pthread_in_use () ? pthread_exit (RETVAL) : 0) + +# if HAVE_PTHREAD_ATFORK +# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) \ + (pthread_in_use () ? pthread_atfork (PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) : 0) +# else +# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0 +# endif + +# ifdef __cplusplus +} +# endif + +#endif + +/* ========================================================================= */ + +#if USE_WINDOWS_THREADS + +# define WIN32_LEAN_AND_MEAN /* avoid including junk */ +# include <windows.h> + +# include "windows-thread.h" + +# ifdef __cplusplus +extern "C" { +# endif + +/* -------------------------- gl_thread_t datatype -------------------------- */ + +typedef glwthread_thread_t gl_thread_t; +# define glthread_create(THREADP, FUNC, ARG) \ + glwthread_thread_create (THREADP, 0, FUNC, ARG) +# define glthread_sigmask(HOW, SET, OSET) \ + /* unsupported */ 0 +# define glthread_join(THREAD, RETVALP) \ + glwthread_thread_join (THREAD, RETVALP) +# define gl_thread_self() \ + glwthread_thread_self () +# define gl_thread_self_pointer() \ + gl_thread_self () +# define gl_thread_exit(RETVAL) \ + glwthread_thread_exit (RETVAL) +# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0 + +# ifdef __cplusplus +} +# endif + +#endif + +/* ========================================================================= */ + +#if !(USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS || USE_WINDOWS_THREADS) + +/* Provide dummy implementation if threads are not supported. */ + +typedef int gl_thread_t; +# define glthread_create(THREADP, FUNC, ARG) ENOSYS +# define glthread_sigmask(HOW, SET, OSET) 0 +# define glthread_join(THREAD, RETVALP) 0 +# define gl_thread_self() 0 +# define gl_thread_self_pointer() \ + ((void *) gl_thread_self ()) +# define gl_thread_exit(RETVAL) 0 +# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0 + +#endif + +/* ========================================================================= */ + +/* Macros with built-in error handling. */ + +#ifdef __cplusplus +extern "C" { +#endif + +_GLTHREAD_THREAD_INLINE gl_thread_t +gl_thread_create (void *(*func) (void *arg), void *arg) +{ + gl_thread_t thread; + int ret; + + ret = glthread_create (&thread, func, arg); + if (ret != 0) + abort (); + return thread; +} +#define gl_thread_sigmask(HOW, SET, OSET) \ + do \ + { \ + if (glthread_sigmask (HOW, SET, OSET)) \ + abort (); \ + } \ + while (0) +#define gl_thread_join(THREAD, RETVAL) \ + do \ + { \ + if (glthread_join (THREAD, RETVAL)) \ + abort (); \ + } \ + while (0) +#define gl_thread_atfork(PREPARE, PARENT, CHILD) \ + do \ + { \ + if (glthread_atfork (PREPARE, PARENT, CHILD)) \ + abort (); \ + } \ + while (0) + +#ifdef __cplusplus +} +#endif + +_GL_INLINE_HEADER_END + +#endif /* _GLTHREAD_THREAD_H */ diff --git a/gnulib-tests/glthread/yield.h b/gnulib-tests/glthread/yield.h new file mode 100644 index 0000000..dd1f50c --- /dev/null +++ b/gnulib-tests/glthread/yield.h @@ -0,0 +1,100 @@ +/* Yielding the processor to other threads and processes. + Copyright (C) 2005-2020 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, 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 <https://www.gnu.org/licenses/>. */ + +/* This file contains a primitive for yielding the processor to other threads. + extern void gl_thread_yield (void); + */ + +#ifndef _GLTHREAD_YIELD_H +#define _GLTHREAD_YIELD_H + +#include <errno.h> + +/* ========================================================================= */ + +#if USE_ISOC_THREADS || USE_ISOC_AND_POSIX_THREADS + +/* Use the ISO C threads library. */ + +# include <threads.h> + +# ifdef __cplusplus +extern "C" { +# endif + +# define gl_thread_yield() \ + thrd_yield () + +# ifdef __cplusplus +} +# endif + +#endif + +/* ========================================================================= */ + +#if USE_POSIX_THREADS + +/* Use the POSIX threads library. */ + +# include <sched.h> + +# ifdef __cplusplus +extern "C" { +# endif + +# define gl_thread_yield() \ + sched_yield () + +# ifdef __cplusplus +} +# endif + +#endif + +/* ========================================================================= */ + +#if USE_WINDOWS_THREADS + +# define WIN32_LEAN_AND_MEAN /* avoid including junk */ +# include <windows.h> + +# ifdef __cplusplus +extern "C" { +# endif + +# define gl_thread_yield() \ + Sleep (0) + +# ifdef __cplusplus +} +# endif + +#endif + +/* ========================================================================= */ + +#if !(USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS || USE_WINDOWS_THREADS) + +/* Provide dummy implementation if threads are not supported. */ + +# define gl_thread_yield() 0 + +#endif + +/* ========================================================================= */ + +#endif /* _GLTHREAD_YIELD_H */ diff --git a/gnulib-tests/gnulib.mk b/gnulib-tests/gnulib.mk new file mode 100644 index 0000000..13551cf --- /dev/null +++ b/gnulib-tests/gnulib.mk @@ -0,0 +1,2899 @@ +## DO NOT EDIT! GENERATED AUTOMATICALLY! +## Process this file with automake to produce Makefile.in. +# Copyright (C) 2002-2020 Free Software Foundation, Inc. +# +# This file 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 file 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 file. If not, see <https://www.gnu.org/licenses/>. +# +# As a special exception to the GNU General Public License, +# this file may be distributed as part of a program that +# contains a configuration script generated by Autoconf, under +# the same distribution terms as the rest of that program. +# +# Generated by gnulib-tool. + +AUTOMAKE_OPTIONS = 1.11 foreign subdir-objects + +SUBDIRS = . +TESTS = +XFAIL_TESTS = +TESTS_ENVIRONMENT = +noinst_PROGRAMS = +check_PROGRAMS = +EXTRA_PROGRAMS = +noinst_HEADERS = +noinst_LIBRARIES = +check_LIBRARIES = libtests.a +EXTRA_DIST = +BUILT_SOURCES = +SUFFIXES = +MOSTLYCLEANFILES = core *.stackdump +MOSTLYCLEANDIRS = +CLEANFILES = +DISTCLEANFILES = +MAINTAINERCLEANFILES = + +AM_CPPFLAGS = \ + -D@gltests_WITNESS@=1 \ + -I. -I$(srcdir) \ + -I.. -I$(srcdir)/.. \ + -I../lib -I$(srcdir)/../lib + +LDADD = libtests.a ../lib/libcoreutils.a libtests.a $(LIBTESTS_LIBDEPS) + +libtests_a_SOURCES = +libtests_a_LIBADD = $(gltests_LIBOBJS) +libtests_a_DEPENDENCIES = $(gltests_LIBOBJS) +EXTRA_libtests_a_SOURCES = +AM_LIBTOOLFLAGS = --preserve-dup-deps + +TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='$(srcdir)' + +## begin gnulib module accept + + +EXTRA_DIST += accept.c w32sock.h + +EXTRA_libtests_a_SOURCES += accept.c + +## end gnulib module accept + +## begin gnulib module accept-tests + +TESTS += test-accept +check_PROGRAMS += test-accept +test_accept_LDADD = $(LDADD) @LIBSOCKET@ +EXTRA_DIST += test-accept.c signature.h macros.h + +## end gnulib module accept-tests + +## begin gnulib module acl-tests + +TESTS += \ + test-set-mode-acl.sh test-set-mode-acl-1.sh test-set-mode-acl-2.sh \ + test-copy-acl.sh test-copy-acl-1.sh test-copy-acl-2.sh +TESTS_ENVIRONMENT += USE_ACL=$(USE_ACL) +check_PROGRAMS += test-set-mode-acl test-copy-acl test-sameacls +test_set_mode_acl_LDADD = $(LDADD) $(LIB_ACL) @LIBINTL@ $(LIB_MBRTOWC) +test_copy_acl_LDADD = $(LDADD) $(LIB_ACL) @LIBINTL@ $(LIB_MBRTOWC) +test_sameacls_LDADD = $(LDADD) $(LIB_ACL) @LIBINTL@ $(LIB_MBRTOWC) +EXTRA_DIST += test-set-mode-acl.sh test-set-mode-acl-1.sh test-set-mode-acl-2.sh test-copy-acl.sh test-copy-acl-1.sh test-copy-acl-2.sh test-set-mode-acl.c test-copy-acl.c test-sameacls.c macros.h + +## end gnulib module acl-tests + +## begin gnulib module alignof-tests + +TESTS += test-alignof +check_PROGRAMS += test-alignof + +EXTRA_DIST += test-alignof.c + +## end gnulib module alignof-tests + +## begin gnulib module alloca-opt-tests + +TESTS += test-alloca-opt +check_PROGRAMS += test-alloca-opt + +EXTRA_DIST += test-alloca-opt.c + +## end gnulib module alloca-opt-tests + +## begin gnulib module areadlink-tests + +TESTS += test-areadlink +check_PROGRAMS += test-areadlink +EXTRA_DIST += test-areadlink.h test-areadlink.c macros.h + +## end gnulib module areadlink-tests + +## begin gnulib module areadlink-with-size-tests + +TESTS += test-areadlink-with-size +check_PROGRAMS += test-areadlink-with-size +EXTRA_DIST += test-areadlink.h test-areadlink-with-size.c macros.h + +## end gnulib module areadlink-with-size-tests + +## begin gnulib module areadlinkat-tests + +TESTS += test-areadlinkat +check_PROGRAMS += test-areadlinkat +test_areadlinkat_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-areadlink.h test-areadlinkat.c macros.h + +## end gnulib module areadlinkat-tests + +## begin gnulib module argmatch-tests + +TESTS += test-argmatch +check_PROGRAMS += test-argmatch +test_argmatch_LDADD = $(LDADD) @LIBINTL@ $(LIB_MBRTOWC) + +EXTRA_DIST += test-argmatch.c macros.h + +## end gnulib module argmatch-tests + +## begin gnulib module argv-iter-tests + +TESTS += test-argv-iter +check_PROGRAMS += test-argv-iter +EXTRA_DIST += test-argv-iter.c macros.h + +## end gnulib module argv-iter-tests + +## begin gnulib module arpa_inet-tests + +TESTS += test-arpa_inet +check_PROGRAMS += test-arpa_inet +EXTRA_DIST += test-arpa_inet.c + +## end gnulib module arpa_inet-tests + +## begin gnulib module base32-tests + +TESTS += test-base32 +check_PROGRAMS += test-base32 +EXTRA_DIST += test-base32.c macros.h + +## end gnulib module base32-tests + +## begin gnulib module base64-tests + +TESTS += test-base64 +check_PROGRAMS += test-base64 +EXTRA_DIST += test-base64.c macros.h + +## end gnulib module base64-tests + +## begin gnulib module binary-io-tests + +TESTS += test-binary-io.sh +check_PROGRAMS += test-binary-io + +EXTRA_DIST += test-binary-io.sh test-binary-io.c macros.h + +## end gnulib module binary-io-tests + +## begin gnulib module bind + + +EXTRA_DIST += bind.c w32sock.h + +EXTRA_libtests_a_SOURCES += bind.c + +## end gnulib module bind + +## begin gnulib module bind-tests + +TESTS += test-bind +check_PROGRAMS += test-bind +test_bind_LDADD = $(LDADD) @LIBSOCKET@ $(INET_PTON_LIB) +EXTRA_DIST += test-bind.c signature.h macros.h + +## end gnulib module bind-tests + +## begin gnulib module bitrotate-tests + +TESTS += test-bitrotate +check_PROGRAMS += test-bitrotate +EXTRA_DIST += test-bitrotate.c macros.h + +## end gnulib module bitrotate-tests + +## begin gnulib module btowc-tests + +TESTS += test-btowc1.sh test-btowc2.sh +TESTS_ENVIRONMENT += LOCALE_FR='@LOCALE_FR@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' +check_PROGRAMS += test-btowc +test_btowc_LDADD = $(LDADD) $(LIB_SETLOCALE) +EXTRA_DIST += test-btowc1.sh test-btowc2.sh test-btowc.c signature.h macros.h + +## end gnulib module btowc-tests + +## begin gnulib module byteswap-tests + +TESTS += test-byteswap +check_PROGRAMS += test-byteswap +EXTRA_DIST += test-byteswap.c macros.h + +## end gnulib module byteswap-tests + +## begin gnulib module c-ctype-tests + +TESTS += test-c-ctype +check_PROGRAMS += test-c-ctype +test_c_ctype_LDADD = $(LDADD) $(LIB_SETLOCALE) +EXTRA_DIST += test-c-ctype.c macros.h + +## end gnulib module c-ctype-tests + +## begin gnulib module c-strcase-tests + +TESTS += test-c-strcase.sh +TESTS_ENVIRONMENT += LOCALE_FR='@LOCALE_FR@' LOCALE_TR_UTF8='@LOCALE_TR_UTF8@' +check_PROGRAMS += test-c-strcasecmp test-c-strncasecmp +test_c_strcasecmp_LDADD = $(LDADD) $(LIB_SETLOCALE) +test_c_strncasecmp_LDADD = $(LDADD) $(LIB_SETLOCALE) +EXTRA_DIST += test-c-strcase.sh test-c-strcasecmp.c test-c-strncasecmp.c macros.h + +## end gnulib module c-strcase-tests + +## begin gnulib module calloc-gnu-tests + +TESTS += test-calloc-gnu +check_PROGRAMS += test-calloc-gnu +EXTRA_DIST += test-calloc-gnu.c + +## end gnulib module calloc-gnu-tests + +## begin gnulib module canonicalize-tests + +TESTS += test-canonicalize +check_PROGRAMS += test-canonicalize +test_canonicalize_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-canonicalize.c null-ptr.h macros.h + +## end gnulib module canonicalize-tests + +## begin gnulib module chdir-tests + +TESTS += test-chdir +check_PROGRAMS += test-chdir +EXTRA_DIST += test-chdir.c signature.h macros.h + +## end gnulib module chdir-tests + +## begin gnulib module chown-tests + +TESTS += test-chown +check_PROGRAMS += test-chown +test_chown_LDADD = $(LDADD) $(LIB_NANOSLEEP) +EXTRA_DIST += nap.h test-chown.h test-chown.c signature.h macros.h + +## end gnulib module chown-tests + +## begin gnulib module cloexec-tests + +TESTS += test-cloexec +check_PROGRAMS += test-cloexec +EXTRA_DIST += test-cloexec.c macros.h + +## end gnulib module cloexec-tests + +## begin gnulib module close-tests + +TESTS += test-close +check_PROGRAMS += test-close +EXTRA_DIST += test-close.c signature.h macros.h + +## end gnulib module close-tests + +## begin gnulib module closein-tests + +TESTS += test-closein.sh +check_PROGRAMS += test-closein +test_closein_LDADD = $(LDADD) @LIBINTL@ $(LIB_MBRTOWC) +EXTRA_DIST += test-closein.sh test-closein.c + +## end gnulib module closein-tests + +## begin gnulib module connect + + +EXTRA_DIST += connect.c w32sock.h + +EXTRA_libtests_a_SOURCES += connect.c + +## end gnulib module connect + +## begin gnulib module connect-tests + +TESTS += test-connect +check_PROGRAMS += test-connect +test_connect_LDADD = $(LDADD) @LIBSOCKET@ $(INET_PTON_LIB) +EXTRA_DIST += test-connect.c signature.h macros.h + +## end gnulib module connect-tests + +## begin gnulib module count-leading-zeros-tests + +TESTS += test-count-leading-zeros +check_PROGRAMS += test-count-leading-zeros +EXTRA_DIST += test-count-leading-zeros.c macros.h + +## end gnulib module count-leading-zeros-tests + +## begin gnulib module crypto/md5-tests + +TESTS += test-md5 +check_PROGRAMS += test-md5 +noinst_PROGRAMS += bench-md5 +test_md5_LDADD = $(LDADD) @LIB_CRYPTO@ +bench_md5_LDADD = $(LDADD) @LIB_CRYPTO@ +EXTRA_DIST += test-md5.c test-digest.h bench-md5.c bench-digest.h macros.h + +## end gnulib module crypto/md5-tests + +## begin gnulib module crypto/sha1-tests + +TESTS += test-sha1 +check_PROGRAMS += test-sha1 +noinst_PROGRAMS += bench-sha1 +test_sha1_LDADD = $(LDADD) @LIB_CRYPTO@ +bench_sha1_LDADD = $(LDADD) @LIB_CRYPTO@ +EXTRA_DIST += test-sha1.c test-digest.h bench-sha1.c bench-digest.h macros.h + +## end gnulib module crypto/sha1-tests + +## begin gnulib module crypto/sha256-tests + +TESTS += test-sha256 +check_PROGRAMS += test-sha256 +noinst_PROGRAMS += bench-sha224 bench-sha256 +test_sha256_LDADD = $(LDADD) @LIB_CRYPTO@ +bench_sha224_LDADD = $(LDADD) @LIB_CRYPTO@ +bench_sha256_LDADD = $(LDADD) @LIB_CRYPTO@ +EXTRA_DIST += test-sha256.c test-digest.h bench-sha224.c bench-sha256.c bench-digest.h macros.h + +## end gnulib module crypto/sha256-tests + +## begin gnulib module crypto/sha512-tests + +TESTS += test-sha512 +check_PROGRAMS += test-sha512 +noinst_PROGRAMS += bench-sha384 bench-sha512 +test_sha512_LDADD = $(LDADD) @LIB_CRYPTO@ +bench_sha384_LDADD = $(LDADD) @LIB_CRYPTO@ +bench_sha512_LDADD = $(LDADD) @LIB_CRYPTO@ +EXTRA_DIST += test-sha512.c test-digest.h bench-sha384.c bench-sha512.c bench-digest.h macros.h + +## end gnulib module crypto/sha512-tests + +## begin gnulib module ctype-tests + +TESTS += test-ctype +check_PROGRAMS += test-ctype +EXTRA_DIST += test-ctype.c + +## end gnulib module ctype-tests + +## begin gnulib module di-set-tests + +TESTS += test-di-set +check_PROGRAMS += test-di-set +EXTRA_DIST += test-di-set.c macros.h + +## end gnulib module di-set-tests + +## begin gnulib module dirent-safer-tests + +TESTS += test-dirent-safer +check_PROGRAMS += test-dirent-safer +# Link with libintl when needed. dirent-safer uses fdopendir if it is present, +# and fdopendir indirectly depends on openat-die -> gettext-h. +test_dirent_safer_LDADD = $(LDADD) $(LIBINTL) +EXTRA_DIST += test-dirent-safer.c macros.h + +## end gnulib module dirent-safer-tests + +## begin gnulib module dirent-tests + +TESTS += test-dirent +check_PROGRAMS += test-dirent +EXTRA_DIST += test-dirent.c + +## end gnulib module dirent-tests + +## begin gnulib module dirname-tests + +TESTS += test-dirname +check_PROGRAMS += test-dirname +test_dirname_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-dirname.c + +## end gnulib module dirname-tests + +## begin gnulib module dup-tests + +TESTS += test-dup +check_PROGRAMS += test-dup +EXTRA_DIST += test-dup.c signature.h macros.h + +## end gnulib module dup-tests + +## begin gnulib module dup2-tests + +TESTS += test-dup2 +check_PROGRAMS += test-dup2 +EXTRA_DIST += test-dup2.c signature.h macros.h + +## end gnulib module dup2-tests + +## begin gnulib module environ-tests + +TESTS += test-environ +check_PROGRAMS += test-environ + +EXTRA_DIST += test-environ.c + +## end gnulib module environ-tests + +## begin gnulib module errno-tests + +TESTS += test-errno +check_PROGRAMS += test-errno + +EXTRA_DIST += test-errno.c + +## end gnulib module errno-tests + +## begin gnulib module exclude-tests + +TESTS += \ + test-exclude1.sh\ + test-exclude2.sh\ + test-exclude3.sh\ + test-exclude4.sh\ + test-exclude5.sh\ + test-exclude6.sh\ + test-exclude7.sh\ + test-exclude8.sh + +check_PROGRAMS += test-exclude +test_exclude_LDADD = $(LDADD) @LIBINTL@ $(LIB_MBRTOWC) $(LIBTHREAD) +EXTRA_DIST += test-exclude.c test-exclude1.sh test-exclude2.sh test-exclude3.sh test-exclude4.sh test-exclude5.sh test-exclude6.sh test-exclude7.sh test-exclude8.sh + +## end gnulib module exclude-tests + +## begin gnulib module faccessat-tests + +TESTS += test-faccessat +check_PROGRAMS += test-faccessat +test_faccessat_LDADD = $(LDADD) $(LIB_EACCESS) @LIBINTL@ +EXTRA_DIST += test-faccessat.c signature.h macros.h + +## end gnulib module faccessat-tests + +## begin gnulib module fadvise-tests + +TESTS += test-fadvise +check_PROGRAMS += test-fadvise +EXTRA_DIST += test-fadvise.c + +## end gnulib module fadvise-tests + +## begin gnulib module fchdir-tests + +TESTS += test-fchdir +check_PROGRAMS += test-fchdir +test_fchdir_LDADD = $(LDADD) $(LIBINTL) +EXTRA_DIST += test-fchdir.c signature.h macros.h + +## end gnulib module fchdir-tests + +## begin gnulib module fchmodat-tests + +TESTS += test-fchmodat +check_PROGRAMS += test-fchmodat +test_fchmodat_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-fchmodat.c signature.h macros.h + +## end gnulib module fchmodat-tests + +## begin gnulib module fchownat-tests + +TESTS += test-fchownat +check_PROGRAMS += test-fchownat +test_fchownat_LDADD = $(LDADD) $(LIB_NANOSLEEP) @LIBINTL@ +EXTRA_DIST += nap.h test-chown.h test-lchown.h test-fchownat.c signature.h macros.h + +## end gnulib module fchownat-tests + +## begin gnulib module fclose-tests + +TESTS += test-fclose +check_PROGRAMS += test-fclose +EXTRA_DIST += test-fclose.c + +## end gnulib module fclose-tests + +## begin gnulib module fcntl-h-tests + +TESTS += test-fcntl-h +check_PROGRAMS += test-fcntl-h +EXTRA_DIST += test-fcntl-h.c + +## end gnulib module fcntl-h-tests + +## begin gnulib module fcntl-safer-tests + +TESTS += test-fcntl-safer +check_PROGRAMS += test-fcntl-safer +EXTRA_DIST += test-open.h test-fcntl-safer.c macros.h + +## end gnulib module fcntl-safer-tests + +## begin gnulib module fcntl-tests + +TESTS += test-fcntl +check_PROGRAMS += test-fcntl +EXTRA_DIST += test-fcntl.c signature.h macros.h + +## end gnulib module fcntl-tests + +## begin gnulib module fdatasync-tests + +TESTS += test-fdatasync +check_PROGRAMS += test-fdatasync +test_fdatasync_LDADD = $(LDADD) $(LIB_FDATASYNC) +EXTRA_DIST += test-fdatasync.c signature.h macros.h + +## end gnulib module fdatasync-tests + +## begin gnulib module fdopen-tests + +TESTS += test-fdopen +check_PROGRAMS += test-fdopen +EXTRA_DIST += test-fdopen.c signature.h macros.h + +## end gnulib module fdopen-tests + +## begin gnulib module fdopendir-tests + +TESTS += test-fdopendir +check_PROGRAMS += test-fdopendir +test_fdopendir_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-fdopendir.c signature.h macros.h + +## end gnulib module fdopendir-tests + +## begin gnulib module fdutimensat-tests + +TESTS += test-fdutimensat +check_PROGRAMS += test-fdutimensat +test_fdutimensat_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) \ + $(LIB_NANOSLEEP) @LIBINTL@ +EXTRA_DIST += nap.h test-futimens.h test-lutimens.h test-utimens.h test-utimens-common.h test-fdutimensat.c macros.h + +## end gnulib module fdutimensat-tests + +## begin gnulib module fflush-tests + +TESTS += test-fflush test-fflush2.sh +check_PROGRAMS += test-fflush test-fflush2 +MOSTLYCLEANFILES += test-fflush.txt +EXTRA_DIST += test-fflush.c test-fflush2.sh test-fflush2.c signature.h macros.h + +## end gnulib module fflush-tests + +## begin gnulib module fgetc-tests + +TESTS += test-fgetc +check_PROGRAMS += test-fgetc +EXTRA_DIST += test-fgetc.c signature.h macros.h + +## end gnulib module fgetc-tests + +## begin gnulib module file-has-acl-tests + +TESTS += \ + test-file-has-acl.sh test-file-has-acl-1.sh test-file-has-acl-2.sh +TESTS_ENVIRONMENT += USE_ACL=$(USE_ACL) +check_PROGRAMS += test-file-has-acl +test_file_has_acl_LDADD = $(LDADD) $(LIB_HAS_ACL) +EXTRA_DIST += test-file-has-acl.sh test-file-has-acl-1.sh test-file-has-acl-2.sh test-file-has-acl.c macros.h + +## end gnulib module file-has-acl-tests + +## begin gnulib module filenamecat-tests + +TESTS += test-filenamecat +check_PROGRAMS += test-filenamecat +test_filenamecat_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-filenamecat.c + +## end gnulib module filenamecat-tests + +## begin gnulib module filevercmp-tests + +TESTS += test-filevercmp +check_PROGRAMS += test-filevercmp +EXTRA_DIST += test-filevercmp.c macros.h + +## end gnulib module filevercmp-tests + +## begin gnulib module float-tests + +TESTS += test-float +check_PROGRAMS += test-float +EXTRA_DIST += test-float.c macros.h + +## end gnulib module float-tests + +## begin gnulib module fnmatch-h-tests + +TESTS += test-fnmatch-h +check_PROGRAMS += test-fnmatch-h +EXTRA_DIST += test-fnmatch-h.c + +## end gnulib module fnmatch-h-tests + +## begin gnulib module fnmatch-tests + +TESTS += test-fnmatch +check_PROGRAMS += test-fnmatch +test_fnmatch_LDADD = $(LDADD) $(LIB_MBRTOWC) +EXTRA_DIST += test-fnmatch.c signature.h macros.h + +## end gnulib module fnmatch-tests + +## begin gnulib module fopen-safer-tests + +TESTS += test-fopen-safer +check_PROGRAMS += test-fopen-safer +EXTRA_DIST += test-fopen.h test-fopen-safer.c macros.h + +## end gnulib module fopen-safer-tests + +## begin gnulib module fopen-tests + +TESTS += test-fopen +check_PROGRAMS += test-fopen + +EXTRA_DIST += test-fopen.h test-fopen.c signature.h macros.h + +## end gnulib module fopen-tests + +## begin gnulib module fpending-tests + +TESTS += test-fpending.sh +check_PROGRAMS += test-fpending +MOSTLYCLEANFILES += test-fpending.t +EXTRA_DIST += test-fpending.c test-fpending.sh macros.h + +## end gnulib module fpending-tests + +## begin gnulib module fpurge-tests + +TESTS += test-fpurge +check_PROGRAMS += test-fpurge +MOSTLYCLEANFILES += t-fpurge.tmp +EXTRA_DIST += test-fpurge.c macros.h + +## end gnulib module fpurge-tests + +## begin gnulib module fputc-tests + +TESTS += test-fputc +check_PROGRAMS += test-fputc +EXTRA_DIST += test-fputc.c signature.h macros.h + +## end gnulib module fputc-tests + +## begin gnulib module fread-tests + +TESTS += test-fread +check_PROGRAMS += test-fread +EXTRA_DIST += test-fread.c signature.h macros.h + +## end gnulib module fread-tests + +## begin gnulib module freadahead-tests + +TESTS += test-freadahead.sh +check_PROGRAMS += test-freadahead +EXTRA_DIST += test-freadahead.c test-freadahead.sh macros.h + +## end gnulib module freadahead-tests + +## begin gnulib module freading-tests + +TESTS += test-freading +check_PROGRAMS += test-freading +MOSTLYCLEANFILES += t-freading.tmp +EXTRA_DIST += test-freading.c macros.h + +## end gnulib module freading-tests + +## begin gnulib module freadptr-tests + +TESTS += test-freadptr.sh test-freadptr2.sh +check_PROGRAMS += test-freadptr test-freadptr2 +EXTRA_DIST += test-freadptr.c test-freadptr.sh test-freadptr2.c test-freadptr2.sh macros.h + +## end gnulib module freadptr-tests + +## begin gnulib module freadseek-tests + +TESTS += test-freadseek.sh +check_PROGRAMS += test-freadseek +EXTRA_DIST += test-freadseek.c test-freadseek.sh macros.h + +## end gnulib module freadseek-tests + +## begin gnulib module freopen-safer-tests + +TESTS += test-freopen-safer +check_PROGRAMS += test-freopen-safer +EXTRA_DIST += test-freopen-safer.c macros.h + +## end gnulib module freopen-safer-tests + +## begin gnulib module freopen-tests + +TESTS += test-freopen +check_PROGRAMS += test-freopen + +EXTRA_DIST += test-freopen.c signature.h macros.h + +## end gnulib module freopen-tests + +## begin gnulib module frexp-nolibm-tests + +TESTS += test-frexp-nolibm +check_PROGRAMS += test-frexp-nolibm +test_frexp_nolibm_SOURCES = test-frexp.c randomd.c +EXTRA_DIST += test-frexp.c test-frexp.h minus-zero.h infinity.h nan.h signature.h macros.h randomd.c + +## end gnulib module frexp-nolibm-tests + +## begin gnulib module frexpl-nolibm-tests + +TESTS += test-frexpl-nolibm +check_PROGRAMS += test-frexpl-nolibm +test_frexpl_nolibm_SOURCES = test-frexpl.c randoml.c +EXTRA_DIST += test-frexpl.c test-frexp.h minus-zero.h infinity.h nan.h signature.h macros.h randoml.c + +## end gnulib module frexpl-nolibm-tests + +## begin gnulib module fseek-tests + +TESTS += test-fseek.sh test-fseek2.sh +check_PROGRAMS += test-fseek +EXTRA_DIST += test-fseek.c test-fseek.sh test-fseek2.sh signature.h macros.h + +## end gnulib module fseek-tests + +## begin gnulib module fseeko-tests + +TESTS += test-fseeko.sh test-fseeko2.sh test-fseeko3.sh test-fseeko4.sh +check_PROGRAMS += test-fseeko test-fseeko3 test-fseeko4 +EXTRA_DIST += test-fseeko.c test-fseeko.sh test-fseeko2.sh test-fseeko3.c test-fseeko3.sh test-fseeko4.c test-fseeko4.sh signature.h macros.h + +## end gnulib module fseeko-tests + +## begin gnulib module fseterr-tests + +TESTS += test-fseterr +check_PROGRAMS += test-fseterr + +EXTRA_DIST += test-fseterr.c + +## end gnulib module fseterr-tests + +## begin gnulib module fstat-tests + +TESTS += test-fstat +check_PROGRAMS += test-fstat +EXTRA_DIST += test-fstat.c signature.h macros.h + +## end gnulib module fstat-tests + +## begin gnulib module fstatat-tests + +TESTS += test-fstatat +check_PROGRAMS += test-fstatat +test_fstatat_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-fstatat.c test-lstat.h test-stat.h signature.h macros.h + +## end gnulib module fstatat-tests + +## begin gnulib module fsync-tests + +TESTS += test-fsync +check_PROGRAMS += test-fsync +EXTRA_DIST += test-fsync.c signature.h macros.h + +## end gnulib module fsync-tests + +## begin gnulib module ftell-tests + +TESTS += test-ftell.sh test-ftell2.sh test-ftell3 +check_PROGRAMS += test-ftell test-ftell3 +MOSTLYCLEANFILES += t-ftell3.tmp +EXTRA_DIST += test-ftell.c test-ftell.sh test-ftell2.sh test-ftell3.c signature.h macros.h + +## end gnulib module ftell-tests + +## begin gnulib module ftello-tests + +TESTS += test-ftello.sh test-ftello2.sh test-ftello3 test-ftello4.sh +check_PROGRAMS += test-ftello test-ftello3 test-ftello4 +MOSTLYCLEANFILES += t-ftello3.tmp +EXTRA_DIST += test-ftello.c test-ftello.sh test-ftello2.sh test-ftello3.c test-ftello4.c test-ftello4.sh signature.h macros.h + +## end gnulib module ftello-tests + +## begin gnulib module ftruncate-tests + +TESTS += test-ftruncate.sh +check_PROGRAMS += test-ftruncate +EXTRA_DIST += test-ftruncate.c test-ftruncate.sh signature.h macros.h + +## end gnulib module ftruncate-tests + +## begin gnulib module futimens-tests + +TESTS += test-futimens +check_PROGRAMS += test-futimens +test_futimens_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_NANOSLEEP) @LIBINTL@ +EXTRA_DIST += nap.h test-futimens.h test-utimens-common.h test-futimens.c signature.h macros.h + +## end gnulib module futimens-tests + +## begin gnulib module fwrite-tests + +TESTS += test-fwrite +check_PROGRAMS += test-fwrite +EXTRA_DIST += test-fwrite.c signature.h macros.h + +## end gnulib module fwrite-tests + +## begin gnulib module getaddrinfo-tests + +TESTS += test-getaddrinfo +check_PROGRAMS += test-getaddrinfo +test_getaddrinfo_LDADD = $(LDADD) @GETADDRINFO_LIB@ @LIBINTL@ +EXTRA_DIST += signature.h test-getaddrinfo.c + +## end gnulib module getaddrinfo-tests + +## begin gnulib module getcwd-lgpl-tests + +TESTS += test-getcwd-lgpl +check_PROGRAMS += test-getcwd-lgpl +test_getcwd_lgpl_LDADD = $(LDADD) $(LIBINTL) +EXTRA_DIST += test-getcwd-lgpl.c signature.h macros.h + +## end gnulib module getcwd-lgpl-tests + +## begin gnulib module getcwd-tests + +TESTS += test-getcwd.sh +check_PROGRAMS += test-getcwd +test_getcwd_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-getcwd.c test-getcwd.sh + +## end gnulib module getcwd-tests + +## begin gnulib module getdelim-tests + +TESTS += test-getdelim +check_PROGRAMS += test-getdelim +MOSTLYCLEANFILES += test-getdelim.txt +EXTRA_DIST += test-getdelim.c signature.h macros.h + +## end gnulib module getdelim-tests + +## begin gnulib module getdtablesize-tests + +TESTS += test-getdtablesize +check_PROGRAMS += test-getdtablesize +EXTRA_DIST += test-getdtablesize.c signature.h macros.h + +## end gnulib module getdtablesize-tests + +## begin gnulib module getgroups-tests + +TESTS += test-getgroups +check_PROGRAMS += test-getgroups +EXTRA_DIST += test-getgroups.c signature.h macros.h + +## end gnulib module getgroups-tests + +## begin gnulib module gethostname-tests + +TESTS += test-gethostname +check_PROGRAMS += test-gethostname +test_gethostname_LDADD = $(LDADD) @GETHOSTNAME_LIB@ +EXTRA_DIST += signature.h test-gethostname.c + +## end gnulib module gethostname-tests + +## begin gnulib module getline-tests + +TESTS += test-getline +check_PROGRAMS += test-getline +MOSTLYCLEANFILES += test-getline.txt +EXTRA_DIST += test-getline.c signature.h macros.h + +## end gnulib module getline-tests + +## begin gnulib module getloadavg-tests + +TESTS += test-getloadavg +check_PROGRAMS += test-getloadavg +test_getloadavg_LDADD = $(LDADD) @GETLOADAVG_LIBS@ +EXTRA_DIST += test-getloadavg.c signature.h + +## end gnulib module getloadavg-tests + +## begin gnulib module getlogin-tests + +TESTS += test-getlogin +check_PROGRAMS += test-getlogin +test_getlogin_LDADD = $(LDADD) $(LIB_GETLOGIN) +EXTRA_DIST += test-getlogin.c test-getlogin.h signature.h macros.h + +## end gnulib module getlogin-tests + +## begin gnulib module getndelim2-tests + +TESTS += test-getndelim2 +check_PROGRAMS += test-getndelim2 +MOSTLYCLEANFILES += test-getndelim2.txt +EXTRA_DIST += test-getndelim2.c macros.h + +## end gnulib module getndelim2-tests + +## begin gnulib module getopt-gnu-tests + +TESTS += test-getopt-gnu +check_PROGRAMS += test-getopt-gnu +test_getopt_gnu_LDADD = $(LDADD) $(LIBINTL) +EXTRA_DIST += macros.h signature.h test-getopt-gnu.c test-getopt-main.h test-getopt.h test-getopt_long.h + +## end gnulib module getopt-gnu-tests + +## begin gnulib module getopt-posix-tests + +TESTS += test-getopt-posix +check_PROGRAMS += test-getopt-posix +test_getopt_posix_LDADD = $(LDADD) $(LIBINTL) +EXTRA_DIST += macros.h signature.h test-getopt-posix.c test-getopt-main.h test-getopt.h + +## end gnulib module getopt-posix-tests + +## begin gnulib module getprogname-tests + +DEFS += -DEXEEXT=\"@EXEEXT@\" +TESTS += test-getprogname +check_PROGRAMS += test-getprogname +test_getprogname_LDADD = $(LDADD) +EXTRA_DIST += test-getprogname.c + +## end gnulib module getprogname-tests + +## begin gnulib module getrusage + + +EXTRA_DIST += getrusage.c + +EXTRA_libtests_a_SOURCES += getrusage.c + +## end gnulib module getrusage + +## begin gnulib module getrusage-tests + +TESTS += test-getrusage +check_PROGRAMS += test-getrusage +EXTRA_DIST += test-getrusage.c signature.h macros.h + +## end gnulib module getrusage-tests + +## begin gnulib module gettimeofday-tests + +TESTS += test-gettimeofday +check_PROGRAMS += test-gettimeofday + +EXTRA_DIST += signature.h test-gettimeofday.c + +## end gnulib module gettimeofday-tests + +## begin gnulib module gperf + +GPERF = gperf +V_GPERF = $(V_GPERF_@AM_V@) +V_GPERF_ = $(V_GPERF_@AM_DEFAULT_V@) +V_GPERF_0 = @echo " GPERF " $@; + +## end gnulib module gperf + +## begin gnulib module hard-locale-tests + +TESTS += test-hard-locale +check_PROGRAMS += test-hard-locale +test_hard_locale_LDADD = $(LDADD) $(LIB_SETLOCALE) @LIB_HARD_LOCALE@ +# We cannot call this program 'locale', because the C++ compiler on Mac OS X +# would then barf upon '#include <locale>'. So, call it 'current-locale'. +noinst_PROGRAMS += current-locale +current_locale_SOURCES = locale.c +EXTRA_DIST += test-hard-locale.c locale.c + +## end gnulib module hard-locale-tests + +## begin gnulib module hash-tests + +TESTS += test-hash +check_PROGRAMS += test-hash +EXTRA_DIST += test-hash.c macros.h + +## end gnulib module hash-tests + +## begin gnulib module i-ring-tests + +TESTS += test-i-ring +check_PROGRAMS += test-i-ring +EXTRA_DIST += test-i-ring.c macros.h + +## end gnulib module i-ring-tests + +## begin gnulib module iconv-h-tests + +TESTS += test-iconv-h +check_PROGRAMS += test-iconv-h +EXTRA_DIST += test-iconv-h.c + +## end gnulib module iconv-h-tests + +## begin gnulib module iconv-tests + +TESTS += test-iconv +check_PROGRAMS += test-iconv +test_iconv_LDADD = $(LDADD) @LIBICONV@ + +EXTRA_DIST += test-iconv.c signature.h macros.h + +## end gnulib module iconv-tests + +## begin gnulib module ignore-value-tests + +TESTS += test-ignore-value +check_PROGRAMS += test-ignore-value +EXTRA_DIST += test-ignore-value.c + +## end gnulib module ignore-value-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 signature.h macros.h + +## end gnulib module inet_ntop-tests + +## begin gnulib module inet_pton + + +EXTRA_DIST += inet_pton.c + +EXTRA_libtests_a_SOURCES += inet_pton.c + +## end gnulib module inet_pton + +## 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 signature.h macros.h + +## end gnulib module inet_pton-tests + +## begin gnulib module ino-map-tests + +TESTS += test-ino-map +check_PROGRAMS += test-ino-map +EXTRA_DIST += test-ino-map.c macros.h + +## end gnulib module ino-map-tests + +## begin gnulib module intprops-tests + +TESTS += test-intprops +check_PROGRAMS += test-intprops +EXTRA_DIST += test-intprops.c macros.h + +## end gnulib module intprops-tests + +## begin gnulib module inttostr-tests + +TESTS += test-inttostr +check_PROGRAMS += test-inttostr +EXTRA_DIST += macros.h test-inttostr.c + +## end gnulib module inttostr-tests + +## begin gnulib module inttypes-tests + +TESTS += test-inttypes +check_PROGRAMS += test-inttypes +EXTRA_DIST += test-inttypes.c + +## end gnulib module inttypes-tests + +## begin gnulib module ioctl + + +EXTRA_DIST += ioctl.c w32sock.h + +EXTRA_libtests_a_SOURCES += ioctl.c + +## end gnulib module ioctl + +## begin gnulib module ioctl-tests + +TESTS += test-ioctl +check_PROGRAMS += test-ioctl +EXTRA_DIST += test-ioctl.c signature.h macros.h + +## end gnulib module ioctl-tests + +## begin gnulib module isatty-tests + +TESTS += test-isatty +check_PROGRAMS += test-isatty +EXTRA_DIST += test-isatty.c signature.h macros.h + +## end gnulib module isatty-tests + +## begin gnulib module isblank-tests + +TESTS += test-isblank +check_PROGRAMS += test-isblank +EXTRA_DIST += test-isblank.c signature.h macros.h + +## end gnulib module isblank-tests + +## begin gnulib module isnand-nolibm-tests + +TESTS += test-isnand-nolibm +check_PROGRAMS += test-isnand-nolibm + +EXTRA_DIST += test-isnand-nolibm.c test-isnand.h minus-zero.h infinity.h nan.h macros.h + +## end gnulib module isnand-nolibm-tests + +## begin gnulib module isnanf-nolibm-tests + +TESTS += test-isnanf-nolibm +check_PROGRAMS += test-isnanf-nolibm + +EXTRA_DIST += test-isnanf-nolibm.c test-isnanf.h minus-zero.h infinity.h nan.h macros.h + +## end gnulib module isnanf-nolibm-tests + +## begin gnulib module isnanl-nolibm-tests + +TESTS += test-isnanl-nolibm +check_PROGRAMS += test-isnanl-nolibm + +EXTRA_DIST += test-isnanl-nolibm.c test-isnanl.h minus-zero.h infinity.h nan.h macros.h + +## end gnulib module isnanl-nolibm-tests + +## begin gnulib module iswblank-tests + +TESTS += test-iswblank +check_PROGRAMS += test-iswblank +EXTRA_DIST += test-iswblank.c macros.h + +## end gnulib module iswblank-tests + +## begin gnulib module iswdigit-tests + +TESTS += test-iswdigit.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-iswdigit +test_iswdigit_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC) +EXTRA_DIST += test-iswdigit.sh test-iswdigit.c signature.h macros.h + +## end gnulib module iswdigit-tests + +## begin gnulib module iswxdigit-tests + +TESTS += test-iswxdigit.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-iswxdigit +test_iswxdigit_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC) +EXTRA_DIST += test-iswxdigit.sh test-iswxdigit.c signature.h macros.h + +## end gnulib module iswxdigit-tests + +## begin gnulib module langinfo-tests + +TESTS += test-langinfo +check_PROGRAMS += test-langinfo +EXTRA_DIST += test-langinfo.c + +## end gnulib module langinfo-tests + +## begin gnulib module lchmod-tests + +TESTS += test-lchmod +check_PROGRAMS += test-lchmod +test_lchmod_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-lchmod.c signature.h macros.h + +## end gnulib module lchmod-tests + +## begin gnulib module lchown-tests + +TESTS += test-lchown +check_PROGRAMS += test-lchown +test_lchown_LDADD = $(LDADD) $(LIB_NANOSLEEP) +EXTRA_DIST += nap.h test-lchown.h test-lchown.c signature.h macros.h + +## end gnulib module lchown-tests + +## begin gnulib module limits-h-tests + +TESTS += test-limits-h +check_PROGRAMS += test-limits-h +EXTRA_DIST += test-limits-h.c + +## end gnulib module limits-h-tests + +## begin gnulib module link-tests + +TESTS += test-link +check_PROGRAMS += test-link +test_link_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-link.h test-link.c signature.h macros.h + +## end gnulib module link-tests + +## begin gnulib module linkat-tests + +TESTS += test-linkat +check_PROGRAMS += test-linkat +test_linkat_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-link.h test-linkat.c signature.h macros.h + +## end gnulib module linkat-tests + +## begin gnulib module listen + + +EXTRA_DIST += listen.c w32sock.h + +EXTRA_libtests_a_SOURCES += listen.c + +## end gnulib module listen + +## begin gnulib module listen-tests + +TESTS += test-listen +check_PROGRAMS += test-listen +test_listen_LDADD = $(LDADD) @LIBSOCKET@ +EXTRA_DIST += test-listen.c signature.h macros.h + +## end gnulib module listen-tests + +## begin gnulib module localcharset-tests + +noinst_PROGRAMS += test-localcharset +test_localcharset_LDADD = $(LDADD) $(LIB_SETLOCALE) +EXTRA_DIST += test-localcharset.c + +## end gnulib module localcharset-tests + +## begin gnulib module locale-tests + +TESTS += test-locale +check_PROGRAMS += test-locale +EXTRA_DIST += test-locale.c + +## end gnulib module locale-tests + +## begin gnulib module localeconv-tests + +TESTS += test-localeconv +check_PROGRAMS += test-localeconv +EXTRA_DIST += test-localeconv.c signature.h macros.h + +## end gnulib module localeconv-tests + +## begin gnulib module localename + +libtests_a_SOURCES += localename.c localename-table.c + +EXTRA_DIST += localename-table.h localename.h + +## end gnulib module localename + +## begin gnulib module localename-tests + +TESTS += test-localename +check_PROGRAMS += test-localename +test_localename_LDADD = $(LDADD) $(LIB_SETLOCALE) @INTL_MACOSX_LIBS@ $(LIBTHREAD) + +EXTRA_DIST += test-localename.c macros.h + +## end gnulib module localename-tests + +## begin gnulib module lock-tests + +TESTS += test-rwlock1 test-lock test-once1 test-once2 +check_PROGRAMS += test-rwlock1 test-lock test-once1 test-once2 +test_rwlock1_LDADD = $(LDADD) @LIBMULTITHREAD@ @YIELD_LIB@ +test_lock_LDADD = $(LDADD) @LIBMULTITHREAD@ @YIELD_LIB@ @LIB_SEMAPHORE@ +test_once1_SOURCES = test-once.c +test_once1_LDADD = $(LDADD) @LIBTHREAD@ +test_once2_SOURCES = test-once.c +test_once2_LDADD = $(LDADD) @LIBMULTITHREAD@ +EXTRA_DIST += test-rwlock1.c test-lock.c test-once.c + +## end gnulib module lock-tests + +## begin gnulib module lseek-tests + +TESTS += test-lseek.sh +check_PROGRAMS += test-lseek +EXTRA_DIST += test-lseek.c test-lseek.sh signature.h macros.h + +## end gnulib module lseek-tests + +## begin gnulib module lstat-tests + +TESTS += test-lstat +check_PROGRAMS += test-lstat +EXTRA_DIST += test-lstat.h test-lstat.c signature.h macros.h + +## end gnulib module lstat-tests + +## begin gnulib module malloc-gnu-tests + +TESTS += test-malloc-gnu +check_PROGRAMS += test-malloc-gnu +EXTRA_DIST += test-malloc-gnu.c + +## end gnulib module malloc-gnu-tests + +## begin gnulib module malloca-tests + +TESTS += test-malloca +check_PROGRAMS += test-malloca + +EXTRA_DIST += test-malloca.c + +## end gnulib module malloca-tests + +## begin gnulib module math-tests + +TESTS += test-math +check_PROGRAMS += test-math +EXTRA_DIST += test-math.c macros.h + +## end gnulib module math-tests + +## begin gnulib module mbrtowc-tests + +TESTS += \ + test-mbrtowc1.sh test-mbrtowc2.sh test-mbrtowc3.sh test-mbrtowc4.sh \ + test-mbrtowc5.sh \ + test-mbrtowc-w32-1.sh test-mbrtowc-w32-2.sh test-mbrtowc-w32-3.sh \ + test-mbrtowc-w32-4.sh test-mbrtowc-w32-5.sh test-mbrtowc-w32-6.sh \ + test-mbrtowc-w32-7.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-mbrtowc test-mbrtowc-w32 +test_mbrtowc_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC) +EXTRA_DIST += test-mbrtowc1.sh test-mbrtowc2.sh test-mbrtowc3.sh test-mbrtowc4.sh test-mbrtowc5.sh test-mbrtowc.c test-mbrtowc-w32-1.sh test-mbrtowc-w32-2.sh test-mbrtowc-w32-3.sh test-mbrtowc-w32-4.sh test-mbrtowc-w32-5.sh test-mbrtowc-w32-6.sh test-mbrtowc-w32-7.sh test-mbrtowc-w32.c signature.h macros.h + +## end gnulib module mbrtowc-tests + +## begin gnulib module mbsalign-tests + +TESTS += test-mbsalign +check_PROGRAMS += test-mbsalign +EXTRA_DIST += test-mbsalign.c macros.h + +## end gnulib module mbsalign-tests + +## begin gnulib module mbscasecmp-tests + +TESTS += test-mbscasecmp.sh +TESTS_ENVIRONMENT += LOCALE_TR_UTF8='@LOCALE_TR_UTF8@' +check_PROGRAMS += test-mbscasecmp +test_mbscasecmp_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC) +EXTRA_DIST += test-mbscasecmp.sh test-mbscasecmp.c macros.h + +## end gnulib module mbscasecmp-tests + +## begin gnulib module mbschr-tests + +TESTS += test-mbschr.sh +TESTS_ENVIRONMENT += LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-mbschr +test_mbschr_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC) +EXTRA_DIST += test-mbschr.sh test-mbschr.c macros.h + +## end gnulib module mbschr-tests + +## begin gnulib module mbsinit-tests + +TESTS += test-mbsinit.sh +TESTS_ENVIRONMENT += LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' +check_PROGRAMS += test-mbsinit +test_mbsinit_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC) +EXTRA_DIST += test-mbsinit.sh test-mbsinit.c signature.h macros.h + +## end gnulib module mbsinit-tests + +## begin gnulib module mbsrtowcs-tests + +TESTS += test-mbsrtowcs1.sh test-mbsrtowcs2.sh test-mbsrtowcs3.sh test-mbsrtowcs4.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-mbsrtowcs +test_mbsrtowcs_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC) +EXTRA_DIST += test-mbsrtowcs1.sh test-mbsrtowcs2.sh test-mbsrtowcs3.sh test-mbsrtowcs4.sh test-mbsrtowcs.c signature.h macros.h + +## end gnulib module mbsrtowcs-tests + +## begin gnulib module mbsstr-tests + +TESTS += test-mbsstr1 test-mbsstr2.sh test-mbsstr3.sh +TESTS_ENVIRONMENT += LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-mbsstr1 test-mbsstr2 test-mbsstr3 +test_mbsstr1_LDADD = $(LDADD) $(LIB_MBRTOWC) +test_mbsstr2_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC) +test_mbsstr3_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC) +EXTRA_DIST += test-mbsstr1.c test-mbsstr2.sh test-mbsstr2.c test-mbsstr3.sh test-mbsstr3.c macros.h + +## end gnulib module mbsstr-tests + +## begin gnulib module memcasecmp-tests + +TESTS += test-memcasecmp +check_PROGRAMS += test-memcasecmp +EXTRA_DIST += test-memcasecmp.c zerosize-ptr.h macros.h + +## end gnulib module memcasecmp-tests + +## begin gnulib module memchr-tests + +TESTS += test-memchr +check_PROGRAMS += test-memchr +EXTRA_DIST += test-memchr.c zerosize-ptr.h signature.h macros.h + +## end gnulib module memchr-tests + +## begin gnulib module memchr2-tests + +TESTS += test-memchr2 +check_PROGRAMS += test-memchr2 +EXTRA_DIST += test-memchr2.c zerosize-ptr.h macros.h + +## end gnulib module memchr2-tests + +## begin gnulib module memcoll-tests + +TESTS += test-memcoll +check_PROGRAMS += test-memcoll +EXTRA_DIST += test-memcoll.c macros.h + +## end gnulib module memcoll-tests + +## begin gnulib module memrchr-tests + +TESTS += test-memrchr +check_PROGRAMS += test-memrchr +EXTRA_DIST += test-memrchr.c zerosize-ptr.h signature.h macros.h + +## end gnulib module memrchr-tests + +## begin gnulib module mkdir-tests + +TESTS += test-mkdir +check_PROGRAMS += test-mkdir +EXTRA_DIST += test-mkdir.h test-mkdir.c signature.h macros.h + +## end gnulib module mkdir-tests + +## begin gnulib module mkfifo-tests + +TESTS += test-mkfifo +check_PROGRAMS += test-mkfifo +EXTRA_DIST += test-mkfifo.h test-mkfifo.c signature.h macros.h + +## end gnulib module mkfifo-tests + +## begin gnulib module mknod-tests + +TESTS += test-mknod +check_PROGRAMS += test-mknod +EXTRA_DIST += test-mkfifo.h test-mknod.c signature.h macros.h + +## end gnulib module mknod-tests + +## begin gnulib module nanosleep-tests + +TESTS += test-nanosleep +check_PROGRAMS += test-nanosleep +test_nanosleep_LDADD = $(LDADD) $(LIB_NANOSLEEP) +EXTRA_DIST += test-nanosleep.c signature.h macros.h + +## end gnulib module nanosleep-tests + +## begin gnulib module netdb-tests + +TESTS += test-netdb +check_PROGRAMS += test-netdb +EXTRA_DIST += test-netdb.c + +## end gnulib module netdb-tests + +## begin gnulib module netinet_in-tests + +TESTS += test-netinet_in +check_PROGRAMS += test-netinet_in +EXTRA_DIST += test-netinet_in.c + +## end gnulib module netinet_in-tests + +## begin gnulib module nl_langinfo-tests + +TESTS += test-nl_langinfo.sh test-nl_langinfo-mt +TESTS_ENVIRONMENT += LOCALE_FR='@LOCALE_FR@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' +check_PROGRAMS += test-nl_langinfo test-nl_langinfo-mt +test_nl_langinfo_LDADD = $(LDADD) $(LIB_SETLOCALE) +test_nl_langinfo_mt_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBMULTITHREAD) $(LIB_NANOSLEEP) +EXTRA_DIST += test-nl_langinfo.sh test-nl_langinfo.c test-nl_langinfo-mt.c signature.h macros.h + +## end gnulib module nl_langinfo-tests + +## begin gnulib module nstrftime-tests + +TESTS += test-nstrftime +check_PROGRAMS += test-nstrftime +EXTRA_DIST += test-nstrftime.c macros.h + +## end gnulib module nstrftime-tests + +## begin gnulib module open-tests + +TESTS += test-open +check_PROGRAMS += test-open +EXTRA_DIST += test-open.h test-open.c signature.h macros.h + +## end gnulib module open-tests + +## begin gnulib module openat-safer-tests + +TESTS += test-openat-safer +check_PROGRAMS += test-openat-safer +test_openat_safer_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-openat-safer.c macros.h + +## end gnulib module openat-safer-tests + +## begin gnulib module openat-tests + +TESTS += test-openat +check_PROGRAMS += test-openat +test_openat_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-openat.c test-open.h signature.h macros.h + +## end gnulib module openat-tests + +## begin gnulib module parse-datetime-tests + +TESTS += test-parse-datetime +check_PROGRAMS += test-parse-datetime +test_parse_datetime_LDADD = $(LDADD) @LIBINTL@ $(LIB_CLOCK_GETTIME) +EXTRA_DIST += test-parse-datetime.c macros.h + +## end gnulib module parse-datetime-tests + +## begin gnulib module pathmax-tests + +TESTS += test-pathmax +check_PROGRAMS += test-pathmax +EXTRA_DIST += test-pathmax.c + +## end gnulib module pathmax-tests + +## begin gnulib module perror + + +EXTRA_DIST += perror.c + +EXTRA_libtests_a_SOURCES += perror.c + +## end gnulib module perror + +## begin gnulib module perror-tests + +TESTS += test-perror.sh test-perror2 +check_PROGRAMS += test-perror test-perror2 +EXTRA_DIST += macros.h signature.h test-perror.c test-perror2.c test-perror.sh + +## end gnulib module perror-tests + +## begin gnulib module pipe-posix-tests + +TESTS += test-pipe +check_PROGRAMS += test-pipe +EXTRA_DIST += test-pipe.c signature.h macros.h + +## end gnulib module pipe-posix-tests + +## begin gnulib module pipe2-tests + +TESTS += test-pipe2 +check_PROGRAMS += test-pipe2 +test_pipe2_LDADD = $(LDADD) $(LIBSOCKET) +EXTRA_DIST += test-pipe2.c signature.h macros.h + +## end gnulib module pipe2-tests + +## begin gnulib module posixtm-tests + +TESTS += test-posixtm +check_PROGRAMS += test-posixtm +EXTRA_DIST += test-posixtm.c macros.h + +## end gnulib module posixtm-tests + +## begin gnulib module printf-frexp-tests + +TESTS += test-printf-frexp +check_PROGRAMS += test-printf-frexp +EXTRA_DIST += test-printf-frexp.c macros.h + +## end gnulib module printf-frexp-tests + +## begin gnulib module printf-frexpl-tests + +TESTS += test-printf-frexpl +check_PROGRAMS += test-printf-frexpl +EXTRA_DIST += test-printf-frexpl.c macros.h + +## end gnulib module printf-frexpl-tests + +## begin gnulib module priv-set-tests + +TESTS += test-priv-set +check_PROGRAMS += test-priv-set +EXTRA_DIST += test-priv-set.c macros.h + +## end gnulib module priv-set-tests + +## begin gnulib module pthread-cond-tests + +TESTS += test-pthread-cond +check_PROGRAMS += test-pthread-cond +test_pthread_cond_LDADD = $(LDADD) @LIBPMULTITHREAD@ @LIB_SCHED_YIELD@ +EXTRA_DIST += test-pthread-cond.c macros.h + +## end gnulib module pthread-cond-tests + +## begin gnulib module pthread-h-tests + +TESTS += test-pthread +check_PROGRAMS += test-pthread +EXTRA_DIST += test-pthread.c + +## end gnulib module pthread-h-tests + +## begin gnulib module pthread-mutex-tests + +TESTS += test-pthread-mutex +check_PROGRAMS += test-pthread-mutex +test_pthread_mutex_LDADD = $(LDADD) @LIBPMULTITHREAD@ @LIB_SCHED_YIELD@ @LIB_SEMAPHORE@ +EXTRA_DIST += test-pthread-mutex.c macros.h + +## end gnulib module pthread-mutex-tests + +## begin gnulib module pthread-thread-tests + +TESTS += test-pthread-thread +check_PROGRAMS += test-pthread-thread +test_pthread_thread_LDADD = $(LDADD) @LIBPMULTITHREAD@ +EXTRA_DIST += test-pthread-thread.c macros.h + +## end gnulib module pthread-thread-tests + +## begin gnulib module pthread_sigmask-tests + +TESTS += test-pthread_sigmask1 test-pthread_sigmask2 +check_PROGRAMS += test-pthread_sigmask1 test-pthread_sigmask2 +test_pthread_sigmask1_LDADD = $(LDADD) @LIB_PTHREAD_SIGMASK@ +test_pthread_sigmask2_LDADD = $(LDADD) @LIB_PTHREAD_SIGMASK@ @LIBMULTITHREAD@ +EXTRA_DIST += test-pthread_sigmask1.c test-pthread_sigmask2.c signature.h macros.h + +## end gnulib module pthread_sigmask-tests + +## begin gnulib module quotearg-simple-tests + +TESTS += test-quotearg-simple +check_PROGRAMS += test-quotearg-simple +test_quotearg_simple_LDADD = $(LDADD) @LIBINTL@ $(LIB_MBRTOWC) +EXTRA_DIST += test-quotearg-simple.c test-quotearg.h macros.h zerosize-ptr.h + +## end gnulib module quotearg-simple-tests + +## begin gnulib module raise-tests + +TESTS += test-raise +check_PROGRAMS += test-raise +EXTRA_DIST += test-raise.c signature.h macros.h + +## end gnulib module raise-tests + +## begin gnulib module randread-tests + +TESTS += test-rand-isaac +check_PROGRAMS += test-rand-isaac +EXTRA_DIST += test-rand-isaac.c macros.h + +## end gnulib module randread-tests + +## begin gnulib module read-file-tests + +TESTS += test-read-file +check_PROGRAMS += test-read-file +EXTRA_DIST += test-read-file.c + +## end gnulib module read-file-tests + +## begin gnulib module read-tests + +TESTS += test-read +check_PROGRAMS += test-read +EXTRA_DIST += test-read.c signature.h macros.h + +## end gnulib module read-tests + +## begin gnulib module readlink-tests + +TESTS += test-readlink +check_PROGRAMS += test-readlink +EXTRA_DIST += test-readlink.h test-readlink.c signature.h macros.h + +## end gnulib module readlink-tests + +## begin gnulib module readlinkat-tests + +TESTS += test-readlinkat +check_PROGRAMS += test-readlinkat +test_readlinkat_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-readlink.h test-readlinkat.c signature.h macros.h + +## end gnulib module readlinkat-tests + +## begin gnulib module readtokens-tests + +TESTS += test-readtokens.sh +check_PROGRAMS += test-readtokens +test_readtokens_LDADD = $(LDADD) @LIBINTL@ $(LIB_MBRTOWC) +EXTRA_DIST += macros.h test-readtokens.c test-readtokens.sh + +## end gnulib module readtokens-tests + +## begin gnulib module realloc-gnu-tests + +TESTS += test-realloc-gnu +check_PROGRAMS += test-realloc-gnu +EXTRA_DIST += test-realloc-gnu.c + +## end gnulib module realloc-gnu-tests + +## begin gnulib module regex-tests + +TESTS += test-regex +check_PROGRAMS += test-regex +test_regex_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC) @LIBINTL@ $(LIBTHREAD) +EXTRA_DIST += test-regex.c macros.h + +## end gnulib module regex-tests + +## begin gnulib module remove-tests + +TESTS += test-remove +check_PROGRAMS += test-remove +EXTRA_DIST += test-remove.c signature.h macros.h + +## end gnulib module remove-tests + +## begin gnulib module rename-tests + +TESTS += test-rename +check_PROGRAMS += test-rename +test_rename_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-rename.h test-rename.c signature.h macros.h + +## end gnulib module rename-tests + +## begin gnulib module renameat-tests + +TESTS += test-renameat +check_PROGRAMS += test-renameat +test_renameat_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-rename.h test-renameat.c signature.h macros.h + +## end gnulib module renameat-tests + +## begin gnulib module renameatu-tests + +TESTS += test-renameatu +check_PROGRAMS += test-renameatu +test_renameatu_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-rename.h test-renameatu.c signature.h macros.h + +## end gnulib module renameatu-tests + +## begin gnulib module rmdir-tests + +TESTS += test-rmdir +check_PROGRAMS += test-rmdir +EXTRA_DIST += test-rmdir.h test-rmdir.c signature.h macros.h + +## end gnulib module rmdir-tests + +## begin gnulib module sched-tests + +TESTS += test-sched +check_PROGRAMS += test-sched +EXTRA_DIST += test-sched.c + +## end gnulib module sched-tests + +## begin gnulib module sched_yield + + +EXTRA_DIST += sched_yield.c + +EXTRA_libtests_a_SOURCES += sched_yield.c + +## end gnulib module sched_yield + +## begin gnulib module secure_getenv + + +EXTRA_DIST += secure_getenv.c + +EXTRA_libtests_a_SOURCES += secure_getenv.c + +## end gnulib module secure_getenv + +## begin gnulib module select-tests + +TESTS += test-select test-select-in.sh test-select-out.sh +# test-select-stdin has to be run by hand. +check_PROGRAMS += test-select test-select-fd test-select-stdin +test_select_LDADD = $(LDADD) @LIB_SELECT@ @LIBSOCKET@ $(INET_PTON_LIB) +test_select_fd_LDADD = $(LDADD) @LIB_SELECT@ +test_select_stdin_LDADD = $(LDADD) @LIB_SELECT@ +EXTRA_DIST += macros.h signature.h test-select.c test-select.h test-select-fd.c test-select-in.sh test-select-out.sh test-select-stdin.c + +## end gnulib module select-tests + +## begin gnulib module setenv-tests + +TESTS += test-setenv +check_PROGRAMS += test-setenv +EXTRA_DIST += test-setenv.c signature.h macros.h + +## end gnulib module setenv-tests + +## begin gnulib module setlocale + + +EXTRA_DIST += setlocale.c + +EXTRA_libtests_a_SOURCES += setlocale.c + +## end gnulib module setlocale + +## begin gnulib module setlocale-null-tests + +TESTS += \ + test-setlocale_null \ + test-setlocale_null-mt-one \ + test-setlocale_null-mt-all +check_PROGRAMS += \ + test-setlocale_null \ + test-setlocale_null-mt-one \ + test-setlocale_null-mt-all +test_setlocale_null_LDADD = $(LDADD) @LIB_SETLOCALE_NULL@ +test_setlocale_null_mt_one_LDADD = $(LDADD) @LIB_SETLOCALE_NULL@ $(LIBMULTITHREAD) $(LIB_NANOSLEEP) +test_setlocale_null_mt_all_LDADD = $(LDADD) @LIB_SETLOCALE_NULL@ $(LIBMULTITHREAD) $(LIB_NANOSLEEP) +EXTRA_DIST += test-setlocale_null.c test-setlocale_null-mt-one.c test-setlocale_null-mt-all.c + +## end gnulib module setlocale-null-tests + +## begin gnulib module setlocale-tests + +TESTS += test-setlocale1.sh test-setlocale2.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-setlocale1 test-setlocale2 +test_setlocale1_LDADD = $(LDADD) @LIB_SETLOCALE@ +test_setlocale2_LDADD = $(LDADD) @LIB_SETLOCALE@ +EXTRA_DIST += test-setlocale1.sh test-setlocale1.c test-setlocale2.sh test-setlocale2.c signature.h macros.h + +## end gnulib module setlocale-tests + +## begin gnulib module setsockopt + + +EXTRA_DIST += setsockopt.c w32sock.h + +EXTRA_libtests_a_SOURCES += setsockopt.c + +## end gnulib module setsockopt + +## begin gnulib module setsockopt-tests + +TESTS += test-setsockopt +check_PROGRAMS += test-setsockopt +test_setsockopt_LDADD = $(LDADD) @LIBSOCKET@ +EXTRA_DIST += test-setsockopt.c signature.h macros.h + +## end gnulib module setsockopt-tests + +## begin gnulib module sigaction-tests + +TESTS += test-sigaction +check_PROGRAMS += test-sigaction +EXTRA_DIST += test-sigaction.c signature.h macros.h + +## end gnulib module sigaction-tests + +## begin gnulib module signal-h-tests + +TESTS += test-signal-h +check_PROGRAMS += test-signal-h +EXTRA_DIST += test-signal-h.c + +## end gnulib module signal-h-tests + +## begin gnulib module signbit-tests + +TESTS += test-signbit +check_PROGRAMS += test-signbit + +EXTRA_DIST += test-signbit.c minus-zero.h infinity.h macros.h + +## end gnulib module signbit-tests + +## begin gnulib module sigprocmask-tests + +TESTS += test-sigprocmask +check_PROGRAMS += test-sigprocmask +EXTRA_DIST += test-sigprocmask.c signature.h macros.h + +## end gnulib module sigprocmask-tests + +## begin gnulib module sleep + + +EXTRA_DIST += sleep.c + +EXTRA_libtests_a_SOURCES += sleep.c + +## end gnulib module sleep + +## begin gnulib module sleep-tests + +TESTS += test-sleep +check_PROGRAMS += test-sleep +EXTRA_DIST += test-sleep.c signature.h macros.h + +## end gnulib module sleep-tests + +## begin gnulib module snippet/_Noreturn + +# Because this Makefile snippet defines a variable used by other +# gnulib Makefile snippets, it must be present in all makefiles that +# need it. This is ensured by the applicability 'all' defined above. + +_NORETURN_H=$(srcdir)/_Noreturn.h + +EXTRA_DIST += _Noreturn.h + +## end gnulib module snippet/_Noreturn + +## begin gnulib module snippet/arg-nonnull + +# Because this Makefile snippet defines a variable used by other +# gnulib Makefile snippets, it must be present in all makefiles that +# need it. This is ensured by the applicability 'all' defined above. + +ARG_NONNULL_H=$(srcdir)/arg-nonnull.h + +EXTRA_DIST += arg-nonnull.h + +## end gnulib module snippet/arg-nonnull + +## begin gnulib module snippet/c++defs + +# Because this Makefile snippet defines a variable used by other +# gnulib Makefile snippets, it must be present in all makefiles that +# need it. This is ensured by the applicability 'all' defined above. + +CXXDEFS_H=$(srcdir)/c++defs.h + +EXTRA_DIST += c++defs.h + +## end gnulib module snippet/c++defs + +## begin gnulib module snippet/unused-parameter + +# Because this Makefile snippet defines a variable used by other +# gnulib Makefile snippets, it must be present in all makefiles that +# need it. This is ensured by the applicability 'all' defined above. + +UNUSED_PARAMETER_H=$(srcdir)/unused-parameter.h + +EXTRA_DIST += unused-parameter.h + +## end gnulib module snippet/unused-parameter + +## begin gnulib module snippet/warn-on-use + +# Because this Makefile snippet defines a variable used by other +# gnulib Makefile snippets, it must be present in all makefiles that +# need it. This is ensured by the applicability 'all' defined above. + +WARN_ON_USE_H=$(srcdir)/warn-on-use.h + +EXTRA_DIST += warn-on-use.h + +## end gnulib module snippet/warn-on-use + +## begin gnulib module snprintf-tests + +TESTS += test-snprintf +check_PROGRAMS += test-snprintf + +EXTRA_DIST += test-snprintf.c signature.h macros.h + +## end gnulib module snprintf-tests + +## begin gnulib module socket + + +EXTRA_DIST += socket.c w32sock.h + +EXTRA_libtests_a_SOURCES += socket.c + +## end gnulib module socket + +## begin gnulib module sockets-tests + +TESTS += test-sockets +check_PROGRAMS += test-sockets +test_sockets_LDADD = $(LDADD) @LIBSOCKET@ +EXTRA_DIST += test-sockets.c + +## end gnulib module sockets-tests + +## begin gnulib module stat-tests + +TESTS += test-stat +check_PROGRAMS += test-stat +test_stat_LDADD = $(LDADD) $(LIBINTL) +EXTRA_DIST += test-stat.h test-stat.c signature.h macros.h + +## end gnulib module stat-tests + +## begin gnulib module stat-time-tests + +TESTS += test-stat-time +check_PROGRAMS += test-stat-time +test_stat_time_LDADD = $(LDADD) $(LIB_NANOSLEEP) +EXTRA_DIST += test-stat-time.c macros.h nap.h + +## end gnulib module stat-time-tests + +## begin gnulib module statat-tests + +TESTS += test-statat +check_PROGRAMS += test-statat +test_statat_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-statat.c + +## end gnulib module statat-tests + +## begin gnulib module stdalign-tests + +TESTS += test-stdalign +check_PROGRAMS += test-stdalign +EXTRA_DIST += test-stdalign.c macros.h + +## end gnulib module stdalign-tests + +## begin gnulib module stdbool-tests + +TESTS += test-stdbool +check_PROGRAMS += test-stdbool +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 +check_PROGRAMS += test-stdint +EXTRA_DIST += test-stdint.c + +## end gnulib module stdint-tests + +## begin gnulib module stdio-tests + +TESTS += test-stdio +check_PROGRAMS += test-stdio +EXTRA_DIST += test-stdio.c + +## end gnulib module stdio-tests + +## begin gnulib module stdlib-tests + +TESTS += test-stdlib +check_PROGRAMS += test-stdlib +EXTRA_DIST += test-stdlib.c test-sys_wait.h + +## end gnulib module stdlib-tests + +## begin gnulib module strerror-tests + +TESTS += test-strerror +check_PROGRAMS += test-strerror +EXTRA_DIST += test-strerror.c signature.h macros.h + +## end gnulib module strerror-tests + +## begin gnulib module strerror_r-posix + + +EXTRA_DIST += strerror_r.c + +EXTRA_libtests_a_SOURCES += strerror_r.c + +## end gnulib module strerror_r-posix + +## begin gnulib module strerror_r-posix-tests + +TESTS += test-strerror_r +check_PROGRAMS += test-strerror_r +EXTRA_DIST += test-strerror_r.c signature.h macros.h + +## end gnulib module strerror_r-posix-tests + +## begin gnulib module striconv-tests + +TESTS += test-striconv +check_PROGRAMS += test-striconv +test_striconv_LDADD = $(LDADD) @LIBICONV@ + +EXTRA_DIST += test-striconv.c macros.h + +## end gnulib module striconv-tests + +## begin gnulib module string-tests + +TESTS += test-string +check_PROGRAMS += test-string +EXTRA_DIST += test-string.c + +## end gnulib module string-tests + +## begin gnulib module strncat-tests + +TESTS += test-strncat +check_PROGRAMS += test-strncat +EXTRA_DIST += test-strncat.c unistr/test-strncat.h zerosize-ptr.h signature.h macros.h + +## end gnulib module strncat-tests + +## begin gnulib module strnlen-tests + +TESTS += test-strnlen +check_PROGRAMS += test-strnlen +EXTRA_DIST += test-strnlen.c zerosize-ptr.h signature.h macros.h + +## end gnulib module strnlen-tests + +## begin gnulib module strsignal-tests + +TESTS += test-strsignal +check_PROGRAMS += test-strsignal +test_strsignal_LDADD = $(LDADD) @LIBINTL@ $(LIBTHREAD) +EXTRA_DIST += test-strsignal.c signature.h macros.h + +## end gnulib module strsignal-tests + +## begin gnulib module strtod-tests + +TESTS += test-strtod +check_PROGRAMS += test-strtod + +TESTS += test-strtod1.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' +check_PROGRAMS += test-strtod1 +test_strtod1_LDADD = $(LDADD) $(LIB_SETLOCALE) +EXTRA_DIST += test-strtod.c test-strtod1.sh test-strtod1.c signature.h minus-zero.h macros.h + +## end gnulib module strtod-tests + +## begin gnulib module strtoimax-tests + +TESTS += test-strtoimax +check_PROGRAMS += test-strtoimax +EXTRA_DIST += test-strtoimax.c signature.h macros.h + +## end gnulib module strtoimax-tests + +## begin gnulib module strtold-tests + +TESTS += test-strtold +check_PROGRAMS += test-strtold + +TESTS += test-strtold1.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' +check_PROGRAMS += test-strtold1 +test_strtold1_LDADD = $(LDADD) $(LIB_SETLOCALE) +EXTRA_DIST += test-strtold.c test-strtold1.sh test-strtold1.c signature.h minus-zero.h macros.h + +## end gnulib module strtold-tests + +## begin gnulib module strtoll-tests + +TESTS += test-strtoll +check_PROGRAMS += test-strtoll +EXTRA_DIST += test-strtoll.c signature.h macros.h + +## end gnulib module strtoll-tests + +## begin gnulib module strtoull-tests + +TESTS += test-strtoull +check_PROGRAMS += test-strtoull +EXTRA_DIST += test-strtoull.c signature.h macros.h + +## end gnulib module strtoull-tests + +## begin gnulib module strtoumax-tests + +TESTS += test-strtoumax +check_PROGRAMS += test-strtoumax +EXTRA_DIST += test-strtoumax.c signature.h macros.h + +## end gnulib module strtoumax-tests + +## begin gnulib module symlink-tests + +TESTS += test-symlink +check_PROGRAMS += test-symlink +EXTRA_DIST += test-symlink.h test-symlink.c signature.h macros.h + +## end gnulib module symlink-tests + +## begin gnulib module symlinkat-tests + +TESTS += test-symlinkat +check_PROGRAMS += test-symlinkat +test_symlinkat_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-symlink.h test-symlinkat.c signature.h macros.h + +## end gnulib module symlinkat-tests + +## begin gnulib module sys_ioctl-tests + +TESTS += test-sys_ioctl +check_PROGRAMS += test-sys_ioctl +EXTRA_DIST += test-sys_ioctl.c + +## end gnulib module sys_ioctl-tests + +## begin gnulib module sys_resource-tests + +TESTS += test-sys_resource +check_PROGRAMS += test-sys_resource +EXTRA_DIST += test-sys_resource.c + +## end gnulib module sys_resource-tests + +## begin gnulib module sys_select-tests + +TESTS += test-sys_select +check_PROGRAMS += test-sys_select +EXTRA_DIST += test-sys_select.c signature.h + +## end gnulib module sys_select-tests + +## begin gnulib module sys_socket-tests + +TESTS += test-sys_socket +check_PROGRAMS += test-sys_socket +EXTRA_DIST += test-sys_socket.c + +## end gnulib module sys_socket-tests + +## begin gnulib module sys_stat-tests + +TESTS += test-sys_stat +check_PROGRAMS += test-sys_stat +EXTRA_DIST += test-sys_stat.c + +## end gnulib module sys_stat-tests + +## begin gnulib module sys_time-tests + +TESTS += test-sys_time +check_PROGRAMS += test-sys_time +EXTRA_DIST += test-sys_time.c + +## end gnulib module sys_time-tests + +## begin gnulib module sys_types-tests + +TESTS += test-sys_types +check_PROGRAMS += test-sys_types +EXTRA_DIST += test-sys_types.c + +## end gnulib module sys_types-tests + +## begin gnulib module sys_uio-tests + +TESTS += test-sys_uio +check_PROGRAMS += test-sys_uio +EXTRA_DIST += test-sys_uio.c + +## end gnulib module sys_uio-tests + +## begin gnulib module sys_utsname-tests + +TESTS += test-sys_utsname +check_PROGRAMS += test-sys_utsname +EXTRA_DIST += test-sys_utsname.c + +## end gnulib module sys_utsname-tests + +## begin gnulib module sys_wait-tests + +TESTS += test-sys_wait +check_PROGRAMS += test-sys_wait +EXTRA_DIST += test-sys_wait.c test-sys_wait.h + +## end gnulib module sys_wait-tests + +## begin gnulib module termios-tests + +TESTS += test-termios +check_PROGRAMS += test-termios +EXTRA_DIST += test-termios.c + +## end gnulib module termios-tests + +## begin gnulib module test-framework-sh-tests + +TESTS += test-init.sh +EXTRA_DIST += init.sh +EXTRA_DIST += test-init.sh + +## end gnulib module test-framework-sh-tests + +## begin gnulib module thread + +libtests_a_SOURCES += glthread/thread.h glthread/thread.c + +## end gnulib module thread + +## begin gnulib module thread-tests + +TESTS += test-thread_self test-thread_create +check_PROGRAMS += test-thread_self test-thread_create +test_thread_self_LDADD = $(LDADD) @LIBTHREAD@ +test_thread_create_LDADD = $(LDADD) @LIBMULTITHREAD@ +EXTRA_DIST += test-thread_self.c test-thread_create.c macros.h + +## end gnulib module thread-tests + +## begin gnulib module time-tests + +TESTS += test-time +check_PROGRAMS += test-time +EXTRA_DIST += test-time.c + +## end gnulib module time-tests + +## begin gnulib module timespec-add + +libtests_a_SOURCES += timespec-add.c + +## end gnulib module timespec-add + +## begin gnulib module timespec-sub + +libtests_a_SOURCES += timespec-sub.c + +## end gnulib module timespec-sub + +## begin gnulib module timespec-tests + +TESTS += test-timespec +check_PROGRAMS += test-timespec +EXTRA_DIST += test-timespec.c macros.h + +## end gnulib module timespec-tests + +## begin gnulib module tls-tests + +TESTS += test-tls +check_PROGRAMS += test-tls +test_tls_LDADD = $(LDADD) @LIBMULTITHREAD@ @YIELD_LIB@ + +EXTRA_DIST += test-tls.c + +## end gnulib module tls-tests + +## begin gnulib module tmpdir + +libtests_a_SOURCES += tmpdir.h tmpdir.c + +## end gnulib module tmpdir + +## begin gnulib module tmpfile + + +EXTRA_DIST += tmpfile.c + +EXTRA_libtests_a_SOURCES += tmpfile.c + +## end gnulib module tmpfile + +## begin gnulib module u64-tests + +TESTS += test-u64 +check_PROGRAMS += test-u64 +EXTRA_DIST += test-u64.c + +## end gnulib module u64-tests + +## begin gnulib module uname-tests + +TESTS += test-uname +check_PROGRAMS += test-uname +test_uname_LDADD = $(LDADD) @GETHOSTNAME_LIB@ +EXTRA_DIST += test-uname.c signature.h macros.h + +## end gnulib module uname-tests + +## begin gnulib module unistd-safer-tests + +TESTS += test-dup-safer +check_PROGRAMS += test-dup-safer +EXTRA_DIST += test-dup-safer.c macros.h + +## end gnulib module unistd-safer-tests + +## begin gnulib module unistd-tests + +TESTS += test-unistd +check_PROGRAMS += test-unistd +EXTRA_DIST += test-unistd.c + +## end gnulib module unistd-tests + +## begin gnulib module unistr/u8-mbtoucr-tests + +TESTS += test-u8-mbtoucr +check_PROGRAMS += test-u8-mbtoucr +test_u8_mbtoucr_SOURCES = unistr/test-u8-mbtoucr.c +test_u8_mbtoucr_LDADD = $(LDADD) $(LIBUNISTRING) +EXTRA_DIST += unistr/test-u8-mbtoucr.c macros.h + +## end gnulib module unistr/u8-mbtoucr-tests + +## begin gnulib module unistr/u8-uctomb-tests + +TESTS += test-u8-uctomb +check_PROGRAMS += test-u8-uctomb +test_u8_uctomb_SOURCES = unistr/test-u8-uctomb.c +test_u8_uctomb_LDADD = $(LDADD) $(LIBUNISTRING) +EXTRA_DIST += unistr/test-u8-uctomb.c macros.h + +## end gnulib module unistr/u8-uctomb-tests + +## begin gnulib module uniwidth/width-tests + +TESTS += test-uc_width uniwidth/test-uc_width2.sh +check_PROGRAMS += test-uc_width test-uc_width2 +test_uc_width_SOURCES = uniwidth/test-uc_width.c +test_uc_width_LDADD = $(LDADD) $(LIBUNISTRING) +test_uc_width2_SOURCES = uniwidth/test-uc_width2.c +test_uc_width2_LDADD = $(LDADD) $(LIBUNISTRING) +EXTRA_DIST += uniwidth/test-uc_width.c uniwidth/test-uc_width2.c uniwidth/test-uc_width2.sh macros.h + +## end gnulib module uniwidth/width-tests + +## begin gnulib module unlink-tests + +TESTS += test-unlink +check_PROGRAMS += test-unlink +EXTRA_DIST += test-unlink.h test-unlink.c signature.h macros.h + +## end gnulib module unlink-tests + +## begin gnulib module unlinkat-tests + +TESTS += test-unlinkat +check_PROGRAMS += test-unlinkat +test_unlinkat_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-unlinkat.c test-rmdir.h test-unlink.h signature.h macros.h + +## end gnulib module unlinkat-tests + +## begin gnulib module unsetenv-tests + +TESTS += test-unsetenv +check_PROGRAMS += test-unsetenv +EXTRA_DIST += test-unsetenv.c signature.h macros.h + +## end gnulib module unsetenv-tests + +## begin gnulib module update-copyright-tests + +TESTS += test-update-copyright.sh +TESTS_ENVIRONMENT += abs_aux_dir='$(abs_aux_dir)' +EXTRA_DIST += test-update-copyright.sh + +## end gnulib module update-copyright-tests + +## begin gnulib module userspec-tests + +TESTS += test-userspec +check_PROGRAMS += test-userspec +test_userspec_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-userspec.c + +## end gnulib module userspec-tests + +## begin gnulib module usleep + + +EXTRA_DIST += usleep.c + +EXTRA_libtests_a_SOURCES += usleep.c + +## end gnulib module usleep + +## begin gnulib module usleep-tests + +TESTS += test-usleep +check_PROGRAMS += test-usleep +EXTRA_DIST += test-usleep.c signature.h macros.h + +## end gnulib module usleep-tests + +## begin gnulib module utime-h-tests + +TESTS += test-utime-h +check_PROGRAMS += test-utime-h +EXTRA_DIST += test-utime-h.c + +## end gnulib module utime-h-tests + +## begin gnulib module utime-tests + +TESTS += test-utime +check_PROGRAMS += test-utime +test_utime_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_NANOSLEEP) @LIBINTL@ +EXTRA_DIST += test-utime.c nap.h test-utimens-common.h macros.h + +## end gnulib module utime-tests + +## begin gnulib module utimens-tests + +TESTS += test-utimens +check_PROGRAMS += test-utimens +test_utimens_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_NANOSLEEP) @LIBINTL@ +EXTRA_DIST += nap.h test-futimens.h test-lutimens.h test-utimens.h test-utimens-common.h test-utimens.c macros.h + +## end gnulib module utimens-tests + +## begin gnulib module utimensat-tests + +TESTS += test-utimensat +check_PROGRAMS += test-utimensat +test_utimensat_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_NANOSLEEP) @LIBINTL@ +EXTRA_DIST += nap.h test-lutimens.h test-utimens.h test-utimens-common.h test-utimensat.c signature.h macros.h + +## end gnulib module utimensat-tests + +## begin gnulib module vasnprintf-tests + +TESTS += test-vasnprintf +check_PROGRAMS += test-vasnprintf + +EXTRA_DIST += test-vasnprintf.c macros.h + +## end gnulib module vasnprintf-tests + +## begin gnulib module vasprintf-posix-tests + +TESTS += test-vasprintf-posix +check_PROGRAMS += test-vasprintf-posix + +EXTRA_DIST += test-vasprintf-posix.c minus-zero.h infinity.h nan.h macros.h + +## end gnulib module vasprintf-posix-tests + +## begin gnulib module vasprintf-tests + +TESTS += test-vasprintf +check_PROGRAMS += test-vasprintf + +EXTRA_DIST += test-vasprintf.c signature.h macros.h + +## end gnulib module vasprintf-tests + +## begin gnulib module vc-list-files-tests + +TESTS += test-vc-list-files-git.sh +TESTS += test-vc-list-files-cvs.sh +TESTS_ENVIRONMENT += abs_aux_dir='$(abs_aux_dir)' +EXTRA_DIST += test-vc-list-files-git.sh test-vc-list-files-cvs.sh + +## end gnulib module vc-list-files-tests + +## begin gnulib module verify-tests + +TESTS_ENVIRONMENT += MAKE='$(MAKE)' +TESTS += test-verify test-verify.sh +check_PROGRAMS += test-verify +# test-verify-try is never built, but test-verify.sh needs a rule to +# build test-verify-try.o. +EXTRA_PROGRAMS += test-verify-try + +# This test expects compilation of test-verify-try.c to fail, and +# each time it fails, the makefile rule does not perform the usual +# "mv -f $name.Tpo $name.po, so tell make clean to remove that file. +MOSTLYCLEANFILES += .deps/test-verify-try.Tpo +EXTRA_DIST += test-verify.c test-verify-try.c test-verify.sh + +## end gnulib module verify-tests + +## begin gnulib module version-etc-tests + +TESTS += test-version-etc.sh +check_PROGRAMS += test-version-etc +test_version_etc_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-version-etc.c test-version-etc.sh + +## end gnulib module version-etc-tests + +## begin gnulib module vfprintf-posix-tests + +TESTS += test-vfprintf-posix.sh +check_PROGRAMS += test-vfprintf-posix +EXTRA_DIST += test-vfprintf-posix.sh test-vfprintf-posix.c test-fprintf-posix.h test-printf-posix.output infinity.h signature.h macros.h + +## end gnulib module vfprintf-posix-tests + +## begin gnulib module vprintf-posix-tests + +TESTS += test-vprintf-posix.sh +check_PROGRAMS += test-vprintf-posix +EXTRA_DIST += test-vprintf-posix.sh test-vprintf-posix.c test-printf-posix.h test-printf-posix.output infinity.h signature.h macros.h + +## end gnulib module vprintf-posix-tests + +## begin gnulib module wchar-tests + +TESTS += test-wchar +check_PROGRAMS += test-wchar +EXTRA_DIST += test-wchar.c + +## end gnulib module wchar-tests + +## begin gnulib module wcrtomb-tests + +TESTS += \ + test-wcrtomb.sh \ + test-wcrtomb-w32-1.sh test-wcrtomb-w32-2.sh test-wcrtomb-w32-3.sh \ + test-wcrtomb-w32-4.sh test-wcrtomb-w32-5.sh test-wcrtomb-w32-6.sh \ + test-wcrtomb-w32-7.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-wcrtomb test-wcrtomb-w32 +test_wcrtomb_LDADD = $(LDADD) $(LIB_SETLOCALE) +EXTRA_DIST += test-wcrtomb.sh test-wcrtomb.c test-wcrtomb-w32-1.sh test-wcrtomb-w32-2.sh test-wcrtomb-w32-3.sh test-wcrtomb-w32-4.sh test-wcrtomb-w32-5.sh test-wcrtomb-w32-6.sh test-wcrtomb-w32-7.sh test-wcrtomb-w32.c signature.h macros.h + +## end gnulib module wcrtomb-tests + +## begin gnulib module wctob + + +EXTRA_DIST += wctob.c + +EXTRA_libtests_a_SOURCES += wctob.c + +## end gnulib module wctob + +## begin gnulib module wctomb + + +EXTRA_DIST += wctomb-impl.h wctomb.c + +EXTRA_libtests_a_SOURCES += wctomb.c + +## end gnulib module wctomb + +## begin gnulib module wctype-h-tests + +TESTS += test-wctype-h +check_PROGRAMS += test-wctype-h +EXTRA_DIST += test-wctype-h.c macros.h + +## end gnulib module wctype-h-tests + +## begin gnulib module wcwidth-tests + +TESTS += test-wcwidth +check_PROGRAMS += test-wcwidth +test_wcwidth_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBUNISTRING) +EXTRA_DIST += test-wcwidth.c signature.h macros.h + +## end gnulib module wcwidth-tests + +## begin gnulib module write-tests + +TESTS += test-write +check_PROGRAMS += test-write +EXTRA_DIST += test-write.c signature.h macros.h + +## end gnulib module write-tests + +## begin gnulib module xalloc-die-tests + +TESTS += test-xalloc-die.sh +check_PROGRAMS += test-xalloc-die +test_xalloc_die_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-xalloc-die.c test-xalloc-die.sh + +## end gnulib module xalloc-die-tests + +## begin gnulib module xprintf-posix-tests + +TESTS += test-xprintf-posix.sh +check_PROGRAMS += test-xfprintf-posix test-xprintf-posix +test_xfprintf_posix_LDADD = $(LDADD) @LIBINTL@ +test_xprintf_posix_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-xprintf-posix.sh test-xfprintf-posix.c test-xprintf-posix.c test-fprintf-posix.h test-printf-posix.h test-printf-posix.output infinity.h macros.h + +## end gnulib module xprintf-posix-tests + +## begin gnulib module xstrtoimax-tests + +TESTS += test-xstrtoimax.sh +check_PROGRAMS += test-xstrtoimax +test_xstrtoimax_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-xstrtoimax.c test-xstrtoimax.sh + +## end gnulib module xstrtoimax-tests + +## begin gnulib module xstrtol-tests + +TESTS += test-xstrtol.sh +check_PROGRAMS += test-xstrtol test-xstrtoul +test_xstrtol_LDADD = $(LDADD) @LIBINTL@ +test_xstrtoul_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-xstrtol.c test-xstrtoul.c test-xstrtol.sh + +## end gnulib module xstrtol-tests + +## begin gnulib module xstrtoumax-tests + +TESTS += test-xstrtoumax.sh +check_PROGRAMS += test-xstrtoumax +test_xstrtoumax_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-xstrtoumax.c test-xstrtoumax.sh + +## end gnulib module xstrtoumax-tests + +## begin gnulib module xvasprintf-tests + +TESTS += test-xvasprintf +check_PROGRAMS += test-xvasprintf +test_xvasprintf_LDADD = $(LDADD) @LIBINTL@ + +EXTRA_DIST += test-xvasprintf.c macros.h + +## end gnulib module xvasprintf-tests + +## begin gnulib module yesno-tests + +TESTS += test-yesno.sh +check_PROGRAMS += test-yesno +test_yesno_LDADD = $(LDADD) @LIBINTL@ $(LIB_MBRTOWC) +EXTRA_DIST += test-yesno.c test-yesno.sh + +## end gnulib module yesno-tests + +## begin gnulib module yield + +libtests_a_SOURCES += glthread/yield.h + +## end gnulib module yield + +# Clean up after Solaris cc. +clean-local: + rm -rf SunWS_cache + +mostlyclean-local: mostlyclean-generic + @for dir in '' $(MOSTLYCLEANDIRS); do \ + if test -n "$$dir" && test -d $$dir; then \ + echo "rmdir $$dir"; rmdir $$dir; \ + fi; \ + done; \ + : diff --git a/gnulib-tests/inet_pton.c b/gnulib-tests/inet_pton.c new file mode 100644 index 0000000..3e392fc --- /dev/null +++ b/gnulib-tests/inet_pton.c @@ -0,0 +1,268 @@ +/* inet_pton.c -- convert IPv4 and IPv6 addresses from text to binary form + + Copyright (C) 2006, 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* + * Copyright (c) 1996,1999 by Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#include <config.h> + +/* Specification. */ +#include <arpa/inet.h> + +#if HAVE_DECL_INET_PTON + +# undef inet_pton + +int +rpl_inet_pton (int af, const char *restrict src, void *restrict dst) +{ + return inet_pton (af, src, dst); +} + +#else + +# include <c-ctype.h> +# include <string.h> +# include <errno.h> + +# define NS_INADDRSZ 4 +# define NS_IN6ADDRSZ 16 +# define NS_INT16SZ 2 + +/* + * WARNING: Don't even consider trying to compile this on a system where + * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. + */ + +static int inet_pton4 (const char *src, unsigned char *dst); +# if HAVE_IPV6 +static int inet_pton6 (const char *src, unsigned char *dst); +# endif + +/* int + * inet_pton(af, src, dst) + * convert from presentation format (which usually means ASCII printable) + * to network format (which is usually some kind of binary format). + * return: + * 1 if the address was valid for the specified address family + * 0 if the address wasn't valid ('dst' is untouched in this case) + * -1 if some other error occurred ('dst' is untouched in this case, too) + * author: + * Paul Vixie, 1996. + */ +int +inet_pton (int af, const char *restrict src, void *restrict dst) +{ + switch (af) + { + case AF_INET: + return (inet_pton4 (src, dst)); + +# if HAVE_IPV6 + case AF_INET6: + return (inet_pton6 (src, dst)); +# endif + + default: + errno = EAFNOSUPPORT; + return (-1); + } + /* NOTREACHED */ +} + +/* int + * inet_pton4(src, dst) + * like inet_aton() but without all the hexadecimal, octal (with the + * exception of 0) and shorthand. + * return: + * 1 if 'src' is a valid dotted quad, else 0. + * notice: + * does not touch 'dst' unless it's returning 1. + * author: + * Paul Vixie, 1996. + */ +static int +inet_pton4 (const char *restrict src, unsigned char *restrict dst) +{ + int saw_digit, octets, ch; + unsigned char tmp[NS_INADDRSZ], *tp; + + saw_digit = 0; + octets = 0; + *(tp = tmp) = 0; + while ((ch = *src++) != '\0') + { + + if (ch >= '0' && ch <= '9') + { + unsigned new = *tp * 10 + (ch - '0'); + + if (saw_digit && *tp == 0) + return (0); + if (new > 255) + return (0); + *tp = new; + if (!saw_digit) + { + if (++octets > 4) + return (0); + saw_digit = 1; + } + } + else if (ch == '.' && saw_digit) + { + if (octets == 4) + return (0); + *++tp = 0; + saw_digit = 0; + } + else + return (0); + } + if (octets < 4) + return (0); + memcpy (dst, tmp, NS_INADDRSZ); + return (1); +} + +# if HAVE_IPV6 + +/* int + * inet_pton6(src, dst) + * convert presentation level address to network order binary form. + * return: + * 1 if 'src' is a valid [RFC1884 2.2] address, else 0. + * notice: + * (1) does not touch 'dst' unless it's returning 1. + * (2) :: in a full address is silently ignored. + * credit: + * inspired by Mark Andrews. + * author: + * Paul Vixie, 1996. + */ +static int +inet_pton6 (const char *restrict src, unsigned char *restrict dst) +{ + static const char xdigits[] = "0123456789abcdef"; + unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp; + const char *curtok; + int ch, saw_xdigit; + unsigned val; + + tp = memset (tmp, '\0', NS_IN6ADDRSZ); + endp = tp + NS_IN6ADDRSZ; + colonp = NULL; + /* Leading :: requires some special handling. */ + if (*src == ':') + if (*++src != ':') + return (0); + curtok = src; + saw_xdigit = 0; + val = 0; + while ((ch = c_tolower (*src++)) != '\0') + { + const char *pch; + + pch = strchr (xdigits, ch); + if (pch != NULL) + { + val <<= 4; + val |= (pch - xdigits); + if (val > 0xffff) + return (0); + saw_xdigit = 1; + continue; + } + if (ch == ':') + { + curtok = src; + if (!saw_xdigit) + { + if (colonp) + return (0); + colonp = tp; + continue; + } + else if (*src == '\0') + { + return (0); + } + if (tp + NS_INT16SZ > endp) + return (0); + *tp++ = (u_char) (val >> 8) & 0xff; + *tp++ = (u_char) val & 0xff; + saw_xdigit = 0; + val = 0; + continue; + } + if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) && + inet_pton4 (curtok, tp) > 0) + { + tp += NS_INADDRSZ; + saw_xdigit = 0; + break; /* '\0' was seen by inet_pton4(). */ + } + return (0); + } + if (saw_xdigit) + { + if (tp + NS_INT16SZ > endp) + return (0); + *tp++ = (u_char) (val >> 8) & 0xff; + *tp++ = (u_char) val & 0xff; + } + if (colonp != NULL) + { + /* + * Since some memmove()'s erroneously fail to handle + * overlapping regions, we'll do the shift by hand. + */ + const int n = tp - colonp; + int i; + + if (tp == endp) + return (0); + for (i = 1; i <= n; i++) + { + endp[-i] = colonp[n - i]; + colonp[n - i] = 0; + } + tp = endp; + } + if (tp != endp) + return (0); + memcpy (dst, tmp, NS_IN6ADDRSZ); + return (1); +} + +# endif + +#endif diff --git a/gnulib-tests/infinity.h b/gnulib-tests/infinity.h new file mode 100644 index 0000000..d8bf1a8 --- /dev/null +++ b/gnulib-tests/infinity.h @@ -0,0 +1,66 @@ +/* Macros for infinity. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + + +/* Infinityf () returns a 'float' +Infinity. */ + +/* The Microsoft MSVC 9 compiler chokes on the expression 1.0f / 0.0f. + The IBM XL C compiler on z/OS complains. + PGI 16.10 complains. */ +#if defined _MSC_VER || (defined __MVS__ && defined __IBMC__) || defined __PGI +static float +Infinityf () +{ + static float zero = 0.0f; + return 1.0f / zero; +} +#else +# define Infinityf() (1.0f / 0.0f) +#endif + + +/* Infinityd () returns a 'double' +Infinity. */ + +/* The Microsoft MSVC 9 compiler chokes on the expression 1.0 / 0.0. + The IBM XL C compiler on z/OS complains. + PGI 16.10 complains. */ +#if defined _MSC_VER || (defined __MVS__ && defined __IBMC__) || defined __PGI +static double +Infinityd () +{ + static double zero = 0.0; + return 1.0 / zero; +} +#else +# define Infinityd() (1.0 / 0.0) +#endif + + +/* Infinityl () returns a 'long double' +Infinity. */ + +/* The Microsoft MSVC 9 compiler chokes on the expression 1.0L / 0.0L. + The IBM XL C compiler on z/OS complains. + PGI 16.10 complains. */ +#if defined _MSC_VER || (defined __MVS__ && defined __IBMC__) || defined __PGI +static long double +Infinityl () +{ + static long double zero = 0.0L; + return 1.0L / zero; +} +#else +# define Infinityl() (1.0L / 0.0L) +#endif diff --git a/gnulib-tests/init.sh b/gnulib-tests/init.sh new file mode 100644 index 0000000..b4a5944 --- /dev/null +++ b/gnulib-tests/init.sh @@ -0,0 +1,683 @@ +# source this file; set up for tests + +# Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. + +# Using this file in a test +# ========================= +# +# The typical skeleton of a test looks like this: +# +# #!/bin/sh +# . "${srcdir=.}/init.sh"; path_prepend_ . +# Execute some commands. +# Note that these commands are executed in a subdirectory, therefore you +# need to prepend "../" to relative filenames in the build directory. +# Note that the "path_prepend_ ." is useful only if the body of your +# test invokes programs residing in the initial directory. +# For example, if the programs you want to test are in src/, and this test +# script is named tests/test-1, then you would use "path_prepend_ ../src", +# or perhaps export PATH='$(abs_top_builddir)/src$(PATH_SEPARATOR)'"$$PATH" +# to all tests via automake's TESTS_ENVIRONMENT. +# Set the exit code 0 for success, 77 for skipped, or 1 or other for failure. +# Use the skip_ and fail_ functions to print a diagnostic and then exit +# with the corresponding exit code. +# Exit $? + +# Executing a test that uses this file +# ==================================== +# +# Running a single test: +# $ make check TESTS=test-foo.sh +# +# Running a single test, with verbose output: +# $ make check TESTS=test-foo.sh VERBOSE=yes +# +# Running a single test, keeping the temporary directory: +# $ make check TESTS=test-foo.sh KEEP=yes +# +# Running a single test, with single-stepping: +# 1. Go into a sub-shell: +# $ bash +# 2. Set relevant environment variables from TESTS_ENVIRONMENT in the +# Makefile: +# $ export srcdir=../../tests # this is an example +# 3. Execute the commands from the test, copy&pasting them one by one: +# $ . "$srcdir/init.sh"; path_prepend_ . +# ... +# 4. Finally +# $ exit + +# ============================================================================= +# Elementary diagnostics + +ME_=`expr "./$0" : '.*/\(.*\)$'` + +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which + # contains only /bin. Note that ksh looks also at the FPATH variable, + # so we have to set that as well for the test. + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ + && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ + || PATH_SEPARATOR=';' + } +fi + +# We use a trap below for cleanup. This requires us to go through +# hoops to get the right exit status transported through the handler. +# So use 'Exit STATUS' instead of 'exit STATUS' inside of the tests. +# Turn off errexit here so that we don't trip the bug with OSF1/Tru64 +# sh inside this function. +Exit () { set +e; (exit $1); exit $1; } + +# Print warnings (e.g., about skipped and failed tests) to this file number. +# Override by defining to say, 9, in init.cfg, and putting say, +# export ...ENVVAR_SETTINGS...; $(SHELL) 9>&2 +# in the definition of TESTS_ENVIRONMENT in your tests/Makefile.am file. +# This is useful when using automake's parallel tests mode, to print +# the reason for skip/failure to console, rather than to the .log files. +: ${stderr_fileno_=2} + +# Note that correct expansion of "$*" depends on IFS starting with ' '. +# Always write the full diagnostic to stderr. +# When stderr_fileno_ is not 2, also emit the first line of the +# diagnostic to that file descriptor. +warn_ () +{ + # If IFS does not start with ' ', set it and emit the warning in a subshell. + case $IFS in + ' '*) printf '%s\n' "$*" >&2 + test $stderr_fileno_ = 2 \ + || { printf '%s\n' "$*" | sed 1q >&$stderr_fileno_ ; } ;; + *) (IFS=' '; warn_ "$@");; + esac +} +fail_ () { warn_ "$ME_: failed test: $@"; Exit 1; } +skip_ () { warn_ "$ME_: skipped test: $@"; Exit 77; } +fatal_ () { warn_ "$ME_: hard error: $@"; Exit 99; } +framework_failure_ () { warn_ "$ME_: set-up failure: $@"; Exit 99; } + +# ============================================================================= +# Ensure the shell supports modern syntax. + +# Sanitize this shell to POSIX mode, if possible. +DUALCASE=1; export DUALCASE +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; + esac +fi + +# We require $(...) support unconditionally. +# We require that the printf built-in work correctly regarding octal escapes; +# this eliminates /bin/sh on AIX 7.2. +# We require non-surprising "local" semantics (this eliminates dash). +# This takes the admittedly draconian step of eliminating dash, because the +# assignment tab=$(printf '\t') works fine, yet preceding it with "local " +# transforms it into an assignment that sets the variable to the empty string. +# That is too counter-intuitive, and can lead to subtle run-time malfunction. +# The example below is less subtle in that with dash, it evokes the run-time +# exception "dash: 1: local: 1: bad variable name". +# We require a few additional shell features only when $EXEEXT is nonempty, +# in order to support automatic $EXEEXT emulation: +# - hyphen-containing alias names +# - we prefer to use ${var#...} substitution, rather than having +# to work around lack of support for that feature. +# The following code attempts to find a shell with support for these features. +# If the current shell passes the test, we're done. Otherwise, test other +# shells until we find one that passes. If one is found, re-exec it. +# If no acceptable shell is found, skip the current test. +# +# The "...set -x; P=1 true 2>err..." test is to disqualify any shell that +# emits "P=1" into err, as /bin/sh from SunOS 5.11 and OpenBSD 4.7 do. +# +# Use "9" to indicate success (rather than 0), in case some shell acts +# like Solaris 10's /bin/sh but exits successfully instead of with status 2. + +# Eval this code in a subshell to determine a shell's suitability. +# 10 - passes all tests; ok to use +# 9 - ok, but enabling "set -x" corrupts app stderr; prefer higher score +# ? - not ok +gl_shell_test_script_=' +test $(echo y) = y || exit 1 +LC_ALL=en_US.UTF-8 printf "\\351" 2>/dev/null \ + | LC_ALL=C tr "\\351" x | LC_ALL=C grep "^x$" > /dev/null \ + || exit 1 +printf "\\351" 2>/dev/null \ + | LC_ALL=C tr "\\351" x | LC_ALL=C grep "^x$" > /dev/null \ + || exit 1 +f_local_() { local v=1; }; f_local_ || exit 1 +f_dash_local_fail_() { local t=$(printf " 1"); }; f_dash_local_fail_ +score_=10 +if test "$VERBOSE" = yes; then + test -n "$( (exec 3>&1; set -x; P=1 true 2>&3) 2> /dev/null)" && score_=9 +fi +test -z "$EXEEXT" && exit $score_ +shopt -s expand_aliases +alias a-b="echo zoo" +v=abx + test ${v%x} = ab \ + && test ${v#a} = bx \ + && test $(a-b) = zoo \ + && exit $score_ +' + +if test "x$1" = "x--no-reexec"; then + shift +else + # Assume a working shell. Export to subshells (setup_ needs this). + gl_set_x_corrupts_stderr_=false + export gl_set_x_corrupts_stderr_ + + # Record the first marginally acceptable shell. + marginal_= + + # Search for a shell that meets our requirements. + for re_shell_ in __current__ "${CONFIG_SHELL:-no_shell}" \ + /bin/sh bash dash zsh pdksh fail + do + test "$re_shell_" = no_shell && continue + + # If we've made it all the way to the sentinel, "fail" without + # finding even a marginal shell, skip this test. + if test "$re_shell_" = fail; then + test -z "$marginal_" && skip_ failed to find an adequate shell + re_shell_=$marginal_ + break + fi + + # When testing the current shell, simply "eval" the test code. + # Otherwise, run it via $re_shell_ -c ... + if test "$re_shell_" = __current__; then + # 'eval'ing this code makes Solaris 10's /bin/sh exit with + # $? set to 2. It does not evaluate any of the code after the + # "unexpected" first '('. Thus, we must run it in a subshell. + ( eval "$gl_shell_test_script_" ) > /dev/null 2>&1 + else + "$re_shell_" -c "$gl_shell_test_script_" 2>/dev/null + fi + + st_=$? + + # $re_shell_ works just fine. Use it. + if test $st_ = 10; then + gl_set_x_corrupts_stderr_=false + break + fi + + # If this is our first marginally acceptable shell, remember it. + if test "$st_:$marginal_" = 9: ; then + marginal_="$re_shell_" + gl_set_x_corrupts_stderr_=true + fi + done + + if test "$re_shell_" != __current__; then + # Found a usable shell. Preserve -v and -x. + case $- in + *v*x* | *x*v*) opts_=-vx ;; + *v*) opts_=-v ;; + *x*) opts_=-x ;; + *) opts_= ;; + esac + re_shell=$re_shell_ + export re_shell + exec "$re_shell_" $opts_ "$0" --no-reexec "$@" + echo "$ME_: exec failed" 1>&2 + exit 127 + fi +fi + +# ============================================================================= +# Ensure the shell behaves reasonably. + +# If this is bash, turn off all aliases. +test -n "$BASH_VERSION" && unalias -a + +# Note that when supporting $EXEEXT (transparently mapping from PROG_NAME to +# PROG_NAME.exe), we want to support hyphen-containing names like test-acos. +# That is part of the shell-selection test above. Why use aliases rather +# than functions? Because support for hyphen-containing aliases is more +# widespread than that for hyphen-containing function names. +test -n "$EXEEXT" && test -n "$BASH_VERSION" && shopt -s expand_aliases + +# ============================================================================= +# Creating a temporary directory (needed by the core test framework) + +# Create a temporary directory, much like mktemp -d does. +# Written by Jim Meyering. +# +# Usage: mktempd_ /tmp phoey.XXXXXXXXXX +# +# First, try to use the mktemp program. +# Failing that, we'll roll our own mktemp-like function: +# - try to get random bytes from /dev/urandom +# - failing that, generate output from a combination of quickly-varying +# sources and gzip. Ignore non-varying gzip header, and extract +# "random" bits from there. +# - given those bits, map to file-name bytes using tr, and try to create +# the desired directory. +# - make only $MAX_TRIES_ attempts + +# Helper function. Print $N pseudo-random bytes from a-zA-Z0-9. +rand_bytes_ () +{ + n_=$1 + + # Maybe try openssl rand -base64 $n_prime_|tr '+/=\012' abcd first? + # But if they have openssl, they probably have mktemp, too. + + chars_=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 + dev_rand_=/dev/urandom + if test -r "$dev_rand_"; then + # Note: 256-length($chars_) == 194; 3 copies of $chars_ is 186 + 8 = 194. + dd ibs=$n_ count=1 if=$dev_rand_ 2>/dev/null \ + | LC_ALL=C tr -c $chars_ 01234567$chars_$chars_$chars_ + return + fi + + n_plus_50_=`expr $n_ + 50` + cmds_='date; date +%N; free; who -a; w; ps auxww; ps -ef' + data_=` (eval "$cmds_") 2>&1 | gzip ` + + # Ensure that $data_ has length at least 50+$n_ + while :; do + len_=`echo "$data_"|wc -c` + test $n_plus_50_ -le $len_ && break; + data_=` (echo "$data_"; eval "$cmds_") 2>&1 | gzip ` + done + + echo "$data_" \ + | dd bs=1 skip=50 count=$n_ 2>/dev/null \ + | LC_ALL=C tr -c $chars_ 01234567$chars_$chars_$chars_ +} + +mktempd_ () +{ + case $# in + 2);; + *) fail_ "Usage: mktempd_ DIR TEMPLATE";; + esac + + destdir_=$1 + template_=$2 + + MAX_TRIES_=4 + + # Disallow any trailing slash on specified destdir: + # it would subvert the post-mktemp "case"-based destdir test. + case $destdir_ in + / | //) destdir_slash_=$destdir;; + */) fail_ "invalid destination dir: remove trailing slash(es)";; + *) destdir_slash_=$destdir_/;; + esac + + case $template_ in + *XXXX) ;; + *) fail_ \ + "invalid template: $template_ (must have a suffix of at least 4 X's)";; + esac + + # First, try to use mktemp. + d=`unset TMPDIR; { mktemp -d -t -p "$destdir_" "$template_"; } 2>/dev/null` && + + # The resulting name must be in the specified directory. + case $d in "$destdir_slash_"*) :;; *) false;; esac && + + # It must have created the directory. + test -d "$d" && + + # It must have 0700 permissions. Handle sticky "S" bits. + perms=`ls -dgo "$d" 2>/dev/null` && + case $perms in drwx--[-S]---*) :;; *) false;; esac && { + echo "$d" + return + } + + # If we reach this point, we'll have to create a directory manually. + + # Get a copy of the template without its suffix of X's. + base_template_=`echo "$template_"|sed 's/XX*$//'` + + # Calculate how many X's we've just removed. + template_length_=`echo "$template_" | wc -c` + nx_=`echo "$base_template_" | wc -c` + nx_=`expr $template_length_ - $nx_` + + err_= + i_=1 + while :; do + X_=`rand_bytes_ $nx_` + candidate_dir_="$destdir_slash_$base_template_$X_" + err_=`mkdir -m 0700 "$candidate_dir_" 2>&1` \ + && { echo "$candidate_dir_"; return; } + test $MAX_TRIES_ -le $i_ && break; + i_=`expr $i_ + 1` + done + fail_ "$err_" +} + +# ============================================================================= +# Core test framework + +# An arbitrary prefix to help distinguish test directories. +testdir_prefix_ () { printf gt; } + +# Set up the environment for the test to run in. +setup_ () +{ + if test "$VERBOSE" = yes; then + # Test whether set -x may cause the selected shell to corrupt an + # application's stderr. Many do, including zsh-4.3.10 and the /bin/sh + # from SunOS 5.11, OpenBSD 4.7 and Irix 5.x and 6.5. + # If enabling verbose output this way would cause trouble, simply + # issue a warning and refrain. + if $gl_set_x_corrupts_stderr_; then + warn_ "using SHELL=$SHELL with 'set -x' corrupts stderr" + else + set -x + fi + fi + + initial_cwd_=$PWD + + # Create and enter the temporary directory. + pfx_=`testdir_prefix_` + test_dir_=`mktempd_ "$initial_cwd_" "$pfx_-$ME_.XXXX"` \ + || fail_ "failed to create temporary directory in $initial_cwd_" + cd "$test_dir_" || fail_ "failed to cd to temporary directory" + # Set variables srcdir, builddir, for the convenience of the test. + case $srcdir in + /* | ?:*) ;; + *) srcdir="../$srcdir" ;; + esac + builddir=".." + export srcdir builddir + + # As autoconf-generated configure scripts do, ensure that IFS + # is defined initially, so that saving and restoring $IFS works. + gl_init_sh_nl_=' +' + IFS=" "" $gl_init_sh_nl_" + + # This trap statement, along with a trap on 0 below, ensure that the + # temporary directory, $test_dir_, is removed upon exit as well as + # upon receipt of any of the listed signals. + for sig_ in 1 2 3 13 15; do + eval "trap 'Exit $(expr $sig_ + 128)' $sig_" + done +} + +# This is a stub function that is run upon trap (upon regular exit and +# interrupt). Override it with a per-test function, e.g., to unmount +# a partition, or to undo any other global state changes. +cleanup_ () { :; } + +# Run the user-overridable cleanup_ function, remove the temporary +# directory and exit with the incoming value of $?. +remove_tmp_ () +{ + __st=$? + cleanup_ + if test "$KEEP" = yes; then + echo "Not removing temporary directory $test_dir_" + else + # cd out of the directory we're about to remove + cd "$initial_cwd_" || cd / || cd /tmp + chmod -R u+rwx "$test_dir_" + # If removal fails and exit status was to be 0, then change it to 1. + rm -rf "$test_dir_" || { test $__st = 0 && __st=1; } + fi + exit $__st +} + +# ============================================================================= +# Prepending directories to PATH + +# Given a directory name, DIR, if every entry in it that matches *.exe +# contains only the specified bytes (see the case stmt below), then print +# a space-separated list of those names and return 0. Otherwise, don't +# print anything and return 1. Naming constraints apply also to DIR. +find_exe_basenames_ () +{ + feb_dir_=$1 + feb_fail_=0 + feb_result_= + feb_sp_= + for feb_file_ in $feb_dir_/*.exe; do + # If there was no *.exe file, or there existed a file named "*.exe" that + # was deleted between the above glob expansion and the existence test + # below, just skip it. + test "x$feb_file_" = "x$feb_dir_/*.exe" && test ! -f "$feb_file_" \ + && continue + # Exempt [.exe, since we can't create a function by that name, yet + # we can't invoke [ by PATH search anyways due to shell builtins. + test "x$feb_file_" = "x$feb_dir_/[.exe" && continue + case $feb_file_ in + *[!-a-zA-Z/0-9_.+]*) feb_fail_=1; break;; + *) # Remove leading file name components as well as the .exe suffix. + feb_file_=${feb_file_##*/} + feb_file_=${feb_file_%.exe} + feb_result_="$feb_result_$feb_sp_$feb_file_";; + esac + feb_sp_=' ' + done + test $feb_fail_ = 0 && printf %s "$feb_result_" + return $feb_fail_ +} + +# Consider the files in directory, $1. +# For each file name of the form PROG.exe, create an alias named +# PROG that simply invokes PROG.exe, then return 0. If any selected +# file name or the directory name, $1, contains an unexpected character, +# define no alias and return 1. +create_exe_shims_ () +{ + case $EXEEXT in + '') return 0 ;; + .exe) ;; + *) echo "$0: unexpected \$EXEEXT value: $EXEEXT" 1>&2; return 1 ;; + esac + + base_names_=`find_exe_basenames_ $1` \ + || { echo "$0 (exe_shim): skipping directory: $1" 1>&2; return 0; } + + if test -n "$base_names_"; then + for base_ in $base_names_; do + alias "$base_"="$base_$EXEEXT" + done + fi + + return 0 +} + +# Use this function to prepend to PATH an absolute name for each +# specified, possibly-$initial_cwd_-relative, directory. +path_prepend_ () +{ + while test $# != 0; do + path_dir_=$1 + case $path_dir_ in + '') fail_ "invalid path dir: '$1'";; + /* | ?:*) abs_path_dir_=$path_dir_;; + *) abs_path_dir_=$initial_cwd_/$path_dir_;; + esac + case $abs_path_dir_ in + *$PATH_SEPARATOR*) fail_ "invalid path dir: '$abs_path_dir_'";; + esac + PATH="$abs_path_dir_$PATH_SEPARATOR$PATH" + + # Create an alias, FOO, for each FOO.exe in this directory. + create_exe_shims_ "$abs_path_dir_" \ + || fail_ "something failed (above): $abs_path_dir_" + shift + done + export PATH +} + +# ============================================================================= +# Convenience environment variables for the tests + +# ----------------------------------------------------------------------------- + +# Enable glibc's malloc-perturbing option. +# This is useful for exposing code that depends on the fact that +# malloc-related functions often return memory that is mostly zeroed. +# If you have the time and cycles, use valgrind to do an even better job. +: ${MALLOC_PERTURB_=87} +export MALLOC_PERTURB_ + +# ----------------------------------------------------------------------------- + +# The interpreter for Bourne-shell scripts. +# No special standards compatibility requirements. +# Some environments, such as Android, don't have /bin/sh. +if test -f /bin/sh$EXEEXT; then + BOURNE_SHELL=/bin/sh +else + BOURNE_SHELL=sh +fi + +# ============================================================================= +# Convenience functions for the tests + +# ----------------------------------------------------------------------------- +# Return value checking + +# This is used to simplify checking of the return value +# which is useful when ensuring a command fails as desired. +# I.e., just doing `command ... &&fail=1` will not catch +# a segfault in command for example. With this helper you +# instead check an explicit exit code like +# returns_ 1 command ... || fail +returns_ () { + # Disable tracing so it doesn't interfere with stderr of the wrapped command + { set +x; } 2>/dev/null + + local exp_exit="$1" + shift + "$@" + test $? -eq $exp_exit && ret_=0 || ret_=1 + + if test "$VERBOSE" = yes && test "$gl_set_x_corrupts_stderr_" = false; then + set -x + fi + { return $ret_; } 2>/dev/null +} + +# ----------------------------------------------------------------------------- +# Text file comparison + +# Emit a header similar to that from diff -u; Print the simulated "diff" +# command so that the order of arguments is clear. Don't bother with @@ lines. +emit_diff_u_header_ () +{ + printf '%s\n' "diff -u $*" \ + "--- $1 1970-01-01" \ + "+++ $2 1970-01-01" +} + +# Arrange not to let diff or cmp operate on /dev/null, +# since on some systems (at least OSF/1 5.1), that doesn't work. +# When there are not two arguments, or no argument is /dev/null, return 2. +# When one argument is /dev/null and the other is not empty, +# cat the nonempty file to stderr and return 1. +# Otherwise, return 0. +compare_dev_null_ () +{ + test $# = 2 || return 2 + + if test "x$1" = x/dev/null; then + test -s "$2" || return 0 + emit_diff_u_header_ "$@"; sed 's/^/+/' "$2" + return 1 + fi + + if test "x$2" = x/dev/null; then + test -s "$1" || return 0 + emit_diff_u_header_ "$@"; sed 's/^/-/' "$1" + return 1 + fi + + return 2 +} + +for diff_opt_ in -u -U3 -c '' no; do + test "$diff_opt_" != no && + diff_out_=`exec 2>/dev/null; diff $diff_opt_ "$0" "$0" < /dev/null` && + break +done +if test "$diff_opt_" != no; then + if test -z "$diff_out_"; then + compare_ () { diff $diff_opt_ "$@"; } + else + compare_ () + { + # If no differences were found, AIX and HP-UX 'diff' produce output + # like "No differences encountered". Hide this output. + diff $diff_opt_ "$@" > diff.out + diff_status_=$? + test $diff_status_ -eq 0 || cat diff.out || diff_status_=2 + rm -f diff.out || diff_status_=2 + return $diff_status_ + } + fi +elif cmp -s /dev/null /dev/null 2>/dev/null; then + compare_ () { cmp -s "$@"; } +else + compare_ () { cmp "$@"; } +fi + +# Usage: compare EXPECTED ACTUAL +# +# Given compare_dev_null_'s preprocessing, defer to compare_ if 2 or more. +# Otherwise, propagate $? to caller: any diffs have already been printed. +compare () +{ + # This looks like it can be factored to use a simple "case $?" + # after unchecked compare_dev_null_ invocation, but that would + # fail in a "set -e" environment. + if compare_dev_null_ "$@"; then + return 0 + else + case $? in + 1) return 1;; + *) compare_ "$@";; + esac + fi +} + +# ----------------------------------------------------------------------------- + +# If you want to override the testdir_prefix_ function, +# or to add more utility functions, use this file. +test -f "$srcdir/init.cfg" \ + && . "$srcdir/init.cfg" + +# ============================================================================= +# Set up the environment for the test to run in. + +setup_ "$@" +# This trap is here, rather than in the setup_ function, because some +# shells run the exit trap at shell function exit, rather than script exit. +trap remove_tmp_ 0 diff --git a/gnulib-tests/ioctl.c b/gnulib-tests/ioctl.c new file mode 100644 index 0000000..eb2e825 --- /dev/null +++ b/gnulib-tests/ioctl.c @@ -0,0 +1,92 @@ +/* ioctl.c --- wrappers for Windows ioctl function + + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Paolo Bonzini */ + +#include <config.h> + +#include <sys/ioctl.h> + +#include <stdarg.h> + +#if HAVE_IOCTL + +/* Provide a wrapper with the POSIX prototype. */ +# undef ioctl +int +rpl_ioctl (int fd, int request, ... /* {void *,char *} arg */) +{ + void *buf; + va_list args; + + va_start (args, request); + buf = va_arg (args, void *); + va_end (args); + + /* Cast 'request' so that when the system's ioctl function takes a 64-bit + request argument, the value gets zero-extended, not sign-extended. */ + return ioctl (fd, (unsigned int) request, buf); +} + +#else /* mingw */ + +# include <errno.h> + +/* Get HANDLE. */ +# define WIN32_LEAN_AND_MEAN +# include <windows.h> + +# include "fd-hook.h" +/* Get _get_osfhandle. */ +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include <io.h> +# endif + +static int +primary_ioctl (int fd, int request, void *arg) +{ + /* We don't support FIONBIO on pipes here. If you want to make pipe + fds non-blocking, use the gnulib 'nonblocking' module, until + gnulib implements fcntl F_GETFL / F_SETFL with O_NONBLOCK. */ + + if ((HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE) + errno = ENOSYS; + else + errno = EBADF; + return -1; +} + +int +ioctl (int fd, int request, ... /* {void *,char *} arg */) +{ + void *arg; + va_list args; + + va_start (args, request); + arg = va_arg (args, void *); + va_end (args); + +# if WINDOWS_SOCKETS + return execute_all_ioctl_hooks (primary_ioctl, fd, request, arg); +# else + return primary_ioctl (fd, request, arg); +# endif +} + +#endif diff --git a/gnulib-tests/listen.c b/gnulib-tests/listen.c new file mode 100644 index 0000000..c1db145 --- /dev/null +++ b/gnulib-tests/listen.c @@ -0,0 +1,49 @@ +/* listen.c --- wrappers for Windows listen function + + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Paolo Bonzini */ + +#include <config.h> + +#define WIN32_LEAN_AND_MEAN +/* Get winsock2.h. */ +#include <sys/socket.h> + +/* Get set_winsock_errno, FD_TO_SOCKET etc. */ +#include "w32sock.h" + +#undef listen + +int +rpl_listen (int fd, int backlog) +{ + SOCKET sock = FD_TO_SOCKET (fd); + + if (sock == INVALID_SOCKET) + { + errno = EBADF; + return -1; + } + else + { + int r = listen (sock, backlog); + if (r < 0) + set_winsock_errno (); + + return r; + } +} diff --git a/gnulib-tests/locale.c b/gnulib-tests/locale.c new file mode 100644 index 0000000..323040c --- /dev/null +++ b/gnulib-tests/locale.c @@ -0,0 +1,85 @@ +/* Program that prints the names of the categories of the current locale. + Copyright (C) 2019-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2019. */ + +#include <config.h> + +#include <locale.h> +#include <stdio.h> +#include <stdlib.h> + +/* We want to use the system's setlocale() function here, not the gnulib + override. */ +#undef setlocale + +/* Specification: + <https://pubs.opengroup.org/onlinepubs/9699919799/utilities/locale.html> + Here we implement only the invocation without any command-line options. */ + +static const char * +defaulted_getenv (const char *variable) +{ + const char *value = getenv (variable); + return (value != NULL ? value : ""); +} + +static void +print_category (int category, const char *variable) +{ + const char *value = defaulted_getenv (variable); + if (value[0] != '\0' && defaulted_getenv ("LC_ALL")[0] == '\0') + /* The variable is set in the environment and not overridden by LC_ALL. */ + printf ("%s=%s\n", variable, value); + else + printf ("%s=\"%s\"\n", variable, setlocale (category, NULL)); +} + +int +main () +{ + setlocale (LC_ALL, ""); + + printf ("LANG=%s\n", defaulted_getenv ("LANG")); + print_category (LC_CTYPE, "LC_CTYPE"); + print_category (LC_NUMERIC, "LC_NUMERIC"); + print_category (LC_TIME, "LC_TIME"); + print_category (LC_COLLATE, "LC_COLLATE"); + print_category (LC_MONETARY, "LC_MONETARY"); + print_category (LC_MESSAGES, "LC_MESSAGES"); +#ifdef LC_PAPER + print_category (LC_PAPER, "LC_PAPER"); +#endif +#ifdef LC_NAME + print_category (LC_NAME, "LC_NAME"); +#endif +#ifdef LC_ADDRESS + print_category (LC_ADDRESS, "LC_ADDRESS"); +#endif +#ifdef LC_TELEPHONE + print_category (LC_TELEPHONE, "LC_TELEPHONE"); +#endif +#ifdef LC_MEASUREMENT + print_category (LC_MEASUREMENT, "LC_MEASUREMENT"); +#endif +#ifdef LC_IDENTIFICATION + print_category (LC_IDENTIFICATION, "LC_IDENTIFICATION"); +#endif + + printf ("LC_ALL=%s\n", defaulted_getenv ("LC_ALL")); + + return 0; +} diff --git a/gnulib-tests/localename-table.c b/gnulib-tests/localename-table.c new file mode 100644 index 0000000..89db245 --- /dev/null +++ b/gnulib-tests/localename-table.c @@ -0,0 +1,48 @@ +/* Table that maps a locale object to the names of the locale categories. + Copyright (C) 2018-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2018. */ + +#include <config.h> + +#if HAVE_WORKING_USELOCALE && HAVE_NAMELESS_LOCALES + +/* Specification. */ +#include "localename-table.h" + +#include <stdint.h> + +/* A hash function for pointers. */ +size_t _GL_ATTRIBUTE_CONST +locale_hash_function (locale_t x) +{ + uintptr_t p = (uintptr_t) x; + size_t h = ((p % 4177) << 12) + ((p % 79) << 6) + (p % 61); + return h; +} + +struct locale_hash_node * locale_hash_table[LOCALE_HASH_TABLE_SIZE] + /* = { NULL, ..., NULL } */; + +gl_rwlock_define_initialized(, locale_lock) + +#else + +/* This declaration is solely to ensure that after preprocessing + this file is never empty. */ +typedef int dummy; + +#endif diff --git a/gnulib-tests/localename-table.h b/gnulib-tests/localename-table.h new file mode 100644 index 0000000..d9b8128 --- /dev/null +++ b/gnulib-tests/localename-table.h @@ -0,0 +1,73 @@ +/* Table that maps a locale object to the names of the locale categories. + Copyright (C) 2018-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2018. */ + +#if HAVE_WORKING_USELOCALE && HAVE_NAMELESS_LOCALES + +# include <stddef.h> +# include <locale.h> + +# ifdef IN_LIBINTL +# include "lock.h" +# else +# include "glthread/lock.h" +# endif + +struct locale_categories_names + { + /* Locale category -> name (allocated with indefinite extent). */ + const char *category_name[6]; + }; + +/* A hash table of fixed size. Multiple threads can access it read-only + simultaneously, but only one thread can insert into it or remove from it + at the same time. + This hash table has global scope, so that when an application uses both + GNU libintl and gnulib, the application sees only one hash table. (When + linking statically with libintl, the fact that localename-table.c is a + separate compilation unit resolves the duplicate symbol conflict. When + linking with libintl as a shared library, we rely on ELF and the symbol + conflict resolution implemented in the ELF dynamic loader here.) + Both the libintl overrides and the gnulib overrides of the functions + newlocale, duplocale, freelocale see the same hash table (and the same lock). + For this reason, the internal layout of the hash table and the hash function + MUST NEVER CHANGE. If you need to change the internal layout or the hash + function, introduce versioning by appending a version suffix to the symbols + at the linker level. */ +# define locale_hash_function libintl_locale_hash_function +# define locale_hash_table libintl_locale_hash_table +# define locale_lock libintl_locale_lock + +extern size_t _GL_ATTRIBUTE_CONST locale_hash_function (locale_t x); + +/* A node in a hash bucket collision list. */ +struct locale_hash_node + { + struct locale_hash_node *next; + locale_t locale; + struct locale_categories_names names; + }; + +# define LOCALE_HASH_TABLE_SIZE 101 +extern struct locale_hash_node * locale_hash_table[LOCALE_HASH_TABLE_SIZE]; + +/* This lock protects the locale_hash_table against multiple simultaneous + accesses (except that multiple simultaneous read accesses are allowed). */ + +gl_rwlock_define(extern, locale_lock) + +#endif diff --git a/gnulib-tests/localename.c b/gnulib-tests/localename.c new file mode 100644 index 0000000..20be646 --- /dev/null +++ b/gnulib-tests/localename.c @@ -0,0 +1,3460 @@ +/* Determine name of the currently selected locale. + Copyright (C) 1995-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Ulrich Drepper <drepper@gnu.org>, 1995. */ +/* Native Windows code written by Tor Lillqvist <tml@iki.fi>. */ +/* Mac OS X code written by Bruno Haible <bruno@clisp.org>. */ + +#include <config.h> + +/* Specification. */ +#ifdef IN_LIBINTL +# include "gettextP.h" +#else +# include "localename.h" +#endif + +#include <limits.h> +#include <stddef.h> +#include <stdlib.h> +#include <locale.h> +#include <string.h> + +#include "flexmember.h" +#include "setlocale_null.h" + +/* We cannot support uselocale() on platforms where the locale_t type is fake. + See intl-thread-locale.m4 for details. */ +#if HAVE_WORKING_USELOCALE && !HAVE_FAKE_LOCALES +# define HAVE_GOOD_USELOCALE 1 +#endif + +#if HAVE_GOOD_USELOCALE +/* Mac OS X 10.5 defines the locale_t type in <xlocale.h>. */ +# if defined __APPLE__ && defined __MACH__ +# include <xlocale.h> +# endif +# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || (defined __linux__ && HAVE_LANGINFO_H) || defined __CYGWIN__ +# include <langinfo.h> +# endif +# if !defined IN_LIBINTL +# include "glthread/lock.h" +# endif +# if defined __sun +# if HAVE_GETLOCALENAME_L +/* Solaris >= 12. */ +extern char * getlocalename_l(int, locale_t); +# elif HAVE_SOLARIS114_LOCALES +# include <sys/localedef.h> +# endif +# endif +# if HAVE_NAMELESS_LOCALES +# include <errno.h> +# include "localename-table.h" +# endif +#endif + +#if HAVE_CFPREFERENCESCOPYAPPVALUE +# include <CoreFoundation/CFString.h> +# include <CoreFoundation/CFPreferences.h> +#endif + +#if defined _WIN32 && !defined __CYGWIN__ +# define WINDOWS_NATIVE +# if !defined IN_LIBINTL +# include "glthread/lock.h" +# endif +#endif + +#if defined WINDOWS_NATIVE || defined __CYGWIN__ /* Native Windows or Cygwin */ +# define WIN32_LEAN_AND_MEAN +# include <windows.h> +# include <winnls.h> +/* List of language codes, sorted by value: + 0x01 LANG_ARABIC + 0x02 LANG_BULGARIAN + 0x03 LANG_CATALAN + 0x04 LANG_CHINESE + 0x05 LANG_CZECH + 0x06 LANG_DANISH + 0x07 LANG_GERMAN + 0x08 LANG_GREEK + 0x09 LANG_ENGLISH + 0x0a LANG_SPANISH + 0x0b LANG_FINNISH + 0x0c LANG_FRENCH + 0x0d LANG_HEBREW + 0x0e LANG_HUNGARIAN + 0x0f LANG_ICELANDIC + 0x10 LANG_ITALIAN + 0x11 LANG_JAPANESE + 0x12 LANG_KOREAN + 0x13 LANG_DUTCH + 0x14 LANG_NORWEGIAN + 0x15 LANG_POLISH + 0x16 LANG_PORTUGUESE + 0x17 LANG_ROMANSH + 0x18 LANG_ROMANIAN + 0x19 LANG_RUSSIAN + 0x1a LANG_CROATIAN == LANG_SERBIAN + 0x1b LANG_SLOVAK + 0x1c LANG_ALBANIAN + 0x1d LANG_SWEDISH + 0x1e LANG_THAI + 0x1f LANG_TURKISH + 0x20 LANG_URDU + 0x21 LANG_INDONESIAN + 0x22 LANG_UKRAINIAN + 0x23 LANG_BELARUSIAN + 0x24 LANG_SLOVENIAN + 0x25 LANG_ESTONIAN + 0x26 LANG_LATVIAN + 0x27 LANG_LITHUANIAN + 0x28 LANG_TAJIK + 0x29 LANG_FARSI + 0x2a LANG_VIETNAMESE + 0x2b LANG_ARMENIAN + 0x2c LANG_AZERI + 0x2d LANG_BASQUE + 0x2e LANG_SORBIAN + 0x2f LANG_MACEDONIAN + 0x30 LANG_SUTU + 0x31 LANG_TSONGA + 0x32 LANG_TSWANA + 0x33 LANG_VENDA + 0x34 LANG_XHOSA + 0x35 LANG_ZULU + 0x36 LANG_AFRIKAANS + 0x37 LANG_GEORGIAN + 0x38 LANG_FAEROESE + 0x39 LANG_HINDI + 0x3a LANG_MALTESE + 0x3b LANG_SAMI + 0x3c LANG_GAELIC + 0x3d LANG_YIDDISH + 0x3e LANG_MALAY + 0x3f LANG_KAZAK + 0x40 LANG_KYRGYZ + 0x41 LANG_SWAHILI + 0x42 LANG_TURKMEN + 0x43 LANG_UZBEK + 0x44 LANG_TATAR + 0x45 LANG_BENGALI + 0x46 LANG_PUNJABI + 0x47 LANG_GUJARATI + 0x48 LANG_ORIYA + 0x49 LANG_TAMIL + 0x4a LANG_TELUGU + 0x4b LANG_KANNADA + 0x4c LANG_MALAYALAM + 0x4d LANG_ASSAMESE + 0x4e LANG_MARATHI + 0x4f LANG_SANSKRIT + 0x50 LANG_MONGOLIAN + 0x51 LANG_TIBETAN + 0x52 LANG_WELSH + 0x53 LANG_CAMBODIAN + 0x54 LANG_LAO + 0x55 LANG_BURMESE + 0x56 LANG_GALICIAN + 0x57 LANG_KONKANI + 0x58 LANG_MANIPURI + 0x59 LANG_SINDHI + 0x5a LANG_SYRIAC + 0x5b LANG_SINHALESE + 0x5c LANG_CHEROKEE + 0x5d LANG_INUKTITUT + 0x5e LANG_AMHARIC + 0x5f LANG_TAMAZIGHT + 0x60 LANG_KASHMIRI + 0x61 LANG_NEPALI + 0x62 LANG_FRISIAN + 0x63 LANG_PASHTO + 0x64 LANG_TAGALOG + 0x65 LANG_DIVEHI + 0x66 LANG_EDO + 0x67 LANG_FULFULDE + 0x68 LANG_HAUSA + 0x69 LANG_IBIBIO + 0x6a LANG_YORUBA + 0x6d LANG_BASHKIR + 0x6e LANG_LUXEMBOURGISH + 0x6f LANG_GREENLANDIC + 0x70 LANG_IGBO + 0x71 LANG_KANURI + 0x72 LANG_OROMO + 0x73 LANG_TIGRINYA + 0x74 LANG_GUARANI + 0x75 LANG_HAWAIIAN + 0x76 LANG_LATIN + 0x77 LANG_SOMALI + 0x78 LANG_YI + 0x79 LANG_PAPIAMENTU + 0x7a LANG_MAPUDUNGUN + 0x7c LANG_MOHAWK + 0x7e LANG_BRETON + 0x82 LANG_OCCITAN + 0x83 LANG_CORSICAN + 0x84 LANG_ALSATIAN + 0x85 LANG_YAKUT + 0x86 LANG_KICHE + 0x87 LANG_KINYARWANDA + 0x88 LANG_WOLOF + 0x8c LANG_DARI + 0x91 LANG_SCOTTISH_GAELIC +*/ +/* Mingw headers don't have latest language and sublanguage codes. */ +# ifndef LANG_AFRIKAANS +# define LANG_AFRIKAANS 0x36 +# endif +# ifndef LANG_ALBANIAN +# define LANG_ALBANIAN 0x1c +# endif +# ifndef LANG_ALSATIAN +# define LANG_ALSATIAN 0x84 +# endif +# ifndef LANG_AMHARIC +# define LANG_AMHARIC 0x5e +# endif +# ifndef LANG_ARABIC +# define LANG_ARABIC 0x01 +# endif +# ifndef LANG_ARMENIAN +# define LANG_ARMENIAN 0x2b +# endif +# ifndef LANG_ASSAMESE +# define LANG_ASSAMESE 0x4d +# endif +# ifndef LANG_AZERI +# define LANG_AZERI 0x2c +# endif +# ifndef LANG_BASHKIR +# define LANG_BASHKIR 0x6d +# endif +# ifndef LANG_BASQUE +# define LANG_BASQUE 0x2d +# endif +# ifndef LANG_BELARUSIAN +# define LANG_BELARUSIAN 0x23 +# endif +# ifndef LANG_BENGALI +# define LANG_BENGALI 0x45 +# endif +# ifndef LANG_BRETON +# define LANG_BRETON 0x7e +# endif +# ifndef LANG_BURMESE +# define LANG_BURMESE 0x55 +# endif +# ifndef LANG_CAMBODIAN +# define LANG_CAMBODIAN 0x53 +# endif +# ifndef LANG_CATALAN +# define LANG_CATALAN 0x03 +# endif +# ifndef LANG_CHEROKEE +# define LANG_CHEROKEE 0x5c +# endif +# ifndef LANG_CORSICAN +# define LANG_CORSICAN 0x83 +# endif +# ifndef LANG_DARI +# define LANG_DARI 0x8c +# endif +# ifndef LANG_DIVEHI +# define LANG_DIVEHI 0x65 +# endif +# ifndef LANG_EDO +# define LANG_EDO 0x66 +# endif +# ifndef LANG_ESTONIAN +# define LANG_ESTONIAN 0x25 +# endif +# ifndef LANG_FAEROESE +# define LANG_FAEROESE 0x38 +# endif +# ifndef LANG_FARSI +# define LANG_FARSI 0x29 +# endif +# ifndef LANG_FRISIAN +# define LANG_FRISIAN 0x62 +# endif +# ifndef LANG_FULFULDE +# define LANG_FULFULDE 0x67 +# endif +# ifndef LANG_GAELIC +# define LANG_GAELIC 0x3c +# endif +# ifndef LANG_GALICIAN +# define LANG_GALICIAN 0x56 +# endif +# ifndef LANG_GEORGIAN +# define LANG_GEORGIAN 0x37 +# endif +# ifndef LANG_GREENLANDIC +# define LANG_GREENLANDIC 0x6f +# endif +# ifndef LANG_GUARANI +# define LANG_GUARANI 0x74 +# endif +# ifndef LANG_GUJARATI +# define LANG_GUJARATI 0x47 +# endif +# ifndef LANG_HAUSA +# define LANG_HAUSA 0x68 +# endif +# ifndef LANG_HAWAIIAN +# define LANG_HAWAIIAN 0x75 +# endif +# ifndef LANG_HEBREW +# define LANG_HEBREW 0x0d +# endif +# ifndef LANG_HINDI +# define LANG_HINDI 0x39 +# endif +# ifndef LANG_IBIBIO +# define LANG_IBIBIO 0x69 +# endif +# ifndef LANG_IGBO +# define LANG_IGBO 0x70 +# endif +# ifndef LANG_INDONESIAN +# define LANG_INDONESIAN 0x21 +# endif +# ifndef LANG_INUKTITUT +# define LANG_INUKTITUT 0x5d +# endif +# ifndef LANG_KANNADA +# define LANG_KANNADA 0x4b +# endif +# ifndef LANG_KANURI +# define LANG_KANURI 0x71 +# endif +# ifndef LANG_KASHMIRI +# define LANG_KASHMIRI 0x60 +# endif +# ifndef LANG_KAZAK +# define LANG_KAZAK 0x3f +# endif +# ifndef LANG_KICHE +# define LANG_KICHE 0x86 +# endif +# ifndef LANG_KINYARWANDA +# define LANG_KINYARWANDA 0x87 +# endif +# ifndef LANG_KONKANI +# define LANG_KONKANI 0x57 +# endif +# ifndef LANG_KYRGYZ +# define LANG_KYRGYZ 0x40 +# endif +# ifndef LANG_LAO +# define LANG_LAO 0x54 +# endif +# ifndef LANG_LATIN +# define LANG_LATIN 0x76 +# endif +# ifndef LANG_LATVIAN +# define LANG_LATVIAN 0x26 +# endif +# ifndef LANG_LITHUANIAN +# define LANG_LITHUANIAN 0x27 +# endif +# ifndef LANG_LUXEMBOURGISH +# define LANG_LUXEMBOURGISH 0x6e +# endif +# ifndef LANG_MACEDONIAN +# define LANG_MACEDONIAN 0x2f +# endif +# ifndef LANG_MALAY +# define LANG_MALAY 0x3e +# endif +# ifndef LANG_MALAYALAM +# define LANG_MALAYALAM 0x4c +# endif +# ifndef LANG_MALTESE +# define LANG_MALTESE 0x3a +# endif +# ifndef LANG_MANIPURI +# define LANG_MANIPURI 0x58 +# endif +# ifndef LANG_MAORI +# define LANG_MAORI 0x81 +# endif +# ifndef LANG_MAPUDUNGUN +# define LANG_MAPUDUNGUN 0x7a +# endif +# ifndef LANG_MARATHI +# define LANG_MARATHI 0x4e +# endif +# ifndef LANG_MOHAWK +# define LANG_MOHAWK 0x7c +# endif +# ifndef LANG_MONGOLIAN +# define LANG_MONGOLIAN 0x50 +# endif +# ifndef LANG_NEPALI +# define LANG_NEPALI 0x61 +# endif +# ifndef LANG_OCCITAN +# define LANG_OCCITAN 0x82 +# endif +# ifndef LANG_ORIYA +# define LANG_ORIYA 0x48 +# endif +# ifndef LANG_OROMO +# define LANG_OROMO 0x72 +# endif +# ifndef LANG_PAPIAMENTU +# define LANG_PAPIAMENTU 0x79 +# endif +# ifndef LANG_PASHTO +# define LANG_PASHTO 0x63 +# endif +# ifndef LANG_PUNJABI +# define LANG_PUNJABI 0x46 +# endif +# ifndef LANG_QUECHUA +# define LANG_QUECHUA 0x6b +# endif +# ifndef LANG_ROMANSH +# define LANG_ROMANSH 0x17 +# endif +# ifndef LANG_SAMI +# define LANG_SAMI 0x3b +# endif +# ifndef LANG_SANSKRIT +# define LANG_SANSKRIT 0x4f +# endif +# ifndef LANG_SCOTTISH_GAELIC +# define LANG_SCOTTISH_GAELIC 0x91 +# endif +# ifndef LANG_SERBIAN +# define LANG_SERBIAN 0x1a +# endif +# ifndef LANG_SINDHI +# define LANG_SINDHI 0x59 +# endif +# ifndef LANG_SINHALESE +# define LANG_SINHALESE 0x5b +# endif +# ifndef LANG_SLOVAK +# define LANG_SLOVAK 0x1b +# endif +# ifndef LANG_SOMALI +# define LANG_SOMALI 0x77 +# endif +# ifndef LANG_SORBIAN +# define LANG_SORBIAN 0x2e +# endif +# ifndef LANG_SOTHO +# define LANG_SOTHO 0x6c +# endif +# ifndef LANG_SUTU +# define LANG_SUTU 0x30 +# endif +# ifndef LANG_SWAHILI +# define LANG_SWAHILI 0x41 +# endif +# ifndef LANG_SYRIAC +# define LANG_SYRIAC 0x5a +# endif +# ifndef LANG_TAGALOG +# define LANG_TAGALOG 0x64 +# endif +# ifndef LANG_TAJIK +# define LANG_TAJIK 0x28 +# endif +# ifndef LANG_TAMAZIGHT +# define LANG_TAMAZIGHT 0x5f +# endif +# ifndef LANG_TAMIL +# define LANG_TAMIL 0x49 +# endif +# ifndef LANG_TATAR +# define LANG_TATAR 0x44 +# endif +# ifndef LANG_TELUGU +# define LANG_TELUGU 0x4a +# endif +# ifndef LANG_THAI +# define LANG_THAI 0x1e +# endif +# ifndef LANG_TIBETAN +# define LANG_TIBETAN 0x51 +# endif +# ifndef LANG_TIGRINYA +# define LANG_TIGRINYA 0x73 +# endif +# ifndef LANG_TSONGA +# define LANG_TSONGA 0x31 +# endif +# ifndef LANG_TSWANA +# define LANG_TSWANA 0x32 +# endif +# ifndef LANG_TURKMEN +# define LANG_TURKMEN 0x42 +# endif +# ifndef LANG_UIGHUR +# define LANG_UIGHUR 0x80 +# endif +# ifndef LANG_UKRAINIAN +# define LANG_UKRAINIAN 0x22 +# endif +# ifndef LANG_URDU +# define LANG_URDU 0x20 +# endif +# ifndef LANG_UZBEK +# define LANG_UZBEK 0x43 +# endif +# ifndef LANG_VENDA +# define LANG_VENDA 0x33 +# endif +# ifndef LANG_VIETNAMESE +# define LANG_VIETNAMESE 0x2a +# endif +# ifndef LANG_WELSH +# define LANG_WELSH 0x52 +# endif +# ifndef LANG_WOLOF +# define LANG_WOLOF 0x88 +# endif +# ifndef LANG_XHOSA +# define LANG_XHOSA 0x34 +# endif +# ifndef LANG_YAKUT +# define LANG_YAKUT 0x85 +# endif +# ifndef LANG_YI +# define LANG_YI 0x78 +# endif +# ifndef LANG_YIDDISH +# define LANG_YIDDISH 0x3d +# endif +# ifndef LANG_YORUBA +# define LANG_YORUBA 0x6a +# endif +# ifndef LANG_ZULU +# define LANG_ZULU 0x35 +# endif +# ifndef SUBLANG_AFRIKAANS_SOUTH_AFRICA +# define SUBLANG_AFRIKAANS_SOUTH_AFRICA 0x01 +# endif +# ifndef SUBLANG_ALBANIAN_ALBANIA +# define SUBLANG_ALBANIAN_ALBANIA 0x01 +# endif +# ifndef SUBLANG_ALSATIAN_FRANCE +# define SUBLANG_ALSATIAN_FRANCE 0x01 +# endif +# ifndef SUBLANG_AMHARIC_ETHIOPIA +# define SUBLANG_AMHARIC_ETHIOPIA 0x01 +# endif +# ifndef SUBLANG_ARABIC_SAUDI_ARABIA +# define SUBLANG_ARABIC_SAUDI_ARABIA 0x01 +# endif +# ifndef SUBLANG_ARABIC_IRAQ +# define SUBLANG_ARABIC_IRAQ 0x02 +# endif +# ifndef SUBLANG_ARABIC_EGYPT +# define SUBLANG_ARABIC_EGYPT 0x03 +# endif +# ifndef SUBLANG_ARABIC_LIBYA +# define SUBLANG_ARABIC_LIBYA 0x04 +# endif +# ifndef SUBLANG_ARABIC_ALGERIA +# define SUBLANG_ARABIC_ALGERIA 0x05 +# endif +# ifndef SUBLANG_ARABIC_MOROCCO +# define SUBLANG_ARABIC_MOROCCO 0x06 +# endif +# ifndef SUBLANG_ARABIC_TUNISIA +# define SUBLANG_ARABIC_TUNISIA 0x07 +# endif +# ifndef SUBLANG_ARABIC_OMAN +# define SUBLANG_ARABIC_OMAN 0x08 +# endif +# ifndef SUBLANG_ARABIC_YEMEN +# define SUBLANG_ARABIC_YEMEN 0x09 +# endif +# ifndef SUBLANG_ARABIC_SYRIA +# define SUBLANG_ARABIC_SYRIA 0x0a +# endif +# ifndef SUBLANG_ARABIC_JORDAN +# define SUBLANG_ARABIC_JORDAN 0x0b +# endif +# ifndef SUBLANG_ARABIC_LEBANON +# define SUBLANG_ARABIC_LEBANON 0x0c +# endif +# ifndef SUBLANG_ARABIC_KUWAIT +# define SUBLANG_ARABIC_KUWAIT 0x0d +# endif +# ifndef SUBLANG_ARABIC_UAE +# define SUBLANG_ARABIC_UAE 0x0e +# endif +# ifndef SUBLANG_ARABIC_BAHRAIN +# define SUBLANG_ARABIC_BAHRAIN 0x0f +# endif +# ifndef SUBLANG_ARABIC_QATAR +# define SUBLANG_ARABIC_QATAR 0x10 +# endif +# ifndef SUBLANG_ARMENIAN_ARMENIA +# define SUBLANG_ARMENIAN_ARMENIA 0x01 +# endif +# ifndef SUBLANG_ASSAMESE_INDIA +# define SUBLANG_ASSAMESE_INDIA 0x01 +# endif +# ifndef SUBLANG_AZERI_LATIN +# define SUBLANG_AZERI_LATIN 0x01 +# endif +# ifndef SUBLANG_AZERI_CYRILLIC +# define SUBLANG_AZERI_CYRILLIC 0x02 +# endif +# ifndef SUBLANG_BASHKIR_RUSSIA +# define SUBLANG_BASHKIR_RUSSIA 0x01 +# endif +# ifndef SUBLANG_BASQUE_BASQUE +# define SUBLANG_BASQUE_BASQUE 0x01 +# endif +# ifndef SUBLANG_BELARUSIAN_BELARUS +# define SUBLANG_BELARUSIAN_BELARUS 0x01 +# endif +# ifndef SUBLANG_BENGALI_INDIA +# define SUBLANG_BENGALI_INDIA 0x01 +# endif +# ifndef SUBLANG_BENGALI_BANGLADESH +# define SUBLANG_BENGALI_BANGLADESH 0x02 +# endif +# ifndef SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN +# define SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN 0x05 +# endif +# ifndef SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC +# define SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC 0x08 +# endif +# ifndef SUBLANG_BRETON_FRANCE +# define SUBLANG_BRETON_FRANCE 0x01 +# endif +# ifndef SUBLANG_BULGARIAN_BULGARIA +# define SUBLANG_BULGARIAN_BULGARIA 0x01 +# endif +# ifndef SUBLANG_CAMBODIAN_CAMBODIA +# define SUBLANG_CAMBODIAN_CAMBODIA 0x01 +# endif +# ifndef SUBLANG_CATALAN_SPAIN +# define SUBLANG_CATALAN_SPAIN 0x01 +# endif +# ifndef SUBLANG_CORSICAN_FRANCE +# define SUBLANG_CORSICAN_FRANCE 0x01 +# endif +# ifndef SUBLANG_CROATIAN_CROATIA +# define SUBLANG_CROATIAN_CROATIA 0x01 +# endif +# ifndef SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN +# define SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN 0x04 +# endif +# ifndef SUBLANG_CHINESE_MACAU +# define SUBLANG_CHINESE_MACAU 0x05 +# endif +# ifndef SUBLANG_CZECH_CZECH_REPUBLIC +# define SUBLANG_CZECH_CZECH_REPUBLIC 0x01 +# endif +# ifndef SUBLANG_DANISH_DENMARK +# define SUBLANG_DANISH_DENMARK 0x01 +# endif +# ifndef SUBLANG_DARI_AFGHANISTAN +# define SUBLANG_DARI_AFGHANISTAN 0x01 +# endif +# ifndef SUBLANG_DIVEHI_MALDIVES +# define SUBLANG_DIVEHI_MALDIVES 0x01 +# endif +# ifndef SUBLANG_DUTCH_SURINAM +# define SUBLANG_DUTCH_SURINAM 0x03 +# endif +# ifndef SUBLANG_ENGLISH_SOUTH_AFRICA +# define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07 +# endif +# ifndef SUBLANG_ENGLISH_JAMAICA +# define SUBLANG_ENGLISH_JAMAICA 0x08 +# endif +# ifndef SUBLANG_ENGLISH_CARIBBEAN +# define SUBLANG_ENGLISH_CARIBBEAN 0x09 +# endif +# ifndef SUBLANG_ENGLISH_BELIZE +# define SUBLANG_ENGLISH_BELIZE 0x0a +# endif +# ifndef SUBLANG_ENGLISH_TRINIDAD +# define SUBLANG_ENGLISH_TRINIDAD 0x0b +# endif +# ifndef SUBLANG_ENGLISH_ZIMBABWE +# define SUBLANG_ENGLISH_ZIMBABWE 0x0c +# endif +# ifndef SUBLANG_ENGLISH_PHILIPPINES +# define SUBLANG_ENGLISH_PHILIPPINES 0x0d +# endif +# ifndef SUBLANG_ENGLISH_INDONESIA +# define SUBLANG_ENGLISH_INDONESIA 0x0e +# endif +# ifndef SUBLANG_ENGLISH_HONGKONG +# define SUBLANG_ENGLISH_HONGKONG 0x0f +# endif +# ifndef SUBLANG_ENGLISH_INDIA +# define SUBLANG_ENGLISH_INDIA 0x10 +# endif +# ifndef SUBLANG_ENGLISH_MALAYSIA +# define SUBLANG_ENGLISH_MALAYSIA 0x11 +# endif +# ifndef SUBLANG_ENGLISH_SINGAPORE +# define SUBLANG_ENGLISH_SINGAPORE 0x12 +# endif +# ifndef SUBLANG_ESTONIAN_ESTONIA +# define SUBLANG_ESTONIAN_ESTONIA 0x01 +# endif +# ifndef SUBLANG_FAEROESE_FAROE_ISLANDS +# define SUBLANG_FAEROESE_FAROE_ISLANDS 0x01 +# endif +# ifndef SUBLANG_FARSI_IRAN +# define SUBLANG_FARSI_IRAN 0x01 +# endif +# ifndef SUBLANG_FINNISH_FINLAND +# define SUBLANG_FINNISH_FINLAND 0x01 +# endif +# ifndef SUBLANG_FRENCH_LUXEMBOURG +# define SUBLANG_FRENCH_LUXEMBOURG 0x05 +# endif +# ifndef SUBLANG_FRENCH_MONACO +# define SUBLANG_FRENCH_MONACO 0x06 +# endif +# ifndef SUBLANG_FRENCH_WESTINDIES +# define SUBLANG_FRENCH_WESTINDIES 0x07 +# endif +# ifndef SUBLANG_FRENCH_REUNION +# define SUBLANG_FRENCH_REUNION 0x08 +# endif +# ifndef SUBLANG_FRENCH_CONGO +# define SUBLANG_FRENCH_CONGO 0x09 +# endif +# ifndef SUBLANG_FRENCH_SENEGAL +# define SUBLANG_FRENCH_SENEGAL 0x0a +# endif +# ifndef SUBLANG_FRENCH_CAMEROON +# define SUBLANG_FRENCH_CAMEROON 0x0b +# endif +# ifndef SUBLANG_FRENCH_COTEDIVOIRE +# define SUBLANG_FRENCH_COTEDIVOIRE 0x0c +# endif +# ifndef SUBLANG_FRENCH_MALI +# define SUBLANG_FRENCH_MALI 0x0d +# endif +# ifndef SUBLANG_FRENCH_MOROCCO +# define SUBLANG_FRENCH_MOROCCO 0x0e +# endif +# ifndef SUBLANG_FRENCH_HAITI +# define SUBLANG_FRENCH_HAITI 0x0f +# endif +# ifndef SUBLANG_FRISIAN_NETHERLANDS +# define SUBLANG_FRISIAN_NETHERLANDS 0x01 +# endif +# ifndef SUBLANG_GALICIAN_SPAIN +# define SUBLANG_GALICIAN_SPAIN 0x01 +# endif +# ifndef SUBLANG_GEORGIAN_GEORGIA +# define SUBLANG_GEORGIAN_GEORGIA 0x01 +# endif +# ifndef SUBLANG_GERMAN_LUXEMBOURG +# define SUBLANG_GERMAN_LUXEMBOURG 0x04 +# endif +# ifndef SUBLANG_GERMAN_LIECHTENSTEIN +# define SUBLANG_GERMAN_LIECHTENSTEIN 0x05 +# endif +# ifndef SUBLANG_GREEK_GREECE +# define SUBLANG_GREEK_GREECE 0x01 +# endif +# ifndef SUBLANG_GREENLANDIC_GREENLAND +# define SUBLANG_GREENLANDIC_GREENLAND 0x01 +# endif +# ifndef SUBLANG_GUJARATI_INDIA +# define SUBLANG_GUJARATI_INDIA 0x01 +# endif +# ifndef SUBLANG_HAUSA_NIGERIA_LATIN +# define SUBLANG_HAUSA_NIGERIA_LATIN 0x01 +# endif +# ifndef SUBLANG_HEBREW_ISRAEL +# define SUBLANG_HEBREW_ISRAEL 0x01 +# endif +# ifndef SUBLANG_HINDI_INDIA +# define SUBLANG_HINDI_INDIA 0x01 +# endif +# ifndef SUBLANG_HUNGARIAN_HUNGARY +# define SUBLANG_HUNGARIAN_HUNGARY 0x01 +# endif +# ifndef SUBLANG_ICELANDIC_ICELAND +# define SUBLANG_ICELANDIC_ICELAND 0x01 +# endif +# ifndef SUBLANG_IGBO_NIGERIA +# define SUBLANG_IGBO_NIGERIA 0x01 +# endif +# ifndef SUBLANG_INDONESIAN_INDONESIA +# define SUBLANG_INDONESIAN_INDONESIA 0x01 +# endif +# ifndef SUBLANG_INUKTITUT_CANADA +# define SUBLANG_INUKTITUT_CANADA 0x01 +# endif +# undef SUBLANG_INUKTITUT_CANADA_LATIN +# define SUBLANG_INUKTITUT_CANADA_LATIN 0x02 +# undef SUBLANG_IRISH_IRELAND +# define SUBLANG_IRISH_IRELAND 0x02 +# ifndef SUBLANG_JAPANESE_JAPAN +# define SUBLANG_JAPANESE_JAPAN 0x01 +# endif +# ifndef SUBLANG_KANNADA_INDIA +# define SUBLANG_KANNADA_INDIA 0x01 +# endif +# ifndef SUBLANG_KASHMIRI_INDIA +# define SUBLANG_KASHMIRI_INDIA 0x02 +# endif +# ifndef SUBLANG_KAZAK_KAZAKHSTAN +# define SUBLANG_KAZAK_KAZAKHSTAN 0x01 +# endif +# ifndef SUBLANG_KICHE_GUATEMALA +# define SUBLANG_KICHE_GUATEMALA 0x01 +# endif +# ifndef SUBLANG_KINYARWANDA_RWANDA +# define SUBLANG_KINYARWANDA_RWANDA 0x01 +# endif +# ifndef SUBLANG_KONKANI_INDIA +# define SUBLANG_KONKANI_INDIA 0x01 +# endif +# ifndef SUBLANG_KYRGYZ_KYRGYZSTAN +# define SUBLANG_KYRGYZ_KYRGYZSTAN 0x01 +# endif +# ifndef SUBLANG_LAO_LAOS +# define SUBLANG_LAO_LAOS 0x01 +# endif +# ifndef SUBLANG_LATVIAN_LATVIA +# define SUBLANG_LATVIAN_LATVIA 0x01 +# endif +# ifndef SUBLANG_LITHUANIAN_LITHUANIA +# define SUBLANG_LITHUANIAN_LITHUANIA 0x01 +# endif +# undef SUBLANG_LOWER_SORBIAN_GERMANY +# define SUBLANG_LOWER_SORBIAN_GERMANY 0x02 +# ifndef SUBLANG_LUXEMBOURGISH_LUXEMBOURG +# define SUBLANG_LUXEMBOURGISH_LUXEMBOURG 0x01 +# endif +# ifndef SUBLANG_MACEDONIAN_MACEDONIA +# define SUBLANG_MACEDONIAN_MACEDONIA 0x01 +# endif +# ifndef SUBLANG_MALAY_MALAYSIA +# define SUBLANG_MALAY_MALAYSIA 0x01 +# endif +# ifndef SUBLANG_MALAY_BRUNEI_DARUSSALAM +# define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02 +# endif +# ifndef SUBLANG_MALAYALAM_INDIA +# define SUBLANG_MALAYALAM_INDIA 0x01 +# endif +# ifndef SUBLANG_MALTESE_MALTA +# define SUBLANG_MALTESE_MALTA 0x01 +# endif +# ifndef SUBLANG_MAORI_NEW_ZEALAND +# define SUBLANG_MAORI_NEW_ZEALAND 0x01 +# endif +# ifndef SUBLANG_MAPUDUNGUN_CHILE +# define SUBLANG_MAPUDUNGUN_CHILE 0x01 +# endif +# ifndef SUBLANG_MARATHI_INDIA +# define SUBLANG_MARATHI_INDIA 0x01 +# endif +# ifndef SUBLANG_MOHAWK_CANADA +# define SUBLANG_MOHAWK_CANADA 0x01 +# endif +# ifndef SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA +# define SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA 0x01 +# endif +# ifndef SUBLANG_MONGOLIAN_PRC +# define SUBLANG_MONGOLIAN_PRC 0x02 +# endif +# ifndef SUBLANG_NEPALI_NEPAL +# define SUBLANG_NEPALI_NEPAL 0x01 +# endif +# ifndef SUBLANG_NEPALI_INDIA +# define SUBLANG_NEPALI_INDIA 0x02 +# endif +# ifndef SUBLANG_OCCITAN_FRANCE +# define SUBLANG_OCCITAN_FRANCE 0x01 +# endif +# ifndef SUBLANG_ORIYA_INDIA +# define SUBLANG_ORIYA_INDIA 0x01 +# endif +# ifndef SUBLANG_PASHTO_AFGHANISTAN +# define SUBLANG_PASHTO_AFGHANISTAN 0x01 +# endif +# ifndef SUBLANG_POLISH_POLAND +# define SUBLANG_POLISH_POLAND 0x01 +# endif +# ifndef SUBLANG_PUNJABI_INDIA +# define SUBLANG_PUNJABI_INDIA 0x01 +# endif +# ifndef SUBLANG_PUNJABI_PAKISTAN +# define SUBLANG_PUNJABI_PAKISTAN 0x02 +# endif +# ifndef SUBLANG_QUECHUA_BOLIVIA +# define SUBLANG_QUECHUA_BOLIVIA 0x01 +# endif +# ifndef SUBLANG_QUECHUA_ECUADOR +# define SUBLANG_QUECHUA_ECUADOR 0x02 +# endif +# ifndef SUBLANG_QUECHUA_PERU +# define SUBLANG_QUECHUA_PERU 0x03 +# endif +# ifndef SUBLANG_ROMANIAN_ROMANIA +# define SUBLANG_ROMANIAN_ROMANIA 0x01 +# endif +# ifndef SUBLANG_ROMANIAN_MOLDOVA +# define SUBLANG_ROMANIAN_MOLDOVA 0x02 +# endif +# ifndef SUBLANG_ROMANSH_SWITZERLAND +# define SUBLANG_ROMANSH_SWITZERLAND 0x01 +# endif +# ifndef SUBLANG_RUSSIAN_RUSSIA +# define SUBLANG_RUSSIAN_RUSSIA 0x01 +# endif +# ifndef SUBLANG_RUSSIAN_MOLDAVIA +# define SUBLANG_RUSSIAN_MOLDAVIA 0x02 +# endif +# ifndef SUBLANG_SAMI_NORTHERN_NORWAY +# define SUBLANG_SAMI_NORTHERN_NORWAY 0x01 +# endif +# ifndef SUBLANG_SAMI_NORTHERN_SWEDEN +# define SUBLANG_SAMI_NORTHERN_SWEDEN 0x02 +# endif +# ifndef SUBLANG_SAMI_NORTHERN_FINLAND +# define SUBLANG_SAMI_NORTHERN_FINLAND 0x03 +# endif +# ifndef SUBLANG_SAMI_LULE_NORWAY +# define SUBLANG_SAMI_LULE_NORWAY 0x04 +# endif +# ifndef SUBLANG_SAMI_LULE_SWEDEN +# define SUBLANG_SAMI_LULE_SWEDEN 0x05 +# endif +# ifndef SUBLANG_SAMI_SOUTHERN_NORWAY +# define SUBLANG_SAMI_SOUTHERN_NORWAY 0x06 +# endif +# ifndef SUBLANG_SAMI_SOUTHERN_SWEDEN +# define SUBLANG_SAMI_SOUTHERN_SWEDEN 0x07 +# endif +# undef SUBLANG_SAMI_SKOLT_FINLAND +# define SUBLANG_SAMI_SKOLT_FINLAND 0x08 +# undef SUBLANG_SAMI_INARI_FINLAND +# define SUBLANG_SAMI_INARI_FINLAND 0x09 +# ifndef SUBLANG_SANSKRIT_INDIA +# define SUBLANG_SANSKRIT_INDIA 0x01 +# endif +# ifndef SUBLANG_SERBIAN_LATIN +# define SUBLANG_SERBIAN_LATIN 0x02 +# endif +# ifndef SUBLANG_SERBIAN_CYRILLIC +# define SUBLANG_SERBIAN_CYRILLIC 0x03 +# endif +# ifndef SUBLANG_SINDHI_INDIA +# define SUBLANG_SINDHI_INDIA 0x01 +# endif +# undef SUBLANG_SINDHI_PAKISTAN +# define SUBLANG_SINDHI_PAKISTAN 0x02 +# ifndef SUBLANG_SINDHI_AFGHANISTAN +# define SUBLANG_SINDHI_AFGHANISTAN 0x02 +# endif +# ifndef SUBLANG_SINHALESE_SRI_LANKA +# define SUBLANG_SINHALESE_SRI_LANKA 0x01 +# endif +# ifndef SUBLANG_SLOVAK_SLOVAKIA +# define SUBLANG_SLOVAK_SLOVAKIA 0x01 +# endif +# ifndef SUBLANG_SLOVENIAN_SLOVENIA +# define SUBLANG_SLOVENIAN_SLOVENIA 0x01 +# endif +# ifndef SUBLANG_SOTHO_SOUTH_AFRICA +# define SUBLANG_SOTHO_SOUTH_AFRICA 0x01 +# endif +# ifndef SUBLANG_SPANISH_GUATEMALA +# define SUBLANG_SPANISH_GUATEMALA 0x04 +# endif +# ifndef SUBLANG_SPANISH_COSTA_RICA +# define SUBLANG_SPANISH_COSTA_RICA 0x05 +# endif +# ifndef SUBLANG_SPANISH_PANAMA +# define SUBLANG_SPANISH_PANAMA 0x06 +# endif +# ifndef SUBLANG_SPANISH_DOMINICAN_REPUBLIC +# define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07 +# endif +# ifndef SUBLANG_SPANISH_VENEZUELA +# define SUBLANG_SPANISH_VENEZUELA 0x08 +# endif +# ifndef SUBLANG_SPANISH_COLOMBIA +# define SUBLANG_SPANISH_COLOMBIA 0x09 +# endif +# ifndef SUBLANG_SPANISH_PERU +# define SUBLANG_SPANISH_PERU 0x0a +# endif +# ifndef SUBLANG_SPANISH_ARGENTINA +# define SUBLANG_SPANISH_ARGENTINA 0x0b +# endif +# ifndef SUBLANG_SPANISH_ECUADOR +# define SUBLANG_SPANISH_ECUADOR 0x0c +# endif +# ifndef SUBLANG_SPANISH_CHILE +# define SUBLANG_SPANISH_CHILE 0x0d +# endif +# ifndef SUBLANG_SPANISH_URUGUAY +# define SUBLANG_SPANISH_URUGUAY 0x0e +# endif +# ifndef SUBLANG_SPANISH_PARAGUAY +# define SUBLANG_SPANISH_PARAGUAY 0x0f +# endif +# ifndef SUBLANG_SPANISH_BOLIVIA +# define SUBLANG_SPANISH_BOLIVIA 0x10 +# endif +# ifndef SUBLANG_SPANISH_EL_SALVADOR +# define SUBLANG_SPANISH_EL_SALVADOR 0x11 +# endif +# ifndef SUBLANG_SPANISH_HONDURAS +# define SUBLANG_SPANISH_HONDURAS 0x12 +# endif +# ifndef SUBLANG_SPANISH_NICARAGUA +# define SUBLANG_SPANISH_NICARAGUA 0x13 +# endif +# ifndef SUBLANG_SPANISH_PUERTO_RICO +# define SUBLANG_SPANISH_PUERTO_RICO 0x14 +# endif +# ifndef SUBLANG_SPANISH_US +# define SUBLANG_SPANISH_US 0x15 +# endif +# ifndef SUBLANG_SWAHILI_KENYA +# define SUBLANG_SWAHILI_KENYA 0x01 +# endif +# ifndef SUBLANG_SWEDISH_SWEDEN +# define SUBLANG_SWEDISH_SWEDEN 0x01 +# endif +# ifndef SUBLANG_SWEDISH_FINLAND +# define SUBLANG_SWEDISH_FINLAND 0x02 +# endif +# ifndef SUBLANG_SYRIAC_SYRIA +# define SUBLANG_SYRIAC_SYRIA 0x01 +# endif +# ifndef SUBLANG_TAGALOG_PHILIPPINES +# define SUBLANG_TAGALOG_PHILIPPINES 0x01 +# endif +# ifndef SUBLANG_TAJIK_TAJIKISTAN +# define SUBLANG_TAJIK_TAJIKISTAN 0x01 +# endif +# ifndef SUBLANG_TAMAZIGHT_ARABIC +# define SUBLANG_TAMAZIGHT_ARABIC 0x01 +# endif +# ifndef SUBLANG_TAMAZIGHT_ALGERIA_LATIN +# define SUBLANG_TAMAZIGHT_ALGERIA_LATIN 0x02 +# endif +# ifndef SUBLANG_TAMIL_INDIA +# define SUBLANG_TAMIL_INDIA 0x01 +# endif +# ifndef SUBLANG_TATAR_RUSSIA +# define SUBLANG_TATAR_RUSSIA 0x01 +# endif +# ifndef SUBLANG_TELUGU_INDIA +# define SUBLANG_TELUGU_INDIA 0x01 +# endif +# ifndef SUBLANG_THAI_THAILAND +# define SUBLANG_THAI_THAILAND 0x01 +# endif +# ifndef SUBLANG_TIBETAN_PRC +# define SUBLANG_TIBETAN_PRC 0x01 +# endif +# undef SUBLANG_TIBETAN_BHUTAN +# define SUBLANG_TIBETAN_BHUTAN 0x02 +# ifndef SUBLANG_TIGRINYA_ETHIOPIA +# define SUBLANG_TIGRINYA_ETHIOPIA 0x01 +# endif +# ifndef SUBLANG_TIGRINYA_ERITREA +# define SUBLANG_TIGRINYA_ERITREA 0x02 +# endif +# ifndef SUBLANG_TSWANA_SOUTH_AFRICA +# define SUBLANG_TSWANA_SOUTH_AFRICA 0x01 +# endif +# ifndef SUBLANG_TURKISH_TURKEY +# define SUBLANG_TURKISH_TURKEY 0x01 +# endif +# ifndef SUBLANG_TURKMEN_TURKMENISTAN +# define SUBLANG_TURKMEN_TURKMENISTAN 0x01 +# endif +# ifndef SUBLANG_UIGHUR_PRC +# define SUBLANG_UIGHUR_PRC 0x01 +# endif +# ifndef SUBLANG_UKRAINIAN_UKRAINE +# define SUBLANG_UKRAINIAN_UKRAINE 0x01 +# endif +# ifndef SUBLANG_UPPER_SORBIAN_GERMANY +# define SUBLANG_UPPER_SORBIAN_GERMANY 0x01 +# endif +# ifndef SUBLANG_URDU_PAKISTAN +# define SUBLANG_URDU_PAKISTAN 0x01 +# endif +# ifndef SUBLANG_URDU_INDIA +# define SUBLANG_URDU_INDIA 0x02 +# endif +# ifndef SUBLANG_UZBEK_LATIN +# define SUBLANG_UZBEK_LATIN 0x01 +# endif +# ifndef SUBLANG_UZBEK_CYRILLIC +# define SUBLANG_UZBEK_CYRILLIC 0x02 +# endif +# ifndef SUBLANG_VIETNAMESE_VIETNAM +# define SUBLANG_VIETNAMESE_VIETNAM 0x01 +# endif +# ifndef SUBLANG_WELSH_UNITED_KINGDOM +# define SUBLANG_WELSH_UNITED_KINGDOM 0x01 +# endif +# ifndef SUBLANG_WOLOF_SENEGAL +# define SUBLANG_WOLOF_SENEGAL 0x01 +# endif +# ifndef SUBLANG_XHOSA_SOUTH_AFRICA +# define SUBLANG_XHOSA_SOUTH_AFRICA 0x01 +# endif +# ifndef SUBLANG_YAKUT_RUSSIA +# define SUBLANG_YAKUT_RUSSIA 0x01 +# endif +# ifndef SUBLANG_YI_PRC +# define SUBLANG_YI_PRC 0x01 +# endif +# ifndef SUBLANG_YORUBA_NIGERIA +# define SUBLANG_YORUBA_NIGERIA 0x01 +# endif +# ifndef SUBLANG_ZULU_SOUTH_AFRICA +# define SUBLANG_ZULU_SOUTH_AFRICA 0x01 +# endif +/* GetLocaleInfoA operations. */ +# ifndef LOCALE_SNAME +# define LOCALE_SNAME 0x5c +# endif +# ifndef LOCALE_NAME_MAX_LENGTH +# define LOCALE_NAME_MAX_LENGTH 85 +# endif +#endif + +/* We want to use the system's setlocale() function here, not the gnulib + override. */ +#undef setlocale + + +#if HAVE_CFPREFERENCESCOPYAPPVALUE +/* Mac OS X 10.4 or newer */ + +/* Canonicalize a Mac OS X locale name to a Unix locale name. + NAME is a sufficiently large buffer. + On input, it contains the Mac OS X locale name. + On output, it contains the Unix locale name. */ +# if !defined IN_LIBINTL +static +# endif +void +gl_locale_name_canonicalize (char *name) +{ + /* This conversion is based on a posting by + Deborah GoldSmith <goldsmit@apple.com> on 2005-03-08, + https://lists.apple.com/archives/carbon-dev/2005/Mar/msg00293.html */ + + /* Convert legacy (NeXTstep inherited) English names to Unix (ISO 639 and + ISO 3166) names. Prior to Mac OS X 10.3, there is no API for doing this. + Therefore we do it ourselves, using a table based on the results of the + Mac OS X 10.3.8 function + CFLocaleCreateCanonicalLocaleIdentifierFromString(). */ + typedef struct { const char legacy[21+1]; const char unixy[5+1]; } + legacy_entry; + static const legacy_entry legacy_table[] = { + { "Afrikaans", "af" }, + { "Albanian", "sq" }, + { "Amharic", "am" }, + { "Arabic", "ar" }, + { "Armenian", "hy" }, + { "Assamese", "as" }, + { "Aymara", "ay" }, + { "Azerbaijani", "az" }, + { "Basque", "eu" }, + { "Belarusian", "be" }, + { "Belorussian", "be" }, + { "Bengali", "bn" }, + { "Brazilian Portugese", "pt_BR" }, + { "Brazilian Portuguese", "pt_BR" }, + { "Breton", "br" }, + { "Bulgarian", "bg" }, + { "Burmese", "my" }, + { "Byelorussian", "be" }, + { "Catalan", "ca" }, + { "Chewa", "ny" }, + { "Chichewa", "ny" }, + { "Chinese", "zh" }, + { "Chinese, Simplified", "zh_CN" }, + { "Chinese, Traditional", "zh_TW" }, + { "Chinese, Tradtional", "zh_TW" }, + { "Croatian", "hr" }, + { "Czech", "cs" }, + { "Danish", "da" }, + { "Dutch", "nl" }, + { "Dzongkha", "dz" }, + { "English", "en" }, + { "Esperanto", "eo" }, + { "Estonian", "et" }, + { "Faroese", "fo" }, + { "Farsi", "fa" }, + { "Finnish", "fi" }, + { "Flemish", "nl_BE" }, + { "French", "fr" }, + { "Galician", "gl" }, + { "Gallegan", "gl" }, + { "Georgian", "ka" }, + { "German", "de" }, + { "Greek", "el" }, + { "Greenlandic", "kl" }, + { "Guarani", "gn" }, + { "Gujarati", "gu" }, + { "Hawaiian", "haw" }, /* Yes, "haw", not "cpe". */ + { "Hebrew", "he" }, + { "Hindi", "hi" }, + { "Hungarian", "hu" }, + { "Icelandic", "is" }, + { "Indonesian", "id" }, + { "Inuktitut", "iu" }, + { "Irish", "ga" }, + { "Italian", "it" }, + { "Japanese", "ja" }, + { "Javanese", "jv" }, + { "Kalaallisut", "kl" }, + { "Kannada", "kn" }, + { "Kashmiri", "ks" }, + { "Kazakh", "kk" }, + { "Khmer", "km" }, + { "Kinyarwanda", "rw" }, + { "Kirghiz", "ky" }, + { "Korean", "ko" }, + { "Kurdish", "ku" }, + { "Latin", "la" }, + { "Latvian", "lv" }, + { "Lithuanian", "lt" }, + { "Macedonian", "mk" }, + { "Malagasy", "mg" }, + { "Malay", "ms" }, + { "Malayalam", "ml" }, + { "Maltese", "mt" }, + { "Manx", "gv" }, + { "Marathi", "mr" }, + { "Moldavian", "mo" }, + { "Mongolian", "mn" }, + { "Nepali", "ne" }, + { "Norwegian", "nb" }, /* Yes, "nb", not the obsolete "no". */ + { "Nyanja", "ny" }, + { "Nynorsk", "nn" }, + { "Oriya", "or" }, + { "Oromo", "om" }, + { "Panjabi", "pa" }, + { "Pashto", "ps" }, + { "Persian", "fa" }, + { "Polish", "pl" }, + { "Portuguese", "pt" }, + { "Portuguese, Brazilian", "pt_BR" }, + { "Punjabi", "pa" }, + { "Pushto", "ps" }, + { "Quechua", "qu" }, + { "Romanian", "ro" }, + { "Ruanda", "rw" }, + { "Rundi", "rn" }, + { "Russian", "ru" }, + { "Sami", "se_NO" }, /* Not just "se". */ + { "Sanskrit", "sa" }, + { "Scottish", "gd" }, + { "Serbian", "sr" }, + { "Simplified Chinese", "zh_CN" }, + { "Sindhi", "sd" }, + { "Sinhalese", "si" }, + { "Slovak", "sk" }, + { "Slovenian", "sl" }, + { "Somali", "so" }, + { "Spanish", "es" }, + { "Sundanese", "su" }, + { "Swahili", "sw" }, + { "Swedish", "sv" }, + { "Tagalog", "tl" }, + { "Tajik", "tg" }, + { "Tajiki", "tg" }, + { "Tamil", "ta" }, + { "Tatar", "tt" }, + { "Telugu", "te" }, + { "Thai", "th" }, + { "Tibetan", "bo" }, + { "Tigrinya", "ti" }, + { "Tongan", "to" }, + { "Traditional Chinese", "zh_TW" }, + { "Turkish", "tr" }, + { "Turkmen", "tk" }, + { "Uighur", "ug" }, + { "Ukrainian", "uk" }, + { "Urdu", "ur" }, + { "Uzbek", "uz" }, + { "Vietnamese", "vi" }, + { "Welsh", "cy" }, + { "Yiddish", "yi" } + }; + + /* Convert new-style locale names with language tags (ISO 639 and ISO 15924) + to Unix (ISO 639 and ISO 3166) names. */ + typedef struct { const char langtag[7+1]; const char unixy[12+1]; } + langtag_entry; + static const langtag_entry langtag_table[] = { + /* Mac OS X has "az-Arab", "az-Cyrl", "az-Latn". + The default script for az on Unix is Latin. */ + { "az-Latn", "az" }, + /* Mac OS X has "bs-Cyrl", "bs-Latn". + The default script for bs on Unix is Latin. */ + { "bs-Latn", "bs" }, + /* Mac OS X has "ga-dots". Does not yet exist on Unix. */ + { "ga-dots", "ga" }, + /* Mac OS X has "kk-Cyrl". + The default script for kk on Unix is Cyrillic. */ + { "kk-Cyrl", "kk" }, + /* Mac OS X has "mn-Cyrl", "mn-Mong". + The default script for mn on Unix is Cyrillic. */ + { "mn-Cyrl", "mn" }, + /* Mac OS X has "ms-Arab", "ms-Latn". + The default script for ms on Unix is Latin. */ + { "ms-Latn", "ms" }, + /* Mac OS X has "pa-Arab", "pa-Guru". + Country codes are used to distinguish these on Unix. */ + { "pa-Arab", "pa_PK" }, + { "pa-Guru", "pa_IN" }, + /* Mac OS X has "shi-Latn", "shi-Tfng". Does not yet exist on Unix. */ + /* Mac OS X has "sr-Cyrl", "sr-Latn". + The default script for sr on Unix is Cyrillic. */ + { "sr-Cyrl", "sr" }, + /* Mac OS X has "tg-Cyrl". + The default script for tg on Unix is Cyrillic. */ + { "tg-Cyrl", "tg" }, + /* Mac OS X has "tk-Cyrl". + The default script for tk on Unix is Cyrillic. */ + { "tk-Cyrl", "tk" }, + /* Mac OS X has "tt-Cyrl". + The default script for tt on Unix is Cyrillic. */ + { "tt-Cyrl", "tt" }, + /* Mac OS X has "uz-Arab", "uz-Cyrl", "uz-Latn". + The default script for uz on Unix is Latin. */ + { "uz-Latn", "uz" }, + /* Mac OS X has "vai-Latn", "vai-Vaii". Does not yet exist on Unix. */ + /* Mac OS X has "yue-Hans", "yue-Hant". + The default script for yue on Unix is Simplified Han. */ + { "yue-Hans", "yue" }, + /* Mac OS X has "zh-Hans", "zh-Hant". + Country codes are used to distinguish these on Unix. */ + { "zh-Hans", "zh_CN" }, + { "zh-Hant", "zh_TW" } + }; + + /* Convert script names (ISO 15924) to Unix conventions. + See https://www.unicode.org/iso15924/iso15924-codes.html */ + typedef struct { const char script[4+1]; const char unixy[9+1]; } + script_entry; + static const script_entry script_table[] = { + { "Arab", "arabic" }, + { "Cyrl", "cyrillic" }, + { "Latn", "latin" }, + { "Mong", "mongolian" } + }; + + /* Step 1: Convert using legacy_table. */ + if (name[0] >= 'A' && name[0] <= 'Z') + { + unsigned int i1, i2; + i1 = 0; + i2 = sizeof (legacy_table) / sizeof (legacy_entry); + while (i2 - i1 > 1) + { + /* At this point we know that if name occurs in legacy_table, + its index must be >= i1 and < i2. */ + unsigned int i = (i1 + i2) >> 1; + const legacy_entry *p = &legacy_table[i]; + if (strcmp (name, p->legacy) < 0) + i2 = i; + else + i1 = i; + } + if (strcmp (name, legacy_table[i1].legacy) == 0) + { + strcpy (name, legacy_table[i1].unixy); + return; + } + } + + /* Step 2: Convert using langtag_table and script_table. */ + if (strlen (name) == 7 && name[2] == '-') + { + unsigned int i1, i2; + i1 = 0; + i2 = sizeof (langtag_table) / sizeof (langtag_entry); + while (i2 - i1 > 1) + { + /* At this point we know that if name occurs in langtag_table, + its index must be >= i1 and < i2. */ + unsigned int i = (i1 + i2) >> 1; + const langtag_entry *p = &langtag_table[i]; + if (strcmp (name, p->langtag) < 0) + i2 = i; + else + i1 = i; + } + if (strcmp (name, langtag_table[i1].langtag) == 0) + { + strcpy (name, langtag_table[i1].unixy); + return; + } + + i1 = 0; + i2 = sizeof (script_table) / sizeof (script_entry); + while (i2 - i1 > 1) + { + /* At this point we know that if (name + 3) occurs in script_table, + its index must be >= i1 and < i2. */ + unsigned int i = (i1 + i2) >> 1; + const script_entry *p = &script_table[i]; + if (strcmp (name + 3, p->script) < 0) + i2 = i; + else + i1 = i; + } + if (strcmp (name + 3, script_table[i1].script) == 0) + { + name[2] = '@'; + strcpy (name + 3, script_table[i1].unixy); + return; + } + } + + /* Step 3: Convert new-style dash to Unix underscore. */ + { + char *p; + for (p = name; *p != '\0'; p++) + if (*p == '-') + *p = '_'; + } +} + +#endif + + +#if defined WINDOWS_NATIVE || defined __CYGWIN__ /* Native Windows or Cygwin */ + +/* Canonicalize a Windows native locale name to a Unix locale name. + NAME is a sufficiently large buffer. + On input, it contains the Windows locale name. + On output, it contains the Unix locale name. */ +# if !defined IN_LIBINTL +static +# endif +void +gl_locale_name_canonicalize (char *name) +{ + /* FIXME: This is probably incomplete: it does not handle "zh-Hans" and + "zh-Hant". */ + char *p; + + for (p = name; *p != '\0'; p++) + if (*p == '-') + { + *p = '_'; + p++; + for (; *p != '\0'; p++) + { + if (*p >= 'a' && *p <= 'z') + *p += 'A' - 'a'; + if (*p == '-') + { + *p = '\0'; + return; + } + } + return; + } +} + +# if !defined IN_LIBINTL +static +# endif +const char * +gl_locale_name_from_win32_LANGID (LANGID langid) +{ + /* Activate the new code only when the GETTEXT_MUI environment variable is + set, for the time being, since the new code is not well tested. */ + if (getenv ("GETTEXT_MUI") != NULL) + { + static char namebuf[256]; + + /* Query the system's notion of locale name. + On Windows95/98/ME, GetLocaleInfoA returns some incorrect results. + But we don't need to support systems that are so old. */ + if (GetLocaleInfoA (MAKELCID (langid, SORT_DEFAULT), LOCALE_SNAME, + namebuf, sizeof (namebuf) - 1)) + { + /* Convert it to a Unix locale name. */ + gl_locale_name_canonicalize (namebuf); + return namebuf; + } + } + /* Internet Explorer has an LCID to RFC3066 name mapping stored in + HKEY_CLASSES_ROOT\Mime\Database\Rfc1766. But we better don't use that + since IE's i18n subsystem is known to be inconsistent with the native + Windows base (e.g. they have different character conversion facilities + that produce different results). */ + /* Use our own table. */ + { + int primary, sub; + + /* Split into language and territory part. */ + primary = PRIMARYLANGID (langid); + sub = SUBLANGID (langid); + + /* Dispatch on language. + See also https://www.unicode.org/unicode/onlinedat/languages.html . + For details about languages, see https://www.ethnologue.com/ . */ + switch (primary) + { + case LANG_AFRIKAANS: + switch (sub) + { + case SUBLANG_AFRIKAANS_SOUTH_AFRICA: return "af_ZA"; + } + return "af"; + case LANG_ALBANIAN: + switch (sub) + { + case SUBLANG_ALBANIAN_ALBANIA: return "sq_AL"; + } + return "sq"; + case LANG_ALSATIAN: + switch (sub) + { + case SUBLANG_ALSATIAN_FRANCE: return "gsw_FR"; + } + return "gsw"; + case LANG_AMHARIC: + switch (sub) + { + case SUBLANG_AMHARIC_ETHIOPIA: return "am_ET"; + } + return "am"; + case LANG_ARABIC: + switch (sub) + { + case SUBLANG_ARABIC_SAUDI_ARABIA: return "ar_SA"; + case SUBLANG_ARABIC_IRAQ: return "ar_IQ"; + case SUBLANG_ARABIC_EGYPT: return "ar_EG"; + case SUBLANG_ARABIC_LIBYA: return "ar_LY"; + case SUBLANG_ARABIC_ALGERIA: return "ar_DZ"; + case SUBLANG_ARABIC_MOROCCO: return "ar_MA"; + case SUBLANG_ARABIC_TUNISIA: return "ar_TN"; + case SUBLANG_ARABIC_OMAN: return "ar_OM"; + case SUBLANG_ARABIC_YEMEN: return "ar_YE"; + case SUBLANG_ARABIC_SYRIA: return "ar_SY"; + case SUBLANG_ARABIC_JORDAN: return "ar_JO"; + case SUBLANG_ARABIC_LEBANON: return "ar_LB"; + case SUBLANG_ARABIC_KUWAIT: return "ar_KW"; + case SUBLANG_ARABIC_UAE: return "ar_AE"; + case SUBLANG_ARABIC_BAHRAIN: return "ar_BH"; + case SUBLANG_ARABIC_QATAR: return "ar_QA"; + } + return "ar"; + case LANG_ARMENIAN: + switch (sub) + { + case SUBLANG_ARMENIAN_ARMENIA: return "hy_AM"; + } + return "hy"; + case LANG_ASSAMESE: + switch (sub) + { + case SUBLANG_ASSAMESE_INDIA: return "as_IN"; + } + return "as"; + case LANG_AZERI: + switch (sub) + { + /* FIXME: Adjust this when Azerbaijani locales appear on Unix. */ + case 0x1e: return "az@latin"; + case SUBLANG_AZERI_LATIN: return "az_AZ@latin"; + case 0x1d: return "az@cyrillic"; + case SUBLANG_AZERI_CYRILLIC: return "az_AZ@cyrillic"; + } + return "az"; + case LANG_BASHKIR: + switch (sub) + { + case SUBLANG_BASHKIR_RUSSIA: return "ba_RU"; + } + return "ba"; + case LANG_BASQUE: + switch (sub) + { + case SUBLANG_BASQUE_BASQUE: return "eu_ES"; + } + return "eu"; /* Ambiguous: could be "eu_ES" or "eu_FR". */ + case LANG_BELARUSIAN: + switch (sub) + { + case SUBLANG_BELARUSIAN_BELARUS: return "be_BY"; + } + return "be"; + case LANG_BENGALI: + switch (sub) + { + case SUBLANG_BENGALI_INDIA: return "bn_IN"; + case SUBLANG_BENGALI_BANGLADESH: return "bn_BD"; + } + return "bn"; + case LANG_BRETON: + switch (sub) + { + case SUBLANG_BRETON_FRANCE: return "br_FR"; + } + return "br"; + case LANG_BULGARIAN: + switch (sub) + { + case SUBLANG_BULGARIAN_BULGARIA: return "bg_BG"; + } + return "bg"; + case LANG_BURMESE: + switch (sub) + { + case SUBLANG_DEFAULT: return "my_MM"; + } + return "my"; + case LANG_CAMBODIAN: + switch (sub) + { + case SUBLANG_CAMBODIAN_CAMBODIA: return "km_KH"; + } + return "km"; + case LANG_CATALAN: + switch (sub) + { + case SUBLANG_CATALAN_SPAIN: return "ca_ES"; + } + return "ca"; + case LANG_CHEROKEE: + switch (sub) + { + case SUBLANG_DEFAULT: return "chr_US"; + } + return "chr"; + case LANG_CHINESE: + switch (sub) + { + case SUBLANG_CHINESE_TRADITIONAL: case 0x1f: return "zh_TW"; + case SUBLANG_CHINESE_SIMPLIFIED: case 0x00: return "zh_CN"; + case SUBLANG_CHINESE_HONGKONG: return "zh_HK"; /* traditional */ + case SUBLANG_CHINESE_SINGAPORE: return "zh_SG"; /* simplified */ + case SUBLANG_CHINESE_MACAU: return "zh_MO"; /* traditional */ + } + return "zh"; + case LANG_CORSICAN: + switch (sub) + { + case SUBLANG_CORSICAN_FRANCE: return "co_FR"; + } + return "co"; + case LANG_CROATIAN: /* LANG_CROATIAN == LANG_SERBIAN == LANG_BOSNIAN + * What used to be called Serbo-Croatian + * should really now be two separate + * languages because of political reasons. + * (Says tml, who knows nothing about Serbian + * or Croatian.) + * (I can feel those flames coming already.) + */ + switch (sub) + { + /* Croatian */ + case 0x00: return "hr"; + case SUBLANG_CROATIAN_CROATIA: return "hr_HR"; + case SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN: return "hr_BA"; + /* Serbian */ + case 0x1f: return "sr"; + case 0x1c: return "sr"; /* latin */ + case SUBLANG_SERBIAN_LATIN: return "sr_CS"; /* latin */ + case 0x09: return "sr_RS"; /* latin */ + case 0x0b: return "sr_ME"; /* latin */ + case 0x06: return "sr_BA"; /* latin */ + case 0x1b: return "sr@cyrillic"; + case SUBLANG_SERBIAN_CYRILLIC: return "sr_CS@cyrillic"; + case 0x0a: return "sr_RS@cyrillic"; + case 0x0c: return "sr_ME@cyrillic"; + case 0x07: return "sr_BA@cyrillic"; + /* Bosnian */ + case 0x1e: return "bs"; + case 0x1a: return "bs"; /* latin */ + case SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN: return "bs_BA"; /* latin */ + case 0x19: return "bs@cyrillic"; + case SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC: return "bs_BA@cyrillic"; + } + return "hr"; + case LANG_CZECH: + switch (sub) + { + case SUBLANG_CZECH_CZECH_REPUBLIC: return "cs_CZ"; + } + return "cs"; + case LANG_DANISH: + switch (sub) + { + case SUBLANG_DANISH_DENMARK: return "da_DK"; + } + return "da"; + case LANG_DARI: + /* FIXME: Adjust this when such locales appear on Unix. */ + switch (sub) + { + case SUBLANG_DARI_AFGHANISTAN: return "prs_AF"; + } + return "prs"; + case LANG_DIVEHI: + switch (sub) + { + case SUBLANG_DIVEHI_MALDIVES: return "dv_MV"; + } + return "dv"; + case LANG_DUTCH: + switch (sub) + { + case SUBLANG_DUTCH: return "nl_NL"; + case SUBLANG_DUTCH_BELGIAN: /* FLEMISH, VLAAMS */ return "nl_BE"; + case SUBLANG_DUTCH_SURINAM: return "nl_SR"; + } + return "nl"; + case LANG_EDO: + switch (sub) + { + case SUBLANG_DEFAULT: return "bin_NG"; + } + return "bin"; + case LANG_ENGLISH: + switch (sub) + { + /* SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. Heh. I thought + * English was the language spoken in England. + * Oh well. + */ + case SUBLANG_ENGLISH_US: return "en_US"; + case SUBLANG_ENGLISH_UK: return "en_GB"; + case SUBLANG_ENGLISH_AUS: return "en_AU"; + case SUBLANG_ENGLISH_CAN: return "en_CA"; + case SUBLANG_ENGLISH_NZ: return "en_NZ"; + case SUBLANG_ENGLISH_EIRE: return "en_IE"; + case SUBLANG_ENGLISH_SOUTH_AFRICA: return "en_ZA"; + case SUBLANG_ENGLISH_JAMAICA: return "en_JM"; + case SUBLANG_ENGLISH_CARIBBEAN: return "en_GD"; /* Grenada? */ + case SUBLANG_ENGLISH_BELIZE: return "en_BZ"; + case SUBLANG_ENGLISH_TRINIDAD: return "en_TT"; + case SUBLANG_ENGLISH_ZIMBABWE: return "en_ZW"; + case SUBLANG_ENGLISH_PHILIPPINES: return "en_PH"; + case SUBLANG_ENGLISH_INDONESIA: return "en_ID"; + case SUBLANG_ENGLISH_HONGKONG: return "en_HK"; + case SUBLANG_ENGLISH_INDIA: return "en_IN"; + case SUBLANG_ENGLISH_MALAYSIA: return "en_MY"; + case SUBLANG_ENGLISH_SINGAPORE: return "en_SG"; + } + return "en"; + case LANG_ESTONIAN: + switch (sub) + { + case SUBLANG_ESTONIAN_ESTONIA: return "et_EE"; + } + return "et"; + case LANG_FAEROESE: + switch (sub) + { + case SUBLANG_FAEROESE_FAROE_ISLANDS: return "fo_FO"; + } + return "fo"; + case LANG_FARSI: + switch (sub) + { + case SUBLANG_FARSI_IRAN: return "fa_IR"; + } + return "fa"; + case LANG_FINNISH: + switch (sub) + { + case SUBLANG_FINNISH_FINLAND: return "fi_FI"; + } + return "fi"; + case LANG_FRENCH: + switch (sub) + { + case SUBLANG_FRENCH: return "fr_FR"; + case SUBLANG_FRENCH_BELGIAN: /* WALLOON */ return "fr_BE"; + case SUBLANG_FRENCH_CANADIAN: return "fr_CA"; + case SUBLANG_FRENCH_SWISS: return "fr_CH"; + case SUBLANG_FRENCH_LUXEMBOURG: return "fr_LU"; + case SUBLANG_FRENCH_MONACO: return "fr_MC"; + case SUBLANG_FRENCH_WESTINDIES: return "fr"; /* Caribbean? */ + case SUBLANG_FRENCH_REUNION: return "fr_RE"; + case SUBLANG_FRENCH_CONGO: return "fr_CG"; + case SUBLANG_FRENCH_SENEGAL: return "fr_SN"; + case SUBLANG_FRENCH_CAMEROON: return "fr_CM"; + case SUBLANG_FRENCH_COTEDIVOIRE: return "fr_CI"; + case SUBLANG_FRENCH_MALI: return "fr_ML"; + case SUBLANG_FRENCH_MOROCCO: return "fr_MA"; + case SUBLANG_FRENCH_HAITI: return "fr_HT"; + } + return "fr"; + case LANG_FRISIAN: + switch (sub) + { + case SUBLANG_FRISIAN_NETHERLANDS: return "fy_NL"; + } + return "fy"; + case LANG_FULFULDE: + /* Spoken in Nigeria, Guinea, Senegal, Mali, Niger, Cameroon, Benin. */ + switch (sub) + { + case SUBLANG_DEFAULT: return "ff_NG"; + } + return "ff"; + case LANG_GAELIC: + switch (sub) + { + case 0x01: /* SCOTTISH */ + /* old, superseded by LANG_SCOTTISH_GAELIC */ + return "gd_GB"; + case SUBLANG_IRISH_IRELAND: return "ga_IE"; + } + return "ga"; + case LANG_GALICIAN: + switch (sub) + { + case SUBLANG_GALICIAN_SPAIN: return "gl_ES"; + } + return "gl"; + case LANG_GEORGIAN: + switch (sub) + { + case SUBLANG_GEORGIAN_GEORGIA: return "ka_GE"; + } + return "ka"; + case LANG_GERMAN: + switch (sub) + { + case SUBLANG_GERMAN: return "de_DE"; + case SUBLANG_GERMAN_SWISS: return "de_CH"; + case SUBLANG_GERMAN_AUSTRIAN: return "de_AT"; + case SUBLANG_GERMAN_LUXEMBOURG: return "de_LU"; + case SUBLANG_GERMAN_LIECHTENSTEIN: return "de_LI"; + } + return "de"; + case LANG_GREEK: + switch (sub) + { + case SUBLANG_GREEK_GREECE: return "el_GR"; + } + return "el"; + case LANG_GREENLANDIC: + switch (sub) + { + case SUBLANG_GREENLANDIC_GREENLAND: return "kl_GL"; + } + return "kl"; + case LANG_GUARANI: + switch (sub) + { + case SUBLANG_DEFAULT: return "gn_PY"; + } + return "gn"; + case LANG_GUJARATI: + switch (sub) + { + case SUBLANG_GUJARATI_INDIA: return "gu_IN"; + } + return "gu"; + case LANG_HAUSA: + switch (sub) + { + case 0x1f: return "ha"; + case SUBLANG_HAUSA_NIGERIA_LATIN: return "ha_NG"; + } + return "ha"; + case LANG_HAWAIIAN: + /* FIXME: Do they mean Hawaiian ("haw_US", 1000 speakers) + or Hawaii Creole English ("cpe_US", 600000 speakers)? */ + switch (sub) + { + case SUBLANG_DEFAULT: return "cpe_US"; + } + return "cpe"; + case LANG_HEBREW: + switch (sub) + { + case SUBLANG_HEBREW_ISRAEL: return "he_IL"; + } + return "he"; + case LANG_HINDI: + switch (sub) + { + case SUBLANG_HINDI_INDIA: return "hi_IN"; + } + return "hi"; + case LANG_HUNGARIAN: + switch (sub) + { + case SUBLANG_HUNGARIAN_HUNGARY: return "hu_HU"; + } + return "hu"; + case LANG_IBIBIO: + switch (sub) + { + case SUBLANG_DEFAULT: return "nic_NG"; + } + return "nic"; + case LANG_ICELANDIC: + switch (sub) + { + case SUBLANG_ICELANDIC_ICELAND: return "is_IS"; + } + return "is"; + case LANG_IGBO: + switch (sub) + { + case SUBLANG_IGBO_NIGERIA: return "ig_NG"; + } + return "ig"; + case LANG_INDONESIAN: + switch (sub) + { + case SUBLANG_INDONESIAN_INDONESIA: return "id_ID"; + } + return "id"; + case LANG_INUKTITUT: + switch (sub) + { + case 0x1e: return "iu"; /* syllabic */ + case SUBLANG_INUKTITUT_CANADA: return "iu_CA"; /* syllabic */ + case 0x1f: return "iu@latin"; + case SUBLANG_INUKTITUT_CANADA_LATIN: return "iu_CA@latin"; + } + return "iu"; + case LANG_ITALIAN: + switch (sub) + { + case SUBLANG_ITALIAN: return "it_IT"; + case SUBLANG_ITALIAN_SWISS: return "it_CH"; + } + return "it"; + case LANG_JAPANESE: + switch (sub) + { + case SUBLANG_JAPANESE_JAPAN: return "ja_JP"; + } + return "ja"; + case LANG_KANNADA: + switch (sub) + { + case SUBLANG_KANNADA_INDIA: return "kn_IN"; + } + return "kn"; + case LANG_KANURI: + switch (sub) + { + case SUBLANG_DEFAULT: return "kr_NG"; + } + return "kr"; + case LANG_KASHMIRI: + switch (sub) + { + case SUBLANG_DEFAULT: return "ks_PK"; + case SUBLANG_KASHMIRI_INDIA: return "ks_IN"; + } + return "ks"; + case LANG_KAZAK: + switch (sub) + { + case SUBLANG_KAZAK_KAZAKHSTAN: return "kk_KZ"; + } + return "kk"; + case LANG_KICHE: + /* FIXME: Adjust this when such locales appear on Unix. */ + switch (sub) + { + case SUBLANG_KICHE_GUATEMALA: return "qut_GT"; + } + return "qut"; + case LANG_KINYARWANDA: + switch (sub) + { + case SUBLANG_KINYARWANDA_RWANDA: return "rw_RW"; + } + return "rw"; + case LANG_KONKANI: + /* FIXME: Adjust this when such locales appear on Unix. */ + switch (sub) + { + case SUBLANG_KONKANI_INDIA: return "kok_IN"; + } + return "kok"; + case LANG_KOREAN: + switch (sub) + { + case SUBLANG_DEFAULT: return "ko_KR"; + } + return "ko"; + case LANG_KYRGYZ: + switch (sub) + { + case SUBLANG_KYRGYZ_KYRGYZSTAN: return "ky_KG"; + } + return "ky"; + case LANG_LAO: + switch (sub) + { + case SUBLANG_LAO_LAOS: return "lo_LA"; + } + return "lo"; + case LANG_LATIN: + switch (sub) + { + case SUBLANG_DEFAULT: return "la_VA"; + } + return "la"; + case LANG_LATVIAN: + switch (sub) + { + case SUBLANG_LATVIAN_LATVIA: return "lv_LV"; + } + return "lv"; + case LANG_LITHUANIAN: + switch (sub) + { + case SUBLANG_LITHUANIAN_LITHUANIA: return "lt_LT"; + } + return "lt"; + case LANG_LUXEMBOURGISH: + switch (sub) + { + case SUBLANG_LUXEMBOURGISH_LUXEMBOURG: return "lb_LU"; + } + return "lb"; + case LANG_MACEDONIAN: + switch (sub) + { + case SUBLANG_MACEDONIAN_MACEDONIA: return "mk_MK"; + } + return "mk"; + case LANG_MALAY: + switch (sub) + { + case SUBLANG_MALAY_MALAYSIA: return "ms_MY"; + case SUBLANG_MALAY_BRUNEI_DARUSSALAM: return "ms_BN"; + } + return "ms"; + case LANG_MALAYALAM: + switch (sub) + { + case SUBLANG_MALAYALAM_INDIA: return "ml_IN"; + } + return "ml"; + case LANG_MALTESE: + switch (sub) + { + case SUBLANG_MALTESE_MALTA: return "mt_MT"; + } + return "mt"; + case LANG_MANIPURI: + /* FIXME: Adjust this when such locales appear on Unix. */ + switch (sub) + { + case SUBLANG_DEFAULT: return "mni_IN"; + } + return "mni"; + case LANG_MAORI: + switch (sub) + { + case SUBLANG_MAORI_NEW_ZEALAND: return "mi_NZ"; + } + return "mi"; + case LANG_MAPUDUNGUN: + switch (sub) + { + case SUBLANG_MAPUDUNGUN_CHILE: return "arn_CL"; + } + return "arn"; + case LANG_MARATHI: + switch (sub) + { + case SUBLANG_MARATHI_INDIA: return "mr_IN"; + } + return "mr"; + case LANG_MOHAWK: + switch (sub) + { + case SUBLANG_MOHAWK_CANADA: return "moh_CA"; + } + return "moh"; + case LANG_MONGOLIAN: + switch (sub) + { + case SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA: case 0x1e: return "mn_MN"; + case SUBLANG_MONGOLIAN_PRC: case 0x1f: return "mn_CN"; + } + return "mn"; /* Ambiguous: could be "mn_CN" or "mn_MN". */ + case LANG_NEPALI: + switch (sub) + { + case SUBLANG_NEPALI_NEPAL: return "ne_NP"; + case SUBLANG_NEPALI_INDIA: return "ne_IN"; + } + return "ne"; + case LANG_NORWEGIAN: + switch (sub) + { + case 0x1f: return "nb"; + case SUBLANG_NORWEGIAN_BOKMAL: return "nb_NO"; + case 0x1e: return "nn"; + case SUBLANG_NORWEGIAN_NYNORSK: return "nn_NO"; + } + return "no"; + case LANG_OCCITAN: + switch (sub) + { + case SUBLANG_OCCITAN_FRANCE: return "oc_FR"; + } + return "oc"; + case LANG_ORIYA: + switch (sub) + { + case SUBLANG_ORIYA_INDIA: return "or_IN"; + } + return "or"; + case LANG_OROMO: + switch (sub) + { + case SUBLANG_DEFAULT: return "om_ET"; + } + return "om"; + case LANG_PAPIAMENTU: + switch (sub) + { + case SUBLANG_DEFAULT: return "pap_AN"; + } + return "pap"; + case LANG_PASHTO: + switch (sub) + { + case SUBLANG_PASHTO_AFGHANISTAN: return "ps_AF"; + } + return "ps"; /* Ambiguous: could be "ps_PK" or "ps_AF". */ + case LANG_POLISH: + switch (sub) + { + case SUBLANG_POLISH_POLAND: return "pl_PL"; + } + return "pl"; + case LANG_PORTUGUESE: + switch (sub) + { + /* Hmm. SUBLANG_PORTUGUESE_BRAZILIAN == SUBLANG_DEFAULT. + Same phenomenon as SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. */ + case SUBLANG_PORTUGUESE_BRAZILIAN: return "pt_BR"; + case SUBLANG_PORTUGUESE: return "pt_PT"; + } + return "pt"; + case LANG_PUNJABI: + switch (sub) + { + case SUBLANG_PUNJABI_INDIA: return "pa_IN"; /* Gurmukhi script */ + case SUBLANG_PUNJABI_PAKISTAN: return "pa_PK"; /* Arabic script */ + } + return "pa"; + case LANG_QUECHUA: + /* Note: Microsoft uses the non-ISO language code "quz". */ + switch (sub) + { + case SUBLANG_QUECHUA_BOLIVIA: return "qu_BO"; + case SUBLANG_QUECHUA_ECUADOR: return "qu_EC"; + case SUBLANG_QUECHUA_PERU: return "qu_PE"; + } + return "qu"; + case LANG_ROMANIAN: + switch (sub) + { + case SUBLANG_ROMANIAN_ROMANIA: return "ro_RO"; + case SUBLANG_ROMANIAN_MOLDOVA: return "ro_MD"; + } + return "ro"; + case LANG_ROMANSH: + switch (sub) + { + case SUBLANG_ROMANSH_SWITZERLAND: return "rm_CH"; + } + return "rm"; + case LANG_RUSSIAN: + switch (sub) + { + case SUBLANG_RUSSIAN_RUSSIA: return "ru_RU"; + case SUBLANG_RUSSIAN_MOLDAVIA: return "ru_MD"; + } + return "ru"; /* Ambiguous: could be "ru_RU" or "ru_UA" or "ru_MD". */ + case LANG_SAMI: + switch (sub) + { + /* Northern Sami */ + case 0x00: return "se"; + case SUBLANG_SAMI_NORTHERN_NORWAY: return "se_NO"; + case SUBLANG_SAMI_NORTHERN_SWEDEN: return "se_SE"; + case SUBLANG_SAMI_NORTHERN_FINLAND: return "se_FI"; + /* Lule Sami */ + case 0x1f: return "smj"; + case SUBLANG_SAMI_LULE_NORWAY: return "smj_NO"; + case SUBLANG_SAMI_LULE_SWEDEN: return "smj_SE"; + /* Southern Sami */ + case 0x1e: return "sma"; + case SUBLANG_SAMI_SOUTHERN_NORWAY: return "sma_NO"; + case SUBLANG_SAMI_SOUTHERN_SWEDEN: return "sma_SE"; + /* Skolt Sami */ + case 0x1d: return "sms"; + case SUBLANG_SAMI_SKOLT_FINLAND: return "sms_FI"; + /* Inari Sami */ + case 0x1c: return "smn"; + case SUBLANG_SAMI_INARI_FINLAND: return "smn_FI"; + } + return "se"; /* or "smi"? */ + case LANG_SANSKRIT: + switch (sub) + { + case SUBLANG_SANSKRIT_INDIA: return "sa_IN"; + } + return "sa"; + case LANG_SCOTTISH_GAELIC: + switch (sub) + { + case SUBLANG_DEFAULT: return "gd_GB"; + } + return "gd"; + case LANG_SINDHI: + switch (sub) + { + case SUBLANG_SINDHI_INDIA: return "sd_IN"; + case SUBLANG_SINDHI_PAKISTAN: return "sd_PK"; + /*case SUBLANG_SINDHI_AFGHANISTAN: return "sd_AF";*/ + } + return "sd"; + case LANG_SINHALESE: + switch (sub) + { + case SUBLANG_SINHALESE_SRI_LANKA: return "si_LK"; + } + return "si"; + case LANG_SLOVAK: + switch (sub) + { + case SUBLANG_SLOVAK_SLOVAKIA: return "sk_SK"; + } + return "sk"; + case LANG_SLOVENIAN: + switch (sub) + { + case SUBLANG_SLOVENIAN_SLOVENIA: return "sl_SI"; + } + return "sl"; + case LANG_SOMALI: + switch (sub) + { + case SUBLANG_DEFAULT: return "so_SO"; + } + return "so"; + case LANG_SORBIAN: + /* FIXME: Adjust this when such locales appear on Unix. */ + switch (sub) + { + /* Upper Sorbian */ + case 0x00: return "hsb"; + case SUBLANG_UPPER_SORBIAN_GERMANY: return "hsb_DE"; + /* Lower Sorbian */ + case 0x1f: return "dsb"; + case SUBLANG_LOWER_SORBIAN_GERMANY: return "dsb_DE"; + } + return "wen"; + case LANG_SOTHO: + /* <https://docs.microsoft.com/en-us/windows/desktop/Intl/language-identifier-constants-and-strings> + calls it "Sesotho sa Leboa"; according to + <https://www.ethnologue.com/show_language.asp?code=nso> + <https://www.ethnologue.com/show_language.asp?code=sot> + it's the same as Northern Sotho. */ + switch (sub) + { + case SUBLANG_SOTHO_SOUTH_AFRICA: return "nso_ZA"; + } + return "nso"; + case LANG_SPANISH: + switch (sub) + { + case SUBLANG_SPANISH: return "es_ES"; + case SUBLANG_SPANISH_MEXICAN: return "es_MX"; + case SUBLANG_SPANISH_MODERN: + return "es_ES@modern"; /* not seen on Unix */ + case SUBLANG_SPANISH_GUATEMALA: return "es_GT"; + case SUBLANG_SPANISH_COSTA_RICA: return "es_CR"; + case SUBLANG_SPANISH_PANAMA: return "es_PA"; + case SUBLANG_SPANISH_DOMINICAN_REPUBLIC: return "es_DO"; + case SUBLANG_SPANISH_VENEZUELA: return "es_VE"; + case SUBLANG_SPANISH_COLOMBIA: return "es_CO"; + case SUBLANG_SPANISH_PERU: return "es_PE"; + case SUBLANG_SPANISH_ARGENTINA: return "es_AR"; + case SUBLANG_SPANISH_ECUADOR: return "es_EC"; + case SUBLANG_SPANISH_CHILE: return "es_CL"; + case SUBLANG_SPANISH_URUGUAY: return "es_UY"; + case SUBLANG_SPANISH_PARAGUAY: return "es_PY"; + case SUBLANG_SPANISH_BOLIVIA: return "es_BO"; + case SUBLANG_SPANISH_EL_SALVADOR: return "es_SV"; + case SUBLANG_SPANISH_HONDURAS: return "es_HN"; + case SUBLANG_SPANISH_NICARAGUA: return "es_NI"; + case SUBLANG_SPANISH_PUERTO_RICO: return "es_PR"; + case SUBLANG_SPANISH_US: return "es_US"; + } + return "es"; + case LANG_SUTU: + switch (sub) + { + case SUBLANG_DEFAULT: return "bnt_TZ"; /* or "st_LS" or "nso_ZA"? */ + } + return "bnt"; + case LANG_SWAHILI: + switch (sub) + { + case SUBLANG_SWAHILI_KENYA: return "sw_KE"; + } + return "sw"; + case LANG_SWEDISH: + switch (sub) + { + case SUBLANG_SWEDISH_SWEDEN: return "sv_SE"; + case SUBLANG_SWEDISH_FINLAND: return "sv_FI"; + } + return "sv"; + case LANG_SYRIAC: + switch (sub) + { + case SUBLANG_SYRIAC_SYRIA: return "syr_SY"; /* An extinct language. */ + } + return "syr"; + case LANG_TAGALOG: + switch (sub) + { + case SUBLANG_TAGALOG_PHILIPPINES: return "tl_PH"; /* or "fil_PH"? */ + } + return "tl"; /* or "fil"? */ + case LANG_TAJIK: + switch (sub) + { + case 0x1f: return "tg"; + case SUBLANG_TAJIK_TAJIKISTAN: return "tg_TJ"; + } + return "tg"; + case LANG_TAMAZIGHT: + /* Note: Microsoft uses the non-ISO language code "tmz". */ + switch (sub) + { + /* FIXME: Adjust this when Tamazight locales appear on Unix. */ + case SUBLANG_TAMAZIGHT_ARABIC: return "ber_MA@arabic"; + case 0x1f: return "ber@latin"; + case SUBLANG_TAMAZIGHT_ALGERIA_LATIN: return "ber_DZ@latin"; + } + return "ber"; + case LANG_TAMIL: + switch (sub) + { + case SUBLANG_TAMIL_INDIA: return "ta_IN"; + } + return "ta"; /* Ambiguous: could be "ta_IN" or "ta_LK" or "ta_SG". */ + case LANG_TATAR: + switch (sub) + { + case SUBLANG_TATAR_RUSSIA: return "tt_RU"; + } + return "tt"; + case LANG_TELUGU: + switch (sub) + { + case SUBLANG_TELUGU_INDIA: return "te_IN"; + } + return "te"; + case LANG_THAI: + switch (sub) + { + case SUBLANG_THAI_THAILAND: return "th_TH"; + } + return "th"; + case LANG_TIBETAN: + switch (sub) + { + case SUBLANG_TIBETAN_PRC: + /* Most Tibetans would not like "bo_CN". But Tibet does not yet + have a country code of its own. */ + return "bo"; + case SUBLANG_TIBETAN_BHUTAN: return "bo_BT"; + } + return "bo"; + case LANG_TIGRINYA: + switch (sub) + { + case SUBLANG_TIGRINYA_ETHIOPIA: return "ti_ET"; + case SUBLANG_TIGRINYA_ERITREA: return "ti_ER"; + } + return "ti"; + case LANG_TSONGA: + switch (sub) + { + case SUBLANG_DEFAULT: return "ts_ZA"; + } + return "ts"; + case LANG_TSWANA: + /* Spoken in South Africa, Botswana. */ + switch (sub) + { + case SUBLANG_TSWANA_SOUTH_AFRICA: return "tn_ZA"; + } + return "tn"; + case LANG_TURKISH: + switch (sub) + { + case SUBLANG_TURKISH_TURKEY: return "tr_TR"; + } + return "tr"; + case LANG_TURKMEN: + switch (sub) + { + case SUBLANG_TURKMEN_TURKMENISTAN: return "tk_TM"; + } + return "tk"; + case LANG_UIGHUR: + switch (sub) + { + case SUBLANG_UIGHUR_PRC: return "ug_CN"; + } + return "ug"; + case LANG_UKRAINIAN: + switch (sub) + { + case SUBLANG_UKRAINIAN_UKRAINE: return "uk_UA"; + } + return "uk"; + case LANG_URDU: + switch (sub) + { + case SUBLANG_URDU_PAKISTAN: return "ur_PK"; + case SUBLANG_URDU_INDIA: return "ur_IN"; + } + return "ur"; + case LANG_UZBEK: + switch (sub) + { + case 0x1f: return "uz"; + case SUBLANG_UZBEK_LATIN: return "uz_UZ"; + case 0x1e: return "uz@cyrillic"; + case SUBLANG_UZBEK_CYRILLIC: return "uz_UZ@cyrillic"; + } + return "uz"; + case LANG_VENDA: + switch (sub) + { + case SUBLANG_DEFAULT: return "ve_ZA"; + } + return "ve"; + case LANG_VIETNAMESE: + switch (sub) + { + case SUBLANG_VIETNAMESE_VIETNAM: return "vi_VN"; + } + return "vi"; + case LANG_WELSH: + switch (sub) + { + case SUBLANG_WELSH_UNITED_KINGDOM: return "cy_GB"; + } + return "cy"; + case LANG_WOLOF: + switch (sub) + { + case SUBLANG_WOLOF_SENEGAL: return "wo_SN"; + } + return "wo"; + case LANG_XHOSA: + switch (sub) + { + case SUBLANG_XHOSA_SOUTH_AFRICA: return "xh_ZA"; + } + return "xh"; + case LANG_YAKUT: + switch (sub) + { + case SUBLANG_YAKUT_RUSSIA: return "sah_RU"; + } + return "sah"; + case LANG_YI: + switch (sub) + { + case SUBLANG_YI_PRC: return "ii_CN"; + } + return "ii"; + case LANG_YIDDISH: + switch (sub) + { + case SUBLANG_DEFAULT: return "yi_IL"; + } + return "yi"; + case LANG_YORUBA: + switch (sub) + { + case SUBLANG_YORUBA_NIGERIA: return "yo_NG"; + } + return "yo"; + case LANG_ZULU: + switch (sub) + { + case SUBLANG_ZULU_SOUTH_AFRICA: return "zu_ZA"; + } + return "zu"; + default: return "C"; + } + } +} + +# if !defined IN_LIBINTL +static +# endif +const char * +gl_locale_name_from_win32_LCID (LCID lcid) +{ + LANGID langid; + + /* Strip off the sorting rules, keep only the language part. */ + langid = LANGIDFROMLCID (lcid); + + return gl_locale_name_from_win32_LANGID (langid); +} + +# ifdef WINDOWS_NATIVE + +/* Two variables to interface between get_lcid and the EnumLocales + callback function below. */ +static LCID found_lcid; +static char lname[LC_MAX * (LOCALE_NAME_MAX_LENGTH + 1) + 1]; + +/* Callback function for EnumLocales. */ +static BOOL CALLBACK +enum_locales_fn (LPTSTR locale_num_str) +{ + char *endp; + char locval[2 * LOCALE_NAME_MAX_LENGTH + 1 + 1]; + LCID try_lcid = strtoul (locale_num_str, &endp, 16); + + if (GetLocaleInfo (try_lcid, LOCALE_SENGLANGUAGE, + locval, LOCALE_NAME_MAX_LENGTH)) + { + strcat (locval, "_"); + if (GetLocaleInfo (try_lcid, LOCALE_SENGCOUNTRY, + locval + strlen (locval), LOCALE_NAME_MAX_LENGTH)) + { + size_t locval_len = strlen (locval); + + if (strncmp (locval, lname, locval_len) == 0 + && (lname[locval_len] == '.' + || lname[locval_len] == '\0')) + { + found_lcid = try_lcid; + return FALSE; + } + } + } + return TRUE; +} + +/* This lock protects the get_lcid against multiple simultaneous calls. */ +gl_lock_define_initialized(static, get_lcid_lock) + +/* Return the Locale ID (LCID) number given the locale's name, a + string, in LOCALE_NAME. This works by enumerating all the locales + supported by the system, until we find one whose name matches + LOCALE_NAME. */ +static LCID +get_lcid (const char *locale_name) +{ + /* A simple cache. */ + static LCID last_lcid; + static char last_locale[1000]; + + /* Lock while looking for an LCID, to protect access to static + variables: last_lcid, last_locale, found_lcid, and lname. */ + gl_lock_lock (get_lcid_lock); + if (last_lcid > 0 && strcmp (locale_name, last_locale) == 0) + { + gl_lock_unlock (get_lcid_lock); + return last_lcid; + } + strncpy (lname, locale_name, sizeof (lname) - 1); + lname[sizeof (lname) - 1] = '\0'; + found_lcid = 0; + EnumSystemLocales (enum_locales_fn, LCID_SUPPORTED); + if (found_lcid > 0) + { + last_lcid = found_lcid; + strcpy (last_locale, locale_name); + } + gl_lock_unlock (get_lcid_lock); + return found_lcid; +} + +# endif +#endif + + +#if HAVE_GOOD_USELOCALE /* glibc, Mac OS X, FreeBSD >= 9.1, Cygwin >= 2.6, + Solaris 11 OpenIndiana, or Solaris >= 11.4 */ + +/* Simple hash set of strings. We don't want to drag in lots of hash table + code here. */ + +# define SIZE_BITS (sizeof (size_t) * CHAR_BIT) + +/* A hash function for NUL-terminated char* strings using + the method described by Bruno Haible. + See https://www.haible.de/bruno/hashfunc.html. */ +static size_t _GL_ATTRIBUTE_PURE +string_hash (const void *x) +{ + const char *s = (const char *) x; + size_t h = 0; + + for (; *s; s++) + h = *s + ((h << 9) | (h >> (SIZE_BITS - 9))); + + return h; +} + +/* A hash table of fixed size. Multiple threads can access it read-only + simultaneously, but only one thread can insert into it at the same time. */ + +/* A node in a hash bucket collision list. */ +struct struniq_hash_node + { + struct struniq_hash_node * volatile next; + char contents[FLEXIBLE_ARRAY_MEMBER]; + }; + +# define STRUNIQ_HASH_TABLE_SIZE 257 +static struct struniq_hash_node * volatile struniq_hash_table[STRUNIQ_HASH_TABLE_SIZE] + /* = { NULL, ..., NULL } */; + +/* This lock protects the struniq_hash_table against multiple simultaneous + insertions. */ +gl_lock_define_initialized(static, struniq_lock) + +/* Store a copy of the given string in a string pool with indefinite extent. + Return a pointer to this copy. */ +static const char * +struniq (const char *string) +{ + size_t hashcode = string_hash (string); + size_t slot = hashcode % STRUNIQ_HASH_TABLE_SIZE; + size_t size; + struct struniq_hash_node *new_node; + struct struniq_hash_node *p; + for (p = struniq_hash_table[slot]; p != NULL; p = p->next) + if (strcmp (p->contents, string) == 0) + return p->contents; + size = strlen (string) + 1; + new_node = + (struct struniq_hash_node *) + malloc (FLEXSIZEOF (struct struniq_hash_node, contents, size)); + if (new_node == NULL) + /* Out of memory. Return a statically allocated string. */ + return "C"; + memcpy (new_node->contents, string, size); + /* Lock while inserting new_node. */ + gl_lock_lock (struniq_lock); + /* Check whether another thread already added the string while we were + waiting on the lock. */ + for (p = struniq_hash_table[slot]; p != NULL; p = p->next) + if (strcmp (p->contents, string) == 0) + { + free (new_node); + new_node = p; + goto done; + } + /* Really insert new_node into the hash table. Fill new_node entirely first, + because other threads may be iterating over the linked list. */ + new_node->next = struniq_hash_table[slot]; + struniq_hash_table[slot] = new_node; + done: + /* Unlock after new_node is inserted. */ + gl_lock_unlock (struniq_lock); + return new_node->contents; +} + +#endif + + +#if HAVE_GOOD_USELOCALE && HAVE_NAMELESS_LOCALES + +/* The 'locale_t' object does not contain the names of the locale categories. + We have to associate them with the object through a hash table. + The hash table is defined in localename-table.[hc]. */ + +/* Returns the name of a given locale category in a given locale_t object, + allocated as a string with indefinite extent. */ +static const char * +get_locale_t_name (int category, locale_t locale) +{ + if (locale == LC_GLOBAL_LOCALE) + { + /* Query the global locale. */ + const char *name = setlocale_null (category); + if (name != NULL) + return struniq (name); + else + /* Should normally not happen. */ + return ""; + } + else + { + /* Look up the names in the hash table. */ + size_t hashcode = locale_hash_function (locale); + size_t slot = hashcode % LOCALE_HASH_TABLE_SIZE; + /* If the locale was not found in the table, return "". This can + happen if the application uses the original newlocale()/duplocale() + functions instead of the overridden ones. */ + const char *name = ""; + struct locale_hash_node *p; + /* Lock while looking up the hash node. */ + gl_rwlock_rdlock (locale_lock); + for (p = locale_hash_table[slot]; p != NULL; p = p->next) + if (p->locale == locale) + { + name = p->names.category_name[category]; + break; + } + gl_rwlock_unlock (locale_lock); + return name; + } +} + +# if !(defined newlocale && defined duplocale && defined freelocale) +# error "newlocale, duplocale, freelocale not being replaced as expected!" +# endif + +/* newlocale() override. */ +locale_t +newlocale (int category_mask, const char *name, locale_t base) +#undef newlocale +{ + struct locale_categories_names names; + struct locale_hash_node *node; + locale_t result; + + /* Make sure name has indefinite extent. */ + if (((LC_CTYPE_MASK | LC_NUMERIC_MASK | LC_TIME_MASK | LC_COLLATE_MASK + | LC_MONETARY_MASK | LC_MESSAGES_MASK) + & category_mask) != 0) + name = struniq (name); + + /* Determine the category names of the result. */ + if (((LC_CTYPE_MASK | LC_NUMERIC_MASK | LC_TIME_MASK | LC_COLLATE_MASK + | LC_MONETARY_MASK | LC_MESSAGES_MASK) + & ~category_mask) == 0) + { + /* Use name, ignore base. */ + int category; + + name = struniq (name); + for (category = 0; category < 6; category++) + names.category_name[category] = name; + } + else + { + /* Use base, possibly also name. */ + if (base == NULL) + { + int category; + + for (category = 0; category < 6; category++) + { + int mask; + + switch (category) + { + case LC_CTYPE: + mask = LC_CTYPE_MASK; + break; + case LC_NUMERIC: + mask = LC_NUMERIC_MASK; + break; + case LC_TIME: + mask = LC_TIME_MASK; + break; + case LC_COLLATE: + mask = LC_COLLATE_MASK; + break; + case LC_MONETARY: + mask = LC_MONETARY_MASK; + break; + case LC_MESSAGES: + mask = LC_MESSAGES_MASK; + break; + default: + abort (); + } + names.category_name[category] = + ((mask & category_mask) != 0 ? name : "C"); + } + } + else if (base == LC_GLOBAL_LOCALE) + { + int category; + + for (category = 0; category < 6; category++) + { + int mask; + + switch (category) + { + case LC_CTYPE: + mask = LC_CTYPE_MASK; + break; + case LC_NUMERIC: + mask = LC_NUMERIC_MASK; + break; + case LC_TIME: + mask = LC_TIME_MASK; + break; + case LC_COLLATE: + mask = LC_COLLATE_MASK; + break; + case LC_MONETARY: + mask = LC_MONETARY_MASK; + break; + case LC_MESSAGES: + mask = LC_MESSAGES_MASK; + break; + default: + abort (); + } + names.category_name[category] = + ((mask & category_mask) != 0 + ? name + : get_locale_t_name (category, LC_GLOBAL_LOCALE)); + } + } + else + { + /* Look up the names of base in the hash table. Like multiple calls + of get_locale_t_name, but locking only once. */ + struct locale_hash_node *p; + int category; + + /* Lock while looking up the hash node. */ + gl_rwlock_rdlock (locale_lock); + for (p = locale_hash_table[locale_hash_function (base) % LOCALE_HASH_TABLE_SIZE]; + p != NULL; + p = p->next) + if (p->locale == base) + break; + + for (category = 0; category < 6; category++) + { + int mask; + + switch (category) + { + case LC_CTYPE: + mask = LC_CTYPE_MASK; + break; + case LC_NUMERIC: + mask = LC_NUMERIC_MASK; + break; + case LC_TIME: + mask = LC_TIME_MASK; + break; + case LC_COLLATE: + mask = LC_COLLATE_MASK; + break; + case LC_MONETARY: + mask = LC_MONETARY_MASK; + break; + case LC_MESSAGES: + mask = LC_MESSAGES_MASK; + break; + default: + abort (); + } + names.category_name[category] = + ((mask & category_mask) != 0 + ? name + : (p != NULL ? p->names.category_name[category] : "")); + } + + gl_rwlock_unlock (locale_lock); + } + } + + node = (struct locale_hash_node *) malloc (sizeof (struct locale_hash_node)); + if (node == NULL) + /* errno is set to ENOMEM. */ + return NULL; + + result = newlocale (category_mask, name, base); + if (result == NULL) + { + int saved_errno = errno; + free (node); + errno = saved_errno; + return NULL; + } + + /* Fill the hash node. */ + node->locale = result; + node->names = names; + + /* Insert it in the hash table. */ + { + size_t hashcode = locale_hash_function (result); + size_t slot = hashcode % LOCALE_HASH_TABLE_SIZE; + struct locale_hash_node *p; + + /* Lock while inserting the new node. */ + gl_rwlock_wrlock (locale_lock); + for (p = locale_hash_table[slot]; p != NULL; p = p->next) + if (p->locale == result) + { + /* This can happen if the application uses the original freelocale() + function instead of the overridden one. */ + p->names = node->names; + break; + } + if (p == NULL) + { + node->next = locale_hash_table[slot]; + locale_hash_table[slot] = node; + } + + gl_rwlock_unlock (locale_lock); + + if (p != NULL) + free (node); + } + + return result; +} + +/* duplocale() override. */ +locale_t +duplocale (locale_t locale) +#undef duplocale +{ + struct locale_hash_node *node; + locale_t result; + + if (locale == NULL) + /* Invalid argument. */ + abort (); + + node = (struct locale_hash_node *) malloc (sizeof (struct locale_hash_node)); + if (node == NULL) + /* errno is set to ENOMEM. */ + return NULL; + + result = duplocale (locale); + if (result == NULL) + { + int saved_errno = errno; + free (node); + errno = saved_errno; + return NULL; + } + + /* Fill the hash node. */ + node->locale = result; + if (locale == LC_GLOBAL_LOCALE) + { + int category; + + for (category = 0; category < 6; category++) + node->names.category_name[category] = + get_locale_t_name (category, LC_GLOBAL_LOCALE); + + /* Lock before inserting the new node. */ + gl_rwlock_wrlock (locale_lock); + } + else + { + struct locale_hash_node *p; + + /* Lock once, for the lookup and the insertion. */ + gl_rwlock_wrlock (locale_lock); + + for (p = locale_hash_table[locale_hash_function (locale) % LOCALE_HASH_TABLE_SIZE]; + p != NULL; + p = p->next) + if (p->locale == locale) + break; + if (p != NULL) + node->names = p->names; + else + { + /* This can happen if the application uses the original + newlocale()/duplocale() functions instead of the overridden + ones. */ + int category; + + for (category = 0; category < 6; category++) + node->names.category_name[category] = ""; + } + } + + /* Insert it in the hash table. */ + { + size_t hashcode = locale_hash_function (result); + size_t slot = hashcode % LOCALE_HASH_TABLE_SIZE; + struct locale_hash_node *p; + + for (p = locale_hash_table[slot]; p != NULL; p = p->next) + if (p->locale == result) + { + /* This can happen if the application uses the original freelocale() + function instead of the overridden one. */ + p->names = node->names; + break; + } + if (p == NULL) + { + node->next = locale_hash_table[slot]; + locale_hash_table[slot] = node; + } + + gl_rwlock_unlock (locale_lock); + + if (p != NULL) + free (node); + } + + return result; +} + +/* freelocale() override. */ +void +freelocale (locale_t locale) +#undef freelocale +{ + if (locale == NULL || locale == LC_GLOBAL_LOCALE) + /* Invalid argument. */ + abort (); + + { + size_t hashcode = locale_hash_function (locale); + size_t slot = hashcode % LOCALE_HASH_TABLE_SIZE; + struct locale_hash_node *found; + struct locale_hash_node **p; + + found = NULL; + /* Lock while removing the hash node. */ + gl_rwlock_wrlock (locale_lock); + for (p = &locale_hash_table[slot]; *p != NULL; p = &(*p)->next) + if ((*p)->locale == locale) + { + found = *p; + *p = (*p)->next; + break; + } + gl_rwlock_unlock (locale_lock); + free (found); + } + + freelocale (locale); +} + +#endif + + +#if defined IN_LIBINTL || HAVE_GOOD_USELOCALE + +/* Like gl_locale_name_thread, except that the result is not in storage of + indefinite extent. */ +# if !defined IN_LIBINTL +static +# endif +const char * +gl_locale_name_thread_unsafe (int category, const char *categoryname) +{ +# if HAVE_GOOD_USELOCALE + { + locale_t thread_locale = uselocale (NULL); + if (thread_locale != LC_GLOBAL_LOCALE) + { +# if __GLIBC__ >= 2 && !defined __UCLIBC__ + /* Work around an incorrect definition of the _NL_LOCALE_NAME macro in + glibc < 2.12. + See <https://sourceware.org/bugzilla/show_bug.cgi?id=10968>. */ + const char *name = + nl_langinfo (_NL_ITEM ((category), _NL_ITEM_INDEX (-1))); + if (name[0] == '\0') + /* Fallback code for glibc < 2.4, which did not implement + nl_langinfo (_NL_LOCALE_NAME (category)). */ + name = thread_locale->__names[category]; + return name; +# elif defined __linux__ && HAVE_LANGINFO_H && defined NL_LOCALE_NAME + /* musl libc */ + return nl_langinfo_l (NL_LOCALE_NAME (category), thread_locale); +# elif (defined __FreeBSD__ || defined __DragonFly__) || (defined __APPLE__ && defined __MACH__) + /* FreeBSD, Mac OS X */ + int mask; + + switch (category) + { + case LC_CTYPE: + mask = LC_CTYPE_MASK; + break; + case LC_NUMERIC: + mask = LC_NUMERIC_MASK; + break; + case LC_TIME: + mask = LC_TIME_MASK; + break; + case LC_COLLATE: + mask = LC_COLLATE_MASK; + break; + case LC_MONETARY: + mask = LC_MONETARY_MASK; + break; + case LC_MESSAGES: + mask = LC_MESSAGES_MASK; + break; + default: /* We shouldn't get here. */ + return ""; + } + return querylocale (mask, thread_locale); +# elif defined __sun +# if HAVE_GETLOCALENAME_L + /* Solaris >= 12. */ + return getlocalename_l (category, thread_locale); +# elif HAVE_SOLARIS114_LOCALES + /* Solaris >= 11.4. */ + void *lcp = (*thread_locale)->core.data->lcp; + if (lcp != NULL) + switch (category) + { + case LC_CTYPE: + case LC_NUMERIC: + case LC_TIME: + case LC_COLLATE: + case LC_MONETARY: + case LC_MESSAGES: + return ((const char * const *) lcp)[category]; + default: /* We shouldn't get here. */ + return ""; + } +# elif HAVE_NAMELESS_LOCALES + return get_locale_t_name (category, thread_locale); +# else + /* Solaris 11 OpenIndiana. + For the internal structure of locale objects, see + https://github.com/OpenIndiana/illumos-gate/blob/master/usr/src/lib/libc/port/locale/localeimpl.h */ + switch (category) + { + case LC_CTYPE: + case LC_NUMERIC: + case LC_TIME: + case LC_COLLATE: + case LC_MONETARY: + case LC_MESSAGES: + return ((const char * const *) thread_locale)[category]; + default: /* We shouldn't get here. */ + return ""; + } +# endif +# elif defined _AIX && HAVE_NAMELESS_LOCALES + return get_locale_t_name (category, thread_locale); +# elif defined __CYGWIN__ + /* Cygwin < 2.6 lacks uselocale and thread-local locales altogether. + Cygwin <= 2.6.1 lacks NL_LOCALE_NAME, requiring peeking inside + an opaque struct. */ +# ifdef NL_LOCALE_NAME + return nl_langinfo_l (NL_LOCALE_NAME (category), thread_locale); +# else + /* FIXME: Remove when we can assume new-enough Cygwin. */ + struct __locale_t { + char categories[7][32]; + }; + return ((struct __locale_t *) thread_locale)->categories[category]; +# endif +# elif defined __ANDROID__ + return MB_CUR_MAX == 4 ? "C.UTF-8" : "C"; +# endif + } + } +# endif + return NULL; +} + +#endif + +const char * +gl_locale_name_thread (int category, const char *categoryname) +{ +#if HAVE_GOOD_USELOCALE + const char *name = gl_locale_name_thread_unsafe (category, categoryname); + if (name != NULL) + return struniq (name); +#endif + /* On WINDOWS_NATIVE, don't use GetThreadLocale() here, because when + SetThreadLocale has not been called - which is a very frequent case - + the value of GetThreadLocale() ignores past calls to 'setlocale'. */ + return NULL; +} + +/* XPG3 defines the result of 'setlocale (category, NULL)' as: + "Directs 'setlocale()' to query 'category' and return the current + setting of 'local'." + However it does not specify the exact format. Neither do SUSV2 and + ISO C 99. So we can use this feature only on selected systems (e.g. + those using GNU C Library). */ +#if defined _LIBC || ((defined __GLIBC__ && __GLIBC__ >= 2) && !defined __UCLIBC__) +# define HAVE_LOCALE_NULL +#endif + +const char * +gl_locale_name_posix (int category, const char *categoryname) +{ +#if defined WINDOWS_NATIVE + if (LC_MIN <= category && category <= LC_MAX) + { + const char *locname = + /* setlocale_null (category) is identical to setlocale (category, NULL) + on this platform. */ + setlocale (category, NULL); + + /* Convert locale name to LCID. We don't want to use + LocaleNameToLCID because (a) it is only available since Vista, + and (b) it doesn't accept locale names returned by 'setlocale'. */ + LCID lcid = get_lcid (locname); + + if (lcid > 0) + return gl_locale_name_from_win32_LCID (lcid); + } +#endif + { + const char *locname; + + /* Use the POSIX methods of looking to 'LC_ALL', 'LC_xxx', and 'LANG'. + On some systems this can be done by the 'setlocale' function itself. */ +#if defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL + locname = setlocale_null (category); +#else + /* On other systems we ignore what setlocale reports and instead look at the + environment variables directly. This is necessary + 1. on systems which have a facility for customizing the default locale + (Mac OS X, native Windows, Cygwin) and where the system's setlocale() + function ignores this default locale (Mac OS X, Cygwin), in two cases: + a. when the user missed to use the setlocale() override from libintl + (for example by not including <libintl.h>), + b. when setlocale supports only the "C" locale, such as on Cygwin + 1.5.x. In this case even the override from libintl cannot help. + 2. on all systems where setlocale supports only the "C" locale. */ + /* Strictly speaking, it is a POSIX violation to look at the environment + variables regardless whether setlocale has been called or not. POSIX + says: + "For C-language programs, the POSIX locale shall be the + default locale when the setlocale() function is not called." + But we assume that all programs that use internationalized APIs call + setlocale (LC_ALL, ""). */ + locname = gl_locale_name_environ (category, categoryname); +#endif + /* Convert the locale name from the format returned by setlocale() or found + in the environment variables to the XPG syntax. */ +#if defined WINDOWS_NATIVE + if (locname != NULL) + { + /* Convert locale name to LCID. We don't want to use + LocaleNameToLCID because (a) it is only available since Vista, + and (b) it doesn't accept locale names returned by 'setlocale'. */ + LCID lcid = get_lcid (locname); + + if (lcid > 0) + return gl_locale_name_from_win32_LCID (lcid); + } +#endif + return locname; + } +} + +const char * +gl_locale_name_environ (int category, const char *categoryname) +{ + const char *retval; + + /* Setting of LC_ALL overrides all other. */ + retval = getenv ("LC_ALL"); + if (retval != NULL && retval[0] != '\0') + return retval; + /* Next comes the name of the desired category. */ + retval = getenv (categoryname); + if (retval != NULL && retval[0] != '\0') + return retval; + /* Last possibility is the LANG environment variable. */ + retval = getenv ("LANG"); + if (retval != NULL && retval[0] != '\0') + { +#if HAVE_CFPREFERENCESCOPYAPPVALUE + /* Mac OS X 10.2 or newer. + Ignore invalid LANG value set by the Terminal application. */ + if (strcmp (retval, "UTF-8") != 0) +#endif +#if defined __CYGWIN__ + /* Cygwin. + Ignore dummy LANG value set by ~/.profile. */ + if (strcmp (retval, "C.UTF-8") != 0) +#endif + return retval; + } + + return NULL; +} + +const char * +gl_locale_name_default (void) +{ + /* POSIX:2001 says: + "All implementations shall define a locale as the default locale, to be + invoked when no environment variables are set, or set to the empty + string. This default locale can be the POSIX locale or any other + implementation-defined locale. Some implementations may provide + facilities for local installation administrators to set the default + locale, customizing it for each location. POSIX:2001 does not require + such a facility. + + The systems with such a facility are Mac OS X and Windows: They provide a + GUI that allows the user to choose a locale. + - On Mac OS X, by default, none of LC_* or LANG are set. Starting with + Mac OS X 10.4 or 10.5, LANG is set for processes launched by the + 'Terminal' application (but sometimes to an incorrect value "UTF-8"). + When no environment variable is set, setlocale (LC_ALL, "") uses the + "C" locale. + - On native Windows, by default, none of LC_* or LANG are set. + When no environment variable is set, setlocale (LC_ALL, "") uses the + locale chosen by the user. + - On Cygwin 1.5.x, by default, none of LC_* or LANG are set. + When no environment variable is set, setlocale (LC_ALL, "") uses the + "C" locale. + - On Cygwin 1.7, by default, LANG is set to "C.UTF-8" when the default + ~/.profile is executed. + When no environment variable is set, setlocale (LC_ALL, "") uses the + "C.UTF-8" locale, which operates in the same way as the "C" locale. + */ + +#if !(HAVE_CFPREFERENCESCOPYAPPVALUE || defined WINDOWS_NATIVE || defined __CYGWIN__) + + /* The system does not have a way of setting the locale, other than the + POSIX specified environment variables. We use C as default locale. */ + return "C"; + +#else + + /* Return an XPG style locale name language[_territory][@modifier]. + Don't even bother determining the codeset; it's not useful in this + context, because message catalogs are not specific to a single + codeset. */ + +# if HAVE_CFPREFERENCESCOPYAPPVALUE + /* Mac OS X 10.4 or newer */ + /* Don't use the API introduced in Mac OS X 10.5, CFLocaleCopyCurrent, + because in macOS 10.13.4 it has the following behaviour: + When two or more languages are specified in the + "System Preferences > Language & Region > Preferred Languages" panel, + it returns en_CC where CC is the territory (even when English is not among + the preferred languages!). What we want instead is what + CFLocaleCopyCurrent returned in earlier macOS releases and what + CFPreferencesCopyAppValue still returns, namely ll_CC where ll is the + first among the preferred languages and CC is the territory. */ + { + /* Cache the locale name, since CoreFoundation calls are expensive. */ + static const char *cached_localename; + + if (cached_localename == NULL) + { + char namebuf[256]; + CFTypeRef value = + CFPreferencesCopyAppValue (CFSTR ("AppleLocale"), + kCFPreferencesCurrentApplication); + if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ()) + { + CFStringRef name = (CFStringRef)value; + + if (CFStringGetCString (name, namebuf, sizeof (namebuf), + kCFStringEncodingASCII)) + { + gl_locale_name_canonicalize (namebuf); + cached_localename = strdup (namebuf); + } + } + if (cached_localename == NULL) + cached_localename = "C"; + } + return cached_localename; + } + +# endif + +# if defined WINDOWS_NATIVE || defined __CYGWIN__ /* Native Windows or Cygwin */ + { + LCID lcid; + + /* Use native Windows API locale ID. */ + lcid = GetThreadLocale (); + + return gl_locale_name_from_win32_LCID (lcid); + } +# endif +#endif +} + +/* Determine the current locale's name, and canonicalize it into XPG syntax + language[_territory][.codeset][@modifier] + The codeset part in the result is not reliable; the locale_charset() + should be used for codeset information instead. + The result must not be freed; it is statically allocated. */ + +const char * +gl_locale_name (int category, const char *categoryname) +{ + const char *retval; + + retval = gl_locale_name_thread (category, categoryname); + if (retval != NULL) + return retval; + + retval = gl_locale_name_posix (category, categoryname); + if (retval != NULL) + return retval; + + return gl_locale_name_default (); +} diff --git a/gnulib-tests/localename.h b/gnulib-tests/localename.h new file mode 100644 index 0000000..b67f306 --- /dev/null +++ b/gnulib-tests/localename.h @@ -0,0 +1,98 @@ +/* Determine name of the currently selected locale. + Copyright (C) 2007, 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +#ifndef _GL_LOCALENAME_H +#define _GL_LOCALENAME_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Determine the current locale's name. + It considers both the POSIX notion of locale name (see functions + gl_locale_name_thread and gl_locale_name_posix) and the system notion + of locale name (see function gl_locale_name_default). + CATEGORY is a locale category abbreviation, as defined in <locale.h>, + but not LC_ALL. E.g. LC_MESSAGES. + CATEGORYNAME is the name of CATEGORY as a string, e.g. "LC_MESSAGES". + Return the locale category's name, canonicalized into XPG syntax + language[_territory][.codeset][@modifier] + The codeset part in the result is not reliable; the locale_charset() + should be used for codeset information instead. + The result must not be freed; it is statically allocated. */ +extern const char * gl_locale_name (int category, const char *categoryname); + +/* Determine the current per-thread locale's name, as specified by uselocale() + calls. + CATEGORY is a locale category abbreviation, as defined in <locale.h>, + but not LC_ALL. E.g. LC_MESSAGES. + CATEGORYNAME is the name of CATEGORY as a string, e.g. "LC_MESSAGES". + Return the locale category's name, canonicalized into XPG syntax + language[_territory][.codeset][@modifier] + or NULL if no locale has been specified for the current thread. + The codeset part in the result is not reliable; the locale_charset() + should be used for codeset information instead. + The result must not be freed; it is statically allocated. */ +extern const char * gl_locale_name_thread (int category, const char *categoryname); + +/* Determine the thread-independent current locale's name, as specified by + setlocale() calls or by environment variables. + CATEGORY is a locale category abbreviation, as defined in <locale.h>, + but not LC_ALL. E.g. LC_MESSAGES. + CATEGORYNAME is the name of CATEGORY as a string, e.g. "LC_MESSAGES". + Return the locale category's name, canonicalized into XPG syntax + language[_territory][.codeset][@modifier] + or NULL if no locale has been specified to setlocale() or by environment + variables. + The codeset part in the result is not reliable; the locale_charset() + should be used for codeset information instead. + The result must not be freed; it is statically allocated. */ +extern const char * gl_locale_name_posix (int category, const char *categoryname); + +/* Determine the default locale's name, as specified by environment + variables. + Return the locale category's name, or NULL if no locale has been specified + by environment variables. + The result must not be freed; it is statically allocated. */ +extern const char * gl_locale_name_environ (int category, const char *categoryname); + +/* Determine the default locale's name. This is the current locale's name, + if not specified by uselocale() calls, by setlocale() calls, or by + environment variables. This locale name is usually determined by systems + settings that the user can manipulate through a GUI. + + Quoting POSIX:2001: + "All implementations shall define a locale as the default locale, + to be invoked when no environment variables are set, or set to the + empty string. This default locale can be the C locale or any other + implementation-defined locale. Some implementations may provide + facilities for local installation administrators to set the default + locale, customizing it for each location. IEEE Std 1003.1-2001 does + not require such a facility." + + The result must not be freed; it is statically allocated. */ +extern const char * gl_locale_name_default (void) +#if !(HAVE_CFPREFERENCESCOPYAPPVALUE || defined _WIN32 || defined __CYGWIN__) + _GL_ATTRIBUTE_CONST +#endif + ; + +#ifdef __cplusplus +} +#endif + +#endif /* _GL_LOCALENAME_H */ diff --git a/gnulib-tests/macros.h b/gnulib-tests/macros.h new file mode 100644 index 0000000..c72cc92 --- /dev/null +++ b/gnulib-tests/macros.h @@ -0,0 +1,81 @@ +/* Common macros used by gnulib tests. + Copyright (C) 2006-2020 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 <https://www.gnu.org/licenses/>. */ + + +/* This file contains macros that are used by many gnulib tests. + Put here only frequently used macros, say, used by 10 tests or more. */ + +#include <stdio.h> +#include <stdlib.h> + +#ifndef FALLTHROUGH +# if __GNUC__ < 7 +# define FALLTHROUGH ((void) 0) +# else +# define FALLTHROUGH __attribute__ ((__fallthrough__)) +# endif +#endif + +/* Define ASSERT_STREAM before including this file if ASSERT must + target a stream other than stderr. */ +#ifndef ASSERT_STREAM +# define ASSERT_STREAM stderr +#endif + +/* ASSERT (condition); + verifies that the specified condition is fulfilled. If not, a message + is printed to ASSERT_STREAM if defined (defaulting to stderr if + undefined) and the program is terminated with an error code. + + This macro has the following properties: + - The programmer specifies the expected condition, not the failure + condition. This simplifies thinking. + - The condition is tested always, regardless of compilation flags. + (Unlike the macro from <assert.h>.) + - On Unix platforms, the tester can debug the test program with a + debugger (provided core dumps are enabled: "ulimit -c unlimited"). + - For the sake of platforms where no debugger is available (such as + some mingw systems), an error message is printed on the error + stream that includes the source location of the ASSERT invocation. + */ +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (ASSERT_STREAM, "%s:%d: assertion '%s' failed\n", \ + __FILE__, __LINE__, #expr); \ + fflush (ASSERT_STREAM); \ + abort (); \ + } \ + } \ + while (0) + +/* SIZEOF (array) + returns the number of elements of an array. It works for arrays that are + declared outside functions and for local variables of array type. It does + *not* work for function parameters of array type, because they are actually + parameters of pointer type. */ +#define SIZEOF(array) (sizeof (array) / sizeof (array[0])) + +/* STREQ (str1, str2) + Return true if two strings compare equal. */ +#define STREQ(a, b) (strcmp (a, b) == 0) + +/* Some numbers in the interval [0,1). */ +extern const float randomf[1000]; +extern const double randomd[1000]; +extern const long double randoml[1000]; diff --git a/gnulib-tests/minus-zero.h b/gnulib-tests/minus-zero.h new file mode 100644 index 0000000..df939ff --- /dev/null +++ b/gnulib-tests/minus-zero.h @@ -0,0 +1,74 @@ +/* Macros for floating-point negative zero. + Copyright (C) 2010-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Keep in sync with m4/minus-zero.m4! */ + +#include <float.h> + + +/* minus_zerof represents the value -0.0f. */ + +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0f. + ICC 10.0 has a bug when optimizing the expression -zero. + The expression -FLT_MIN * FLT_MIN does not work when cross-compiling + to PowerPC on Mac OS X 10.5. */ +#if defined __hpux || defined __sgi || defined __ICC +static float +compute_minus_zerof (void) +{ + return -FLT_MIN * FLT_MIN; +} +# define minus_zerof compute_minus_zerof () +#else +float minus_zerof = -0.0f; +#endif + + +/* minus_zerod represents the value -0.0. */ + +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. + ICC 10.0 has a bug when optimizing the expression -zero. + The expression -DBL_MIN * DBL_MIN does not work when cross-compiling + to PowerPC on Mac OS X 10.5. */ +#if defined __hpux || defined __sgi || defined __ICC +static double +compute_minus_zerod (void) +{ + return -DBL_MIN * DBL_MIN; +} +# define minus_zerod compute_minus_zerod () +#else +double minus_zerod = -0.0; +#endif + + +/* minus_zerol represents the value -0.0L. */ + +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L. + IRIX cc can't put -0.0L into .data, but can compute at runtime. + ICC 10.0 has a bug when optimizing the expression -zero. + The expression -LDBL_MIN * LDBL_MIN does not work when cross-compiling + to PowerPC on Mac OS X 10.5. */ +#if defined __hpux || defined __sgi || defined __ICC +static long double +compute_minus_zerol (void) +{ + return -LDBL_MIN * LDBL_MIN; +} +# define minus_zerol compute_minus_zerol () +#else +long double minus_zerol = -0.0L; +#endif diff --git a/gnulib-tests/nan.h b/gnulib-tests/nan.h new file mode 100644 index 0000000..ac44672 --- /dev/null +++ b/gnulib-tests/nan.h @@ -0,0 +1,85 @@ +/* Macros for not-a-number. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + + +/* IBM z/OS supports both hexadecimal and IEEE floating-point formats. The + former does not support NaN and its isnan() implementation returns zero + for all values. */ +#if defined __MVS__ && defined __IBMC__ && !defined __BFP__ +# error "NaN is not supported with IBM's hexadecimal floating-point format; please re-compile with -qfloat=ieee" +#endif + +/* NaNf () returns a 'float' not-a-number. */ + +/* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler choke + on the expression 0.0 / 0.0. The IBM XL C compiler on z/OS complains. + PGI 16.10 complains. */ +#if (defined __DECC || defined _MSC_VER \ + || (defined __MVS__ && defined __IBMC__) \ + || defined __PGI) +static float +NaNf () +{ + static float zero = 0.0f; + return zero / zero; +} +#else +# define NaNf() (0.0f / 0.0f) +#endif + + +/* NaNd () returns a 'double' not-a-number. */ + +/* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler choke + on the expression 0.0 / 0.0. The IBM XL C compiler on z/OS complains. + PGI 16.10 complains. */ +#if (defined __DECC || defined _MSC_VER \ + || (defined __MVS__ && defined __IBMC__) \ + || defined __PGI) +static double +NaNd () +{ + static double zero = 0.0; + return zero / zero; +} +#else +# define NaNd() (0.0 / 0.0) +#endif + + +/* NaNl () returns a 'long double' not-a-number. */ + +/* On Irix 6.5, gcc 3.4.3 can't compute compile-time NaN, and needs the + runtime type conversion. + The Microsoft MSVC 9 compiler chokes on the expression 0.0L / 0.0L. + The IBM XL C compiler on z/OS complains. + PGI 16.10 complains. */ +#ifdef __sgi +static long double NaNl () +{ + double zero = 0.0; + return zero / zero; +} +#elif defined _MSC_VER || (defined __MVS__ && defined __IBMC__) || defined __PGI +static long double +NaNl () +{ + static long double zero = 0.0L; + return zero / zero; +} +#else +# define NaNl() (0.0L / 0.0L) +#endif diff --git a/gnulib-tests/nap.h b/gnulib-tests/nap.h new file mode 100644 index 0000000..5dd264f --- /dev/null +++ b/gnulib-tests/nap.h @@ -0,0 +1,155 @@ +/* Assist in file system timestamp tests. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#ifndef GLTEST_NAP_H +# define GLTEST_NAP_H + +# include <limits.h> +# include <stdbool.h> + +# include <intprops.h> + +/* Name of the witness file. */ +#define TEMPFILE BASE "nap.tmp" + +/* File descriptor used for the witness file. */ +static int nap_fd = -1; + +/* Return A - B, in ns. + Return 0 if the true result would be negative. + Return INT_MAX if the true result would be greater than INT_MAX. */ +static int +diff_timespec (struct timespec a, struct timespec b) +{ + time_t as = a.tv_sec; + time_t bs = b.tv_sec; + int ans = a.tv_nsec; + int bns = b.tv_nsec; + int sdiff; + + ASSERT (0 <= ans && ans < 2000000000); + ASSERT (0 <= bns && bns < 2000000000); + + if (! (bs < as || (bs == as && bns < ans))) + return 0; + + if (INT_SUBTRACT_WRAPV (as, bs, &sdiff) + || INT_MULTIPLY_WRAPV (sdiff, 1000000000, &sdiff) + || INT_ADD_WRAPV (sdiff, ans - bns, &sdiff)) + return INT_MAX; + + return sdiff; +} + +/* If DO_WRITE, bump the modification time of the file designated by NAP_FD. + Then fetch the new STAT information of NAP_FD. */ +static void +nap_get_stat (struct stat *st, int do_write) +{ + if (do_write) + { + ASSERT (write (nap_fd, "\n", 1) == 1); +#if defined _WIN32 || defined __CYGWIN__ + /* On Windows, the modification times are not changed until NAP_FD + is closed. See + <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-writefile> */ + close (nap_fd); + nap_fd = open (TEMPFILE, O_RDWR, 0600); + ASSERT (nap_fd != -1); + lseek (nap_fd, 0, SEEK_END); +#endif + } + ASSERT (fstat (nap_fd, st) == 0); +} + +/* Given a file whose descriptor is FD, see whether delaying by DELAY + nanoseconds causes a change in a file's mtime. + OLD_ST is the file's status, recently gotten. */ +static bool +nap_works (int delay, struct stat old_st) +{ + struct stat st; + struct timespec delay_spec; + delay_spec.tv_sec = delay / 1000000000; + delay_spec.tv_nsec = delay % 1000000000; + ASSERT (nanosleep (&delay_spec, 0) == 0); + nap_get_stat (&st, 1); + + if (diff_timespec (get_stat_mtime (&st), get_stat_mtime (&old_st))) + return true; + + return false; +} + +static void +clear_temp_file (void) +{ + if (0 <= nap_fd) + { + ASSERT (close (nap_fd) != -1); + ASSERT (unlink (TEMPFILE) != -1); + } +} + +/* Sleep long enough to notice a timestamp difference on the file + system in the current directory. Use an adaptive approach, trying + to find the smallest delay which works on the current file system + to make the timestamp difference appear. Assert a maximum delay of + ~2 seconds, more precisely sum(2^n) from 0 to 30 = 2^31 - 1 = 2.1s. + Assumes that BASE is defined, and requires that the test module + depends on nanosleep. */ +static void +nap (void) +{ + struct stat old_st; + static int delay = 1; + + if (-1 == nap_fd) + { + atexit (clear_temp_file); + ASSERT ((nap_fd = creat (TEMPFILE, 0600)) != -1); + nap_get_stat (&old_st, 0); + } + else + { + ASSERT (0 <= nap_fd); + nap_get_stat (&old_st, 1); + } + + if (1 < delay) + delay = delay / 2; /* Try half of the previous delay. */ + ASSERT (0 < delay); + + for (;;) + { + if (nap_works (delay, old_st)) + return; + if (delay <= (2147483647 - 1) / 2) + { + delay = delay * 2 + 1; + continue; + } + else + break; + } + + /* Bummer: even the highest nap delay didn't work. */ + ASSERT (0); +} + +#endif /* GLTEST_NAP_H */ diff --git a/gnulib-tests/null-ptr.h b/gnulib-tests/null-ptr.h new file mode 100644 index 0000000..b978418 --- /dev/null +++ b/gnulib-tests/null-ptr.h @@ -0,0 +1,33 @@ +/* Return a NULL pointer, without letting the compiler know it. + Copyright (C) 2017-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <stdlib.h> + +/* Return NULL. + Usual compilers are not able to infer something about the return value. */ +static void * +null_ptr (void) +{ + unsigned int x = rand (); + unsigned int y = x * x; + if (y & 2) + return (void *) -1; + else + return (void *) 0; +} + +/* If you want to know why this always returns NULL, read + https://en.wikipedia.org/wiki/Quadratic_residue#Prime_power_modulus . */ diff --git a/gnulib-tests/perror.c b/gnulib-tests/perror.c new file mode 100644 index 0000000..6eb83ee --- /dev/null +++ b/gnulib-tests/perror.c @@ -0,0 +1,49 @@ +/* Print a message describing error code. + Copyright (C) 2008-2020 Free Software Foundation, Inc. + Written by Bruno Haible and Simon Josefsson. + + 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +/* Specification. */ +#include <stdio.h> + +#include <errno.h> +#include <stdlib.h> +#include <string.h> + +#include "strerror-override.h" + +/* Use the system functions, not the gnulib overrides in this file. */ +#undef fprintf + +void +perror (const char *string) +{ + char stackbuf[STACKBUF_LEN]; + int ret; + + /* Our implementation guarantees that this will be a non-empty + string, even if it returns EINVAL; and stackbuf should be sized + large enough to avoid ERANGE. */ + ret = strerror_r (errno, stackbuf, sizeof stackbuf); + if (ret == ERANGE) + abort (); + + if (string != NULL && *string != '\0') + fprintf (stderr, "%s: %s\n", string, stackbuf); + else + fprintf (stderr, "%s\n", stackbuf); +} diff --git a/gnulib-tests/randomd.c b/gnulib-tests/randomd.c new file mode 100644 index 0000000..3caa873 --- /dev/null +++ b/gnulib-tests/randomd.c @@ -0,0 +1,1028 @@ +/* Some random 'double' numbers used by gnulib tests. + Copyright (C) 2012-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +/* Specification. */ +#include "macros.h" + +/* Some numbers in the interval [0,1). */ + +const double randomd[1000] = +{ + /* Some not so random numbers at the beginning. */ + 0.0, + /* Then some numbers generated by GNU clisp. */ + 0.89255299921822260894833866359, + 0.56160033401164667976788987953, + 0.51743003502243816003616725706, + 0.78419011286685927826225711525, + 0.64400370685467819470063888148, + 0.38151255107934048933308886009, + 0.279822118770531878839000163945, + 0.51983544681375980919751125922, + 0.314601557551148376372971500376, + 0.44551938964685651088492647794, + 0.44235192503793823441729544512, + 0.0040120762636767874958681841509, + 0.57608572759464216512285032474, + 0.69151953350396585566714564265, + 0.65634190642598148152780718322, + 0.68520459394253807590733184567, + 0.60728078832107635628786818115, + 0.376679934380311318950949959986, + 0.48893422455419005003224231708, + 0.59664228319132670346209747371, + 0.70162191594290728927555900075, + 0.70981089000005327192380201706, + 0.480574069305863387682360414433, + 0.369264627455974856929910550376, + 0.42224495444170593700839286742, + 0.96974027194201320964041066537, + 0.69950081092902694549973698004, + 0.366921803754944985368022837045, + 0.19460757354611588216534077527, + 0.046437559879825520495822908204, + 0.57694149138457596563075731094, + 0.49632733844850578203860859535, + 0.80735347459453553970910033766, + 0.210271595033975357161360058967, + 0.176539870249396534142059724214, + 0.75320267419158828905982021879, + 0.09535042912249636739069790414, + 0.41433965906065337672703334968, + 0.62189345390648146852641556292, + 0.322595610794052908153116342595, + 0.173860860827838938281708881865, + 0.55258425878412963601205794028, + 0.066559056629606284504735241978, + 0.0193835990781649263368095562556, + 0.127101629778251450428653553143, + 0.9603475517586241593077319367, + 0.68429794014738591042302507235, + 0.0139808909843634026741151214975, + 0.0036035679428138856395527711611, + 0.072656401341518399752950821809, + 0.229562863635014486626281702425, + 0.88337277579960676546469424767, + 0.88850212167800818244030104263, + 0.208063225990716089095767541316, + 0.268304917462565269805874454916, + 0.3195427196271617997151392088, + 0.59101407246003811289573881403, + 0.972093867752368095080492689, + 0.409246208960242309650511849637, + 0.84250639316418167849010246997, + 0.063842712141624332977179722113, + 0.96470327141354888687046060373, + 0.43109879978424216966175314888, + 0.14551248610248934836482236208, + 0.84819094513299136408788493212, + 0.41166757935215520377191731704, + 0.96020915727830366672170130175, + 0.55313106883839046701902022583, + 0.9796595451013758579218900134, + 0.74222694300533435700276764516, + 0.117294243075539310976051880564, + 0.32216824750097146958151447387, + 0.59090211400137031908131441, + 0.116841680533127258304897076543, + 0.83595865401141052310417569507, + 0.249488155772987988074361149176, + 0.67896015287499211280971531326, + 0.72256498621401843299673078876, + 0.327315362968271601258667297595, + 0.37438214921868498405279953481, + 0.76929694812658272272027330778, + 0.44282297788821568912463681727, + 0.59517407740270913902014268964, + 0.346217547960702024419571713567, + 0.68339868731911838904373225224, + 0.057507087039986776837238366719, + 0.1189343986186977384509521024, + 0.65646666532916174831489781194, + 0.80925124288745606089697795707, + 0.61302937875769552609444313984, + 0.64367434863387777107222872563, + 0.059228300879437554416166010005, + 0.76899237494115809397158171526, + 0.335797991302131791511629123206, + 0.72923178692628392090326699514, + 0.79300056654108221012876564405, + 0.58866760551158502690719665335, + 0.65249222174748700395779659047, + 0.79573528799715877963614353006, + 0.101363067664632247385474166088, + 0.392494669960902131436398643207, + 0.37323453200630776302168616197, + 0.29857554596542776498065634631, + 0.9796202149626312305197715787, + 0.58770219934833805722677794788, + 0.126574575737099431915356308504, + 0.51086682994362911961448609847, + 0.26221303911946316754295166201, + 0.87331402410090670707406246035, + 0.08604799064198292716037672196, + 0.77880380648915901962140523059, + 0.34131646312914811415381942246, + 0.422787222735822749759714960156, + 0.16550478231620269333824890372, + 0.84087065799129220871741135711, + 0.96561976597443996963329538915, + 0.059890627133354026356081805998, + 0.09359839900604706997291172522, + 0.61463026659668017286248279853, + 0.220582135665522265733252389516, + 0.30146695094150797543070759948, + 0.406591688270652513808216198946, + 0.206959751707199812083987569348, + 0.71382992952779021033600406503, + 0.98971690700151825984363090029, + 0.86339958328134745391858859595, + 0.70037828363249257457230217791, + 0.97380974339470107231135690474, + 0.9184635965630883290893011311, + 0.418605216026507942885819265225, + 0.61793227858714759711625818653, + 0.67394880797682685081908511723, + 0.98871101941805039780826467279, + 0.65973593853137069988371349845, + 0.93348525072186907424189028727, + 0.59164378220465485142298641014, + 0.95303768733773138214124075961, + 0.88667310242538944858141870801, + 0.83785319781204861623008709825, + 0.54026788227426708201242457367, + 0.74842599257855801522259951132, + 0.286624102305531463268442510375, + 0.41180484980938874161376712508, + 0.22754664620316922947541651384, + 0.62360609793949755240041318939, + 0.3311618194042077047850111557, + 0.315407885695867020730009836503, + 0.215221706711430951961780213436, + 0.168600630933631406101821024413, + 0.62661489373200405241464923618, + 0.95357070304277219756741072036, + 0.5186418766697788447635039428, + 0.70772930521061953327927296944, + 0.410376884797056150221504703145, + 0.39705302343406249619577860633, + 0.79215885822696034431481699125, + 0.157831717946112504384603002152, + 0.26892306298536012837855426922, + 0.15697088614321016223211167568, + 0.41395315712905823355235182393, + 0.043977876945327860015049914653, + 0.91453495544799358550673657283, + 0.46230093259088633973148827911, + 0.79479146768024434444120965094, + 0.1466704986407674407377422815, + 0.093614591443204076599999803382, + 0.66061870961706149406527099303, + 0.087462146328394574476138187113, + 0.79683664444310818297700615557, + 0.39732728185755441060070738751, + 0.141934473990413594291362391075, + 0.63111751995951919258061547632, + 0.78521985432793823024330967029, + 0.53307346282606806792796696141, + 0.61679109370763781010143645189, + 0.40696293619387120891515025426, + 0.68670343879278712242412028794, + 0.0115112936831136012901340526452, + 0.70866056737692430987650236649, + 0.75378980574358943122474800795, + 0.17133202766710894969283150847, + 0.36771201738922655520549864974, + 0.64614182581953931840374311331, + 0.354495602088990708111406368474, + 0.96418771817934443444348833491, + 0.51633426669933834634574104246, + 0.064671329812306055349433587193, + 0.084335079914541732137341401384, + 0.98578018340150609333535890283, + 0.32988119060114570391488875477, + 0.70568290443337103364762141207, + 0.7501960060851696034137148851, + 0.141312840936106004164373056114, + 0.60721022154106372815080238296, + 0.49179275887283771965744826261, + 0.85530668893284708999269819019, + 0.09730053915339358769067661488, + 0.48817911888023094845428570434, + 0.37116312252354470380676793579, + 0.61870369881699387959990992873, + 0.381874188039839457469043174076, + 0.68193837613090719561872304949, + 0.4773618313988618747215621251, + 0.152383599292709764750406667286, + 0.54317522808228983459963725598, + 0.363848788591302782268887022354, + 0.0105589810271147011378412305973, + 0.55582445068669939957392951111, + 0.99910376130213936748996659383, + 0.90286867348280161480903197439, + 0.48268382934936288156485037692, + 0.0976084557356802030533675394, + 0.29004949962481398455881920169, + 0.99169758897256717005011514856, + 0.20722895154834288274430061308, + 0.50294863638464584121275744208, + 0.71094033855350495714847377558, + 0.94078709219520224551350834268, + 0.48088262771516317628650315489, + 0.80538698628980761175811796611, + 0.83495029615293903361580945571, + 0.67996381940825251937974905761, + 0.57936805772275234468590364926, + 0.41778137764942046281708286844, + 0.161602687591454506771276482303, + 0.093910625156097743113739432334, + 0.45716763620641108625606409874, + 0.96455075374827233820027584808, + 0.5179966880512917274934448216, + 0.046797382046060065926143985952, + 0.83673567319931334127111064225, + 0.44224504444533247245974476514, + 0.73281179385894336737033582786, + 0.5642490153724193432309549673, + 0.83700200507325250303481208805, + 0.152714941779871552944298597052, + 0.38606607994977770238226473985, + 0.0155140917516105439042442246577, + 0.51621537013393688713546096688, + 0.311969390991657895966526156064, + 0.83890647777450698803932943984, + 0.54370750820133482930695388638, + 0.98636765788772465929756760473, + 0.77334255661128878905675504339, + 0.57070354296508751519811368688, + 0.8365252076669013372866223481, + 0.344601601940890721182485798794, + 0.92658930620470543221158939208, + 0.72724523363899270076210273102, + 0.413672082025645586061788451734, + 0.5132836422023222169840403333, + 0.82135610583961360173883281975, + 0.423835065039748889417547786563, + 0.87083598844595488941471761572, + 0.59009392451459866513886634656, + 0.206124826643305920436961792363, + 0.288685540685143988030522421633, + 0.7944357933456167153993184889, + 0.090945230657758780394996530608, + 0.52981750421369669363095418817, + 0.091368944984485824360107751981, + 0.81824925769562351657564377069, + 0.083315412912658535228751011063, + 0.59602276778799576464600065047, + 0.52258035262146456789454411102, + 0.394692074165738897132014378974, + 0.92031214264405188928824363967, + 0.32812665356161216265971156268, + 0.79754299890007289545033977389, + 0.3029021512227565310021437326, + 0.81425785760698537744367921928, + 0.85199399843570233736733560413, + 0.096629890212080240754541391968, + 0.60643798959967098211181910285, + 0.75368518979236587723780129098, + 0.451368813651510369666120626045, + 0.86189868235067352904955566961, + 0.239506411296874624231401913963, + 0.143392266376287906568670938457, + 0.035585084401323981008798496622, + 0.89407531932950775763701297226, + 0.56699767164913732414312190205, + 0.6107715946195223295493238966, + 0.980870588312723808697191463, + 0.37603666613089681502774907483, + 0.19565477083291620146833762404, + 0.70326913680165706368122461762, + 0.98247770640436619202690080984, + 0.54911931698472764719220618506, + 0.96749331150477343995263612791, + 0.9349501605275792139661332597, + 0.067704019779021886031495084945, + 0.52883185005352261786874768842, + 0.03879817199556086106868125058, + 0.011268895714104342862021635882, + 0.86781395233112768504418642287, + 0.73610697666830606371057497872, + 0.22595829849389174304359852447, + 0.95990840938724981323147621815, + 0.5938079875208820675776232526, + 0.78655922365792476391655372464, + 0.51099073264725007373467108776, + 0.66474884887866769539664215292, + 0.88640025828226102852258218854, + 0.39889893489572927635368967129, + 0.76340426725003756852384366924, + 0.485534753598641026618647825146, + 0.55957578573824837450384728978, + 0.50840543283094885180866842941, + 0.0102415845792896532313226969615, + 0.74666891036262398733922051708, + 0.49044748088989431070743849791, + 0.184017043174756439606592004597, + 0.0225210121470402648790231578307, + 0.096909683465740960387467976065, + 0.0521874432095560437920256545446, + 0.108114343037383115951564617563, + 0.77430486784405922952977031491, + 0.73286432949907824441702845144, + 0.083559249182272369453587951223, + 0.074541345541671560054508020717, + 0.55130541064331728019681677403, + 0.101450912226971008587146654246, + 0.74564503962660370005995595861, + 0.55903832180264925580029280922, + 0.86098138284846671753408133719, + 0.76146956314354797691373262733, + 0.5569854467166466965564479865, + 0.61138555623626762560168304163, + 0.93778268377974305185411499629, + 0.106728342608615813606903105742, + 0.51139895550624845300079248199, + 0.8826404150665399364200384063, + 0.79849755952621824621632991954, + 0.60058338183244813128378689372, + 0.57271235605091257806409062354, + 0.134476676178095582804914204515, + 0.62710051406343298533266304307, + 0.21517566131268423511744492316, + 0.87763268502269127056352092234, + 0.259516013975152388767641295316, + 0.54026961752737864438921779715, + 0.0321012344232942464157113655476, + 0.047765687217921465801489989111, + 0.17851281529041807770891682623, + 0.67864372391481596436180177405, + 0.27188630999531652193578141334, + 0.76570352378902765382129471855, + 0.55727605717645959087760838806, + 0.40035295538031700787360193533, + 0.65772683660586524086245866733, + 0.87515739410383285146563935658, + 0.51637173718066431535845791928, + 0.32843440805452173782945632394, + 0.46789250836790673252530282969, + 0.153916136058705475580104911632, + 0.38115724589238346986896925035, + 0.96911901452270741576104655076, + 0.327510878721849788805057952285, + 0.52921188196053063832762822112, + 0.357891066893689952162669812174, + 0.8109495999496825638917226258, + 0.87378695338223548954000159812, + 0.071735687760291841872657613394, + 0.22099818521305441851106524174, + 0.61319403424123059973018445501, + 0.49185069904977836269777464774, + 0.8465618819298531473261910176, + 0.88263955123256235889766657732, + 0.264605739218701311737446373095, + 0.157257748694727606809000832224, + 0.61172692557424578980817509135, + 0.89224381101792427145783648267, + 0.049436313890546252030141534714, + 0.78472068655126867546237630366, + 0.94890896727672958163705440614, + 0.61244719025309458330037069759, + 0.69652639673616920270100103049, + 0.82306805868313923466426022855, + 0.4619352653236511042512479492, + 0.248913888569715263431474781448, + 0.64972077945521993267494748532, + 0.058989138867897862567374093665, + 0.97969837050674699927934092348, + 0.112860503606029382332397067852, + 0.9148268966080465389473749031, + 0.80522292073416096202056634334, + 0.80810563925192214527344776336, + 0.082994810842601316055993203972, + 0.58154183958194788097113770541, + 0.91401321304178026032151961143, + 0.064162440925738934087179609749, + 0.15233762499249088696399602351, + 0.05051666992337641462246832006, + 0.138526581114846840617440323377, + 0.3330645447918149831766264793, + 0.217487368997014213919568641696, + 0.61893770768550649722673903221, + 0.48128956859001312165262121487, + 0.67074178502738313699688470847, + 0.74389636308055141796746779725, + 0.78623735396470085242463142878, + 0.74044466560335570728816983391, + 0.44977042205766449238521848558, + 0.04936658918716696558210777333, + 0.46898154881467544198433735515, + 0.86577421926732888331279455256, + 0.351697801257336354285066689416, + 0.44607679846684358775746123434, + 0.68542184287580537292736482205, + 0.044146424753083577398366558491, + 0.84496717026871403905274974765, + 0.20398318496314438897842101827, + 0.75107700174605698650069666924, + 0.178571061661964354577482608798, + 0.67178502534981979941629966218, + 0.90847842600882488644789391115, + 0.073076683947302775918335357377, + 0.33981323802799502107773228774, + 0.88205531070102240708858032672, + 0.52395959911163033140017417074, + 0.339537812421755656306362620887, + 0.54102447887624739438002987695, + 0.99615637434542139613844677579, + 0.91178029521112995461052949527, + 0.75825739605806537625994927603, + 0.20376049709427102495755901889, + 0.414724980644126108685694310425, + 0.33340705339227162790042902392, + 0.63442350111338002489027718102, + 0.79083735924049231993808201264, + 0.7022290803727963570326957922, + 0.073051026670174816217706335151, + 0.50842348505687696224462184336, + 0.32363091931107924009593033016, + 0.097074638787613630803324174721, + 0.79231345620836950165162896374, + 0.46134517653790366185204412042, + 0.87767180094474465071641454817, + 0.30504377737897498569142680272, + 0.96430402804903305707372788262, + 0.58722709934909516402891605024, + 0.36287829330987989626587492725, + 0.341369045118572012709880807167, + 0.18622546427505557603629823709, + 0.71794779555885705340742601105, + 0.098775720656078510422828040021, + 0.94170390436210924588938028149, + 0.6256516749208606216856038288, + 0.84990648194056707180867958453, + 0.24897158268824763099382644974, + 0.67126976686560821454618204853, + 0.18287142221906188751198231263, + 0.58301735289988287890086250316, + 0.39451451502323596545833498888, + 0.64778726863510310777659172018, + 0.344060647976610102257104623935, + 0.8543225374577925606075052273, + 0.41721025737118350088955048104, + 0.346301150923723212219486824146, + 0.430145349151890094004681136873, + 0.083653676599147505357408467754, + 0.89927285917733406113015320169, + 0.87717630249665962395834008139, + 0.114609060439245285884826496387, + 0.19079403943711412757743782207, + 0.095752662525740063245815699042, + 0.79249438764728213221559489213, + 0.36889557473162465630046043798, + 0.076691690566591062968137595944, + 0.82502767429905549906741868154, + 0.7665582347663079379259164121, + 0.40329445688627141530172819257, + 0.76025417855373928649612014969, + 0.67742016809536470259225177395, + 0.56458198627250149175789836481, + 0.78923506303765674533158921804, + 0.242546191857944356752822856477, + 0.5429792204847717222270173404, + 0.7269010821579782458839227112, + 0.68884017933657182784660476876, + 0.037868346502260087811459749823, + 0.5900507745679403546108564628, + 0.2867946536016681954708929644, + 0.47061390957475445523849010039, + 0.51289737877965767076806069599, + 0.422963220866519099525024712084, + 0.056516063514784913538055836342, + 0.77559606292381102490968685122, + 0.44812023547000818124896526252, + 0.8496368064876247362896528731, + 0.272242276648834925536741986616, + 0.21366791927514210787832263868, + 0.458126557153035507756298880855, + 0.59095285049337797286946531198, + 0.41387171106200290943847880691, + 0.040527832792286543640976926214, + 0.84749051864346812142321430329, + 0.6591922374100337646083630177, + 0.30504037894556796180304594549, + 0.69588062596190762407598122745, + 0.54615362946297678668402889519, + 0.27179536774730804380125320985, + 0.16312965572910266758089041195, + 0.60443803311418335000528681396, + 0.76221957063947757300487766314, + 0.0012561481228798307955579245318, + 0.38477311712200424042679172286, + 0.86336953839931184684851388121, + 0.85132017314817690655384788334, + 0.79741410166633177181313320738, + 0.81142674213295830272567127246, + 0.90095974521916505411272740187, + 0.461262866736651478343958282766, + 0.163149749038393754125992055513, + 0.079563568933303239293664877234, + 0.0076308467066608702534098522771, + 0.74020408989686798939059759005, + 0.68004244363120265645245845544, + 0.99423282025586676895879517721, + 0.256512790150101579655974619204, + 0.15841489307390214447222985222, + 0.53156533193583516285295078457, + 0.51195175518666885397864463638, + 0.2688502522458221215136352473, + 0.290743998007688539265414246556, + 0.375642431327791011131765421904, + 0.73366824563603699669790620984, + 0.89031055476039433366324605036, + 0.63269458446317741594059410575, + 0.79677646360837164675956632, + 0.91096051787867659208019728176, + 0.056411022047894420770349313174, + 0.7117937367428418076554349793, + 0.494496454398059649677550547185, + 0.9944698091905991687808626336, + 0.195654008095567563746040882677, + 0.33245249703376584453346565181, + 0.91671965905832444523554539619, + 0.104159073216349402499760928077, + 0.78250381705179599027513221262, + 0.82221952254403323129879405024, + 0.25404653774104883427079980313, + 0.89334850648967094099280368977, + 0.2721479244387740074938025269, + 0.58627710421889854554604323774, + 0.80740872172002770008164688167, + 0.295213737773499230779293451686, + 0.366266263469556210902410635735, + 0.72189449997560167388059780325, + 0.91339160960295327548014703572, + 0.27978723834100283634925494393, + 0.44312275285067091147157546317, + 0.88264479919648468925459438057, + 0.74860386620420068665117140949, + 0.97534502025842784289380076051, + 0.183653687608870314454061893335, + 0.14143760686328530307343938507, + 0.7794390875763962068165432699, + 0.79988123088296718350409621263, + 0.91344402454829897860268279997, + 0.3003753710559256572305330721, + 0.92236868180619898327118824659, + 0.85128995509445007265453349716, + 0.51226586850988855988005111668, + 0.59328586801467434659081264762, + 0.131543061349700789237108200816, + 0.97962864281984756641024957818, + 0.80003961712390827564285728721, + 0.07332191035039234849987853587, + 0.33710892945255754021249327366, + 0.237798240512212115424045579506, + 0.050628096786899757905464602857, + 0.36368141580193860149061967396, + 0.074547282281222729072803274018, + 0.32013351651022219595136046535, + 0.50087363542319392259892635316, + 0.95534128322832584718763016378, + 0.63089810554419660091974256912, + 0.45937043591639452731937380837, + 0.77794827072126710252068287081, + 0.5833967217973934570703322242, + 0.89948711130168823436943591707, + 0.88448792344727137087709578749, + 0.75774410588649351850782212564, + 0.51545850808454807305763364038, + 0.89535564141616759448334976604, + 0.433876155086630438489414332084, + 0.263145194001722566517185175524, + 0.094513715303174637696079970882, + 0.0067905149976316075236601623182, + 0.3746548325271489972742277758, + 0.81418012245523025207375976459, + 0.7382555515800124086679648947, + 0.71505454385778976492869269043, + 0.7698698840252614242858413632, + 0.53096667868591647121855295207, + 0.5913146508318579789498085478, + 0.82865413011200335887487636747, + 0.246477924915753655378269255135, + 0.7718625116939460952174295485, + 0.33088224685104582360581424038, + 0.077396220323469426942810035952, + 0.399851739373243384531661374094, + 0.74828949567652386217126904324, + 0.55533476993642340021791702209, + 0.475356366587838670689554086714, + 0.99199926249299355831492581518, + 0.60739053074816626181185925167, + 0.94570422855790142383862352906, + 0.67410117583869264525962136333, + 0.99340016295179621471645098914, + 0.30521664837678549625426072163, + 0.82786899862234431119578444516, + 0.0246054418785779831964997687095, + 0.33057040500642957115284791089, + 0.325865542252271051046671982904, + 0.116469964535698881624567000313, + 0.38792519202192930208550481713, + 0.147033252049062199325747990948, + 0.333360890210745561370686771174, + 0.267717098935309378552279527125, + 0.473606191830554736751491306975, + 0.69379726024488030302072707274, + 0.39866105325920152799379542147, + 0.075996151521605600512218326895, + 0.43692155239290098173990417979, + 0.63183509185797834489905365016, + 0.327726835190132824885685947736, + 0.82769389015654780671213364517, + 0.38036542617183448008870457384, + 0.06416363778906221378580326597, + 0.95989693996326393340364540321, + 0.77473792948077472252492320019, + 0.73353080354752465520384745159, + 0.79531316211939777703706647305, + 0.31887745411495362933791547194, + 0.5504233366621661345254817397, + 0.133841546560512334978343647306, + 0.93323316393590598213508657757, + 0.219534116905903225236593922786, + 0.352227557302752346568799070044, + 0.50699048681296139093781410327, + 0.56063256677949754339755086295, + 0.97859418495668224120337606178, + 0.43217748779939454097021337034, + 0.6118800794139137562939270606, + 0.8826339041571606455078384688, + 0.190654349423411314990846249777, + 0.0272323818569649486990095499454, + 0.13501820915175992368033644254, + 0.34430252524220055863712676536, + 0.135013324503164182485257894453, + 0.83301344777287732687815180326, + 0.71146270180847724757833953093, + 0.059584725284656364940760846576, + 0.124388342467555907606115942139, + 0.86760011350010388002288781466, + 0.43443235444248399222879725088, + 0.62257025564267773540408523682, + 0.42224480338939459869117553607, + 0.122203729563367693705179104655, + 0.86763329805228175173701751082, + 0.61852711996472568821866689006, + 0.9981036801779161471700405786, + 0.177126618334123901292041594724, + 0.37033568941002233661950847289, + 0.81720705981865203019383851894, + 0.194752883553301253160228353622, + 0.5399475493930702257701115294, + 0.21555050095259535717046390477, + 0.031480898918419061738395489394, + 0.0108626235742996694506893658131, + 0.29439861659506237876675916168, + 0.25969803792963051605662393213, + 0.64305111681301349941082616522, + 0.398301763391130971280749586885, + 0.82959279528518208376169366062, + 0.494452121232255582677051524076, + 0.032046850110252624668328949032, + 0.304808216164121089322038632124, + 0.43743086801077933536332835933, + 0.067635143022119684849606244687, + 0.062601171413915686472972559687, + 0.80704249768256597155262089974, + 0.049090587901867220876053770281, + 0.14290280489067737067786839775, + 0.85153414385190808252068833198, + 0.052035578866778404379096518691, + 0.84803461110488710482683367176, + 0.323391780352303842858779454674, + 0.52713499343541339922976296515, + 0.91034109375479019837692785976, + 0.106146556890642346491650008212, + 0.291532189474064930184344798145, + 0.330494959183718721493342551525, + 0.6236537208920888603043773443, + 0.89122121355780761549659392994, + 0.51799810738861013193016943087, + 0.249256177739037963581221438965, + 0.76322106809612787470242640888, + 0.97852511972383831461233976406, + 0.52255677693690499607690355455, + 0.4450034860583097087122794844, + 0.79114162250324775713725095404, + 0.94756217345536380876998110362, + 0.58677918818329126036021764787, + 0.84845252924877884299669190981, + 0.30081720041370757827674016113, + 0.27920525653128846538023076229, + 0.33471466998109052439193176801, + 0.77432114969973711331784009482, + 0.79975078898170550460312445454, + 0.90029380309155505829673878957, + 0.22735855793472972935624370264, + 0.83917898101167717908999667914, + 0.96001063929762371813642857618, + 0.80557845129235602137075744771, + 0.227828260252387705994553631692, + 0.45514459312672738783331856798, + 0.6996049090759249573037751274, + 0.76407211467383802388153449844, + 0.35750763601712374361686514082, + 0.090157662209549066428683554241, + 0.95043897530001474792481472865, + 0.97262166470012788338731033975, + 0.203045895422423613196589718133, + 0.217437635156560627036179586425, + 0.5222956932204809424910993278, + 0.52865060708104384493756729767, + 0.97715373213739469800445297208, + 0.5740174414400501666597490431, + 0.172348314420047937640907870932, + 0.57197038071649167881433868039, + 0.26289948915209002196358225729, + 0.177903112174726341611524884074, + 0.74917239660013094610681443816, + 0.59837085384984040836442442706, + 0.065070324689375259831989322427, + 0.44807493892928848916566949155, + 0.59027783360778386064107723777, + 0.122058971772529617939528531479, + 0.18965096763129552013799044806, + 0.179455202785822708296801760066, + 0.032170979041981235014758366854, + 0.297222966386620738492021519056, + 0.91323423393143490893801153646, + 0.75998869946268189685327906564, + 0.83934073246383862944110864099, + 0.17898779712956184324621175982, + 0.480986398855505957279379560397, + 0.60860751560721289727164165043, + 0.298927282590269088379100218673, + 0.77935020447343759584143119835, + 0.480545242963934573648858250607, + 0.85619790637736236353631524289, + 0.96488893882602300700764346564, + 0.36351865634843046736230405883, + 0.82895257550724293657223335349, + 0.79749691055514662573933190753, + 0.20106705267868388883102752272, + 0.33623918491977977623116871123, + 0.93256466340279772952587363977, + 0.88648669501682764515636262464, + 0.47662235152771500250187825963, + 0.52659238455883068245922982067, + 0.94111676559395948458425469814, + 0.323317713690175795284098362026, + 0.34796405933091263994264450729, + 0.52445433363119391822452105405, + 0.525140277317638922334264421, + 0.64469482443585357444532895759, + 0.33472685924872903603447879104, + 0.42400458791646499703641118014, + 0.8222662798441265944554029489, + 0.75524567154228028735673060411, + 0.90790601849806560799894333131, + 0.75164241313793249434488428193, + 0.38724602290468111557712203885, + 0.36352513950081020449187506395, + 0.078398790907179055722325452963, + 0.5003676822199407758422514133, + 0.86055044548361328714384972985, + 0.66748567445598821900669819042, + 0.95450644393912187127659765969, + 0.9536501355878008523425355652, + 0.56207573012593503802043957099, + 0.99057795680550440527031916411, + 0.056136908924222021770088579728, + 0.89322960593560085272815946927, + 0.19380351076299398770342941398, + 0.036881975481577328074706357897, + 0.38834900979665334617449710449, + 0.77196507761008668275581490587, + 0.87539115393397618421355963533, + 0.9131721846286054396553858461, + 0.62245648254908013430163665866, + 0.56021174819199355559539089633, + 0.86987294559046384230921358438, + 0.474584307464076041054198211805, + 0.37224942408757353492416873571, + 0.198307276357215222087716993615, + 0.81633548414328354008913860616, + 0.071192681637945014051745371309, + 0.227203421058334439883665388655, + 0.50527083273847576806586104904, + 0.25911353175247232791676189983, + 0.103567996992606824957067451526, + 0.98316826751311017109085781757, + 0.99206610065531611133123425907, + 0.63838444880264351660305680771, + 0.90013304139719692321619239255, + 0.541419881593941428911392944, + 0.434681681520065487913409442927, + 0.0277935905905462584654818408167, + 0.28736085880215502013374946299, + 0.204706679291990486471085620508, + 0.29639415300325412139805373353, + 0.316818074164048785111401123944, + 0.58068268044073033182148412246, + 0.137736206950094621238996907006, + 0.80907996549523150166492783923, + 0.73799561611209772635015717353, + 0.84013433924397440368969968592, + 0.46126521311414726401422152854, + 0.78013716447507497359555980298, + 0.83405708922951231042933175851, + 0.6366367969739079258896472192, + 0.77353748358406402598000037557, + 0.17489624725635947111471117775, + 0.80267952648428412026314875447, + 0.80437106861315296029137160672, + 0.62834462177566783487584779777, + 0.31539602345858033626133832055, + 0.50541890853061839219557074283, + 0.0195874476781850222509795360627, + 0.011676447193909007242643314705, + 0.85675479754070644130150816794, + 0.09391269154749661204040398199, + 0.369625667102334643216258483376, + 0.84311577046357953313746551837, + 0.66438426715728382263582851036, + 0.70530906415261448155650458603, + 0.446783684004800041373395690117, + 0.75627790284213576819810990131, + 0.57190285913753158265774292274, + 0.97785681370875218892539297465, + 0.0244503386494348881614690746194, + 0.48528430854909558202793141933, + 0.89436155397807056672243211894, + 0.40757489194485346255194449191, + 0.91772837786834838909335779229, + 0.28020326531649972709359017096, + 0.28847822326776188982020803144, + 0.93193769743225684077624356649, + 0.58336147304815741644785105161, + 0.4004241800179331174134885947, + 0.265790823692672203607418801725, + 0.4137092141145146388568879939, + 0.0255090449126572366852573357318, + 0.47601725598948555645487446626, + 0.69141516452580797436419291497, + 0.187709862166242786826507443003, + 0.31177816288567708916778389045, + 0.79635247302484103596788484137, + 0.14648403361265752358955335086, + 0.0088027047060531475573345163528, + 0.90053967411241805345616039474, + 0.373822238382428585287035417224, + 0.94303097002109978273901800507, + 0.037263906643698883423150604649, + 0.98416823398276433881119247311, + 0.257766562836474661728601317803, + 0.09336855716941364387765222813, + 0.057604551843195630210060755775, + 0.37732024813036636644231432449, + 0.437099108019093398068604946814, + 0.0298274889889844501626534131975, + 0.54161045457572229928359302347, + 0.354192069739745951755754451894, + 0.9952629304832433588789284291, + 0.61362350596285189174752077338, + 0.23176197923774029736185020682, + 0.259000332877923815426717028414, + 0.77171708810079063604185854121, + 0.87278431247491539306511051532, + 0.386310463821549823085972724515, + 0.19043920209178263945663905422, + 0.77200547833114724875436606573, + 0.2683024354984293205497398925, + 0.144270112550972640008446091075, + 0.36996280314557984925474224612, + 0.163548224543250866742712583905, + 0.54541238293503241055380526708, + 0.54270760938500008382580072956, + 0.7374073253240524865446763851, + 0.93470960326436177572863031654, + 0.71417607213823278615975270201, + 0.65837463356664939532769528292, + 0.433323451649582925271830911365, + 0.79664580661766246494864588315, + 0.392079017934601610514677836005, + 0.212454387416532999103471570235, + 0.198678082418012501322802116335, + 0.61525672800559338657275986197, + 0.99339589895181138684928419014, + 0.53563057949945927383392076793, + 0.68817192513245948798192690082, + 0.59671938169380086666866042956, + 0.5686075254645125832635026196, + 0.25860953535454698758704936914, + 0.60779864941995215785819783969, + 0.46515241662568547274625942204, + 0.8756966078479474164213834749, + 0.89153160343113076353740745469, + 0.57055911159151577684982200009, + 0.39366246576557783924065683256, + 0.53789676931469921495851209609, + 0.95842028586447684249630374944, + 0.25218284880717367924827402845, + 0.23718965807272971860203662735, + 0.334222632819004380754702693406, + 0.6370849366068287810411454729, + 0.722665796162802454203702773, + 0.50216248905279887048328225791, + 0.34529823309520970630714708672, + 0.45098892404492692601908443802, + 0.64640019115293913591196874603, + 0.137077316379736192931987264458, + 0.29368115076039970149731521521, + 0.20091822953913855557804069085, + 0.066267083813833718511605782276, + 0.88094596104423280074202839474, + 0.071730322265966936504743175424, + 0.69735904142296779896396736035, + 0.91352594564083795862432502567, + 0.13244220377041278512040316988, + 0.6283911312781029516331064494, + 0.34896540167805105781090114462, + 0.6795367801751911186206756471, + 0.74898526486791573083377925403, + 0.71700182398199203349731046015, + 0.121142833366516620257163901501, + 0.32678002036857151533698078636, + 0.327511655875027224450064555456, + 0.0079152053645354575349489795814, + 0.84748954479623021059675156738, + 0.75041561033954009809301550159, + 0.41101693712463238996746228193, + 0.90155864029338267639417046915, + 0.35464670537047753945618208157, + 0.68848712573944472430623590326, + 0.08893193373618063124738179594, + 0.58932830480784385636485098641, + 0.0501618828375381577588978271165, + 0.9451968329901169788400753848, + 0.074994725566097580721185016702, + 0.191860088196691871607965261685, + 0.67853841063536805868885844477, + 0.179445375284033906887325905976, + 0.84157620913886056000430779083, + 0.7377942162322144186341324232, + 0.231126715579023126062082806996, + 0.127662509645324778320005407937, + 0.63062414859560283674777403205, + 0.55283326072907470543330204975, + 0.81243486031688046850257374808, + 0.299095175225750536694802628506, + 0.34284433830834748530634854762, + 0.92098838107935607957057329632, + 0.6334432153537539286206936299, + 0.49203336326915182548719200464, + 0.70089872986754081776092540042, + 0.410346112246289262244008861334, + 0.689375704219352519232614571, + 0.53543492718830214408075484368, + 0.78985504761729292283075540625, + 0.66802245726332267870092702429, + 0.75600588548341120124374250114, + 0.83217485519464083512235296359, + 0.77758150309412736979136465746, + 0.067382141804836913185384124002, + 0.7289836962356747770023887674, + 0.453434776313686590560640460504, + 0.3160796148757468204057886796, + 0.0098933475787107681104048511314, + 0.3620064234142809735084479026, + 0.85993179373877360456391909506, + 0.90684883450763884954227285187, + 0.75959171037325548903969803948, + 0.91219881792279148536349496306, + 0.97175430264940118917041244436, + 0.292364544897748356834218017667, + 0.126096590956329503351026499397, + 0.058210669685805595156500555938, + 0.207143479048534791976348255132, + 0.202837039257860939456824357966, + 0.459137240079351948795601640776, + 0.65480905235794807223708347609 +}; diff --git a/gnulib-tests/randoml.c b/gnulib-tests/randoml.c new file mode 100644 index 0000000..c4cbaf8 --- /dev/null +++ b/gnulib-tests/randoml.c @@ -0,0 +1,1028 @@ +/* Some random 'long double' numbers used by gnulib tests. + Copyright (C) 2012-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +/* Specification. */ +#include "macros.h" + +/* Some numbers in the interval [0,1). */ + +const long double randoml[1000] = +{ + /* Some not so random numbers at the beginning. */ + 0.0L, + /* Then some numbers generated by GNU clisp. */ + 0.709874756135422554674614242046304686448L, + 0.486497838502717923110029188864352615388L, + 0.474019570990182753146861083750226106848L, + 0.998821069612940336401792152067298257397L, + 0.68230324395444341476284133813649237509L, + 0.0812383212795450007980350531141537177532L, + 0.43131112016001535977175708439191217567L, + 0.1596337172541222285215378906083607753005L, + 0.0447361192177328171952931546845870270203L, + 0.669148550486018286115665314826153614017L, + 0.398752708644620313955955676251505325896L, + 0.600019492390024166744893736290881101244L, + 0.78337397012688890834008412364808365851L, + 0.747414410152603863408503379239564644402L, + 0.550615721371501982864462175362996180322L, + 0.0073983673767251687422683917248311760491L, + 0.693846360902780799478892082407382699085L, + 0.751592057901191172906159475240427353057L, + 0.74000578784995401707243054106755282117L, + 0.847264623235961908747497547605068838836L, + 0.917431426585209425652777605148791919017L, + 0.267532476015101748449269162884835638528L, + 0.486834088208986505203048715784492259319L, + 0.4580154564181484580770749178538567666L, + 0.391521076582874764982597286237947922907L, + 0.69173131929214083677828129436922728366L, + 0.995268639187054867212755710743514657877L, + 0.553189251912843822062196619876802699895L, + 0.632300552505301947698796653386744186037L, + 0.445572801006840927064646197943103543344L, + 0.993634311396905276414701816228609517838L, + 0.611582274481091436495638926486363711255L, + 0.017611091105275929341544154464243038417L, + 0.598936378040443270534796418637146416803L, + 0.939730325871014729497001074244817030738L, + 0.385712528561693907444911228190200940125L, + 0.48796444333495738271693214259711532603L, + 0.508634972895891442259656591497940133962L, + 0.88453398179301716552318999435310293852L, + 0.509099535482633468613040057130206639612L, + 0.333677997666677081186230843198919594355L, + 0.82715349353996770180499230535973424237L, + 0.0372593663309767971914036990047894757662L, + 0.932828780275931267421133064996449298348L, + 0.486099261359133830842098860485004683725L, + 0.987156392631551825781809767746170502002L, + 0.824739790678073493124786291053674093535L, + 0.671869573118280976952523743592826377585L, + 0.48088844444394888967684860088619551899L, + 0.017233021606613044454327510797750273989L, + 0.988102711714879869326666071903065279145L, + 0.091615081537455465573860363408517029583L, + 0.0113278995312253231106729997476313183323L, + 0.294349528513080028346115860151112891433L, + 0.0097058790914280197566968241982258935964L, + 0.715113281550035710673074854712220192465L, + 0.739627170474553083453358265804562580162L, + 0.588476045636558489860462119645353521893L, + 0.91330346819098343970944232526748274664L, + 0.281457572112513183673653575304242456425L, + 0.784192391468991402261628322552430383283L, + 0.504857923842698553133786835061714061812L, + 0.230410937725986177704701374433825197397L, + 0.535805811877939822805608704986961969659L, + 0.0508287955596506952822240797812703550548L, + 0.179399756999629053194209501169297540332L, + 0.675837373242984020977236431747771655704L, + 0.981496523455084073391380532008173135055L, + 0.325845075647804753424852268729037997407L, + 0.832630951427200447589084239299500129776L, + 0.825354056334755646582091209610369762364L, + 0.574731012869980895104127749738122205757L, + 0.799028354294603017571131513193291020045L, + 0.537721586879667191016369071169775496218L, + 0.83846801885738807298552515294277869191L, + 0.0922901597877978587435698953162723703674L, + 0.434458505758559675954739433438496373717L, + 0.308017320632506922735963882703835222897L, + 0.0192693232310748837390370764187488626234L, + 0.65275462537999797862908920689650691667L, + 0.357130585286320841741290333260811815153L, + 0.359562085720204868627653630044659240449L, + 0.758320826841831017712067337815543048118L, + 0.62169722559489484088614873429559348682L, + 0.17335411409874538731529771306978631118L, + 0.154077331752487118534287271363344964006L, + 0.148559174998934930922746358844164455867L, + 0.881316225913391098839630896554038163768L, + 0.89289796752480477623907740261818685845L, + 0.57786655574695620371527391411424563834L, + 0.318175774295281868509200498351278930862L, + 0.194978302204782205514236430086515458283L, + 0.87084962252516402992532937666368998137L, + 0.362113882465068209502300826516448793743L, + 0.273446496762640462316848141032810658473L, + 0.1471399192242189033406154289397228481905L, + 0.937157507052090331728212622934524925056L, + 0.600045430164287985733450402316667890373L, + 0.794478865621258499047814379367829521507L, + 0.889115878933706260333129391997704491913L, + 0.631825206206982866021784416451887594472L, + 0.966422225095067311240936396545408962515L, + 0.676845470105427028205320649846678927664L, + 0.671163783319728784750606328490914935783L, + 0.213726274743505026386536996423761328083L, + 0.99483340496284948345969144891145513965L, + 0.362072360280863974302182899205431874295L, + 0.89135316959373017710710890812308229361L, + 0.861008403776277958081202417380537907424L, + 0.518258469677886348298849030872657409393L, + 0.74995117457421590827489329835282465567L, + 0.141688060236646135992059548400562463963L, + 0.231055693687838328234866575264314255906L, + 0.128367320195147852998795956530756587271L, + 0.735643745226188370911313880883935933086L, + 0.481951681233521227023903083881246017963L, + 0.29797778097740396719094352844253033076L, + 0.259026843185033526978277511857498182853L, + 0.76454793636766387350530239448634042225L, + 0.921742101320371872828332060575170679558L, + 0.135594574885855893452962438848740230435L, + 0.249482789438500604376469100084029356821L, + 0.447893460512394580798054060401740249162L, + 0.841167533365717681130523968098862274883L, + 0.063885342343669943206116658917625959392L, + 0.49268569222220133343083683720155184169L, + 0.0320364278163828327673837310979596079469L, + 0.83067006037141488187036282222404336846L, + 0.32687090604018629599351990634445890267L, + 0.524229581985562678867475657633756672726L, + 0.26442137331545990230136529620604338964L, + 0.1804465247704923307363156457827584866855L, + 0.219897692414720290686302976466475627349L, + 0.657372240957848561373923532613997515665L, + 0.94917951707325275578037456019158874452L, + 0.999935336870950506894538846120127792282L, + 0.334292387732229479489367107895450895382L, + 0.519605753222230586160238890634421180626L, + 0.2353320030331258205431171147281090084686L, + 0.697837952881171466097464830413620278996L, + 0.337355949172173312279209733133367570558L, + 0.59624609578396787690174902306338541087L, + 0.430566868363073838098964774826687118822L, + 0.303143768470597821848720008902412356097L, + 0.45566572082779255052299434804712613961L, + 0.63651052470632278377988990008643926753L, + 0.88355849548999550762491205909993278845L, + 0.857627182143034336666679544569747793963L, + 0.579654405386150422035981447661995358225L, + 0.527551502180559045145630115424486189773L, + 0.227798290812497436015108334865799792168L, + 0.860285575656798735433746383563482660567L, + 0.657434642899561800145850990323893418457L, + 0.991915916857419346367596676050775541352L, + 0.0299053482258395117883768309912517801074L, + 0.494186962160200346319995839440170254278L, + 0.795837941248740362154274095100822390282L, + 0.213898349709271555518444444268604992712L, + 0.635385838537788174234352352696939407706L, + 0.1161960540496013767418067989853615145483L, + 0.236636716576793997613161803474856412323L, + 0.250257128320679509772248555959408855321L, + 0.754809883956726591031066199439807350575L, + 0.240047496212680591313028855365466345707L, + 0.125918185384015376472834932789271923263L, + 0.830761928512260978768305988740912711273L, + 0.0833746595456954680423678981938324373477L, + 0.993235018876045312632920249583820095078L, + 0.74457886551486005017424251252790500917L, + 0.904041666312003998553971236017433817041L, + 0.99682247674917724207607173416904094376L, + 0.778185258630194559195184600522592063632L, + 0.617908428541966249479693433082678846704L, + 0.034201434638706652764862810175677292771L, + 0.1166825963578175046863759835887066398776L, + 0.618184997077951045734597662867931774914L, + 0.67223166229200793562043589747700629457L, + 0.50367723015643325152991864733820551338L, + 0.287805524504497224349445840278160308547L, + 0.418530565562949537953621246456529701546L, + 0.356577284504836083965140033686046682705L, + 0.727797226876543100474285620953868682292L, + 0.261158535215243995918166290296126543963L, + 0.1233681715943113445590872776925938156L, + 0.397342365090131218507373938120760734013L, + 0.33651833905580176460704582099080050591L, + 0.124851176251609572087737060478799388707L, + 0.49869389018540295598691678028277690211L, + 0.603921102513219725593707198424421456834L, + 0.0288068305492076274901316515486696644854L, + 0.27635950491121559708402485015430409745L, + 0.0219820746750707161670181537628175322048L, + 0.893266704905772978187424688068554761406L, + 0.055131714446612192984065196401480701447L, + 0.478917803887421452005543212818108274705L, + 0.1089109338581245135310441557812062287244L, + 0.451355129465699006367714322379179082201L, + 0.933539696310061306235683130737189659555L, + 0.295046527696521751967458467625754033345L, + 0.657654030109877699469191835246373699585L, + 0.699519422709288537538980841108763784234L, + 0.754780411476609088293217972311402262028L, + 0.940185229424181440596885768821586612845L, + 0.641206442188302531301220212171259413504L, + 0.483623421775598486212538785028426545698L, + 0.1819507033406890598006456890391145571876L, + 0.3493992184159313422014002142021878866L, + 0.2282143482135155999703670773974654680736L, + 0.65404355620292102948676570623901452325L, + 0.000126697620991797753719907018394969483701L, + 0.000128697615694221449450257101713351917085L, + 0.66277677565136622936757573048183355679L, + 0.954427508631091518542647272554320259L, + 0.821452416615550557725422642536361482673L, + 0.783949133156224682132225528942727293192L, + 0.883688268329322182794294084718215227776L, + 0.887198477924019626901140168907684736036L, + 0.301153686936585019868640358522761168745L, + 0.97031160152938862140377079439908121466L, + 0.613591225576913510391808189718881180802L, + 0.973773801885628446394837963774216539007L, + 0.969946092528631153860793542995840284225L, + 0.0552318705490405481104532089875456066346L, + 0.398506652226642658353465649824893657953L, + 0.577466681084525459648007205600389579233L, + 0.538305717497527581210294472297571817608L, + 0.0378969572225333661087665511893845011475L, + 0.82821208446292402852221418490682507414L, + 0.207039760611344134455359310666092356869L, + 0.278071434395492049592363658721835175976L, + 0.418157919791356829061560807874478279737L, + 0.917935426878916775097393966246600470752L, + 0.968879316988430839484738642933327229065L, + 0.836847484003257581736597938908686488306L, + 0.95787762740618523171012745852536482523L, + 0.381833463284092269744674988738521423563L, + 0.585758801118634412354899474049588357203L, + 0.590675098878457580254555486356030743515L, + 0.999102261786447498899644398829003134788L, + 0.278723779765613710807952395929736248799L, + 0.150160483677965826860533794972733497469L, + 0.39044191915595120943090707935299688844L, + 0.882025297705744570797306391637391855587L, + 0.26053886056730883704893455389142056588L, + 0.530123960707389279621444598593626923328L, + 0.307497951588709795568291546230129131789L, + 0.755712717002473210112772528495042985208L, + 0.403971099596680128749039001982260210321L, + 0.0955902605698226580325595772471302440213L, + 0.733946822526846681865131682504158670327L, + 0.824558199580936798107294631591949429405L, + 0.355777480091076251706346214380424670616L, + 0.183210308747040172107746729630689571628L, + 0.943081072447366944673610412439697363267L, + 0.823437046917209496498923793615721213912L, + 0.272212671889142468847791216625072718846L, + 0.467586497114075237282436742306271250655L, + 0.965430243779957305809196327799423550657L, + 0.264527585376739963287684763043832918263L, + 0.78305929918791974277407705060017330726L, + 0.1569161089271269079867408493909342109635L, + 0.385890512318945048667111881493883277209L, + 0.748768801714747310036929893375463390286L, + 0.9607241213632062657075501565333113635L, + 0.681005349771442926258254424282975745535L, + 0.417404611754855157969846623218352380733L, + 0.384922954690351156114438668003273806442L, + 0.0248688875333777009659560293287195312336L, + 0.289622732329138351547499030028075517487L, + 0.356660798938142089830284922931103513564L, + 0.1092119220339924538904809107210351902013L, + 0.263044604533896828574983495057823392153L, + 0.72916056882229781356884933113775509031L, + 0.277279616044198734111166028359400949283L, + 0.448496025651349045553194567962243478962L, + 0.397797975606664545700620422788810306397L, + 0.915573317477921170464219734057440942223L, + 0.565957191780698852582910000301549192135L, + 0.0199640867363067059474765492007910956547L, + 0.380718754942963039702539139065633248878L, + 0.271561535356661429325107452975658450244L, + 0.65703383768996023094650337496290243735L, + 0.810303462640169412310932301780031244584L, + 0.34389677270659068303923976829417662132L, + 0.1459701849396526086771469906702178205394L, + 0.0709566883230581731990192048699199874356L, + 0.0273188133279639766234319338307950998466L, + 0.189257375093862859152281617127963424911L, + 0.483370049027267515091110020077746913052L, + 0.6121051307445822901845022667347352688L, + 0.0669683489197768142011855877890933175548L, + 0.0462440353376468071116256899031962430102L, + 0.66179099750239749196171922709429044667L, + 0.331447780875915347204488922360787127231L, + 0.88878630766137716878808504113561041651L, + 0.57831688009568937419273238575083437733L, + 0.1665758643537997337473156606765968668944L, + 0.609499751553850514507525575752744468325L, + 0.842660412678850878529299409778020570114L, + 0.868735885617006579468607975714721515953L, + 0.518323673739076029376626898444587264186L, + 0.465048961779768578307935679739067346325L, + 0.739933063031511059934522150792493137138L, + 0.366097491036976922528977805725731033037L, + 0.622890978255856721366594654155975719428L, + 0.945120241233001881267096151974150875442L, + 0.711795000549305806399598132955701848342L, + 0.120093380051693652573317820347038096902L, + 0.461420048084338423641881546847056927696L, + 0.201645977777376722385295339631509175754L, + 0.1479402104137110360277226090924965371445L, + 0.287960179369955828242600303166176042591L, + 0.788362667534075941033937374958276358103L, + 0.610312055398887641020833805884097007991L, + 0.758450801974187424825814780682156814865L, + 0.64208882693968320907867911523798381855L, + 0.255468285690834138126389042932304445888L, + 0.0370478385689831649949675007793815537737L, + 0.551880617631056560992613768623601574096L, + 0.559262357532227558112085482526038868046L, + 0.129705275018847798920129782613409588523L, + 0.1076289463968801831500602693982998566697L, + 0.272506325706516323678193293634687081578L, + 0.721990855538151706841764025895777805643L, + 0.523084042169573467351077180119310086396L, + 0.0858615712848179826840482241961243288956L, + 0.589714739430299853251893655400362103563L, + 0.512412326166823937685402214713910254025L, + 0.802350747297003067442509635888112412853L, + 0.715817091619681167941132068164905209087L, + 0.0824951218034037355816988555328185436778L, + 0.829228234554153070848595829448989414728L, + 0.59652037694553054648270061009002150308L, + 0.133585725647906582691822880117773950377L, + 0.812005216254498654412124509257882599085L, + 0.808142463854396488512203093936737654517L, + 0.570217922503074432494487309472855783614L, + 0.704017977813333280013384719294741845102L, + 0.0251797587779118690185681150429720019843L, + 0.676272439608475367571481578590700290242L, + 0.880796414989798318500723261307937258554L, + 0.387922631107753361553377889431536170676L, + 0.282350224157064849683455744598629321323L, + 0.721001172978128539392551761867898599807L, + 0.98720056526474911920598612334425157851L, + 0.9951900286811655251775209231187451065L, + 0.051844546479017627818996668613208776283L, + 0.103738972117399718145836730690615155693L, + 0.228544758674525285763674099492074936604L, + 0.429309402103194762341587536897342160049L, + 0.564535575507982971760351294178163523416L, + 0.999063571593237112671743187500362701266L, + 0.340374156369508513494787137157934959152L, + 0.778748988242111504661479799747122556733L, + 0.471307010869691772647781526213794708743L, + 0.289707428078962269353959639691462373973L, + 0.826577651264033230456965284610788939828L, + 0.860667694131974131835140122175480202008L, + 0.596405567348984902495263677852931818947L, + 0.79786093770390728560184577433203234578L, + 0.85492142888696693237980696048371212203L, + 0.57242705004809831263405538576519171441L, + 0.829648119655355629047392239460860046016L, + 0.783260316181642610272420809845230036294L, + 0.0941718863377651336163202407301145871807L, + 0.156372209579300482444127671309443664823L, + 0.95045258077372510217507306087908380692L, + 0.1885289021059534081345247308001373861575L, + 0.660776653890123229320677431688026234587L, + 0.2333507388961794003755022400755269739225L, + 0.926661255852332295794894190183342387092L, + 0.862240624886232672002503279536846219655L, + 0.093072473040365648693897225471155002338L, + 0.210437952956145192084247103889970459783L, + 0.98112543168220233380555460117617724093L, + 0.740174391774267645790688716222038485627L, + 0.0209886798500615011013258311339617682421L, + 0.41833754096087514377582590206105535614L, + 0.469019942905167330505858885046130048223L, + 0.715228143253914303084091910768414947468L, + 0.949215045400946624794326433082702896278L, + 0.0839262379919984011512905346130401074556L, + 0.358856470231875479544116669678510859691L, + 0.676461324144301815445903930221360844898L, + 0.321802718137104975636543941512529575137L, + 0.993411285955596090334951526803325817472L, + 0.860164319140927797258503749506400508873L, + 0.94773452678939638468420772776729628408L, + 0.786167026315331965750413583155691260173L, + 0.45156944204188755542678210840170293585L, + 0.490807428869058127589400400723875752095L, + 0.1064150484458768919266881304357565451445L, + 0.324460881496927069927267886879512784128L, + 0.892536276084459403262968666925514247957L, + 0.626906362142556286375622503025155623158L, + 0.912617117728752553677432546319200457076L, + 0.670287539555608481364011494943625670644L, + 0.247614513279178220157281399165275150246L, + 0.328334024179281412037962820247065990969L, + 0.829445540957824174480776183273738605512L, + 0.1787214688659462728637669907628671276175L, + 0.925570168885833135397413435137754040344L, + 0.98275386432184844551191217367555375122L, + 0.364711512670624901280733420446798813805L, + 0.0676060703890593392691073615176801081634L, + 0.01088522590112897075539168583333589679446L, + 0.0611693052224598303672047526429160913973L, + 0.214589347780615411637055343786045569195L, + 0.698097005257153990899739747284349971478L, + 0.0354356066334430559162358810601367856981L, + 0.0279531560831790454930326667914520406377L, + 0.939682879995515407044885888120427639943L, + 0.312419879113847025637130107480365284706L, + 0.429063186024752762548549652686423948472L, + 0.198325752893057589388425455067795077316L, + 0.653970278037364931023007417819508007502L, + 0.396811027519564931158159336303275106925L, + 0.50451059823222344440248588902992099958L, + 0.0862505815838354201964323759027263746603L, + 0.957096030216378795442646824371057760147L, + 0.587610162738417619467784731999441435863L, + 0.582187586992416238476426545279573456436L, + 0.535716130421670802716666237861890374707L, + 0.090478847153957807764386571203708454605L, + 0.788473620511487574655894325144660477707L, + 0.610237648835883657058234607228408957708L, + 0.678372723016422015853594971922211368707L, + 0.0477042323920128297852928999674240977938L, + 0.916676966783686851658830754268116450562L, + 0.385373716764729378193009393283577714611L, + 0.51049308234047313597601380814795899816L, + 0.1196704708003806819299545192341910042065L, + 0.446475706132336496196697021305914636716L, + 0.22995164195921866005337396330755244987L, + 0.632225374693904589951305492826903497058L, + 0.1049567841702419598059377515889392050297L, + 0.66749284825574584532432314559877621928L, + 0.730750212627697291852996268443402535667L, + 0.44210748459007730373853303409845654876L, + 0.165882407048533464405922485111215401752L, + 0.326102079042974476137893383568312181916L, + 0.894926469777796621626659556932174565354L, + 0.829811268916354531033773068150153342864L, + 0.0607253283595596933368529290946492114805L, + 0.0677752868787034912813695724240479638585L, + 0.82861506635734784945473366382511846348L, + 0.160085543323090657960949278634908144601L, + 0.232569451519550129004668131405568301759L, + 0.848363194546104528297512566450812116666L, + 0.793640414525406609723674517332020118566L, + 0.0908665486135344605492576594616215607582L, + 0.98524892289773367881284955458176900047L, + 0.232277847265217861619371474795084074907L, + 0.2478103820537262599906715455471023544214L, + 0.518524645780409202282547691600231775584L, + 0.726858378884955244314303315523158335615L, + 0.245545705017836867827662773158398435754L, + 0.2242602776132220616213985660229694803996L, + 0.69321599409749039262414070240230983052L, + 0.0112978587458533729787299027903363211672L, + 0.201700091442640051051557572594860881596L, + 0.1553158804742445432796353137546288871905L, + 0.297307958467221836656545818754009116053L, + 0.858321137590160233755873079497950982112L, + 0.66848174756798322137180974713907803341L, + 0.996344263106353369755981871581860505522L, + 0.0298469963581545313060582891253178820216L, + 0.5825562269883888340326171333296281312L, + 0.493316240919863194534203651249074989694L, + 0.25506115557073666386519530923416434445L, + 0.990037777634583670683401168871182857585L, + 0.111966792328779238876716387539738843995L, + 0.555536981182848652400091282463345207445L, + 0.281763605895317871765768390877174374161L, + 0.902702281907817546029803311979267829958L, + 0.526223239446627547666226037912343453756L, + 0.663322588876953268851644820272004691035L, + 0.925956679854174995001911256195736125327L, + 0.978687628923344717267490649565202182013L, + 0.295452218109470204949110043833472171496L, + 0.763317372768444290934585368155544717374L, + 0.41484295515622153189510360412010755096L, + 0.95319138766107113957717501566306191772L, + 0.449833295238493367386837134824022661087L, + 0.380903660964162496124546078818966824203L, + 0.0591435603332779390763767398658188273838L, + 0.594973116752510574186847848340951992488L, + 0.66051154347057943107777082783767373976L, + 0.9590947364014878778361002605613544034L, + 0.141719503437180601174660143271258240733L, + 0.72942088503531365739564056985302156428L, + 0.96229479992042091317494337141213026865L, + 0.51401712994901482942061876482808737646L, + 0.09446204537625467018781365109090483186L, + 0.568441523568450417056301286402539600564L, + 0.598604342726174263070596195546293250945L, + 0.774951017988365558347613104226790833317L, + 0.81892086730816467017537310019875247387L, + 0.890143355483709851496792149649550808793L, + 0.2191477338352410954693547610221317715285L, + 0.726897475480314385643181203422499653L, + 0.756138778886812022822443490226271392144L, + 0.36128016023552084266898937740898271179L, + 0.410782581318000192446155911986931996913L, + 0.223641334296034708685419059866928946095L, + 0.0611617201563377229556630546893173872466L, + 0.0454251140845604672274274573289906520655L, + 0.292039969549662442463090760177927466818L, + 0.0892783972345646734854765244000589132126L, + 0.98769280749877429524697464655962686569L, + 0.889843464657722517503667653048728011052L, + 0.651776307404858375062718114948328477704L, + 0.87617575855504123004785690824244025026L, + 0.338359170956885135997817905734588127076L, + 0.734032684330295341291816774804886223887L, + 0.862422342223053851459695185679195132964L, + 0.197333977370262353727756586852240555633L, + 0.586060335783457129849055206578505427124L, + 0.132898852938756538479400358451026471607L, + 0.548298096092246267871555639877296879195L, + 0.301119859270324657077136364646995297056L, + 0.02186689635349189676964089313754648484195L, + 0.037538023766844046167768352700498359816L, + 0.739462465806194132819844936199304370748L, + 0.306338591475158278790432712666553704959L, + 0.0349382326130091592369352494672121905505L, + 0.12659131714329909411210854142389581492L, + 0.991566243159047696662802015340988687108L, + 0.265613985138476447081523915107505113653L, + 0.379928020809782559672193104868857287448L, + 0.3311424971073397473661763760151895103L, + 0.702177302636984264408758773725210449873L, + 0.975045571615360787500646118846671455125L, + 0.0373462862349996603561237755410350012631L, + 0.846126776062337124521510357150131165153L, + 0.604046707233534456382774833817964498043L, + 0.1981113045697699450375369418161865703455L, + 0.0223467484405979164693956414316536174577L, + 0.67121960182601511325776586363807504696L, + 0.165784481427263519151726479123968726022L, + 0.721784618575898210943875783221281669927L, + 0.247408211201465904622132596487935205602L, + 0.474174174442367430962454680799704832459L, + 0.38041380356189313505762491005159753494L, + 0.412834591083812886132307610186713638625L, + 0.294378742681402760124595985235966036022L, + 0.319576442623415298744966071520183847465L, + 0.17227236515412864866186439447886640924L, + 0.19227796294349462194111033545303573433L, + 0.701351402612222654905938605774127547107L, + 0.55598633289035034815584162421930015865L, + 0.402729648554369906881359212431684355721L, + 0.595951760748834493622338584190905994085L, + 0.119840257870361007206544525046135477756L, + 0.90443395581066590152525534589406902782L, + 0.205188871300477881549673944463237196075L, + 0.339175278174772519132232276502457660768L, + 0.447725444308107151040888910769680233742L, + 0.541239546708188153505885726785683096117L, + 0.12984235126732767588700711245028426254L, + 0.0534701599183773436559514525508752846737L, + 0.793436019832695131646422778046763975325L, + 0.718125883729211211336344362949260539072L, + 0.328649037343445105052694618356980072933L, + 0.113307342739499399477248133420602576291L, + 0.87683936228301044929749768481864525904L, + 0.212591937265603187751611886807532831791L, + 0.761002958456888912899646497131654914807L, + 0.220849601519164170820922984026707209176L, + 0.222305857213559738578093188054272365062L, + 0.651516500020930005107266726995614198887L, + 0.1505613416188572288472651067305496894266L, + 0.166658450989632252583252879193540688162L, + 0.249417632511505538283736333645627460544L, + 0.50096054904291170172998992288713266662L, + 0.173701146801321486346972068110605414347L, + 0.93433415280052265881674202089278791561L, + 0.1167900820460300938880016624066890278452L, + 0.265137084235229705213901240937609442947L, + 0.110072770364904306470596762714108445086L, + 0.0670575770615268870829070207384379655213L, + 0.92447493539224566948960065689964970346L, + 0.187517201307673207566548753071237315229L, + 0.935719666366703749433556454391358561756L, + 0.964002672100646458888742916175546552353L, + 0.6304136194377902875122727617639812134L, + 0.497041144725381002743104205240568050483L, + 0.589232636183711897405482721407549359295L, + 0.524588285641300028631908965527617181296L, + 0.786409662511483672510756944887012261427L, + 0.9924030873238807048291154748671174581L, + 0.891407534733792276848059682970952672076L, + 0.308538095910260975496982224956384014562L, + 0.949088891149549225900320967233005245566L, + 0.507378396004105004571665876613293881214L, + 0.348875146873077771786031143309488031474L, + 0.129717394366372388305812826098578876617L, + 0.371316171885006633822161450072014737125L, + 0.550162123072752251266003313454007126843L, + 0.822171979807031777641565545578299345138L, + 0.75171547658293988559512988487590040284L, + 0.329537443635543385256682239450819107475L, + 0.159687481361602477899361671181005148163L, + 0.788720723813465707294018605642035752394L, + 0.1031423865826241581828274573741444954832L, + 0.1925157943560383416361499973635531049876L, + 0.771893047929845637497166550933789470487L, + 0.681189132819106369246924892765206195007L, + 0.180608768713011918428603967211913698036L, + 0.0869303304414286810402604783458783443746L, + 0.63890744831302111307395023326393791462L, + 0.531696069328179766265158866360885671855L, + 0.557357572478102464274432325432400878297L, + 0.765306589402879669413870462450921612475L, + 0.0941202729911292570046371838018359372082L, + 0.902333472113108821746674873990738636997L, + 0.165516366160118370026922089795742876131L, + 0.0317472434880413278821576585103363607157L, + 0.706107972335163251316361316043030620453L, + 0.832472986392763388669796997227437520663L, + 0.769939001736494466971306881365718899207L, + 0.83093185023987157595917781461722256739L, + 0.1143834825195292986705373579359335590854L, + 0.283326017120251162360393258571085609729L, + 0.301605389836836671045912951769199753359L, + 0.855854391727628505548518803309296566532L, + 0.089938332734139699450960989316391404434L, + 0.310225946153425747793112265736973169299L, + 0.96854812596413627994714291059983626441L, + 0.279767360423571836833858253122290577619L, + 0.113545981876279916290815278422648489865L, + 0.943101270554056170747004305255027939268L, + 0.812274724978801470221644756549524210083L, + 0.9678011347395447510273023981530290554L, + 0.514795136336602722878788704708053145966L, + 0.50560840616487841567055789750974674943L, + 0.127654209842819812026603428361923670116L, + 0.273727399985085036497076514726791191553L, + 0.964821797874257789566527793136425594082L, + 0.853392912197074096341317268954834390727L, + 0.914236806849585335611299422695886165192L, + 0.277335361137281076359079507288838688219L, + 0.865708792613433194377422367016717680172L, + 0.761947879929658945814013586634774725302L, + 0.276975494384441865188273120642155257808L, + 0.0678895000408079241574268817560335475378L, + 0.929521528875748672899760603996998763144L, + 0.44453824299955605846877126958322272066L, + 0.444318159420536625223816052640621069982L, + 0.42913762214779045597457741573009821738L, + 0.98994873802399078252493194985812582986L, + 0.93065975343157446755652147574743540714L, + 0.821639107980128580428385838275355600123L, + 0.031337950421787684669360817154012683829L, + 0.839516942888416107002513723437531514126L, + 0.785501376812531727571251496474527490183L, + 0.247978681554054401906203846371863203863L, + 0.985774009303654108868853196421131421187L, + 0.635347409930173147315815281304257764708L, + 0.40087985483327734740658289294086718422L, + 0.374059729085540852289174052767716446502L, + 0.367226053686019780853702834825808619761L, + 0.166424328898161772576167906091392715805L, + 0.838115185925303343477055122060982270143L, + 0.829549684532006011608856001441012324216L, + 0.059867788238866724897690318151639504149L, + 0.0253429734563284738087263277549928280781L, + 0.953315773263436653713242828719775352192L, + 0.597536998796130884349662459732857817956L, + 0.0320571321493587106457025626624408278814L, + 0.477506594803204144826488443400695434979L, + 0.285541992141868221897101891229394096707L, + 0.764190678950226854486968785768647879005L, + 0.895489776830293129781335242249167913705L, + 0.570740793029533496018083006013191540077L, + 0.938316924714444954315906773563465846538L, + 0.56157168133328941481074926451373503549L, + 0.354184283860505415751320741296599995231L, + 0.778294119283540721552919906619543293274L, + 0.434953011661757598127924745629053141294L, + 0.37156491156117895854194599593687697796L, + 0.898767478977082606651667259049374990828L, + 0.21819365919403129548458400006737057993L, + 0.278163373548978939704874687746089548269L, + 0.1089005781457343817756962209721573336768L, + 0.85152888717082537570752846642305937149L, + 0.2419243481761527583754399630924438738944L, + 0.69442654829377168239365980152821108287L, + 0.1512336533453368944625038813397779875445L, + 0.617712962492924013140729661730350287525L, + 0.935400762900002313827620435729493050175L, + 0.79357339902161958573967958515254111256L, + 0.734250188990467683521536859220675412636L, + 0.748517858206364295837674601491185485078L, + 0.82520014781239194590337105462135253912L, + 0.1240649365160101108753438662971422995014L, + 0.479769236133748631678854875312914195598L, + 0.171269492636258554036912204801376697988L, + 0.833025419245729049117746814929956940986L, + 0.354429813451205200141830318428840891828L, + 0.474809123369344367691189422128776480146L, + 0.692239655770541262287308180705629028608L, + 0.271366901464125731413801963807240905363L, + 0.561330233800121182669429172066686942393L, + 0.0695868383638479426233449148171168522655L, + 0.627576910684655924911125045007979454546L, + 0.423331542652214907262628326674848471962L, + 0.354725031694671387579309719042578580595L, + 0.312419264533145363169359084710774849388L, + 0.167819037053563697473931127337972350099L, + 0.99960836112225007722014049168024866743L, + 0.820598666739967434549389339457492152643L, + 0.689495024741546551592649728378054973272L, + 0.831455766750164249604246627812180304754L, + 0.515538871956858025876039391193370146897L, + 0.011724889011994886395520178564059346913L, + 0.587485679650311054946861235938601293477L, + 0.113010564497810081892271654273794311467L, + 0.381261245177928587613552004600730320213L, + 0.466933821322235841488251157296771536952L, + 0.646965031311287534221872388017990968767L, + 0.1811101995014685369939482409137380098995L, + 0.247896943912780884738461558340983142645L, + 0.989351208835640462928338658234638846217L, + 0.924605283008839688813842975338096967047L, + 0.232010860908797395869871518793187418799L, + 0.90274859050487649728273938229764570199L, + 0.664078588165617572819884867627266650356L, + 0.532118803501055886836301096658125012493L, + 0.854049566634563277356849166147057535436L, + 0.756477818237029394317820041473365538516L, + 0.84578312219074068824832318394711642503L, + 0.169914247711153055959592721695068126213L, + 0.50848961455796310913779527189620088788L, + 0.715231849280217810525151667911662744854L, + 0.59666585539439202929452535210623694053L, + 0.72343578283497935670188130618697814035L, + 0.982228826906846431195861293729527133844L, + 0.98068755339273420823366752414155272462L, + 0.805277135157133623039231303778838094716L, + 0.840154168539481858495551656699708834713L, + 0.41783933695481411993780663692806809771L, + 0.070981740672048589027432942629842679319L, + 0.96664795205679820656636930925268162457L, + 0.155178444292580006807274171645675417735L, + 0.276407670358590477524508525465318694191L, + 0.1054964292635286397825421772930229411286L, + 0.354205947516472098240472076653525679013L, + 0.583456972150065135260312420865576513532L, + 0.338643867118430587299252775116788065723L, + 0.146467849593879827355466951871059968293L, + 0.0639448405747942007938896940026153617467L, + 0.846536583732599902600485371566229612512L, + 0.599728399399342923058515558777947417833L, + 0.140387922890235239162309673093379598453L, + 0.1613160217694973394489944660056369626715L, + 0.151848582163159668039725770584081620756L, + 0.663365628518336712743995463098831995163L, + 0.752166976367665534193146852225632451022L, + 0.911311062532571765386023433215793121138L, + 0.692490353635171096989434518397248623866L, + 0.990512559245857089458980255962574316578L, + 0.135026433195284768293027372762691869458L, + 0.82220389984592453325084678614092535756L, + 0.385471328555065081327630832374267955206L, + 0.108251633446048989722318564345306848022L, + 0.429090236713339412878596384043906547999L, + 0.983421429305507423332481562450757515935L, + 0.0163920521681887489391607174895946079877L, + 0.634276319224952361916496263299135133978L, + 0.53164375434562160610011793242431018808L, + 0.92801127390978303506935520414803575609L, + 0.708525110316144414918831897015500504675L, + 0.722458240987313977092360928226487539067L, + 0.432028911017122242491499522489684865593L, + 0.0001754664935299182587224394863719217640876L, + 0.384266658709383389800969077999970411222L, + 0.284964603427904715461598563563830112021L, + 0.1541443027599544245798778784933517572175L, + 0.958338802063400795313378181913830622686L, + 0.636927309395779701122460610729048286624L, + 0.0963946603295477475541191401069719222887L, + 0.0995190436935072136624400787867889652226L, + 0.294220607618706451139091631947946466958L, + 0.180831121994104393794487526888221966969L, + 0.635403971764105414766318934434540385347L, + 0.333929089029202997624323059191296321991L, + 0.498378678845335358166419186432789231466L, + 0.79769145046274241777533636404451138797L, + 0.269285209299779365433012558225847643041L, + 0.110524792990169183853219228066613162975L, + 0.252694136970632381193559370648931722998L, + 0.447232396115786457656991370803052298542L, + 0.136974250599080636030665381278567779455L, + 0.67243844394695156696032636816317618716L, + 0.280265952023932940327982570523639258968L, + 0.960024614746466668963206103951264089396L, + 0.83595031847062668345135859090890188348L, + 0.127840531352213174558502027846545305518L, + 0.333183884044346150282363573006579940787L, + 0.480504229384957927069515726093850498988L, + 0.768498913093287331615443023486434378468L, + 0.940413493411219283289136687423264928073L, + 0.548648592555019577089750862504091661273L, + 0.57814360039222917342516307696519676185L, + 0.752806287004316513987155718410926624384L, + 0.328211694133870995310455637563825433641L, + 0.153907665030571878436793446358668488233L, + 0.694742699178286984320321272531890059073L, + 0.25435421168640709608520313542078743933L, + 0.61387638208113240104328972389071498415L, + 0.250476311300881635346483832554226742174L, + 0.345809836897231980069633800588202859833L, + 0.343083789419841923142937785323119943136L, + 0.319174378869537109008405333721782689566L, + 0.158111477528301687597604325494967120237L, + 0.244000500810322900960285910812181460829L, + 0.23179705702278726416861948783067588642L, + 0.54682924846605062799436489677774333716L, + 0.549008127982055819651521103931442895238L, + 0.262583044663608129412956518168777449925L, + 0.00126513153702681878410946802239924274583L, + 0.942613696151881635585127791325641506562L, + 0.352686443706689559388572818776843215083L, + 0.90689998425792029984240460273113807702L, + 0.867511650419363872431681377574762734184L, + 0.280671949468087158951852027769013272607L, + 0.162038690615698843560500386213858514888L, + 0.71179364933082197276587611716632482938L, + 0.0967402545497599384082792036477527703823L, + 0.465040868275334873151726613879001199556L, + 0.621004503662486553272117361134036130264L, + 0.732964940483576253705474121238830973672L, + 0.423374863473223783721502627532544136435L, + 0.490338535425760290944218064913112069833L, + 0.0243433415988311460557576165617657963508L, + 0.0502339423891456566961808478207103394328L, + 0.57668149339841029115236469576085057193L, + 0.654589079253818313716855283653923913987L, + 0.1099728579252794893221972017964445810946L, + 0.95067113980240197864048876003001477344L, + 0.271440369581834169312179003284604198334L, + 0.067152474145377434478612939162576726923L, + 0.77434193893477314687843638736266814713L, + 0.2095679937785625400917773512669417520444L, + 0.7681370807102749183539277908648691358L, + 0.24472807400083103884984122018932641814L, + 0.191307162486577428460074174309309551616L, + 0.637215617752531571162184184570005111405L, + 0.858141525396878877938747690015117846998L, + 0.338400625200720062249435065450813258281L, + 0.564981422008979753676981861330327611986L, + 0.809460314261206431741632790718777271837L, + 0.879343403409393604462128113991125533726L, + 0.284697509116613252542034824007026845569L, + 0.497023470648395180497606069099534119801L, + 0.650004713241995983979792197286941523L, + 0.1177129995341492896184329340448111002318L, + 0.923625966014428778639333261268345799732L, + 0.698837131343914189577155394009532120604L, + 0.28242326745092132457477019796509942259L, + 0.70025600885251684699238650783454037429L, + 0.876659050276528114198964471020380705343L, + 0.52914892693002332233566353042454639365L, + 0.319860854431864688430502078275989809115L, + 0.83483115610648557287441551698147898778L, + 0.727639064249568383685922880431792837046L, + 0.58743287662861037184349933549802687836L, + 0.510383231616356949495559076196319035197L, + 0.00229935944348919214521608305418404052343L, + 0.799567224020488433652933994297769381902L, + 0.343651210821093611687224166251624444254L, + 0.405948097827175151257603419529941300798L, + 0.456473183882957921169800992232941517586L, + 0.570248304776860782392105323292264026118L, + 0.534779754769153667870756893044557559557L, + 0.472965511839676757434979299779809656808L, + 0.137335340499076127280155831169214403285L, + 0.51975901660926295231312276736119435645L, + 0.8085867293332018994761547260739912451L, + 0.812416413241484848007226874256949892893L, + 0.852994977709961112714176162016389410712L, + 0.95270886248643660114015239563660004248L, + 0.845133719240648570417568652136630304138L, + 0.4074980021816323645978397907609428101L, + 0.335850514497730546494305840184055599972L, + 0.0882622233237065445998153436898044995127L, + 0.936467561027640943446178111237050277205L, + 0.56676472173638044722431698799123577376L, + 0.528427769051008704179988533062745663408L, + 0.460890427579778855697205646060084318038L, + 0.754971897131798313468797543428083655928L, + 0.980733597969419782109470537306886067907L, + 0.204362127415649555111877580124343815074L, + 0.424822548090499017266619697426652494042L, + 0.790847149074521364262028407892114384257L, + 0.559922683392730473870877613727301497865L, + 0.779993507158626042106006393237738208875L, + 0.30516368089713691312418593599115685319L, + 0.68918765842229398168455844072311006826L, + 0.972291357858071465096079542885284602882L, + 0.92204286423973856982373873105566928589L, + 0.488649453783638471576482476648021023315L, + 0.467124744623849284659862825278549932824L, + 0.548051233865943557014854568009331816852L, + 0.306838990296265483205551142903402056051L, + 0.497005516835688988273805238236922199451L, + 0.341504433884138135798086132528045458722L, + 0.969816416247460790089503289400709886528L, + 0.63656435610220447227337751650167349487L, + 0.83588076122262875881859751942918794857L, + 0.647568600604975972308348018018445212894L, + 0.916061870307308870029862807808332479077L, + 0.767988745496844638880672392122527991445L, + 0.1623230195628039449666927123215281227666L, + 0.0791082835859634251558587844284289799848L, + 0.575858643610197202634665099752882990844L, + 0.559159434263749620344702466000799724913L, + 0.063765998380760211208741798736948488376L, + 0.230557913975359017084357477142151415967L, + 0.702854691657277602758421942319022953845L, + 0.789516660466782621905392733079230211954L, + 0.491496186820051632244513986127898500904L, + 0.171499215418269578563458417238340672634L, + 0.626470061831746666081979158043673024967L, + 0.258903137813870706268979320963343541457L, + 0.64156850108405218894694811301875120511L, + 0.534043520260340661507140771088018906496L, + 0.388275182018399247097875416106759899469L, + 0.920936363560998030495046998224168162945L, + 0.826139404694006088220407338888245165242L, + 0.343561253523163451528918423980552161597L, + 0.921521003270491194867019217479780072647L, + 0.656212467754097185125864111703195343744L, + 0.628186262290474398328350301885606581942L, + 0.573227336542237665153422986363073650388L, + 0.94178975003001342039795597242477049832L, + 0.0408103561362355768975182155847755354614L, + 0.382581672073273072487550945526454964287L, + 0.152851256046525520308098129538613498254L, + 0.966735024597183045592313880114075824298L, + 0.215564894798334550271993595018433286244L, + 0.776491530531523589201618375156272004616L, + 0.912460554179311241821569665648929177608L, + 0.632880016212040018958086886452474382272L, + 0.711577891112709305169603082360885583086L, + 0.1120655756066491784920471129299439607153L, + 0.691106483958832651050573402690448368687L, + 0.227442567846797646970770128970529357636L, + 0.837435613090485891584882062239924101455L, + 0.524389161590691896070067767400758142565L, + 0.591360583466508186135247682666313136762L, + 0.103155847462960450706124014839446958843L, + 0.98360160577671960281465138408293984545L, + 0.197665014114674630647437622579741018817L, + 0.1099709194312379594014239398842185159354L, + 0.394053373921474751303577685990936074485L, + 0.94945354787200894450508557094182436657L, + 0.372593716084661547440393809983835348274L, + 0.62514674616343692328572382301636412566L, + 0.2001871481416310130073795585638383984926L, + 0.148432902421401306477690922498335475507L, + 0.687921673269487018193347305425182239764L, + 0.470940334348984370262797433659013738143L, + 0.1592476430730276812200821020958787823795L, + 0.296776110696565927524970058176467314578L, + 0.1491253105142218631726813695413369166796L, + 0.579194717868638955003571989739802264354L, + 0.0730543936466744761440131951539370917776L, + 0.941296077873340797733875467209629660594L, + 0.76720024949523806992504865943580486187L, + 0.419526107681583337049761526455092560735L, + 0.00688594806937144144337797612615981618743L, + 0.931682704636487927763651991274577493318L, + 0.660524215847727125058815911433184924133L, + 0.71780972384903067744609138100002205676L, + 0.02961791918271995070621856302848439458175L, + 0.692791206212428997136050006631240567502L, + 0.162762426697948445642880183096693062538L, + 0.183637795551464341949019870428026949035L, + 0.51263789620316407488619761125039609046L, + 0.90238698122728366178818828411640824056L, + 0.229784208410123517024401367798925386038L, + 0.227218480059027721044118324890061381517L, + 0.6555059570778176955459672492237825867L, + 0.929815767583615624563413584598741896834L, + 0.188559597559312695774663933876436875041L, + 0.396184448063913762028147791554346199354L, + 0.656329540957568516760105602115555736073L, + 0.1410678455413176345310401990667063246115L, + 0.621004667838855651847651367745487628637L, + 0.01277988784767030635209958407461792778387L, + 0.69482142276844418673788732511112265014L, + 0.925705031133221932065307191539105635005L, + 0.925744341385232535963050430363763081603L, + 0.24189467813699258571134382505828701386L, + 0.646009544609703485845605410919901799L, + 0.051119212999532673562206731603906295406L, + 0.85076142804383409765024452942896578158L +}; diff --git a/gnulib-tests/sched_yield.c b/gnulib-tests/sched_yield.c new file mode 100644 index 0000000..07964c7 --- /dev/null +++ b/gnulib-tests/sched_yield.c @@ -0,0 +1,46 @@ +/* Schedule other threads to run. + Copyright (C) 2019-2020 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, 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2019. */ + +#include <config.h> + +/* Specification. */ +#include <sched.h> + +#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS +/* Use Windows threads. */ + +# define WIN32_LEAN_AND_MEAN /* avoid including junk */ +# include <windows.h> + +int +sched_yield (void) +{ + Sleep (0); + return 0; +} + +#else +/* Provide a dummy implementation for single-threaded applications. */ + +int +sched_yield (void) +{ + return 0; +} + +#endif diff --git a/gnulib-tests/secure_getenv.c b/gnulib-tests/secure_getenv.c new file mode 100644 index 0000000..d39f682 --- /dev/null +++ b/gnulib-tests/secure_getenv.c @@ -0,0 +1,54 @@ +/* Look up an environment variable, returning NULL in insecure situations. + + Copyright 2013-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdlib.h> + +#if !HAVE___SECURE_GETENV +# if HAVE_ISSETUGID || (HAVE_GETUID && HAVE_GETEUID && HAVE_GETGID && HAVE_GETEGID) +# include <unistd.h> +# endif +#endif + +char * +secure_getenv (char const *name) +{ +#if HAVE___SECURE_GETENV /* glibc */ + return __secure_getenv (name); +#elif HAVE_ISSETUGID /* OS X, FreeBSD, NetBSD, OpenBSD */ + if (issetugid ()) + return NULL; + return getenv (name); +#elif HAVE_GETUID && HAVE_GETEUID && HAVE_GETGID && HAVE_GETEGID /* other Unix */ + if (geteuid () != getuid () || getegid () != getgid ()) + return NULL; + return getenv (name); +#elif defined _WIN32 && ! defined __CYGWIN__ /* native Windows */ + /* On native Windows, there is no such concept as setuid or setgid binaries. + - Programs launched as system services have high privileges, but they don't + inherit environment variables from a user. + - Programs launched by a user with "Run as Administrator" have high + privileges and use the environment variables, but the user has been asked + whether he agrees. + - Programs launched by a user without "Run as Administrator" cannot gain + high privileges, therefore there is no risk. */ + return getenv (name); +#else + return NULL; +#endif +} diff --git a/gnulib-tests/setlocale.c b/gnulib-tests/setlocale.c new file mode 100644 index 0000000..f4141be --- /dev/null +++ b/gnulib-tests/setlocale.c @@ -0,0 +1,1673 @@ +/* Set the current locale. -*- coding: utf-8 -*- + Copyright (C) 2009, 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2009. */ + +#include <config.h> + +/* Override setlocale() so that when the default locale is requested + (locale = ""), the environment variables LC_ALL, LC_*, and LANG are + considered. + Also include all the functionality from libintl's setlocale() override. */ + +/* Please keep this file in sync with + gettext/gettext-runtime/intl/setlocale.c ! */ + +/* Specification. */ +#include <locale.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "localename.h" + +#if HAVE_CFLOCALECOPYPREFERREDLANGUAGES || HAVE_CFPREFERENCESCOPYAPPVALUE +# if HAVE_CFLOCALECOPYPREFERREDLANGUAGES +# include <CoreFoundation/CFLocale.h> +# elif HAVE_CFPREFERENCESCOPYAPPVALUE +# include <CoreFoundation/CFPreferences.h> +# endif +# include <CoreFoundation/CFPropertyList.h> +# include <CoreFoundation/CFArray.h> +# include <CoreFoundation/CFString.h> +extern void gl_locale_name_canonicalize (char *name); +#endif + +#if 1 + +# undef setlocale + +/* Which of the replacements to activate? */ +# if NEED_SETLOCALE_IMPROVED +# define setlocale_improved rpl_setlocale +# elif NEED_SETLOCALE_MTSAFE +# define setlocale_mtsafe rpl_setlocale +# else +# error "This file should only be compiled if NEED_SETLOCALE_IMPROVED || NEED_SETLOCALE_MTSAFE." +# endif + +/* Like setlocale, but guaranteed to be multithread-safe if LOCALE == NULL. */ +# if !SETLOCALE_NULL_ALL_MTSAFE || !SETLOCALE_NULL_ONE_MTSAFE /* i.e. if NEED_SETLOCALE_MTSAFE */ + +# if NEED_SETLOCALE_IMPROVED +static +# endif +char * +setlocale_mtsafe (int category, const char *locale) +{ + if (locale == NULL) + return (char *) setlocale_null (category); + else + return setlocale (category, locale); +} +# else /* !NEED_SETLOCALE_MTSAFE */ + +# define setlocale_mtsafe setlocale + +# endif /* NEED_SETLOCALE_MTSAFE */ + +# if NEED_SETLOCALE_IMPROVED + +/* Return string representation of locale category CATEGORY. */ +static const char * +category_to_name (int category) +{ + const char *retval; + + switch (category) + { + case LC_COLLATE: + retval = "LC_COLLATE"; + break; + case LC_CTYPE: + retval = "LC_CTYPE"; + break; + case LC_MONETARY: + retval = "LC_MONETARY"; + break; + case LC_NUMERIC: + retval = "LC_NUMERIC"; + break; + case LC_TIME: + retval = "LC_TIME"; + break; + case LC_MESSAGES: + retval = "LC_MESSAGES"; + break; + default: + /* If you have a better idea for a default value let me know. */ + retval = "LC_XXX"; + } + + return retval; +} + +# if defined _WIN32 && ! defined __CYGWIN__ + +/* The native Windows setlocale() function expects locale names of the form + "German" or "German_Germany" or "DEU", but not "de" or "de_DE". We need + to convert the names from the form with ISO 639 language code and ISO 3166 + country code to the form with English names or with three-letter identifier. + The three-letter identifiers known by a Windows XP SP2 or SP3 are: + AFK Afrikaans_South Africa.1252 + ARA Arabic_Saudi Arabia.1256 + ARB Arabic_Lebanon.1256 + ARE Arabic_Egypt.1256 + ARG Arabic_Algeria.1256 + ARH Arabic_Bahrain.1256 + ARI Arabic_Iraq.1256 + ARJ Arabic_Jordan.1256 + ARK Arabic_Kuwait.1256 + ARL Arabic_Libya.1256 + ARM Arabic_Morocco.1256 + ARO Arabic_Oman.1256 + ARQ Arabic_Qatar.1256 + ARS Arabic_Syria.1256 + ART Arabic_Tunisia.1256 + ARU Arabic_U.A.E..1256 + ARY Arabic_Yemen.1256 + AZE Azeri (Latin)_Azerbaijan.1254 + BEL Belarusian_Belarus.1251 + BGR Bulgarian_Bulgaria.1251 + BSB Bosnian_Bosnia and Herzegovina.1250 + BSC Bosnian (Cyrillic)_Bosnia and Herzegovina.1250 (wrong encoding!) + CAT Catalan_Spain.1252 + CHH Chinese_Hong Kong S.A.R..950 + CHI Chinese_Singapore.936 + CHS Chinese_People's Republic of China.936 + CHT Chinese_Taiwan.950 + CSY Czech_Czech Republic.1250 + CYM Welsh_United Kingdom.1252 + DAN Danish_Denmark.1252 + DEA German_Austria.1252 + DEC German_Liechtenstein.1252 + DEL German_Luxembourg.1252 + DES German_Switzerland.1252 + DEU German_Germany.1252 + ELL Greek_Greece.1253 + ENA English_Australia.1252 + ENB English_Caribbean.1252 + ENC English_Canada.1252 + ENG English_United Kingdom.1252 + ENI English_Ireland.1252 + ENJ English_Jamaica.1252 + ENL English_Belize.1252 + ENP English_Republic of the Philippines.1252 + ENS English_South Africa.1252 + ENT English_Trinidad and Tobago.1252 + ENU English_United States.1252 + ENW English_Zimbabwe.1252 + ENZ English_New Zealand.1252 + ESA Spanish_Panama.1252 + ESB Spanish_Bolivia.1252 + ESC Spanish_Costa Rica.1252 + ESD Spanish_Dominican Republic.1252 + ESE Spanish_El Salvador.1252 + ESF Spanish_Ecuador.1252 + ESG Spanish_Guatemala.1252 + ESH Spanish_Honduras.1252 + ESI Spanish_Nicaragua.1252 + ESL Spanish_Chile.1252 + ESM Spanish_Mexico.1252 + ESN Spanish_Spain.1252 + ESO Spanish_Colombia.1252 + ESP Spanish_Spain.1252 + ESR Spanish_Peru.1252 + ESS Spanish_Argentina.1252 + ESU Spanish_Puerto Rico.1252 + ESV Spanish_Venezuela.1252 + ESY Spanish_Uruguay.1252 + ESZ Spanish_Paraguay.1252 + ETI Estonian_Estonia.1257 + EUQ Basque_Spain.1252 + FAR Farsi_Iran.1256 + FIN Finnish_Finland.1252 + FOS Faroese_Faroe Islands.1252 + FPO Filipino_Philippines.1252 + FRA French_France.1252 + FRB French_Belgium.1252 + FRC French_Canada.1252 + FRL French_Luxembourg.1252 + FRM French_Principality of Monaco.1252 + FRS French_Switzerland.1252 + FYN Frisian_Netherlands.1252 + GLC Galician_Spain.1252 + HEB Hebrew_Israel.1255 + HRB Croatian_Bosnia and Herzegovina.1250 + HRV Croatian_Croatia.1250 + HUN Hungarian_Hungary.1250 + IND Indonesian_Indonesia.1252 + IRE Irish_Ireland.1252 + ISL Icelandic_Iceland.1252 + ITA Italian_Italy.1252 + ITS Italian_Switzerland.1252 + IUK Inuktitut (Latin)_Canada.1252 + JPN Japanese_Japan.932 + KKZ Kazakh_Kazakhstan.1251 + KOR Korean_Korea.949 + KYR Kyrgyz_Kyrgyzstan.1251 + LBX Luxembourgish_Luxembourg.1252 + LTH Lithuanian_Lithuania.1257 + LVI Latvian_Latvia.1257 + MKI FYRO Macedonian_Former Yugoslav Republic of Macedonia.1251 + MON Mongolian_Mongolia.1251 + MPD Mapudungun_Chile.1252 + MSB Malay_Brunei Darussalam.1252 + MSL Malay_Malaysia.1252 + MWK Mohawk_Canada.1252 + NLB Dutch_Belgium.1252 + NLD Dutch_Netherlands.1252 + NON Norwegian-Nynorsk_Norway.1252 + NOR Norwegian (Bokmål)_Norway.1252 + NSO Northern Sotho_South Africa.1252 + PLK Polish_Poland.1250 + PTB Portuguese_Brazil.1252 + PTG Portuguese_Portugal.1252 + QUB Quechua_Bolivia.1252 + QUE Quechua_Ecuador.1252 + QUP Quechua_Peru.1252 + RMC Romansh_Switzerland.1252 + ROM Romanian_Romania.1250 + RUS Russian_Russia.1251 + SKY Slovak_Slovakia.1250 + SLV Slovenian_Slovenia.1250 + SMA Sami (Southern)_Norway.1252 + SMB Sami (Southern)_Sweden.1252 + SME Sami (Northern)_Norway.1252 + SMF Sami (Northern)_Sweden.1252 + SMG Sami (Northern)_Finland.1252 + SMJ Sami (Lule)_Norway.1252 + SMK Sami (Lule)_Sweden.1252 + SMN Sami (Inari)_Finland.1252 + SMS Sami (Skolt)_Finland.1252 + SQI Albanian_Albania.1250 + SRB Serbian (Cyrillic)_Serbia and Montenegro.1251 + SRL Serbian (Latin)_Serbia and Montenegro.1250 + SRN Serbian (Cyrillic)_Bosnia and Herzegovina.1251 + SRS Serbian (Latin)_Bosnia and Herzegovina.1250 + SVE Swedish_Sweden.1252 + SVF Swedish_Finland.1252 + SWK Swahili_Kenya.1252 + THA Thai_Thailand.874 + TRK Turkish_Turkey.1254 + TSN Tswana_South Africa.1252 + TTT Tatar_Russia.1251 + UKR Ukrainian_Ukraine.1251 + URD Urdu_Islamic Republic of Pakistan.1256 + USA English_United States.1252 + UZB Uzbek (Latin)_Uzbekistan.1254 + VIT Vietnamese_Viet Nam.1258 + XHO Xhosa_South Africa.1252 + ZHH Chinese_Hong Kong S.A.R..950 + ZHI Chinese_Singapore.936 + ZHM Chinese_Macau S.A.R..950 + ZUL Zulu_South Africa.1252 + */ + +/* Table from ISO 639 language code, optionally with country or script suffix, + to English name. + Keep in sync with the gl_locale_name_from_win32_LANGID function in + localename.c! */ +struct table_entry +{ + const char *code; + const char *english; +}; +static const struct table_entry language_table[] = + { + { "af", "Afrikaans" }, + { "am", "Amharic" }, + { "ar", "Arabic" }, + { "arn", "Mapudungun" }, + { "as", "Assamese" }, + { "az@cyrillic", "Azeri (Cyrillic)" }, + { "az@latin", "Azeri (Latin)" }, + { "ba", "Bashkir" }, + { "be", "Belarusian" }, + { "ber", "Tamazight" }, + { "ber@arabic", "Tamazight (Arabic)" }, + { "ber@latin", "Tamazight (Latin)" }, + { "bg", "Bulgarian" }, + { "bin", "Edo" }, + { "bn", "Bengali" }, + { "bn_BD", "Bengali (Bangladesh)" }, + { "bn_IN", "Bengali (India)" }, + { "bnt", "Sutu" }, + { "bo", "Tibetan" }, + { "br", "Breton" }, + { "bs", "BSB" }, /* "Bosnian (Latin)" */ + { "bs@cyrillic", "BSC" }, /* Bosnian (Cyrillic) */ + { "ca", "Catalan" }, + { "chr", "Cherokee" }, + { "co", "Corsican" }, + { "cpe", "Hawaiian" }, + { "cs", "Czech" }, + { "cy", "Welsh" }, + { "da", "Danish" }, + { "de", "German" }, + { "dsb", "Lower Sorbian" }, + { "dv", "Divehi" }, + { "el", "Greek" }, + { "en", "English" }, + { "es", "Spanish" }, + { "et", "Estonian" }, + { "eu", "Basque" }, + { "fa", "Farsi" }, + { "ff", "Fulfulde" }, + { "fi", "Finnish" }, + { "fo", "Faroese" }, /* "Faeroese" does not work */ + { "fr", "French" }, + { "fy", "Frisian" }, + { "ga", "IRE" }, /* Gaelic (Ireland) */ + { "gd", "Gaelic (Scotland)" }, + { "gd", "Scottish Gaelic" }, + { "gl", "Galician" }, + { "gn", "Guarani" }, + { "gsw", "Alsatian" }, + { "gu", "Gujarati" }, + { "ha", "Hausa" }, + { "he", "Hebrew" }, + { "hi", "Hindi" }, + { "hr", "Croatian" }, + { "hsb", "Upper Sorbian" }, + { "hu", "Hungarian" }, + { "hy", "Armenian" }, + { "id", "Indonesian" }, + { "ig", "Igbo" }, + { "ii", "Yi" }, + { "is", "Icelandic" }, + { "it", "Italian" }, + { "iu", "IUK" }, /* Inuktitut */ + { "ja", "Japanese" }, + { "ka", "Georgian" }, + { "kk", "Kazakh" }, + { "kl", "Greenlandic" }, + { "km", "Cambodian" }, + { "km", "Khmer" }, + { "kn", "Kannada" }, + { "ko", "Korean" }, + { "kok", "Konkani" }, + { "kr", "Kanuri" }, + { "ks", "Kashmiri" }, + { "ks_IN", "Kashmiri_India" }, + { "ks_PK", "Kashmiri (Arabic)_Pakistan" }, + { "ky", "Kyrgyz" }, + { "la", "Latin" }, + { "lb", "Luxembourgish" }, + { "lo", "Lao" }, + { "lt", "Lithuanian" }, + { "lv", "Latvian" }, + { "mi", "Maori" }, + { "mk", "FYRO Macedonian" }, + { "mk", "Macedonian" }, + { "ml", "Malayalam" }, + { "mn", "Mongolian" }, + { "mni", "Manipuri" }, + { "moh", "Mohawk" }, + { "mr", "Marathi" }, + { "ms", "Malay" }, + { "mt", "Maltese" }, + { "my", "Burmese" }, + { "nb", "NOR" }, /* Norwegian Bokmål */ + { "ne", "Nepali" }, + { "nic", "Ibibio" }, + { "nl", "Dutch" }, + { "nn", "NON" }, /* Norwegian Nynorsk */ + { "no", "Norwegian" }, + { "nso", "Northern Sotho" }, + { "nso", "Sepedi" }, + { "oc", "Occitan" }, + { "om", "Oromo" }, + { "or", "Oriya" }, + { "pa", "Punjabi" }, + { "pap", "Papiamentu" }, + { "pl", "Polish" }, + { "prs", "Dari" }, + { "ps", "Pashto" }, + { "pt", "Portuguese" }, + { "qu", "Quechua" }, + { "qut", "K'iche'" }, + { "rm", "Romansh" }, + { "ro", "Romanian" }, + { "ru", "Russian" }, + { "rw", "Kinyarwanda" }, + { "sa", "Sanskrit" }, + { "sah", "Yakut" }, + { "sd", "Sindhi" }, + { "se", "Sami (Northern)" }, + { "se", "Northern Sami" }, + { "si", "Sinhalese" }, + { "sk", "Slovak" }, + { "sl", "Slovenian" }, + { "sma", "Sami (Southern)" }, + { "sma", "Southern Sami" }, + { "smj", "Sami (Lule)" }, + { "smj", "Lule Sami" }, + { "smn", "Sami (Inari)" }, + { "smn", "Inari Sami" }, + { "sms", "Sami (Skolt)" }, + { "sms", "Skolt Sami" }, + { "so", "Somali" }, + { "sq", "Albanian" }, + { "sr", "Serbian (Latin)" }, + { "sr@cyrillic", "SRB" }, /* Serbian (Cyrillic) */ + { "sv", "Swedish" }, + { "sw", "Swahili" }, + { "syr", "Syriac" }, + { "ta", "Tamil" }, + { "te", "Telugu" }, + { "tg", "Tajik" }, + { "th", "Thai" }, + { "ti", "Tigrinya" }, + { "tk", "Turkmen" }, + { "tl", "Filipino" }, + { "tn", "Tswana" }, + { "tr", "Turkish" }, + { "ts", "Tsonga" }, + { "tt", "Tatar" }, + { "ug", "Uighur" }, + { "uk", "Ukrainian" }, + { "ur", "Urdu" }, + { "uz", "Uzbek" }, + { "uz", "Uzbek (Latin)" }, + { "uz@cyrillic", "Uzbek (Cyrillic)" }, + { "ve", "Venda" }, + { "vi", "Vietnamese" }, + { "wen", "Sorbian" }, + { "wo", "Wolof" }, + { "xh", "Xhosa" }, + { "yi", "Yiddish" }, + { "yo", "Yoruba" }, + { "zh", "Chinese" }, + { "zu", "Zulu" } + }; + +/* Table from ISO 3166 country code to English name. + Keep in sync with the gl_locale_name_from_win32_LANGID function in + localename.c! */ +static const struct table_entry country_table[] = + { + { "AE", "U.A.E." }, + { "AF", "Afghanistan" }, + { "AL", "Albania" }, + { "AM", "Armenia" }, + { "AN", "Netherlands Antilles" }, + { "AR", "Argentina" }, + { "AT", "Austria" }, + { "AU", "Australia" }, + { "AZ", "Azerbaijan" }, + { "BA", "Bosnia and Herzegovina" }, + { "BD", "Bangladesh" }, + { "BE", "Belgium" }, + { "BG", "Bulgaria" }, + { "BH", "Bahrain" }, + { "BN", "Brunei Darussalam" }, + { "BO", "Bolivia" }, + { "BR", "Brazil" }, + { "BT", "Bhutan" }, + { "BY", "Belarus" }, + { "BZ", "Belize" }, + { "CA", "Canada" }, + { "CG", "Congo" }, + { "CH", "Switzerland" }, + { "CI", "Cote d'Ivoire" }, + { "CL", "Chile" }, + { "CM", "Cameroon" }, + { "CN", "People's Republic of China" }, + { "CO", "Colombia" }, + { "CR", "Costa Rica" }, + { "CS", "Serbia and Montenegro" }, + { "CZ", "Czech Republic" }, + { "DE", "Germany" }, + { "DK", "Denmark" }, + { "DO", "Dominican Republic" }, + { "DZ", "Algeria" }, + { "EC", "Ecuador" }, + { "EE", "Estonia" }, + { "EG", "Egypt" }, + { "ER", "Eritrea" }, + { "ES", "Spain" }, + { "ET", "Ethiopia" }, + { "FI", "Finland" }, + { "FO", "Faroe Islands" }, + { "FR", "France" }, + { "GB", "United Kingdom" }, + { "GD", "Caribbean" }, + { "GE", "Georgia" }, + { "GL", "Greenland" }, + { "GR", "Greece" }, + { "GT", "Guatemala" }, + { "HK", "Hong Kong" }, + { "HK", "Hong Kong S.A.R." }, + { "HN", "Honduras" }, + { "HR", "Croatia" }, + { "HT", "Haiti" }, + { "HU", "Hungary" }, + { "ID", "Indonesia" }, + { "IE", "Ireland" }, + { "IL", "Israel" }, + { "IN", "India" }, + { "IQ", "Iraq" }, + { "IR", "Iran" }, + { "IS", "Iceland" }, + { "IT", "Italy" }, + { "JM", "Jamaica" }, + { "JO", "Jordan" }, + { "JP", "Japan" }, + { "KE", "Kenya" }, + { "KG", "Kyrgyzstan" }, + { "KH", "Cambodia" }, + { "KR", "South Korea" }, + { "KW", "Kuwait" }, + { "KZ", "Kazakhstan" }, + { "LA", "Laos" }, + { "LB", "Lebanon" }, + { "LI", "Liechtenstein" }, + { "LK", "Sri Lanka" }, + { "LT", "Lithuania" }, + { "LU", "Luxembourg" }, + { "LV", "Latvia" }, + { "LY", "Libya" }, + { "MA", "Morocco" }, + { "MC", "Principality of Monaco" }, + { "MD", "Moldava" }, + { "MD", "Moldova" }, + { "ME", "Montenegro" }, + { "MK", "Former Yugoslav Republic of Macedonia" }, + { "ML", "Mali" }, + { "MM", "Myanmar" }, + { "MN", "Mongolia" }, + { "MO", "Macau S.A.R." }, + { "MT", "Malta" }, + { "MV", "Maldives" }, + { "MX", "Mexico" }, + { "MY", "Malaysia" }, + { "NG", "Nigeria" }, + { "NI", "Nicaragua" }, + { "NL", "Netherlands" }, + { "NO", "Norway" }, + { "NP", "Nepal" }, + { "NZ", "New Zealand" }, + { "OM", "Oman" }, + { "PA", "Panama" }, + { "PE", "Peru" }, + { "PH", "Philippines" }, + { "PK", "Islamic Republic of Pakistan" }, + { "PL", "Poland" }, + { "PR", "Puerto Rico" }, + { "PT", "Portugal" }, + { "PY", "Paraguay" }, + { "QA", "Qatar" }, + { "RE", "Reunion" }, + { "RO", "Romania" }, + { "RS", "Serbia" }, + { "RU", "Russia" }, + { "RW", "Rwanda" }, + { "SA", "Saudi Arabia" }, + { "SE", "Sweden" }, + { "SG", "Singapore" }, + { "SI", "Slovenia" }, + { "SK", "Slovak" }, + { "SN", "Senegal" }, + { "SO", "Somalia" }, + { "SR", "Suriname" }, + { "SV", "El Salvador" }, + { "SY", "Syria" }, + { "TH", "Thailand" }, + { "TJ", "Tajikistan" }, + { "TM", "Turkmenistan" }, + { "TN", "Tunisia" }, + { "TR", "Turkey" }, + { "TT", "Trinidad and Tobago" }, + { "TW", "Taiwan" }, + { "TZ", "Tanzania" }, + { "UA", "Ukraine" }, + { "US", "United States" }, + { "UY", "Uruguay" }, + { "VA", "Vatican" }, + { "VE", "Venezuela" }, + { "VN", "Viet Nam" }, + { "YE", "Yemen" }, + { "ZA", "South Africa" }, + { "ZW", "Zimbabwe" } + }; + +/* Given a string STRING, find the set of indices i such that TABLE[i].code is + the given STRING. It is a range [lo,hi-1]. */ +typedef struct { size_t lo; size_t hi; } range_t; +static void +search (const struct table_entry *table, size_t table_size, const char *string, + range_t *result) +{ + /* The table is sorted. Perform a binary search. */ + size_t hi = table_size; + size_t lo = 0; + while (lo < hi) + { + /* Invariant: + for i < lo, strcmp (table[i].code, string) < 0, + for i >= hi, strcmp (table[i].code, string) > 0. */ + size_t mid = (hi + lo) >> 1; /* >= lo, < hi */ + int cmp = strcmp (table[mid].code, string); + if (cmp < 0) + lo = mid + 1; + else if (cmp > 0) + hi = mid; + else + { + /* Found an i with + strcmp (language_table[i].code, string) == 0. + Find the entire interval of such i. */ + { + size_t i; + + for (i = mid; i > lo; ) + { + i--; + if (strcmp (table[i].code, string) < 0) + { + lo = i + 1; + break; + } + } + } + { + size_t i; + + for (i = mid + 1; i < hi; i++) + { + if (strcmp (table[i].code, string) > 0) + { + hi = i; + break; + } + } + } + /* The set of i with + strcmp (language_table[i].code, string) == 0 + is the interval [lo, hi-1]. */ + break; + } + } + result->lo = lo; + result->hi = hi; +} + +/* Like setlocale, but accept also locale names in the form ll or ll_CC, + where ll is an ISO 639 language code and CC is an ISO 3166 country code. */ +static char * +setlocale_unixlike (int category, const char *locale) +{ + char *result; + char llCC_buf[64]; + char ll_buf[64]; + char CC_buf[64]; + + /* The native Windows implementation of setlocale understands the special + locale name "C", but not "POSIX". Therefore map "POSIX" to "C". */ + if (locale != NULL && strcmp (locale, "POSIX") == 0) + locale = "C"; + + /* First, try setlocale with the original argument unchanged. */ + result = setlocale_mtsafe (category, locale); + if (result != NULL) + return result; + + /* Otherwise, assume the argument is in the form + language[_territory][.codeset][@modifier] + and try to map it using the tables. */ + if (strlen (locale) < sizeof (llCC_buf)) + { + /* Second try: Remove the codeset part. */ + { + const char *p = locale; + char *q = llCC_buf; + + /* Copy the part before the dot. */ + for (; *p != '\0' && *p != '.'; p++, q++) + *q = *p; + if (*p == '.') + /* Skip the part up to the '@', if any. */ + for (; *p != '\0' && *p != '@'; p++) + ; + /* Copy the part starting with '@', if any. */ + for (; *p != '\0'; p++, q++) + *q = *p; + *q = '\0'; + } + /* llCC_buf now contains + language[_territory][@modifier] + */ + if (strcmp (llCC_buf, locale) != 0) + { + result = setlocale (category, llCC_buf); + if (result != NULL) + return result; + } + /* Look it up in language_table. */ + { + range_t range; + size_t i; + + search (language_table, + sizeof (language_table) / sizeof (language_table[0]), + llCC_buf, + &range); + + for (i = range.lo; i < range.hi; i++) + { + /* Try the replacement in language_table[i]. */ + result = setlocale (category, language_table[i].english); + if (result != NULL) + return result; + } + } + /* Split language[_territory][@modifier] + into ll_buf = language[@modifier] + and CC_buf = territory + */ + { + const char *underscore = strchr (llCC_buf, '_'); + if (underscore != NULL) + { + const char *territory_start = underscore + 1; + const char *territory_end = strchr (territory_start, '@'); + if (territory_end == NULL) + territory_end = territory_start + strlen (territory_start); + + memcpy (ll_buf, llCC_buf, underscore - llCC_buf); + strcpy (ll_buf + (underscore - llCC_buf), territory_end); + + memcpy (CC_buf, territory_start, territory_end - territory_start); + CC_buf[territory_end - territory_start] = '\0'; + + { + /* Look up ll_buf in language_table + and CC_buf in country_table. */ + range_t language_range; + + search (language_table, + sizeof (language_table) / sizeof (language_table[0]), + ll_buf, + &language_range); + if (language_range.lo < language_range.hi) + { + range_t country_range; + + search (country_table, + sizeof (country_table) / sizeof (country_table[0]), + CC_buf, + &country_range); + if (country_range.lo < country_range.hi) + { + size_t i; + size_t j; + + for (i = language_range.lo; i < language_range.hi; i++) + for (j = country_range.lo; j < country_range.hi; j++) + { + /* Concatenate the replacements. */ + const char *part1 = language_table[i].english; + size_t part1_len = strlen (part1); + const char *part2 = country_table[j].english; + size_t part2_len = strlen (part2) + 1; + char buf[64+64]; + + if (!(part1_len + 1 + part2_len <= sizeof (buf))) + abort (); + memcpy (buf, part1, part1_len); + buf[part1_len] = '_'; + memcpy (buf + part1_len + 1, part2, part2_len); + + /* Try the concatenated replacements. */ + result = setlocale (category, buf); + if (result != NULL) + return result; + } + } + + /* Try omitting the country entirely. This may set a locale + corresponding to the wrong country, but is better than + failing entirely. */ + { + size_t i; + + for (i = language_range.lo; i < language_range.hi; i++) + { + /* Try only the language replacement. */ + result = + setlocale (category, language_table[i].english); + if (result != NULL) + return result; + } + } + } + } + } + } + } + + /* Failed. */ + return NULL; +} + +# elif defined __ANDROID__ + +/* Like setlocale, but accept also the locale names "C" and "POSIX". */ +static char * +setlocale_unixlike (int category, const char *locale) +{ + char *result = setlocale_mtsafe (category, locale); + if (result == NULL) + switch (category) + { + case LC_CTYPE: + case LC_NUMERIC: + case LC_TIME: + case LC_COLLATE: + case LC_MONETARY: + case LC_MESSAGES: + case LC_ALL: + case LC_PAPER: + case LC_NAME: + case LC_ADDRESS: + case LC_TELEPHONE: + case LC_MEASUREMENT: + if (locale == NULL + || strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0) + result = (char *) "C"; + break; + default: + break; + } + return result; +} +# define setlocale setlocale_unixlike + +# else +# define setlocale_unixlike setlocale_mtsafe +# endif + +# if LC_MESSAGES == 1729 + +/* The system does not store an LC_MESSAGES locale category. Do it here. */ +static char lc_messages_name[64] = "C"; + +/* Like setlocale, but support also LC_MESSAGES. */ +static char * +setlocale_single (int category, const char *locale) +{ + if (category == LC_MESSAGES) + { + if (locale != NULL) + { + lc_messages_name[sizeof (lc_messages_name) - 1] = '\0'; + strncpy (lc_messages_name, locale, sizeof (lc_messages_name) - 1); + } + return lc_messages_name; + } + else + return setlocale_unixlike (category, locale); +} + +# else +# define setlocale_single setlocale_unixlike +# endif + +# if defined __APPLE__ && defined __MACH__ + +/* Mapping from language to main territory where that language is spoken. */ +static char const locales_with_principal_territory[][6 + 1] = + { + /* Language Main territory */ + "ace_ID", /* Achinese Indonesia */ + "af_ZA", /* Afrikaans South Africa */ + "ak_GH", /* Akan Ghana */ + "am_ET", /* Amharic Ethiopia */ + "an_ES", /* Aragonese Spain */ + "ang_GB", /* Old English Britain */ + "arn_CL", /* Mapudungun Chile */ + "as_IN", /* Assamese India */ + "ast_ES", /* Asturian Spain */ + "av_RU", /* Avaric Russia */ + "awa_IN", /* Awadhi India */ + "az_AZ", /* Azerbaijani Azerbaijan */ + "ban_ID", /* Balinese Indonesia */ + "be_BY", /* Belarusian Belarus */ + "bej_SD", /* Beja Sudan */ + "bem_ZM", /* Bemba Zambia */ + "bg_BG", /* Bulgarian Bulgaria */ + "bho_IN", /* Bhojpuri India */ + "bi_VU", /* Bislama Vanuatu */ + "bik_PH", /* Bikol Philippines */ + "bin_NG", /* Bini Nigeria */ + "bm_ML", /* Bambara Mali */ + "bn_IN", /* Bengali India */ + "bo_CN", /* Tibetan China */ + "br_FR", /* Breton France */ + "bs_BA", /* Bosnian Bosnia */ + "bug_ID", /* Buginese Indonesia */ + "ca_ES", /* Catalan Spain */ + "ce_RU", /* Chechen Russia */ + "ceb_PH", /* Cebuano Philippines */ + "co_FR", /* Corsican France */ + "cr_CA", /* Cree Canada */ + /* Don't put "crh_UZ" or "crh_UA" here. That would be asking for fruitless + political discussion. */ + "cs_CZ", /* Czech Czech Republic */ + "csb_PL", /* Kashubian Poland */ + "cy_GB", /* Welsh Britain */ + "da_DK", /* Danish Denmark */ + "de_DE", /* German Germany */ + "din_SD", /* Dinka Sudan */ + "doi_IN", /* Dogri India */ + "dsb_DE", /* Lower Sorbian Germany */ + "dv_MV", /* Divehi Maldives */ + "dz_BT", /* Dzongkha Bhutan */ + "ee_GH", /* Éwé Ghana */ + "el_GR", /* Greek Greece */ + /* Don't put "en_GB" or "en_US" here. That would be asking for fruitless + political discussion. */ + "es_ES", /* Spanish Spain */ + "et_EE", /* Estonian Estonia */ + "fa_IR", /* Persian Iran */ + "fi_FI", /* Finnish Finland */ + "fil_PH", /* Filipino Philippines */ + "fj_FJ", /* Fijian Fiji */ + "fo_FO", /* Faroese Faeroe Islands */ + "fon_BJ", /* Fon Benin */ + "fr_FR", /* French France */ + "fur_IT", /* Friulian Italy */ + "fy_NL", /* Western Frisian Netherlands */ + "ga_IE", /* Irish Ireland */ + "gd_GB", /* Scottish Gaelic Britain */ + "gon_IN", /* Gondi India */ + "gsw_CH", /* Swiss German Switzerland */ + "gu_IN", /* Gujarati India */ + "he_IL", /* Hebrew Israel */ + "hi_IN", /* Hindi India */ + "hil_PH", /* Hiligaynon Philippines */ + "hr_HR", /* Croatian Croatia */ + "hsb_DE", /* Upper Sorbian Germany */ + "ht_HT", /* Haitian Haiti */ + "hu_HU", /* Hungarian Hungary */ + "hy_AM", /* Armenian Armenia */ + "id_ID", /* Indonesian Indonesia */ + "ig_NG", /* Igbo Nigeria */ + "ii_CN", /* Sichuan Yi China */ + "ilo_PH", /* Iloko Philippines */ + "is_IS", /* Icelandic Iceland */ + "it_IT", /* Italian Italy */ + "ja_JP", /* Japanese Japan */ + "jab_NG", /* Hyam Nigeria */ + "jv_ID", /* Javanese Indonesia */ + "ka_GE", /* Georgian Georgia */ + "kab_DZ", /* Kabyle Algeria */ + "kaj_NG", /* Jju Nigeria */ + "kam_KE", /* Kamba Kenya */ + "kmb_AO", /* Kimbundu Angola */ + "kcg_NG", /* Tyap Nigeria */ + "kdm_NG", /* Kagoma Nigeria */ + "kg_CD", /* Kongo Democratic Republic of Congo */ + "kk_KZ", /* Kazakh Kazakhstan */ + "kl_GL", /* Kalaallisut Greenland */ + "km_KH", /* Central Khmer Cambodia */ + "kn_IN", /* Kannada India */ + "ko_KR", /* Korean Korea (South) */ + "kok_IN", /* Konkani India */ + "kr_NG", /* Kanuri Nigeria */ + "kru_IN", /* Kurukh India */ + "ky_KG", /* Kyrgyz Kyrgyzstan */ + "lg_UG", /* Ganda Uganda */ + "li_BE", /* Limburgish Belgium */ + "lo_LA", /* Laotian Laos */ + "lt_LT", /* Lithuanian Lithuania */ + "lu_CD", /* Luba-Katanga Democratic Republic of Congo */ + "lua_CD", /* Luba-Lulua Democratic Republic of Congo */ + "luo_KE", /* Luo Kenya */ + "lv_LV", /* Latvian Latvia */ + "mad_ID", /* Madurese Indonesia */ + "mag_IN", /* Magahi India */ + "mai_IN", /* Maithili India */ + "mak_ID", /* Makasar Indonesia */ + "man_ML", /* Mandingo Mali */ + "men_SL", /* Mende Sierra Leone */ + "mfe_MU", /* Mauritian Creole Mauritius */ + "mg_MG", /* Malagasy Madagascar */ + "mi_NZ", /* Maori New Zealand */ + "min_ID", /* Minangkabau Indonesia */ + "mk_MK", /* Macedonian North Macedonia */ + "ml_IN", /* Malayalam India */ + "mn_MN", /* Mongolian Mongolia */ + "mni_IN", /* Manipuri India */ + "mos_BF", /* Mossi Burkina Faso */ + "mr_IN", /* Marathi India */ + "ms_MY", /* Malay Malaysia */ + "mt_MT", /* Maltese Malta */ + "mwr_IN", /* Marwari India */ + "my_MM", /* Burmese Myanmar */ + "na_NR", /* Nauru Nauru */ + "nah_MX", /* Nahuatl Mexico */ + "nap_IT", /* Neapolitan Italy */ + "nb_NO", /* Norwegian Bokmål Norway */ + "nds_DE", /* Low Saxon Germany */ + "ne_NP", /* Nepali Nepal */ + "nl_NL", /* Dutch Netherlands */ + "nn_NO", /* Norwegian Nynorsk Norway */ + "no_NO", /* Norwegian Norway */ + "nr_ZA", /* South Ndebele South Africa */ + "nso_ZA", /* Northern Sotho South Africa */ + "ny_MW", /* Chichewa Malawi */ + "nym_TZ", /* Nyamwezi Tanzania */ + "nyn_UG", /* Nyankole Uganda */ + "oc_FR", /* Occitan France */ + "oj_CA", /* Ojibwa Canada */ + "or_IN", /* Oriya India */ + "pa_IN", /* Punjabi India */ + "pag_PH", /* Pangasinan Philippines */ + "pam_PH", /* Pampanga Philippines */ + "pap_AN", /* Papiamento Netherlands Antilles - this line can be removed in 2018 */ + "pbb_CO", /* Páez Colombia */ + "pl_PL", /* Polish Poland */ + "ps_AF", /* Pashto Afghanistan */ + "pt_PT", /* Portuguese Portugal */ + "raj_IN", /* Rajasthani India */ + "rm_CH", /* Romansh Switzerland */ + "rn_BI", /* Kirundi Burundi */ + "ro_RO", /* Romanian Romania */ + "ru_RU", /* Russian Russia */ + "rw_RW", /* Kinyarwanda Rwanda */ + "sa_IN", /* Sanskrit India */ + "sah_RU", /* Yakut Russia */ + "sas_ID", /* Sasak Indonesia */ + "sat_IN", /* Santali India */ + "sc_IT", /* Sardinian Italy */ + "scn_IT", /* Sicilian Italy */ + "sg_CF", /* Sango Central African Republic */ + "shn_MM", /* Shan Myanmar */ + "si_LK", /* Sinhala Sri Lanka */ + "sid_ET", /* Sidamo Ethiopia */ + "sk_SK", /* Slovak Slovakia */ + "sl_SI", /* Slovenian Slovenia */ + "sm_WS", /* Samoan Samoa */ + "smn_FI", /* Inari Sami Finland */ + "sms_FI", /* Skolt Sami Finland */ + "so_SO", /* Somali Somalia */ + "sq_AL", /* Albanian Albania */ + "sr_RS", /* Serbian Serbia */ + "srr_SN", /* Serer Senegal */ + "suk_TZ", /* Sukuma Tanzania */ + "sus_GN", /* Susu Guinea */ + "sv_SE", /* Swedish Sweden */ + "te_IN", /* Telugu India */ + "tem_SL", /* Timne Sierra Leone */ + "tet_ID", /* Tetum Indonesia */ + "tg_TJ", /* Tajik Tajikistan */ + "th_TH", /* Thai Thailand */ + "ti_ER", /* Tigrinya Eritrea */ + "tiv_NG", /* Tiv Nigeria */ + "tk_TM", /* Turkmen Turkmenistan */ + "tl_PH", /* Tagalog Philippines */ + "to_TO", /* Tonga Tonga */ + "tpi_PG", /* Tok Pisin Papua New Guinea */ + "tr_TR", /* Turkish Turkey */ + "tum_MW", /* Tumbuka Malawi */ + "ug_CN", /* Uighur China */ + "uk_UA", /* Ukrainian Ukraine */ + "umb_AO", /* Umbundu Angola */ + "ur_PK", /* Urdu Pakistan */ + "uz_UZ", /* Uzbek Uzbekistan */ + "ve_ZA", /* Venda South Africa */ + "vi_VN", /* Vietnamese Vietnam */ + "wa_BE", /* Walloon Belgium */ + "wal_ET", /* Walamo Ethiopia */ + "war_PH", /* Waray Philippines */ + "wen_DE", /* Sorbian Germany */ + "yao_MW", /* Yao Malawi */ + "zap_MX" /* Zapotec Mexico */ + }; + +/* Compare just the language part of two locale names. */ +static int +langcmp (const char *locale1, const char *locale2) +{ + size_t locale1_len; + size_t locale2_len; + int cmp; + + { + const char *locale1_end = strchr (locale1, '_'); + if (locale1_end != NULL) + locale1_len = locale1_end - locale1; + else + locale1_len = strlen (locale1); + } + { + const char *locale2_end = strchr (locale2, '_'); + if (locale2_end != NULL) + locale2_len = locale2_end - locale2; + else + locale2_len = strlen (locale2); + } + + if (locale1_len < locale2_len) + { + cmp = memcmp (locale1, locale2, locale1_len); + if (cmp == 0) + cmp = -1; + } + else + { + cmp = memcmp (locale1, locale2, locale2_len); + if (locale1_len > locale2_len && cmp == 0) + cmp = 1; + } + + return cmp; +} + +/* Given a locale name, return the main locale with the same language, + or NULL if not found. + For example: "fr_DE" -> "fr_FR". */ +static const char * +get_main_locale_with_same_language (const char *locale) +{ +# define table locales_with_principal_territory + /* The table is sorted. Perform a binary search. */ + size_t hi = sizeof (table) / sizeof (table[0]); + size_t lo = 0; + while (lo < hi) + { + /* Invariant: + for i < lo, langcmp (table[i], locale) < 0, + for i >= hi, langcmp (table[i], locale) > 0. */ + size_t mid = (hi + lo) >> 1; /* >= lo, < hi */ + int cmp = langcmp (table[mid], locale); + if (cmp < 0) + lo = mid + 1; + else if (cmp > 0) + hi = mid; + else + { + /* Found an i with + langcmp (language_table[i], locale) == 0. + Verify that it is the only such i. */ + if (mid > lo && langcmp (table[mid - 1], locale) >= 0) + abort (); + if (mid + 1 < hi && langcmp (table[mid + 1], locale) <= 0) + abort (); + return table[mid]; + } + } +# undef table + return NULL; +} + +/* Mapping from territory to main language that is spoken in that territory. */ +static char const locales_with_principal_language[][6 + 1] = + { + /* This is based on the set of existing locales in glibc, with duplicates + removed, and on the Wikipedia pages named "Languages of <territory>". + If in doubt, use the locale that exists in macOS. For example, the only + "*_IN" locale in macOS 10.13 is "hi_IN", so use that. */ + /* A useful shell function for producing a line of this table is: + func_line () + { + # Usage: func_line ll_CC + ll=`echo "$1" | sed -e 's|_.*||'` + cc=`echo "$1" | sed -e 's|^.*_||'` + llx=`sed -n -e "s|^${ll} ||p" < gettext-tools/doc/ISO_639` + ccx=`expand gettext-tools/doc/ISO_3166 | sed -n -e "s|^${cc} *||p"` + echo " \"$1\", /$X* ${llx} ${ccx} *$X/" + } + */ + /* Main language Territory */ + "ca_AD", /* Catalan Andorra */ + "ar_AE", /* Arabic United Arab Emirates */ + "ps_AF", /* Pashto Afghanistan */ + "en_AG", /* English Antigua and Barbuda */ + "sq_AL", /* Albanian Albania */ + "hy_AM", /* Armenian Armenia */ + "pap_AN", /* Papiamento Netherlands Antilles - this line can be removed in 2018 */ + "pt_AO", /* Portuguese Angola */ + "es_AR", /* Spanish Argentina */ + "de_AT", /* German Austria */ + "en_AU", /* English Australia */ + /* Aruba has two official languages: "nl_AW", "pap_AW". */ + "az_AZ", /* Azerbaijani Azerbaijan */ + "bs_BA", /* Bosnian Bosnia */ + "bn_BD", /* Bengali Bangladesh */ + "nl_BE", /* Dutch Belgium */ + "fr_BF", /* French Burkina Faso */ + "bg_BG", /* Bulgarian Bulgaria */ + "ar_BH", /* Arabic Bahrain */ + "rn_BI", /* Kirundi Burundi */ + "fr_BJ", /* French Benin */ + "es_BO", /* Spanish Bolivia */ + "pt_BR", /* Portuguese Brazil */ + "dz_BT", /* Dzongkha Bhutan */ + "en_BW", /* English Botswana */ + "be_BY", /* Belarusian Belarus */ + "en_CA", /* English Canada */ + "fr_CD", /* French Democratic Republic of Congo */ + "sg_CF", /* Sango Central African Republic */ + "de_CH", /* German Switzerland */ + "es_CL", /* Spanish Chile */ + "zh_CN", /* Chinese China */ + "es_CO", /* Spanish Colombia */ + "es_CR", /* Spanish Costa Rica */ + "es_CU", /* Spanish Cuba */ + /* Curaçao has three official languages: "nl_CW", "pap_CW", "en_CW". */ + "el_CY", /* Greek Cyprus */ + "cs_CZ", /* Czech Czech Republic */ + "de_DE", /* German Germany */ + /* Djibouti has two official languages: "ar_DJ" and "fr_DJ". */ + "da_DK", /* Danish Denmark */ + "es_DO", /* Spanish Dominican Republic */ + "ar_DZ", /* Arabic Algeria */ + "es_EC", /* Spanish Ecuador */ + "et_EE", /* Estonian Estonia */ + "ar_EG", /* Arabic Egypt */ + "ti_ER", /* Tigrinya Eritrea */ + "es_ES", /* Spanish Spain */ + "am_ET", /* Amharic Ethiopia */ + "fi_FI", /* Finnish Finland */ + /* Fiji has three official languages: "en_FJ", "fj_FJ", "hif_FJ". */ + "fo_FO", /* Faroese Faeroe Islands */ + "fr_FR", /* French France */ + "en_GB", /* English Britain */ + "ka_GE", /* Georgian Georgia */ + "en_GH", /* English Ghana */ + "kl_GL", /* Kalaallisut Greenland */ + "fr_GN", /* French Guinea */ + "el_GR", /* Greek Greece */ + "es_GT", /* Spanish Guatemala */ + "zh_HK", /* Chinese Hong Kong */ + "es_HN", /* Spanish Honduras */ + "hr_HR", /* Croatian Croatia */ + "ht_HT", /* Haitian Haiti */ + "hu_HU", /* Hungarian Hungary */ + "id_ID", /* Indonesian Indonesia */ + "en_IE", /* English Ireland */ + "he_IL", /* Hebrew Israel */ + "hi_IN", /* Hindi India */ + "ar_IQ", /* Arabic Iraq */ + "fa_IR", /* Persian Iran */ + "is_IS", /* Icelandic Iceland */ + "it_IT", /* Italian Italy */ + "ar_JO", /* Arabic Jordan */ + "ja_JP", /* Japanese Japan */ + "sw_KE", /* Swahili Kenya */ + "ky_KG", /* Kyrgyz Kyrgyzstan */ + "km_KH", /* Central Khmer Cambodia */ + "ko_KR", /* Korean Korea (South) */ + "ar_KW", /* Arabic Kuwait */ + "kk_KZ", /* Kazakh Kazakhstan */ + "lo_LA", /* Laotian Laos */ + "ar_LB", /* Arabic Lebanon */ + "de_LI", /* German Liechtenstein */ + "si_LK", /* Sinhala Sri Lanka */ + "lt_LT", /* Lithuanian Lithuania */ + /* Luxembourg has three official languages: "lb_LU", "fr_LU", "de_LU". */ + "lv_LV", /* Latvian Latvia */ + "ar_LY", /* Arabic Libya */ + "ar_MA", /* Arabic Morocco */ + "sr_ME", /* Serbian Montenegro */ + "mg_MG", /* Malagasy Madagascar */ + "mk_MK", /* Macedonian North Macedonia */ + "fr_ML", /* French Mali */ + "my_MM", /* Burmese Myanmar */ + "mn_MN", /* Mongolian Mongolia */ + "mt_MT", /* Maltese Malta */ + "mfe_MU", /* Mauritian Creole Mauritius */ + "dv_MV", /* Divehi Maldives */ + "ny_MW", /* Chichewa Malawi */ + "es_MX", /* Spanish Mexico */ + "ms_MY", /* Malay Malaysia */ + "en_NG", /* English Nigeria */ + "es_NI", /* Spanish Nicaragua */ + "nl_NL", /* Dutch Netherlands */ + "no_NO", /* Norwegian Norway */ + "ne_NP", /* Nepali Nepal */ + "na_NR", /* Nauru Nauru */ + "niu_NU", /* Niuean Niue */ + "en_NZ", /* English New Zealand */ + "ar_OM", /* Arabic Oman */ + "es_PA", /* Spanish Panama */ + "es_PE", /* Spanish Peru */ + "tpi_PG", /* Tok Pisin Papua New Guinea */ + "fil_PH", /* Filipino Philippines */ + "pa_PK", /* Punjabi Pakistan */ + "pl_PL", /* Polish Poland */ + "es_PR", /* Spanish Puerto Rico */ + "pt_PT", /* Portuguese Portugal */ + "es_PY", /* Spanish Paraguay */ + "ar_QA", /* Arabic Qatar */ + "ro_RO", /* Romanian Romania */ + "sr_RS", /* Serbian Serbia */ + "ru_RU", /* Russian Russia */ + "rw_RW", /* Kinyarwanda Rwanda */ + "ar_SA", /* Arabic Saudi Arabia */ + "en_SC", /* English Seychelles */ + "ar_SD", /* Arabic Sudan */ + "sv_SE", /* Swedish Sweden */ + "en_SG", /* English Singapore */ + "sl_SI", /* Slovenian Slovenia */ + "sk_SK", /* Slovak Slovakia */ + "en_SL", /* English Sierra Leone */ + "fr_SN", /* French Senegal */ + "so_SO", /* Somali Somalia */ + "ar_SS", /* Arabic South Sudan */ + "es_SV", /* Spanish El Salvador */ + "ar_SY", /* Arabic Syria */ + "th_TH", /* Thai Thailand */ + "tg_TJ", /* Tajik Tajikistan */ + "tk_TM", /* Turkmen Turkmenistan */ + "ar_TN", /* Arabic Tunisia */ + "to_TO", /* Tonga Tonga */ + "tr_TR", /* Turkish Turkey */ + "zh_TW", /* Chinese Taiwan */ + "sw_TZ", /* Swahili Tanzania */ + "uk_UA", /* Ukrainian Ukraine */ + "lg_UG", /* Ganda Uganda */ + "en_US", /* English United States of America */ + "es_UY", /* Spanish Uruguay */ + "uz_UZ", /* Uzbek Uzbekistan */ + "es_VE", /* Spanish Venezuela */ + "vi_VN", /* Vietnamese Vietnam */ + "bi_VU", /* Bislama Vanuatu */ + "sm_WS", /* Samoan Samoa */ + "ar_YE", /* Arabic Yemen */ + "en_ZA", /* English South Africa */ + "en_ZM", /* English Zambia */ + "en_ZW" /* English Zimbabwe */ + }; + +/* Compare just the territory part of two locale names. */ +static int +terrcmp (const char *locale1, const char *locale2) +{ + const char *territory1 = strrchr (locale1, '_') + 1; + const char *territory2 = strrchr (locale2, '_') + 1; + + return strcmp (territory1, territory2); +} + +/* Given a locale name, return the locale corresponding to the main language + with the same territory, or NULL if not found. + For example: "fr_DE" -> "de_DE". */ +static const char * +get_main_locale_with_same_territory (const char *locale) +{ + if (strrchr (locale, '_') != NULL) + { +# define table locales_with_principal_language + /* The table is sorted. Perform a binary search. */ + size_t hi = sizeof (table) / sizeof (table[0]); + size_t lo = 0; + while (lo < hi) + { + /* Invariant: + for i < lo, terrcmp (table[i], locale) < 0, + for i >= hi, terrcmp (table[i], locale) > 0. */ + size_t mid = (hi + lo) >> 1; /* >= lo, < hi */ + int cmp = terrcmp (table[mid], locale); + if (cmp < 0) + lo = mid + 1; + else if (cmp > 0) + hi = mid; + else + { + /* Found an i with + terrcmp (language_table[i], locale) == 0. + Verify that it is the only such i. */ + if (mid > lo && terrcmp (table[mid - 1], locale) >= 0) + abort (); + if (mid + 1 < hi && terrcmp (table[mid + 1], locale) <= 0) + abort (); + return table[mid]; + } + } +# undef table + } + return NULL; +} + +# endif + +char * +setlocale_improved (int category, const char *locale) +{ + if (locale != NULL && locale[0] == '\0') + { + /* A request to the set the current locale to the default locale. */ + if (category == LC_ALL) + { + /* Set LC_CTYPE first. Then the other categories. */ + static int const categories[] = + { + LC_CTYPE, + LC_NUMERIC, + LC_TIME, + LC_COLLATE, + LC_MONETARY, + LC_MESSAGES + }; + char *saved_locale; + const char *base_name; + unsigned int i; + + /* Back up the old locale, in case one of the steps fails. */ + saved_locale = setlocale (LC_ALL, NULL); + if (saved_locale == NULL) + return NULL; + saved_locale = strdup (saved_locale); + if (saved_locale == NULL) + return NULL; + + /* Set LC_CTYPE category. Set all other categories (except possibly + LC_MESSAGES) to the same value in the same call; this is likely to + save calls. */ + base_name = + gl_locale_name_environ (LC_CTYPE, category_to_name (LC_CTYPE)); + if (base_name == NULL) + base_name = gl_locale_name_default (); + + if (setlocale_unixlike (LC_ALL, base_name) != NULL) + { + /* LC_CTYPE category already set. */ + i = 1; + } + else + { + /* On Mac OS X, "UTF-8" is a valid locale name for LC_CTYPE but + not for LC_ALL. Therefore this call may fail. So, try + another base_name. */ + base_name = "C"; + if (setlocale_unixlike (LC_ALL, base_name) == NULL) + goto fail; + i = 0; + } +# if defined _WIN32 && ! defined __CYGWIN__ + /* On native Windows, setlocale(LC_ALL,...) may succeed but set the + LC_CTYPE category to an invalid value ("C") when it does not + support the specified encoding. Report a failure instead. */ + if (strchr (base_name, '.') != NULL + && strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) + goto fail; +# endif + + for (; i < sizeof (categories) / sizeof (categories[0]); i++) + { + int cat = categories[i]; + const char *name; + + name = gl_locale_name_environ (cat, category_to_name (cat)); + if (name == NULL) + name = gl_locale_name_default (); + + /* If name is the same as base_name, it has already been set + through the setlocale call before the loop. */ + if (strcmp (name, base_name) != 0 +# if LC_MESSAGES == 1729 + || cat == LC_MESSAGES +# endif + ) + if (setlocale_single (cat, name) == NULL) +# if defined __APPLE__ && defined __MACH__ + { + /* On Mac OS X 10.13, some locales can be set through + System Preferences > Language & Region, that are not + supported by libc. The system's setlocale() falls + back to "C" for these locale categories. We can do + better, by trying an existing locale with the same + language or an existing locale with the same territory. + If we can't, print a warning, to limit user + expectations. */ + int warn = 0; + + if (cat == LC_CTYPE) + warn = (setlocale_single (cat, "UTF-8") == NULL); + else if (cat == LC_MESSAGES) + { +# if HAVE_CFLOCALECOPYPREFERREDLANGUAGES || HAVE_CFPREFERENCESCOPYAPPVALUE /* MacOS X 10.4 or newer */ + /* Take the primary language preference. */ +# if HAVE_CFLOCALECOPYPREFERREDLANGUAGES /* MacOS X 10.5 or newer */ + CFArrayRef prefArray = CFLocaleCopyPreferredLanguages (); +# elif HAVE_CFPREFERENCESCOPYAPPVALUE /* MacOS X 10.4 or newer */ + CFTypeRef preferences = + CFPreferencesCopyAppValue (CFSTR ("AppleLanguages"), + kCFPreferencesCurrentApplication); + if (preferences != NULL + && CFGetTypeID (preferences) == CFArrayGetTypeID ()) + { + CFArrayRef prefArray = (CFArrayRef)preferences; +# endif + int n = CFArrayGetCount (prefArray); + if (n > 0) + { + char buf[256]; + CFTypeRef element = CFArrayGetValueAtIndex (prefArray, 0); + if (element != NULL + && CFGetTypeID (element) == CFStringGetTypeID () + && CFStringGetCString ((CFStringRef)element, + buf, sizeof (buf), + kCFStringEncodingASCII)) + { + /* Remove the country. + E.g. "zh-Hans-DE" -> "zh-Hans". */ + char *last_minus = strrchr (buf, '-'); + if (last_minus != NULL) + *last_minus = '\0'; + + /* Convert to Unix locale name. + E.g. "zh-Hans" -> "zh_CN". */ + gl_locale_name_canonicalize (buf); + + /* Try setlocale with this value. */ + if (setlocale_single (cat, buf) == NULL) + { + const char *last_try = + get_main_locale_with_same_language (buf); + + if (last_try == NULL + || setlocale_single (cat, last_try) == NULL) + warn = 1; + } + } + } +# if HAVE_CFLOCALECOPYPREFERREDLANGUAGES /* MacOS X 10.5 or newer */ + CFRelease (prefArray); +# elif HAVE_CFPREFERENCESCOPYAPPVALUE /* MacOS X 10.4 or newer */ + } +# endif +# else + const char *last_try = + get_main_locale_with_same_language (name); + + if (last_try == NULL + || setlocale_single (cat, last_try) == NULL) + warn = 1; +# endif + } + else + { + /* For LC_NUMERIC, the application should use the locale + properties kCFLocaleDecimalSeparator, + kCFLocaleGroupingSeparator. + For LC_TIME, the application should use the locale + property kCFLocaleCalendarIdentifier. + For LC_COLLATE, the application should use the locale + properties kCFLocaleCollationIdentifier, + kCFLocaleCollatorIdentifier. + For LC_MONETARY, the applicationshould use the locale + properties kCFLocaleCurrencySymbol, + kCFLocaleCurrencyCode. + But since most applications don't have macOS specific + code like this, try an existing locale with the same + territory. */ + const char *last_try = + get_main_locale_with_same_territory (name); + + if (last_try == NULL + || setlocale_single (cat, last_try) == NULL) + warn = 1; + } + + if (warn) + { + /* Warn only if the environment variable + SETLOCALE_VERBOSE is set. Otherwise these warnings + are just annoyances, since normal users won't invoke + 'localedef'. */ + const char *verbose = getenv ("SETLOCALE_VERBOSE"); + if (verbose != NULL && verbose[0] != '\0') + fprintf (stderr, + "Warning: Failed to set locale category %s to %s.\n", + category_to_name (cat), name); + } + } +# else + goto fail; +# endif + } + + /* All steps were successful. */ + free (saved_locale); + return setlocale (LC_ALL, NULL); + + fail: + if (saved_locale[0] != '\0') /* don't risk an endless recursion */ + setlocale (LC_ALL, saved_locale); + free (saved_locale); + return NULL; + } + else + { + const char *name = + gl_locale_name_environ (category, category_to_name (category)); + if (name == NULL) + name = gl_locale_name_default (); + + return setlocale_single (category, name); + } + } + else + { +# if defined _WIN32 && ! defined __CYGWIN__ + if (category == LC_ALL && locale != NULL && strchr (locale, '.') != NULL) + { + char *saved_locale; + + /* Back up the old locale. */ + saved_locale = setlocale (LC_ALL, NULL); + if (saved_locale == NULL) + return NULL; + saved_locale = strdup (saved_locale); + if (saved_locale == NULL) + return NULL; + + if (setlocale_unixlike (LC_ALL, locale) == NULL) + { + free (saved_locale); + return NULL; + } + + /* On native Windows, setlocale(LC_ALL,...) may succeed but set the + LC_CTYPE category to an invalid value ("C") when it does not + support the specified encoding. Report a failure instead. */ + if (strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) + { + if (saved_locale[0] != '\0') /* don't risk an endless recursion */ + setlocale (LC_ALL, saved_locale); + free (saved_locale); + return NULL; + } + + /* It was really successful. */ + free (saved_locale); + return setlocale (LC_ALL, NULL); + } + else +# endif + return setlocale_single (category, locale); + } +} + +# endif /* NEED_SETLOCALE_IMPROVED */ + +#endif diff --git a/gnulib-tests/setsockopt.c b/gnulib-tests/setsockopt.c new file mode 100644 index 0000000..ce0f9dd --- /dev/null +++ b/gnulib-tests/setsockopt.c @@ -0,0 +1,65 @@ +/* setsockopt.c --- wrappers for Windows setsockopt function + + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Paolo Bonzini */ + +#include <config.h> + +#define WIN32_LEAN_AND_MEAN +/* Get winsock2.h. */ +#include <sys/socket.h> + +/* Get struct timeval. */ +#include <sys/time.h> + +/* Get set_winsock_errno, FD_TO_SOCKET etc. */ +#include "w32sock.h" + +#undef setsockopt + +int +rpl_setsockopt (int fd, int level, int optname, const void *optval, socklen_t optlen) +{ + SOCKET sock = FD_TO_SOCKET (fd); + int r; + + if (sock == INVALID_SOCKET) + { + errno = EBADF; + return -1; + } + else + { + if (level == SOL_SOCKET + && (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO)) + { + const struct timeval *tv = optval; + int milliseconds = tv->tv_sec * 1000 + tv->tv_usec / 1000; + optval = &milliseconds; + r = setsockopt (sock, level, optname, optval, sizeof (int)); + } + else + { + r = setsockopt (sock, level, optname, optval, optlen); + } + + if (r < 0) + set_winsock_errno (); + + return r; + } +} diff --git a/gnulib-tests/signature.h b/gnulib-tests/signature.h new file mode 100644 index 0000000..c586fec --- /dev/null +++ b/gnulib-tests/signature.h @@ -0,0 +1,48 @@ +/* Macro for checking that a function declaration is compliant. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +#ifndef SIGNATURE_CHECK + +/* Check that the function FN takes the specified arguments ARGS with + a return type of RET. This header is designed to be included after + <config.h> and the one system header that is supposed to contain + the function being checked, but prior to any other system headers + that are necessary for the unit test. Therefore, this file does + not include any system headers, nor reference anything outside of + the macro arguments. For an example, if foo.h should provide: + + extern int foo (char, float); + + then the unit test named test-foo.c would start out with: + + #include <config.h> + #include <foo.h> + #include "signature.h" + SIGNATURE_CHECK (foo, int, (char, float)); + #include <other.h> + ... +*/ +# define SIGNATURE_CHECK(fn, ret, args) \ + SIGNATURE_CHECK1 (fn, ret, args, __LINE__) + +/* Necessary to allow multiple SIGNATURE_CHECK lines in a unit test. + Note that the checks must not occupy the same line. */ +# define SIGNATURE_CHECK1(fn, ret, args, id) \ + SIGNATURE_CHECK2 (fn, ret, args, id) /* macroexpand line */ +# define SIGNATURE_CHECK2(fn, ret, args, id) \ + static ret (* _GL_UNUSED signature_check ## id) args = fn + +#endif /* SIGNATURE_CHECK */ diff --git a/gnulib-tests/sleep.c b/gnulib-tests/sleep.c new file mode 100644 index 0000000..8aca605 --- /dev/null +++ b/gnulib-tests/sleep.c @@ -0,0 +1,76 @@ +/* Pausing execution of the current thread. + Copyright (C) 2007, 2009-2020 Free Software Foundation, Inc. + Written by Bruno Haible <bruno@clisp.org>, 2007. + + 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +/* Specification. */ +#include <unistd.h> + +#include <limits.h> + +#include "verify.h" + +#if defined _WIN32 && ! defined __CYGWIN__ + +# define WIN32_LEAN_AND_MEAN /* avoid including junk */ +# include <windows.h> + +unsigned int +sleep (unsigned int seconds) +{ + unsigned int remaining; + + /* Sleep for 1 second many times, because + 1. Sleep is not interruptible by Ctrl-C, + 2. we want to avoid arithmetic overflow while multiplying with 1000. */ + for (remaining = seconds; remaining > 0; remaining--) + Sleep (1000); + + return remaining; +} + +#elif HAVE_SLEEP + +# undef sleep + +/* Guarantee unlimited sleep and a reasonable return value. Cygwin + 1.5.x rejects attempts to sleep more than 49.7 days (2**32 + milliseconds), but uses uninitialized memory which results in a + garbage answer. Similarly, Linux 2.6.9 with glibc 2.3.4 has a too + small return value when asked to sleep more than 24.85 days. */ +unsigned int +rpl_sleep (unsigned int seconds) +{ + /* This requires int larger than 16 bits. */ + verify (UINT_MAX / 24 / 24 / 60 / 60); + const unsigned int limit = 24 * 24 * 60 * 60; + while (limit < seconds) + { + unsigned int result; + seconds -= limit; + result = sleep (limit); + if (result) + return seconds + result; + } + return sleep (seconds); +} + +#else /* !HAVE_SLEEP */ + + #error "Please port gnulib sleep.c to your platform, possibly using usleep() or select(), then report this to bug-gnulib." + +#endif diff --git a/gnulib-tests/socket.c b/gnulib-tests/socket.c new file mode 100644 index 0000000..67c6b1e --- /dev/null +++ b/gnulib-tests/socket.c @@ -0,0 +1,49 @@ +/* socket.c --- wrappers for Windows socket function + + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Paolo Bonzini */ + +#include <config.h> + +#define WIN32_LEAN_AND_MEAN +/* Get winsock2.h. */ +#include <sys/socket.h> + +/* Get set_winsock_errno, FD_TO_SOCKET etc. */ +#include "w32sock.h" + +#include "sockets.h" + +int +rpl_socket (int domain, int type, int protocol) +{ + SOCKET fh; + + gl_sockets_startup (SOCKETS_1_1); + + /* We have to use WSASocket() to create non-overlapped IO sockets. + Overlapped IO sockets cannot be used with read/write. */ + fh = WSASocket (domain, type, protocol, NULL, 0, 0); + + if (fh == INVALID_SOCKET) + { + set_winsock_errno (); + return -1; + } + else + return SOCKET_TO_FD (fh); +} diff --git a/gnulib-tests/strerror_r.c b/gnulib-tests/strerror_r.c new file mode 100644 index 0000000..9ccc6c3 --- /dev/null +++ b/gnulib-tests/strerror_r.c @@ -0,0 +1,451 @@ +/* strerror_r.c --- POSIX compatible system error routine + + Copyright (C) 2010-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2010. */ + +#include <config.h> + +/* Enable declaration of sys_nerr and sys_errlist in <errno.h> on NetBSD. */ +#define _NETBSD_SOURCE 1 + +/* Specification. */ +#include <string.h> + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#if !HAVE_SNPRINTF +# include <stdarg.h> +#endif + +#include "strerror-override.h" + +#if (__GLIBC__ >= 2 || defined __UCLIBC__ || defined __CYGWIN__) && HAVE___XPG_STRERROR_R /* glibc >= 2.3.4, cygwin >= 1.7.9 */ + +# define USE_XPG_STRERROR_R 1 +extern +#ifdef __cplusplus +"C" +#endif +int __xpg_strerror_r (int errnum, char *buf, size_t buflen); + +#elif HAVE_DECL_STRERROR_R && !(__GLIBC__ >= 2 || defined __UCLIBC__ || defined __CYGWIN__) + +/* The system's strerror_r function is OK, except that its third argument + is 'int', not 'size_t', or its return type is wrong. */ + +# include <limits.h> + +# define USE_SYSTEM_STRERROR_R 1 + +#else /* (__GLIBC__ >= 2 || defined __UCLIBC__ || defined __CYGWIN__ ? !HAVE___XPG_STRERROR_R : !HAVE_DECL_STRERROR_R) */ + +/* Use the system's strerror(). Exclude glibc and cygwin because the + system strerror_r has the wrong return type, and cygwin 1.7.9 + strerror_r clobbers strerror. */ +# undef strerror + +# define USE_SYSTEM_STRERROR 1 + +# if defined __NetBSD__ || defined __hpux || (defined _WIN32 && !defined __CYGWIN__) || defined __sgi || (defined __sun && !defined _LP64) || defined __CYGWIN__ + +/* No locking needed. */ + +/* Get catgets internationalization functions. */ +# if HAVE_CATGETS +# include <nl_types.h> +# endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Get sys_nerr, sys_errlist on HP-UX (otherwise only declared in C++ mode). + Get sys_nerr, sys_errlist on IRIX (otherwise only declared with _SGIAPI). */ +# if defined __hpux || defined __sgi +extern int sys_nerr; +extern char *sys_errlist[]; +# endif + +/* Get sys_nerr on Solaris. */ +# if defined __sun && !defined _LP64 +extern int sys_nerr; +# endif + +#ifdef __cplusplus +} +#endif + +# else + +# include "glthread/lock.h" + +/* This lock protects the buffer returned by strerror(). We assume that + no other uses of strerror() exist in the program. */ +gl_lock_define_initialized(static, strerror_lock) + +# endif + +#endif + +/* On MSVC, there is no snprintf() function, just a _snprintf(). + It is of lower quality, but sufficient for the simple use here. + We only have to make sure to NUL terminate the result (_snprintf + does not NUL terminate, like strncpy). */ +#if !HAVE_SNPRINTF +static int +local_snprintf (char *buf, size_t buflen, const char *format, ...) +{ + va_list args; + int result; + + va_start (args, format); + result = _vsnprintf (buf, buflen, format, args); + va_end (args); + if (buflen > 0 && (result < 0 || result >= buflen)) + buf[buflen - 1] = '\0'; + return result; +} +# define snprintf local_snprintf +#endif + +/* Copy as much of MSG into BUF as possible, without corrupting errno. + Return 0 if MSG fit in BUFLEN, otherwise return ERANGE. */ +static int +safe_copy (char *buf, size_t buflen, const char *msg) +{ + size_t len = strlen (msg); + size_t moved = len < buflen ? len : buflen - 1; + + /* Although POSIX lets memmove corrupt errno, we don't + know of any implementation where this is a real problem. */ + memmove (buf, msg, moved); + buf[moved] = '\0'; + return len < buflen ? 0 : ERANGE; +} + + +int +strerror_r (int errnum, char *buf, size_t buflen) +#undef strerror_r +{ + /* Filter this out now, so that rest of this replacement knows that + there is room for a non-empty message and trailing NUL. */ + if (buflen <= 1) + { + if (buflen) + *buf = '\0'; + return ERANGE; + } + *buf = '\0'; + + /* Check for gnulib overrides. */ + { + char const *msg = strerror_override (errnum); + + if (msg) + return safe_copy (buf, buflen, msg); + } + + { + int ret; + int saved_errno = errno; + +#if USE_XPG_STRERROR_R + + { + ret = __xpg_strerror_r (errnum, buf, buflen); + if (ret < 0) + ret = errno; + if (!*buf) + { + /* glibc 2.13 would not touch buf on err, so we have to fall + back to GNU strerror_r which always returns a thread-safe + untruncated string to (partially) copy into our buf. */ + safe_copy (buf, buflen, strerror_r (errnum, buf, buflen)); + } + } + +#elif USE_SYSTEM_STRERROR_R + + if (buflen > INT_MAX) + buflen = INT_MAX; + +# ifdef __hpux + /* On HP-UX 11.31, strerror_r always fails when buflen < 80; it + also fails to change buf on EINVAL. */ + { + char stackbuf[80]; + + if (buflen < sizeof stackbuf) + { + ret = strerror_r (errnum, stackbuf, sizeof stackbuf); + if (ret == 0) + ret = safe_copy (buf, buflen, stackbuf); + } + else + ret = strerror_r (errnum, buf, buflen); + } +# else + ret = strerror_r (errnum, buf, buflen); + + /* Some old implementations may return (-1, EINVAL) instead of EINVAL. + But on Haiku, valid error numbers are negative. */ +# if !defined __HAIKU__ + if (ret < 0) + ret = errno; +# endif +# endif + +# if defined _AIX || defined __HAIKU__ + /* AIX and Haiku return 0 rather than ERANGE when truncating strings; try + again until we are sure we got the entire string. */ + if (!ret && strlen (buf) == buflen - 1) + { + char stackbuf[STACKBUF_LEN]; + size_t len; + strerror_r (errnum, stackbuf, sizeof stackbuf); + len = strlen (stackbuf); + /* STACKBUF_LEN should have been large enough. */ + if (len + 1 == sizeof stackbuf) + abort (); + if (buflen <= len) + ret = ERANGE; + } +# else + /* Solaris 10 does not populate buf on ERANGE. OpenBSD 4.7 + truncates early on ERANGE rather than return a partial integer. + We prefer the maximal string. We set buf[0] earlier, and we + know of no implementation that modifies buf to be an + unterminated string, so this strlen should be portable in + practice (rather than pulling in a safer strnlen). */ + if (ret == ERANGE && strlen (buf) < buflen - 1) + { + char stackbuf[STACKBUF_LEN]; + + /* STACKBUF_LEN should have been large enough. */ + if (strerror_r (errnum, stackbuf, sizeof stackbuf) == ERANGE) + abort (); + safe_copy (buf, buflen, stackbuf); + } +# endif + +#else /* USE_SYSTEM_STRERROR */ + + /* Try to do what strerror (errnum) does, but without clobbering the + buffer used by strerror(). */ + +# if defined __NetBSD__ || defined __hpux || (defined _WIN32 && !defined __CYGWIN__) || defined __CYGWIN__ /* NetBSD, HP-UX, native Windows, Cygwin */ + + /* NetBSD: sys_nerr, sys_errlist are declared through _NETBSD_SOURCE + and <errno.h> above. + HP-UX: sys_nerr, sys_errlist are declared explicitly above. + native Windows: sys_nerr, sys_errlist are declared in <stdlib.h>. + Cygwin: sys_nerr, sys_errlist are declared in <errno.h>. */ + if (errnum >= 0 && errnum < sys_nerr) + { +# if HAVE_CATGETS && (defined __NetBSD__ || defined __hpux) +# if defined __NetBSD__ + nl_catd catd = catopen ("libc", NL_CAT_LOCALE); + const char *errmsg = + (catd != (nl_catd)-1 + ? catgets (catd, 1, errnum, sys_errlist[errnum]) + : sys_errlist[errnum]); +# endif +# if defined __hpux + nl_catd catd = catopen ("perror", NL_CAT_LOCALE); + const char *errmsg = + (catd != (nl_catd)-1 + ? catgets (catd, 1, 1 + errnum, sys_errlist[errnum]) + : sys_errlist[errnum]); +# endif +# else + const char *errmsg = sys_errlist[errnum]; +# endif + if (errmsg == NULL || *errmsg == '\0') + ret = EINVAL; + else + ret = safe_copy (buf, buflen, errmsg); +# if HAVE_CATGETS && (defined __NetBSD__ || defined __hpux) + if (catd != (nl_catd)-1) + catclose (catd); +# endif + } + else + ret = EINVAL; + +# elif defined __sgi || (defined __sun && !defined _LP64) /* IRIX, Solaris <= 9 32-bit */ + + /* For a valid error number, the system's strerror() function returns + a pointer to a not copied string, not to a buffer. */ + if (errnum >= 0 && errnum < sys_nerr) + { + char *errmsg = strerror (errnum); + + if (errmsg == NULL || *errmsg == '\0') + ret = EINVAL; + else + ret = safe_copy (buf, buflen, errmsg); + } + else + ret = EINVAL; + +# else + + gl_lock_lock (strerror_lock); + + { + char *errmsg = strerror (errnum); + + /* For invalid error numbers, strerror() on + - IRIX 6.5 returns NULL, + - HP-UX 11 returns an empty string. */ + if (errmsg == NULL || *errmsg == '\0') + ret = EINVAL; + else + ret = safe_copy (buf, buflen, errmsg); + } + + gl_lock_unlock (strerror_lock); + +# endif + +#endif + +#if defined _WIN32 && !defined __CYGWIN__ + /* MSVC 14 defines names for many error codes in the range 100..140, + but _sys_errlist contains strings only for the error codes + < _sys_nerr = 43. */ + if (ret == EINVAL) + { + const char *errmsg; + + switch (errnum) + { + case 100 /* EADDRINUSE */: + errmsg = "Address already in use"; + break; + case 101 /* EADDRNOTAVAIL */: + errmsg = "Cannot assign requested address"; + break; + case 102 /* EAFNOSUPPORT */: + errmsg = "Address family not supported by protocol"; + break; + case 103 /* EALREADY */: + errmsg = "Operation already in progress"; + break; + case 105 /* ECANCELED */: + errmsg = "Operation canceled"; + break; + case 106 /* ECONNABORTED */: + errmsg = "Software caused connection abort"; + break; + case 107 /* ECONNREFUSED */: + errmsg = "Connection refused"; + break; + case 108 /* ECONNRESET */: + errmsg = "Connection reset by peer"; + break; + case 109 /* EDESTADDRREQ */: + errmsg = "Destination address required"; + break; + case 110 /* EHOSTUNREACH */: + errmsg = "No route to host"; + break; + case 112 /* EINPROGRESS */: + errmsg = "Operation now in progress"; + break; + case 113 /* EISCONN */: + errmsg = "Transport endpoint is already connected"; + break; + case 114 /* ELOOP */: + errmsg = "Too many levels of symbolic links"; + break; + case 115 /* EMSGSIZE */: + errmsg = "Message too long"; + break; + case 116 /* ENETDOWN */: + errmsg = "Network is down"; + break; + case 117 /* ENETRESET */: + errmsg = "Network dropped connection on reset"; + break; + case 118 /* ENETUNREACH */: + errmsg = "Network is unreachable"; + break; + case 119 /* ENOBUFS */: + errmsg = "No buffer space available"; + break; + case 123 /* ENOPROTOOPT */: + errmsg = "Protocol not available"; + break; + case 126 /* ENOTCONN */: + errmsg = "Transport endpoint is not connected"; + break; + case 128 /* ENOTSOCK */: + errmsg = "Socket operation on non-socket"; + break; + case 129 /* ENOTSUP */: + errmsg = "Not supported"; + break; + case 130 /* EOPNOTSUPP */: + errmsg = "Operation not supported"; + break; + case 132 /* EOVERFLOW */: + errmsg = "Value too large for defined data type"; + break; + case 133 /* EOWNERDEAD */: + errmsg = "Owner died"; + break; + case 134 /* EPROTO */: + errmsg = "Protocol error"; + break; + case 135 /* EPROTONOSUPPORT */: + errmsg = "Protocol not supported"; + break; + case 136 /* EPROTOTYPE */: + errmsg = "Protocol wrong type for socket"; + break; + case 138 /* ETIMEDOUT */: + errmsg = "Connection timed out"; + break; + case 140 /* EWOULDBLOCK */: + errmsg = "Operation would block"; + break; + default: + errmsg = NULL; + break; + } + if (errmsg != NULL) + ret = safe_copy (buf, buflen, errmsg); + } +#endif + + if (ret == EINVAL && !*buf) + { +#if defined __HAIKU__ + /* For consistency with perror(). */ + snprintf (buf, buflen, "Unknown Application Error (%d)", errnum); +#else + snprintf (buf, buflen, "Unknown error %d", errnum); +#endif + } + + errno = saved_errno; + return ret; + } +} diff --git a/gnulib-tests/test-accept.c b/gnulib-tests/test-accept.c new file mode 100644 index 0000000..cdf8cb2 --- /dev/null +++ b/gnulib-tests/test-accept.c @@ -0,0 +1,56 @@ +/* Test accepting a connection to a server socket. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <sys/socket.h> + +#include "signature.h" +SIGNATURE_CHECK (accept, int, (int, struct sockaddr *, socklen_t *)); + +#include <errno.h> +#include <netinet/in.h> +#include <unistd.h> + +#include "sockets.h" +#include "macros.h" + +int +main (void) +{ + (void) gl_sockets_startup (SOCKETS_1_1); + + /* Test behaviour for invalid file descriptors. */ + { + struct sockaddr_in addr; + socklen_t addrlen = sizeof (addr); + + errno = 0; + ASSERT (accept (-1, (struct sockaddr *) &addr, &addrlen) == -1); + ASSERT (errno == EBADF); + } + { + struct sockaddr_in addr; + socklen_t addrlen = sizeof (addr); + + close (99); + errno = 0; + ASSERT (accept (99, (struct sockaddr *) &addr, &addrlen) == -1); + ASSERT (errno == EBADF); + } + + return 0; +} diff --git a/gnulib-tests/test-alignof.c b/gnulib-tests/test-alignof.c new file mode 100644 index 0000000..34eaec2 --- /dev/null +++ b/gnulib-tests/test-alignof.c @@ -0,0 +1,59 @@ +/* Test of <alignof.h>. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2009. */ + +#include <config.h> + +#include <alignof.h> + +#include <stddef.h> +#include <stdint.h> + +#include "verify.h" + +typedef long double longdouble; +typedef struct { char a[1]; } struct1; +typedef struct { char a[2]; } struct2; +typedef struct { char a[3]; } struct3; +typedef struct { char a[4]; } struct4; + +#define CHECK(type) \ + typedef struct { char slot1; type slot2; } type##_helper; \ + verify (alignof_slot (type) == offsetof (type##_helper, slot2)); \ + const int type##_slot_alignment = alignof_slot (type); \ + const int type##_type_alignment = alignof_type (type); + +CHECK (char) +CHECK (short) +CHECK (int) +CHECK (long) +CHECK (float) +CHECK (double) +CHECK (longdouble) +#ifdef INT64_MAX +CHECK (int64_t) +#endif +CHECK (struct1) +CHECK (struct2) +CHECK (struct3) +CHECK (struct4) + +int +main () +{ + return 0; +} diff --git a/gnulib-tests/test-alloca-opt.c b/gnulib-tests/test-alloca-opt.c new file mode 100644 index 0000000..faf7c74 --- /dev/null +++ b/gnulib-tests/test-alloca-opt.c @@ -0,0 +1,62 @@ +/* Test of optional automatic memory allocation. + Copyright (C) 2005, 2007, 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <alloca.h> + +#if HAVE_ALLOCA + +static void +do_allocation (int n) +{ + void *ptr = alloca (n); + (void) ptr; +} + +void (*func) (int) = do_allocation; + +#endif + +int +main () +{ +#if HAVE_ALLOCA + int i; + + /* Repeat a lot of times, to make sure there's no memory leak. */ + for (i = 0; i < 100000; i++) + { + /* Try various values. + n = 0 gave a crash on Alpha with gcc-2.5.8. + Some versions of Mac OS X have a stack size limit of 512 KB. */ + func (34); + func (134); + func (399); + func (510823); + func (129321); + func (0); + func (4070); + func (4095); + func (1); + func (16582); + } +#endif + + return 0; +} diff --git a/gnulib-tests/test-areadlink-with-size.c b/gnulib-tests/test-areadlink-with-size.c new file mode 100644 index 0000000..a962612 --- /dev/null +++ b/gnulib-tests/test-areadlink-with-size.c @@ -0,0 +1,46 @@ +/* Tests of areadlink_with_size. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include "areadlink.h" + +#include <fcntl.h> +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> +#include <unistd.h> + +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-areadlink-with-size.t" + +#include "test-areadlink.h" + +int +main (void) +{ + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + return test_areadlink (areadlink_with_size, true); +} diff --git a/gnulib-tests/test-areadlink.c b/gnulib-tests/test-areadlink.c new file mode 100644 index 0000000..d8e10ae --- /dev/null +++ b/gnulib-tests/test-areadlink.c @@ -0,0 +1,53 @@ +/* Tests of areadlink. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include "areadlink.h" + +#include <fcntl.h> +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> +#include <unistd.h> + +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-areadlink.t" + +#include "test-areadlink.h" + +/* Wrapper for testing areadlink. */ +static char * +do_areadlink (char const *name, size_t ignored _GL_UNUSED) +{ + return areadlink (name); +} + +int +main (void) +{ + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + return test_areadlink (do_areadlink, true); +} diff --git a/gnulib-tests/test-areadlink.h b/gnulib-tests/test-areadlink.h new file mode 100644 index 0000000..b1fb372 --- /dev/null +++ b/gnulib-tests/test-areadlink.h @@ -0,0 +1,83 @@ +/* Tests of areadlink and friends. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +/* This file is designed to test areadlink(a), + areadlink_with_size(a,b), and areadlinkat(AT_FDCWD,a). FUNC is the + function to test; a length is always supplied, but may be ignored. + Assumes that BASE and ASSERT are already defined, and that + appropriate headers are already included. If PRINT, warn before + skipping symlink tests with status 77. */ + +static int +test_areadlink (char * (*func) (char const *, size_t), bool print) +{ + /* Sanity checks of failures. Mingw lacks symlink, but areadlink can + still distinguish between various errors. */ + errno = 0; + ASSERT (func ("no_such", 1) == NULL); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func ("no_such/", 1) == NULL); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func ("", 1) == NULL); + ASSERT (errno == ENOENT || errno == EINVAL); + errno = 0; + ASSERT (func (".", 1) == NULL); + ASSERT (errno == EINVAL); + errno = 0; + ASSERT (func ("./", 1) == NULL); + ASSERT (errno == EINVAL); + ASSERT (close (creat (BASE "file", 0600)) == 0); + errno = 0; + ASSERT (func (BASE "file", 1) == NULL); + ASSERT (errno == EINVAL); + errno = 0; + ASSERT (func (BASE "file/", 1) == NULL); + ASSERT (errno == ENOTDIR || errno == EINVAL); /* AIX yields EINVAL */ + ASSERT (unlink (BASE "file") == 0); + + /* Now test actual symlinks. */ + if (symlink (BASE "dir", BASE "link")) + { + if (print) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + ASSERT (mkdir (BASE "dir", 0700) == 0); + errno = 0; + ASSERT (func (BASE "link/", 1) == NULL); + ASSERT (errno == EINVAL); + { + /* Too small a guess is okay. */ + char *buf = func (BASE "link", 1); + ASSERT (buf); + ASSERT (strcmp (buf, BASE "dir") == 0); + free (buf); + /* Too large a guess is okay. */ + buf = func (BASE "link", 10000000); + ASSERT (buf); + ASSERT (strcmp (buf, BASE "dir") == 0); + free (buf); + } + ASSERT (rmdir (BASE "dir") == 0); + ASSERT (unlink (BASE "link") == 0); + + return 0; +} diff --git a/gnulib-tests/test-areadlinkat.c b/gnulib-tests/test-areadlinkat.c new file mode 100644 index 0000000..00a4de0 --- /dev/null +++ b/gnulib-tests/test-areadlinkat.c @@ -0,0 +1,89 @@ +/* Tests of areadlinkat. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include "areadlink.h" + +#include <fcntl.h> +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> +#include <unistd.h> + +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-areadlinkat.t" + +#include "test-areadlink.h" + +static int dfd = AT_FDCWD; + +/* Wrapper for testing areadlinkat. */ +static char * +do_areadlinkat (char const *name, size_t ignored _GL_UNUSED) +{ + return areadlinkat (dfd, name); +} + +int +main (void) +{ + int result; + + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + /* Basic tests. */ + result = test_areadlink (do_areadlinkat, false); + dfd = open (".", O_RDONLY); + ASSERT (0 <= dfd); + ASSERT (test_areadlink (do_areadlinkat, false) == result); + + /* Relative tests. */ + if (result == 77) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + else + { + char *buf; + ASSERT (symlink ("nowhere", BASE "link") == 0); + ASSERT (mkdir (BASE "dir", 0700) == 0); + ASSERT (chdir (BASE "dir") == 0); + buf = areadlinkat (dfd, BASE "link"); + ASSERT (buf); + ASSERT (strcmp (buf, "nowhere") == 0); + free (buf); + errno = 0; + ASSERT (areadlinkat (-1, BASE "link") == NULL); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (areadlinkat (AT_FDCWD, BASE "link") == NULL); + ASSERT (errno == ENOENT); + ASSERT (chdir ("..") == 0); + ASSERT (rmdir (BASE "dir") == 0); + ASSERT (unlink (BASE "link") == 0); + } + + ASSERT (close (dfd) == 0); + return result; +} diff --git a/gnulib-tests/test-argmatch.c b/gnulib-tests/test-argmatch.c new file mode 100644 index 0000000..24a0500 --- /dev/null +++ b/gnulib-tests/test-argmatch.c @@ -0,0 +1,156 @@ +/* Test of exact or abbreviated match search. + Copyright (C) 1990, 1998-1999, 2001-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007, based on test code + by David MacKenzie <djm@gnu.ai.mit.edu>. */ + +#include <config.h> + +#include "argmatch.h" + +#include <stdlib.h> + +#include "macros.h" + +# define N_(Msgid) (Msgid) + +/* Some packages define ARGMATCH_DIE and ARGMATCH_DIE_DECL in <config.h>, and + thus must link with a definition of that function. Provide it here. */ +#ifdef ARGMATCH_DIE_DECL + +_Noreturn ARGMATCH_DIE_DECL; +ARGMATCH_DIE_DECL { exit (1); } + +#endif + +enum backup_type +{ + no_backups, + simple_backups, + numbered_existing_backups, + numbered_backups +}; + +static const char *const backup_args[] = +{ + "no", "none", "off", + "simple", "never", "single", + "existing", "nil", "numbered-existing", + "numbered", "t", "newstyle", + NULL +}; + +static const enum backup_type backup_vals[] = +{ + no_backups, no_backups, no_backups, + simple_backups, simple_backups, simple_backups, + numbered_existing_backups, numbered_existing_backups, numbered_existing_backups, + numbered_backups, numbered_backups, numbered_backups +}; + +ARGMATCH_DEFINE_GROUP(backup, enum backup_type); + +static const argmatch_backup_doc argmatch_backup_docs[] = +{ + { "no", N_("never make backups (even if --backup is given)") }, + { "numbered", N_("make numbered backups") }, + { "existing", N_("numbered if numbered backups exist, simple otherwise") }, + { "simple", N_("always make simple backups") }, + { NULL, NULL } +}; + +static const argmatch_backup_arg argmatch_backup_args[] = +{ + { "no", no_backups }, + { "none", no_backups }, + { "off", no_backups }, + { "simple", simple_backups }, + { "never", simple_backups }, + { "single", simple_backups }, + { "existing", numbered_existing_backups }, + { "nil", numbered_existing_backups }, + { "numbered-existing", numbered_existing_backups }, + { "numbered", numbered_backups }, + { "t", numbered_backups }, + { "newstyle", numbered_backups }, + { NULL, no_backups } +}; + +const argmatch_backup_group_type argmatch_backup_group = +{ + argmatch_backup_args, + argmatch_backup_docs, + N_("\ +The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.\n\ +The version control method may be selected via the --backup option or through\n\ +the VERSION_CONTROL environment variable. Here are the values:\n"), + NULL +}; + +int +main (int argc, char *argv[]) +{ +#define CHECK(Input, Output) \ + do { \ + ASSERT (ARGMATCH (Input, backup_args, backup_vals) == Output); \ + ASSERT (argmatch_backup_choice (Input) == Output); \ + if (0 <= Output) \ + { \ + enum backup_type val = argmatch_backup_args[Output].val; \ + ASSERT (*argmatch_backup_value ("test", Input) == val); \ + ASSERT (*argmatch_backup_value ("test", \ + argmatch_backup_argument (&val)) \ + == val); \ + } \ + } while (0) + + /* Not found. */ + CHECK ("klingon", -1); + + /* Exact match. */ + CHECK ("none", 1); + CHECK ("nil", 7); + + /* Too long. */ + CHECK ("nilpotent", -1); + + /* Abbreviated. */ + CHECK ("simpl", 3); + CHECK ("simp", 3); + CHECK ("sim", 3); + + /* Exact match and abbreviated. */ + CHECK ("numbered", 9); + CHECK ("numbere", -2); + CHECK ("number", -2); + CHECK ("numbe", -2); + CHECK ("numb", -2); + CHECK ("num", -2); + CHECK ("nu", -2); + CHECK ("n", -2); + + /* Ambiguous abbreviated. */ + CHECK ("ne", -2); + + /* Ambiguous abbreviated, but same value ("single" and "simple"). */ + CHECK ("si", 3); + CHECK ("s", 3); +#undef CHECK + + argmatch_backup_usage (stdout); + + return 0; +} diff --git a/gnulib-tests/test-argv-iter.c b/gnulib-tests/test-argv-iter.c new file mode 100644 index 0000000..82deb57 --- /dev/null +++ b/gnulib-tests/test-argv-iter.c @@ -0,0 +1,107 @@ +/* Test argv iterator + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Jim Meyering. */ + +#include <config.h> + +#include "argv-iter.h" + +#include <stdio.h> +#include <string.h> + +#include "macros.h" + +#define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array)) +#define STREQ(a, b) (strcmp (a, b) == 0) + +static FILE * +write_nul_delimited_argv (char **argv) +{ + FILE *fp = tmpfile (); + ASSERT (fp); + while (*argv) + { + size_t len = strlen (*argv) + 1; + ASSERT (fwrite (*argv, len, 1, fp) == 1); + argv++; + } + ASSERT (fflush (fp) == 0); + rewind (fp); + return fp; +} + +int +main (void) +{ + static char one[] = "1"; + static char two[] = "2"; + static char three[] = "3"; + static char *av[][4] = { + {NULL}, + {one, NULL}, + {one, two, NULL}, + {one, two, three, NULL} + }; + + int use_stream; + for (use_stream = 0; use_stream < 2; use_stream++) + { + size_t i; + for (i = 0; i < ARRAY_CARDINALITY (av); i++) + { + FILE *fp; + struct argv_iterator *ai; + size_t n_found = 0; + if (use_stream) + { + /* Generate an identical list to be read via FP. */ + ASSERT ((fp = write_nul_delimited_argv (av[i])) != NULL); + ai = argv_iter_init_stream (fp); + } + else + { + fp = NULL; + ai = argv_iter_init_argv (av[i]); + } + ASSERT (ai); + + while (1) + { + enum argv_iter_err ai_err; + char *s = argv_iter (ai, &ai_err); + ASSERT ((i == n_found) == (ai_err == AI_ERR_EOF)); + ASSERT ((s == NULL) ^ (ai_err == AI_ERR_OK)); + ASSERT (ai_err == AI_ERR_OK || ai_err == AI_ERR_EOF); + if (ai_err == AI_ERR_OK) + ++n_found; + if (ai_err == AI_ERR_EOF) + break; + /* In stream mode, the strings are equal, but + in argv mode the actual pointers are equal. */ + ASSERT (use_stream + ? STREQ (s, av[i][n_found - 1]) + : s == av[i][n_found - 1]); + } + ASSERT (argv_iter_n_args (ai) == i); + argv_iter_free (ai); + if (fp) + ASSERT (fclose (fp) == 0); + } + } + + return 0; +} diff --git a/gnulib-tests/test-arpa_inet.c b/gnulib-tests/test-arpa_inet.c new file mode 100644 index 0000000..b7234b3 --- /dev/null +++ b/gnulib-tests/test-arpa_inet.c @@ -0,0 +1,27 @@ +/* Test of <arpa/inet.h> substitute. + Copyright (C) 2007, 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <arpa/inet.h> + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tests/test-base32.c b/gnulib-tests/test-base32.c new file mode 100644 index 0000000..906f411 --- /dev/null +++ b/gnulib-tests/test-base32.c @@ -0,0 +1,261 @@ +/* Self tests for base32. + Copyright (C) 2004, 2008-2020 Free Software Foundation, Inc. + Based on the tests for base64 written by Simon Josefsson. + Adapted for base32 by Gijs van Tulder. + + 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include "base32.h" + +#include <stddef.h> +#include <stdbool.h> +#include <stdlib.h> +#include <string.h> +#include <stdint.h> + +#include "macros.h" + +int +main (void) +{ + const char *in = "abcdefghijklmnop"; + const char *b32in = "MFRGGZDFMZTWQ2LKNNWG23TPOA======"; + char out[255]; + size_t len; + bool ok; + char *p; + + memset (out, 0x42, sizeof (out)); + base32_encode (in, 0, out, 0); + ASSERT (out[0] == '\x42'); + + memset (out, 0x42, sizeof (out)); + base32_encode (in, 1, out, 10); + ASSERT (memcmp (out, "ME======", 1) == 0); + + memset (out, 0x42, sizeof (out)); + base32_encode (in, 1, out, 2); + ASSERT (memcmp (out, "ME======", 2) == 0); + + memset (out, 0x42, sizeof (out)); + base32_encode (in, 1, out, 3); + ASSERT (memcmp (out, "ME======", 3) == 0); + + memset (out, 0x42, sizeof (out)); + base32_encode (in, 1, out, 4); + ASSERT (memcmp (out, "ME======", 4) == 0); + + memset (out, 0x42, sizeof (out)); + base32_encode (in, 1, out, 8); + ASSERT (memcmp (out, "ME======", 8) == 0); + + memset (out, 0x42, sizeof (out)); + base32_encode (in, 2, out, 8); + ASSERT (memcmp (out, "MFRA====", 8) == 0); + + memset (out, 0x42, sizeof (out)); + base32_encode (in, 3, out, 8); + ASSERT (memcmp (out, "MFRGG===", 8) == 0); + + memset (out, 0x42, sizeof (out)); + base32_encode (in, 4, out, 8); + ASSERT (memcmp (out, "MFRGGZA=", 8) == 0); + + memset (out, 0x42, sizeof (out)); + base32_encode (in, 5, out, 8); + ASSERT (memcmp (out, "MFRGGZDF", 8) == 0); + + memset (out, 0x42, sizeof (out)); + base32_encode (in, 6, out, 16); + ASSERT (memcmp (out, "MFRGGZDFMY======", 16) == 0); + + memset (out, 0x42, sizeof (out)); + base32_encode (in, 6, out, 100); + ASSERT (memcmp (out, "MFRGGZDFMY======", 16) == 0); + + /* Decode. */ + + memset (out, 0x42, sizeof (out)); + len = 0; + ok = base32_decode (b32in, 8, out, &len); + ASSERT (ok); + ASSERT (len == 0); + + memset (out, 0x42, sizeof (out)); + len = 1; + ok = base32_decode (b32in, 8, out, &len); + ASSERT (ok); + ASSERT (len == 1); + ASSERT (memcmp (out, "abcdefghijklmnop", 1) == 0); + + memset (out, 0x42, sizeof (out)); + len = 2; + ok = base32_decode (b32in, 8, out, &len); + ASSERT (ok); + ASSERT (len == 2); + ASSERT (memcmp (out, "abcdefghijklmnop", 2) == 0); + + memset (out, 0x42, sizeof (out)); + len = 3; + ok = base32_decode (b32in, 8, out, &len); + ASSERT (ok); + ASSERT (len == 3); + ASSERT (memcmp (out, "abcdefghijklmnop", 3) == 0); + + memset (out, 0x42, sizeof (out)); + len = 4; + ok = base32_decode (b32in, 8, out, &len); + ASSERT (ok); + ASSERT (len == 4); + ASSERT (memcmp (out, "abcdefghijklmnop", 4) == 0); + + memset (out, 0x42, sizeof (out)); + len = 5; + ok = base32_decode (b32in, 8, out, &len); + ASSERT (ok); + ASSERT (len == 5); + ASSERT (memcmp (out, "abcdefghijklmnop", 5) == 0); + + memset (out, 0x42, sizeof (out)); + len = 6; + ok = base32_decode (b32in, 8, out, &len); + ASSERT (ok); + ASSERT (len == 5); + ASSERT (memcmp (out, "abcdefghijklmnop", 5) == 0); + + memset (out, 0x42, sizeof (out)); + len = 100; + ok = base32_decode (b32in, strlen (b32in), out, &len); + ASSERT (ok); + ASSERT (len == 16); + ASSERT (memcmp (out, "abcdefghijklmnop", 16) == 0); + + /* Allocating encode */ + + len = base32_encode_alloc (in, strlen (in), &p); + ASSERT (len == 32); + ASSERT (strcmp (p, "MFRGGZDFMZTWQ2LKNNWG23TPOA======") == 0); + free (p); + + len = base32_encode_alloc (in, SIZE_MAX - 5, &p); + ASSERT (len == 0); + + /* Decode context function */ + { + struct base32_decode_context ctx; + + base32_decode_ctx_init (&ctx); + + len = sizeof (out); + ok = base32_decode_ctx (&ctx, b32in, strlen (b32in), out, &len); + ASSERT (ok); + ASSERT (len == 16); + ASSERT (memcmp (out, "abcdefghijklmnop", len) == 0); + } + + /* Allocating decode context function */ + + ok = base32_decode_alloc_ctx (NULL, b32in, strlen (b32in), &p, &len); + ASSERT (ok); + ASSERT (len == 16); + ASSERT (memcmp (out, "abcdefghijklmnop", len) == 0); + free (p); + + { + struct base32_decode_context ctx; + const char *newlineb32 = "MFRG\nGZDFMZTWQ2LKNNW\nG23TPOA======"; + + base32_decode_ctx_init (&ctx); + + ok = base32_decode_alloc_ctx (&ctx, newlineb32, strlen (newlineb32), &p, &len); + ASSERT (ok); + ASSERT (len == strlen (in)); + ASSERT (memcmp (p, in, len) == 0); + free (p); + } + + { + struct base32_decode_context ctx; + base32_decode_ctx_init (&ctx); + + ok = base32_decode_alloc_ctx (&ctx, "MFRGGZDFM\nZTWQ2LK", 17, &p, &len); + ASSERT (ok); + ASSERT (len == 10); + ASSERT (memcmp (p, "abcdefghij", len) == 0); + free (p); + + base32_decode_ctx_init (&ctx); + + ok = base32_decode_alloc_ctx (&ctx, "MF\n", 3, &p, &len); + ASSERT (ok); + ASSERT (len == 0); + free (p); + + ok = base32_decode_alloc_ctx (&ctx, "RGGZDFMZ", 8, &p, &len); + ASSERT (ok); + ASSERT (len == 5); + ASSERT (memcmp (p, "abcde", len) == 0); + free (p); + + ok = base32_decode_alloc_ctx (&ctx, "TWQ2LK", 6, &p, &len); + ASSERT (ok); + ASSERT (len == 5); + ASSERT (memcmp (p, "fghij", len) == 0); + free (p); + + ok = base32_decode_alloc_ctx (&ctx, "", 0, &p, &len); + ASSERT (ok); + free (p); + } + + { + struct base32_decode_context ctx; + const char *newlineb32 = "\n\n\n\n\n"; + + base32_decode_ctx_init (&ctx); + + ok = base32_decode_alloc_ctx (&ctx, newlineb32, strlen (newlineb32), &p, &len); + ASSERT (ok); + ASSERT (len == 0); + free (p); + } + + ok = base32_decode_alloc_ctx (NULL, " ! ", 3, &p, &len); + ASSERT (!ok); + + ok = base32_decode_alloc_ctx (NULL, "ABC\nDEF", 7, &p, &len); + ASSERT (!ok); + + ok = base32_decode_alloc_ctx (NULL, "AA", 2, &p, &len); + ASSERT (!ok); + + ok = base32_decode_alloc_ctx (NULL, "AA=", 3, &p, &len); + ASSERT (!ok); + + ok = base32_decode_alloc_ctx (NULL, "AABBAAxx", 8, &p, &len); + ASSERT (!ok); + + ok = base32_decode_alloc_ctx (NULL, "AABBAA=X", 8, &p, &len); + ASSERT (!ok); + + ok = base32_decode_alloc_ctx (NULL, "AABBAA=X", 8, &p, &len); + ASSERT (!ok); + + ok = base32_decode_alloc_ctx (NULL, "AABBAA=A", 8, &p, &len); + ASSERT (!ok); + + return 0; +} diff --git a/gnulib-tests/test-base64.c b/gnulib-tests/test-base64.c new file mode 100644 index 0000000..b59df0d --- /dev/null +++ b/gnulib-tests/test-base64.c @@ -0,0 +1,238 @@ +/* Self tests for base64. + Copyright (C) 2004, 2008-2020 Free Software Foundation, Inc. + Written by Simon Josefsson. + + 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include "base64.h" + +#include <stddef.h> +#include <stdbool.h> +#include <stdlib.h> +#include <string.h> +#include <stdint.h> + +#include "macros.h" + +int +main (void) +{ + const char *in = "abcdefghijklmnop"; + const char *b64in = "YWJjZGVmZw=="; + char out[255]; + size_t len; + bool ok; + char *p; + + memset (out, 0x42, sizeof (out)); + base64_encode (in, 0, out, 0); + ASSERT (out[0] == '\x42'); + + memset (out, 0x42, sizeof (out)); + base64_encode (in, 1, out, 1); + ASSERT (memcmp (out, "YQ==", 1) == 0); + + memset (out, 0x42, sizeof (out)); + base64_encode (in, 1, out, 2); + ASSERT (memcmp (out, "YQ==", 2) == 0); + + memset (out, 0x42, sizeof (out)); + base64_encode (in, 1, out, 3); + ASSERT (memcmp (out, "YQ==", 3) == 0); + + memset (out, 0x42, sizeof (out)); + base64_encode (in, 1, out, 4); + ASSERT (memcmp (out, "YQ==", 4) == 0); + + memset (out, 0x42, sizeof (out)); + base64_encode (in, 1, out, 8); + ASSERT (memcmp (out, "YQ==", 4) == 0); + + memset (out, 0x42, sizeof (out)); + base64_encode (in, 2, out, 4); + ASSERT (memcmp (out, "YWI=", 4) == 0); + + memset (out, 0x42, sizeof (out)); + base64_encode (in, 3, out, 4); + ASSERT (memcmp (out, "YWJj", 4) == 0); + + memset (out, 0x42, sizeof (out)); + base64_encode (in, 4, out, 5); + ASSERT (memcmp (out, "YWJjZA==", 5) == 0); + + memset (out, 0x42, sizeof (out)); + base64_encode (in, 4, out, 100); + ASSERT (memcmp (out, "YWJjZA==", 6) == 0); + + /* Decode. */ + + memset (out, 0x42, sizeof (out)); + len = 0; + ok = base64_decode (b64in, 4, out, &len); + ASSERT (ok); + ASSERT (len == 0); + + memset (out, 0x42, sizeof (out)); + len = 1; + ok = base64_decode (b64in, 4, out, &len); + ASSERT (ok); + ASSERT (len == 1); + ASSERT (memcmp (out, "abcdefg", 1) == 0); + + memset (out, 0x42, sizeof (out)); + len = 2; + ok = base64_decode (b64in, 4, out, &len); + ASSERT (ok); + ASSERT (len == 2); + ASSERT (memcmp (out, "abcdefg", 2) == 0); + + memset (out, 0x42, sizeof (out)); + len = 3; + ok = base64_decode (b64in, 4, out, &len); + ASSERT (ok); + ASSERT (len == 3); + ASSERT (memcmp (out, "abcdefg", 3) == 0); + + memset (out, 0x42, sizeof (out)); + len = 4; + ok = base64_decode (b64in, 4, out, &len); + ASSERT (ok); + ASSERT (len == 3); + ASSERT (memcmp (out, "abcdefg", 3) == 0); + + memset (out, 0x42, sizeof (out)); + len = 100; + ok = base64_decode (b64in, strlen (b64in), out, &len); + ASSERT (ok); + ASSERT (len == 7); + ASSERT (memcmp (out, "abcdefg", 7) == 0); + + /* Allocating encode */ + + len = base64_encode_alloc (in, strlen (in), &p); + ASSERT (len == 24); + ASSERT (strcmp (p, "YWJjZGVmZ2hpamtsbW5vcA==") == 0); + free (p); + + len = base64_encode_alloc (in, SIZE_MAX - 5, &p); + ASSERT (len == 0); + + /* Decode context function */ + { + struct base64_decode_context ctx; + + base64_decode_ctx_init (&ctx); + + len = sizeof (out); + ok = base64_decode_ctx (&ctx, b64in, strlen (b64in), out, &len); + ASSERT (ok); + ASSERT (len == 7); + ASSERT (memcmp (out, "abcdefg", len) == 0); + } + + /* Allocating decode context function */ + + ok = base64_decode_alloc_ctx (NULL, b64in, strlen (b64in), &p, &len); + ASSERT (ok); + ASSERT (len == 7); + ASSERT (memcmp (out, "abcdefg", len) == 0); + free (p); + + { + struct base64_decode_context ctx; + const char *newlineb64 = "YWJjZG\nVmZ2hp\namtsbW5vcA=="; + + base64_decode_ctx_init (&ctx); + + ok = base64_decode_alloc_ctx (&ctx, newlineb64, strlen (newlineb64), &p, &len); + ASSERT (ok); + ASSERT (len == strlen (in)); + ASSERT (memcmp (p, in, len) == 0); + free (p); + } + + { + struct base64_decode_context ctx; + base64_decode_ctx_init (&ctx); + + ok = base64_decode_alloc_ctx (&ctx, "YW\nJjZGVmZ2hp", 13, &p, &len); + ASSERT (ok); + ASSERT (len == 9); + ASSERT (memcmp (p, "abcdefghi", len) == 0); + free (p); + + base64_decode_ctx_init (&ctx); + + ok = base64_decode_alloc_ctx (&ctx, "YW\n", 3, &p, &len); + ASSERT (ok); + ASSERT (len == 0); + free (p); + + ok = base64_decode_alloc_ctx (&ctx, "JjZGVmZ2", 8, &p, &len); + ASSERT (ok); + ASSERT (len == 6); + ASSERT (memcmp (p, "abcdef", len) == 0); + free (p); + + ok = base64_decode_alloc_ctx (&ctx, "hp", 2, &p, &len); + ASSERT (ok); + ASSERT (len == 3); + ASSERT (memcmp (p, "ghi", len) == 0); + free (p); + + ok = base64_decode_alloc_ctx (&ctx, "", 0, &p, &len); + ASSERT (ok); + free (p); + } + + { + struct base64_decode_context ctx; + const char *newlineb64 = "\n\n\n\n\n"; + + base64_decode_ctx_init (&ctx); + + ok = base64_decode_alloc_ctx (&ctx, newlineb64, strlen (newlineb64), &p, &len); + ASSERT (ok); + ASSERT (len == 0); + free (p); + } + + ok = base64_decode_alloc_ctx (NULL, " ! ", 3, &p, &len); + ASSERT (!ok); + + ok = base64_decode_alloc_ctx (NULL, "abc\ndef", 7, &p, &len); + ASSERT (!ok); + + ok = base64_decode_alloc_ctx (NULL, "aa", 2, &p, &len); + ASSERT (!ok); + + ok = base64_decode_alloc_ctx (NULL, "aa=", 3, &p, &len); + ASSERT (!ok); + + ok = base64_decode_alloc_ctx (NULL, "aax", 3, &p, &len); + ASSERT (!ok); + + ok = base64_decode_alloc_ctx (NULL, "aa=X", 4, &p, &len); + ASSERT (!ok); + + ok = base64_decode_alloc_ctx (NULL, "aa=X", 4, &p, &len); + ASSERT (!ok); + + ok = base64_decode_alloc_ctx (NULL, "aax=X", 5, &p, &len); + ASSERT (!ok); + + return 0; +} diff --git a/gnulib-tests/test-binary-io.c b/gnulib-tests/test-binary-io.c new file mode 100644 index 0000000..808b8b5 --- /dev/null +++ b/gnulib-tests/test-binary-io.c @@ -0,0 +1,63 @@ +/* Test of binary mode I/O. + Copyright (C) 2005, 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2005. */ + +#include <config.h> + +#include "binary-io.h" + +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + /* Test the O_BINARY macro. */ + { + int fd = + open ("t-bin-out0.tmp", O_CREAT | O_TRUNC | O_RDWR | O_BINARY, 0600); + if (write (fd, "Hello\n", 6) < 0) + exit (1); + close (fd); + } + { + struct stat statbuf; + if (stat ("t-bin-out0.tmp", &statbuf) < 0) + exit (1); + ASSERT (statbuf.st_size == 6); + } + + switch (argv[1][0]) + { + case '1': + /* Test the set_binary_mode() function. */ + set_binary_mode (1, O_BINARY); + fputs ("Hello\n", stdout); + break; + + default: + break; + } + + return 0; +} diff --git a/gnulib-tests/test-binary-io.sh b/gnulib-tests/test-binary-io.sh new file mode 100755 index 0000000..a177d94 --- /dev/null +++ b/gnulib-tests/test-binary-io.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +tmpfiles="" +trap 'rm -fr $tmpfiles' 1 2 3 15 + +tmpfiles="$tmpfiles t-bin-out0.tmp t-bin-out1.tmp" +${CHECKER} ./test-binary-io${EXEEXT} 1 > t-bin-out1.tmp || exit 1 +cmp t-bin-out0.tmp t-bin-out1.tmp > /dev/null || exit 1 + +rm -fr $tmpfiles + +exit 0 diff --git a/gnulib-tests/test-bind.c b/gnulib-tests/test-bind.c new file mode 100644 index 0000000..2f38de9 --- /dev/null +++ b/gnulib-tests/test-bind.c @@ -0,0 +1,58 @@ +/* Test binding a server socket to a port. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <sys/socket.h> + +#include "signature.h" +SIGNATURE_CHECK (bind, int, (int, const struct sockaddr *, socklen_t)); + +#include <errno.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <unistd.h> + +#include "sockets.h" +#include "macros.h" + +int +main (void) +{ + (void) gl_sockets_startup (SOCKETS_1_1); + + /* Test behaviour for invalid file descriptors. */ + { + struct sockaddr_in addr; + + addr.sin_family = AF_INET; + inet_pton (AF_INET, "127.0.0.1", &addr.sin_addr); + addr.sin_port = htons (80); + { + errno = 0; + ASSERT (bind (-1, (const struct sockaddr *) &addr, sizeof (addr)) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (bind (99, (const struct sockaddr *) &addr, sizeof (addr)) == -1); + ASSERT (errno == EBADF); + } + } + + return 0; +} diff --git a/gnulib-tests/test-bitrotate.c b/gnulib-tests/test-bitrotate.c new file mode 100644 index 0000000..0007d1c --- /dev/null +++ b/gnulib-tests/test-bitrotate.c @@ -0,0 +1,279 @@ +/* Test of <bitrotate.h> substitute. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Simon Josefsson <simon@josefsson.org>, 2008. */ + +#include <config.h> + +#include "bitrotate.h" + +#include "macros.h" + +int +main (void) +{ + ASSERT (rotl8 (42, 0) == 42); + ASSERT (rotl8 (42, 1) == 84); + ASSERT (rotl8 (42, 2) == 168); + ASSERT (rotl8 (42, 3) == 81); + ASSERT (rotl8 (42, 4) == 162); + ASSERT (rotl8 (42, 5) == 69); + ASSERT (rotl8 (42, 6) == 138); + ASSERT (rotl8 (42, 7) == 21); + ASSERT (rotl8 (42, 8) == 42); + + ASSERT (rotr8 (42, 0) == 42); + ASSERT (rotr8 (42, 1) == 21); + ASSERT (rotr8 (42, 2) == 138); + ASSERT (rotr8 (42, 3) == 69); + ASSERT (rotr8 (42, 4) == 162); + ASSERT (rotr8 (42, 5) == 81); + ASSERT (rotr8 (42, 6) == 168); + ASSERT (rotr8 (42, 7) == 84); + ASSERT (rotr8 (42, 8) == 42); + + ASSERT (rotl16 (43981, 0) == 43981); + ASSERT (rotl16 (43981, 1) == 22427); + ASSERT (rotl16 (43981, 2) == 44854); + ASSERT (rotl16 (43981, 3) == 24173); + ASSERT (rotl16 (43981, 4) == 48346); + ASSERT (rotl16 (43981, 5) == 31157); + ASSERT (rotl16 (43981, 6) == 62314); + ASSERT (rotl16 (43981, 7) == 59093); + ASSERT (rotl16 (43981, 8) == 52651); + ASSERT (rotl16 (43981, 9) == 39767); + ASSERT (rotl16 (43981, 10) == 13999); + ASSERT (rotl16 (43981, 11) == 27998); + ASSERT (rotl16 (43981, 12) == 55996); + ASSERT (rotl16 (43981, 13) == 46457); + ASSERT (rotl16 (43981, 14) == 27379); + ASSERT (rotl16 (43981, 15) == 54758); + ASSERT (rotl16 (43981, 16) == 43981); + + ASSERT (rotr16 (43981, 0) == 43981); + ASSERT (rotr16 (43981, 1) == 54758); + ASSERT (rotr16 (43981, 2) == 27379); + ASSERT (rotr16 (43981, 3) == 46457); + ASSERT (rotr16 (43981, 4) == 55996); + ASSERT (rotr16 (43981, 5) == 27998); + ASSERT (rotr16 (43981, 6) == 13999); + ASSERT (rotr16 (43981, 7) == 39767); + ASSERT (rotr16 (43981, 8) == 52651); + ASSERT (rotr16 (43981, 9) == 59093); + ASSERT (rotr16 (43981, 10) == 62314); + ASSERT (rotr16 (43981, 11) == 31157); + ASSERT (rotr16 (43981, 12) == 48346); + ASSERT (rotr16 (43981, 13) == 24173); + ASSERT (rotr16 (43981, 14) == 44854); + ASSERT (rotr16 (43981, 15) == 22427); + ASSERT (rotr16 (43981, 16) == 43981); + + ASSERT (rotl32 (2309737967U, 1) == 324508639U); + ASSERT (rotl32 (2309737967U, 2) == 649017278U); + ASSERT (rotl32 (2309737967U, 3) == 1298034556U); + ASSERT (rotl32 (2309737967U, 4) == 2596069112U); + ASSERT (rotl32 (2309737967U, 5) == 897170929U); + ASSERT (rotl32 (2309737967U, 6) == 1794341858U); + ASSERT (rotl32 (2309737967U, 7) == 3588683716U); + ASSERT (rotl32 (2309737967U, 8) == 2882400137U); + ASSERT (rotl32 (2309737967U, 9) == 1469832979U); + ASSERT (rotl32 (2309737967U, 10) == 2939665958U); + ASSERT (rotl32 (2309737967U, 11) == 1584364621U); + ASSERT (rotl32 (2309737967U, 12) == 3168729242U); + ASSERT (rotl32 (2309737967U, 13) == 2042491189U); + ASSERT (rotl32 (2309737967U, 14) == 4084982378U); + ASSERT (rotl32 (2309737967U, 15) == 3874997461U); + ASSERT (rotl32 (2309737967U, 16) == 3455027627U); + ASSERT (rotl32 (2309737967U, 17) == 2615087959U); + ASSERT (rotl32 (2309737967U, 18) == 935208623U); + ASSERT (rotl32 (2309737967U, 19) == 1870417246U); + ASSERT (rotl32 (2309737967U, 20) == 3740834492U); + ASSERT (rotl32 (2309737967U, 21) == 3186701689U); + ASSERT (rotl32 (2309737967U, 22) == 2078436083U); + ASSERT (rotl32 (2309737967U, 23) == 4156872166U); + ASSERT (rotl32 (2309737967U, 24) == 4018777037U); + ASSERT (rotl32 (2309737967U, 25) == 3742586779U); + ASSERT (rotl32 (2309737967U, 26) == 3190206263U); + ASSERT (rotl32 (2309737967U, 27) == 2085445231U); + ASSERT (rotl32 (2309737967U, 28) == 4170890462U); + ASSERT (rotl32 (2309737967U, 29) == 4046813629U); + ASSERT (rotl32 (2309737967U, 30) == 3798659963U); + ASSERT (rotl32 (2309737967U, 31) == 3302352631U); + + ASSERT (rotr32 (2309737967U, 1) == 3302352631lU); + ASSERT (rotr32 (2309737967U, 2) == 3798659963lU); + ASSERT (rotr32 (2309737967U, 3) == 4046813629lU); + ASSERT (rotr32 (2309737967U, 4) == 4170890462lU); + ASSERT (rotr32 (2309737967U, 5) == 2085445231lU); + ASSERT (rotr32 (2309737967U, 6) == 3190206263lU); + ASSERT (rotr32 (2309737967U, 7) == 3742586779lU); + ASSERT (rotr32 (2309737967U, 8) == 4018777037lU); + ASSERT (rotr32 (2309737967U, 9) == 4156872166lU); + ASSERT (rotr32 (2309737967U, 10) == 2078436083lU); + ASSERT (rotr32 (2309737967U, 11) == 3186701689lU); + ASSERT (rotr32 (2309737967U, 12) == 3740834492lU); + ASSERT (rotr32 (2309737967U, 13) == 1870417246lU); + ASSERT (rotr32 (2309737967U, 14) == 935208623lU); + ASSERT (rotr32 (2309737967U, 15) == 2615087959lU); + ASSERT (rotr32 (2309737967U, 16) == 3455027627lU); + ASSERT (rotr32 (2309737967U, 17) == 3874997461lU); + ASSERT (rotr32 (2309737967U, 18) == 4084982378lU); + ASSERT (rotr32 (2309737967U, 19) == 2042491189lU); + ASSERT (rotr32 (2309737967U, 20) == 3168729242lU); + ASSERT (rotr32 (2309737967U, 21) == 1584364621lU); + ASSERT (rotr32 (2309737967U, 22) == 2939665958lU); + ASSERT (rotr32 (2309737967U, 23) == 1469832979lU); + ASSERT (rotr32 (2309737967U, 24) == 2882400137lU); + ASSERT (rotr32 (2309737967U, 25) == 3588683716lU); + ASSERT (rotr32 (2309737967U, 26) == 1794341858lU); + ASSERT (rotr32 (2309737967U, 27) == 897170929lU); + ASSERT (rotr32 (2309737967U, 28) == 2596069112lU); + ASSERT (rotr32 (2309737967U, 29) == 1298034556lU); + ASSERT (rotr32 (2309737967U, 30) == 649017278lU); + ASSERT (rotr32 (2309737967U, 31) == 324508639lU); + +#ifdef UINT64_MAX + ASSERT (rotl64 (16045690984503098046ULL, 1) == 13644637895296644477ULL); + ASSERT (rotl64 (16045690984503098046ULL, 2) == 8842531716883737339ULL); + ASSERT (rotl64 (16045690984503098046ULL, 3) == 17685063433767474678ULL); + ASSERT (rotl64 (16045690984503098046ULL, 4) == 16923382793825397741ULL); + ASSERT (rotl64 (16045690984503098046ULL, 5) == 15400021513941243867ULL); + ASSERT (rotl64 (16045690984503098046ULL, 6) == 12353298954172936119ULL); + ASSERT (rotl64 (16045690984503098046ULL, 7) == 6259853834636320623ULL); + ASSERT (rotl64 (16045690984503098046ULL, 8) == 12519707669272641246ULL); + ASSERT (rotl64 (16045690984503098046ULL, 9) == 6592671264835730877ULL); + ASSERT (rotl64 (16045690984503098046ULL, 10) == 13185342529671461754ULL); + ASSERT (rotl64 (16045690984503098046ULL, 11) == 7923940985633371893ULL); + ASSERT (rotl64 (16045690984503098046ULL, 12) == 15847881971266743786ULL); + ASSERT (rotl64 (16045690984503098046ULL, 13) == 13249019868823935957ULL); + ASSERT (rotl64 (16045690984503098046ULL, 14) == 8051295663938320299ULL); + ASSERT (rotl64 (16045690984503098046ULL, 15) == 16102591327876640598ULL); + ASSERT (rotl64 (16045690984503098046ULL, 16) == 13758438582043729581ULL); + ASSERT (rotl64 (16045690984503098046ULL, 17) == 9070133090377907547ULL); + ASSERT (rotl64 (16045690984503098046ULL, 18) == 18140266180755815094ULL); + ASSERT (rotl64 (16045690984503098046ULL, 19) == 17833788287802078573ULL); + ASSERT (rotl64 (16045690984503098046ULL, 20) == 17220832501894605531ULL); + ASSERT (rotl64 (16045690984503098046ULL, 21) == 15994920930079659447ULL); + ASSERT (rotl64 (16045690984503098046ULL, 22) == 13543097786449767279ULL); + ASSERT (rotl64 (16045690984503098046ULL, 23) == 8639451499189982943ULL); + ASSERT (rotl64 (16045690984503098046ULL, 24) == 17278902998379965886ULL); + ASSERT (rotl64 (16045690984503098046ULL, 25) == 16111061923050380157ULL); + ASSERT (rotl64 (16045690984503098046ULL, 26) == 13775379772391208699ULL); + ASSERT (rotl64 (16045690984503098046ULL, 27) == 9104015471072865783ULL); + ASSERT (rotl64 (16045690984503098046ULL, 28) == 18208030942145731566ULL); + ASSERT (rotl64 (16045690984503098046ULL, 29) == 17969317810581911517ULL); + ASSERT (rotl64 (16045690984503098046ULL, 30) == 17491891547454271419ULL); + ASSERT (rotl64 (16045690984503098046ULL, 31) == 16537039021198991223ULL); + ASSERT (rotl64 (16045690984503098046ULL, 32) == 14627333968688430831ULL); + ASSERT (rotl64 (16045690984503098046ULL, 33) == 10807923863667310047ULL); + ASSERT (rotl64 (16045690984503098046ULL, 34) == 3169103653625068479ULL); + ASSERT (rotl64 (16045690984503098046ULL, 35) == 6338207307250136958ULL); + ASSERT (rotl64 (16045690984503098046ULL, 36) == 12676414614500273916ULL); + ASSERT (rotl64 (16045690984503098046ULL, 37) == 6906085155290996217ULL); + ASSERT (rotl64 (16045690984503098046ULL, 38) == 13812170310581992434ULL); + ASSERT (rotl64 (16045690984503098046ULL, 39) == 9177596547454433253ULL); + ASSERT (rotl64 (16045690984503098046ULL, 40) == 18355193094908866506ULL); + ASSERT (rotl64 (16045690984503098046ULL, 41) == 18263642116108181397ULL); + ASSERT (rotl64 (16045690984503098046ULL, 42) == 18080540158506811179ULL); + ASSERT (rotl64 (16045690984503098046ULL, 43) == 17714336243304070743ULL); + ASSERT (rotl64 (16045690984503098046ULL, 44) == 16981928412898589871ULL); + ASSERT (rotl64 (16045690984503098046ULL, 45) == 15517112752087628127ULL); + ASSERT (rotl64 (16045690984503098046ULL, 46) == 12587481430465704639ULL); + ASSERT (rotl64 (16045690984503098046ULL, 47) == 6728218787221857663ULL); + ASSERT (rotl64 (16045690984503098046ULL, 48) == 13456437574443715326ULL); + ASSERT (rotl64 (16045690984503098046ULL, 49) == 8466131075177879037ULL); + ASSERT (rotl64 (16045690984503098046ULL, 50) == 16932262150355758074ULL); + ASSERT (rotl64 (16045690984503098046ULL, 51) == 15417780227001964533ULL); + ASSERT (rotl64 (16045690984503098046ULL, 52) == 12388816380294377451ULL); + ASSERT (rotl64 (16045690984503098046ULL, 53) == 6330888686879203287ULL); + ASSERT (rotl64 (16045690984503098046ULL, 54) == 12661777373758406574ULL); + ASSERT (rotl64 (16045690984503098046ULL, 55) == 6876810673807261533ULL); + ASSERT (rotl64 (16045690984503098046ULL, 56) == 13753621347614523066ULL); + ASSERT (rotl64 (16045690984503098046ULL, 57) == 9060498621519494517ULL); + ASSERT (rotl64 (16045690984503098046ULL, 58) == 18120997243038989034ULL); + ASSERT (rotl64 (16045690984503098046ULL, 59) == 17795250412368426453ULL); + ASSERT (rotl64 (16045690984503098046ULL, 60) == 17143756751027301291ULL); + ASSERT (rotl64 (16045690984503098046ULL, 61) == 15840769428345050967ULL); + ASSERT (rotl64 (16045690984503098046ULL, 62) == 13234794782980550319ULL); + ASSERT (rotl64 (16045690984503098046ULL, 63) == 8022845492251549023ULL); + + ASSERT (rotr64 (16045690984503098046ULL, 1) == 8022845492251549023ULL); + ASSERT (rotr64 (16045690984503098046ULL, 2) == 13234794782980550319ULL); + ASSERT (rotr64 (16045690984503098046ULL, 3) == 15840769428345050967ULL); + ASSERT (rotr64 (16045690984503098046ULL, 4) == 17143756751027301291ULL); + ASSERT (rotr64 (16045690984503098046ULL, 5) == 17795250412368426453ULL); + ASSERT (rotr64 (16045690984503098046ULL, 6) == 18120997243038989034ULL); + ASSERT (rotr64 (16045690984503098046ULL, 7) == 9060498621519494517ULL); + ASSERT (rotr64 (16045690984503098046ULL, 8) == 13753621347614523066ULL); + ASSERT (rotr64 (16045690984503098046ULL, 9) == 6876810673807261533ULL); + ASSERT (rotr64 (16045690984503098046ULL, 10) == 12661777373758406574ULL); + ASSERT (rotr64 (16045690984503098046ULL, 11) == 6330888686879203287ULL); + ASSERT (rotr64 (16045690984503098046ULL, 12) == 12388816380294377451ULL); + ASSERT (rotr64 (16045690984503098046ULL, 13) == 15417780227001964533ULL); + ASSERT (rotr64 (16045690984503098046ULL, 14) == 16932262150355758074ULL); + ASSERT (rotr64 (16045690984503098046ULL, 15) == 8466131075177879037ULL); + ASSERT (rotr64 (16045690984503098046ULL, 16) == 13456437574443715326ULL); + ASSERT (rotr64 (16045690984503098046ULL, 17) == 6728218787221857663ULL); + ASSERT (rotr64 (16045690984503098046ULL, 18) == 12587481430465704639ULL); + ASSERT (rotr64 (16045690984503098046ULL, 19) == 15517112752087628127ULL); + ASSERT (rotr64 (16045690984503098046ULL, 20) == 16981928412898589871ULL); + ASSERT (rotr64 (16045690984503098046ULL, 21) == 17714336243304070743ULL); + ASSERT (rotr64 (16045690984503098046ULL, 22) == 18080540158506811179ULL); + ASSERT (rotr64 (16045690984503098046ULL, 23) == 18263642116108181397ULL); + ASSERT (rotr64 (16045690984503098046ULL, 24) == 18355193094908866506ULL); + ASSERT (rotr64 (16045690984503098046ULL, 25) == 9177596547454433253ULL); + ASSERT (rotr64 (16045690984503098046ULL, 26) == 13812170310581992434ULL); + ASSERT (rotr64 (16045690984503098046ULL, 27) == 6906085155290996217ULL); + ASSERT (rotr64 (16045690984503098046ULL, 28) == 12676414614500273916ULL); + ASSERT (rotr64 (16045690984503098046ULL, 29) == 6338207307250136958ULL); + ASSERT (rotr64 (16045690984503098046ULL, 30) == 3169103653625068479ULL); + ASSERT (rotr64 (16045690984503098046ULL, 31) == 10807923863667310047ULL); + ASSERT (rotr64 (16045690984503098046ULL, 32) == 14627333968688430831ULL); + ASSERT (rotr64 (16045690984503098046ULL, 33) == 16537039021198991223ULL); + ASSERT (rotr64 (16045690984503098046ULL, 34) == 17491891547454271419ULL); + ASSERT (rotr64 (16045690984503098046ULL, 35) == 17969317810581911517ULL); + ASSERT (rotr64 (16045690984503098046ULL, 36) == 18208030942145731566ULL); + ASSERT (rotr64 (16045690984503098046ULL, 37) == 9104015471072865783ULL); + ASSERT (rotr64 (16045690984503098046ULL, 38) == 13775379772391208699ULL); + ASSERT (rotr64 (16045690984503098046ULL, 39) == 16111061923050380157ULL); + ASSERT (rotr64 (16045690984503098046ULL, 40) == 17278902998379965886ULL); + ASSERT (rotr64 (16045690984503098046ULL, 41) == 8639451499189982943ULL); + ASSERT (rotr64 (16045690984503098046ULL, 42) == 13543097786449767279ULL); + ASSERT (rotr64 (16045690984503098046ULL, 43) == 15994920930079659447ULL); + ASSERT (rotr64 (16045690984503098046ULL, 44) == 17220832501894605531ULL); + ASSERT (rotr64 (16045690984503098046ULL, 45) == 17833788287802078573ULL); + ASSERT (rotr64 (16045690984503098046ULL, 46) == 18140266180755815094ULL); + ASSERT (rotr64 (16045690984503098046ULL, 47) == 9070133090377907547ULL); + ASSERT (rotr64 (16045690984503098046ULL, 48) == 13758438582043729581ULL); + ASSERT (rotr64 (16045690984503098046ULL, 49) == 16102591327876640598ULL); + ASSERT (rotr64 (16045690984503098046ULL, 50) == 8051295663938320299ULL); + ASSERT (rotr64 (16045690984503098046ULL, 51) == 13249019868823935957ULL); + ASSERT (rotr64 (16045690984503098046ULL, 52) == 15847881971266743786ULL); + ASSERT (rotr64 (16045690984503098046ULL, 53) == 7923940985633371893ULL); + ASSERT (rotr64 (16045690984503098046ULL, 54) == 13185342529671461754ULL); + ASSERT (rotr64 (16045690984503098046ULL, 55) == 6592671264835730877ULL); + ASSERT (rotr64 (16045690984503098046ULL, 56) == 12519707669272641246ULL); + ASSERT (rotr64 (16045690984503098046ULL, 57) == 6259853834636320623ULL); + ASSERT (rotr64 (16045690984503098046ULL, 58) == 12353298954172936119ULL); + ASSERT (rotr64 (16045690984503098046ULL, 59) == 15400021513941243867ULL); + ASSERT (rotr64 (16045690984503098046ULL, 60) == 16923382793825397741ULL); + ASSERT (rotr64 (16045690984503098046ULL, 61) == 17685063433767474678ULL); + ASSERT (rotr64 (16045690984503098046ULL, 62) == 8842531716883737339ULL); + ASSERT (rotr64 (16045690984503098046ULL, 63) == 13644637895296644477ULL); +#endif /* UINT64_MAX */ + + return 0; +} diff --git a/gnulib-tests/test-btowc.c b/gnulib-tests/test-btowc.c new file mode 100644 index 0000000..18ad71b --- /dev/null +++ b/gnulib-tests/test-btowc.c @@ -0,0 +1,63 @@ +/* Test of conversion of unibyte character to wide character. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2008. */ + +#include <config.h> + +#include <wchar.h> + +#include "signature.h" +SIGNATURE_CHECK (btowc, wint_t, (int)); + +#include <locale.h> +#include <stdio.h> + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + int c; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + ASSERT (btowc (EOF) == WEOF); + + if (argc > 1) + switch (argv[1][0]) + { + case '1': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + for (c = 0; c < 0x80; c++) + ASSERT (btowc (c) == c); + for (c = 0xA0; c < 0x100; c++) + ASSERT (btowc (c) != WEOF); + return 0; + + case '2': + /* Locale encoding is UTF-8. */ + for (c = 0; c < 0x80; c++) + ASSERT (btowc (c) == c); + for (c = 0x80; c < 0x100; c++) + ASSERT (btowc (c) == WEOF); + return 0; + } + + return 1; +} diff --git a/gnulib-tests/test-btowc1.sh b/gnulib-tests/test-btowc1.sh new file mode 100755 index 0000000..ab4b287 --- /dev/null +++ b/gnulib-tests/test-btowc1.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: ${LOCALE_FR=fr_FR} +if test $LOCALE_FR = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no traditional french locale is installed" + else + echo "Skipping test: no traditional french locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR \ +${CHECKER} ./test-btowc${EXEEXT} 1 diff --git a/gnulib-tests/test-btowc2.sh b/gnulib-tests/test-btowc2.sh new file mode 100755 index 0000000..d7d4d9c --- /dev/null +++ b/gnulib-tests/test-btowc2.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific UTF-8 locale is installed. +: ${LOCALE_FR_UTF8=fr_FR.UTF-8} +if test $LOCALE_FR_UTF8 = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no french Unicode locale is installed" + else + echo "Skipping test: no french Unicode locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR_UTF8 \ +${CHECKER} ./test-btowc${EXEEXT} 2 diff --git a/gnulib-tests/test-byteswap.c b/gnulib-tests/test-byteswap.c new file mode 100644 index 0000000..e499838 --- /dev/null +++ b/gnulib-tests/test-byteswap.c @@ -0,0 +1,32 @@ +/* Test of <byteswap.h> substitute. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <byteswap.h> + +#include "macros.h" + +int +main () +{ + ASSERT (bswap_16 (0xABCD) == 0xCDAB); + ASSERT (bswap_32 (0xDEADBEEF) == 0xEFBEADDE); + + return 0; +} diff --git a/gnulib-tests/test-c-ctype.c b/gnulib-tests/test-c-ctype.c new file mode 100644 index 0000000..0cf1fdf --- /dev/null +++ b/gnulib-tests/test-c-ctype.c @@ -0,0 +1,228 @@ +/* Test of character handling in C locale. + Copyright (C) 2005, 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2005. */ + +#include <config.h> + +#include "c-ctype.h" + +#include <ctype.h> +#include <limits.h> +#include <locale.h> + +#include "macros.h" + +static void +test_agree_with_C_locale (void) +{ + int c; + + for (c = 0; c <= UCHAR_MAX; c++) + { + ASSERT (c_isascii (c) == (isascii (c) != 0)); + if (c_isascii (c)) + { + ASSERT (c_isalnum (c) == (isalnum (c) != 0)); + ASSERT (c_isalpha (c) == (isalpha (c) != 0)); + ASSERT (c_isblank (c) == (isblank (c) != 0)); + ASSERT (c_iscntrl (c) == (iscntrl (c) != 0)); + ASSERT (c_isdigit (c) == (isdigit (c) != 0)); + ASSERT (c_islower (c) == (islower (c) != 0)); + ASSERT (c_isgraph (c) == (isgraph (c) != 0)); + ASSERT (c_isprint (c) == (isprint (c) != 0)); + ASSERT (c_ispunct (c) == (ispunct (c) != 0)); + ASSERT (c_isspace (c) == (isspace (c) != 0)); + ASSERT (c_isupper (c) == (isupper (c) != 0)); + ASSERT (c_isxdigit (c) == (isxdigit (c) != 0)); + ASSERT (c_tolower (c) == tolower (c)); + ASSERT (c_toupper (c) == toupper (c)); + } + } +} + +static void +test_all (void) +{ + int c; + int n_isascii = 0; + + for (c = CHAR_MIN; c <= UCHAR_MAX; c++) + { + if (! (0 <= c && c <= CHAR_MAX)) + { + ASSERT (! c_isascii (c)); + ASSERT (! c_isalnum (c)); + ASSERT (! c_isalpha (c)); + ASSERT (! c_isblank (c)); + ASSERT (! c_iscntrl (c)); + ASSERT (! c_isdigit (c)); + ASSERT (! c_islower (c)); + ASSERT (! c_isgraph (c)); + ASSERT (! c_isprint (c)); + ASSERT (! c_ispunct (c)); + ASSERT (! c_isspace (c)); + ASSERT (! c_isupper (c)); + ASSERT (! c_isxdigit (c)); + ASSERT (c_tolower (c) == c); + ASSERT (c_toupper (c) == c); + } + + n_isascii += c_isascii (c); + +#ifdef C_CTYPE_ASCII + ASSERT (c_isascii (c) == (0 <= c && c <= 0x7f)); +#endif + + ASSERT (c_isascii (c) == (c_isprint (c) || c_iscntrl (c))); + + ASSERT (c_isalnum (c) == (c_isalpha (c) || c_isdigit (c))); + + ASSERT (c_isalpha (c) == (c_islower (c) || c_isupper (c))); + + switch (c) + { + case '\t': case ' ': + ASSERT (c_isblank (c) == 1); + break; + default: + ASSERT (c_isblank (c) == 0); + break; + } + +#ifdef C_CTYPE_ASCII + ASSERT (c_iscntrl (c) == ((c >= 0 && c < 0x20) || c == 0x7f)); +#endif + + switch (c) + { + case '\a': case '\b': case '\f': case '\n': + case '\r': case '\t': case '\v': + ASSERT (c_iscntrl (c)); + break; + } + + ASSERT (! (c_iscntrl (c) && c_isprint (c))); + + switch (c) + { + case '0': case '1': case '2': case '3': case '4': case '5': + case '6': case '7': case '8': case '9': + ASSERT (c_isdigit (c) == 1); + break; + default: + ASSERT (c_isdigit (c) == 0); + break; + } + + switch (c) + { + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': + case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': + case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': + case 's': case 't': case 'u': case 'v': case 'w': case 'x': + case 'y': case 'z': + ASSERT (c_islower (c) == 1); + ASSERT (c_toupper (c) == c - 'a' + 'A'); + break; + default: + ASSERT (c_islower (c) == 0); + ASSERT (c_toupper (c) == c); + break; + } + +#ifdef C_CTYPE_ASCII + ASSERT (c_isgraph (c) == ((c >= 0x20 && c < 0x7f) && c != ' ')); + + ASSERT (c_isprint (c) == (c >= 0x20 && c < 0x7f)); +#endif + + ASSERT (c_isgraph (c) == (c_isalnum (c) || c_ispunct (c))); + + ASSERT (c_isprint (c) == (c_isgraph (c) || c == ' ')); + + switch (c) + { + case '!': case '"': case '#': case '$': case '%': case '&': case '\'': + case '(': case ')': case '*': case '+': case ',': case '-': case '.': + case '/': case ':': case ';': case '<': case '=': case '>': case '?': + case '@': case '[': case'\\': case ']': case '^': case '_': case '`': + case '{': case '|': case '}': case '~': + ASSERT (c_ispunct (c) == 1); + break; + default: + ASSERT (c_ispunct (c) == 0); + break; + } + + switch (c) + { + case ' ': case '\t': case '\n': case '\v': case '\f': case '\r': + ASSERT (c_isspace (c) == 1); + break; + default: + ASSERT (c_isspace (c) == 0); + break; + } + + switch (c) + { + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': + case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': + case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': + case 'Y': case 'Z': + ASSERT (c_isupper (c) == 1); + ASSERT (c_tolower (c) == c - 'A' + 'a'); + break; + default: + ASSERT (c_isupper (c) == 0); + ASSERT (c_tolower (c) == c); + break; + } + + switch (c) + { + case '0': case '1': case '2': case '3': case '4': case '5': + case '6': case '7': case '8': case '9': + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': + ASSERT (c_isxdigit (c) == 1); + break; + default: + ASSERT (c_isxdigit (c) == 0); + break; + } + } + + ASSERT (n_isascii == 128); +} + +int +main () +{ + test_agree_with_C_locale (); + + test_all (); + + setlocale (LC_ALL, "de_DE"); + test_all (); + + setlocale (LC_ALL, "ja_JP.EUC-JP"); + test_all (); + + return 0; +} diff --git a/gnulib-tests/test-c-strcase.sh b/gnulib-tests/test-c-strcase.sh new file mode 100755 index 0000000..14bdfb2 --- /dev/null +++ b/gnulib-tests/test-c-strcase.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +# Test in the C locale. +${CHECKER} ./test-c-strcasecmp${EXEEXT} || exit 1 +${CHECKER} ./test-c-strncasecmp${EXEEXT} || exit 1 + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: ${LOCALE_FR=fr_FR} +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR ${CHECKER} ./test-c-strcasecmp${EXEEXT} locale || exit 1 + LC_ALL=$LOCALE_FR ${CHECKER} ./test-c-strncasecmp${EXEEXT} locale || exit 1 +fi + +# Test in a Turkish UTF-8 locale. +: ${LOCALE_TR_UTF8=tr_TR.UTF-8} +if test $LOCALE_TR_UTF8 != none; then + LC_ALL=$LOCALE_TR_UTF8 ${CHECKER} ./test-c-strcasecmp${EXEEXT} locale || exit 1 + LC_ALL=$LOCALE_TR_UTF8 ${CHECKER} ./test-c-strncasecmp${EXEEXT} locale || exit 1 +fi + +exit 0 diff --git a/gnulib-tests/test-c-strcasecmp.c b/gnulib-tests/test-c-strcasecmp.c new file mode 100644 index 0000000..c73cb9d --- /dev/null +++ b/gnulib-tests/test-c-strcasecmp.c @@ -0,0 +1,68 @@ +/* Test of case-insensitive string comparison function. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include "c-strcase.h" +#include "c-ctype.h" + +#include <locale.h> +#include <string.h> + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + if (argc > 1) + { + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + } + + ASSERT (c_strcasecmp ("paragraph", "Paragraph") == 0); + + ASSERT (c_strcasecmp ("paragrapH", "parAgRaph") == 0); + + ASSERT (c_strcasecmp ("paragraph", "paraLyzed") < 0); + ASSERT (c_strcasecmp ("paraLyzed", "paragraph") > 0); + + ASSERT (c_strcasecmp ("para", "paragraph") < 0); + ASSERT (c_strcasecmp ("paragraph", "para") > 0); + + /* The following tests shows how c_strcasecmp() is different from + strcasecmp(). */ + + ASSERT (c_strcasecmp ("\311mile", "\351mile") < 0); + ASSERT (c_strcasecmp ("\351mile", "\311mile") > 0); + + /* The following tests shows how c_strcasecmp() is different from + mbscasecmp(). */ + + ASSERT (c_strcasecmp ("\303\266zg\303\274r", "\303\226ZG\303\234R") > 0); /* özgür */ + ASSERT (c_strcasecmp ("\303\226ZG\303\234R", "\303\266zg\303\274r") < 0); /* özgür */ + +#if C_CTYPE_ASCII + /* This test shows how strings of different size cannot compare equal. */ + ASSERT (c_strcasecmp ("turkish", "TURK\304\260SH") < 0); + ASSERT (c_strcasecmp ("TURK\304\260SH", "turkish") > 0); +#endif + + return 0; +} diff --git a/gnulib-tests/test-c-strncasecmp.c b/gnulib-tests/test-c-strncasecmp.c new file mode 100644 index 0000000..bbef54f --- /dev/null +++ b/gnulib-tests/test-c-strncasecmp.c @@ -0,0 +1,82 @@ +/* Test of case-insensitive string comparison function. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include "c-strcase.h" +#include "c-ctype.h" + +#include <locale.h> +#include <string.h> + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + if (argc > 1) + { + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + } + + ASSERT (c_strncasecmp ("paragraph", "Paragraph", 1000000) == 0); + ASSERT (c_strncasecmp ("paragraph", "Paragraph", 9) == 0); + + ASSERT (c_strncasecmp ("paragrapH", "parAgRaph", 1000000) == 0); + ASSERT (c_strncasecmp ("paragrapH", "parAgRaph", 9) == 0); + + ASSERT (c_strncasecmp ("paragraph", "paraLyzed", 10) < 0); + ASSERT (c_strncasecmp ("paragraph", "paraLyzed", 9) < 0); + ASSERT (c_strncasecmp ("paragraph", "paraLyzed", 5) < 0); + ASSERT (c_strncasecmp ("paragraph", "paraLyzed", 4) == 0); + ASSERT (c_strncasecmp ("paraLyzed", "paragraph", 10) > 0); + ASSERT (c_strncasecmp ("paraLyzed", "paragraph", 9) > 0); + ASSERT (c_strncasecmp ("paraLyzed", "paragraph", 5) > 0); + ASSERT (c_strncasecmp ("paraLyzed", "paragraph", 4) == 0); + + ASSERT (c_strncasecmp ("para", "paragraph", 10) < 0); + ASSERT (c_strncasecmp ("para", "paragraph", 9) < 0); + ASSERT (c_strncasecmp ("para", "paragraph", 5) < 0); + ASSERT (c_strncasecmp ("para", "paragraph", 4) == 0); + ASSERT (c_strncasecmp ("paragraph", "para", 10) > 0); + ASSERT (c_strncasecmp ("paragraph", "para", 9) > 0); + ASSERT (c_strncasecmp ("paragraph", "para", 5) > 0); + ASSERT (c_strncasecmp ("paragraph", "para", 4) == 0); + + /* The following tests shows how c_strncasecmp() is different from + strncasecmp(). */ + + ASSERT (c_strncasecmp ("\311mily", "\351mile", 4) < 0); + ASSERT (c_strncasecmp ("\351mile", "\311mily", 4) > 0); + + /* The following tests shows how c_strncasecmp() is different from + mbsncasecmp(). */ + + ASSERT (c_strncasecmp ("\303\266zg\303\274r", "\303\226ZG\303\234R", 99) > 0); /* özgür */ + ASSERT (c_strncasecmp ("\303\226ZG\303\234R", "\303\266zg\303\274r", 99) < 0); /* özgür */ + +#if C_CTYPE_ASCII + /* This test shows how strings of different size cannot compare equal. */ + ASSERT (c_strncasecmp ("turkish", "TURK\304\260SH", 7) < 0); + ASSERT (c_strncasecmp ("TURK\304\260SH", "turkish", 7) > 0); +#endif + + return 0; +} diff --git a/gnulib-tests/test-calloc-gnu.c b/gnulib-tests/test-calloc-gnu.c new file mode 100644 index 0000000..c13ba47 --- /dev/null +++ b/gnulib-tests/test-calloc-gnu.c @@ -0,0 +1,55 @@ +/* Test of calloc function. + Copyright (C) 2010-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdlib.h> + +/* Return 8. + Usual compilers are not able to infer something about the return value. */ +static unsigned int +eight (void) +{ + unsigned int x = rand (); + unsigned int y = x * x * x * x; + x++; y |= x * x * x * x; + x++; y |= x * x * x * x; + x++; y |= x * x * x * x; + y = y >> 1; + return y & -y; +} + +int +main () +{ + /* Check that calloc (0, 0) is not a NULL pointer. */ + void *p = calloc (0, 0); + if (p == NULL) + return 1; + free (p); + + /* Check that calloc fails when requested to allocate a block of memory + larger than SIZE_MAX bytes. + We use eight (), not 8, to avoid a compiler warning from GCC 7. */ + p = calloc ((size_t) -1 / 8 + 1, eight ()); + if (p != NULL) + { + free (p); + return 1; + } + + return 0; +} diff --git a/gnulib-tests/test-canonicalize.c b/gnulib-tests/test-canonicalize.c new file mode 100644 index 0000000..e0b623f --- /dev/null +++ b/gnulib-tests/test-canonicalize.c @@ -0,0 +1,375 @@ +/* Test of execution of file name canonicalization. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc + may "optimize" the null_ptr function, when its result gets passed to a + function that has an argument declared as _GL_ARG_NONNULL. */ +#define _GL_ARG_NONNULL(params) + +#include <config.h> + +#include "canonicalize.h" + +#include <errno.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> +#include <unistd.h> + +#include "same-inode.h" +#include "ignore-value.h" + +#if GNULIB_defined_canonicalize_file_name +# include "null-ptr.h" +#endif + +#include "macros.h" + +#define BASE "t-can.tmp" + +int +main (void) +{ + /* Setup some hierarchy to be used by this test. Start by removing + any leftovers from a previous partial run. */ + { + int fd; + ignore_value (system ("rm -rf " BASE " ise")); + ASSERT (mkdir (BASE, 0700) == 0); + fd = creat (BASE "/tra", 0600); + ASSERT (0 <= fd); + ASSERT (close (fd) == 0); + } + + /* Check for ., .., intermediate // handling, and for error cases. */ + { + char *result1 = canonicalize_file_name (BASE "//./..//" BASE "/tra"); + char *result2 = canonicalize_filename_mode (BASE "//./..//" BASE "/tra", + CAN_EXISTING); + ASSERT (result1 != NULL); + ASSERT (result2 != NULL); + ASSERT (strcmp (result1, result2) == 0); + ASSERT (strstr (result1, "/" BASE "/tra") + == result1 + strlen (result1) - strlen ("/" BASE "/tra")); + free (result1); + free (result2); + + errno = 0; + result1 = canonicalize_file_name (""); + ASSERT (result1 == NULL); + ASSERT (errno == ENOENT); + + errno = 0; + result2 = canonicalize_filename_mode ("", CAN_EXISTING); + ASSERT (result2 == NULL); + ASSERT (errno == ENOENT); + + /* This test works only if the canonicalize_file_name implementation + comes from gnulib. If it comes from libc, we have no way to prevent + gcc from "optimizing" the null_ptr function in invalid ways. See + <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93156>. */ +#if GNULIB_defined_canonicalize_file_name + errno = 0; + result1 = canonicalize_file_name (null_ptr ()); + ASSERT (result1 == NULL); + ASSERT (errno == EINVAL); +#endif + + errno = 0; + result2 = canonicalize_filename_mode (NULL, CAN_EXISTING); + ASSERT (result2 == NULL); + ASSERT (errno == EINVAL); + + errno = 0; + result2 = canonicalize_filename_mode (".", CAN_MISSING | CAN_ALL_BUT_LAST); + ASSERT (result2 == NULL); + ASSERT (errno == EINVAL); + } + + /* Check that a non-directory with trailing slash yields NULL. */ + { + char *result1; + char *result2; + errno = 0; + result1 = canonicalize_file_name (BASE "/tra/"); + ASSERT (result1 == NULL); + ASSERT (errno == ENOTDIR); + errno = 0; + result2 = canonicalize_filename_mode (BASE "/tra/", CAN_EXISTING); + ASSERT (result2 == NULL); + ASSERT (errno == ENOTDIR); + } + + /* Check that a missing directory yields NULL. */ + { + char *result1; + char *result2; + errno = 0; + result1 = canonicalize_file_name (BASE "/zzz/.."); + ASSERT (result1 == NULL); + ASSERT (errno == ENOENT); + errno = 0; + result2 = canonicalize_filename_mode (BASE "/zzz/..", CAN_EXISTING); + ASSERT (result2 == NULL); + ASSERT (errno == ENOENT); + } + + /* From here on out, tests involve symlinks. */ + if (symlink (BASE "/ket", "ise") != 0) + { + ASSERT (remove (BASE "/tra") == 0); + ASSERT (rmdir (BASE) == 0); + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + ASSERT (symlink ("bef", BASE "/plo") == 0); + ASSERT (symlink ("tra", BASE "/huk") == 0); + ASSERT (symlink ("lum", BASE "/bef") == 0); + ASSERT (symlink ("wum", BASE "/ouk") == 0); + ASSERT (symlink ("../ise", BASE "/ket") == 0); + ASSERT (mkdir (BASE "/lum", 0700) == 0); + ASSERT (symlink ("s", BASE "/p") == 0); + ASSERT (symlink ("d", BASE "/s") == 0); + ASSERT (mkdir (BASE "/d", 0700) == 0); + ASSERT (close (creat (BASE "/d/2", 0600)) == 0); + ASSERT (symlink ("../s/2", BASE "/d/1") == 0); + ASSERT (symlink ("//.//../..", BASE "/droot") == 0); + + /* Check that symbolic links are not resolved, with CAN_NOLINKS. */ + { + char *result1 = canonicalize_filename_mode (BASE "/huk", CAN_NOLINKS); + ASSERT (result1 != NULL); + ASSERT (strcmp (result1 + strlen (result1) - strlen ("/" BASE "/huk"), + "/" BASE "/huk") == 0); + free (result1); + } + + /* Check that the symbolic link to a file can be resolved. */ + { + char *result1 = canonicalize_file_name (BASE "/huk"); + char *result2 = canonicalize_file_name (BASE "/tra"); + char *result3 = canonicalize_filename_mode (BASE "/huk", CAN_EXISTING); + ASSERT (result1 != NULL); + ASSERT (result2 != NULL); + ASSERT (result3 != NULL); + ASSERT (strcmp (result1, result2) == 0); + ASSERT (strcmp (result2, result3) == 0); + ASSERT (strcmp (result1 + strlen (result1) - strlen ("/" BASE "/tra"), + "/" BASE "/tra") == 0); + free (result1); + free (result2); + free (result3); + } + + /* Check that the symbolic link to a directory can be resolved. */ + { + char *result1 = canonicalize_file_name (BASE "/plo"); + char *result2 = canonicalize_file_name (BASE "/bef"); + char *result3 = canonicalize_file_name (BASE "/lum"); + char *result4 = canonicalize_filename_mode (BASE "/plo", CAN_EXISTING); + ASSERT (result1 != NULL); + ASSERT (result2 != NULL); + ASSERT (result3 != NULL); + ASSERT (result4 != NULL); + ASSERT (strcmp (result1, result2) == 0); + ASSERT (strcmp (result2, result3) == 0); + ASSERT (strcmp (result3, result4) == 0); + ASSERT (strcmp (result1 + strlen (result1) - strlen ("/" BASE "/lum"), + "/" BASE "/lum") == 0); + free (result1); + free (result2); + free (result3); + free (result4); + } + + /* Check that a symbolic link to a nonexistent file yields NULL. */ + { + char *result1; + char *result2; + errno = 0; + result1 = canonicalize_file_name (BASE "/ouk"); + ASSERT (result1 == NULL); + ASSERT (errno == ENOENT); + errno = 0; + result2 = canonicalize_filename_mode (BASE "/ouk", CAN_EXISTING); + ASSERT (result2 == NULL); + ASSERT (errno == ENOENT); + } + + /* Check that a non-directory symlink with trailing slash yields NULL. */ + { + char *result1; + char *result2; + errno = 0; + result1 = canonicalize_file_name (BASE "/huk/"); + ASSERT (result1 == NULL); + ASSERT (errno == ENOTDIR); + errno = 0; + result2 = canonicalize_filename_mode (BASE "/huk/", CAN_EXISTING); + ASSERT (result2 == NULL); + ASSERT (errno == ENOTDIR); + } + + /* Check that a missing directory via symlink yields NULL. */ + { + char *result1; + char *result2; + errno = 0; + result1 = canonicalize_file_name (BASE "/ouk/.."); + ASSERT (result1 == NULL); + ASSERT (errno == ENOENT); + errno = 0; + result2 = canonicalize_filename_mode (BASE "/ouk/..", CAN_EXISTING); + ASSERT (result2 == NULL); + ASSERT (errno == ENOENT); + } + + /* Check that a loop of symbolic links is detected. */ + { + char *result1; + char *result2; + errno = 0; + result1 = canonicalize_file_name ("ise"); + ASSERT (result1 == NULL); + ASSERT (errno == ELOOP); + errno = 0; + result2 = canonicalize_filename_mode ("ise", CAN_EXISTING); + ASSERT (result2 == NULL); + ASSERT (errno == ELOOP); + } + + /* Check that alternate modes can resolve missing basenames. */ + { + char *result1 = canonicalize_filename_mode (BASE "/zzz", CAN_ALL_BUT_LAST); + char *result2 = canonicalize_filename_mode (BASE "/zzz", CAN_MISSING); + char *result3 = canonicalize_filename_mode (BASE "/zzz/", CAN_ALL_BUT_LAST); + char *result4 = canonicalize_filename_mode (BASE "/zzz/", CAN_MISSING); + ASSERT (result1 != NULL); + ASSERT (result2 != NULL); + ASSERT (result3 != NULL); + ASSERT (result4 != NULL); + ASSERT (strcmp (result1, result2) == 0); + ASSERT (strcmp (result2, result3) == 0); + ASSERT (strcmp (result3, result4) == 0); + ASSERT (strcmp (result1 + strlen (result1) - strlen ("/" BASE "/zzz"), + "/" BASE "/zzz") == 0); + free (result1); + free (result2); + free (result3); + free (result4); + } + + /* Check that alternate modes can resolve broken symlink basenames. */ + { + char *result1 = canonicalize_filename_mode (BASE "/ouk", CAN_ALL_BUT_LAST); + char *result2 = canonicalize_filename_mode (BASE "/ouk", CAN_MISSING); + char *result3 = canonicalize_filename_mode (BASE "/ouk/", CAN_ALL_BUT_LAST); + char *result4 = canonicalize_filename_mode (BASE "/ouk/", CAN_MISSING); + ASSERT (result1 != NULL); + ASSERT (result2 != NULL); + ASSERT (result3 != NULL); + ASSERT (result4 != NULL); + ASSERT (strcmp (result1, result2) == 0); + ASSERT (strcmp (result2, result3) == 0); + ASSERT (strcmp (result3, result4) == 0); + ASSERT (strcmp (result1 + strlen (result1) - strlen ("/" BASE "/wum"), + "/" BASE "/wum") == 0); + free (result1); + free (result2); + free (result3); + free (result4); + } + + /* Check that alternate modes can handle missing dirnames. */ + { + char *result1 = canonicalize_filename_mode ("t-can.zzz/zzz", CAN_ALL_BUT_LAST); + char *result2 = canonicalize_filename_mode ("t-can.zzz/zzz", CAN_MISSING); + ASSERT (result1 == NULL); + ASSERT (result2 != NULL); + ASSERT (strcmp (result2 + strlen (result2) - 14, "/t-can.zzz/zzz") == 0); + free (result2); + } + + /* Ensure that the following is resolved properly. + Before 2007-09-27, it would mistakenly report a loop. */ + { + char *result1 = canonicalize_filename_mode (BASE, CAN_EXISTING); + char *result2 = canonicalize_filename_mode (BASE "/p/1", CAN_EXISTING); + ASSERT (result1 != NULL); + ASSERT (result2 != NULL); + ASSERT (strcmp (result2 + strlen (result1), "/d/2") == 0); + free (result1); + free (result2); + } + + /* Check that leading // is honored correctly. */ + { + struct stat st1; + struct stat st2; + char *result1 = canonicalize_file_name ("//."); + char *result2 = canonicalize_filename_mode ("//.", CAN_EXISTING); + char *result3 = canonicalize_file_name (BASE "/droot"); + char *result4 = canonicalize_filename_mode (BASE "/droot", CAN_EXISTING); + ASSERT (result1); + ASSERT (result2); + ASSERT (result3); + ASSERT (result4); + ASSERT (stat ("/", &st1) == 0); + ASSERT (stat ("//", &st2) == 0); + if (SAME_INODE (st1, st2)) + { + ASSERT (strcmp (result1, "/") == 0); + ASSERT (strcmp (result2, "/") == 0); + ASSERT (strcmp (result3, "/") == 0); + ASSERT (strcmp (result4, "/") == 0); + } + else + { + ASSERT (strcmp (result1, "//") == 0); + ASSERT (strcmp (result2, "//") == 0); + ASSERT (strcmp (result3, "//") == 0); + ASSERT (strcmp (result4, "//") == 0); + } + free (result1); + free (result2); + free (result3); + free (result4); + } + + /* Cleanup. */ + ASSERT (remove (BASE "/droot") == 0); + ASSERT (remove (BASE "/d/1") == 0); + ASSERT (remove (BASE "/d/2") == 0); + ASSERT (remove (BASE "/d") == 0); + ASSERT (remove (BASE "/s") == 0); + ASSERT (remove (BASE "/p") == 0); + ASSERT (remove (BASE "/plo") == 0); + ASSERT (remove (BASE "/huk") == 0); + ASSERT (remove (BASE "/bef") == 0); + ASSERT (remove (BASE "/ouk") == 0); + ASSERT (remove (BASE "/ket") == 0); + ASSERT (remove (BASE "/lum") == 0); + ASSERT (remove (BASE "/tra") == 0); + ASSERT (remove (BASE) == 0); + ASSERT (remove ("ise") == 0); + + return 0; +} diff --git a/gnulib-tests/test-chdir.c b/gnulib-tests/test-chdir.c new file mode 100644 index 0000000..9f0739d --- /dev/null +++ b/gnulib-tests/test-chdir.c @@ -0,0 +1,33 @@ +/* Test changing to a directory. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +/* Specification. */ +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (chdir, int, (const char *)); + +#include "macros.h" + +int +main (void) +{ + ASSERT (chdir ("/") == 0); + + return 0; +} diff --git a/gnulib-tests/test-chown.c b/gnulib-tests/test-chown.c new file mode 100644 index 0000000..a3de19e --- /dev/null +++ b/gnulib-tests/test-chown.c @@ -0,0 +1,49 @@ +/* Tests of chown. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (chown, int, (char const *, uid_t, gid_t)); + +#include <fcntl.h> +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/stat.h> + +#include "mgetgroups.h" +#include "stat-time.h" +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-chown.t" + +#include "test-chown.h" + +int +main (void) +{ + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + return test_chown (chown, true); +} diff --git a/gnulib-tests/test-chown.h b/gnulib-tests/test-chown.h new file mode 100644 index 0000000..eb068f0 --- /dev/null +++ b/gnulib-tests/test-chown.h @@ -0,0 +1,209 @@ +/* Tests of chown. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include "nap.h" + +#if !HAVE_GETEGID +# define getegid() ((gid_t) -1) +#endif + +/* This file is designed to test chown(n,o,g) and + chownat(AT_FDCWD,n,o,g,0). FUNC is the function to test. Assumes + that BASE and ASSERT are already defined, and that appropriate + headers are already included. If PRINT, warn before skipping + symlink tests with status 77. */ + +static int +test_chown (int (*func) (char const *, uid_t, gid_t), bool print) +{ + struct stat st1; + struct stat st2; + gid_t *gids = NULL; + int gids_count; + int result; + + /* Solaris 8 is interesting - if the current process belongs to + multiple groups, the current directory is owned by a group that + the current process belongs to but different than getegid(), and + the current directory does not have the S_ISGID bit, then regular + files created in the directory belong to the directory's group, + but symlinks belong to the current effective group id. If + S_ISGID is set, then both files and symlinks belong to the + directory's group. However, it is possible to run the testsuite + from within a directory owned by a group we don't belong to, in + which case all things that we create belong to the current + effective gid. So, work around the issues by creating a + subdirectory (we are guaranteed that the subdirectory will be + owned by one of our current groups), change ownership of that + directory to the current effective gid (which will thus succeed), + then create all other files within that directory (eliminating + questions on whether inheritance or current id triumphs, since + the two methods resolve to the same gid). */ + ASSERT (mkdir (BASE "dir", 0700) == 0); + ASSERT (stat (BASE "dir", &st1) == 0); + + /* Filter out mingw and file systems which have no concept of groups. */ + result = func (BASE "dir", st1.st_uid, getegid ()); + if (result == -1 && (errno == ENOSYS || errno == EPERM)) + { + ASSERT (rmdir (BASE "dir") == 0); + if (print) + fputs ("skipping test: no support for ownership\n", stderr); + return 77; + } + ASSERT (result == 0); + + ASSERT (close (creat (BASE "dir/file", 0600)) == 0); + ASSERT (stat (BASE "dir/file", &st1) == 0); + ASSERT (st1.st_uid != (uid_t) -1); + ASSERT (st1.st_gid != (gid_t) -1); + ASSERT (st1.st_gid == getegid ()); + + /* Sanity check of error cases. */ + errno = 0; + ASSERT (func ("", -1, -1) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func ("no_such", -1, -1) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func ("no_such/", -1, -1) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func (BASE "dir/file/", -1, -1) == -1); + ASSERT (errno == ENOTDIR); + + /* Check that -1 does not alter ownership. */ + ASSERT (func (BASE "dir/file", -1, st1.st_gid) == 0); + ASSERT (func (BASE "dir/file", st1.st_uid, -1) == 0); + ASSERT (func (BASE "dir/file", (uid_t) -1, (gid_t) -1) == 0); + ASSERT (stat (BASE "dir/file", &st2) == 0); + ASSERT (st1.st_uid == st2.st_uid); + ASSERT (st1.st_gid == st2.st_gid); + + /* Even if the values aren't changing, ctime is required to change + if at least one argument is not -1. */ + nap (); + ASSERT (func (BASE "dir/file", st1.st_uid, st1.st_gid) == 0); + ASSERT (stat (BASE "dir/file", &st2) == 0); + ASSERT (st1.st_ctime < st2.st_ctime + || (st1.st_ctime == st2.st_ctime + && get_stat_ctime_ns (&st1) < get_stat_ctime_ns (&st2))); + + /* Test symlink behavior. */ + if (symlink ("link", BASE "dir/link2")) + { + ASSERT (unlink (BASE "dir/file") == 0); + ASSERT (rmdir (BASE "dir") == 0); + if (print) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + errno = 0; + ASSERT (func (BASE "dir/link2", -1, -1) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func (BASE "dir/link2/", st1.st_uid, st1.st_gid) == -1); + ASSERT (errno == ENOENT); + ASSERT (symlink ("file", BASE "dir/link") == 0); + + /* For non-privileged users, chown can only portably succeed at + changing group ownership of a file we own. If we belong to at + least two groups, then verifying the correct change is simple. + But if we belong to only one group, then we fall back on the + other observable effect of chown: the ctime must be updated. */ + gids_count = mgetgroups (NULL, st1.st_gid, &gids); + if (1 < gids_count) + { + ASSERT (gids[1] != st1.st_gid); + ASSERT (gids[1] != (gid_t) -1); + ASSERT (lstat (BASE "dir/link", &st2) == 0); + ASSERT (st1.st_uid == st2.st_uid); + ASSERT (st1.st_gid == st2.st_gid); + ASSERT (lstat (BASE "dir/link2", &st2) == 0); + ASSERT (st1.st_uid == st2.st_uid); + ASSERT (st1.st_gid == st2.st_gid); + + errno = 0; + ASSERT (func (BASE "dir/link2/", -1, gids[1]) == -1); + ASSERT (errno == ENOTDIR); + ASSERT (stat (BASE "dir/file", &st2) == 0); + ASSERT (st1.st_uid == st2.st_uid); + ASSERT (st1.st_gid == st2.st_gid); + ASSERT (lstat (BASE "dir/link", &st2) == 0); + ASSERT (st1.st_uid == st2.st_uid); + ASSERT (st1.st_gid == st2.st_gid); + ASSERT (lstat (BASE "dir/link2", &st2) == 0); + ASSERT (st1.st_uid == st2.st_uid); + ASSERT (st1.st_gid == st2.st_gid); + + ASSERT (func (BASE "dir/link2", -1, gids[1]) == 0); + ASSERT (stat (BASE "dir/file", &st2) == 0); + ASSERT (st1.st_uid == st2.st_uid); + ASSERT (gids[1] == st2.st_gid); + ASSERT (lstat (BASE "dir/link", &st2) == 0); + ASSERT (st1.st_uid == st2.st_uid); + ASSERT (st1.st_gid == st2.st_gid); + ASSERT (lstat (BASE "dir/link2", &st2) == 0); + ASSERT (st1.st_uid == st2.st_uid); + ASSERT (st1.st_gid == st2.st_gid); + } + else + { + struct stat l1; + struct stat l2; + ASSERT (stat (BASE "dir/file", &st1) == 0); + ASSERT (lstat (BASE "dir/link", &l1) == 0); + ASSERT (lstat (BASE "dir/link2", &l2) == 0); + + nap (); + errno = 0; + ASSERT (func (BASE "dir/link2/", -1, st1.st_gid) == -1); + ASSERT (errno == ENOTDIR); + ASSERT (stat (BASE "dir/file", &st2) == 0); + ASSERT (st1.st_ctime == st2.st_ctime); + ASSERT (get_stat_ctime_ns (&st1) == get_stat_ctime_ns (&st2)); + ASSERT (lstat (BASE "dir/link", &st2) == 0); + ASSERT (l1.st_ctime == st2.st_ctime); + ASSERT (get_stat_ctime_ns (&l1) == get_stat_ctime_ns (&st2)); + ASSERT (lstat (BASE "dir/link2", &st2) == 0); + ASSERT (l2.st_ctime == st2.st_ctime); + ASSERT (get_stat_ctime_ns (&l2) == get_stat_ctime_ns (&st2)); + + ASSERT (func (BASE "dir/link2", -1, st1.st_gid) == 0); + ASSERT (stat (BASE "dir/file", &st2) == 0); + ASSERT (st1.st_ctime < st2.st_ctime + || (st1.st_ctime == st2.st_ctime + && get_stat_ctime_ns (&st1) < get_stat_ctime_ns (&st2))); + ASSERT (lstat (BASE "dir/link", &st2) == 0); + ASSERT (l1.st_ctime == st2.st_ctime); + ASSERT (get_stat_ctime_ns (&l1) == get_stat_ctime_ns (&st2)); + ASSERT (lstat (BASE "dir/link2", &st2) == 0); + ASSERT (l2.st_ctime == st2.st_ctime); + ASSERT (get_stat_ctime_ns (&l2) == get_stat_ctime_ns (&st2)); + } + + /* Cleanup. */ + free (gids); + ASSERT (unlink (BASE "dir/file") == 0); + ASSERT (unlink (BASE "dir/link") == 0); + ASSERT (unlink (BASE "dir/link2") == 0); + ASSERT (rmdir (BASE "dir") == 0); + return 0; +} diff --git a/gnulib-tests/test-cloexec.c b/gnulib-tests/test-cloexec.c new file mode 100644 index 0000000..7c992df --- /dev/null +++ b/gnulib-tests/test-cloexec.c @@ -0,0 +1,148 @@ +/* Test duplicating non-inheritable file descriptors. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include "cloexec.h" + +#include <errno.h> +#include <fcntl.h> +#include <unistd.h> + +#if defined _WIN32 && ! defined __CYGWIN__ +/* Get declarations of the native Windows API functions. */ +# define WIN32_LEAN_AND_MEAN +# include <windows.h> +/* Get _get_osfhandle. */ +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include <io.h> +# endif +#endif + +#include "binary-io.h" +#include "macros.h" + +/* Return non-zero if FD is open and inheritable across exec/spawn. */ +static int +is_inheritable (int fd) +{ +#if defined _WIN32 && ! defined __CYGWIN__ + /* On native Windows, 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. */ + HANDLE h = (HANDLE) _get_osfhandle (fd); + DWORD flags; + if (h == INVALID_HANDLE_VALUE || GetHandleInformation (h, &flags) == 0) + return 0; + return (flags & HANDLE_FLAG_INHERIT) != 0; +#else +# ifndef F_GETFD +# error Please port fcntl to your platform +# endif + int i = fcntl (fd, F_GETFD); + return 0 <= i && (i & FD_CLOEXEC) == 0; +#endif +} + +#if !O_BINARY +# define setmode(f,m) zero () +static int zero (void) { return 0; } +#endif + +/* Return non-zero if FD is open in the given MODE, which is either + O_TEXT or O_BINARY. */ +static int +is_mode (int fd, int mode) +{ + int value = setmode (fd, O_BINARY); + setmode (fd, value); + return mode == value; +} + +int +main (void) +{ + const char *file = "test-cloexec.tmp"; + int fd = creat (file, 0600); + int fd2; + int bad_fd = getdtablesize (); + + /* Assume std descriptors were provided by invoker. */ + ASSERT (STDERR_FILENO < fd); + ASSERT (is_inheritable (fd)); + + /* Normal use of set_cloexec_flag. */ + ASSERT (set_cloexec_flag (fd, true) == 0); +#if !(defined _WIN32 && ! defined __CYGWIN__) + ASSERT (!is_inheritable (fd)); +#endif + ASSERT (set_cloexec_flag (fd, false) == 0); + ASSERT (is_inheritable (fd)); + + /* Normal use of dup_cloexec. */ + fd2 = dup_cloexec (fd); + ASSERT (fd < fd2); + ASSERT (!is_inheritable (fd2)); + ASSERT (close (fd) == 0); + ASSERT (dup_cloexec (fd2) == fd); + ASSERT (!is_inheritable (fd)); + ASSERT (close (fd2) == 0); + + /* On systems that distinguish between text and binary mode, + dup_cloexec reuses the mode of the source. */ + setmode (fd, O_BINARY); + ASSERT (is_mode (fd, O_BINARY)); + fd2 = dup_cloexec (fd); + ASSERT (fd < fd2); + ASSERT (is_mode (fd2, O_BINARY)); + ASSERT (close (fd2) == 0); + setmode (fd, O_TEXT); + ASSERT (is_mode (fd, O_TEXT)); + fd2 = dup_cloexec (fd); + ASSERT (fd < fd2); + ASSERT (is_mode (fd2, O_TEXT)); + ASSERT (close (fd2) == 0); + + /* Test error handling. */ + errno = 0; + ASSERT (set_cloexec_flag (-1, false) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (set_cloexec_flag (bad_fd, false) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (set_cloexec_flag (fd2, false) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (dup_cloexec (-1) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (dup_cloexec (bad_fd) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (dup_cloexec (fd2) == -1); + ASSERT (errno == EBADF); + + /* Clean up. */ + ASSERT (close (fd) == 0); + ASSERT (unlink (file) == 0); + + return 0; +} diff --git a/gnulib-tests/test-close.c b/gnulib-tests/test-close.c new file mode 100644 index 0000000..beb7768 --- /dev/null +++ b/gnulib-tests/test-close.c @@ -0,0 +1,45 @@ +/* Test closing a file or socket. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (close, int, (int)); + +#include <errno.h> + +#include "macros.h" + +int +main (void) +{ + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (close (-1) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (close (99) == -1); + ASSERT (errno == EBADF); + } + + return 0; +} diff --git a/gnulib-tests/test-closein.c b/gnulib-tests/test-closein.c new file mode 100644 index 0000000..b7e9bdf --- /dev/null +++ b/gnulib-tests/test-closein.c @@ -0,0 +1,49 @@ +/* Test of closein module. + Copyright (C) 2007-2020 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, 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake. */ + +#include <config.h> + +#include "closein.h" + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "binary-io.h" +#include "ignore-value.h" + +/* With no arguments, do nothing. With arguments, attempt to consume + first 6 bytes of stdin. In either case, let exit() take care of + closing std streams and changing exit status if ferror(stdin). */ +int +main (int argc, char **argv) +{ + char buf[7]; + atexit (close_stdin); + + /* close_stdin currently relies on ftell, but mingw ftell is + unreliable on text mode input. */ + set_binary_mode (0, O_BINARY); + + if (argc > 2) + close (0); + + if (argc > 1) + ignore_value (fread (buf, 1, 6, stdin)); + return 0; +} diff --git a/gnulib-tests/test-closein.sh b/gnulib-tests/test-closein.sh new file mode 100755 index 0000000..d6359f9 --- /dev/null +++ b/gnulib-tests/test-closein.sh @@ -0,0 +1,32 @@ +#!/bin/sh +: ${srcdir=.} +. "$srcdir/init.sh"; path_prepend_ . + +echo Hello world > in.tmp +echo world > xout.tmp + +fail=0 +# Test with seekable stdin; follow-on process must see remaining data +(${CHECKER} test-closein; cat) < in.tmp > out1.tmp || fail=1 +cmp out1.tmp in.tmp || fail=1 + +(${CHECKER} test-closein consume; cat) < in.tmp > out2.tmp || fail=1 +cmp out2.tmp xout.tmp || fail=1 + +# Test for lack of error on pipe. Ignore any EPIPE failures from cat. +cat in.tmp 2>/dev/null | ${CHECKER} test-closein || fail=1 + +cat in.tmp 2>/dev/null | ${CHECKER} test-closein consume || fail=1 + +# Test for lack of error when nothing is read +${CHECKER} test-closein </dev/null || fail=1 + +${CHECKER} test-closein <&- || fail=1 + +# Test for no error when EOF is read early +${CHECKER} test-closein consume </dev/null || fail=1 + +# Test for error when read fails because no file available +${CHECKER} test-closein consume close <&- 2>/dev/null && fail=1 + +Exit $fail diff --git a/gnulib-tests/test-connect.c b/gnulib-tests/test-connect.c new file mode 100644 index 0000000..7f35ad1 --- /dev/null +++ b/gnulib-tests/test-connect.c @@ -0,0 +1,60 @@ +/* Test connecting a client socket. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <sys/socket.h> + +#include "signature.h" +SIGNATURE_CHECK (connect, int, (int, const struct sockaddr *, socklen_t)); + +#include <errno.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <unistd.h> + +#include "sockets.h" +#include "macros.h" + +int +main (void) +{ + (void) gl_sockets_startup (SOCKETS_1_1); + + /* Test behaviour for invalid file descriptors. */ + { + struct sockaddr_in addr; + + addr.sin_family = AF_INET; + inet_pton (AF_INET, "127.0.0.1", &addr.sin_addr); + addr.sin_port = htons (80); + { + errno = 0; + ASSERT (connect (-1, (const struct sockaddr *) &addr, sizeof (addr)) + == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (connect (99, (const struct sockaddr *) &addr, sizeof (addr)) + == -1); + ASSERT (errno == EBADF); + } + } + + return 0; +} diff --git a/gnulib-tests/test-copy-acl-1.sh b/gnulib-tests/test-copy-acl-1.sh new file mode 100755 index 0000000..0fe44a5 --- /dev/null +++ b/gnulib-tests/test-copy-acl-1.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +# Test copy-acl on the file system of /var/tmp, which usually is a local +# file system. + +. "${srcdir=.}/init.sh"; path_prepend_ . + +if test -d /var/tmp; then + TMPDIR=/var/tmp +else + TMPDIR=/tmp +fi +test -d $TMPDIR || Exit 77 +export TMPDIR + +$BOURNE_SHELL "${srcdir}/test-copy-acl.sh" + +Exit $? diff --git a/gnulib-tests/test-copy-acl-2.sh b/gnulib-tests/test-copy-acl-2.sh new file mode 100755 index 0000000..a35c12e --- /dev/null +++ b/gnulib-tests/test-copy-acl-2.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# Test copy-acl on the file system of the build directory, which may be +# a local file system or NFS mounted. + +. "${srcdir=.}/init.sh"; path_prepend_ . + +TMPDIR=`pwd` +export TMPDIR + +$BOURNE_SHELL "${srcdir}/test-copy-acl.sh" + +Exit $? diff --git a/gnulib-tests/test-copy-acl.c b/gnulib-tests/test-copy-acl.c new file mode 100644 index 0000000..e7c5e54 --- /dev/null +++ b/gnulib-tests/test-copy-acl.c @@ -0,0 +1,73 @@ +/* Test of copying of files. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2008. */ + +#include <config.h> + +#include "acl.h" + +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + const char *file1; + const char *file2; + int fd1; + struct stat statbuf; + int mode; + int fd2; + + ASSERT (argc == 3); + + file1 = argv[1]; + file2 = argv[2]; + + fd1 = open (file1, O_RDONLY); + if (fd1 < 0 || fstat (fd1, &statbuf) < 0) + { + fprintf (stderr, "could not open file \"%s\"\n", file1); + exit (EXIT_FAILURE); + } + mode = statbuf.st_mode & 07777; + + fd2 = open (file2, O_WRONLY, 0600); + if (fd2 < 0) + { + fprintf (stderr, "could not open file \"%s\"\n", file2); + exit (EXIT_FAILURE); + } + +#if USE_ACL + if (copy_acl (file1, fd1, file2, fd2, mode)) + exit (EXIT_FAILURE); +#else + chmod (file2, mode); +#endif + + close (fd2); + close (fd1); + + return 0; +} diff --git a/gnulib-tests/test-copy-acl.sh b/gnulib-tests/test-copy-acl.sh new file mode 100755 index 0000000..9f69d14 --- /dev/null +++ b/gnulib-tests/test-copy-acl.sh @@ -0,0 +1,664 @@ +#!/bin/sh + +# Show all commands when run with environment variable VERBOSE=yes. +test -z "$VERBOSE" || set -x + +test "$USE_ACL" = 0 && + { + echo "Skipping test: insufficient ACL support" + exit 77 + } + +# func_tmpdir +# creates a temporary directory. +# Sets variable +# - tmp pathname of freshly created temporary directory +func_tmpdir () +{ + # Use the environment variable TMPDIR, falling back to /tmp. This allows + # users to specify a different temporary directory, for example, if their + # /tmp is filled up or too small. + : ${TMPDIR=/tmp} + { + # Use the mktemp program if available. If not available, hide the error + # message. + tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" + } || + { + # Use a simple mkdir command. It is guaranteed to fail if the directory + # already exists. $RANDOM is bash specific and expands to empty in shells + # other than bash, ksh and zsh. Its use does not increase security; + # rather, it minimizes the probability of failure in a very cluttered /tmp + # directory. + tmp=$TMPDIR/gl$$-$RANDOM + (umask 077 && mkdir "$tmp") + } || + { + echo "$0: cannot create a temporary directory in $TMPDIR" >&2 + exit 1 + } +} + +func_tmpdir +# builddir may already be set by the script that invokes this one. +case "$builddir" in + '') builddir=`pwd` ;; + /* | ?:*) ;; + *) builddir=`pwd`/$builddir ;; +esac +cd "$builddir" || + { + echo "$0: cannot determine build directory (unreadable parent dir?)" >&2 + exit 1 + } +# Switch to a temporary directory, to increase the likelihood that ACLs are +# supported on the current file system. (/tmp is usually locally mounted, +# whereas the build dir is sometimes NFS-mounted.) +( cd "$tmp" + + # Prepare tmpfile0. + rm -f tmpfile[0-9] tmpaclout[0-2] + echo "Simple contents" > tmpfile0 + chmod 600 tmpfile0 + + # Classification of the platform according to the programs available for + # manipulating ACLs. + # Possible values are: + # linux, cygwin, freebsd, solaris, hpux, hpuxjfs, osf1, aix, macosx, irix, none. + # TODO: Support also native Windows platforms (mingw). + acl_flavor=none + if (getfacl tmpfile0 >/dev/null) 2>/dev/null; then + # Platforms with the getfacl and setfacl programs. + # Linux, FreeBSD, Solaris, Cygwin. + if (setfacl --help >/dev/null) 2>/dev/null; then + # Linux, Cygwin. + if (LC_ALL=C setfacl --help | grep ' --set-file' >/dev/null) 2>/dev/null; then + # Linux. + acl_flavor=linux + else + acl_flavor=cygwin + fi + else + # FreeBSD, Solaris. + if (LC_ALL=C setfacl 2>&1 | grep '\-x entries' >/dev/null) 2>/dev/null; then + # FreeBSD. + acl_flavor=freebsd + else + # Solaris. + acl_flavor=solaris + fi + fi + else + if (lsacl / >/dev/null) 2>/dev/null; then + # Platforms with the lsacl and chacl programs. + # HP-UX, sometimes also IRIX. + if (getacl tmpfile0 >/dev/null) 2>/dev/null; then + # HP-UX 11.11 or newer. + acl_flavor=hpuxjfs + else + # HP-UX 11.00. + acl_flavor=hpux + fi + else + if (getacl tmpfile0 >/dev/null) 2>/dev/null; then + # Tru64, NonStop Kernel. + if (getacl -m tmpfile0 >/dev/null) 2>/dev/null; then + # Tru64. + acl_flavor=osf1 + else + # NonStop Kernel. + acl_flavor=nsk + fi + else + if (aclget tmpfile0 >/dev/null) 2>/dev/null; then + # AIX. + acl_flavor=aix + else + if (fsaclctl -v >/dev/null) 2>/dev/null; then + # Mac OS X. + acl_flavor=macosx + else + if test -f /sbin/chacl; then + # IRIX. + acl_flavor=irix + fi + fi + fi + fi + fi + fi + + # Define a function to test for the same ACLs, from the point of view of + # the programs. + # func_test_same_acls file1 file2 + case $acl_flavor in + linux | cygwin | freebsd | solaris) + func_test_same_acls () + { + getfacl "$1" | sed -e "s/$1/FILENAME/g" > tmpaclout1 + getfacl "$2" | sed -e "s/$2/FILENAME/g" > tmpaclout2 + cmp tmpaclout1 tmpaclout2 > /dev/null + } + ;; + hpux) + func_test_same_acls () + { + lsacl "$1" | sed -e "s/$1/FILENAME/g" > tmpaclout1 + lsacl "$2" | sed -e "s/$2/FILENAME/g" > tmpaclout2 + cmp tmpaclout1 tmpaclout2 > /dev/null + } + ;; + hpuxjfs) + func_test_same_acls () + { + { lsacl "$1" | sed -e "s/$1/FILENAME/g" > tmpaclout1 + lsacl "$2" | sed -e "s/$2/FILENAME/g" > tmpaclout2 + cmp tmpaclout1 tmpaclout2 > /dev/null + } && + { getacl "$1" | sed -e "s/$1/FILENAME/g" > tmpaclout1 + getacl "$2" | sed -e "s/$2/FILENAME/g" > tmpaclout2 + cmp tmpaclout1 tmpaclout2 > /dev/null + } + } + ;; + osf1 | nsk) + func_test_same_acls () + { + getacl "$1" | sed -e "s/$1/FILENAME/g" > tmpaclout1 + getacl "$2" | sed -e "s/$2/FILENAME/g" > tmpaclout2 + cmp tmpaclout1 tmpaclout2 > /dev/null + } + ;; + aix) + func_test_same_acls () + { + aclget "$1" > tmpaclout1 + aclget "$2" > tmpaclout2 + cmp tmpaclout1 tmpaclout2 > /dev/null + } + ;; + macosx) + func_test_same_acls () + { + /bin/ls -le "$1" | sed -e "s/$1/FILENAME/g" > tmpaclout1 + /bin/ls -le "$2" | sed -e "s/$2/FILENAME/g" > tmpaclout2 + cmp tmpaclout1 tmpaclout2 > /dev/null + } + ;; + irix) + func_test_same_acls () + { + /bin/ls -lD "$1" | sed -e "s/$1/FILENAME/g" > tmpaclout1 + /bin/ls -lD "$2" | sed -e "s/$2/FILENAME/g" > tmpaclout2 + cmp tmpaclout1 tmpaclout2 > /dev/null + } + ;; + none) + func_test_same_acls () + { + : + } + ;; + esac + + # func_test_copy file1 file2 + # copies file1 to file2 and verifies the permissions and ACLs are the same + # on both. + func_test_copy () + { + echo "Simple contents" > "$2" + chmod 600 "$2" + ${CHECKER} "$builddir"/test-copy-acl${EXEEXT} "$1" "$2" || exit 1 + ${CHECKER} "$builddir"/test-sameacls${EXEEXT} "$1" "$2" || exit 1 + func_test_same_acls "$1" "$2" || exit 1 + } + + func_test_copy tmpfile0 tmpfile1 + + if test $acl_flavor != none; then + # A POSIX compliant 'id' program. + if test -f /usr/xpg4/bin/id; then + ID=/usr/xpg4/bin/id + else + ID=id + fi + # Use a user and group id different from the current one, to avoid + # redundant/ambiguous ACLs. + myuid=`$ID -u` + mygid=`$ID -g` + auid=1 + if test "$auid" = "$myuid"; then auid=2; fi + agid=1 + if test "$agid" = "$mygid"; then agid=2; fi + + case $acl_flavor in + linux | freebsd | solaris) + + # Set an ACL for a user. + setfacl -m user:$auid:1 tmpfile0 + + func_test_copy tmpfile0 tmpfile2 + + # Set an ACL for a group. + setfacl -m group:$agid:4 tmpfile0 + + func_test_copy tmpfile0 tmpfile3 + + # Set an ACL for other. + case $acl_flavor in + freebsd) setfacl -m other::4 tmpfile0 ;; + solaris) chmod o+r tmpfile0 ;; + *) setfacl -m other:4 tmpfile0 ;; + esac + + func_test_copy tmpfile0 tmpfile4 + + # Remove the ACL for the user. + case $acl_flavor in + linux) setfacl -x user:$auid tmpfile0 ;; + freebsd) setfacl -x user:$auid:1 tmpfile0 ;; + *) setfacl -d user:$auid:1 tmpfile0 ;; + esac + + func_test_copy tmpfile0 tmpfile5 + + # Remove the ACL for other. + case $acl_flavor in + linux | solaris) ;; # impossible + freebsd) setfacl -x other::4 tmpfile0 ;; + *) setfacl -d other:4 tmpfile0 ;; + esac + + func_test_copy tmpfile0 tmpfile6 + + # Remove the ACL for the group. + case $acl_flavor in + linux) setfacl -x group:$agid tmpfile0 ;; + freebsd) setfacl -x group:$agid:4 tmpfile0 ;; + *) setfacl -d group:$agid:4 tmpfile0 ;; + esac + + func_test_copy tmpfile0 tmpfile7 + + # Delete all optional ACLs. + case $acl_flavor in + linux | freebsd) + setfacl -m user:$auid:1 tmpfile0 + setfacl -b tmpfile0 + ;; + *) + setfacl -s user::6,group::0,other:0 tmpfile0 ;; + esac + + func_test_copy tmpfile0 tmpfile8 + + # Copy ACLs from a file that has no ACLs. + echo > tmpfile9 + chmod a+x tmpfile9 + case $acl_flavor in + linux) getfacl tmpfile9 | setfacl --set-file=- tmpfile0 ;; + freebsd) ;; + *) getfacl tmpfile9 | setfacl -f - tmpfile0 ;; + esac + rm -f tmpfile9 + + func_test_copy tmpfile0 tmpfile9 + + ;; + + cygwin) + + # Set an ACL for a group. + setfacl -m group:0:1 tmpfile0 + + func_test_copy tmpfile0 tmpfile2 + + # Set an ACL for other. + setfacl -m other:4 tmpfile0 + + func_test_copy tmpfile0 tmpfile4 + + # Remove the ACL for the group. + setfacl -d group:0 tmpfile0 + + func_test_copy tmpfile0 tmpfile5 + + # Remove the ACL for other. + setfacl -d other:4 tmpfile0 + + func_test_copy tmpfile0 tmpfile6 + + # Delete all optional ACLs. + setfacl -s user::6,group::0,other:0 tmpfile0 + + func_test_copy tmpfile0 tmpfile8 + + # Copy ACLs from a file that has no ACLs. + echo > tmpfile9 + chmod a+x tmpfile9 + getfacl tmpfile9 | setfacl -f - tmpfile0 + rm -f tmpfile9 + + func_test_copy tmpfile0 tmpfile9 + + ;; + + hpux) + + # Set an ACL for a user. + orig=`lsacl tmpfile0 | sed -e 's/ tmpfile0$//'` + chacl -r "${orig}($auid.%,--x)" tmpfile0 + + func_test_copy tmpfile0 tmpfile2 + + # Set an ACL for a group. + orig=`lsacl tmpfile0 | sed -e 's/ tmpfile0$//'` + chacl -r "${orig}(%.$agid,r--)" tmpfile0 + + func_test_copy tmpfile0 tmpfile3 + + # Set an ACL for other. + orig=`lsacl tmpfile0 | sed -e 's/ tmpfile0$//'` + chacl -r "${orig}(%.%,r--)" tmpfile0 + + func_test_copy tmpfile0 tmpfile4 + + # Remove the ACL for the user. + chacl -d "($auid.%,--x)" tmpfile0 + + func_test_copy tmpfile0 tmpfile5 + + # Remove the ACL for the group. + chacl -d "(%.$agid,r--)" tmpfile0 + + func_test_copy tmpfile0 tmpfile6 + + # Delete all optional ACLs. + chacl -z tmpfile0 + + func_test_copy tmpfile0 tmpfile8 + + # Copy ACLs from a file that has no ACLs. + echo > tmpfile9 + chmod a+x tmpfile9 + orig=`lsacl tmpfile9 | sed -e 's/ tmpfile9$//'` + rm -f tmpfile9 + chacl -r "${orig}" tmpfile0 + + func_test_copy tmpfile0 tmpfile9 + + ;; + + hpuxjfs) + + # Set an ACL for a user. + orig=`lsacl tmpfile0 | sed -e 's/ tmpfile0$//'` + chacl -r "${orig}($auid.%,--x)" tmpfile0 \ + || setacl -m user:$auid:1 tmpfile0 + + func_test_copy tmpfile0 tmpfile2 + + # Set an ACL for a group. + orig=`lsacl tmpfile0 | sed -e 's/ tmpfile0$//'` + chacl -r "${orig}(%.$agid,r--)" tmpfile0 \ + || setacl -m group:$agid:4 tmpfile0 + + func_test_copy tmpfile0 tmpfile3 + + # Set an ACL for other. + orig=`lsacl tmpfile0 | sed -e 's/ tmpfile0$//'` + chacl -r "${orig}(%.%,r--)" tmpfile0 \ + || setacl -m other:4 tmpfile0 + + func_test_copy tmpfile0 tmpfile4 + + # Remove the ACL for the user. + chacl -d "($auid.%,--x)" tmpfile0 \ + || setacl -d user:$auid tmpfile0 + + func_test_copy tmpfile0 tmpfile5 + + # Remove the ACL for the group. + chacl -d "(%.$agid,r--)" tmpfile0 \ + || setacl -d group:$agid tmpfile0 + + func_test_copy tmpfile0 tmpfile6 + + # Delete all optional ACLs. + chacl -z tmpfile0 \ + || { setacl -m user:$auid:1 tmpfile0 + setacl -s user::6,group::0,class:7,other:0 tmpfile0 + } + + func_test_copy tmpfile0 tmpfile8 + + # Copy ACLs from a file that has no ACLs. + echo > tmpfile9 + chmod a+x tmpfile9 + orig=`lsacl tmpfile9 | sed -e 's/ tmpfile9$//'` + getacl tmpfile9 > tmpaclout0 + rm -f tmpfile9 + chacl -r "${orig}" tmpfile0 \ + || setacl -f tmpaclout0 tmpfile0 + + func_test_copy tmpfile0 tmpfile9 + + ;; + + osf1) + + # Set an ACL for a user. + setacl -u user:$auid:1 tmpfile0 + + func_test_copy tmpfile0 tmpfile2 + + # Set an ACL for a group. + setacl -u group:$agid:4 tmpfile0 + + func_test_copy tmpfile0 tmpfile3 + + # Set an ACL for other. + setacl -u other::4 tmpfile0 + + func_test_copy tmpfile0 tmpfile4 + + # Remove the ACL for the user. + setacl -x user:$auid:1 tmpfile0 + + func_test_copy tmpfile0 tmpfile5 + + if false; then # would give an error "can't set ACL: Invalid argument" + # Remove the ACL for other. + setacl -x other::4 tmpfile0 + + func_test_copy tmpfile0 tmpfile6 + fi + + # Remove the ACL for the group. + setacl -x group:$agid:4 tmpfile0 + + func_test_copy tmpfile0 tmpfile7 + + # Delete all optional ACLs. + setacl -u user:$auid:1 tmpfile0 + setacl -b tmpfile0 + + func_test_copy tmpfile0 tmpfile8 + + # Copy ACLs from a file that has no ACLs. + echo > tmpfile9 + chmod a+x tmpfile9 + getacl tmpfile9 > tmpaclout0 + setacl -b -U tmpaclout0 tmpfile0 + rm -f tmpfile9 + + func_test_copy tmpfile0 tmpfile9 + + ;; + + nsk) + + # Set an ACL for a user. + setacl -m user:$auid:1 tmpfile0 + + func_test_copy tmpfile0 tmpfile2 + + # Set an ACL for a group. + setacl -m group:$agid:4 tmpfile0 + + func_test_copy tmpfile0 tmpfile3 + + # Set an ACL for other. + setacl -m other:4 tmpfile0 + + func_test_copy tmpfile0 tmpfile4 + + # Remove the ACL for the user. + setacl -d user:$auid tmpfile0 + + func_test_copy tmpfile0 tmpfile5 + + # Remove the ACL for the group. + setacl -d group:$agid tmpfile0 + + func_test_copy tmpfile0 tmpfile6 + + # Delete all optional ACLs. + setacl -m user:$auid:1 tmpfile0 + setacl -s user::6,group::0,class:7,other:0 tmpfile0 + + func_test_copy tmpfile0 tmpfile8 + + # Copy ACLs from a file that has no ACLs. + echo > tmpfile9 + chmod a+x tmpfile9 + getacl tmpfile9 > tmpaclout0 + setacl -f tmpaclout0 tmpfile0 + rm -f tmpfile9 + + func_test_copy tmpfile0 tmpfile9 + + ;; + + aix) + + # Set an ACL for a user. + { aclget tmpfile0 | sed -e 's/disabled$/enabled/'; echo " permit --x u:$auid"; } | aclput tmpfile0 + + func_test_copy tmpfile0 tmpfile2 + + # Set an ACL for a group. + { aclget tmpfile0 | sed -e 's/disabled$/enabled/'; echo " permit r-- g:$agid"; } | aclput tmpfile0 + + func_test_copy tmpfile0 tmpfile3 + + # Set an ACL for other. + chmod o+r tmpfile0 + + func_test_copy tmpfile0 tmpfile4 + + # Remove the ACL for the user. + aclget tmpfile0 | grep -v ' u:[^ ]*$' | aclput tmpfile0 + + func_test_copy tmpfile0 tmpfile5 + + # Remove the ACL for the group. + aclget tmpfile0 | grep -v ' g:[^ ]*$' | aclput tmpfile0 + + func_test_copy tmpfile0 tmpfile7 + + # Delete all optional ACLs. + aclget tmpfile0 | sed -e 's/enabled$/disabled/' | sed -e '/disabled$/q' | aclput tmpfile0 + + func_test_copy tmpfile0 tmpfile8 + + # Copy ACLs from a file that has no ACLs. + echo > tmpfile9 + chmod a+x tmpfile9 + aclget tmpfile9 | aclput tmpfile0 + rm -f tmpfile9 + + func_test_copy tmpfile0 tmpfile9 + + ;; + + macosx) + + # Set an ACL for a user. + /bin/chmod +a "user:daemon allow execute" tmpfile0 + + func_test_copy tmpfile0 tmpfile2 + + # Set an ACL for a group. + /bin/chmod +a "group:daemon allow read" tmpfile0 + + func_test_copy tmpfile0 tmpfile3 + + # Set an ACL for other. + chmod o+r tmpfile0 + + func_test_copy tmpfile0 tmpfile4 + + # Remove the ACL for the user. + /bin/chmod -a "user:daemon allow execute" tmpfile0 + + func_test_copy tmpfile0 tmpfile5 + + # Remove the ACL for the group. + /bin/chmod -a "group:daemon allow read" tmpfile0 + + func_test_copy tmpfile0 tmpfile7 + + # Delete all optional ACLs. + /bin/chmod -N tmpfile0 + + func_test_copy tmpfile0 tmpfile8 + + # Copy ACLs from a file that has no ACLs. + echo > tmpfile9 + chmod a+x tmpfile9 + { /bin/ls -le tmpfile9 | sed -n -e 's/^ [0-9][0-9]*: //p'; echo; } | /bin/chmod -E tmpfile0 + rm -f tmpfile9 + + func_test_copy tmpfile0 tmpfile9 + + ;; + + irix) + + # Set an ACL for a user. + /sbin/chacl user::rw-,group::---,other::---,user:$auid:--x tmpfile0 + + func_test_copy tmpfile0 tmpfile2 + + # Set an ACL for a group. + /sbin/chacl user::rw-,group::---,other::---,user:$auid:--x,group:$agid:r-- tmpfile0 + + func_test_copy tmpfile0 tmpfile3 + + # Set an ACL for other. + /sbin/chacl user::rw-,group::---,user:$auid:--x,group:$agid:r--,other::r-- tmpfile0 + + func_test_copy tmpfile0 tmpfile4 + + # Remove the ACL for the user. + /sbin/chacl user::rw-,group::---,group:$agid:r--,other::r-- tmpfile0 + + func_test_copy tmpfile0 tmpfile5 + + # Remove the ACL for the group. + /sbin/chacl user::rw-,group::---,other::r-- tmpfile0 + + func_test_copy tmpfile0 tmpfile7 + + ;; + + esac + fi + + rm -f tmpfile[0-9] tmpaclout[0-2] +) || exit 1 + +rm -rf "$tmp" +exit 0 diff --git a/gnulib-tests/test-count-leading-zeros.c b/gnulib-tests/test-count-leading-zeros.c new file mode 100644 index 0000000..24dff86 --- /dev/null +++ b/gnulib-tests/test-count-leading-zeros.c @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2012-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake. */ + +#include <config.h> + +#include "count-leading-zeros.h" + +#include <limits.h> +#include <stdio.h> + +#include "macros.h" + +#define UINT_BIT (sizeof (unsigned int) * CHAR_BIT) +#define ULONG_BIT (sizeof (unsigned long int) * CHAR_BIT) +#define ULLONG_BIT (sizeof (unsigned long long int) * CHAR_BIT) + +int +main (int argc, char *argv[]) +{ + int i, j; + +#define TEST_COUNT_LEADING_ZEROS(FUNC, TYPE, BITS, MAX, ONE) \ + ASSERT (FUNC (0) == BITS); \ + for (i = 0; i < BITS; i++) \ + { \ + ASSERT (FUNC (ONE << i) == BITS - i - 1); \ + for (j = 0; j < i; j++) \ + ASSERT (FUNC ((ONE << i) | (ONE << j)) == BITS - i - 1); \ + } \ + for (i = 0; i < 1000; i++) \ + { \ + /* RAND_MAX is most often 0x7fff or 0x7fffffff. */ \ + TYPE value = \ + (RAND_MAX <= 0xffff \ + ? ((TYPE) rand () >> 3) \ + ^ (((TYPE) rand () >> 3) << 12) \ + ^ (((TYPE) rand () >> 3) << 24) \ + ^ (((TYPE) rand () >> 3) << 30 << 6) \ + ^ (((TYPE) rand () >> 3) << 30 << 18) \ + ^ (((TYPE) rand () >> 3) << 30 << 30) \ + : ((TYPE) rand () >> 3) \ + ^ (((TYPE) rand () >> 3) << 22) \ + ^ (((TYPE) rand () >> 3) << 22 << 22)); \ + int count = 0; \ + for (j = 0; j < BITS; j++) \ + if (value & (ONE << j)) \ + count = BITS - j - 1; \ + ASSERT (count == FUNC (value)); \ + } \ + ASSERT (FUNC (MAX) == 0); + + TEST_COUNT_LEADING_ZEROS (count_leading_zeros, unsigned int, + UINT_BIT, UINT_MAX, 1U); + TEST_COUNT_LEADING_ZEROS (count_leading_zeros_l, unsigned long int, + ULONG_BIT, ULONG_MAX, 1UL); + TEST_COUNT_LEADING_ZEROS (count_leading_zeros_ll, unsigned long long int, + ULLONG_BIT, ULLONG_MAX, 1ULL); + + return 0; +} diff --git a/gnulib-tests/test-ctype.c b/gnulib-tests/test-ctype.c new file mode 100644 index 0000000..9fc1965 --- /dev/null +++ b/gnulib-tests/test-ctype.c @@ -0,0 +1,27 @@ +/* Test of <ctype.h> substitute. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <ctype.h> + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tests/test-di-set.c b/gnulib-tests/test-di-set.c new file mode 100644 index 0000000..869d053 --- /dev/null +++ b/gnulib-tests/test-di-set.c @@ -0,0 +1,56 @@ +/* Test the di-set module. + Copyright (C) 2010-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Jim Meyering. */ + +#include <config.h> + +#include "di-set.h" + +#include "macros.h" + +int +main (void) +{ + struct di_set *dis = di_set_alloc (); + ASSERT (dis); + di_set_free (dis); /* free with dis->ino_map still being NULL */ + dis = di_set_alloc (); + ASSERT (dis); + + ASSERT (di_set_lookup (dis, 2, 5) == 0); /* initial lookup fails */ + ASSERT (di_set_insert (dis, 2, 5) == 1); /* first insertion succeeds */ + ASSERT (di_set_insert (dis, 2, 5) == 0); /* duplicate fails */ + ASSERT (di_set_insert (dis, 3, 5) == 1); /* diff dev, duplicate inode is ok */ + ASSERT (di_set_insert (dis, 2, 8) == 1); /* same dev, different inode is ok */ + ASSERT (di_set_lookup (dis, 2, 5) == 1); /* now, the lookup succeeds */ + + /* very large (or negative) inode number */ + ASSERT (di_set_insert (dis, 5, (ino_t) -1) == 1); + ASSERT (di_set_insert (dis, 5, (ino_t) -1) == 0); /* dup */ + + { + unsigned int i; + for (i = 0; i < 3000; i++) + ASSERT (di_set_insert (dis, 9, i) == 1); + for (i = 0; i < 3000; i++) + ASSERT (di_set_insert (dis, 9, i) == 0); /* duplicate fails */ + } + + di_set_free (dis); + + return 0; +} diff --git a/gnulib-tests/test-digest.h b/gnulib-tests/test-digest.h new file mode 100644 index 0000000..07ee194 --- /dev/null +++ b/gnulib-tests/test-digest.h @@ -0,0 +1,144 @@ +/* Test of message digests. + Copyright (C) 2018-2020 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 <https://www.gnu.org/licenses/>. */ + +static void +test_digest_on_files (int (*streamfunc) (FILE *, void *), + const char *streamfunc_name, + size_t digest_size, + const void *expected_for_empty_file, + const void *expected_for_small_file, + const void *expected_for_large_file) +{ + int pass; + unlink (TESTFILE); + + for (pass = 0; pass < 5; pass++) + { + { + FILE *fp = fopen (TESTFILE, "wb"); + if (fp == NULL) + { + fprintf (stderr, "Could not create file %s.\n", TESTFILE); + exit (1); + } + switch (pass) + { + case 0: + /* Nothing to do for the empty file. */ + break; + case 2: + /* Fill the small file, with some header that will be skipped. */ + fputs ("ABCD", fp); + FALLTHROUGH; + case 1: + /* Fill the small file. */ + fputs ("The quick brown fox jumps over the lazy dog.\n", fp); + break; + case 4: + /* Fill the large file, with some header that will be skipped. */ + fputs ("ABCD", fp); + FALLTHROUGH; + case 3: + /* Fill the large file (8 MiB). */ + { + unsigned int i; + for (i = 0; i < 0x400000; i++) + { + unsigned char c[2]; + unsigned int j = i * (i-1) * (i-5); + c[0] = (unsigned char)(j >> 6); + c[1] = (i % 499) + (i % 101); + fwrite (c, 1, 2, fp); + } + } + break; + } + if (ferror (fp)) + { + fprintf (stderr, "Could not write data to file %s.\n", TESTFILE); + exit (1); + } + fclose (fp); + } + { + /* Test an unaligned digest. */ + char *digest = (char *) malloc (digest_size + 1) + 1; + const void *expected; + FILE *fp; + int ret; + + switch (pass) + { + case 0: expected = expected_for_empty_file; break; + case 1: case 2: expected = expected_for_small_file; break; + case 3: case 4: expected = expected_for_large_file; break; + default: abort (); + } + + fp = fopen (TESTFILE, "rb"); + if (fp == NULL) + { + fprintf (stderr, "Could not open file %s.\n", TESTFILE); + exit (1); + } + switch (pass) + { + case 2: + case 4: + { + char header[4]; + if (fread (header, 1, sizeof (header), fp) != sizeof (header)) + { + fprintf (stderr, "Could not read the header of %s.\n", + TESTFILE); + exit (1); + } + } + break; + } + ret = streamfunc (fp, digest); + if (ret) + { + fprintf (stderr, "%s failed with error %d\n", streamfunc_name, -ret); + exit (1); + } + if (memcmp (digest, expected, digest_size) != 0) + { + size_t i; + fprintf (stderr, "%s produced wrong result.\n", streamfunc_name); + fprintf (stderr, "Expected: "); + for (i = 0; i < digest_size; i++) + fprintf (stderr, "\\x%02x", ((const unsigned char *) expected)[i]); + fprintf (stderr, "\n"); + fprintf (stderr, "Got: "); + for (i = 0; i < digest_size; i++) + fprintf (stderr, "\\x%02x", ((const unsigned char *) digest)[i]); + fprintf (stderr, "\n"); + exit (1); + } + /* Verify that fp is now positioned at end of file. */ + if (getc (fp) != EOF) + { + fprintf (stderr, "%s left the stream not at EOF\n", streamfunc_name); + exit (1); + } + fclose (fp); + free (digest - 1); + } + } + + unlink (TESTFILE); +} diff --git a/gnulib-tests/test-dirent-safer.c b/gnulib-tests/test-dirent-safer.c new file mode 100644 index 0000000..d0d703d --- /dev/null +++ b/gnulib-tests/test-dirent-safer.c @@ -0,0 +1,94 @@ +/* Test that directory streams leave standard fds alone. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include "dirent--.h" + +#include <errno.h> +#include <fcntl.h> +#include <stdio.h> +#include <unistd.h> + +/* This test intentionally closes stderr. So, we arrange to have fd 10 + (outside the range of interesting fd's during the test) set up to + duplicate the original stderr. */ + +#define BACKUP_STDERR_FILENO 10 +#define ASSERT_STREAM myerr +#include "macros.h" + +static FILE *myerr; + +int +main (void) +{ + int i; + DIR *dp; + /* The dirent-safer module works without the use of fdopendir (which + would also pull in fchdir and openat); but if those modules were + also used, we ensure that they are safe. In particular, the + gnulib version of fdopendir is unable to guarantee that + dirfd(fdopendir(fd))==fd, but we can at least guarantee that if + they are not equal, the fd returned by dirfd is safe. */ +#if HAVE_FDOPENDIR || GNULIB_TEST_FDOPENDIR + int dfd; +#endif + + /* We close fd 2 later, so save it in fd 10. */ + if (dup2 (STDERR_FILENO, BACKUP_STDERR_FILENO) != BACKUP_STDERR_FILENO + || (myerr = fdopen (BACKUP_STDERR_FILENO, "w")) == NULL) + return 2; + +#if HAVE_FDOPENDIR || GNULIB_TEST_FDOPENDIR + dfd = open (".", O_RDONLY); + ASSERT (STDERR_FILENO < dfd); +#endif + + /* Four iterations, with progressively more standard descriptors + closed. */ + for (i = -1; i <= STDERR_FILENO; i++) + { + if (0 <= i) + ASSERT (close (i) == 0); + dp = opendir ("."); + ASSERT (dp); + ASSERT (dirfd (dp) == -1 || STDERR_FILENO < dirfd (dp)); + ASSERT (closedir (dp) == 0); + +#if HAVE_FDOPENDIR || GNULIB_TEST_FDOPENDIR + { + int fd = fcntl (dfd, F_DUPFD_CLOEXEC, STDERR_FILENO + 1); + ASSERT (STDERR_FILENO < fd); + dp = fdopendir (fd); + ASSERT (dp); + ASSERT (dirfd (dp) == -1 || STDERR_FILENO < dirfd (dp)); + ASSERT (closedir (dp) == 0); + errno = 0; + ASSERT (close (fd) == -1); + ASSERT (errno == EBADF); + } +#endif + } + +#if HAVE_FDOPENDIR || GNULIB_TEST_FDOPENDIR + ASSERT (close (dfd) == 0); +#endif + + return 0; +} diff --git a/gnulib-tests/test-dirent.c b/gnulib-tests/test-dirent.c new file mode 100644 index 0000000..f451322 --- /dev/null +++ b/gnulib-tests/test-dirent.c @@ -0,0 +1,32 @@ +/* Test of <dirent.h> substitute. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <dirent.h> + +/* Check for existence of required types. */ +static DIR *dir _GL_UNUSED; +static struct dirent d; +static ino_t i; + +int +main (void) +{ + return d.d_name[0] + i; +} diff --git a/gnulib-tests/test-dirname.c b/gnulib-tests/test-dirname.c new file mode 100644 index 0000000..3381f48 --- /dev/null +++ b/gnulib-tests/test-dirname.c @@ -0,0 +1,193 @@ +/* Test the gnulib dirname module. + Copyright (C) 2005-2007, 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include "dirname.h" + +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +struct test { + const char *name; /* Name under test. */ + const char *dir; /* dir_name (name). */ + const char *last; /* last_component (name). */ + const char *base; /* base_name (name). */ + const char *stripped; /* name after strip_trailing_slashes (name). */ + bool modified; /* result of strip_trailing_slashes (name). */ + bool absolute; /* IS_ABSOLUTE_FILE_NAME (name). */ +}; + +static struct test tests[] = { + {"d/f", "d", "f", "f", "d/f", false, false}, + {"/d/f", "/d", "f", "f", "/d/f", false, true}, + {"d/f/", "d", "f/", "f/", "d/f", true, false}, + {"d/f//", "d", "f//", "f/", "d/f", true, false}, + {"f", ".", "f", "f", "f", false, false}, + {"/", "/", "", "/", "/", false, true}, +#if DOUBLE_SLASH_IS_DISTINCT_ROOT + {"//", "//", "", "//", "//", false, true}, + {"//d", "//", "d", "d", "//d", false, true}, +#else + {"//", "/", "", "/", "/", true, true}, + {"//d", "/", "d", "d", "//d", false, true}, +#endif + {"///", "/", "", "/", "/", true, true}, + {"///a///", "/", "a///", "a/", "///a", true, true}, + /* POSIX requires dirname("") and basename("") to both return ".", + but dir_name and base_name are defined differently. */ + {"", ".", "", "", "", false, false}, + {".", ".", ".", ".", ".", false, false}, + {"..", ".", "..", "..", "..", false, false}, +#if ISSLASH ('\\') + {"a\\", ".", "a\\", "a\\", "a", true, false}, + {"a\\b", "a", "b", "b", "a\\b", false, false}, + {"\\", "\\", "", "\\", "\\", false, true}, + {"\\/\\", "\\", "", "\\", "\\", true, true}, + {"\\\\/", "\\", "", "\\", "\\", true, true}, + {"\\//", "\\", "", "\\", "\\", true, true}, + {"//\\", "/", "", "/", "/", true, true}, +#else + {"a\\", ".", "a\\", "a\\", "a\\", false, false}, + {"a\\b", ".", "a\\b", "a\\b", "a\\b", false, false}, + {"\\", ".", "\\", "\\", "\\", false, false}, + {"\\/\\", "\\", "\\", "\\", "\\/\\",false, false}, + {"\\\\/", ".", "\\\\/","\\\\/","\\\\", true, false}, + {"\\//", ".", "\\//", "\\/", "\\", true, false}, +# if DOUBLE_SLASH_IS_DISTINCT_ROOT + {"//\\", "//", "\\", "\\", "//\\", false, true}, +# else + {"//\\", "/", "\\", "\\", "//\\", false, true}, +# endif +#endif +#if ISSLASH ('\\') +# if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE + {"c:", "c:", "", "c:", "c:", false, false}, + {"c:/", "c:/", "", "c:/", "c:/", false, true}, + {"c://", "c:/", "", "c:/", "c:/", true, true}, + {"c:/d", "c:/", "d", "d", "c:/d", false, true}, + {"c://d", "c:/", "d", "d", "c://d",false, true}, + {"c:/d/", "c:/", "d/", "d/", "c:/d", true, true}, + {"c:/d/f", "c:/d", "f", "f", "c:/d/f",false, true}, + {"c:d", "c:.", "d", "d", "c:d", false, false}, + {"c:d/", "c:.", "d/", "d/", "c:d", true, false}, + {"c:d/f", "c:d", "f", "f", "c:d/f",false, false}, + {"a:b:c", "a:.", "b:c", "./b:c","a:b:c",false, false}, + {"a/b:c", "a", "b:c", "./b:c","a/b:c",false, false}, + {"a/b:c/", "a", "b:c/", "./b:c/","a/b:c",true, false}, +# else /* ! FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE */ + {"c:", "c:", "", "c:", "c:", false, true}, + {"c:/", "c:", "", "c:", "c:", true, true}, + {"c://", "c:", "", "c:", "c:", true, true}, + {"c:/d", "c:", "d", "d", "c:/d", false, true}, + {"c://d", "c:", "d", "d", "c://d",false, true}, + {"c:/d/", "c:", "d/", "d/", "c:/d", true, true}, + {"c:/d/f", "c:/d", "f", "f", "c:/d/f",false, true}, + {"c:d", "c:", "d", "d", "c:d", false, true}, + {"c:d/", "c:", "d/", "d/", "c:d", true, true}, + {"c:d/f", "c:d", "f", "f", "c:d/f",false, true}, + {"a:b:c", "a:", "b:c", "./b:c","a:b:c",false, true}, + {"a/b:c", "a", "b:c", "./b:c","a/b:c",false, false}, + {"a/b:c/", "a", "b:c/", "./b:c/","a/b:c",true, false}, +# endif +#else /* ! ISSLASH ('\\') */ + {"c:", ".", "c:", "c:", "c:", false, false}, + {"c:/", ".", "c:/", "c:/", "c:", true, false}, + {"c://", ".", "c://", "c:/", "c:", true, false}, + {"c:/d", "c:", "d", "d", "c:/d", false, false}, + {"c://d", "c:", "d", "d", "c://d",false, false}, + {"c:/d/", "c:", "d/", "d/", "c:/d", true, false}, + {"c:/d/f", "c:/d", "f", "f", "c:/d/f",false, false}, + {"c:d", ".", "c:d", "c:d", "c:d", false, false}, + {"c:d/", ".", "c:d/", "c:d/", "c:d", true, false}, + {"c:d/f", "c:d", "f", "f", "c:d/f",false, false}, + {"a:b:c", ".", "a:b:c","a:b:c","a:b:c",false, false}, + {"a/b:c", "a", "b:c", "b:c", "a/b:c",false, false}, + {"a/b:c/", "a", "b:c/", "b:c/", "a/b:c",true, false}, +#endif + {"1:", ".", "1:", "1:", "1:", false, false}, + {"1:/", ".", "1:/", "1:/", "1:", true, false}, + {"/:", "/", ":", ":", "/:", false, true}, + {"/:/", "/", ":/", ":/", "/:", true, true}, + /* End sentinel. */ + {NULL, NULL, NULL, NULL, NULL, false, false} +}; + +int +main (void) +{ + struct test *t; + bool ok = true; + + for (t = tests; t->name; t++) + { + char *dir = dir_name (t->name); + int dirlen = dir_len (t->name); + char *last = last_component (t->name); + char *base = base_name (t->name); + int baselen = base_len (base); + char *stripped = strdup (t->name); + bool modified = strip_trailing_slashes (stripped); + bool absolute = IS_ABSOLUTE_FILE_NAME (t->name); + if (! (strcmp (dir, t->dir) == 0 + && (dirlen == strlen (dir) + || (dirlen + 1 == strlen (dir) && dir[dirlen] == '.')))) + { + ok = false; + printf ("dir_name '%s': got '%s' len %d," + " expected '%s' len %lu\n", + t->name, dir, dirlen, + t->dir, (unsigned long) strlen (t->dir)); + } + if (strcmp (last, t->last)) + { + ok = false; + printf ("last_component '%s': got '%s', expected '%s'\n", + t->name, last, t->last); + } + if (! (strcmp (base, t->base) == 0 + && (baselen == strlen (base) + || (baselen + 1 == strlen (base) + && ISSLASH (base[baselen]))))) + { + ok = false; + printf ("base_name '%s': got '%s' len %d," + " expected '%s' len %lu\n", + t->name, base, baselen, + t->base, (unsigned long) strlen (t->base)); + } + if (strcmp (stripped, t->stripped) || modified != t->modified) + { + ok = false; + printf ("strip_trailing_slashes '%s': got %s %s, expected %s %s\n", + t->name, stripped, modified ? "changed" : "unchanged", + t->stripped, t->modified ? "changed" : "unchanged"); + } + if (t->absolute != absolute) + { + ok = false; + printf ("'%s': got %s, expected %s\n", t->name, + absolute ? "absolute" : "relative", + t->absolute ? "absolute" : "relative"); + } + free (dir); + free (base); + free (stripped); + } + return ok ? 0 : 1; +} diff --git a/gnulib-tests/test-dup-safer.c b/gnulib-tests/test-dup-safer.c new file mode 100644 index 0000000..0635541 --- /dev/null +++ b/gnulib-tests/test-dup-safer.c @@ -0,0 +1,180 @@ +/* Test that dup_safer leaves standard fds alone. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include "unistd--.h" + +#include <fcntl.h> +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <unistd.h> + +#include "binary-io.h" +#include "cloexec.h" + +#if defined _WIN32 && ! defined __CYGWIN__ +/* Get declarations of the native Windows API functions. */ +# define WIN32_LEAN_AND_MEAN +# include <windows.h> +/* Get _get_osfhandle. */ +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include <io.h> +# endif +#endif + +#if !O_BINARY +# define setmode(f,m) zero () +static int zero (void) { return 0; } +#endif + +/* This test intentionally closes stderr. So, we arrange to have fd 10 + (outside the range of interesting fd's during the test) set up to + duplicate the original stderr. */ + +#define BACKUP_STDERR_FILENO 10 +#define ASSERT_STREAM myerr +#include "macros.h" + +static FILE *myerr; + +/* Return true if FD is open. */ +static bool +is_open (int fd) +{ +#if defined _WIN32 && ! defined __CYGWIN__ + /* On native Windows, 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 +} + +/* Return true if FD is open and inheritable across exec/spawn. */ +static bool +is_inheritable (int fd) +{ +#if defined _WIN32 && ! defined __CYGWIN__ + /* On native Windows, 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. */ + HANDLE h = (HANDLE) _get_osfhandle (fd); + DWORD flags; + if (h == INVALID_HANDLE_VALUE || GetHandleInformation (h, &flags) == 0) + return 0; + return (flags & HANDLE_FLAG_INHERIT) != 0; +#else +# ifndef F_GETFD +# error Please port fcntl to your platform +# endif + int i = fcntl (fd, F_GETFD); + return 0 <= i && (i & FD_CLOEXEC) == 0; +#endif +} + +/* Return true if FD is open in the given MODE, which is either + O_TEXT or O_BINARY. */ +static bool +is_mode (int fd, int mode) +{ + int value = setmode (fd, O_BINARY); + setmode (fd, value); + return mode == value; +} + +#define witness "test-dup-safer.txt" + +int +main (void) +{ + int i; + int fd; + int bad_fd = getdtablesize (); + + /* We close fd 2 later, so save it in fd 10. */ + if (dup2 (STDERR_FILENO, BACKUP_STDERR_FILENO) != BACKUP_STDERR_FILENO + || (myerr = fdopen (BACKUP_STDERR_FILENO, "w")) == NULL) + return 2; + + /* Create file for later checks. */ + fd = creat (witness, 0600); + ASSERT (STDERR_FILENO < fd); + + /* Four iterations, with progressively more standard descriptors + closed. */ + for (i = -1; i <= STDERR_FILENO; i++) + { + if (0 <= i) + ASSERT (close (i) == 0); + + /* Detect errors. */ + errno = 0; + ASSERT (dup (-1) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (dup (bad_fd) == -1); + ASSERT (errno == EBADF); + close (fd + 1); + errno = 0; + ASSERT (dup (fd + 1) == -1); + ASSERT (errno == EBADF); + + /* Preserve text vs. binary. */ + setmode (fd, O_BINARY); + ASSERT (dup (fd) == fd + 1); + ASSERT (is_open (fd + 1)); + ASSERT (is_inheritable (fd + 1)); + ASSERT (is_mode (fd + 1, O_BINARY)); + + ASSERT (close (fd + 1) == 0); + setmode (fd, O_TEXT); + ASSERT (dup (fd) == fd + 1); + ASSERT (is_open (fd + 1)); + ASSERT (is_inheritable (fd + 1)); + ASSERT (is_mode (fd + 1, O_TEXT)); + + /* Create cloexec copy. */ + ASSERT (close (fd + 1) == 0); + ASSERT (fd_safer_flag (dup_cloexec (fd), O_CLOEXEC) == fd + 1); + ASSERT (set_cloexec_flag (fd + 1, true) == 0); + ASSERT (is_open (fd + 1)); + ASSERT (!is_inheritable (fd + 1)); + ASSERT (close (fd) == 0); + + /* dup always creates inheritable copies. Also, check that + earliest slot past std fds is used. */ + ASSERT (dup (fd + 1) == fd); + ASSERT (is_open (fd)); + ASSERT (is_inheritable (fd)); + ASSERT (close (fd + 1) == 0); + } + + /* Cleanup. */ + ASSERT (close (fd) == 0); + ASSERT (unlink (witness) == 0); + + return 0; +} diff --git a/gnulib-tests/test-dup.c b/gnulib-tests/test-dup.c new file mode 100644 index 0000000..fdcaf39 --- /dev/null +++ b/gnulib-tests/test-dup.c @@ -0,0 +1,45 @@ +/* Test duplicating a file descriptor. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (dup, int, (int)); + +#include <errno.h> + +#include "macros.h" + +int +main (void) +{ + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (dup (-1) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (dup (99) == -1); + ASSERT (errno == EBADF); + } + + return 0; +} diff --git a/gnulib-tests/test-dup2.c b/gnulib-tests/test-dup2.c new file mode 100644 index 0000000..7f7b1c4 --- /dev/null +++ b/gnulib-tests/test-dup2.c @@ -0,0 +1,222 @@ +/* Test duplicating file descriptors. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (dup2, int, (int, int)); + +#include <errno.h> +#include <fcntl.h> + +#if HAVE_SYS_RESOURCE_H +# include <sys/resource.h> +#endif + +#include "binary-io.h" + +#if GNULIB_TEST_CLOEXEC +# include "cloexec.h" +#endif + +#if defined _WIN32 && ! defined __CYGWIN__ +/* Get declarations of the native Windows API functions. */ +# define WIN32_LEAN_AND_MEAN +# include <windows.h> +/* Get _get_osfhandle. */ +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include <io.h> +# endif +#endif + +#include "macros.h" + +/* Return non-zero if FD is open. */ +static int +is_open (int fd) +{ +#if defined _WIN32 && ! defined __CYGWIN__ + /* On native Windows, 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 +} + +#if GNULIB_TEST_CLOEXEC +/* Return non-zero if FD is open and inheritable across exec/spawn. */ +static int +is_inheritable (int fd) +{ +# if defined _WIN32 && ! defined __CYGWIN__ + /* On native Windows, 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. */ + HANDLE h = (HANDLE) _get_osfhandle (fd); + DWORD flags; + if (h == INVALID_HANDLE_VALUE || GetHandleInformation (h, &flags) == 0) + return 0; + return (flags & HANDLE_FLAG_INHERIT) != 0; +# else +# ifndef F_GETFD +# error Please port fcntl to your platform +# endif + int i = fcntl (fd, F_GETFD); + return 0 <= i && (i & FD_CLOEXEC) == 0; +# endif +} +#endif /* GNULIB_TEST_CLOEXEC */ + +#if !O_BINARY +# define setmode(f,m) zero () +static int zero (void) { return 0; } +#endif + +/* Return non-zero if FD is open in the given MODE, which is either + O_TEXT or O_BINARY. */ +static int +is_mode (int fd, int mode) +{ + int value = setmode (fd, O_BINARY); + setmode (fd, value); + return mode == value; +} + +int +main (void) +{ + const char *file = "test-dup2.tmp"; + char buffer[1]; + int bad_fd = getdtablesize (); + int fd = open (file, O_CREAT | O_TRUNC | 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)); + + /* The source must be valid. */ + errno = 0; + ASSERT (dup2 (-1, fd) == -1); + ASSERT (errno == EBADF); + close (99); + errno = 0; + ASSERT (dup2 (99, fd) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (dup2 (AT_FDCWD, fd) == -1); + ASSERT (errno == EBADF); + 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); + 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); + + /* 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)); + + /* Verify 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 (lseek (fd, 0, SEEK_END) == 0); + ASSERT (write (fd + 2, "2", 1) == 1); + ASSERT (lseek (fd, 0, SEEK_SET) == 0); + ASSERT (read (fd, buffer, 1) == 1); + ASSERT (*buffer == '2'); + +#if GNULIB_TEST_CLOEXEC + /* Any new fd created by dup2 must not be cloexec. */ + ASSERT (close (fd + 2) == 0); + ASSERT (dup_cloexec (fd) == fd + 1); + ASSERT (!is_inheritable (fd + 1)); + ASSERT (dup2 (fd + 1, fd + 1) == fd + 1); + ASSERT (!is_inheritable (fd + 1)); + ASSERT (dup2 (fd + 1, fd + 2) == fd + 2); + ASSERT (!is_inheritable (fd + 1)); + ASSERT (is_inheritable (fd + 2)); + errno = 0; + ASSERT (dup2 (fd + 1, -1) == -1); + ASSERT (errno == EBADF); + ASSERT (!is_inheritable (fd + 1)); +#endif + + /* On systems that distinguish between text and binary mode, dup2 + reuses the mode of the source. */ + setmode (fd, O_BINARY); + ASSERT (is_mode (fd, O_BINARY)); + ASSERT (dup2 (fd, fd + 1) == fd + 1); + ASSERT (is_mode (fd + 1, O_BINARY)); + setmode (fd, O_TEXT); + ASSERT (is_mode (fd, O_TEXT)); + ASSERT (dup2 (fd, fd + 1) == fd + 1); + ASSERT (is_mode (fd + 1, O_TEXT)); + + /* Clean up. */ + ASSERT (close (fd + 2) == 0); + ASSERT (close (fd + 1) == 0); + ASSERT (close (fd) == 0); + ASSERT (unlink (file) == 0); + + return 0; +} diff --git a/gnulib-tests/test-environ.c b/gnulib-tests/test-environ.c new file mode 100644 index 0000000..55ccd5d --- /dev/null +++ b/gnulib-tests/test-environ.c @@ -0,0 +1,44 @@ +/* Test of environ variable. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2008. */ + +#include <config.h> + +#include <unistd.h> + +#include <string.h> + +int +main () +{ + /* The environment variables that are set even in the weirdest situations + are HOME and PATH. + POSIX says that HOME is initialized by the system, and that PATH may be + unset. But in practice it's more frequent to see HOME unset and PATH + set. So we test the presence of PATH. */ + char **remaining_variables = environ; + char *string; + + for (; (string = *remaining_variables) != NULL; remaining_variables++) + { + if (strncmp (string, "PATH=", 5) == 0) + /* Found the PATH environment variable. */ + return 0; + } + /* Failed to find the PATH environment variable. */ + return 1; +} diff --git a/gnulib-tests/test-errno.c b/gnulib-tests/test-errno.c new file mode 100644 index 0000000..54f5ae6 --- /dev/null +++ b/gnulib-tests/test-errno.c @@ -0,0 +1,119 @@ +/* Test of <errno.h> substitute. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2008. */ + +#include <config.h> + +#include <errno.h> + +/* Verify that the POSIX mandated errno values exist and can be used as + initializers outside of a function. + The variable names happen to match the Linux/x86 error numbers. */ +int e1 = EPERM; +int e2 = ENOENT; +int e3 = ESRCH; +int e4 = EINTR; +int e5 = EIO; +int e6 = ENXIO; +int e7 = E2BIG; +int e8 = ENOEXEC; +int e9 = EBADF; +int e10 = ECHILD; +int e11 = EAGAIN; +int e11a = EWOULDBLOCK; +int e12 = ENOMEM; +int e13 = EACCES; +int e14 = EFAULT; +int e16 = EBUSY; +int e17 = EEXIST; +int e18 = EXDEV; +int e19 = ENODEV; +int e20 = ENOTDIR; +int e21 = EISDIR; +int e22 = EINVAL; +int e23 = ENFILE; +int e24 = EMFILE; +int e25 = ENOTTY; +int e26 = ETXTBSY; +int e27 = EFBIG; +int e28 = ENOSPC; +int e29 = ESPIPE; +int e30 = EROFS; +int e31 = EMLINK; +int e32 = EPIPE; +int e33 = EDOM; +int e34 = ERANGE; +int e35 = EDEADLK; +int e36 = ENAMETOOLONG; +int e37 = ENOLCK; +int e38 = ENOSYS; +int e39 = ENOTEMPTY; +int e40 = ELOOP; +int e42 = ENOMSG; +int e43 = EIDRM; +int e67 = ENOLINK; +int e71 = EPROTO; +int e72 = EMULTIHOP; +int e74 = EBADMSG; +int e75 = EOVERFLOW; +int e84 = EILSEQ; +int e88 = ENOTSOCK; +int e89 = EDESTADDRREQ; +int e90 = EMSGSIZE; +int e91 = EPROTOTYPE; +int e92 = ENOPROTOOPT; +int e93 = EPROTONOSUPPORT; +int e95 = EOPNOTSUPP; +int e95a = ENOTSUP; +int e97 = EAFNOSUPPORT; +int e98 = EADDRINUSE; +int e99 = EADDRNOTAVAIL; +int e100 = ENETDOWN; +int e101 = ENETUNREACH; +int e102 = ENETRESET; +int e103 = ECONNABORTED; +int e104 = ECONNRESET; +int e105 = ENOBUFS; +int e106 = EISCONN; +int e107 = ENOTCONN; +int e110 = ETIMEDOUT; +int e111 = ECONNREFUSED; +int e113 = EHOSTUNREACH; +int e114 = EALREADY; +int e115 = EINPROGRESS; +int e116 = ESTALE; +int e122 = EDQUOT; +int e125 = ECANCELED; +int e130 = EOWNERDEAD; +int e131 = ENOTRECOVERABLE; + +/* Don't verify that these errno values are all different, except for possibly + EWOULDBLOCK == EAGAIN. Even Linux/x86 does not pass this check: it has + ENOTSUP == EOPNOTSUPP. */ + +int +main () +{ + /* Verify that errno can be assigned. */ + errno = EOVERFLOW; + + /* snprintf() callers want to distinguish EINVAL and EOVERFLOW. */ + if (errno == EINVAL) + return 1; + + return 0; +} diff --git a/gnulib-tests/test-exclude.c b/gnulib-tests/test-exclude.c new file mode 100644 index 0000000..180f167 --- /dev/null +++ b/gnulib-tests/test-exclude.c @@ -0,0 +1,128 @@ +/* Test suite for exclude. + Copyright (C) 2009-2020 Free Software Foundation, Inc. + This file is part of the GNUlib Library. + + 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <string.h> +#include <stdbool.h> +#include <fnmatch.h> + +#include "exclude.h" +#include "error.h" +#include "argmatch.h" + +#ifndef FNM_CASEFOLD +# define FNM_CASEFOLD 0 +#endif +#ifndef FNM_LEADING_DIR +# define FNM_LEADING_DIR 0 +#endif + +char const * const exclude_keywords[] = { + "noescape", + "pathname", + "period", + "leading_dir", + "casefold", + "anchored", + "include", + "wildcards", + NULL +}; + +int exclude_flags[] = { + FNM_NOESCAPE, + FNM_PATHNAME, + FNM_PERIOD, + FNM_LEADING_DIR, + FNM_CASEFOLD, + EXCLUDE_ANCHORED, + EXCLUDE_INCLUDE, + EXCLUDE_WILDCARDS +}; + +ARGMATCH_VERIFY (exclude_keywords, exclude_flags); + +/* Some packages define ARGMATCH_DIE and ARGMATCH_DIE_DECL in <config.h>, and + thus must link with a definition of that function. Provide it here. */ +#ifdef ARGMATCH_DIE_DECL + +_Noreturn ARGMATCH_DIE_DECL; +ARGMATCH_DIE_DECL { exit (1); } + +#endif + +int +main (int argc, char **argv) +{ + int exclude_options = 0; + struct exclude *exclude = new_exclude (); + + if (argc == 1) + error (1, 0, "usage: %s file -- words...", argv[0]); + + while (--argc) + { + char *opt = *++argv; + if (opt[0] == '-') + { + int neg = 0; + int flag; + char *s = opt + 1; + + if (opt[1] == '-' && opt[2] == 0) + { + argc--; + break; + } + if (strlen (s) > 3 && memcmp (s, "no-", 3) == 0) + { + neg = 1; + s += 3; + } + flag = XARGMATCH (opt, s, exclude_keywords, exclude_flags); + if (neg) + exclude_options &= ~flag; + else + exclude_options |= flag; + + /* Skip this test if invoked with -leading-dir on a system that + lacks support for FNM_LEADING_DIR. */ + if (strcmp (s, "leading_dir") == 0 && FNM_LEADING_DIR == 0) + exit (77); + + /* Likewise for -casefold and FNM_CASEFOLD. */ + if (strcmp (s, "casefold") == 0 && FNM_CASEFOLD == 0) + exit (77); + } + else if (add_exclude_file (add_exclude, exclude, opt, + exclude_options, '\n') != 0) + error (1, errno, "error loading %s", opt); + } + + for (; argc; --argc) + { + char *word = *++argv; + + printf ("%s: %d\n", word, excluded_file_name (exclude, word)); + } + + free_exclude (exclude); + return 0; +} diff --git a/gnulib-tests/test-exclude1.sh b/gnulib-tests/test-exclude1.sh new file mode 100755 index 0000000..8b1a451 --- /dev/null +++ b/gnulib-tests/test-exclude1.sh @@ -0,0 +1,50 @@ +#! /bin/sh +# Test suite for exclude. +# Copyright (C) 2009-2020 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# 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 <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/init.sh"; path_prepend_ . +fail=0 + +# Test literal matches + +cat > in <<EOT +foo* +bar +Baz +EOT + +cat > expected <<EOT +foo: 0 +foo*: 1 +bar: 1 +foobar: 0 +baz: 0 +bar/qux: 0 +EOT + +${CHECKER} test-exclude in -- foo 'foo*' bar foobar baz bar/qux > out || exit $? + +# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr +# does not understand '\r'. +case $(echo r | tr -d '\r') in '') cr='\015';; *) cr='\r';; esac + +# normalize output +LC_ALL=C tr -d "$cr" < out > k && mv k out + +compare expected out || fail=1 + +Exit $fail diff --git a/gnulib-tests/test-exclude2.sh b/gnulib-tests/test-exclude2.sh new file mode 100755 index 0000000..db98de0 --- /dev/null +++ b/gnulib-tests/test-exclude2.sh @@ -0,0 +1,50 @@ +#! /bin/sh +# Test suite for exclude. +# Copyright (C) 2009-2020 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# 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 <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/init.sh"; path_prepend_ . +fail=0 + +cat > in <<EOT +foo* +bar +Baz +EOT + +# Test case-insensitive literal matches + +cat > expected <<EOT +foo: 0 +foo*: 1 +bar: 1 +foobar: 0 +baz: 1 +bar/qux: 0 +EOT + +${CHECKER} test-exclude -casefold in -- foo 'foo*' bar foobar baz bar/qux > out || exit $? + +# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr +# does not understand '\r'. +case $(echo r | tr -d '\r') in '') cr='\015';; *) cr='\r';; esac + +# normalize output +LC_ALL=C tr -d "$cr" < out > k && mv k out + +compare expected out || fail=1 + +Exit $fail diff --git a/gnulib-tests/test-exclude3.sh b/gnulib-tests/test-exclude3.sh new file mode 100755 index 0000000..6003fbd --- /dev/null +++ b/gnulib-tests/test-exclude3.sh @@ -0,0 +1,50 @@ +#! /bin/sh +# Test suite for exclude. +# Copyright (C) 2009-2020 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# 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 <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/init.sh"; path_prepend_ . +fail=0 + +# Test include + +cat > in <<EOT +foo* +bar +Baz +EOT + +cat > expected <<EOT +foo: 1 +foo*: 0 +bar: 0 +foobar: 1 +baz: 1 +bar/qux: 1 +EOT + +${CHECKER} test-exclude -include in -- foo 'foo*' bar foobar baz bar/qux > out || exit $? + +# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr +# does not understand '\r'. +case $(echo r | tr -d '\r') in '') cr='\015';; *) cr='\r';; esac + +# normalize output +LC_ALL=C tr -d "$cr" < out > k && mv k out + +compare expected out || fail=1 + +Exit $fail diff --git a/gnulib-tests/test-exclude4.sh b/gnulib-tests/test-exclude4.sh new file mode 100755 index 0000000..b386b88 --- /dev/null +++ b/gnulib-tests/test-exclude4.sh @@ -0,0 +1,45 @@ +#! /bin/sh +# Test suite for exclude. +# Copyright (C) 2009-2020 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# 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 <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/init.sh"; path_prepend_ . +fail=0 + +# Test wildcard matching + +cat > in <<EOT +foo* +bar +Baz +EOT + +cat > expected <<EOT +foobar: 1 +EOT + +${CHECKER} test-exclude -wildcards in -- foobar > out || exit $? + +# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr +# does not understand '\r'. +case $(echo r | tr -d '\r') in '') cr='\015';; *) cr='\r';; esac + +# normalize output +LC_ALL=C tr -d "$cr" < out > k && mv k out + +compare expected out || fail=1 + +Exit $fail diff --git a/gnulib-tests/test-exclude5.sh b/gnulib-tests/test-exclude5.sh new file mode 100755 index 0000000..34ba665 --- /dev/null +++ b/gnulib-tests/test-exclude5.sh @@ -0,0 +1,48 @@ +#! /bin/sh +# Test suite for exclude. +# Copyright (C) 2009-2020 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# 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 <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/init.sh"; path_prepend_ . +fail=0 + +# Test FNM_LEADING_DIR + +cat > in <<EOT +foo* +bar +Baz +EOT + +cat > expected <<EOT +bar: 1 +bar/qux: 1 +barz: 0 +foo/bar: 1 +EOT + +${CHECKER} test-exclude -leading_dir in -- bar bar/qux barz foo/bar > out || exit $? + +# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr +# does not understand '\r'. +case $(echo r | tr -d '\r') in '') cr='\015';; *) cr='\r';; esac + +# normalize output +LC_ALL=C tr -d "$cr" < out > k && mv k out + +compare expected out || fail=1 + +Exit $fail diff --git a/gnulib-tests/test-exclude6.sh b/gnulib-tests/test-exclude6.sh new file mode 100755 index 0000000..be3a4c4 --- /dev/null +++ b/gnulib-tests/test-exclude6.sh @@ -0,0 +1,46 @@ +#! /bin/sh +# Test suite for exclude. +# Copyright (C) 2009-2020 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# 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 <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/init.sh"; path_prepend_ . +fail=0 + +# Test anchored + +cat > in <<EOT +foo* +bar +Baz +EOT + +cat > expected <<EOT +bar: 1 +foo/bar: 0 +EOT + +${CHECKER} test-exclude -anchored in -- bar foo/bar > out || exit $? + +# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr +# does not understand '\r'. +case $(echo r | tr -d '\r') in '') cr='\015';; *) cr='\r';; esac + +# normalize output +LC_ALL=C tr -d "$cr" < out > k && mv k out + +compare expected out || fail=1 + +Exit $fail diff --git a/gnulib-tests/test-exclude7.sh b/gnulib-tests/test-exclude7.sh new file mode 100755 index 0000000..ed4e5bc --- /dev/null +++ b/gnulib-tests/test-exclude7.sh @@ -0,0 +1,47 @@ +#! /bin/sh +# Test suite for exclude. +# Copyright (C) 2009-2020 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# 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 <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/init.sh"; path_prepend_ . +fail=0 + +# Test exclude precedence + +cat > in <<EOT +foo* +bar +Baz +EOT + +cat > expected <<EOT +bar: 0 +bar: 1 +EOT + +${CHECKER} test-exclude in -include in -- bar > out || exit $? +${CHECKER} test-exclude -include in -no-include in -- bar >> out || exit $? + +# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr +# does not understand '\r'. +case $(echo r | tr -d '\r') in '') cr='\015';; *) cr='\r';; esac + +# normalize output +LC_ALL=C tr -d "$cr" < out > k && mv k out + +compare expected out || fail=1 + +Exit $fail diff --git a/gnulib-tests/test-exclude8.sh b/gnulib-tests/test-exclude8.sh new file mode 100755 index 0000000..d496834 --- /dev/null +++ b/gnulib-tests/test-exclude8.sh @@ -0,0 +1,46 @@ +#! /bin/sh +# Test suite for exclude. +# Copyright (C) 2010-2020 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# 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 <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/init.sh"; path_prepend_ . +fail=0 + +# Test escaped metacharacters. + +cat > in <<'EOT' +f\*e +b[a\*]r +EOT + +cat > expected <<'EOT' +f*e: 1 +file: 0 +bar: 1 +EOT + +${CHECKER} test-exclude -wildcards in -- 'f*e' 'file' 'bar' > out || exit $? + +# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr +# does not understand '\r'. +case $(echo r | tr -d '\r') in '') cr='\015';; *) cr='\r';; esac + +# normalize output +LC_ALL=C tr -d "$cr" < out > k && mv k out + +compare expected out || fail=1 + +Exit $fail diff --git a/gnulib-tests/test-faccessat.c b/gnulib-tests/test-faccessat.c new file mode 100644 index 0000000..00342c6 --- /dev/null +++ b/gnulib-tests/test-faccessat.c @@ -0,0 +1,76 @@ +/* Test checking user's permissions for a file. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (faccessat, int, (int, const char *, int, int)); + +#include <errno.h> +#include <fcntl.h> + +#include "macros.h" + +#define BASE "test-faccessat.t" + +int +main (void) +{ + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (faccessat (-1, "foo", F_OK, 0) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (faccessat (99, "foo", F_OK, 0) == -1); + ASSERT (errno == EBADF); + } + + /* Test behavior with trailing slash. */ + unlink (BASE "file"); + ASSERT (faccessat (AT_FDCWD, ".", X_OK, 0) == 0); + ASSERT (faccessat (AT_FDCWD, "./", X_OK, 0) == 0); + ASSERT (close (open (BASE "file", O_CREAT | O_WRONLY, 0)) == 0); + ASSERT (faccessat (AT_FDCWD, BASE "file", F_OK, 0) == 0); + ASSERT (faccessat (AT_FDCWD, BASE "file/", F_OK, 0) != 0); + unlink (BASE "link1"); + if (symlink (".", BASE "link1") == 0) + { + ASSERT (faccessat (AT_FDCWD, BASE "link1", X_OK, 0) == 0); + ASSERT (faccessat (AT_FDCWD, BASE "link1/", X_OK, 0) == 0); + + unlink (BASE "link2"); + ASSERT (symlink (BASE "file", BASE "link2") == 0); + ASSERT (faccessat (AT_FDCWD, BASE "link2", F_OK, 0) == 0); + ASSERT (faccessat (AT_FDCWD, BASE "link2/", F_OK, 0) != 0); + unlink (BASE "link2"); + + unlink (BASE "link3"); + ASSERT (symlink (BASE "no-such-file", BASE "link3") == 0); + ASSERT (faccessat (AT_FDCWD, BASE "link3", F_OK, 0) != 0); + ASSERT (faccessat (AT_FDCWD, BASE "link3/", F_OK, 0) != 0); + unlink (BASE "link3"); + } + unlink (BASE "link1"); + unlink (BASE "file"); + + return 0; +} diff --git a/gnulib-tests/test-fadvise.c b/gnulib-tests/test-fadvise.c new file mode 100644 index 0000000..5d5d9c1 --- /dev/null +++ b/gnulib-tests/test-fadvise.c @@ -0,0 +1,50 @@ +/* Test that fadvise works as advertised. + Copyright (C) 2010-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Pádraig Brady. */ + +#include <config.h> +#include <stdio.h> + +#include "fadvise.h" + +/* We ignore any errors as these hints are only advisory. + * There is the chance one can pass invalid ADVICE, which will + * not be indicated, but given the simplicity of the interface + * this is unlikely. Also not returning errors allows the + * unconditional passing of descriptors to non standard files, + * which will just be ignored if unsupported. */ + +int +main (void) +{ + /* Valid. */ + fadvise (stdin, FADVISE_SEQUENTIAL); + fdadvise (fileno (stdin), 0, 0, FADVISE_RANDOM); + + /* Ignored. */ + fadvise (NULL, FADVISE_RANDOM); + + /* Invalid. */ + fdadvise (42, 0, 0, FADVISE_RANDOM); + /* Unfortunately C enums are not types. + One could hack type safety by wrapping in a struct, + but it's probably not worth the complexity in this case. */ + fadvise (stdin, FADVISE_SEQUENTIAL + FADVISE_RANDOM); + fadvise (stdin, 4242); + + return 0; +} diff --git a/gnulib-tests/test-fchdir.c b/gnulib-tests/test-fchdir.c new file mode 100644 index 0000000..9fc3cdb --- /dev/null +++ b/gnulib-tests/test-fchdir.c @@ -0,0 +1,110 @@ +/* Test changing to a directory named by a file descriptor. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (fchdir, int, (int)); + +#include <errno.h> +#include <fcntl.h> +#include <stdlib.h> +#include <string.h> + +#include "cloexec.h" +#include "macros.h" + +int +main (void) +{ + char *cwd; + int fd; + int i; + + cwd = getcwd (NULL, 0); + ASSERT (cwd); + + fd = open (".", O_RDONLY); + ASSERT (0 <= fd); + + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (fchdir (-1) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (fchdir (99) == -1); + ASSERT (errno == EBADF); + } + + /* Check for other failure cases. */ + { + int bad_fd = open ("/dev/null", O_RDONLY); + ASSERT (0 <= bad_fd); + errno = 0; + ASSERT (fchdir (bad_fd) == -1); + ASSERT (errno == ENOTDIR); + ASSERT (close (bad_fd) == 0); + } + + /* Repeat test twice, once in '.' and once in '..'. */ + for (i = 0; i < 2; i++) + { + ASSERT (chdir (&".."[1 - i]) == 0); + ASSERT (fchdir (fd) == 0); + { + size_t len = strlen (cwd) + 1; + char *new_dir = malloc (len); + ASSERT (new_dir); + ASSERT (getcwd (new_dir, len) == new_dir); + ASSERT (strcmp (cwd, new_dir) == 0); + free (new_dir); + } + + /* For second iteration, use a cloned fd, to ensure that dup + remembers whether an fd was associated with a directory. */ + if (!i) + { + int new_fd = dup (fd); + ASSERT (0 <= new_fd); + ASSERT (close (fd) == 0); + ASSERT (dup2 (new_fd, fd) == fd); + ASSERT (close (new_fd) == 0); + ASSERT (dup_cloexec (fd) == new_fd); + ASSERT (dup2 (new_fd, fd) == fd); + ASSERT (close (new_fd) == 0); + ASSERT (fcntl (fd, F_DUPFD_CLOEXEC, new_fd) == new_fd); + ASSERT (close (fd) == 0); + ASSERT (fcntl (new_fd, F_DUPFD, fd) == fd); + ASSERT (close (new_fd) == 0); +#if GNULIB_TEST_DUP3 + ASSERT (dup3 (fd, new_fd, 0) == new_fd); + ASSERT (dup3 (new_fd, fd, 0) == fd); + ASSERT (close (new_fd) == 0); +#endif + } + } + + free (cwd); + return 0; +} diff --git a/gnulib-tests/test-fchmodat.c b/gnulib-tests/test-fchmodat.c new file mode 100644 index 0000000..f6b695b --- /dev/null +++ b/gnulib-tests/test-fchmodat.c @@ -0,0 +1,64 @@ +/* Test changing the protections of a file relative to an open directory. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <sys/stat.h> + +#include "signature.h" +SIGNATURE_CHECK (fchmodat, int, (int, const char *, mode_t, int)); + +#include <errno.h> +#include <fcntl.h> +#include <sys/stat.h> +#include <unistd.h> + +#include "macros.h" + +#define BASE "test-fchmodat." + +int +main (void) +{ + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (fchmodat (-1, "foo", 0600, 0) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (fchmodat (99, "foo", 0600, 0) == -1); + ASSERT (errno == EBADF); + } + + /* Test that fchmodat works on non-symlinks, when given + the AT_SYMLINK_NOFOLLOW flag. */ + { + struct stat statbuf; + unlink (BASE "file"); + ASSERT (close (creat (BASE "file", 0600)) == 0); + ASSERT (fchmodat (AT_FDCWD, BASE "file", 0400, AT_SYMLINK_NOFOLLOW) == 0); + ASSERT (stat (BASE "file", &statbuf) >= 0); + ASSERT ((statbuf.st_mode & 0700) == 0400); + /* Clean up. */ + ASSERT (chmod (BASE "file", 0600) == 0); + ASSERT (unlink (BASE "file") == 0); + } + + return 0; +} diff --git a/gnulib-tests/test-fchownat.c b/gnulib-tests/test-fchownat.c new file mode 100644 index 0000000..960e2e9 --- /dev/null +++ b/gnulib-tests/test-fchownat.c @@ -0,0 +1,105 @@ +/* Tests of fchownat. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (fchownat, int, (int, char const *, uid_t, gid_t, int)); + +#include <fcntl.h> +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/stat.h> + +#include "mgetgroups.h" +#include "openat.h" +#include "stat-time.h" +#include "ignore-value.h" +#include "macros.h" + +#ifndef BASE +# define BASE "test-fchownat.t" +#endif + +#include "test-chown.h" +#include "test-lchown.h" + +static int dfd = AT_FDCWD; + +/* Wrapper around fchownat to test chown behavior. */ +static int +do_chown (char const *name, uid_t user, gid_t group) +{ +#ifdef TEST_CHOWNAT + return chownat (dfd, name, user, group); +#else + return fchownat (dfd, name, user, group, 0); +#endif +} + +/* Wrapper around fchownat to test lchown behavior. */ +static int +do_lchown (char const *name, uid_t user, gid_t group) +{ +#ifdef TEST_CHOWNAT + return lchownat (dfd, name, user, group); +#else + return fchownat (dfd, name, user, group, AT_SYMLINK_NOFOLLOW); +#endif +} + +int +main (int argc _GL_UNUSED, char *argv[]) +{ + int result1; /* Skip because of no chown/symlink support. */ + int result2; /* Skip because of no lchown support. */ + + /* Clean up any trash from prior testsuite runs. */ + ignore_value (system ("rm -rf " BASE "*")); + + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (fchownat (-1, "foo", getuid (), getgid (), 0) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (fchownat (99, "foo", getuid (), getgid (), 0) == -1); + ASSERT (errno == EBADF); + } + + /* Basic tests. */ + result1 = test_chown (do_chown, true); + result2 = test_lchown (do_lchown, result1 == 0); + dfd = open (".", O_RDONLY); + ASSERT (0 <= dfd); + ASSERT (test_chown (do_chown, false) == result1); + ASSERT (test_lchown (do_lchown, false) == result2); + /* We expect 0/0, 0/77, or 77/77, but not 77/0. */ + ASSERT (result1 <= result2); + ASSERT (close (dfd) == 0); + + /* FIXME - add additional tests of dfd not at current directory. */ + return result1 | result2; +} diff --git a/gnulib-tests/test-fclose.c b/gnulib-tests/test-fclose.c new file mode 100644 index 0000000..36c2b32 --- /dev/null +++ b/gnulib-tests/test-fclose.c @@ -0,0 +1,114 @@ +/* Test of fclose module. + Copyright (C) 2011-2020 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, 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake. */ + +#include <config.h> + +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (fclose, int, (FILE *)); + +#include <errno.h> +#include <fcntl.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include "macros.h" + +#define BASE "test-fclose.t" + +int +main (int argc, char **argv) +{ + const char buf[] = "hello world"; + int fd; + int fd2; + FILE *f; + + /* Prepare a seekable file. */ + fd = open (BASE, O_RDWR | O_CREAT | O_TRUNC, 0600); + ASSERT (0 <= fd); + ASSERT (write (fd, buf, sizeof buf) == sizeof buf); + ASSERT (lseek (fd, 1, SEEK_SET) == 1); + + /* Create an output stream visiting the file; when it is closed, all + other file descriptors visiting the file must see the new file + position. */ + fd2 = dup (fd); + ASSERT (0 <= fd2); + f = fdopen (fd2, "w"); + ASSERT (f); + ASSERT (fputc (buf[1], f) == buf[1]); + ASSERT (fclose (f) == 0); + errno = 0; + ASSERT (lseek (fd2, 0, SEEK_CUR) == -1); + ASSERT (errno == EBADF); + ASSERT (lseek (fd, 0, SEEK_CUR) == 2); + + /* Likewise for an input stream. */ + fd2 = dup (fd); + ASSERT (0 <= fd2); + f = fdopen (fd2, "r"); + ASSERT (f); + ASSERT (fgetc (f) == buf[2]); + ASSERT (fclose (f) == 0); + errno = 0; + ASSERT (lseek (fd2, 0, SEEK_CUR) == -1); + ASSERT (errno == EBADF); + ASSERT (lseek (fd, 0, SEEK_CUR) == 3); + + /* Test that fclose() sets errno if someone else closes the stream + fd behind the back of stdio. */ + { + FILE *fp = fdopen (fd, "w+"); + ASSERT (fp != NULL); + ASSERT (close (fd) == 0); + errno = 0; + ASSERT (fclose (fp) == EOF); + ASSERT (errno == EBADF); + } + + /* Test that fclose() sets errno if the stream was constructed with + an invalid file descriptor. */ + { + FILE *fp = fdopen (-1, "r"); + if (fp != NULL) + { + errno = 0; + ASSERT (fclose (fp) == EOF); + ASSERT (errno == EBADF); + } + } + { + FILE *fp; + close (99); + fp = fdopen (99, "r"); + if (fp != NULL) + { + errno = 0; + ASSERT (fclose (fp) == EOF); + ASSERT (errno == EBADF); + } + } + + /* Clean up. */ + ASSERT (remove (BASE) == 0); + + return 0; +} diff --git a/gnulib-tests/test-fcntl-h.c b/gnulib-tests/test-fcntl-h.c new file mode 100644 index 0000000..22a6212 --- /dev/null +++ b/gnulib-tests/test-fcntl-h.c @@ -0,0 +1,130 @@ +/* Test of <fcntl.h> substitute. + Copyright (C) 2007, 2009-2020 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 <https://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_IGNORE_CTTY | O_NDELAY | O_NOATIME + | O_NONBLOCK | O_NOCTTY | O_NOFOLLOW | O_NOLINK | O_NOLINKS | O_NOTRANS + | O_RSYNC | O_SYNC | O_TTY_INIT | O_BINARY | O_TEXT); + +/* Check that the various SEEK_* macros are defined. */ +int sk[] = { SEEK_CUR, SEEK_END, SEEK_SET }; + +/* Check that the FD_* macros are defined. */ +int i = FD_CLOEXEC; + +/* Check that the types are all defined. */ +pid_t t1; +off_t t2; +mode_t t3; + +int +main (void) +{ + /* Ensure no overlap in SEEK_*. */ + switch (0) + { + case SEEK_CUR: + case SEEK_END: + case SEEK_SET: + ; + } + + /* Ensure no dangerous overlap in non-zero gnulib-defined replacements. */ + switch (O_RDONLY) + { + /* Access modes */ + case O_RDONLY: + case O_WRONLY: + case O_RDWR: +#if O_EXEC && O_EXEC != O_RDONLY + case O_EXEC: +#endif +#if O_SEARCH && O_EXEC != O_SEARCH && O_SEARCH != O_RDONLY + case O_SEARCH: +#endif + i = ! (~O_ACCMODE & (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)); + break; + + /* Everyone should have these */ + case O_CREAT: + case O_EXCL: + case O_TRUNC: + case O_APPEND: + break; + + /* These might be 0 or O_RDONLY, only test non-zero versions. */ +#if O_CLOEXEC + case O_CLOEXEC: +#endif +#if O_DIRECT + case O_DIRECT: +#endif +#if O_DIRECTORY + case O_DIRECTORY: +#endif +#if O_DSYNC + case O_DSYNC: +#endif +#if O_IGNORE_CTTY + case O_IGNORE_CTTY: +#endif +#if O_NOATIME + case O_NOATIME: +#endif +#if O_NONBLOCK + case O_NONBLOCK: +#endif +#if O_NOCTTY + case O_NOCTTY: +#endif +#if O_NOFOLLOW + case O_NOFOLLOW: +#endif +#if O_NOLINK + case O_NOLINK: +#endif +#if O_NOLINKS + case O_NOLINKS: +#endif +#if O_NOTRANS + case O_NOTRANS: +#endif +#if O_RSYNC && O_RSYNC != O_DSYNC + case O_RSYNC: +#endif +#if O_SYNC && O_SYNC != O_DSYNC && O_SYNC != O_RSYNC + case O_SYNC: +#endif +#if O_TTY_INIT + case O_TTY_INIT: +#endif +#if O_BINARY + case O_BINARY: +#endif +#if O_TEXT + case O_TEXT: +#endif + ; + } + + return !i; +} diff --git a/gnulib-tests/test-fcntl-safer.c b/gnulib-tests/test-fcntl-safer.c new file mode 100644 index 0000000..62633ba --- /dev/null +++ b/gnulib-tests/test-fcntl-safer.c @@ -0,0 +1,38 @@ +/* Test of opening a file descriptor. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include "fcntl--.h" + +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <unistd.h> + +#include "macros.h" + +#define BASE "test-fcntl-safer.t" + +#include "test-open.h" + +int +main (void) +{ + return test_open (open, true); +} diff --git a/gnulib-tests/test-fcntl.c b/gnulib-tests/test-fcntl.c new file mode 100644 index 0000000..d5e7e63 --- /dev/null +++ b/gnulib-tests/test-fcntl.c @@ -0,0 +1,414 @@ +/* Test of fcntl(2). + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +/* Specification. */ +#include <fcntl.h> + +#include "signature.h" +SIGNATURE_CHECK (fcntl, int, (int, int, ...)); + +/* Helpers. */ +#include <errno.h> +#include <stdarg.h> +#include <stdbool.h> +#include <unistd.h> + +#if defined _WIN32 && ! defined __CYGWIN__ +/* Get declarations of the native Windows API functions. */ +# define WIN32_LEAN_AND_MEAN +# include <windows.h> +/* Get _get_osfhandle. */ +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include <io.h> +# endif +#endif + +#include "binary-io.h" +#include "macros.h" + +#if !O_BINARY +# define setmode(f,m) zero () +static int zero (void) { return 0; } +#endif + +/* Return true if FD is open. */ +static bool +is_open (int fd) +{ +#if defined _WIN32 && ! defined __CYGWIN__ + /* On native Windows, 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 +} + +/* Return true if FD is open and inheritable across exec/spawn. */ +static bool +is_inheritable (int fd) +{ +#if defined _WIN32 && ! defined __CYGWIN__ + /* On native Windows, 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. */ + HANDLE h = (HANDLE) _get_osfhandle (fd); + DWORD flags; + if (h == INVALID_HANDLE_VALUE || GetHandleInformation (h, &flags) == 0) + return false; + return (flags & HANDLE_FLAG_INHERIT) != 0; +#else +# ifndef F_GETFD +# error Please port fcntl to your platform +# endif + int i = fcntl (fd, F_GETFD); + return 0 <= i && (i & FD_CLOEXEC) == 0; +#endif +} + +/* Return non-zero if FD is open in the given MODE, which is either + O_TEXT or O_BINARY. */ +static bool +is_mode (int fd, int mode) +{ + int value = setmode (fd, O_BINARY); + setmode (fd, value); + return mode == value; +} + +/* Since native fcntl can have more supported operations than our + replacement is aware of, and since various operations assign + different types to the vararg argument, a wrapper around fcntl must + be able to pass a vararg of unknown type on through to the original + fcntl. Make sure that this works properly: func1 behaves like the + original fcntl interpreting the vararg as an int or a pointer to a + struct, and func2 behaves like rpl_fcntl that doesn't know what + type to forward. */ +struct dummy_struct +{ + long filler; + int value; +}; +static int +func1 (int a, ...) +{ + va_list arg; + int i; + va_start (arg, a); + if (a < 4) + i = va_arg (arg, int); + else + { + struct dummy_struct *s = va_arg (arg, struct dummy_struct *); + i = s->value; + } + va_end (arg); + return i; +} +static int +func2 (int a, ...) +{ + va_list arg; + void *p; + va_start (arg, a); + p = va_arg (arg, void *); + va_end (arg); + return func1 (a, p); +} + +/* Ensure that all supported fcntl actions are distinct, and + usable in preprocessor expressions. */ +static void +check_flags (void) +{ + switch (0) + { + case F_DUPFD: +#if F_DUPFD +#endif + + case F_DUPFD_CLOEXEC: +#if F_DUPFD_CLOEXEC +#endif + + case F_GETFD: +#if F_GETFD +#endif + +#ifdef F_SETFD + case F_SETFD: +# if F_SETFD +# endif +#endif + +#ifdef F_GETFL + case F_GETFL: +# if F_GETFL +# endif +#endif + +#ifdef F_SETFL + case F_SETFL: +# if F_SETFL +# endif +#endif + +#ifdef F_GETOWN + case F_GETOWN: +# if F_GETOWN +# endif +#endif + +#ifdef F_SETOWN + case F_SETOWN: +# if F_SETOWN +# endif +#endif + +#ifdef F_GETLK + case F_GETLK: +# if F_GETLK +# endif +#endif + +#ifdef F_SETLK + case F_SETLK: +# if F_SETLK +# endif +#endif + +#ifdef F_SETLKW + case F_SETLKW: +# if F_SETLKW +# endif +#endif + + ; + } +} + +int +main (void) +{ + const char *file = "test-fcntl.tmp"; + int fd; + int bad_fd = getdtablesize (); + + /* Sanity check that rpl_fcntl is likely to work. */ + ASSERT (func2 (1, 2) == 2); + ASSERT (func2 (2, -2) == -2); + ASSERT (func2 (3, 0x80000000) == 0x80000000); + { + struct dummy_struct s = { 0L, 4 }; + ASSERT (func2 (4, &s) == 4); + } + check_flags (); + + /* Assume std descriptors were provided by invoker, and ignore fds + that might have been inherited. */ + fd = creat (file, 0600); + ASSERT (STDERR_FILENO < fd); + close (fd + 1); + close (fd + 2); + + /* For F_DUPFD*, the source must be valid. */ + errno = 0; + ASSERT (fcntl (-1, F_DUPFD, 0) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (fd + 1, F_DUPFD, 0) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (bad_fd, F_DUPFD, 0) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (-1, F_DUPFD_CLOEXEC, 0) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (fd + 1, F_DUPFD_CLOEXEC, 0) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (bad_fd, F_DUPFD_CLOEXEC, 0) == -1); + ASSERT (errno == EBADF); + + /* For F_DUPFD*, the destination must be valid. */ + errno = 0; + ASSERT (fcntl (fd, F_DUPFD, -1) == -1); + ASSERT (errno == EINVAL); + errno = 0; + ASSERT (fcntl (fd, F_DUPFD, bad_fd) == -1); + ASSERT (errno == EINVAL); + errno = 0; + ASSERT (fcntl (fd, F_DUPFD_CLOEXEC, -1) == -1); + ASSERT (errno == EINVAL); + errno = 0; + ASSERT (fcntl (fd, F_DUPFD_CLOEXEC, bad_fd) == -1); + ASSERT (errno == EINVAL + || errno == EMFILE /* WSL */); + + /* For F_DUPFD*, check for correct inheritance, as well as + preservation of text vs. binary. */ + setmode (fd, O_BINARY); + ASSERT (is_open (fd)); + ASSERT (!is_open (fd + 1)); + ASSERT (!is_open (fd + 2)); + ASSERT (is_inheritable (fd)); + ASSERT (is_mode (fd, O_BINARY)); + + ASSERT (fcntl (fd, F_DUPFD, fd) == fd + 1); + ASSERT (is_open (fd)); + ASSERT (is_open (fd + 1)); + ASSERT (!is_open (fd + 2)); + ASSERT (is_inheritable (fd + 1)); + ASSERT (is_mode (fd, O_BINARY)); + ASSERT (is_mode (fd + 1, O_BINARY)); + ASSERT (close (fd + 1) == 0); + + ASSERT (fcntl (fd, F_DUPFD_CLOEXEC, fd + 2) == fd + 2); + ASSERT (is_open (fd)); + ASSERT (!is_open (fd + 1)); + ASSERT (is_open (fd + 2)); + ASSERT (is_inheritable (fd)); + ASSERT (!is_inheritable (fd + 2)); + ASSERT (is_mode (fd, O_BINARY)); + ASSERT (is_mode (fd + 2, O_BINARY)); + ASSERT (close (fd) == 0); + + setmode (fd + 2, O_TEXT); + ASSERT (fcntl (fd + 2, F_DUPFD, fd + 1) == fd + 1); + ASSERT (!is_open (fd)); + ASSERT (is_open (fd + 1)); + ASSERT (is_open (fd + 2)); + ASSERT (is_inheritable (fd + 1)); + ASSERT (!is_inheritable (fd + 2)); + ASSERT (is_mode (fd + 1, O_TEXT)); + ASSERT (is_mode (fd + 2, O_TEXT)); + ASSERT (close (fd + 1) == 0); + + ASSERT (fcntl (fd + 2, F_DUPFD_CLOEXEC, 0) == fd); + ASSERT (is_open (fd)); + ASSERT (!is_open (fd + 1)); + ASSERT (is_open (fd + 2)); + ASSERT (!is_inheritable (fd)); + ASSERT (!is_inheritable (fd + 2)); + ASSERT (is_mode (fd, O_TEXT)); + ASSERT (is_mode (fd + 2, O_TEXT)); + ASSERT (close (fd + 2) == 0); + + /* Test F_GETFD on invalid file descriptors. */ + errno = 0; + ASSERT (fcntl (-1, F_GETFD) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (fd + 1, F_GETFD) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (bad_fd, F_GETFD) == -1); + ASSERT (errno == EBADF); + + /* Test F_GETFD, the FD_CLOEXEC bit. */ + { + int result = fcntl (fd, F_GETFD); + ASSERT (0 <= result); + ASSERT ((result & FD_CLOEXEC) == FD_CLOEXEC); + ASSERT (dup (fd) == fd + 1); + result = fcntl (fd + 1, F_GETFD); + ASSERT (0 <= result); + ASSERT ((result & FD_CLOEXEC) == 0); + ASSERT (close (fd + 1) == 0); + } + +#ifdef F_SETFD + /* Test F_SETFD on invalid file descriptors. */ + errno = 0; + ASSERT (fcntl (-1, F_SETFD, 0) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (fd + 1, F_SETFD, 0) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (bad_fd, F_SETFD, 0) == -1); + ASSERT (errno == EBADF); +#endif + +#ifdef F_GETFL + /* Test F_GETFL on invalid file descriptors. */ + errno = 0; + ASSERT (fcntl (-1, F_GETFL) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (fd + 1, F_GETFL) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (bad_fd, F_GETFL) == -1); + ASSERT (errno == EBADF); +#endif + +#ifdef F_SETFL + /* Test F_SETFL on invalid file descriptors. */ + errno = 0; + ASSERT (fcntl (-1, F_SETFL, 0) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (fd + 1, F_SETFL, 0) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (bad_fd, F_SETFL, 0) == -1); + ASSERT (errno == EBADF); +#endif + +#ifdef F_GETOWN + /* Test F_GETOWN on invalid file descriptors. */ + errno = 0; + ASSERT (fcntl (-1, F_GETOWN) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (fd + 1, F_GETOWN) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (bad_fd, F_GETOWN) == -1); + ASSERT (errno == EBADF); +#endif + +#ifdef F_SETOWN + /* Test F_SETFL on invalid file descriptors. */ + errno = 0; + ASSERT (fcntl (-1, F_SETOWN, 0) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (fd + 1, F_SETOWN, 0) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (bad_fd, F_SETOWN, 0) == -1); + ASSERT (errno == EBADF); +#endif + + /* Cleanup. */ + ASSERT (close (fd) == 0); + ASSERT (unlink (file) == 0); + + return 0; +} diff --git a/gnulib-tests/test-fdatasync.c b/gnulib-tests/test-fdatasync.c new file mode 100644 index 0000000..403cc97 --- /dev/null +++ b/gnulib-tests/test-fdatasync.c @@ -0,0 +1,81 @@ +/* Test of fdatasync() function. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (fdatasync, int, (int)); + +#include <errno.h> +#include <fcntl.h> + +#include "macros.h" + +int +main (void) +{ + int fd; + const char *file = "test-fdatasync.txt"; + + /* Assuming stdin and stdout are ttys, fdatasync is allowed to fail, but + may succeed as an extension. */ + for (fd = 0; fd < 2; fd++) + if (fdatasync (fd) != 0) + { + ASSERT (errno == EINVAL /* POSIX */ + || errno == ENOTSUP /* seen on Mac OS X 10.5 */ + || errno == EBADF /* seen on AIX 7.1 */ + || errno == EIO /* seen on mingw */ + ); + } + + /* fdatasync must fail on invalid fd. */ + { + errno = 0; + ASSERT (fdatasync (-1) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (fdatasync (99) == -1); + ASSERT (errno == EBADF); + } + + fd = open (file, O_WRONLY|O_CREAT|O_TRUNC, 0644); + ASSERT (0 <= fd); + ASSERT (write (fd, "hello", 5) == 5); + ASSERT (fdatasync (fd) == 0); + ASSERT (close (fd) == 0); + +#if 0 + /* POSIX is self-contradictory on whether fdatasync must fail on + read-only file descriptors. Glibc allows it, as does our + implementation if fsync allows it. */ + fd = open (file, O_RDONLY); + ASSERT (0 <= fd); + errno = 0; + ASSERT (fdatasync (fd) == -1); + ASSERT (errno == EBADF); + ASSERT (close (fd) == 0); +#endif + + ASSERT (unlink (file) == 0); + + return 0; +} diff --git a/gnulib-tests/test-fdopen.c b/gnulib-tests/test-fdopen.c new file mode 100644 index 0000000..e10a858 --- /dev/null +++ b/gnulib-tests/test-fdopen.c @@ -0,0 +1,49 @@ +/* Test opening a stream with a file descriptor. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (fdopen, FILE *, (int, const char *)); + +#include <errno.h> +#include <unistd.h> + +#include "macros.h" + +int +main (void) +{ + /* Test behavior on failure. POSIX makes it hard to check for + failure, since the behavior is not well-defined on invalid file + descriptors, so try fdopen 1000 times and if that's not enough to + fail due to EMFILE, so be it. */ + + int i; + for (i = 0; i < 1000; i++) + { + errno = 0; + if (! fdopen (STDOUT_FILENO, "w")) + { + ASSERT (errno != 0); + break; + } + } + + return 0; +} diff --git a/gnulib-tests/test-fdopendir.c b/gnulib-tests/test-fdopendir.c new file mode 100644 index 0000000..eda9153 --- /dev/null +++ b/gnulib-tests/test-fdopendir.c @@ -0,0 +1,80 @@ +/* Test opening a directory stream from a file descriptor. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <dirent.h> + +#include "signature.h" +SIGNATURE_CHECK (fdopendir, DIR *, (int)); + +#include <errno.h> +#include <fcntl.h> +#include <unistd.h> + +#include "macros.h" + +int +main (int argc _GL_UNUSED, char *argv[]) +{ + DIR *d; + int fd; + + /* A non-directory cannot be turned into a directory stream. */ + fd = open ("test-fdopendir.tmp", O_RDONLY | O_CREAT, 0600); + ASSERT (0 <= fd); + errno = 0; + ASSERT (fdopendir (fd) == NULL); + ASSERT (errno == ENOTDIR); + ASSERT (close (fd) == 0); + ASSERT (unlink ("test-fdopendir.tmp") == 0); + + /* A bad fd cannot be turned into a stream. */ + { + errno = 0; + ASSERT (fdopendir (-1) == NULL); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (fdopendir (99) == NULL); + ASSERT (errno == EBADF); + } + + /* This should work. */ + fd = open (".", O_RDONLY); + ASSERT (0 <= fd); + d = fdopendir (fd); + ASSERT (d); + /* fdopendir should not close fd. */ + ASSERT (dup2 (fd, fd) == fd); + + /* Don't test dirfd here. dirfd (d) must return fd on current POSIX + platforms, but on pre-2008 platforms or on non-POSIX platforms + dirfd (fd) might return some other descriptor, or -1, and gnulib + does not work around this porting problem. */ + + ASSERT (closedir (d) == 0); + /* Now we can guarantee that fd must be closed. */ + errno = 0; + ASSERT (dup2 (fd, fd) == -1); + ASSERT (errno == EBADF); + + return 0; +} diff --git a/gnulib-tests/test-fdutimensat.c b/gnulib-tests/test-fdutimensat.c new file mode 100644 index 0000000..a4a0a16 --- /dev/null +++ b/gnulib-tests/test-fdutimensat.c @@ -0,0 +1,151 @@ +/* Tests of fdutimensat. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include "utimens.h" + +#include <fcntl.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> + +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-fdutimensat.t" + +#include "test-futimens.h" +#include "test-lutimens.h" +#include "test-utimens.h" + +static int dfd = AT_FDCWD; + +/* Wrap fdutimensat to behave like futimens. */ +static int +do_futimens (int fd, struct timespec const times[2]) +{ + return fdutimensat (fd, dfd, NULL, times, 0); +} + +/* Test the use of file descriptors alongside a name. */ +static int +do_fdutimens (char const *name, struct timespec const times[2]) +{ + int result; + int nofollow_result; + int nofollow_errno; + int fd = openat (dfd, name, O_WRONLY); + if (fd < 0) + fd = openat (dfd, name, O_RDONLY); + errno = 0; + nofollow_result = fdutimensat (fd, dfd, name, times, AT_SYMLINK_NOFOLLOW); + nofollow_errno = errno; + result = fdutimensat (fd, dfd, name, times, 0); + ASSERT (result == nofollow_result + || (nofollow_result == -1 && nofollow_errno == ENOSYS)); + if (0 <= fd) + { + int saved_errno = errno; + close (fd); + errno = saved_errno; + } + return result; +} + +/* Wrap lutimensat to behave like lutimens. */ +static int +do_lutimens (const char *name, struct timespec const times[2]) +{ + return lutimensat (dfd, name, times); +} + +/* Wrap fdutimensat to behave like lutimens. */ +static int +do_lutimens1 (const char *name, struct timespec const times[2]) +{ + return fdutimensat (-1, dfd, name, times, AT_SYMLINK_NOFOLLOW); +} + +/* Wrap fdutimensat to behave like utimens. */ +static int +do_utimens (const char *name, struct timespec const times[2]) +{ + return fdutimensat (-1, dfd, name, times, 0); +} + +int +main (void) +{ + int result1; /* Skip because of no symlink support. */ + int result2; /* Skip because of no futimens support. */ + int result3; /* Skip because of no lutimens support. */ + int fd; + + /* Clean up any trash from prior testsuite runs. */ + ignore_value (system ("rm -rf " BASE "*")); + + /* Basic tests. */ + result1 = test_utimens (do_utimens, true); + ASSERT (test_utimens (do_fdutimens, false) == result1); + result2 = test_futimens (do_futimens, result1 == 0); + result3 = test_lutimens (do_lutimens, (result1 + result2) == 0); + /* We expect 0/0, 0/77, or 77/77, but not 77/0. */ + ASSERT (result1 <= result3); + ASSERT (test_lutimens (do_lutimens1, (result1 + result2) == 0) == result3); + dfd = open (".", O_RDONLY); + ASSERT (0 <= dfd); + ASSERT (test_utimens (do_utimens, false) == result1); + ASSERT (test_utimens (do_fdutimens, false) == result1); + ASSERT (test_futimens (do_futimens, false) == result2); + ASSERT (test_lutimens (do_lutimens, false) == result3); + ASSERT (test_lutimens (do_lutimens1, false) == result3); + + /* Directory relative tests. */ + ASSERT (mkdir (BASE "dir", 0700) == 0); + ASSERT (chdir (BASE "dir") == 0); + fd = creat ("file", 0600); + ASSERT (0 <= fd); + errno = 0; + ASSERT (fdutimensat (AT_FDCWD, fd, ".", NULL, 0) == -1); + ASSERT (errno == ENOTDIR); + { + struct timespec ts[2]; + struct stat st; + ts[0].tv_sec = Y2K; + ts[0].tv_nsec = 0; + ts[1] = ts[0]; + ASSERT (fdutimensat (fd, dfd, BASE "dir/file", ts, 0) == 0); + ASSERT (stat ("file", &st) == 0); + ASSERT (st.st_atime == Y2K); + ASSERT (get_stat_atime_ns (&st) == 0); + ASSERT (st.st_mtime == Y2K); + ASSERT (get_stat_mtime_ns (&st) == 0); + } + ASSERT (close (fd) == 0); + ASSERT (close (dfd) == 0); + errno = 0; + ASSERT (fdutimensat (-1, dfd, ".", NULL, 0) == -1); + ASSERT (errno == EBADF); + + /* Cleanup. */ + ASSERT (chdir ("..") == 0); + ASSERT (unlink (BASE "dir/file") == 0); + ASSERT (rmdir (BASE "dir") == 0); + return result1 | result2 | result3; +} diff --git a/gnulib-tests/test-fflush.c b/gnulib-tests/test-fflush.c new file mode 100644 index 0000000..cf61905 --- /dev/null +++ b/gnulib-tests/test-fflush.c @@ -0,0 +1,191 @@ +/* Test of POSIX compatible fflush() function. + Copyright (C) 2007, 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake, 2007. */ + +#include <config.h> + +/* None of the files accessed by this test are large, so disable the + ftell link warning if we are not using the gnulib ftell module. */ +#define _GL_NO_LARGE_FILES +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (fflush, int, (FILE *)); + +#include <errno.h> +#include <unistd.h> + +#include "macros.h" + +int +main (void) +{ + FILE *f; + char buffer[10]; + int fd; + + /* Create test file. */ + f = fopen ("test-fflush.txt", "w"); + if (!f || fwrite ("1234567890ABCDEFG", 1, 17, f) != 17 || fclose (f) != 0) + { + fputs ("Failed to create sample file.\n", stderr); + unlink ("test-fflush.txt"); + return 1; + } + + /* Test fflush. */ + f = fopen ("test-fflush.txt", "r"); + ASSERT (f != NULL); + fd = fileno (f); + if (!f || 0 > fd || fread (buffer, 1, 5, f) != 5) + { + fputs ("Failed initial read of sample file.\n", stderr); + if (f) + fclose (f); + unlink ("test-fflush.txt"); + return 1; + } + /* For deterministic results, ensure f read a bigger buffer. + This is not the case on BeOS, nor on uClibc. */ +#if !(defined __BEOS__ || defined __UCLIBC__) + if (lseek (fd, 0, SEEK_CUR) == 5) + { + fputs ("Sample file was not buffered after fread.\n", stderr); + fclose (f); + unlink ("test-fflush.txt"); + return 1; + } +#endif + /* POSIX requires fflush-fseek to set file offset of fd. */ + if (fflush (f) != 0 || fseeko (f, 0, SEEK_CUR) != 0) + { + fputs ("Failed to flush-fseek sample file.\n", stderr); + fclose (f); + unlink ("test-fflush.txt"); + return 1; + } + /* Check that offset is correct. */ + if (lseek (fd, 0, SEEK_CUR) != 5) + { + fprintf (stderr, "File offset is wrong after fseek: %ld.\n", + (long) lseek (fd, 0, SEEK_CUR)); + fclose (f); + unlink ("test-fflush.txt"); + return 1; + } + if (ftell (f) != 5) + { + fprintf (stderr, "ftell result is wrong after fseek: %ld.\n", + (long) ftell (f)); + fclose (f); + unlink ("test-fflush.txt"); + return 1; + } + /* Check that file reading resumes at correct location. */ + if (fgetc (f) != '6') + { + fputs ("Failed to read next byte after fseek.\n", stderr); + fclose (f); + unlink ("test-fflush.txt"); + return 1; + } + /* For deterministic results, ensure f read a bigger buffer. */ + if (lseek (fd, 0, SEEK_CUR) == 6) + { + fputs ("Sample file was not buffered after fgetc.\n", stderr); + fclose (f); + unlink ("test-fflush.txt"); + return 1; + } + /* POSIX requires fflush-fseeko to set file offset of fd. */ + if (fflush (f) != 0 || fseeko (f, 0, SEEK_CUR) != 0) + { + fputs ("Failed to flush-fseeko sample file.\n", stderr); + fclose (f); + unlink ("test-fflush.txt"); + return 1; + } + /* Check that offset is correct. */ + if (lseek (fd, 0, SEEK_CUR) != 6) + { + fprintf (stderr, "File offset is wrong after fseeko: %ld.\n", + (long) lseek (fd, 0, SEEK_CUR)); + fclose (f); + unlink ("test-fflush.txt"); + return 1; + } + if (ftell (f) != 6) + { + fprintf (stderr, "ftell result is wrong after fseeko: %ld.\n", + (long) ftell (f)); + fclose (f); + unlink ("test-fflush.txt"); + return 1; + } + /* Check that file reading resumes at correct location. */ + if (fgetc (f) != '7') + { + fputs ("Failed to read next byte after fseeko.\n", stderr); + fclose (f); + unlink ("test-fflush.txt"); + return 1; + } + fclose (f); + + /* Test that fflush() sets errno if someone else closes the stream + fd behind the back of stdio. */ + { + FILE *fp = fopen ("test-fflush.txt", "w"); + ASSERT (fp != NULL); + fputc ('x', fp); + ASSERT (close (fileno (fp)) == 0); + errno = 0; + ASSERT (fflush (fp) == EOF); + ASSERT (errno == EBADF); + fclose (fp); + } + + /* Test that fflush() sets errno if the stream was constructed with + an invalid file descriptor. */ + { + FILE *fp = fdopen (-1, "w"); + if (fp != NULL) + { + fputc ('x', fp); + errno = 0; + ASSERT (fflush (fp) == EOF); + ASSERT (errno == EBADF); + } + } + { + FILE *fp; + close (99); + fp = fdopen (99, "w"); + if (fp != NULL) + { + fputc ('x', fp); + errno = 0; + ASSERT (fflush (fp) == EOF); + ASSERT (errno == EBADF); + } + } + + /* Clean up. */ + unlink ("test-fflush.txt"); + + return 0; +} diff --git a/gnulib-tests/test-fflush2.c b/gnulib-tests/test-fflush2.c new file mode 100644 index 0000000..acca0ae --- /dev/null +++ b/gnulib-tests/test-fflush2.c @@ -0,0 +1,102 @@ +/* Test of POSIX compatible fflush() function. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdio.h> + +#include "binary-io.h" +#include "macros.h" + +int +main (int argc, char **argv) +{ + int c; + + /* Avoid the well-known bugs of fflush() on streams in O_TEXT mode + on native Windows platforms. */ + set_binary_mode (0, O_BINARY); + + if (argc > 1) + switch (argv[1][0]) + { + case '1': + /* Check fflush after a backup ungetc() call. This is case 1a in + terms of + <https://lists.gnu.org/r/bug-gnulib/2008-03/msg00131.html>, + according to the Austin Group's resolution on 2009-01-08. */ + + c = fgetc (stdin); + ASSERT (c == '#'); + + c = fgetc (stdin); + ASSERT (c == '!'); + + /* Here the file-position indicator must be 2. */ + + c = ungetc ('!', stdin); + ASSERT (c == '!'); + + fflush (stdin); + + /* Here the file-position indicator must be 1. */ + + c = fgetc (stdin); + ASSERT (c == '!'); + + c = fgetc (stdin); + ASSERT (c == '/'); + + return 0; + + case '2': + /* Check fflush after a non-backup ungetc() call. This is case 2a in + terms of + <https://lists.gnu.org/r/bug-gnulib/2008-03/msg00131.html>, + according to the Austin Group's resolution on 2009-01-08. */ + /* Check that fflush after a non-backup ungetc() call discards the + ungetc buffer. This is mandated by POSIX + <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fflush.html>: + "...any characters pushed back onto the stream by ungetc() + or ungetwc() that have not subsequently been read from the + stream shall be discarded..." */ + + c = fgetc (stdin); + ASSERT (c == '#'); + + c = fgetc (stdin); + ASSERT (c == '!'); + + /* Here the file-position indicator must be 2. */ + + c = ungetc ('@', stdin); + ASSERT (c == '@'); + + fflush (stdin); + + /* Here the file-position indicator must be 1. */ + + c = fgetc (stdin); + ASSERT (c == '!'); + + c = fgetc (stdin); + ASSERT (c == '/'); + + return 0; + } + + return 1; +} diff --git a/gnulib-tests/test-fflush2.sh b/gnulib-tests/test-fflush2.sh new file mode 100755 index 0000000..0d8859d --- /dev/null +++ b/gnulib-tests/test-fflush2.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# Execute the test only with seekable input stream. +# The behaviour of fflush() on a non-seekable input stream is undefined. +${CHECKER} ./test-fflush2${EXEEXT} 1 < "$srcdir/test-fflush2.sh" || exit $? +${CHECKER} ./test-fflush2${EXEEXT} 2 < "$srcdir/test-fflush2.sh" || exit $? +#cat "$srcdir/test-fflush2.sh" | ${CHECKER} ./test-fflush2${EXEEXT} || exit $? + +exit 0 diff --git a/gnulib-tests/test-fgetc.c b/gnulib-tests/test-fgetc.c new file mode 100644 index 0000000..42db301 --- /dev/null +++ b/gnulib-tests/test-fgetc.c @@ -0,0 +1,99 @@ +/* Test of fgetc() function. + Copyright (C) 2011-2020 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, 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (fgetc, int, (FILE *)); + +#include <errno.h> +#include <fcntl.h> +#include <unistd.h> + +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER +# include "msvc-inval.h" +#endif + +#include "macros.h" + +int +main (int argc, char **argv) +{ + const char *filename = "test-fgetc.txt"; + + /* We don't have an fgetc() function that installs an invalid parameter + handler so far. So install that handler here, explicitly. */ +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER \ + && MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING + gl_msvc_inval_ensure_handler (); +#endif + + /* Prepare a file. */ + { + const char text[] = "hello world"; + int fd = open (filename, O_RDWR | O_CREAT | O_TRUNC, 0600); + ASSERT (fd >= 0); + ASSERT (write (fd, text, sizeof (text)) == sizeof (text)); + ASSERT (close (fd) == 0); + } + + /* Test that fgetc() sets errno if someone else closes the stream + fd behind the back of stdio. */ + { + FILE *fp = fopen (filename, "r"); + ASSERT (fp != NULL); + ASSERT (close (fileno (fp)) == 0); + errno = 0; + ASSERT (fgetc (fp) == EOF); + ASSERT (errno == EBADF); + ASSERT (ferror (fp)); + fclose (fp); + } + + /* Test that fgetc() sets errno if the stream was constructed with + an invalid file descriptor. */ + { + FILE *fp = fdopen (-1, "r"); + if (fp != NULL) + { + errno = 0; + ASSERT (fgetc (fp) == EOF); + ASSERT (errno == EBADF); + ASSERT (ferror (fp)); + fclose (fp); + } + } + { + FILE *fp; + close (99); + fp = fdopen (99, "r"); + if (fp != NULL) + { + errno = 0; + ASSERT (fgetc (fp) == EOF); + ASSERT (errno == EBADF); + ASSERT (ferror (fp)); + fclose (fp); + } + } + + /* Clean up. */ + unlink (filename); + + return 0; +} diff --git a/gnulib-tests/test-file-has-acl-1.sh b/gnulib-tests/test-file-has-acl-1.sh new file mode 100755 index 0000000..c789d22 --- /dev/null +++ b/gnulib-tests/test-file-has-acl-1.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +# Test file-has-acl on the file system of /var/tmp, which usually is a local +# file system. + +. "${srcdir=.}/init.sh"; path_prepend_ . + +if test -d /var/tmp; then + TMPDIR=/var/tmp +else + TMPDIR=/tmp +fi +test -d $TMPDIR || Exit 77 +export TMPDIR + +$BOURNE_SHELL "${srcdir}/test-file-has-acl.sh" + +Exit $? diff --git a/gnulib-tests/test-file-has-acl-2.sh b/gnulib-tests/test-file-has-acl-2.sh new file mode 100755 index 0000000..41561d6 --- /dev/null +++ b/gnulib-tests/test-file-has-acl-2.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# Test file-has-acl on the file system of the build directory, which may be +# a local file system or NFS mounted. + +. "${srcdir=.}/init.sh"; path_prepend_ . + +TMPDIR=`pwd` +export TMPDIR + +$BOURNE_SHELL "${srcdir}/test-file-has-acl.sh" + +Exit $? diff --git a/gnulib-tests/test-file-has-acl.c b/gnulib-tests/test-file-has-acl.c new file mode 100644 index 0000000..35f8658 --- /dev/null +++ b/gnulib-tests/test-file-has-acl.c @@ -0,0 +1,74 @@ +/* Test for presence of ACL. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2008. */ + +#include <config.h> + +#include "acl.h" + +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + const char *file; + struct stat statbuf; + + ASSERT (argc == 2); + + file = argv[1]; + + if (stat (file, &statbuf) < 0) + { + fprintf (stderr, "could not access file \"%s\"\n", file); + exit (EXIT_FAILURE); + } + + /* Check against possible infinite loop in file_has_acl. */ +#if HAVE_DECL_ALARM + /* Declare failure if test takes too long, by using default abort + caused by SIGALRM. */ + { + int alarm_value = 5; + signal (SIGALRM, SIG_DFL); + alarm (alarm_value); + } +#endif + +#if USE_ACL + { + int ret = file_has_acl (file, &statbuf); + if (ret < 0) + { + fprintf (stderr, "could not access the ACL of file \"%s\"\n", file); + exit (EXIT_FAILURE); + } + printf ("%s\n", ret ? "yes" : "no"); + } +#else + printf ("no\n"); +#endif + + return 0; +} diff --git a/gnulib-tests/test-file-has-acl.sh b/gnulib-tests/test-file-has-acl.sh new file mode 100755 index 0000000..09d18da --- /dev/null +++ b/gnulib-tests/test-file-has-acl.sh @@ -0,0 +1,389 @@ +#!/bin/sh + +# Show all commands when run with environment variable VERBOSE=yes. +test -z "$VERBOSE" || set -x + +test "$USE_ACL" = 0 && + { + echo "Skipping test: insufficient ACL support" + exit 77 + } + +# func_tmpdir +# creates a temporary directory. +# Sets variable +# - tmp pathname of freshly created temporary directory +func_tmpdir () +{ + # Use the environment variable TMPDIR, falling back to /tmp. This allows + # users to specify a different temporary directory, for example, if their + # /tmp is filled up or too small. + : ${TMPDIR=/tmp} + { + # Use the mktemp program if available. If not available, hide the error + # message. + tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" + } || + { + # Use a simple mkdir command. It is guaranteed to fail if the directory + # already exists. $RANDOM is bash specific and expands to empty in shells + # other than bash, ksh and zsh. Its use does not increase security; + # rather, it minimizes the probability of failure in a very cluttered /tmp + # directory. + tmp=$TMPDIR/gl$$-$RANDOM + (umask 077 && mkdir "$tmp") + } || + { + echo "$0: cannot create a temporary directory in $TMPDIR" >&2 + exit 1 + } +} + +func_tmpdir +# builddir may already be set by the script that invokes this one. +case "$builddir" in + '') builddir=`pwd` ;; + /* | ?:*) ;; + *) builddir=`pwd`/$builddir ;; +esac +cd "$builddir" || + { + echo "$0: cannot determine build directory (unreadable parent dir?)" >&2 + exit 1 + } +# Switch to a temporary directory, to increase the likelihood that ACLs are +# supported on the current file system. (/tmp is usually locally mounted, +# whereas the build dir is sometimes NFS-mounted.) +( cd "$tmp" + + # Prepare tmpfile0. + rm -f tmpfile[0-9] tmp.err + echo "Simple contents" > tmpfile0 + chmod 600 tmpfile0 + + # Classification of the platform according to the programs available for + # manipulating ACLs. + # Possible values are: + # linux, cygwin, freebsd, solaris, hpux, hpuxjfs, osf1, aix, macosx, irix, none. + # TODO: Support also native Windows platforms (mingw). + acl_flavor=none + if (getfacl tmpfile0 >/dev/null) 2>/dev/null; then + # Platforms with the getfacl and setfacl programs. + # Linux, FreeBSD, Solaris, Cygwin. + if (setfacl --help >/dev/null) 2>/dev/null; then + # Linux, Cygwin. + if (LC_ALL=C setfacl --help | grep ' --set-file' >/dev/null) 2>/dev/null; then + # Linux. + acl_flavor=linux + else + acl_flavor=cygwin + fi + else + # FreeBSD, Solaris. + if (LC_ALL=C setfacl 2>&1 | grep '\-x entries' >/dev/null) 2>/dev/null; then + # FreeBSD. + acl_flavor=freebsd + else + # Solaris. + acl_flavor=solaris + fi + fi + else + if (lsacl / >/dev/null) 2>/dev/null; then + # Platforms with the lsacl and chacl programs. + # HP-UX, sometimes also IRIX. + if (getacl tmpfile0 >/dev/null) 2>/dev/null; then + # HP-UX 11.11 or newer. + acl_flavor=hpuxjfs + else + # HP-UX 11.00. + acl_flavor=hpux + fi + else + if (getacl tmpfile0 >/dev/null) 2>/dev/null; then + # Tru64, NonStop Kernel. + if (getacl -m tmpfile0 >/dev/null) 2>/dev/null; then + # Tru64. + acl_flavor=osf1 + else + # NonStop Kernel. + acl_flavor=nsk + fi + else + if (aclget tmpfile0 >/dev/null) 2>/dev/null; then + # AIX. + acl_flavor=aix + else + if (fsaclctl -v >/dev/null) 2>/dev/null; then + # Mac OS X. + acl_flavor=macosx + else + if test -f /sbin/chacl; then + # IRIX. + acl_flavor=irix + fi + fi + fi + fi + fi + fi + + # func_test_file_has_acl file expected + # tests the result of the file_has_acl function on file, and checks that it + # matches the expected value. + func_test_file_has_acl () + { + res=`${CHECKER} "$builddir"/test-file-has-acl${EXEEXT} "$1"` + test "$res" = "$2" || { + echo "file_has_acl(\"$1\") returned $res, expected $2" 1>&2 + exit 1 + } + } + + # func_test_has_acl file expected + # tests the result of the file_has_acl function on file, and checks that it + # matches the expected value, also taking into account the system's 'ls' + # program. + case $acl_flavor in + freebsd | solaris | hpux | macosx) + case $acl_flavor in + freebsd | solaris | hpux) acl_ls_option="-ld" ;; + macosx) acl_ls_option="-lde" ;; + esac + func_test_has_acl () + { + func_test_file_has_acl "$1" "$2" + case `/bin/ls $acl_ls_option "$1" | sed 1q` in + ??????????+*) + test "$2" = yes || { + echo "/bin/ls $acl_ls_option $1 shows an ACL, but expected $2" 1>&2 + exit 1 + } + ;; + ??????????" "*) + test "$2" = no || { + echo "/bin/ls $acl_ls_option $1 shows no ACL, but expected $2" 1>&2 + exit 1 + } + ;; + esac + } + ;; + irix) + func_test_has_acl () + { + func_test_file_has_acl "$1" "$2" + case `/bin/ls -ldD "$1" | sed 1q` in + *" []") + test "$2" = no || { + echo "/bin/ls -ldD $1 shows no ACL, but expected $2" 1>&2 + exit 1 + } + ;; + *) + test "$2" = yes || { + echo "/bin/ls -ldD $1 shows an ACL, but expected $2" 1>&2 + exit 1 + } + ;; + esac + } + ;; + *) + func_test_has_acl () + { + func_test_file_has_acl "$1" "$2" + } + ;; + esac + + func_test_has_acl tmpfile0 no + + mkdir tmpdir0 + func_test_has_acl tmpdir0 no + + if test $acl_flavor != none; then + # A POSIX compliant 'id' program. + if test -f /usr/xpg4/bin/id; then + ID=/usr/xpg4/bin/id + else + ID=id + fi + # Use a user and group id different from the current one, to avoid + # redundant/ambiguous ACLs. + myuid=`$ID -u` + mygid=`$ID -g` + auid=1 + if test "$auid" = "$myuid"; then auid=2; fi + agid=1 + if test "$agid" = "$mygid"; then agid=2; fi + + case $acl_flavor in + linux | freebsd | solaris) + + # Set an ACL for a user. + if setfacl -m user:$auid:1 tmpfile0; then + + func_test_has_acl tmpfile0 yes + + # Remove the ACL for the user. + case $acl_flavor in + linux) setfacl -x user:$auid tmpfile0 ;; + freebsd) setfacl -x user:$auid:1 tmpfile0 ;; + *) setfacl -d user:$auid:1 tmpfile0 ;; + esac + + # On Linux and FreeBSD, the ACL for the mask is implicitly added. + # On Solaris, it is always there. + case $acl_flavor in + linux | freebsd) func_test_has_acl tmpfile0 yes ;; + *) func_test_has_acl tmpfile0 no ;; + esac + + # Remove the ACL for the mask, if it was implicitly added. + case $acl_flavor in + linux | freebsd) setfacl -x mask: tmpfile0 ;; + *) setfacl -d mask: tmpfile0 ;; + esac + + func_test_has_acl tmpfile0 no + + fi + ;; + + cygwin) + + # Set an ACL for a group. + if setfacl -m group:0:1 tmpfile0; then + + func_test_has_acl tmpfile0 yes + + # Remove the ACL for the group. + setfacl -d group:0 tmpfile0 + + func_test_has_acl tmpfile0 no + + fi + ;; + + hpux | hpuxjfs) + + # Set an ACL for a user. + orig=`lsacl tmpfile0 | sed -e 's/ tmpfile0$//'` + if chacl -r "${orig}($auid.%,--x)" tmpfile0; then + + func_test_has_acl tmpfile0 yes + + # Remove the ACL for the user. + chacl -d "($auid.%,--x)" tmpfile0 + + func_test_has_acl tmpfile0 no + + else + if test $acl_flavor = hpuxjfs; then + + # Set an ACL for a user. + setacl -m user:$auid:1 tmpfile0 + + func_test_has_acl tmpfile0 yes + + # Remove the ACL for the user. + setacl -d user:$auid tmpfile0 + + func_test_has_acl tmpfile0 no + + fi + fi + ;; + + osf1) + + # Set an ACL for a user. + setacl -u user:$auid:1 tmpfile0 2> tmp.err + cat tmp.err 1>&2 + if grep 'Error:' tmp.err > /dev/null \ + || grep 'Operation not supported' tmp.err > /dev/null; then + : + else + + func_test_has_acl tmpfile0 yes + + # Remove the ACL for the user. + setacl -x user:$auid:1 tmpfile0 + + func_test_has_acl tmpfile0 no + + fi + ;; + + nsk) + + # Set an ACL for a user. + setacl -m user:$auid:1 tmpfile0 + + func_test_has_acl tmpfile0 yes + + # Remove the ACL for the user. + setacl -d user:$auid tmpfile0 + + func_test_has_acl tmpfile0 no + + ;; + + aix) + + # Set an ACL for a user. + { aclget tmpfile0 | sed -e 's/disabled$/enabled/'; echo " permit --x u:$auid"; } | aclput tmpfile0 + if aclget tmpfile0 | grep enabled > /dev/null; then + + func_test_has_acl tmpfile0 yes + + # Remove the ACL for the user. + aclget tmpfile0 | grep -v ' u:[^ ]*$' | aclput tmpfile0 + + func_test_has_acl tmpfile0 no + + fi + ;; + + macosx) + + # Set an ACL for a user. + /bin/chmod +a "user:daemon allow execute" tmpfile0 + + func_test_has_acl tmpfile0 yes + + # Remove the ACL for the user. + /bin/chmod -a "user:daemon allow execute" tmpfile0 + + func_test_has_acl tmpfile0 no + + ;; + + irix) + + # Set an ACL for a user. + /sbin/chacl user::rw-,group::---,other::---,user:$auid:--x tmpfile0 2> tmp.err + cat tmp.err 1>&2 + if test -s tmp.err; then :; else + + func_test_has_acl tmpfile0 yes + + # Remove the ACL for the user. + /sbin/chacl user::rw-,group::---,other::--- tmpfile0 + + func_test_has_acl tmpfile0 no + + fi + ;; + + esac + fi + + rm -f tmpfile[0-9] tmp.err + rm -rf tmpdir0 +) || exit 1 + +rm -rf "$tmp" +exit 0 diff --git a/gnulib-tests/test-filenamecat.c b/gnulib-tests/test-filenamecat.c new file mode 100644 index 0000000..a6f236e --- /dev/null +++ b/gnulib-tests/test-filenamecat.c @@ -0,0 +1,85 @@ +/* Test of concatenation of two arbitrary file names. + + Copyright (C) 1996-2007, 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Jim Meyering. */ + +#include <config.h> + +#include "filenamecat.h" + +#include <stdbool.h> +#include <stddef.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + + +int +main (int argc _GL_UNUSED, char *argv[]) +{ + static char const *const tests[][3] = + { + {"a", "b", "a/b"}, + {"a/", "b", "a/b"}, + {"a/", "/b", "a/b"}, + {"a", "/b", "a/b"}, + + {"/", "b", "/b"}, + {"/", "/b", "/./b"}, /* This result could be shorter. */ + {"/", "/", "/./"}, /* This result could be shorter. */ + {"a", "/", "a/"}, /* this might deserve a diagnostic */ + {"/a", "/", "/a/"}, /* this might deserve a diagnostic */ + {"a", "//b", "a//b"}, + {"", "a", "a"}, /* this might deserve a diagnostic */ + }; + unsigned int i; + bool fail = false; + + for (i = 0; i < sizeof tests / sizeof tests[0]; i++) + { + char *base_in_result; + char const *const *t = tests[i]; + char *res = file_name_concat (t[0], t[1], &base_in_result); + ptrdiff_t prefixlen = base_in_result - res; + size_t t0len = strlen (t[0]); + size_t reslen = strlen (res); + if (strcmp (res, t[2]) != 0) + { + fprintf (stderr, "test #%u: got %s, expected %s\n", i, res, t[2]); + fail = true; + } + if (strcmp (t[1], base_in_result) != 0) + { + fprintf (stderr, "test #%u: base %s != base_in_result %s\n", + i, t[1], base_in_result); + fail = true; + } + if (! (0 <= prefixlen && prefixlen <= reslen)) + { + fprintf (stderr, "test #%u: base_in_result is not in result\n", i); + fail = true; + } + if (reslen < t0len || memcmp (res, t[0], t0len) != 0) + { + fprintf (stderr, "test #%u: %s is not a prefix of %s\n", + i, t[0], res); + fail = true; + } + free (res); + } + exit (fail ? EXIT_FAILURE : EXIT_SUCCESS); +} diff --git a/gnulib-tests/test-filevercmp.c b/gnulib-tests/test-filevercmp.c new file mode 100644 index 0000000..8da27a2 --- /dev/null +++ b/gnulib-tests/test-filevercmp.c @@ -0,0 +1,120 @@ +/* Test of filevercmp() function. + Copyright (C) 2008-2020 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, 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include "filevercmp.h" + +#include <stddef.h> + +#include "macros.h" + +/* set of well sorted examples */ +static const char *const examples[] = +{ + "", + ".", + "..", + ".0", + ".9", + ".A", + ".Z", + ".a~", + ".a", + ".b~", + ".b", + ".z", + ".zz~", + ".zz", + ".zz.~1~", + ".zz.0", + "0", + "9", + "A", + "Z", + "a~", + "a", + "a.b~", + "a.b", + "a.bc~", + "a.bc", + "b~", + "b", + "gcc-c++-10.fc9.tar.gz", + "gcc-c++-10.fc9.tar.gz.~1~", + "gcc-c++-10.fc9.tar.gz.~2~", + "gcc-c++-10.8.12-0.7rc2.fc9.tar.bz2", + "gcc-c++-10.8.12-0.7rc2.fc9.tar.bz2.~1~", + "glibc-2-0.1.beta1.fc10.rpm", + "glibc-common-5-0.2.beta2.fc9.ebuild", + "glibc-common-5-0.2b.deb", + "glibc-common-11b.ebuild", + "glibc-common-11-0.6rc2.ebuild", + "libstdc++-0.5.8.11-0.7rc2.fc10.tar.gz", + "libstdc++-4a.fc8.tar.gz", + "libstdc++-4.10.4.20040204svn.rpm", + "libstdc++-devel-3.fc8.ebuild", + "libstdc++-devel-3a.fc9.tar.gz", + "libstdc++-devel-8.fc8.deb", + "libstdc++-devel-8.6.2-0.4b.fc8", + "nss_ldap-1-0.2b.fc9.tar.bz2", + "nss_ldap-1-0.6rc2.fc8.tar.gz", + "nss_ldap-1.0-0.1a.tar.gz", + "nss_ldap-10beta1.fc8.tar.gz", + "nss_ldap-10.11.8.6.20040204cvs.fc10.ebuild", + "z", + "zz~", + "zz", + "zz.~1~", + "zz.0", + "#.b#", + NULL +}; + +int +main (void) +{ + const char *const *i; + + /* Following tests taken from test-strverscmp.c */ + ASSERT (filevercmp ("", "") == 0); + ASSERT (filevercmp ("a", "a") == 0); + ASSERT (filevercmp ("a", "b") < 0); + ASSERT (filevercmp ("b", "a") > 0); + ASSERT (filevercmp ("a0", "a") > 0); + ASSERT (filevercmp ("00", "01") < 0); + ASSERT (filevercmp ("01", "010") < 0); + ASSERT (filevercmp ("9", "10") < 0); + ASSERT (filevercmp ("0a", "0") > 0); + + /* compare each version string with each other - O(n^2) */ + for (i = examples; *i; i++) + { + const char *const *j; + for (j = examples; *j; j++) + { + int result = filevercmp (*i, *j); + if (result < 0) + ASSERT (i < j); + else if (0 < result) + ASSERT (j < i); + else + ASSERT (i == j); + } + } + + return 0; +} diff --git a/gnulib-tests/test-float.c b/gnulib-tests/test-float.c new file mode 100644 index 0000000..f84959c --- /dev/null +++ b/gnulib-tests/test-float.c @@ -0,0 +1,384 @@ +/* Test of <float.h> substitute. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2011. */ + +#include <config.h> + +#include <float.h> + +#include "fpucw.h" +#include "macros.h" + +/* Check that FLT_RADIX is a constant expression. */ +int a[] = { FLT_RADIX }; + +#if FLT_RADIX == 2 + +/* Return 2^n. */ +static float +pow2f (int n) +{ + int k = n; + volatile float x = 1; + volatile float y = 2; + /* Invariant: 2^n == x * y^k. */ + if (k < 0) + { + y = 0.5f; + k = - k; + } + while (k > 0) + { + if (k != 2 * (k / 2)) + { + x = x * y; + k = k - 1; + } + if (k == 0) + break; + y = y * y; + k = k / 2; + } + /* Now k == 0, hence x == 2^n. */ + return x; +} + +/* Return 2^n. */ +static double +pow2d (int n) +{ + int k = n; + volatile double x = 1; + volatile double y = 2; + /* Invariant: 2^n == x * y^k. */ + if (k < 0) + { + y = 0.5; + k = - k; + } + while (k > 0) + { + if (k != 2 * (k / 2)) + { + x = x * y; + k = k - 1; + } + if (k == 0) + break; + y = y * y; + k = k / 2; + } + /* Now k == 0, hence x == 2^n. */ + return x; +} + +/* Return 2^n. */ +static long double +pow2l (int n) +{ + int k = n; + volatile long double x = 1; + volatile long double y = 2; + /* Invariant: 2^n == x * y^k. */ + if (k < 0) + { + y = 0.5L; + k = - k; + } + while (k > 0) + { + if (k != 2 * (k / 2)) + { + x = x * y; + k = k - 1; + } + if (k == 0) + break; + y = y * y; + k = k / 2; + } + /* Now k == 0, hence x == 2^n. */ + return x; +} + +/* ----------------------- Check macros for 'float' ----------------------- */ + +/* Check that the FLT_* macros expand to constant expressions. */ +int fb[] = + { + FLT_MANT_DIG, FLT_MIN_EXP, FLT_MAX_EXP, + FLT_DIG, FLT_MIN_10_EXP, FLT_MAX_10_EXP + }; +float fc[] = { FLT_EPSILON, FLT_MIN, FLT_MAX }; + +static void +test_float (void) +{ + /* Check that the value of FLT_MIN_EXP is well parenthesized. */ + ASSERT ((FLT_MIN_EXP % 101111) == (FLT_MIN_EXP) % 101111); + + /* Check that the value of DBL_MIN_10_EXP is well parenthesized. */ + ASSERT ((FLT_MIN_10_EXP % 101111) == (FLT_MIN_10_EXP) % 101111); + + /* Check that 'float' is as specified in IEEE 754. */ + ASSERT (FLT_MANT_DIG == 24); + ASSERT (FLT_MIN_EXP == -125); + ASSERT (FLT_MAX_EXP == 128); + + /* Check the value of FLT_MIN_10_EXP. */ + ASSERT (FLT_MIN_10_EXP == - (int) (- (FLT_MIN_EXP - 1) * 0.30103)); + + /* Check the value of FLT_DIG. */ + ASSERT (FLT_DIG == (int) ((FLT_MANT_DIG - 1) * 0.30103)); + + /* Check the value of FLT_MIN_10_EXP. */ + ASSERT (FLT_MIN_10_EXP == - (int) (- (FLT_MIN_EXP - 1) * 0.30103)); + + /* Check the value of FLT_MAX_10_EXP. */ + ASSERT (FLT_MAX_10_EXP == (int) (FLT_MAX_EXP * 0.30103)); + + /* Check the value of FLT_MAX. */ + { + volatile float m = FLT_MAX; + int n; + + ASSERT (m + m > m); + for (n = 0; n <= 2 * FLT_MANT_DIG; n++) + { + volatile float pow2_n = pow2f (n); /* 2^n */ + volatile float x = m + (m / pow2_n); + if (x > m) + ASSERT (x + x == x); + else + ASSERT (!(x + x == x)); + } + } + + /* Check the value of FLT_MIN. */ + { + volatile float m = FLT_MIN; + volatile float x = pow2f (FLT_MIN_EXP - 1); + ASSERT (m == x); + } + + /* Check the value of FLT_EPSILON. */ + { + volatile float e = FLT_EPSILON; + volatile float me; + int n; + + me = 1.0f + e; + ASSERT (me > 1.0f); + ASSERT (me - 1.0f == e); + for (n = 0; n <= 2 * FLT_MANT_DIG; n++) + { + volatile float half_n = pow2f (- n); /* 2^-n */ + volatile float x = me - half_n; + if (x < me) + ASSERT (x <= 1.0f); + } + } +} + +/* ----------------------- Check macros for 'double' ----------------------- */ + +/* Check that the DBL_* macros expand to constant expressions. */ +int db[] = + { + DBL_MANT_DIG, DBL_MIN_EXP, DBL_MAX_EXP, + DBL_DIG, DBL_MIN_10_EXP, DBL_MAX_10_EXP + }; +double dc[] = { DBL_EPSILON, DBL_MIN, DBL_MAX }; + +static void +test_double (void) +{ + /* Check that the value of DBL_MIN_EXP is well parenthesized. */ + ASSERT ((DBL_MIN_EXP % 101111) == (DBL_MIN_EXP) % 101111); + + /* Check that the value of DBL_MIN_10_EXP is well parenthesized. */ + ASSERT ((DBL_MIN_10_EXP % 101111) == (DBL_MIN_10_EXP) % 101111); + + /* Check that 'double' is as specified in IEEE 754. */ + ASSERT (DBL_MANT_DIG == 53); + ASSERT (DBL_MIN_EXP == -1021); + ASSERT (DBL_MAX_EXP == 1024); + + /* Check the value of DBL_MIN_10_EXP. */ + ASSERT (DBL_MIN_10_EXP == - (int) (- (DBL_MIN_EXP - 1) * 0.30103)); + + /* Check the value of DBL_DIG. */ + ASSERT (DBL_DIG == (int) ((DBL_MANT_DIG - 1) * 0.30103)); + + /* Check the value of DBL_MIN_10_EXP. */ + ASSERT (DBL_MIN_10_EXP == - (int) (- (DBL_MIN_EXP - 1) * 0.30103)); + + /* Check the value of DBL_MAX_10_EXP. */ + ASSERT (DBL_MAX_10_EXP == (int) (DBL_MAX_EXP * 0.30103)); + + /* Check the value of DBL_MAX. */ + { + volatile double m = DBL_MAX; + int n; + + ASSERT (m + m > m); + for (n = 0; n <= 2 * DBL_MANT_DIG; n++) + { + volatile double pow2_n = pow2d (n); /* 2^n */ + volatile double x = m + (m / pow2_n); + if (x > m) + ASSERT (x + x == x); + else + ASSERT (!(x + x == x)); + } + } + + /* Check the value of DBL_MIN. */ + { + volatile double m = DBL_MIN; + volatile double x = pow2d (DBL_MIN_EXP - 1); + ASSERT (m == x); + } + + /* Check the value of DBL_EPSILON. */ + { + volatile double e = DBL_EPSILON; + volatile double me; + int n; + + me = 1.0 + e; + ASSERT (me > 1.0); + ASSERT (me - 1.0 == e); + for (n = 0; n <= 2 * DBL_MANT_DIG; n++) + { + volatile double half_n = pow2d (- n); /* 2^-n */ + volatile double x = me - half_n; + if (x < me) + ASSERT (x <= 1.0); + } + } +} + +/* -------------------- Check macros for 'long double' -------------------- */ + +/* Check that the LDBL_* macros expand to constant expressions. */ +int lb[] = + { + LDBL_MANT_DIG, LDBL_MIN_EXP, LDBL_MAX_EXP, + LDBL_DIG, LDBL_MIN_10_EXP, LDBL_MAX_10_EXP + }; +long double lc1 = LDBL_EPSILON; +long double lc2 = LDBL_MIN; +#if 0 /* LDBL_MAX is not a constant expression on some platforms. */ +long double lc3 = LDBL_MAX; +#endif + +static void +test_long_double (void) +{ + /* Check that the value of LDBL_MIN_EXP is well parenthesized. */ + ASSERT ((LDBL_MIN_EXP % 101111) == (LDBL_MIN_EXP) % 101111); + + /* Check that the value of LDBL_MIN_10_EXP is well parenthesized. */ + ASSERT ((LDBL_MIN_10_EXP % 101111) == (LDBL_MIN_10_EXP) % 101111); + + /* Check that 'long double' is at least as wide as 'double'. */ + ASSERT (LDBL_MANT_DIG >= DBL_MANT_DIG); + ASSERT (LDBL_MIN_EXP - LDBL_MANT_DIG <= DBL_MIN_EXP - DBL_MANT_DIG); + ASSERT (LDBL_MAX_EXP >= DBL_MAX_EXP); + + /* Check the value of LDBL_DIG. */ + ASSERT (LDBL_DIG == (int)((LDBL_MANT_DIG - 1) * 0.30103)); + + /* Check the value of LDBL_MIN_10_EXP. */ + ASSERT (LDBL_MIN_10_EXP == - (int) (- (LDBL_MIN_EXP - 1) * 0.30103)); + + /* Check the value of LDBL_MAX_10_EXP. */ + ASSERT (LDBL_MAX_10_EXP == (int) (LDBL_MAX_EXP * 0.30103)); + + /* Check the value of LDBL_MAX. */ + { + volatile long double m = LDBL_MAX; + int n; + + ASSERT (m + m > m); + for (n = 0; n <= 2 * LDBL_MANT_DIG; n++) + { + volatile long double pow2_n = pow2l (n); /* 2^n */ + volatile long double x = m + (m / pow2_n); + if (x > m) + ASSERT (x + x == x); + else + ASSERT (!(x + x == x)); + } + } + + /* Check the value of LDBL_MIN. */ + { + volatile long double m = LDBL_MIN; + volatile long double x = pow2l (LDBL_MIN_EXP - 1); + ASSERT (m == x); + } + + /* Check the value of LDBL_EPSILON. */ + { + volatile long double e = LDBL_EPSILON; + volatile long double me; + int n; + + me = 1.0L + e; + ASSERT (me > 1.0L); + ASSERT (me - 1.0L == e); + for (n = 0; n <= 2 * LDBL_MANT_DIG; n++) + { + volatile long double half_n = pow2l (- n); /* 2^-n */ + volatile long double x = me - half_n; + if (x < me) + ASSERT (x <= 1.0L); + } + } +} + +int +main () +{ + test_float (); + test_double (); + + { + DECL_LONG_DOUBLE_ROUNDING + + BEGIN_LONG_DOUBLE_ROUNDING (); + + test_long_double (); + + END_LONG_DOUBLE_ROUNDING (); + } + + return 0; +} + +#else + +int +main () +{ + fprintf (stderr, "Skipping test: FLT_RADIX is not 2.\n"); + return 77; +} + +#endif diff --git a/gnulib-tests/test-fnmatch-h.c b/gnulib-tests/test-fnmatch-h.c new file mode 100644 index 0000000..f44d06c --- /dev/null +++ b/gnulib-tests/test-fnmatch-h.c @@ -0,0 +1,31 @@ +/* Test of <fnmatch.h> substitute. + Copyright (C) 2018-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2018. */ + +#include <config.h> + +#include <fnmatch.h> + +/* Check that the various FNM_* macros are defined. */ +int ret = FNM_NOMATCH; +int options[] = { FNM_PATHNAME, FNM_PERIOD, FNM_NOESCAPE }; + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tests/test-fnmatch.c b/gnulib-tests/test-fnmatch.c new file mode 100644 index 0000000..a094c1f --- /dev/null +++ b/gnulib-tests/test-fnmatch.c @@ -0,0 +1,56 @@ +/* Test of fnmatch string matching function. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Simon Josefsson <simon@josefsson.org>, 2009. */ + +#include <config.h> + +#include <fnmatch.h> + +#include "signature.h" +SIGNATURE_CHECK (fnmatch, int, (char const *, char const *, int)); + +#include "macros.h" + +int +main () +{ + int res; + + ASSERT (res = fnmatch ("", "", 0) == 0); + + ASSERT (res = fnmatch ("*", "", 0) == 0); + ASSERT (res = fnmatch ("*", "foo", 0) == 0); + ASSERT (res = fnmatch ("*", "bar", 0) == 0); + ASSERT (res = fnmatch ("*", "*", 0) == 0); + ASSERT (res = fnmatch ("**", "f", 0) == 0); + ASSERT (res = fnmatch ("**", "foo.txt", 0) == 0); + ASSERT (res = fnmatch ("*.*", "foo.txt", 0) == 0); + + ASSERT (res = fnmatch ("foo*.txt", "foobar.txt", 0) == 0); + + ASSERT (res = fnmatch ("foo.txt", "foo.txt", 0) == 0); + ASSERT (res = fnmatch ("foo\\.txt", "foo.txt", 0) == 0); + ASSERT (res = fnmatch ("foo\\.txt", "foo.txt", FNM_NOESCAPE) == FNM_NOMATCH); + + /* Verify that an unmatched [ is treated as a literal, as POSIX + requires. This test ensures that glibc Bugzilla bug #12378 stays + fixed. + */ + ASSERT (res = fnmatch ("[/b", "[/b", 0) == 0); + + return 0; +} diff --git a/gnulib-tests/test-fopen-safer.c b/gnulib-tests/test-fopen-safer.c new file mode 100644 index 0000000..b041fc1 --- /dev/null +++ b/gnulib-tests/test-fopen-safer.c @@ -0,0 +1,31 @@ +/* Test of opening a file stream. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include "stdio--.h" + +#define BASE "test-fopen-safer.t" + +#include "test-fopen.h" + +int +main (void) +{ + return test_fopen (); +} diff --git a/gnulib-tests/test-fopen.c b/gnulib-tests/test-fopen.c new file mode 100644 index 0000000..36d2529 --- /dev/null +++ b/gnulib-tests/test-fopen.c @@ -0,0 +1,34 @@ +/* Test of opening a file stream. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (fopen, FILE *, (char const *, char const *)); + +#define BASE "test-fopen.t" + +#include "test-fopen.h" + +int +main (void) +{ + return test_fopen (); +} diff --git a/gnulib-tests/test-fopen.h b/gnulib-tests/test-fopen.h new file mode 100644 index 0000000..fb036af --- /dev/null +++ b/gnulib-tests/test-fopen.h @@ -0,0 +1,73 @@ +/* Test of opening a file stream. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +/* Include <config.h> and a form of <stdio.h> first. */ + +#include <errno.h> +#include <unistd.h> + +#include "macros.h" + +/* Test fopen. Assumes BASE is defined. */ + +static int +test_fopen (void) +{ + FILE *f; + /* Remove anything from prior partial run. */ + unlink (BASE "file"); + + /* Read requires existing file. */ + errno = 0; + ASSERT (fopen (BASE "file", "r") == NULL); + ASSERT (errno == ENOENT); + + /* Write can create a file. */ + f = fopen (BASE "file", "w"); + ASSERT (f); + ASSERT (fclose (f) == 0); + + /* Trailing slash is invalid on non-directory. */ + errno = 0; + ASSERT (fopen (BASE "file/", "r") == NULL); + ASSERT (errno == ENOTDIR || errno == EISDIR || errno == EINVAL); + + /* Cannot create a directory. */ + errno = 0; + ASSERT (fopen ("nonexist.ent/", "w") == NULL); + ASSERT (errno == ENOTDIR || errno == EISDIR || errno == ENOENT + || errno == EINVAL); + + /* Directories cannot be opened for writing. */ + errno = 0; + ASSERT (fopen (".", "w") == NULL); + ASSERT (errno == EISDIR || errno == EINVAL || errno == EACCES); + + /* /dev/null must exist, and be writable. */ + f = fopen ("/dev/null", "r"); + ASSERT (f); + ASSERT (fclose (f) == 0); + f = fopen ("/dev/null", "w"); + ASSERT (f); + ASSERT (fclose (f) == 0); + + /* Cleanup. */ + ASSERT (unlink (BASE "file") == 0); + + return 0; +} diff --git a/gnulib-tests/test-fpending.c b/gnulib-tests/test-fpending.c new file mode 100644 index 0000000..a0bdd96 --- /dev/null +++ b/gnulib-tests/test-fpending.c @@ -0,0 +1,41 @@ +/* Ensure that __fpending works. + + Copyright (C) 2004, 2007-2020 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 <https://www.gnu.org/licenses/>. + + Written by Jim Meyering. */ + +#include <config.h> + +#include "fpending.h" + +#include <stdio.h> +#include <stdlib.h> + +#include "macros.h" + +int +main (void) +{ + ASSERT (__fpending (stdout) == 0); + + fputs ("foo", stdout); + ASSERT (__fpending (stdout) == 3); + + fflush (stdout); + ASSERT (__fpending (stdout) == 0); + + exit (0); +} diff --git a/gnulib-tests/test-fpending.sh b/gnulib-tests/test-fpending.sh new file mode 100755 index 0000000..abe7d83 --- /dev/null +++ b/gnulib-tests/test-fpending.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +tmpfile= +trap 'rm -fr $tmpfile' 1 2 3 15 + +tmpfile=test-fpending.t + +${CHECKER} ./test-fpending${EXEEXT} > $tmpfile || exit 1 + +rm -fr $tmpfile + +exit 0 diff --git a/gnulib-tests/test-fprintf-posix.h b/gnulib-tests/test-fprintf-posix.h new file mode 100644 index 0000000..8974ed6 --- /dev/null +++ b/gnulib-tests/test-fprintf-posix.h @@ -0,0 +1,153 @@ +/* Test of POSIX compatible vsprintf() and sprintf() functions. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include "infinity.h" + +static void +test_function (int (*my_fprintf) (FILE *, const char *, ...)) +{ + /* Here we don't test output that may be platform dependent. + The bulk of the tests is done as part of the 'vasnprintf-posix' module. */ + + /* Test support of size specifiers as in C99. */ + + my_fprintf (stdout, "%ju %d\n", (uintmax_t) 12345671, 33, 44, 55); + + my_fprintf (stdout, "%zu %d\n", (size_t) 12345672, 33, 44, 55); + + my_fprintf (stdout, "%tu %d\n", (ptrdiff_t) 12345673, 33, 44, 55); + + /* Test the support of the 'a' and 'A' conversion specifier for hexadecimal + output of floating-point numbers. */ + + /* Positive zero. */ + my_fprintf (stdout, "%a %d\n", 0.0, 33, 44, 55); + + /* Positive infinity. */ + my_fprintf (stdout, "%a %d\n", Infinityd (), 33, 44, 55); + + /* Negative infinity. */ + my_fprintf (stdout, "%a %d\n", - Infinityd (), 33, 44, 55); + + /* FLAG_ZERO with infinite number. */ + my_fprintf (stdout, "%010a %d\n", Infinityd (), 33, 44, 55); + + /* Test the support of the %f format directive. */ + + /* A positive number. */ + my_fprintf (stdout, "%f %d\n", 12.75, 33, 44, 55); + + /* A larger positive number. */ + my_fprintf (stdout, "%f %d\n", 1234567.0, 33, 44, 55); + + /* A negative number. */ + my_fprintf (stdout, "%f %d\n", -0.03125, 33, 44, 55); + + /* Positive zero. */ + my_fprintf (stdout, "%f %d\n", 0.0, 33, 44, 55); + + /* FLAG_ZERO. */ + my_fprintf (stdout, "%015f %d\n", 1234.0, 33, 44, 55); + + /* Precision. */ + my_fprintf (stdout, "%.f %d\n", 1234.0, 33, 44, 55); + + /* Precision with no rounding. */ + my_fprintf (stdout, "%.2f %d\n", 999.95, 33, 44, 55); + + /* Precision with rounding. */ + my_fprintf (stdout, "%.2f %d\n", 999.996, 33, 44, 55); + + /* A positive number. */ + my_fprintf (stdout, "%Lf %d\n", 12.75L, 33, 44, 55); + + /* A larger positive number. */ + my_fprintf (stdout, "%Lf %d\n", 1234567.0L, 33, 44, 55); + + /* A negative number. */ + my_fprintf (stdout, "%Lf %d\n", -0.03125L, 33, 44, 55); + + /* Positive zero. */ + my_fprintf (stdout, "%Lf %d\n", 0.0L, 33, 44, 55); + + /* FLAG_ZERO. */ + my_fprintf (stdout, "%015Lf %d\n", 1234.0L, 33, 44, 55); + + /* Precision. */ + my_fprintf (stdout, "%.Lf %d\n", 1234.0L, 33, 44, 55); + + /* Precision with no rounding. */ + my_fprintf (stdout, "%.2Lf %d\n", 999.95L, 33, 44, 55); + + /* Precision with rounding. */ + my_fprintf (stdout, "%.2Lf %d\n", 999.996L, 33, 44, 55); + + /* Test the support of the %F format directive. */ + + /* A positive number. */ + my_fprintf (stdout, "%F %d\n", 12.75, 33, 44, 55); + + /* A larger positive number. */ + my_fprintf (stdout, "%F %d\n", 1234567.0, 33, 44, 55); + + /* A negative number. */ + my_fprintf (stdout, "%F %d\n", -0.03125, 33, 44, 55); + + /* Positive zero. */ + my_fprintf (stdout, "%F %d\n", 0.0, 33, 44, 55); + + /* FLAG_ZERO. */ + my_fprintf (stdout, "%015F %d\n", 1234.0, 33, 44, 55); + + /* Precision. */ + my_fprintf (stdout, "%.F %d\n", 1234.0, 33, 44, 55); + + /* Precision with no rounding. */ + my_fprintf (stdout, "%.2F %d\n", 999.95, 33, 44, 55); + + /* Precision with rounding. */ + my_fprintf (stdout, "%.2F %d\n", 999.996, 33, 44, 55); + + /* A positive number. */ + my_fprintf (stdout, "%LF %d\n", 12.75L, 33, 44, 55); + + /* A larger positive number. */ + my_fprintf (stdout, "%LF %d\n", 1234567.0L, 33, 44, 55); + + /* A negative number. */ + my_fprintf (stdout, "%LF %d\n", -0.03125L, 33, 44, 55); + + /* Positive zero. */ + my_fprintf (stdout, "%LF %d\n", 0.0L, 33, 44, 55); + + /* FLAG_ZERO. */ + my_fprintf (stdout, "%015LF %d\n", 1234.0L, 33, 44, 55); + + /* Precision. */ + my_fprintf (stdout, "%.LF %d\n", 1234.0L, 33, 44, 55); + + /* Precision with no rounding. */ + my_fprintf (stdout, "%.2LF %d\n", 999.95L, 33, 44, 55); + + /* Precision with rounding. */ + my_fprintf (stdout, "%.2LF %d\n", 999.996L, 33, 44, 55); + + /* Test the support of the POSIX/XSI format strings with positions. */ + + my_fprintf (stdout, "%2$d %1$d\n", 33, 55); +} diff --git a/gnulib-tests/test-fpurge.c b/gnulib-tests/test-fpurge.c new file mode 100644 index 0000000..3bca176 --- /dev/null +++ b/gnulib-tests/test-fpurge.c @@ -0,0 +1,134 @@ +/* Test of fpurge() function. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +/* None of the files accessed by this test are large, so disable the + fseek link warning if we are not using the gnulib fseek module. */ +#define _GL_NO_LARGE_FILES +#include <stdio.h> + +#include <string.h> + +#include "macros.h" + +#define TESTFILE "t-fpurge.tmp" + +int +main (void) +{ + int check_filepos; + + for (check_filepos = 0; check_filepos <= 1; check_filepos++) + { + FILE *fp; + + /* Create a file with some contents. */ + fp = fopen (TESTFILE, "w"); + if (fp == NULL) + goto skip; + if (fwrite ("foobarsh", 1, 8, fp) < 8) + goto skip; + if (fclose (fp)) + goto skip; + + /* The file's contents is now "foobarsh". */ + + /* Open it in read-write mode. */ + fp = fopen (TESTFILE, "r+"); + if (fp == NULL) + goto skip; + if (fseek (fp, 3, SEEK_CUR)) + goto skip; + if (fwrite ("g", 1, 1, fp) < 1) + goto skip; + if (fflush (fp)) + goto skip; + if (fwrite ("bz", 1, 2, fp) < 2) + goto skip; + /* Discard pending write. */ + ASSERT (fpurge (fp) == 0); + /* Verify that when discarding pending output, the file position is set + back to where it was before the write calls. */ + if (check_filepos) + ASSERT (ftell (fp) == 4); + ASSERT (fclose (fp) == 0); + + /* Open it in read-only mode. */ + fp = fopen (TESTFILE, "r"); + if (fp == NULL) + goto skip; + /* Verify that the pending writes before the fpurge were really + discarded. */ + { + char buf[8]; + if (fread (buf, 1, 7, fp) < 7) + goto skip; + ASSERT (memcmp (buf, "foogars", 7) == 0); + } + /* Discard the buffered 'h'. */ + if (check_filepos) + ASSERT (ftell (fp) == 7); + ASSERT (fpurge (fp) == 0); + /* Verify that when discarding pending input, the file position is + advanced to match the end of the previously read input. */ + if (check_filepos) + ASSERT (ftell (fp) == 8); + ASSERT (getc (fp) == EOF); + ASSERT (fclose (fp) == 0); + + /* The file's contents is now "foogarsh". */ + + /* Ensure that purging a read does not corrupt subsequent writes. */ + fp = fopen (TESTFILE, "r+"); + if (fp == NULL) + goto skip; + if (fseek (fp, -1, SEEK_END)) + goto skip; + ASSERT (getc (fp) == 'h'); + ASSERT (getc (fp) == EOF); + if (check_filepos) + ASSERT (ftell (fp) == 8); + ASSERT (fpurge (fp) == 0); + if (check_filepos) + ASSERT (ftell (fp) == 8); + ASSERT (putc ('!', fp) == '!'); + if (check_filepos) + ASSERT (ftell (fp) == 9); + ASSERT (fclose (fp) == 0); + fp = fopen (TESTFILE, "r"); + if (fp == NULL) + goto skip; + { + char buf[10]; + ASSERT (fread (buf, 1, 10, fp) == 9); + ASSERT (memcmp (buf, "foogarsh!", 9) == 0); + } + ASSERT (fclose (fp) == 0); + + /* The file's contents is now "foogarsh!". */ + } + + remove (TESTFILE); + return 0; + + skip: + fprintf (stderr, "Skipping test: prerequisite file operations failed.\n"); + remove (TESTFILE); + return 77; +} diff --git a/gnulib-tests/test-fputc.c b/gnulib-tests/test-fputc.c new file mode 100644 index 0000000..e8e25b8 --- /dev/null +++ b/gnulib-tests/test-fputc.c @@ -0,0 +1,93 @@ +/* Test of fputc() function. + Copyright (C) 2011-2020 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, 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (fputc, int, (int, FILE *)); + +#include <errno.h> +#include <fcntl.h> +#include <unistd.h> + +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER +# include "msvc-inval.h" +#endif + +#include "macros.h" + +int +main (int argc, char **argv) +{ + const char *filename = "test-fputc.txt"; + + /* We don't have an fputc() function that installs an invalid parameter + handler so far. So install that handler here, explicitly. */ +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER \ + && MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING + gl_msvc_inval_ensure_handler (); +#endif + + /* Test that fputc() on an unbuffered stream sets errno if someone else + closes the stream fd behind the back of stdio. */ + { + FILE *fp = fopen (filename, "w"); + ASSERT (fp != NULL); + setvbuf (fp, NULL, _IONBF, 0); + ASSERT (close (fileno (fp)) == 0); + errno = 0; + ASSERT (fputc ('x', fp) == EOF); + ASSERT (errno == EBADF); + ASSERT (ferror (fp)); + fclose (fp); + } + + /* Test that fputc() on an unbuffered stream sets errno if the stream + was constructed with an invalid file descriptor. */ + { + FILE *fp = fdopen (-1, "w"); + if (fp != NULL) + { + setvbuf (fp, NULL, _IONBF, 0); + errno = 0; + ASSERT (fputc ('x', fp) == EOF); + ASSERT (errno == EBADF); + ASSERT (ferror (fp)); + fclose (fp); + } + } + { + FILE *fp; + close (99); + fp = fdopen (99, "w"); + if (fp != NULL) + { + setvbuf (fp, NULL, _IONBF, 0); + errno = 0; + ASSERT (fputc ('x', fp) == EOF); + ASSERT (errno == EBADF); + ASSERT (ferror (fp)); + fclose (fp); + } + } + + /* Clean up. */ + unlink (filename); + + return 0; +} diff --git a/gnulib-tests/test-fread.c b/gnulib-tests/test-fread.c new file mode 100644 index 0000000..08b3a11 --- /dev/null +++ b/gnulib-tests/test-fread.c @@ -0,0 +1,102 @@ +/* Test of fread() function. + Copyright (C) 2011-2020 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, 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (fread, size_t, (void *, size_t, size_t, FILE *)); + +#include <errno.h> +#include <fcntl.h> +#include <unistd.h> + +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER +# include "msvc-inval.h" +#endif + +#include "macros.h" + +int +main (int argc, char **argv) +{ + const char *filename = "test-fread.txt"; + + /* We don't have an fread() function that installs an invalid parameter + handler so far. So install that handler here, explicitly. */ +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER \ + && MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING + gl_msvc_inval_ensure_handler (); +#endif + + /* Prepare a file. */ + { + const char text[] = "hello world"; + int fd = open (filename, O_RDWR | O_CREAT | O_TRUNC, 0600); + ASSERT (fd >= 0); + ASSERT (write (fd, text, sizeof (text)) == sizeof (text)); + ASSERT (close (fd) == 0); + } + + /* Test that fread() sets errno if someone else closes the stream + fd behind the back of stdio. */ + { + FILE *fp = fopen (filename, "r"); + char buf[5]; + ASSERT (fp != NULL); + ASSERT (close (fileno (fp)) == 0); + errno = 0; + ASSERT (fread (buf, 1, sizeof (buf), fp) == 0); + ASSERT (errno == EBADF); + ASSERT (ferror (fp)); + fclose (fp); + } + + /* Test that fread() sets errno if the stream was constructed with + an invalid file descriptor. */ + { + FILE *fp = fdopen (-1, "r"); + if (fp != NULL) + { + char buf[1]; + errno = 0; + ASSERT (fread (buf, 1, 1, fp) == 0); + ASSERT (errno == EBADF); + ASSERT (ferror (fp)); + fclose (fp); + } + } + { + FILE *fp; + close (99); + fp = fdopen (99, "r"); + if (fp != NULL) + { + char buf[1]; + errno = 0; + ASSERT (fread (buf, 1, 1, fp) == 0); + ASSERT (errno == EBADF); + ASSERT (ferror (fp)); + fclose (fp); + } + } + + /* Clean up. */ + unlink (filename); + + return 0; +} diff --git a/gnulib-tests/test-freadahead.c b/gnulib-tests/test-freadahead.c new file mode 100644 index 0000000..a7042f1 --- /dev/null +++ b/gnulib-tests/test-freadahead.c @@ -0,0 +1,77 @@ +/* Test of freadahead() function. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include "freadahead.h" + +#include <stdlib.h> +#include <unistd.h> + +#include "macros.h" + +int +main (int argc, char **argv) +{ + int nbytes = atoi (argv[1]); + if (nbytes > 0) + { + void *buf = malloc (nbytes); + ASSERT (fread (buf, 1, nbytes, stdin) == nbytes); + free (buf); + } + + if (nbytes == 0) + ASSERT (freadahead (stdin) == 0); + else + { + if (lseek (0, 0, SEEK_CUR) == nbytes) + /* An unbuffered stdio, such as BeOS or on uClibc compiled without + __STDIO_BUFFERS. */ + ASSERT (freadahead (stdin) == 0); + else + { + /* Normal buffered stdio. */ + size_t buffered; + int c, c2; + + ASSERT (freadahead (stdin) != 0); + buffered = freadahead (stdin); + + c = fgetc (stdin); + ASSERT (freadahead (stdin) == buffered - 1); + ungetc (c, stdin); + ASSERT (freadahead (stdin) == buffered); + c2 = fgetc (stdin); + ASSERT (c2 == c); + ASSERT (freadahead (stdin) == buffered - 1); + + c = '@'; + ungetc (c, stdin); + ASSERT (freadahead (stdin) == buffered); + c2 = fgetc (stdin); + ASSERT (c2 == c); + ASSERT (freadahead (stdin) == buffered - 1); + } + } + + /* Free memory allocated during ungetc(). */ + fclose (stdin); + + return 0; +} diff --git a/gnulib-tests/test-freadahead.sh b/gnulib-tests/test-freadahead.sh new file mode 100755 index 0000000..f420000 --- /dev/null +++ b/gnulib-tests/test-freadahead.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +${CHECKER} ./test-freadahead${EXEEXT} 0 < "$srcdir/test-freadahead.sh" || exit 1 +${CHECKER} ./test-freadahead${EXEEXT} 5 < "$srcdir/test-freadahead.sh" || exit 1 +exit 0 diff --git a/gnulib-tests/test-freading.c b/gnulib-tests/test-freading.c new file mode 100644 index 0000000..f2abd1f --- /dev/null +++ b/gnulib-tests/test-freading.c @@ -0,0 +1,130 @@ +/* Test of freading() function. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +/* None of the files accessed by this test are large, so disable the + fseek link warning if we are not using the gnulib fseek module. */ +#define _GL_NO_LARGE_FILES +#include "freading.h" + +#include <stdio.h> + +#include "macros.h" + +#define TESTFILE "t-freading.tmp" + +int +main (void) +{ + FILE *fp; + + /* Create a file with some contents. Write-only file is never reading. */ + fp = fopen (TESTFILE, "w"); + ASSERT (fp); + ASSERT (!freading (fp)); + ASSERT (fwrite ("foobarsh", 1, 8, fp) == 8); + ASSERT (!freading (fp)); + ASSERT (fclose (fp) == 0); + + /* Open it in read-only mode. Read-only file is always reading. */ + fp = fopen (TESTFILE, "r"); + ASSERT (fp); + ASSERT (freading (fp)); + ASSERT (fgetc (fp) == 'f'); + ASSERT (freading (fp)); + ASSERT (fseek (fp, 2, SEEK_CUR) == 0); + ASSERT (freading (fp)); + ASSERT (fgetc (fp) == 'b'); + ASSERT (freading (fp)); + fflush (fp); + ASSERT (freading (fp)); + ASSERT (fgetc (fp) == 'a'); + ASSERT (freading (fp)); + ASSERT (fseek (fp, 0, SEEK_END) == 0); + ASSERT (freading (fp)); + ASSERT (fclose (fp) == 0); + + /* Open it in read-write mode. POSIX requires a reposition (fseek, + fsetpos, rewind) or EOF when transitioning from read to write; + freading is only deterministic after input or output, but this + test case should be portable even on open, after reposition, and + at EOF. */ + /* First a scenario with only fgetc, fseek, fputc. */ + fp = fopen (TESTFILE, "r+"); + ASSERT (fp); + ASSERT (!freading (fp)); + ASSERT (fgetc (fp) == 'f'); + ASSERT (freading (fp)); + ASSERT (fseek (fp, 2, SEEK_CUR) == 0); + /* freading (fp) is undefined here, but fwriting (fp) is false. */ + ASSERT (fgetc (fp) == 'b'); + ASSERT (freading (fp)); + /* This fseek call is necessary when switching from reading to writing. + See the description of fopen(), ISO C 99 7.19.5.3.(6). */ + ASSERT (fseek (fp, 0, SEEK_CUR) == 0); + /* freading (fp) is undefined here, but fwriting (fp) is false. */ + ASSERT (fputc ('x', fp) == 'x'); + ASSERT (!freading (fp)); + ASSERT (fseek (fp, 0, SEEK_END) == 0); + /* freading (fp) is undefined here, because on some implementations (e.g. + glibc) fseek causes a buffer to be read. + fwriting (fp) is undefined as well. */ + ASSERT (fclose (fp) == 0); + + /* Open it in read-write mode. POSIX requires a reposition (fseek, + fsetpos, rewind) or EOF when transitioning from read to write; + freading is only deterministic after input or output, but this + test case should be portable even on open, after reposition, and + at EOF. */ + /* Here a scenario that includes fflush. */ + fp = fopen (TESTFILE, "r+"); + ASSERT (fp); + ASSERT (!freading (fp)); + ASSERT (fgetc (fp) == 'f'); + ASSERT (freading (fp)); + ASSERT (fseek (fp, 2, SEEK_CUR) == 0); + /* freading (fp) is undefined here, but fwriting (fp) is false. */ + ASSERT (fgetc (fp) == 'b'); + ASSERT (freading (fp)); + fflush (fp); + /* freading (fp) is undefined here, but fwriting (fp) is false. */ + ASSERT (fgetc (fp) == 'x'); + ASSERT (freading (fp)); + /* This fseek call is necessary when switching from reading to writing. + See the description of fopen(), ISO C 99 7.19.5.3.(6). */ + ASSERT (fseek (fp, 0, SEEK_CUR) == 0); + /* freading (fp) is undefined here, but fwriting (fp) is false. */ + ASSERT (fputc ('z', fp) == 'z'); + ASSERT (!freading (fp)); + ASSERT (fseek (fp, 0, SEEK_END) == 0); + /* freading (fp) is undefined here, because on some implementations (e.g. + glibc) fseek causes a buffer to be read. + fwriting (fp) is undefined as well. */ + ASSERT (fclose (fp) == 0); + + /* Open it in append mode. Write-only file is never reading. */ + fp = fopen (TESTFILE, "a"); + ASSERT (fp); + ASSERT (!freading (fp)); + ASSERT (fwrite ("bla", 1, 3, fp) == 3); + ASSERT (!freading (fp)); + ASSERT (fclose (fp) == 0); + ASSERT (remove (TESTFILE) == 0); + return 0; +} diff --git a/gnulib-tests/test-freadptr.c b/gnulib-tests/test-freadptr.c new file mode 100644 index 0000000..3a4a349 --- /dev/null +++ b/gnulib-tests/test-freadptr.c @@ -0,0 +1,100 @@ +/* Test of freadptr() function. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2008. */ + +#include <config.h> + +#include "freadptr.h" + +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include "macros.h" + +int +main (int argc, char **argv) +{ + int nbytes = atoi (argv[1]); + { + void *buf = malloc (nbytes); + ASSERT (fread (buf, 1, nbytes, stdin) == nbytes); + free (buf); + } + + if (lseek (0, 0, SEEK_CUR) == nbytes) + { + /* An unbuffered stdio, such as BeOS or on uClibc compiled without + __STDIO_BUFFERS. Or stdin is a pipe. */ + size_t size; + ASSERT (freadptr (stdin, &size) == NULL); + } + else + { + /* Normal buffered stdio. */ + const char stdin_contents[] = + "#!/bin/sh\n\n${CHECKER} ./test-freadptr${EXEEXT} 5 < \"$srcdir/test-freadptr.sh\" || exit 1\ncat \"$srcdir/test-freadptr.sh\" | ${CHECKER} ./test-freadptr${EXEEXT} 5 || exit 1\nexit 0\n"; + const char *expected = stdin_contents + nbytes; + size_t available1; + size_t available2; + size_t available3; + + /* Test normal behaviour. */ + { + const char *ptr = freadptr (stdin, &available1); + + ASSERT (ptr != NULL); + ASSERT (available1 != 0); + ASSERT (available1 <= strlen (expected)); + ASSERT (memcmp (ptr, expected, available1) == 0); + } + + /* Test behaviour after normal ungetc. */ + ungetc (fgetc (stdin), stdin); + { + const char *ptr = freadptr (stdin, &available2); + + if (ptr != NULL) + { + ASSERT (available2 == available1); + ASSERT (memcmp (ptr, expected, available2) == 0); + } + } + + /* Test behaviour after arbitrary ungetc. */ + fgetc (stdin); + ungetc ('@', stdin); + { + const char *ptr = freadptr (stdin, &available3); + + if (ptr != NULL) + { + ASSERT (available3 == 1 || available3 == available1); + ASSERT (ptr[0] == '@'); + if (available3 > 1) + { + ASSERT (memcmp (ptr + 1, expected + 1, available3 - 1) == 0); + } + } + } + } + + /* Free memory allocated during ungetc(). */ + fclose (stdin); + + return 0; +} diff --git a/gnulib-tests/test-freadptr.sh b/gnulib-tests/test-freadptr.sh new file mode 100755 index 0000000..0917fa3 --- /dev/null +++ b/gnulib-tests/test-freadptr.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +${CHECKER} ./test-freadptr${EXEEXT} 5 < "$srcdir/test-freadptr.sh" || exit 1 +cat "$srcdir/test-freadptr.sh" | ${CHECKER} ./test-freadptr${EXEEXT} 5 || exit 1 +exit 0 diff --git a/gnulib-tests/test-freadptr2.c b/gnulib-tests/test-freadptr2.c new file mode 100644 index 0000000..c26751e --- /dev/null +++ b/gnulib-tests/test-freadptr2.c @@ -0,0 +1,63 @@ +/* Test of freadptr() function. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include "freadptr.h" + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "macros.h" + +static int +freadptrbufsize (FILE *fp) +{ + size_t size = 0; + + freadptr (fp, &size); + return size; +} + +int +main (int argc, char **argv) +{ + int nbytes = atoi (argv[1]); + if (nbytes > 0) + { + void *buf = malloc (nbytes); + ASSERT (fread (buf, 1, nbytes, stdin) == nbytes); + free (buf); + } + + if (nbytes == 0) + ASSERT (freadptrbufsize (stdin) == 0); + else + { + if (lseek (0, 0, SEEK_CUR) == nbytes) + /* An unbuffered stdio, such as BeOS or on uClibc compiled without + __STDIO_BUFFERS. */ + ASSERT (freadptrbufsize (stdin) == 0); + else + /* Normal buffered stdio. */ + ASSERT (freadptrbufsize (stdin) != 0); + } + + return 0; +} diff --git a/gnulib-tests/test-freadptr2.sh b/gnulib-tests/test-freadptr2.sh new file mode 100755 index 0000000..f429f38 --- /dev/null +++ b/gnulib-tests/test-freadptr2.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +${CHECKER} ./test-freadptr2${EXEEXT} 0 < "$srcdir/test-freadptr2.sh" || exit 1 +${CHECKER} ./test-freadptr2${EXEEXT} 5 < "$srcdir/test-freadptr2.sh" || exit 1 +exit 0 diff --git a/gnulib-tests/test-freadseek.c b/gnulib-tests/test-freadseek.c new file mode 100644 index 0000000..d1698c5 --- /dev/null +++ b/gnulib-tests/test-freadseek.c @@ -0,0 +1,98 @@ +/* Test of freadseek() function. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2008. */ + +#include <config.h> + +#include "freadseek.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include "macros.h" + +int +main (int argc, char **argv) +{ + static const char stdin_contents[] = + "#!/bin/sh\n\n${CHECKER} ./test-freadseek${EXEEXT} 5 19 6 7 18 9 19 < \"$srcdir/test-freadseek.sh\" || exit 1\ncat \"$srcdir/test-freadseek.sh\" | ${CHECKER} ./test-freadseek${EXEEXT} 5 19 6 7 18 9 19 || exit 1\nexit 0\n"; + int nbytes1 = atoi (argv[1]); + int nbytes2 = atoi (argv[2]); + int nbytes3 = atoi (argv[3]); + int nbytes4 = atoi (argv[4]); + int nbytes5 = atoi (argv[5]); + int nbytes6 = atoi (argv[6]); + int nbytes7 = atoi (argv[7]); + void *buf1 = malloc (nbytes1); + void *buf3 = malloc (nbytes3); + void *buf5 = malloc (nbytes5); + void *buf7 = malloc (nbytes7); + /* A private variable to keep track of the position. */ + size_t position = 0; + + ASSERT (fread (buf1, 1, nbytes1, stdin) == nbytes1); + ASSERT (memcmp (buf1, stdin_contents + position, nbytes1) == 0); + position += nbytes1; + + /* Test normal behaviour. */ + ASSERT (freadseek (stdin, nbytes2) == 0); + position += nbytes2; + + ASSERT (fread (buf3, 1, nbytes3, stdin) == nbytes3); + ASSERT (memcmp (buf3, stdin_contents + position, nbytes3) == 0); + position += nbytes3; + + /* Test behaviour after normal ungetc. */ + ungetc (fgetc (stdin), stdin); + ASSERT (freadseek (stdin, nbytes4) == 0); + position += nbytes4; + + ASSERT (fread (buf5, 1, nbytes5, stdin) == nbytes5); + ASSERT (memcmp (buf5, stdin_contents + position, nbytes5) == 0); + position += nbytes5; + + /* Test behaviour after arbitrary ungetc. */ + fgetc (stdin); + ungetc ('@', stdin); + ASSERT (freadseek (stdin, nbytes6) == 0); + position += nbytes6; + + ASSERT (fread (buf7, 1, nbytes7, stdin) == nbytes7); + ASSERT (memcmp (buf7, stdin_contents + position, nbytes7) == 0); + position += nbytes7; + + /* Test move to end of file. */ + ASSERT (freadseek (stdin, strlen (stdin_contents) - position) == 0); + ASSERT (fgetc (stdin) == EOF); + ASSERT (!ferror (stdin)); + +#if !defined __MINT__ /* FreeMiNT has problems seeking past end of file */ + /* Test move beyond end of file. */ + ASSERT (freadseek (stdin, 1000000) == 0); + ASSERT (fgetc (stdin) == EOF); + ASSERT (!ferror (stdin)); +#endif + + free (buf7); + free (buf5); + free (buf3); + free (buf1); + + return 0; +} diff --git a/gnulib-tests/test-freadseek.sh b/gnulib-tests/test-freadseek.sh new file mode 100755 index 0000000..8925204 --- /dev/null +++ b/gnulib-tests/test-freadseek.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +${CHECKER} ./test-freadseek${EXEEXT} 5 19 6 7 18 9 19 < "$srcdir/test-freadseek.sh" || exit 1 +cat "$srcdir/test-freadseek.sh" | ${CHECKER} ./test-freadseek${EXEEXT} 5 19 6 7 18 9 19 || exit 1 +exit 0 diff --git a/gnulib-tests/test-freopen-safer.c b/gnulib-tests/test-freopen-safer.c new file mode 100644 index 0000000..de696fa --- /dev/null +++ b/gnulib-tests/test-freopen-safer.c @@ -0,0 +1,97 @@ +/* Test of reopening a stream. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +/* Specification. */ +#include "stdio--.h" + +/* Helpers. */ +#include <unistd.h> + +/* This test intentionally closes stderr. So, we arrange to have fd 10 + (outside the range of interesting fd's during the test) set up to + duplicate the original stderr. */ + +#define BACKUP_STDERR_FILENO 10 +#define ASSERT_STREAM myerr +#include "macros.h" + +static FILE *myerr; + +int +main (void) +{ + FILE *fp; + + /* We close fd 2 later, so save it in fd 10. */ + if (dup2 (STDERR_FILENO, BACKUP_STDERR_FILENO) != BACKUP_STDERR_FILENO + || (myerr = fdopen (BACKUP_STDERR_FILENO, "w")) == NULL) + return 2; + + { + FILE *tmp; + ASSERT (tmp = fopen ("/dev/null", "r")); + ASSERT (STDERR_FILENO < fileno (tmp)); + ASSERT (fp = fopen ("/dev/null", "w")); + ASSERT (fileno (tmp) < fileno (fp)); + ASSERT (fclose (tmp) == 0); + } + + /* Gap in fds. */ + ASSERT (freopen ("/dev/null", "r+", fp) == fp); + ASSERT (STDERR_FILENO < fileno (fp)); + + ASSERT (freopen ("/dev/null", "r", stdin) == stdin); + ASSERT (STDIN_FILENO == fileno (stdin)); + + ASSERT (freopen ("/dev/null", "w", stdout) == stdout); + ASSERT (STDOUT_FILENO == fileno (stdout)); + + ASSERT (freopen ("/dev/null", "w", stderr) == stderr); + ASSERT (STDERR_FILENO == fileno (stderr)); + + /* fd 0 closed. */ + ASSERT (close (STDIN_FILENO) == 0); + + ASSERT (freopen ("/dev/null", "w", stdout) == stdout); + ASSERT (STDOUT_FILENO == fileno (stdout)); + + ASSERT (freopen ("/dev/null", "w", stderr) == stderr); + ASSERT (STDERR_FILENO == fileno (stderr)); + + ASSERT (freopen ("/dev/null", "a", fp) == fp); + ASSERT (STDERR_FILENO < fileno (fp)); + + /* fd 1 closed. */ + ASSERT (close (STDOUT_FILENO) == 0); + + ASSERT (freopen ("/dev/null", "w", stderr) == stderr); + ASSERT (STDERR_FILENO == fileno (stderr)); + + ASSERT (freopen ("/dev/null", "a+", fp) == fp); + ASSERT (STDERR_FILENO < fileno (fp)); + + /* fd 2 closed. */ + ASSERT (close (STDERR_FILENO) == 0); + + ASSERT (freopen ("/dev/null", "w+", fp) == fp); + ASSERT (STDERR_FILENO < fileno (fp)); + + return 0; +} diff --git a/gnulib-tests/test-freopen.c b/gnulib-tests/test-freopen.c new file mode 100644 index 0000000..b609208 --- /dev/null +++ b/gnulib-tests/test-freopen.c @@ -0,0 +1,86 @@ +/* Test of opening a file stream. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (freopen, FILE *, (char const *, char const *, FILE *)); + +#include <errno.h> +#include <unistd.h> + +#include "macros.h" + +int +main () +{ + const char *filename = "test-freopen.txt"; + + close (STDIN_FILENO); + ASSERT (freopen ("/dev/null", "r", stdin) != NULL); + ASSERT (getchar () == EOF); + ASSERT (!ferror (stdin)); + ASSERT (feof (stdin)); + +#if 0 /* freopen (NULL, ...) is unsupported on most platforms. */ + /* Test that freopen() sets errno if someone else closes the stream + fd behind the back of stdio. */ + { + FILE *fp = fopen (filename, "w+"); + ASSERT (fp != NULL); + ASSERT (close (fileno (fp)) == 0); + errno = 0; + ASSERT (freopen (NULL, "r", fp) == NULL); + perror("freopen"); + ASSERT (errno == EBADF); + fclose (fp); + } + + /* Test that freopen() sets errno if the stream was constructed with + an invalid file descriptor. */ + { + FILE *fp = fdopen (-1, "w+"); + if (fp != NULL) + { + errno = 0; + ASSERT (freopen (NULL, "r", fp) == NULL); + ASSERT (errno == EBADF); + fclose (fp); + } + } + { + FILE *fp; + close (99); + fp = fdopen (99, "w+"); + if (fp != NULL) + { + errno = 0; + ASSERT (freopen (NULL, "r", fp) == NULL); + ASSERT (errno == EBADF); + fclose (fp); + } + } +#endif + + /* Clean up. */ + unlink (filename); + + return 0; +} diff --git a/gnulib-tests/test-frexp.c b/gnulib-tests/test-frexp.c new file mode 100644 index 0000000..c503847 --- /dev/null +++ b/gnulib-tests/test-frexp.c @@ -0,0 +1,67 @@ +/* Test of splitting a double into fraction and mantissa. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <math.h> + +#include "signature.h" +SIGNATURE_CHECK (frexp, double, (double, int *)); + +#include <float.h> + +#include "isnand-nolibm.h" +#include "minus-zero.h" +#include "infinity.h" +#include "nan.h" +#include "macros.h" + +/* Avoid some warnings from "gcc -Wshadow". + This file doesn't use the exp() function. */ +#undef exp +#define exp exponent + +#undef INFINITY +#undef NAN + +#define DOUBLE double +/* The use of 'volatile' guarantees that excess precision bits are dropped + when dealing with denormalized numbers. It is necessary on x86 systems + where double-floats are not IEEE compliant by default, to avoid that the + results become platform and compiler option dependent. 'volatile' is a + portable alternative to gcc's -ffloat-store option. */ +#define VOLATILE volatile +#define ISNAN isnand +#define INFINITY Infinityd () +#define NAN NaNd () +#define L_(literal) literal +#define MINUS_ZERO minus_zerod +#define MAX_EXP DBL_MAX_EXP +#define MIN_EXP DBL_MIN_EXP +#define MIN_NORMAL_EXP DBL_MIN_EXP +#define FREXP frexp +#define RANDOM randomd +#include "test-frexp.h" + +int +main () +{ + test_function (); + + return 0; +} diff --git a/gnulib-tests/test-frexp.h b/gnulib-tests/test-frexp.h new file mode 100644 index 0000000..9b54da3 --- /dev/null +++ b/gnulib-tests/test-frexp.h @@ -0,0 +1,179 @@ +/* Test of splitting a double into fraction and mantissa. + Copyright (C) 2012-2020 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 <https://www.gnu.org/licenses/>. */ + +static DOUBLE +my_ldexp (DOUBLE x, int d) +{ + for (; d > 0; d--) + x *= L_(2.0); + for (; d < 0; d++) + x *= L_(0.5); + return x; +} + +static void +test_function (void) +{ + int i; + VOLATILE DOUBLE x; + + { /* NaN. */ + int exp = -9999; + DOUBLE mantissa; + x = NAN; + mantissa = FREXP (x, &exp); + ASSERT (ISNAN (mantissa)); + } + + { /* Positive infinity. */ + int exp = -9999; + DOUBLE mantissa; + x = INFINITY; + mantissa = FREXP (x, &exp); + ASSERT (mantissa == x); + } + + { /* Negative infinity. */ + int exp = -9999; + DOUBLE mantissa; + x = - INFINITY; + mantissa = FREXP (x, &exp); + ASSERT (mantissa == x); + } + + { /* Positive zero. */ + int exp = -9999; + DOUBLE mantissa; + x = L_(0.0); + mantissa = FREXP (x, &exp); + ASSERT (exp == 0); + ASSERT (mantissa == x); + ASSERT (!signbit (mantissa)); + } + + { /* Negative zero. */ + int exp = -9999; + DOUBLE mantissa; + x = MINUS_ZERO; + mantissa = FREXP (x, &exp); + ASSERT (exp == 0); + ASSERT (mantissa == x); + ASSERT (signbit (mantissa)); + } + + for (i = 1, x = L_(1.0); i <= MAX_EXP; i++, x *= L_(2.0)) + { + int exp = -9999; + DOUBLE mantissa = FREXP (x, &exp); + ASSERT (exp == i); + ASSERT (mantissa == L_(0.5)); + } + for (i = 1, x = L_(1.0); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5)) + { + int exp = -9999; + DOUBLE mantissa = FREXP (x, &exp); + ASSERT (exp == i); + ASSERT (mantissa == L_(0.5)); + } + for (; i >= MIN_EXP - 100 && x > L_(0.0); i--, x *= L_(0.5)) + { + int exp = -9999; + DOUBLE mantissa = FREXP (x, &exp); + ASSERT (exp == i); + ASSERT (mantissa == L_(0.5)); + } + + for (i = 1, x = - L_(1.0); i <= MAX_EXP; i++, x *= L_(2.0)) + { + int exp = -9999; + DOUBLE mantissa = FREXP (x, &exp); + ASSERT (exp == i); + ASSERT (mantissa == - L_(0.5)); + } + for (i = 1, x = - L_(1.0); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5)) + { + int exp = -9999; + DOUBLE mantissa = FREXP (x, &exp); + ASSERT (exp == i); + ASSERT (mantissa == - L_(0.5)); + } + for (; i >= MIN_EXP - 100 && x < L_(0.0); i--, x *= L_(0.5)) + { + int exp = -9999; + DOUBLE mantissa = FREXP (x, &exp); + ASSERT (exp == i); + ASSERT (mantissa == - L_(0.5)); + } + + for (i = 1, x = L_(1.01); i <= MAX_EXP; i++, x *= L_(2.0)) + { + int exp = -9999; + DOUBLE mantissa = FREXP (x, &exp); + ASSERT (exp == i); + ASSERT (mantissa == L_(0.505)); + } + for (i = 1, x = L_(1.01); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5)) + { + int exp = -9999; + DOUBLE mantissa = FREXP (x, &exp); + ASSERT (exp == i); + ASSERT (mantissa == L_(0.505)); + } + for (; i >= MIN_EXP - 100 && x > L_(0.0); i--, x *= L_(0.5)) + { + int exp = -9999; + DOUBLE mantissa = FREXP (x, &exp); + ASSERT (exp == i); + ASSERT (mantissa >= L_(0.5)); + ASSERT (mantissa < L_(1.0)); + ASSERT (mantissa == my_ldexp (x, - exp)); + } + + for (i = 1, x = L_(1.73205); i <= MAX_EXP; i++, x *= L_(2.0)) + { + int exp = -9999; + DOUBLE mantissa = FREXP (x, &exp); + ASSERT (exp == i); + ASSERT (mantissa == L_(0.866025)); + } + for (i = 1, x = L_(1.73205); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5)) + { + int exp = -9999; + DOUBLE mantissa = FREXP (x, &exp); + ASSERT (exp == i); + ASSERT (mantissa == L_(0.866025)); + } + for (; i >= MIN_EXP - 100 && x > L_(0.0); i--, x *= L_(0.5)) + { + int exp = -9999; + DOUBLE mantissa = FREXP (x, &exp); + ASSERT (exp == i || exp == i + 1); + ASSERT (mantissa >= L_(0.5)); + ASSERT (mantissa < L_(1.0)); + ASSERT (mantissa == my_ldexp (x, - exp)); + } + + /* Randomized tests. */ + for (i = 0; i < SIZEOF (RANDOM); i++) + { + x = L_(20.0) * RANDOM[i] - L_(10.0); /* -10.0 <= x <= 10.0 */ + { + int exp = -9999; + DOUBLE mantissa = FREXP (x, &exp); + ASSERT (x == my_ldexp (mantissa, exp)); + } + } +} diff --git a/gnulib-tests/test-frexpl.c b/gnulib-tests/test-frexpl.c new file mode 100644 index 0000000..bed1802 --- /dev/null +++ b/gnulib-tests/test-frexpl.c @@ -0,0 +1,78 @@ +/* Test of splitting a 'long double' into fraction and mantissa. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <math.h> + +#include "signature.h" +SIGNATURE_CHECK (frexpl, long double, (long double, int *)); + +#include <float.h> + +#include "fpucw.h" +#include "isnanl-nolibm.h" +#include "minus-zero.h" +#include "infinity.h" +#include "nan.h" +#include "macros.h" + +/* Avoid some warnings from "gcc -Wshadow". + This file doesn't use the exp() function. */ +#undef exp +#define exp exponent + +#undef INFINITY +#undef NAN + +#define DOUBLE long double +#define VOLATILE +#define ISNAN isnanl +#define INFINITY Infinityl () +#define NAN NaNl () +#define L_(literal) literal##L +#define MINUS_ZERO minus_zerol +#define MAX_EXP LDBL_MAX_EXP +#define MIN_EXP LDBL_MIN_EXP +/* On MIPS IRIX machines, LDBL_MIN_EXP is -1021, but the smallest reliable + exponent for 'long double' is -964. Similarly, on PowerPC machines, + LDBL_MIN_EXP is -1021, but the smallest reliable exponent for 'long double' + is -968. For exponents below that, the precision may be truncated to the + precision used for 'double'. */ +#ifdef __sgi +# define MIN_NORMAL_EXP (LDBL_MIN_EXP + 57) +#elif defined __ppc || defined __ppc__ || defined __powerpc || defined __powerpc__ +# define MIN_NORMAL_EXP (LDBL_MIN_EXP + 53) +#else +# define MIN_NORMAL_EXP LDBL_MIN_EXP +#endif +#define FREXP frexpl +#define RANDOM randoml +#include "test-frexp.h" + +int +main () +{ + DECL_LONG_DOUBLE_ROUNDING + + BEGIN_LONG_DOUBLE_ROUNDING (); + + test_function (); + + return 0; +} diff --git a/gnulib-tests/test-fseek.c b/gnulib-tests/test-fseek.c new file mode 100644 index 0000000..ae653a7 --- /dev/null +++ b/gnulib-tests/test-fseek.c @@ -0,0 +1,70 @@ +/* Test of fseek() function. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +/* None of the files accessed by this test are large, so disable the + fseek link warning if the user requested GNULIB_POSIXCHECK. */ +#define _GL_NO_LARGE_FILES +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (fseek, int, (FILE *, long, int)); + +#include "macros.h" + +#ifndef FUNC_UNGETC_BROKEN +# define FUNC_UNGETC_BROKEN 0 +#endif + +int +main (int argc, char **argv) +{ + /* Assume stdin is non-empty, seekable, and starts with '#!/bin/sh' + iff argc > 1. */ + int expected = argc > 1 ? 0 : -1; + ASSERT (fseek (stdin, 0, SEEK_CUR) == expected); + if (argc > 1) + { + /* Test that fseek discards previously read ungetc data. */ + int ch = fgetc (stdin); + ASSERT (ch == '#'); + ASSERT (ungetc (ch, stdin) == ch); + ASSERT (fseek (stdin, 2, SEEK_SET) == 0); + ch = fgetc (stdin); + ASSERT (ch == '/'); + if (2 < argc) + { + if (FUNC_UNGETC_BROKEN) + { + fputs ("Skipping test: ungetc cannot handle arbitrary bytes\n", + stderr); + return 77; + } + /* Test that fseek discards random ungetc data. */ + ASSERT (ungetc (ch ^ 0xff, stdin) == (ch ^ 0xff)); + } + ASSERT (fseek (stdin, 0, SEEK_END) == 0); + ASSERT (fgetc (stdin) == EOF); + /* Test that fseek resets end-of-file marker. */ + ASSERT (feof (stdin)); + ASSERT (fseek (stdin, 0, SEEK_END) == 0); + ASSERT (!feof (stdin)); + } + return 0; +} diff --git a/gnulib-tests/test-fseek.sh b/gnulib-tests/test-fseek.sh new file mode 100755 index 0000000..4ad3fda --- /dev/null +++ b/gnulib-tests/test-fseek.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +${CHECKER} ./test-fseek${EXEEXT} 1 < "$srcdir/test-fseek.sh" || exit 1 +echo hi | ${CHECKER} ./test-fseek${EXEEXT} || exit 1 +exit 0 diff --git a/gnulib-tests/test-fseek2.sh b/gnulib-tests/test-fseek2.sh new file mode 100755 index 0000000..beadc98 --- /dev/null +++ b/gnulib-tests/test-fseek2.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +exec ${CHECKER} ./test-fseek${EXEEXT} 1 2 < "$srcdir/test-fseek2.sh" diff --git a/gnulib-tests/test-fseeko.c b/gnulib-tests/test-fseeko.c new file mode 100644 index 0000000..2452999 --- /dev/null +++ b/gnulib-tests/test-fseeko.c @@ -0,0 +1,74 @@ +/* Test of fseeko() function. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +/* None of the files accessed by this test are large, so disable the + fseek link warning if we are not using the gnulib fseek module. */ +#define _GL_NO_LARGE_FILES +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (fseeko, int, (FILE *, off_t, int)); + + +#include "macros.h" + +#ifndef FUNC_UNGETC_BROKEN +# define FUNC_UNGETC_BROKEN 0 +#endif + +int +main (int argc, char **argv _GL_UNUSED) +{ + /* Assume stdin is non-empty, seekable, and starts with '#!/bin/sh' + iff argc > 1. */ + int expected = argc > 1 ? 0 : -1; + /* Exit with success only if fseek/fseeko agree. */ + int r1 = fseeko (stdin, 0, SEEK_CUR); + int r2 = fseek (stdin, 0, SEEK_CUR); + ASSERT (r1 == r2 && r1 == expected); + if (argc > 1) + { + /* Test that fseek discards previously read ungetc data. */ + int ch = fgetc (stdin); + ASSERT (ch == '#'); + ASSERT (ungetc (ch, stdin) == ch); + ASSERT (fseeko (stdin, 2, SEEK_SET) == 0); + ch = fgetc (stdin); + ASSERT (ch == '/'); + if (2 < argc) + { + if (FUNC_UNGETC_BROKEN) + { + fputs ("Skipping test: ungetc cannot handle arbitrary bytes\n", + stderr); + return 77; + } + /* Test that fseek discards random ungetc data. */ + ASSERT (ungetc (ch ^ 0xff, stdin) == (ch ^ 0xff)); + } + ASSERT (fseeko (stdin, 0, SEEK_END) == 0); + ASSERT (fgetc (stdin) == EOF); + /* Test that fseek resets end-of-file marker. */ + ASSERT (feof (stdin)); + ASSERT (fseeko (stdin, 0, SEEK_END) == 0); + ASSERT (!feof (stdin)); + } + return 0; +} diff --git a/gnulib-tests/test-fseeko.sh b/gnulib-tests/test-fseeko.sh new file mode 100755 index 0000000..c7b675e --- /dev/null +++ b/gnulib-tests/test-fseeko.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +${CHECKER} ./test-fseeko${EXEEXT} 1 < "$srcdir/test-fseeko.sh" || exit 1 +echo hi | ${CHECKER} ./test-fseeko${EXEEXT} || exit 1 +exit 0 diff --git a/gnulib-tests/test-fseeko2.sh b/gnulib-tests/test-fseeko2.sh new file mode 100755 index 0000000..7bf315e --- /dev/null +++ b/gnulib-tests/test-fseeko2.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +exec ${CHECKER} ./test-fseeko${EXEEXT} 1 2 < "$srcdir/test-fseeko2.sh" diff --git a/gnulib-tests/test-fseeko3.c b/gnulib-tests/test-fseeko3.c new file mode 100644 index 0000000..78b79c6 --- /dev/null +++ b/gnulib-tests/test-fseeko3.c @@ -0,0 +1,51 @@ +/* Test of fseeko() function. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <eblake@redhat.com>, 2011. */ + +#include <config.h> + +#include <stdio.h> + +#include <stdlib.h> + +#include "macros.h" + +int +main (int argc, char **argv) +{ + int do_initial_ftell = atoi (argv[1]); + const char *filename = argv[2]; + FILE *fp = fopen (filename, "r"); + ASSERT (fp != NULL); + + if (do_initial_ftell) + { + off_t pos = ftell (fp); + ASSERT (pos == 0); + } + + ASSERT (fseeko (fp, 0, SEEK_END) == 0); + + { + off_t pos = ftell (fp); + ASSERT (pos > 0); + } + + ASSERT (fclose (fp) == 0); + + return 0; +} diff --git a/gnulib-tests/test-fseeko3.sh b/gnulib-tests/test-fseeko3.sh new file mode 100755 index 0000000..254d0cb --- /dev/null +++ b/gnulib-tests/test-fseeko3.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +${CHECKER} ./test-fseeko3${EXEEXT} 0 "$srcdir/test-fseeko3.sh" || exit 1 + +${CHECKER} ./test-fseeko3${EXEEXT} 1 "$srcdir/test-fseeko3.sh" || exit 1 + +exit 0 diff --git a/gnulib-tests/test-fseeko4.c b/gnulib-tests/test-fseeko4.c new file mode 100644 index 0000000..5e19c27 --- /dev/null +++ b/gnulib-tests/test-fseeko4.c @@ -0,0 +1,73 @@ +/* Test of fseeko() function. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdio.h> + +#include <errno.h> +#include <unistd.h> + +#include "macros.h" + +int +main (int argc, char **argv) +{ + const char *filename = argv[1]; + + /* Test that fseeko() sets errno if someone else closes the stream + fd behind the back of stdio. */ + { + FILE *fp = fopen (filename, "r"); + ASSERT (fp != NULL); + setvbuf (fp, NULL, _IONBF, 0); + ASSERT (ftell (fp) == 0); + ASSERT (fseeko (fp, 0, SEEK_END) == 0); + ASSERT (ftell (fp) > 0); + ASSERT (close (fileno (fp)) == 0); + errno = 0; + ASSERT (fseeko (fp, 0, SEEK_SET) == -1); + ASSERT (errno == EBADF); + fclose (fp); + } + + /* Test that fseeko() sets errno if the stream was constructed with + an invalid file descriptor. */ + { + FILE *fp = fdopen (-1, "w"); + if (fp != NULL) + { + errno = 0; + ASSERT (fseeko (fp, 0, SEEK_END) == -1); + ASSERT (errno == EBADF); + fclose (fp); + } + } + { + FILE *fp; + close (99); + fp = fdopen (99, "w"); + if (fp != NULL) + { + errno = 0; + ASSERT (fseeko (fp, 0, SEEK_END) == -1); + ASSERT (errno == EBADF); + fclose (fp); + } + } + + return 0; +} diff --git a/gnulib-tests/test-fseeko4.sh b/gnulib-tests/test-fseeko4.sh new file mode 100755 index 0000000..7a4d352 --- /dev/null +++ b/gnulib-tests/test-fseeko4.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +${CHECKER} ./test-fseeko4${EXEEXT} "$srcdir/test-fseeko4.sh" || exit 1 + +exit 0 diff --git a/gnulib-tests/test-fseterr.c b/gnulib-tests/test-fseterr.c new file mode 100644 index 0000000..cb042c1 --- /dev/null +++ b/gnulib-tests/test-fseterr.c @@ -0,0 +1,44 @@ +/* Test setting the error indicator of a stream. + Copyright (C) 2007, 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include "fseterr.h" + +#include <stdio.h> +#include <stdlib.h> + +int +main () +{ + /* All streams are initially created with the error indicator cleared. */ + if (ferror (stdout)) + abort (); + + /* Verify that fseterr() works. */ + fseterr (stdout); + if (!ferror (stdout)) + abort (); + + /* Verify fseterr's effect can be undone by clearerr(). */ + clearerr (stdout); + if (ferror (stdout)) + abort (); + + return 0; +} diff --git a/gnulib-tests/test-fstat.c b/gnulib-tests/test-fstat.c new file mode 100644 index 0000000..621498c --- /dev/null +++ b/gnulib-tests/test-fstat.c @@ -0,0 +1,50 @@ +/* Tests of fstat() function. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <sys/stat.h> + +#include "signature.h" +SIGNATURE_CHECK (fstat, int, (int, struct stat *)); + +#include <errno.h> +#include <unistd.h> + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + /* Test behaviour for invalid file descriptors. */ + { + struct stat statbuf; + + errno = 0; + ASSERT (fstat (-1, &statbuf) == -1); + ASSERT (errno == EBADF); + } + { + struct stat statbuf; + + close (99); + errno = 0; + ASSERT (fstat (99, &statbuf) == -1); + ASSERT (errno == EBADF); + } + + return 0; +} diff --git a/gnulib-tests/test-fstatat.c b/gnulib-tests/test-fstatat.c new file mode 100644 index 0000000..f0f12b5 --- /dev/null +++ b/gnulib-tests/test-fstatat.c @@ -0,0 +1,108 @@ +/* Tests of fstatat. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <sys/stat.h> + +#include "signature.h" +SIGNATURE_CHECK (fstatat, int, (int, char const *, struct stat *, int)); + +#include <fcntl.h> +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "openat.h" +#include "same-inode.h" +#include "ignore-value.h" +#include "macros.h" + +#ifndef BASE +# define BASE "test-fstatat.t" +#endif + +#include "test-lstat.h" +#include "test-stat.h" + +static int dfd = AT_FDCWD; + +/* Wrapper around fstatat to test stat behavior. */ +static int +do_stat (char const *name, struct stat *st) +{ +#ifdef TEST_STATAT + return statat (dfd, name, st); +#else + return fstatat (dfd, name, st, 0); +#endif +} + +/* Wrapper around fstatat to test lstat behavior. */ +static int +do_lstat (char const *name, struct stat *st) +{ +#ifdef TEST_STATAT + return lstatat (dfd, name, st); +#else + return fstatat (dfd, name, st, AT_SYMLINK_NOFOLLOW); +#endif +} + +int +main (int argc _GL_UNUSED, char *argv[]) +{ + int result; + + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + /* Test behaviour for invalid file descriptors. */ + { + struct stat statbuf; + + errno = 0; + ASSERT (fstatat (-1, "foo", &statbuf, 0) == -1); + ASSERT (errno == EBADF); + } + { + struct stat statbuf; + + close (99); + errno = 0; + ASSERT (fstatat (99, "foo", &statbuf, 0) == -1); + ASSERT (errno == EBADF); + } + + result = test_stat_func (do_stat, false); + ASSERT (test_lstat_func (do_lstat, false) == result); + dfd = open (".", O_RDONLY); + ASSERT (0 <= dfd); + ASSERT (test_stat_func (do_stat, false) == result); + ASSERT (test_lstat_func (do_lstat, false) == result); + ASSERT (close (dfd) == 0); + + /* FIXME - add additional tests of dfd not at current directory. */ + + if (result == 77) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return result; +} diff --git a/gnulib-tests/test-fsync.c b/gnulib-tests/test-fsync.c new file mode 100644 index 0000000..2e0381b --- /dev/null +++ b/gnulib-tests/test-fsync.c @@ -0,0 +1,83 @@ +/* Test of fsync() function. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (fsync, int, (int)); + +#include <errno.h> +#include <fcntl.h> + +#include "macros.h" + +int +main (void) +{ + int fd; + const char *file = "test-fsync.txt"; + + /* Assuming stdin and stdout are ttys, fsync is allowed to fail, but + may succeed as an extension. */ + for (fd = 0; fd < 2; fd++) + if (fsync (fd) != 0) + { + ASSERT (errno == EINVAL /* POSIX */ + || errno == ENOTSUP /* seen on Mac OS X 10.5 */ + || errno == EBADF /* seen on AIX 7.1 */ + || errno == EIO /* seen on mingw */ + ); + } + + /* fsync must fail on invalid fd. */ + { + errno = 0; + ASSERT (fsync (-1) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (fsync (99) == -1); + ASSERT (errno == EBADF); + } + + fd = open (file, O_WRONLY|O_CREAT|O_TRUNC, 0644); + ASSERT (0 <= fd); + ASSERT (write (fd, "hello", 5) == 5); + ASSERT (fsync (fd) == 0); + ASSERT (close (fd) == 0); + + /* For a read-only regular file input file descriptor, fsync should + succeed (since at least atime changes can be synchronized). + On AIX and Cygwin, this test would fail. */ +#if !(defined _AIX || defined __CYGWIN__) + fd = open (file, O_RDONLY); + ASSERT (0 <= fd); + { + char buf[1]; + ASSERT (read (fd, buf, sizeof buf) == sizeof buf); + } + ASSERT (fsync (fd) == 0); + ASSERT (close (fd) == 0); +#endif + + ASSERT (unlink (file) == 0); + + return 0; +} diff --git a/gnulib-tests/test-ftell.c b/gnulib-tests/test-ftell.c new file mode 100644 index 0000000..859fec7 --- /dev/null +++ b/gnulib-tests/test-ftell.c @@ -0,0 +1,107 @@ +/* Test of ftell() function. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +/* None of the files accessed by this test are large, so disable the + fseek link warning if we are not using the gnulib fseek module. */ +#define _GL_NO_LARGE_FILES +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (ftell, long, (FILE *)); + +#include "binary-io.h" +#include "macros.h" + +#ifndef FUNC_UNGETC_BROKEN +# define FUNC_UNGETC_BROKEN 0 +#endif + +int +main (int argc, char **argv) +{ + int ch; + /* Assume stdin is seekable iff argc > 1. */ + if (argc == 1) + { + ASSERT (ftell (stdin) == -1); + return 0; + } + + /* mingw ftell is unreliable on text mode input. */ + set_binary_mode (0, O_BINARY); + + /* Simple tests. */ + ASSERT (ftell (stdin) == 0); + + ch = fgetc (stdin); + ASSERT (ch == '#'); + ASSERT (ftell (stdin) == 1); + + /* Test ftell after ungetc of read input. */ + ch = ungetc ('#', stdin); + ASSERT (ch == '#'); + ASSERT (ftell (stdin) == 0); + + ch = fgetc (stdin); + ASSERT (ch == '#'); + ASSERT (ftell (stdin) == 1); + + /* Test ftell after fseek. */ + ASSERT (fseek (stdin, 2, SEEK_SET) == 0); + ASSERT (ftell (stdin) == 2); + + /* Test ftell after random ungetc. */ + ch = fgetc (stdin); + ASSERT (ch == '/'); + ch = ungetc ('@', stdin); + ASSERT (ch == '@'); + ASSERT (ftell (stdin) == 2); + + ch = fgetc (stdin); + ASSERT (ch == '@'); + ASSERT (ftell (stdin) == 3); + + if (2 < argc) + { + if (FUNC_UNGETC_BROKEN) + { + fputs ("Skipping test: ungetc cannot handle arbitrary bytes\n", + stderr); + return 77; + } + /* Test ftell after ungetc without read. */ + ASSERT (fseek (stdin, 0, SEEK_CUR) == 0); + ASSERT (ftell (stdin) == 3); + + ch = ungetc ('~', stdin); + ASSERT (ch == '~'); + ASSERT (ftell (stdin) == 2); + } + +#if !defined __MINT__ /* FreeMiNT has problems seeking past end of file */ + /* Test ftell beyond end of file. */ + ASSERT (fseek (stdin, 0, SEEK_END) == 0); + ch = ftell (stdin); + ASSERT (fseek (stdin, 10, SEEK_END) == 0); + ASSERT (ftell (stdin) == ch + 10); +#endif + + return 0; +} diff --git a/gnulib-tests/test-ftell.sh b/gnulib-tests/test-ftell.sh new file mode 100755 index 0000000..5c27808 --- /dev/null +++ b/gnulib-tests/test-ftell.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +${CHECKER} ./test-ftell${EXEEXT} 1 < "$srcdir/test-ftell.sh" || exit 1 +echo hi | ${CHECKER} ./test-ftell${EXEEXT} || exit 1 +exit 0 diff --git a/gnulib-tests/test-ftell2.sh b/gnulib-tests/test-ftell2.sh new file mode 100755 index 0000000..7d116d2 --- /dev/null +++ b/gnulib-tests/test-ftell2.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +exec ${CHECKER} ./test-ftell${EXEEXT} 1 2 < "$srcdir/test-ftell2.sh" diff --git a/gnulib-tests/test-ftell3.c b/gnulib-tests/test-ftell3.c new file mode 100644 index 0000000..1feafcb --- /dev/null +++ b/gnulib-tests/test-ftell3.c @@ -0,0 +1,78 @@ +/* Test of ftell() function. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +/* None of the files accessed by this test are large, so disable the + fseek link warning if we are not using the gnulib fseek module. */ +#define _GL_NO_LARGE_FILES +#include <stdio.h> + +#include <string.h> + +#include "macros.h" + +#define TESTFILE "t-ftell3.tmp" + +int +main (void) +{ + FILE *fp; + + /* Create a file with some contents. */ + fp = fopen (TESTFILE, "w"); + if (fp == NULL) + goto skip; + if (fwrite ("foogarsh", 1, 8, fp) < 8) + goto skip; + if (fclose (fp)) + goto skip; + + /* The file's contents is now "foogarsh". */ + + /* Try writing after reading to EOF. */ + fp = fopen (TESTFILE, "r+"); + if (fp == NULL) + goto skip; + if (fseek (fp, -1, SEEK_END)) + goto skip; + ASSERT (getc (fp) == 'h'); + ASSERT (getc (fp) == EOF); + ASSERT (ftell (fp) == 8); + ASSERT (ftell (fp) == 8); + ASSERT (putc ('!', fp) == '!'); + ASSERT (ftell (fp) == 9); + ASSERT (fclose (fp) == 0); + fp = fopen (TESTFILE, "r"); + if (fp == NULL) + goto skip; + { + char buf[10]; + ASSERT (fread (buf, 1, 10, fp) == 9); + ASSERT (memcmp (buf, "foogarsh!", 9) == 0); + } + ASSERT (fclose (fp) == 0); + + /* The file's contents is now "foogarsh!". */ + + remove (TESTFILE); + return 0; + + skip: + fprintf (stderr, "Skipping test: prerequisite file operations failed.\n"); + remove (TESTFILE); + return 77; +} diff --git a/gnulib-tests/test-ftello.c b/gnulib-tests/test-ftello.c new file mode 100644 index 0000000..71936a1 --- /dev/null +++ b/gnulib-tests/test-ftello.c @@ -0,0 +1,118 @@ +/* Test of ftello() function. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +/* None of the files accessed by this test are large, so disable the + fseek link warning if we are not using the gnulib fseek module. */ +#define _GL_NO_LARGE_FILES +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (ftello, off_t, (FILE *)); + +#include "binary-io.h" +#include "macros.h" + +#ifndef FUNC_UNGETC_BROKEN +# define FUNC_UNGETC_BROKEN 0 +#endif + +int +main (int argc, char **argv _GL_UNUSED) +{ + int ch; + /* Assume stdin is seekable iff argc > 1. */ + if (argc == 1) + { + ASSERT (ftell (stdin) == -1); + ASSERT (ftello (stdin) == -1); + return 0; + } + + /* mingw ftell is unreliable on text mode input. */ + set_binary_mode (0, O_BINARY); + + /* Simple tests. For each test, make sure ftell and ftello agree. */ + ASSERT (ftell (stdin) == 0); + ASSERT (ftello (stdin) == 0); + + ch = fgetc (stdin); + ASSERT (ch == '#'); + ASSERT (ftell (stdin) == 1); + ASSERT (ftello (stdin) == 1); + + /* Test ftell after ungetc of read input. */ + ch = ungetc ('#', stdin); + ASSERT (ch == '#'); + ASSERT (ftell (stdin) == 0); + ASSERT (ftello (stdin) == 0); + + ch = fgetc (stdin); + ASSERT (ch == '#'); + ASSERT (ftell (stdin) == 1); + ASSERT (ftello (stdin) == 1); + + /* Test ftell after fseek. */ + ASSERT (fseek (stdin, 2, SEEK_SET) == 0); + ASSERT (ftell (stdin) == 2); + ASSERT (ftello (stdin) == 2); + + /* Test ftell after random ungetc. */ + ch = fgetc (stdin); + ASSERT (ch == '/'); + ch = ungetc ('@', stdin); + ASSERT (ch == '@'); + ASSERT (ftell (stdin) == 2); + ASSERT (ftello (stdin) == 2); + + ch = fgetc (stdin); + ASSERT (ch == '@'); + ASSERT (ftell (stdin) == 3); + ASSERT (ftello (stdin) == 3); + + if (2 < argc) + { + if (FUNC_UNGETC_BROKEN) + { + fputs ("Skipping test: ungetc cannot handle arbitrary bytes\n", + stderr); + return 77; + } + /* Test ftell after ungetc without read. */ + ASSERT (fseek (stdin, 0, SEEK_CUR) == 0); + ASSERT (ftell (stdin) == 3); + ASSERT (ftello (stdin) == 3); + + ch = ungetc ('~', stdin); + ASSERT (ch == '~'); + ASSERT (ftell (stdin) == 2); + ASSERT (ftello (stdin) == 2); + } + +#if !defined __MINT__ /* FreeMiNT has problems seeking past end of file */ + /* Test ftell beyond end of file. */ + ASSERT (fseek (stdin, 0, SEEK_END) == 0); + ch = ftello (stdin); + ASSERT (fseek (stdin, 10, SEEK_END) == 0); + ASSERT (ftell (stdin) == ch + 10); + ASSERT (ftello (stdin) == ch + 10); +#endif + + return 0; +} diff --git a/gnulib-tests/test-ftello.sh b/gnulib-tests/test-ftello.sh new file mode 100755 index 0000000..e8db061 --- /dev/null +++ b/gnulib-tests/test-ftello.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +${CHECKER} ./test-ftello${EXEEXT} 1 < "$srcdir/test-ftello.sh" || exit 1 +echo hi | ${CHECKER} ./test-ftello${EXEEXT} || exit 1 +exit 0 diff --git a/gnulib-tests/test-ftello2.sh b/gnulib-tests/test-ftello2.sh new file mode 100755 index 0000000..63a222c --- /dev/null +++ b/gnulib-tests/test-ftello2.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +exec ${CHECKER} ./test-ftello${EXEEXT} 1 2 < "$srcdir/test-ftello2.sh" diff --git a/gnulib-tests/test-ftello3.c b/gnulib-tests/test-ftello3.c new file mode 100644 index 0000000..f693596 --- /dev/null +++ b/gnulib-tests/test-ftello3.c @@ -0,0 +1,78 @@ +/* Test of ftello() function. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +/* None of the files accessed by this test are large, so disable the + fseek link warning if we are not using the gnulib fseek module. */ +#define _GL_NO_LARGE_FILES +#include <stdio.h> + +#include <string.h> + +#include "macros.h" + +#define TESTFILE "t-ftello3.tmp" + +int +main (void) +{ + FILE *fp; + + /* Create a file with some contents. */ + fp = fopen (TESTFILE, "w"); + if (fp == NULL) + goto skip; + if (fwrite ("foogarsh", 1, 8, fp) < 8) + goto skip; + if (fclose (fp)) + goto skip; + + /* The file's contents is now "foogarsh". */ + + /* Try writing after reading to EOF. */ + fp = fopen (TESTFILE, "r+"); + if (fp == NULL) + goto skip; + if (fseek (fp, -1, SEEK_END)) + goto skip; + ASSERT (getc (fp) == 'h'); + ASSERT (getc (fp) == EOF); + ASSERT (ftello (fp) == 8); + ASSERT (ftello (fp) == 8); + ASSERT (putc ('!', fp) == '!'); + ASSERT (ftello (fp) == 9); + ASSERT (fclose (fp) == 0); + fp = fopen (TESTFILE, "r"); + if (fp == NULL) + goto skip; + { + char buf[10]; + ASSERT (fread (buf, 1, 10, fp) == 9); + ASSERT (memcmp (buf, "foogarsh!", 9) == 0); + } + ASSERT (fclose (fp) == 0); + + /* The file's contents is now "foogarsh!". */ + + remove (TESTFILE); + return 0; + + skip: + fprintf (stderr, "Skipping test: prerequisite file operations failed.\n"); + remove (TESTFILE); + return 77; +} diff --git a/gnulib-tests/test-ftello4.c b/gnulib-tests/test-ftello4.c new file mode 100644 index 0000000..54cfe75 --- /dev/null +++ b/gnulib-tests/test-ftello4.c @@ -0,0 +1,70 @@ +/* Test of ftello() function. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdio.h> + +#include <errno.h> +#include <unistd.h> + +#include "macros.h" + +int +main (int argc, char **argv) +{ + const char *filename = argv[1]; + + /* Test that ftello() sets errno if someone else closes the stream + fd behind the back of stdio. */ + { + FILE *fp = fopen (filename, "r"); + ASSERT (fp != NULL); + setvbuf (fp, NULL, _IONBF, 0); + ASSERT (close (fileno (fp)) == 0); + errno = 0; + ASSERT (ftello (fp) == (off_t)-1); + ASSERT (errno == EBADF); + fclose (fp); + } + + /* Test that ftello() sets errno if the stream was constructed with + an invalid file descriptor. */ + { + FILE *fp = fdopen (-1, "w"); + if (fp != NULL) + { + errno = 0; + ASSERT (ftello (fp) == (off_t)-1); + ASSERT (errno == EBADF); + fclose (fp); + } + } + { + FILE *fp; + close (99); + fp = fdopen (99, "w"); + if (fp != NULL) + { + errno = 0; + ASSERT (ftello (fp) == (off_t)-1); + ASSERT (errno == EBADF); + fclose (fp); + } + } + + return 0; +} diff --git a/gnulib-tests/test-ftello4.sh b/gnulib-tests/test-ftello4.sh new file mode 100755 index 0000000..f7ff149 --- /dev/null +++ b/gnulib-tests/test-ftello4.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +${CHECKER} ./test-ftello4${EXEEXT} "$srcdir/test-ftello4.sh" || exit 1 + +exit 0 diff --git a/gnulib-tests/test-ftruncate.c b/gnulib-tests/test-ftruncate.c new file mode 100644 index 0000000..3ad7edd --- /dev/null +++ b/gnulib-tests/test-ftruncate.c @@ -0,0 +1,60 @@ +/* Test truncating a file. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (ftruncate, int, (int, off_t)); + +#include <errno.h> +#include <fcntl.h> + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + const char *filename = argv[1]; + + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (ftruncate (-1, 0) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (ftruncate (99, 0) == -1); + ASSERT (errno == EBADF); + } + + /* Test behaviour for read-only file descriptors. */ + { + int fd = open (filename, O_RDONLY); + ASSERT (fd >= 0); + errno = 0; + ASSERT (ftruncate (fd, 0) == -1); + ASSERT (errno == EBADF || errno == EINVAL + || errno == EACCES /* seen on mingw */ + ); + close (fd); + } + + return 0; +} diff --git a/gnulib-tests/test-ftruncate.sh b/gnulib-tests/test-ftruncate.sh new file mode 100755 index 0000000..203e07b --- /dev/null +++ b/gnulib-tests/test-ftruncate.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +exec ${CHECKER} ./test-ftruncate${EXEEXT} "$srcdir/test-ftruncate.sh" diff --git a/gnulib-tests/test-futimens.c b/gnulib-tests/test-futimens.c new file mode 100644 index 0000000..87cd7a7 --- /dev/null +++ b/gnulib-tests/test-futimens.c @@ -0,0 +1,51 @@ +/* Tests of futimens. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <sys/stat.h> + +#include "signature.h" +SIGNATURE_CHECK (futimens, int, (int, struct timespec const[2])); + +#include <fcntl.h> +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include "stat-time.h" +#include "timespec.h" +#include "utimecmp.h" +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-futimens.t" + +#include "test-futimens.h" + +int +main (void) +{ + /* Clean up any trash from prior testsuite runs. */ + ignore_value (system ("rm -rf " BASE "*")); + + return test_futimens (futimens, true); +} diff --git a/gnulib-tests/test-futimens.h b/gnulib-tests/test-futimens.h new file mode 100644 index 0000000..b5645e6 --- /dev/null +++ b/gnulib-tests/test-futimens.h @@ -0,0 +1,177 @@ +/* Test of file timestamp modification functions. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +#include "test-utimens-common.h" + +/* This file is designed to test both fdutimens(a,NULL,b) and + futimens(a,b). FUNC is the function to test. Assumes that BASE + and ASSERT are already defined. If PRINT, warn before skipping + tests with status 77. */ +static int +test_futimens (int (*func) (int, struct timespec const *), + bool print) +{ + int fd = creat (BASE "file", 0600); + int result; + struct stat st1; + struct stat st2; + ASSERT (0 <= fd); + + /* Sanity check. */ + ASSERT (fstat (fd, &st1) == 0); + nap (); + errno = 0; + result = func (fd, NULL); + if (result == -1 && errno == ENOSYS) + { + ASSERT (close (fd) == 0); + ASSERT (unlink (BASE "file") == 0); + if (print) + fputs ("skipping test: " + "setting fd time not supported on this file system\n", + stderr); + return 77; + } + ASSERT (!result); + ASSERT (fstat (fd, &st2) == 0); + /* If utimens truncates to worse resolution than the file system + supports, then time can appear to go backwards between now and a + follow-up utimens with UTIME_NOW or a NULL timespec. Use + UTIMECMP_TRUNCATE_SOURCE to compensate, with st1 as the + source. */ + ASSERT (0 <= utimecmp (BASE "file", &st2, &st1, UTIMECMP_TRUNCATE_SOURCE)); + if (check_ctime) + ASSERT (ctime_compare (&st1, &st2) < 0); + { + /* On some NFS systems, the 'now' timestamp of creat or a NULL + timespec is determined by the server, but the 'now' timestamp + determined by gettime() (as is done when using UTIME_NOW) is + determined by the client; since the two machines are not + necessarily on the same clock, this is another case where time + can appear to go backwards. The rest of this test cares about + client time, so manually use gettime() to set both times. */ + struct timespec ts[2]; + gettime (&ts[0]); + ts[1] = ts[0]; + ASSERT (func (fd, ts) == 0); + ASSERT (fstat (fd, &st1) == 0); + nap (); + } + + /* Invalid arguments. */ + { + errno = 0; + ASSERT (func (AT_FDCWD, NULL) == -1); + ASSERT (errno == EBADF); + } + { + errno = 0; + ASSERT (func (-1, NULL) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (func (99, NULL) == -1); + ASSERT (errno == EBADF); + } + { + int fd0 = dup (0); + ASSERT (0 <= fd0); + ASSERT (close (fd0) == 0); + errno = 0; + ASSERT (func (fd0, NULL) == -1); + ASSERT (errno == EBADF); + } + { + struct timespec ts[2]; + ts[0].tv_sec = Y2K; + ts[0].tv_nsec = UTIME_BOGUS_POS; + ts[1].tv_sec = Y2K; + ts[1].tv_nsec = 0; + errno = 0; + ASSERT (func (fd, ts) == -1); + ASSERT (errno == EINVAL); + } + { + struct timespec ts[2]; + ts[0].tv_sec = Y2K; + ts[0].tv_nsec = 0; + ts[1].tv_sec = Y2K; + ts[1].tv_nsec = UTIME_BOGUS_NEG; + errno = 0; + ASSERT (func (fd, ts) == -1); + ASSERT (errno == EINVAL); + } + ASSERT (fstat (fd, &st2) == 0); + ASSERT (st1.st_atime == st2.st_atime); + ASSERT (get_stat_atime_ns (&st1) == get_stat_atime_ns (&st2)); + ASSERT (utimecmp (BASE "file", &st1, &st2, 0) == 0); + + /* Set both times. */ + { + struct timespec ts[2]; + ts[0].tv_sec = Y2K; + ts[0].tv_nsec = BILLION / 2 - 1; + ts[1].tv_sec = Y2K; + ts[1].tv_nsec = BILLION - 1; + ASSERT (func (fd, ts) == 0); + ASSERT (fstat (fd, &st2) == 0); + ASSERT (st2.st_atime == Y2K); + ASSERT (0 <= get_stat_atime_ns (&st2)); + ASSERT (get_stat_atime_ns (&st2) < BILLION / 2); + ASSERT (st2.st_mtime == Y2K); + ASSERT (0 <= get_stat_mtime_ns (&st2)); + ASSERT (get_stat_mtime_ns (&st2) < BILLION); + if (check_ctime) + ASSERT (ctime_compare (&st1, &st2) < 0); + } + + /* Play with UTIME_OMIT, UTIME_NOW. */ + { + struct stat st3; + struct timespec ts[2]; + ts[0].tv_sec = BILLION; + ts[0].tv_nsec = UTIME_OMIT; + ts[1].tv_sec = 0; + ts[1].tv_nsec = UTIME_NOW; + nap (); + ASSERT (func (fd, ts) == 0); + ASSERT (fstat (fd, &st3) == 0); + ASSERT (st3.st_atime == Y2K); + ASSERT (0 <= get_stat_atime_ns (&st3)); + ASSERT (get_stat_atime_ns (&st3) <= BILLION / 2); + ASSERT (utimecmp (BASE "file", &st1, &st3, 0) <= 0); + if (check_ctime) + ASSERT (ctime_compare (&st2, &st3) < 0); + nap (); + ts[0].tv_nsec = 0; + ts[1].tv_nsec = UTIME_OMIT; + ASSERT (func (fd, ts) == 0); + ASSERT (fstat (fd, &st2) == 0); + ASSERT (st2.st_atime == BILLION); + ASSERT (get_stat_atime_ns (&st2) == 0); + ASSERT (st3.st_mtime == st2.st_mtime); + ASSERT (get_stat_mtime_ns (&st3) == get_stat_mtime_ns (&st2)); + if (check_ctime) + ASSERT (ctime_compare (&st3, &st2) < 0); + } + + /* Cleanup. */ + ASSERT (close (fd) == 0); + ASSERT (unlink (BASE "file") == 0); + return 0; +} diff --git a/gnulib-tests/test-fwrite.c b/gnulib-tests/test-fwrite.c new file mode 100644 index 0000000..9ff0d07 --- /dev/null +++ b/gnulib-tests/test-fwrite.c @@ -0,0 +1,96 @@ +/* Test of fwrite() function. + Copyright (C) 2011-2020 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, 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (fwrite, size_t, (const void *, size_t, size_t, FILE *)); + +#include <errno.h> +#include <fcntl.h> +#include <unistd.h> + +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER +# include "msvc-inval.h" +#endif + +#include "macros.h" + +int +main (int argc, char **argv) +{ + const char *filename = "test-fwrite.txt"; + + /* We don't have an fwrite() function that installs an invalid parameter + handler so far. So install that handler here, explicitly. */ +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER \ + && MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING + gl_msvc_inval_ensure_handler (); +#endif + + /* Test that fwrite() on an unbuffered stream sets errno if someone else + closes the stream fd behind the back of stdio. */ + { + FILE *fp = fopen (filename, "w"); + char buf[5] = "world"; + ASSERT (fp != NULL); + setvbuf (fp, NULL, _IONBF, 0); + ASSERT (close (fileno (fp)) == 0); + errno = 0; + ASSERT (fwrite (buf, 1, sizeof (buf), fp) == 0); + ASSERT (errno == EBADF); + ASSERT (ferror (fp)); + fclose (fp); + } + + /* Test that fwrite() on an unbuffered stream sets errno if the stream + was constructed with an invalid file descriptor. */ + { + FILE *fp = fdopen (-1, "w"); + if (fp != NULL) + { + char buf[5] = "world"; + setvbuf (fp, NULL, _IONBF, 0); + errno = 0; + ASSERT (fwrite (buf, 1, sizeof (buf), fp) == 0); + ASSERT (errno == EBADF); + ASSERT (ferror (fp)); + fclose (fp); + } + } + { + FILE *fp; + close (99); + fp = fdopen (99, "w"); + if (fp != NULL) + { + char buf[5] = "world"; + setvbuf (fp, NULL, _IONBF, 0); + errno = 0; + ASSERT (fwrite (buf, 1, sizeof (buf), fp) == 0); + ASSERT (errno == EBADF); + ASSERT (ferror (fp)); + fclose (fp); + } + } + + /* Clean up. */ + unlink (filename); + + return 0; +} diff --git a/gnulib-tests/test-getaddrinfo.c b/gnulib-tests/test-getaddrinfo.c new file mode 100644 index 0000000..5b439a9 --- /dev/null +++ b/gnulib-tests/test-getaddrinfo.c @@ -0,0 +1,178 @@ +/* Test the getaddrinfo module. + + Copyright (C) 2006-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Simon Josefsson. */ + +#include <config.h> + +#include <netdb.h> + +#include "signature.h" +SIGNATURE_CHECK (gai_strerror, char const *, (int)); +/* On native Windows, these two functions may have the __stdcall calling + convention. But the SIGNATURE_CHECK works only for functions with __cdecl + calling convention. */ +#if !(defined _WIN32 && !defined __CYGWIN__) +SIGNATURE_CHECK (freeaddrinfo, void, (struct addrinfo *)); +SIGNATURE_CHECK (getaddrinfo, int, (char const *, char const *, + struct addrinfo const *, + struct addrinfo **)); +#endif + +#include <arpa/inet.h> +#include <errno.h> +#include <netinet/in.h> +#include <stdio.h> +#include <string.h> + +#include "sockets.h" + +/* Whether to print debugging messages. */ +#define ENABLE_DEBUGGING 0 + +#if ENABLE_DEBUGGING +# define dbgprintf printf +#else +# define dbgprintf if (0) printf +#endif + +/* BeOS does not have AF_UNSPEC. */ +#ifndef AF_UNSPEC +# define AF_UNSPEC 0 +#endif + +#ifndef EAI_SERVICE +# define EAI_SERVICE 0 +#endif + +static int +simple (char const *host, char const *service) +{ + char buf[BUFSIZ]; + static int skip = 0; + struct addrinfo hints; + struct addrinfo *ai0, *ai; + int res; + int err; + + /* Once we skipped the test, do not try anything else */ + if (skip) + return 0; + + dbgprintf ("Finding %s service %s...\n", host, service); + + /* This initializes "hints" but does not use it. Is there a reason + for this? If so, please fix this comment. */ + memset (&hints, 0, sizeof (hints)); + hints.ai_flags = AI_CANONNAME; + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + + res = getaddrinfo (host, service, 0, &ai0); + err = errno; + + dbgprintf ("res %d: %s\n", res, gai_strerror (res)); + + if (res != 0) + { + /* EAI_AGAIN is returned if no network is available. Don't fail + the test merely because someone is down the country on their + in-law's farm. */ + if (res == EAI_AGAIN) + { + skip++; + fprintf (stderr, "skipping getaddrinfo test: no network?\n"); + return 77; + } + /* IRIX reports EAI_NONAME for "https". Don't fail the test + merely because of this. */ + if (res == EAI_NONAME) + return 0; + /* Solaris reports EAI_SERVICE for "http" and "https". Don't + fail the test merely because of this. */ + if (res == EAI_SERVICE) + return 0; +#ifdef EAI_NODATA + /* AIX reports EAI_NODATA for "https". Don't fail the test + merely because of this. */ + if (res == EAI_NODATA) + return 0; +#endif + /* Provide details if errno was set. */ + if (res == EAI_SYSTEM) + fprintf (stderr, "system error: %s\n", strerror (err)); + + return 1; + } + + for (ai = ai0; ai; ai = ai->ai_next) + { + void *ai_addr = ai->ai_addr; + struct sockaddr_in *sock_addr = ai_addr; + dbgprintf ("\tflags %x\n", ai->ai_flags + 0u); + dbgprintf ("\tfamily %x\n", ai->ai_family + 0u); + dbgprintf ("\tsocktype %x\n", ai->ai_socktype + 0u); + dbgprintf ("\tprotocol %x\n", ai->ai_protocol + 0u); + dbgprintf ("\taddrlen %lu: ", (unsigned long) ai->ai_addrlen); + dbgprintf ("\tFound %s\n", + inet_ntop (ai->ai_family, + &sock_addr->sin_addr, + buf, sizeof (buf) - 1)); + if (ai->ai_canonname) + dbgprintf ("\tFound %s...\n", ai->ai_canonname); + + { + char ipbuf[BUFSIZ]; + char portbuf[BUFSIZ]; + + res = getnameinfo (ai->ai_addr, ai->ai_addrlen, + ipbuf, sizeof (ipbuf) - 1, + portbuf, sizeof (portbuf) - 1, + NI_NUMERICHOST|NI_NUMERICSERV); + dbgprintf ("\t\tgetnameinfo %d: %s\n", res, gai_strerror (res)); + if (res == 0) + { + dbgprintf ("\t\tip %s\n", ipbuf); + dbgprintf ("\t\tport %s\n", portbuf); + } + } + + } + + freeaddrinfo (ai0); + + return 0; +} + +#define HOST1 "www.gnu.org" +#define SERV1 "http" +#define HOST2 "www.ibm.com" +#define SERV2 "https" +#define HOST3 "microsoft.com" +#define SERV3 "http" +#define HOST4 "google.org" +#define SERV4 "ldap" + +int main (void) +{ + (void) gl_sockets_startup (SOCKETS_1_1); + + return simple (HOST1, SERV1) + + simple (HOST2, SERV2) + + simple (HOST3, SERV3) + + simple (HOST4, SERV4); +} diff --git a/gnulib-tests/test-getcwd-lgpl.c b/gnulib-tests/test-getcwd-lgpl.c new file mode 100644 index 0000000..fdf0afd --- /dev/null +++ b/gnulib-tests/test-getcwd-lgpl.c @@ -0,0 +1,102 @@ +/* Test of getcwd() function. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (getcwd, char *, (char *, size_t)); + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "macros.h" + +int +main (int argc, char **argv) +{ + char *pwd1; + char *pwd2; + /* If the user provides an argument, attempt to chdir there first. */ + if (1 < argc) + { + if (chdir (argv[1]) == 0) + printf ("changed to directory %s\n", argv[1]); + } + + pwd1 = getcwd (NULL, 0); + ASSERT (pwd1 && *pwd1); + if (1 < argc) + printf ("cwd=%s\n", pwd1); + + /* Make sure the result is usable. */ + ASSERT (chdir (pwd1) == 0); + ASSERT (chdir (".//./.") == 0); + + /* Make sure that result is normalized. */ + pwd2 = getcwd (NULL, 0); + ASSERT (pwd2); + ASSERT (strcmp (pwd1, pwd2) == 0); + free (pwd2); + { + size_t len = strlen (pwd1); + ssize_t i = len - 10; + if (i < 1) + i = 1; + pwd2 = getcwd (NULL, len + 1); + ASSERT (pwd2); + free (pwd2); + pwd2 = malloc (len + 2); + for ( ; i <= len; i++) + { + char *tmp; + errno = 0; + ASSERT (getcwd (pwd2, i) == NULL); + ASSERT (errno == ERANGE); + /* Allow either glibc or BSD behavior, since POSIX allows both. */ + errno = 0; + tmp = getcwd (NULL, i); + if (tmp) + { + ASSERT (strcmp (pwd1, tmp) == 0); + free (tmp); + } + else + { + ASSERT (errno == ERANGE); + } + } + ASSERT (getcwd (pwd2, len + 1) == pwd2); + pwd2[len] = '/'; + pwd2[len + 1] = '\0'; + } + ASSERT (strstr (pwd2, "/./") == NULL); + ASSERT (strstr (pwd2, "/../") == NULL); + ASSERT (strstr (pwd2 + 1 + (pwd2[1] == '/'), "//") == NULL); + + /* Validate a POSIX requirement on size. */ + errno = 0; + ASSERT (getcwd(pwd2, 0) == NULL); + ASSERT (errno == EINVAL); + + free (pwd1); + free (pwd2); + + return 0; +} diff --git a/gnulib-tests/test-getcwd.c b/gnulib-tests/test-getcwd.c new file mode 100644 index 0000000..e1df1ff --- /dev/null +++ b/gnulib-tests/test-getcwd.c @@ -0,0 +1,260 @@ +/* Test of getcwd() function. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <unistd.h> + +#include <errno.h> +#include <fcntl.h> +#include <limits.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> + +#include "pathmax.h" +#include "macros.h" + +#if ! HAVE_GETPAGESIZE +# define getpagesize() 0 +#endif + +/* This size is chosen to be larger than PATH_MAX (4k), yet smaller than + the 16kB pagesize on ia64 linux. Those conditions make the code below + trigger a bug in glibc's getcwd implementation before 2.4.90-10. */ +#define TARGET_LEN (5 * 1024) + +#if defined HAVE_OPENAT || (defined GNULIB_OPENAT && defined HAVE_FDOPENDIR) +# define HAVE_OPENAT_SUPPORT 1 +#else +# define HAVE_OPENAT_SUPPORT 0 +#endif + +/* Keep this test in sync with m4/getcwd-abort-bug.m4. */ +static int +test_abort_bug (void) +{ + char *cwd; + size_t initial_cwd_len; + int fail = 0; + + /* The bug is triggered when PATH_MAX < getpagesize (), so skip + this relatively expensive and invasive test if that's not true. */ +#ifdef PATH_MAX + int bug_possible = PATH_MAX < getpagesize (); +#else + int bug_possible = 0; +#endif + if (! bug_possible) + return 0; + + cwd = getcwd (NULL, 0); + if (cwd == NULL) + return 2; + + initial_cwd_len = strlen (cwd); + free (cwd); + + if (HAVE_OPENAT_SUPPORT) + { + static char const dir_name[] = "confdir-14B---"; + size_t desired_depth = ((TARGET_LEN - 1 - initial_cwd_len) + / sizeof dir_name); + size_t d; + for (d = 0; d < desired_depth; d++) + { + if (mkdir (dir_name, S_IRWXU) < 0 || chdir (dir_name) < 0) + { + if (! (errno == ERANGE || errno == ENAMETOOLONG + || errno == ENOENT)) + fail = 3; /* Unable to construct deep hierarchy. */ + break; + } + } + + /* If libc has the bug in question, this invocation of getcwd + results in a failed assertion. */ + cwd = getcwd (NULL, 0); + if (cwd == NULL) + fail = 4; /* getcwd didn't assert, but it failed for a long name + where the answer could have been learned. */ + free (cwd); + + /* Call rmdir first, in case the above chdir failed. */ + rmdir (dir_name); + while (0 < d--) + { + if (chdir ("..") < 0) + { + fail = 5; + break; + } + rmdir (dir_name); + } + } + + return fail; +} + +/* The length of this name must be 8. */ +#define DIR_NAME "confdir3" +#define DIR_NAME_LEN 8 +#define DIR_NAME_SIZE (DIR_NAME_LEN + 1) + +/* The length of "../". */ +#define DOTDOTSLASH_LEN 3 + +/* Leftover bytes in the buffer, to work around library or OS bugs. */ +#define BUF_SLOP 20 + +/* Keep this test in sync with m4/getcwd-path-max.m4. */ +static int +test_long_name (void) +{ +#ifndef PATH_MAX + /* The Hurd doesn't define this, so getcwd can't exhibit the bug -- + at least not on a local file system. And if we were to start worrying + about remote file systems, we'd have to enable the wrapper function + all of the time, just to be safe. That's not worth the cost. */ + return 0; +#elif ((INT_MAX / (DIR_NAME_SIZE / DOTDOTSLASH_LEN + 1) \ + - DIR_NAME_SIZE - BUF_SLOP) \ + <= PATH_MAX) + /* FIXME: Assuming there's a system for which this is true, + this should be done in a compile test. */ + return 0; +#else + char buf[PATH_MAX * (DIR_NAME_SIZE / DOTDOTSLASH_LEN + 1) + + DIR_NAME_SIZE + BUF_SLOP]; + char *cwd = getcwd (buf, PATH_MAX); + size_t initial_cwd_len; + size_t cwd_len; + int fail = 0; + size_t n_chdirs = 0; + + if (cwd == NULL) + return 1; + + cwd_len = initial_cwd_len = strlen (cwd); + + while (1) + { +# ifdef HAVE_GETCWD_SHORTER + /* On OS/X <= 10.9 for example, we're restricted to shorter paths + as lstat() doesn't support more than PATH_MAX. */ + size_t dotdot_max = PATH_MAX * 2; +# else + size_t dotdot_max = PATH_MAX * (DIR_NAME_SIZE / DOTDOTSLASH_LEN); +# endif + char *c = NULL; + + cwd_len += DIR_NAME_SIZE; + /* If mkdir or chdir fails, it could be that this system cannot create + any file with an absolute name longer than PATH_MAX, such as cygwin. + If so, leave fail as 0, because the current working directory can't + be too long for getcwd if it can't even be created. On Linux with + the 9p file system, mkdir fails with error EINVAL when cwd_len gets + too long; ignore this failure because the getcwd() system call + produces good results whereas the gnulib substitute calls getdents64 + which fails with error EPROTO. + For other errors, be pessimistic and consider that as a failure, + too. */ + if (mkdir (DIR_NAME, S_IRWXU) < 0 || chdir (DIR_NAME) < 0) + { + if (! (errno == ERANGE || errno == ENAMETOOLONG || errno == ENOENT)) + #ifdef __linux__ + if (! (errno == EINVAL)) + #endif + fail = 2; + break; + } + + if (PATH_MAX <= cwd_len && cwd_len < PATH_MAX + DIR_NAME_SIZE) + { + c = getcwd (buf, PATH_MAX); + if (!c && errno == ENOENT) + { + fail = 3; + break; + } + if (c) + { + fail = 4; + break; + } + if (! (errno == ERANGE || errno == ENAMETOOLONG)) + { + fail = 5; + break; + } + } + + if (dotdot_max <= cwd_len - initial_cwd_len) + { + if (dotdot_max + DIR_NAME_SIZE < cwd_len - initial_cwd_len) + break; + c = getcwd (buf, cwd_len + 1); + if (!c) + { + if (! (errno == ERANGE || errno == ENOENT + || errno == ENAMETOOLONG)) + { + fail = 6; + break; + } + if (HAVE_OPENAT_SUPPORT || errno == ERANGE || errno == ENOENT) + { + fail = 7; + break; + } + } + } + + if (c && strlen (c) != cwd_len) + { + fail = 8; + break; + } + ++n_chdirs; + } + + /* Leaving behind such a deep directory is not polite. + So clean up here, right away, even though the driving + shell script would also clean up. */ + { + size_t i; + + /* Try rmdir first, in case the chdir failed. */ + rmdir (DIR_NAME); + for (i = 0; i <= n_chdirs; i++) + { + if (chdir ("..") < 0) + break; + if (rmdir (DIR_NAME) != 0) + break; + } + } + + return fail; +#endif +} + +int +main (int argc, char **argv) +{ + return test_abort_bug () * 10 + test_long_name (); +} diff --git a/gnulib-tests/test-getcwd.sh b/gnulib-tests/test-getcwd.sh new file mode 100755 index 0000000..64a3c7c --- /dev/null +++ b/gnulib-tests/test-getcwd.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +. "${srcdir=.}/init.sh"; path_prepend_ . + +${CHECKER} test-getcwd + +Exit $? diff --git a/gnulib-tests/test-getdelim.c b/gnulib-tests/test-getdelim.c new file mode 100644 index 0000000..3ce7ccc --- /dev/null +++ b/gnulib-tests/test-getdelim.c @@ -0,0 +1,94 @@ +/* Test of getdelim() function. + Copyright (C) 2007-2020 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, 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2007. */ + +#include <config.h> + +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (getdelim, ssize_t, (char **, size_t *, int, FILE *)); + +#include <stdlib.h> +#include <string.h> + +#include "macros.h" + +int +main (void) +{ + FILE *f; + char *line; + size_t len; + ssize_t result; + + /* Create test file. */ + f = fopen ("test-getdelim.txt", "wb"); + if (!f || fwrite ("anAnbcnd\0f", 1, 10, f) != 10 || fclose (f) != 0) + { + fputs ("Failed to create sample file.\n", stderr); + remove ("test-getdelim.txt"); + return 1; + } + f = fopen ("test-getdelim.txt", "rb"); + if (!f) + { + fputs ("Failed to reopen sample file.\n", stderr); + remove ("test-getdelim.txt"); + return 1; + } + + /* Test initial allocation, which must include trailing NUL. */ + line = NULL; + len = 0; + result = getdelim (&line, &len, 'n', f); + ASSERT (result == 2); + ASSERT (strcmp (line, "an") == 0); + ASSERT (2 < len); + free (line); + + /* Test initial allocation again, with line = NULL and len != 0. */ + line = NULL; + len = (size_t)(~0) / 4; + result = getdelim (&line, &len, 'n', f); + ASSERT (result == 2); + ASSERT (strcmp (line, "An") == 0); + ASSERT (2 < len); + free (line); + + /* Test growth of buffer. */ + line = malloc (1); + len = 1; + result = getdelim (&line, &len, 'n', f); + ASSERT (result == 3); + ASSERT (strcmp (line, "bcn") == 0); + ASSERT (3 < len); + + /* Test embedded NULs and EOF behavior. */ + result = getdelim (&line, &len, 'n', f); + ASSERT (result == 3); + ASSERT (memcmp (line, "d\0f", 4) == 0); + ASSERT (3 < len); + + result = getdelim (&line, &len, 'n', f); + ASSERT (result == -1); + + free (line); + fclose (f); + remove ("test-getdelim.txt"); + return 0; +} diff --git a/gnulib-tests/test-getdtablesize.c b/gnulib-tests/test-getdtablesize.c new file mode 100644 index 0000000..bf00fb4 --- /dev/null +++ b/gnulib-tests/test-getdtablesize.c @@ -0,0 +1,36 @@ +/* Test of getdtablesize() function. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2008. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (getdtablesize, int, (void)); + +#include "macros.h" + +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/gnulib-tests/test-getgroups.c b/gnulib-tests/test-getgroups.c new file mode 100644 index 0000000..5c7bc5c --- /dev/null +++ b/gnulib-tests/test-getgroups.c @@ -0,0 +1,79 @@ +/* Tests of getgroups. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (getgroups, int, (int, gid_t[])); + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> + +#include "macros.h" + +int +main (int argc, char **argv _GL_UNUSED) +{ + int result; + gid_t *groups; + + errno = 0; + result = getgroups (0, NULL); + if (result == -1 && errno == ENOSYS) + { + fputs ("skipping test: no support for groups\n", stderr); + return 77; + } + ASSERT (0 <= result); + ASSERT (result + 1 < SIZE_MAX / sizeof *groups); + groups = malloc ((result + 1) * sizeof *groups); + ASSERT (groups); + groups[result] = -1; + /* Check for EINVAL handling. Not all processes have supplemental + groups, and getgroups does not have to return the effective gid, + so a result of 0 is reasonable. Also, we can't test for EINVAL + if result is 1, because of how getgroups treats 0. */ + if (1 < result) + { + errno = 0; + ASSERT (getgroups (result - 1, groups) == -1); + ASSERT (errno == EINVAL); + } + ASSERT (getgroups (result, groups) == result); + ASSERT (getgroups (result + 1, groups) == result); + ASSERT (groups[result] == -1); + errno = 0; + ASSERT (getgroups (-1, NULL) == -1); + ASSERT (errno == EINVAL); + + /* The automated unit test, with no arguments, ends here. However, + for debugging purposes, you can pass a command-line argument to + list the returned groups. */ + if (1 < argc) + { + int i; + for (i = 0; i < result; i++) + printf ("%d\n", (int) groups[i]); + } + free (groups); + return 0; +} diff --git a/gnulib-tests/test-gethostname.c b/gnulib-tests/test-gethostname.c new file mode 100644 index 0000000..74fd1dc --- /dev/null +++ b/gnulib-tests/test-gethostname.c @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2008-2020 Free Software Foundation, Inc. + * Written by Simon Josefsson. + * + * 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +/* Get gethostname() declaration. */ +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (gethostname, int, (char *, size_t)); + +/* Get HOST_NAME_MAX definition. */ +#include <limits.h> + +#include <stdio.h> +#include <string.h> +#include <errno.h> + +#define NOHOSTNAME "magic-gnulib-test-string" + +int +main (int argc, char *argv[] _GL_UNUSED) +{ + char buf[HOST_NAME_MAX]; + int rc; + + if (strlen (NOHOSTNAME) >= HOST_NAME_MAX) + { + printf ("HOST_NAME_MAX impossibly small?! %d\n", HOST_NAME_MAX); + return 2; + } + + strcpy (buf, NOHOSTNAME); + + rc = gethostname (buf, sizeof (buf)); + + if (rc != 0) + { + printf ("gethostname failed, rc %d errno %d\n", rc, errno); + return 1; + } + + if (strcmp (buf, NOHOSTNAME) == 0) + { + printf ("gethostname left buffer untouched.\n"); + return 1; + } + + if (argc > 1) + printf ("hostname: %s\n", buf); + + return 0; +} diff --git a/gnulib-tests/test-getline.c b/gnulib-tests/test-getline.c new file mode 100644 index 0000000..3e7a4b7 --- /dev/null +++ b/gnulib-tests/test-getline.c @@ -0,0 +1,94 @@ +/* Test of getline() function. + Copyright (C) 2007-2020 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, 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2007. */ + +#include <config.h> + +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (getline, ssize_t, (char **, size_t *, FILE *)); + +#include <stdlib.h> +#include <string.h> + +#include "macros.h" + +int +main (void) +{ + FILE *f; + char *line; + size_t len; + ssize_t result; + + /* Create test file. */ + f = fopen ("test-getline.txt", "wb"); + if (!f || fwrite ("a\nA\nbc\nd\0f", 1, 10, f) != 10 || fclose (f) != 0) + { + fputs ("Failed to create sample file.\n", stderr); + remove ("test-getline.txt"); + return 1; + } + f = fopen ("test-getline.txt", "rb"); + if (!f) + { + fputs ("Failed to reopen sample file.\n", stderr); + remove ("test-getline.txt"); + return 1; + } + + /* Test initial allocation, which must include trailing NUL. */ + line = NULL; + len = 0; + result = getline (&line, &len, f); + ASSERT (result == 2); + ASSERT (strcmp (line, "a\n") == 0); + ASSERT (2 < len); + free (line); + + /* Test initial allocation again, with line = NULL and len != 0. */ + line = NULL; + len = (size_t)(~0) / 4; + result = getline (&line, &len, f); + ASSERT (result == 2); + ASSERT (strcmp (line, "A\n") == 0); + ASSERT (2 < len); + free (line); + + /* Test growth of buffer, must not leak. */ + len = 1; + line = malloc (len); + result = getline (&line, &len, f); + ASSERT (result == 3); + ASSERT (strcmp (line, "bc\n") == 0); + ASSERT (3 < len); + + /* Test embedded NULs and EOF behavior. */ + result = getline (&line, &len, f); + ASSERT (result == 3); + ASSERT (memcmp (line, "d\0f", 4) == 0); + ASSERT (3 < len); + + result = getline (&line, &len, f); + ASSERT (result == -1); + + free (line); + fclose (f); + remove ("test-getline.txt"); + return 0; +} diff --git a/gnulib-tests/test-getloadavg.c b/gnulib-tests/test-getloadavg.c new file mode 100644 index 0000000..daf443b --- /dev/null +++ b/gnulib-tests/test-getloadavg.c @@ -0,0 +1,83 @@ +/* Test of getting load average. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdlib.h> + +#include "signature.h" +SIGNATURE_CHECK (getloadavg, int, (double [], int)); + +#include <errno.h> +#include <stdio.h> +#include <unistd.h> + +static void +check_avg (int minutes, double avg, int printit) +{ + if (printit) + printf ("%d-minute: %f ", minutes, avg); + else + { + /* Plausibility checks. */ + if (avg < 0.01) + printf ("suspiciously low %d-minute average: %f\n", minutes, avg); + if (avg > 1000000) + printf ("suspiciously high %d-minute average: %f\n", minutes, avg); + } + if (avg < 0 || avg != avg) + exit (minutes); +} + +/* This program can also be used as a manual test, by invoking it with + an argument; it then prints the load average. If the argument is + nonzero, the manual test repeats forever, sleeping for the stated + interval between each iteration. */ +int +main (int argc, char **argv) +{ + int naptime = 0; + + if (argc > 1) + naptime = atoi (argv[1]); + + while (1) + { + double avg[3]; + int loads = getloadavg (avg, 3); + if (loads == -1) + { + if (! (errno == ENOSYS || errno == ENOTSUP || errno == ENOENT)) + return 1; + perror ("Skipping test; load average not supported"); + return 77; + } + if (loads > 0) + check_avg (1, avg[0], argc > 1); + if (loads > 1) + check_avg (5, avg[1], argc > 1); + if (loads > 2) + check_avg (15, avg[1], argc > 1); + if (loads > 0 && argc > 1) + putchar ('\n'); + + if (naptime == 0) + break; + sleep (naptime); + } + + return 0; +} diff --git a/gnulib-tests/test-getlogin.c b/gnulib-tests/test-getlogin.c new file mode 100644 index 0000000..a3048f2 --- /dev/null +++ b/gnulib-tests/test-getlogin.c @@ -0,0 +1,38 @@ +/* Test of getting user name. + Copyright (C) 2010-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible and Paul Eggert. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (getlogin, char *, (void)); + +#include "test-getlogin.h" + +int +main (void) +{ + /* Test value. */ + char *buf = getlogin (); + int err = buf ? 0 : errno; + ASSERT (buf || err); + test_getlogin_result (buf, err); + + return 0; +} diff --git a/gnulib-tests/test-getlogin.h b/gnulib-tests/test-getlogin.h new file mode 100644 index 0000000..0939015 --- /dev/null +++ b/gnulib-tests/test-getlogin.h @@ -0,0 +1,92 @@ +/* Test of getting user name. + Copyright (C) 2010-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible and Paul Eggert. */ + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#if !(defined _WIN32 && !defined __CYGWIN__) +# include <pwd.h> +#endif + +#include <sys/stat.h> +#include <sys/types.h> + +#include "macros.h" + +static void +test_getlogin_result (const char *buf, int err) +{ + if (err != 0) + { + if (err == ENOENT) + { + /* This can happen on GNU/Linux. */ + fprintf (stderr, "Skipping test: no entry in utmp file.\n"); + exit (77); + } + + /* It fails when stdin is not connected to a tty. */ + ASSERT (err == ENOTTY + || err == EINVAL /* seen on Linux/SPARC */ + || err == ENXIO + ); +#if !defined __hpux /* On HP-UX 11.11 it fails anyway. */ + ASSERT (! isatty (0)); +#endif + fprintf (stderr, "Skipping test: stdin is not a tty.\n"); + exit (77); + } + + /* Compare against the value from the environment. */ +#if !(defined _WIN32 && !defined __CYGWIN__) + /* Unix platform */ + { + struct stat stat_buf; + struct passwd *pwd; + + if (!isatty (STDIN_FILENO)) + { + fprintf (stderr, "Skipping test: stdin is not a tty.\n"); + exit (77); + } + + ASSERT (fstat (STDIN_FILENO, &stat_buf) == 0); + + pwd = getpwnam (buf); + if (! pwd) + { + fprintf (stderr, "Skipping test: %s: no such user\n", buf); + exit (77); + } + + ASSERT (pwd->pw_uid == stat_buf.st_uid); + } +#endif +#if defined _WIN32 && !defined __CYGWIN__ + /* Native Windows platform. + Note: This test would fail on Cygwin in an ssh session, because sshd + sets USERNAME=SYSTEM. */ + { + const char *name = getenv ("USERNAME"); + if (name != NULL && name[0] != '\0') + ASSERT (strcmp (buf, name) == 0); + } +#endif +} diff --git a/gnulib-tests/test-getndelim2.c b/gnulib-tests/test-getndelim2.c new file mode 100644 index 0000000..e7dbf64 --- /dev/null +++ b/gnulib-tests/test-getndelim2.c @@ -0,0 +1,151 @@ +/* Test of getndelim2() function. + Copyright (C) 2008-2020 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, 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2008. */ + +#include <config.h> + +#include "getndelim2.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "macros.h" + +int +main (void) +{ + FILE *f; + char *line = NULL; + size_t len = 0; + ssize_t result; + + /* Create test file. */ + f = fopen ("test-getndelim2.txt", "wb+"); + if (!f || fwrite ("a\nbc\nd\0f", 1, 8, f) != 8) + { + fputs ("Failed to create sample file.\n", stderr); + remove ("test-getndelim2.txt"); + return 1; + } + rewind (f); + + /* Unlimited lines. */ + + /* Test initial allocation, which must include trailing NUL. */ + result = getndelim2 (&line, &len, 0, GETNLINE_NO_LIMIT, '\n', '\n', f); + ASSERT (result == 2); + ASSERT (strcmp (line, "a\n") == 0); + ASSERT (2 < len); + + /* Test growth of buffer, must not leak. */ + free (line); + line = malloc (1); + len = 0; + result = getndelim2 (&line, &len, 0, GETNLINE_NO_LIMIT, EOF, '\n', f); + ASSERT (result == 3); + ASSERT (strcmp (line, "bc\n") == 0); + ASSERT (3 < len); + + /* Test embedded NULs and EOF behavior. */ + result = getndelim2 (&line, &len, 0, GETNLINE_NO_LIMIT, '\n', EOF, f); + ASSERT (result == 3); + ASSERT (memcmp (line, "d\0f", 4) == 0); + ASSERT (3 < len); + + result = getndelim2 (&line, &len, 0, GETNLINE_NO_LIMIT, '\n', EOF, f); + ASSERT (result == -1); + + /* Using offset and nmax. */ + + /* Limit growth to four bytes, including NUL, but parse to next 'd'. */ + free (line); + rewind (f); + line = malloc (8); + memset (line, 'e', 8); + len = 8; + result = getndelim2 (&line, &len, 6, 10, 'd', 'd', f); + ASSERT (result == 3); + ASSERT (10 == len); + ASSERT (strcmp (line, "eeeeeea\nb") == 0); + + /* No change if offset larger than limit. */ + result = getndelim2 (&line, &len, len, 1, EOF, EOF, f); + ASSERT (result == -1); + ASSERT (10 == len); + ASSERT (strcmp (line, "eeeeeea\nb") == 0); + + /* Consume to end of file, including embedded NUL. */ + result = getndelim2 (&line, &len, 0, GETNLINE_NO_LIMIT, EOF, EOF, f); + ASSERT (result == 2); + ASSERT (10 == len); + ASSERT (memcmp (line, "\0f\0eeea\nb", 10) == 0); + + result = getndelim2 (&line, &len, 0, GETNLINE_NO_LIMIT, '\n', '\r', f); + ASSERT (result == -1); + + /* Larger file size. */ + rewind (f); + { + int i; + for (i = 0; i < 16; i++) + fprintf (f, "%500x%c", i + 0u, i % 2 ? '\n' : '\r'); + } + rewind (f); + { + char buffer[502]; + + result = getndelim2 (&line, &len, 0, GETNLINE_NO_LIMIT, '\n', '\r', f); + ASSERT (result == 501); + ASSERT (501 < len); + memset (buffer, ' ', 499); + buffer[499] = '0'; + buffer[500] = '\r'; + buffer[501] = '\0'; + ASSERT (strcmp (buffer, line) == 0); + + result = getndelim2 (&line, &len, 0, GETNLINE_NO_LIMIT, '\n', '\r', f); + ASSERT (result == 501); + ASSERT (501 < len); + buffer[499] = '1'; + buffer[500] = '\n'; + ASSERT (strcmp (buffer, line) == 0); + + result = getndelim2 (&line, &len, 0, GETNLINE_NO_LIMIT, 'g', 'f', f); + ASSERT (result == 501 * 14 - 1); + ASSERT (501 * 14 <= len); + buffer[499] = 'f'; + buffer[500] = '\0'; + ASSERT (strcmp (buffer, line + 501 * 13) == 0); + + result = getndelim2 (&line, &len, 501 * 14 - 1, GETNLINE_NO_LIMIT, + EOF, EOF, f); + ASSERT (result == 1); + buffer[500] = '\n'; + ASSERT (strcmp (buffer, line + 501 * 13) == 0); + + result = getndelim2 (&line, &len, 501 * 14 - 1, GETNLINE_NO_LIMIT, + EOF, EOF, f); + buffer[500] = '\0'; + ASSERT (strcmp (buffer, line + 501 * 13) == 0); + ASSERT (result == -1); + } + + fclose (f); + remove ("test-getndelim2.txt"); + return 0; +} diff --git a/gnulib-tests/test-getopt-gnu.c b/gnulib-tests/test-getopt-gnu.c new file mode 100644 index 0000000..34db5ae --- /dev/null +++ b/gnulib-tests/test-getopt-gnu.c @@ -0,0 +1,45 @@ +/* Test of command line argument processing. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2009. */ + +#include <config.h> + +/* None of the files accessed by this test are large, so disable the + ftell link warning if we are not using the gnulib ftell module. */ +#define _GL_NO_LARGE_FILES + +/* POSIX and glibc provide the getopt() function in <unistd.h>, see + https://pubs.opengroup.org/onlinepubs/9699919799/functions/getopt.html + https://www.gnu.org/software/libc/manual/html_node/Using-Getopt.html + But gnulib provides the getopt() function in <getopt.h>, not in <unistd.h>. + This is what we are testing here. */ +#include <getopt.h> + +#ifndef __getopt_argv_const +# define __getopt_argv_const const +#endif +#include "signature.h" +SIGNATURE_CHECK (getopt_long, int, (int, char *__getopt_argv_const *, + char const *, struct option const *, + int *)); +SIGNATURE_CHECK (getopt_long_only, int, (int, char *__getopt_argv_const *, + char const *, struct option const *, + int *)); + +#define TEST_GETOPT_GNU 1 +#define TEST_GETOPT_TMP_NAME "test-getopt-gnu.tmp" +#include "test-getopt-main.h" diff --git a/gnulib-tests/test-getopt-main.h b/gnulib-tests/test-getopt-main.h new file mode 100644 index 0000000..f3278cc --- /dev/null +++ b/gnulib-tests/test-getopt-main.h @@ -0,0 +1,76 @@ +/* Test of command line argument processing. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2009. */ + +#include "signature.h" +SIGNATURE_CHECK (getopt, int, (int, char * const[], char const *)); + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +/* This test intentionally remaps stderr. So, we arrange to have fd 10 + (outside the range of interesting fd's during the test) set up to + duplicate the original stderr. */ + +#define BACKUP_STDERR_FILENO 10 +#define ASSERT_STREAM myerr +#include "macros.h" + +static FILE *myerr; + +#include "test-getopt.h" +#if TEST_GETOPT_GNU +# include "test-getopt_long.h" +#endif + +int +main (void) +{ + /* This test validates that stderr is used correctly, so move the + original into fd 10. */ + if (dup2 (STDERR_FILENO, BACKUP_STDERR_FILENO) != BACKUP_STDERR_FILENO + || (myerr = fdopen (BACKUP_STDERR_FILENO, "w")) == NULL) + return 2; + + ASSERT (freopen (TEST_GETOPT_TMP_NAME, "w", stderr) == stderr); + + /* These default values are required by POSIX. */ + ASSERT (optind == 1); + ASSERT (opterr != 0); + + setenv ("POSIXLY_CORRECT", "1", 1); + test_getopt (); + +#if TEST_GETOPT_GNU + test_getopt_long_posix (); +#endif + + unsetenv ("POSIXLY_CORRECT"); + test_getopt (); + +#if TEST_GETOPT_GNU + test_getopt_long (); + test_getopt_long_only (); +#endif + + ASSERT (fclose (stderr) == 0); + ASSERT (remove (TEST_GETOPT_TMP_NAME) == 0); + + return 0; +} diff --git a/gnulib-tests/test-getopt-posix.c b/gnulib-tests/test-getopt-posix.c new file mode 100644 index 0000000..10ed784 --- /dev/null +++ b/gnulib-tests/test-getopt-posix.c @@ -0,0 +1,34 @@ +/* Test of command line argument processing. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2009. */ + +#include <config.h> + +/* None of the files accessed by this test are large, so disable the + ftell link warning if we are not using the gnulib ftell module. */ +#define _GL_NO_LARGE_FILES + +/* POSIX and glibc provide the getopt() function in <unistd.h>, see + https://pubs.opengroup.org/onlinepubs/9699919799/functions/getopt.html + https://www.gnu.org/software/libc/manual/html_node/Using-Getopt.html + But gnulib provides the getopt() function in <getopt.h>, not in <unistd.h>. + Nevertheless the getopt() function should also be found in <unistd.h>. */ +#include <unistd.h> + +#define TEST_GETOPT_GNU 0 +#define TEST_GETOPT_TMP_NAME "test-getopt-posix.tmp" +#include "test-getopt-main.h" diff --git a/gnulib-tests/test-getopt.h b/gnulib-tests/test-getopt.h new file mode 100644 index 0000000..c9237b0 --- /dev/null +++ b/gnulib-tests/test-getopt.h @@ -0,0 +1,1391 @@ +/* Test of command line argument processing. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2009. */ + +#include <stdbool.h> + +/* The glibc/gnulib implementation of getopt supports setting optind = + 0, but not all other implementations do. This matters for getopt. + But for getopt_long, we require GNU compatibility. */ +#if defined __GETOPT_PREFIX || (__GLIBC__ >= 2 && !defined __UCLIBC__) +# define OPTIND_MIN 0 +#elif HAVE_DECL_OPTRESET +# define OPTIND_MIN (optreset = 1) +#else +# define OPTIND_MIN 1 +#endif + +static void +getopt_loop (int argc, const char **argv, + const char *options, + int *a_seen, int *b_seen, + const char **p_value, const char **q_value, + int *non_options_count, const char **non_options, + int *unrecognized, bool *message_issued) +{ + int c; + int pos = ftell (stderr); + + while ((c = getopt (argc, (char **) argv, options)) != -1) + { + switch (c) + { + case 'a': + (*a_seen)++; + break; + case 'b': + (*b_seen)++; + break; + case 'p': + *p_value = optarg; + break; + case 'q': + *q_value = optarg; + break; + case '\1': + /* Must only happen with option '-' at the beginning. */ + ASSERT (options[0] == '-'); + non_options[(*non_options_count)++] = optarg; + break; + case ':': + /* Must only happen with option ':' at the beginning. */ + ASSERT (options[0] == ':' + || ((options[0] == '-' || options[0] == '+') + && options[1] == ':')); + FALLTHROUGH; + case '?': + *unrecognized = optopt; + break; + default: + *unrecognized = c; + break; + } + } + + *message_issued = pos < ftell (stderr); +} + +static void +test_getopt (void) +{ + int start; + bool posixly = !!getenv ("POSIXLY_CORRECT"); + /* See comment in getopt.c: + glibc gets a LSB-compliant getopt. + Standalone applications get a POSIX-compliant getopt. */ +#if defined __GETOPT_PREFIX || !(__GLIBC__ >= 2 || defined __MINGW32__) + /* Using getopt from gnulib or from a non-glibc system. */ + posixly = true; +#endif + + /* Test processing of boolean options. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-a"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "ab", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-b"; + argv[argc++] = "-a"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "ab", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 1); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 3); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-ba"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "ab", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 1); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-ab"; + argv[argc++] = "-a"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "ab", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 2); + ASSERT (b_seen == 1); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 3); + ASSERT (!output); + } + + /* Test processing of options with arguments. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-pfoo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "p:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "p:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 3); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-ab"; + argv[argc++] = "-q"; + argv[argc++] = "baz"; + argv[argc++] = "-pfoo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 1); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value != NULL && strcmp (q_value, "baz") == 0); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 5); + ASSERT (!output); + } + +#if GNULIB_TEST_GETOPT_GNU + /* Test processing of options with optional arguments. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-pfoo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "p::q::", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "p::q::", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "abp::q::", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 3); + ASSERT (!output); + } +#endif /* GNULIB_TEST_GETOPT_GNU */ + + /* Check that invalid options are recognized; and that both opterr + and leading ':' can silence output. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "-x"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 42; + getopt_loop (argc, argv, "abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 'x'); + ASSERT (optind == 5); + ASSERT (output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "-x"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 0; + getopt_loop (argc, argv, "abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 'x'); + ASSERT (optind == 5); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "-x"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, ":abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 'x'); + ASSERT (optind == 5); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "-:"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 42; + getopt_loop (argc, argv, "abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == ':'); + ASSERT (optind == 5); + ASSERT (output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "-:"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 0; + getopt_loop (argc, argv, "abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == ':'); + ASSERT (optind == 5); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "-:"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, ":abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == ':'); + ASSERT (optind == 5); + ASSERT (!output); + } + + /* Check for missing argument behavior. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-ap"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 'p'); + ASSERT (optind == 2); + ASSERT (output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-ap"; + argv[argc] = NULL; + optind = start; + opterr = 0; + getopt_loop (argc, argv, "abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 'p'); + ASSERT (optind == 2); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-ap"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, ":abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 'p'); + ASSERT (optind == 2); + ASSERT (!output); + } + + /* Check that by default, non-options arguments are moved to the end. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + if (posixly) + { + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 1); + ASSERT (!output); + } + else + { + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "-p") == 0); + ASSERT (strcmp (argv[2], "billy") == 0); + ASSERT (strcmp (argv[3], "-a") == 0); + ASSERT (strcmp (argv[4], "donald") == 0); + ASSERT (strcmp (argv[5], "duck") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 4); + ASSERT (!output); + } + } + + /* Check that '--' ends the argument processing. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[20]; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "--"; + argv[argc++] = "-b"; + argv[argc++] = "foo"; + argv[argc++] = "-q"; + argv[argc++] = "johnny"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + if (posixly) + { + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "--") == 0); + ASSERT (strcmp (argv[7], "-b") == 0); + ASSERT (strcmp (argv[8], "foo") == 0); + ASSERT (strcmp (argv[9], "-q") == 0); + ASSERT (strcmp (argv[10], "johnny") == 0); + ASSERT (strcmp (argv[11], "bar") == 0); + ASSERT (argv[12] == NULL); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 1); + ASSERT (!output); + } + else + { + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "-p") == 0); + ASSERT (strcmp (argv[2], "billy") == 0); + ASSERT (strcmp (argv[3], "-a") == 0); + ASSERT (strcmp (argv[4], "--") == 0); + ASSERT (strcmp (argv[5], "donald") == 0); + ASSERT (strcmp (argv[6], "duck") == 0); + ASSERT (strcmp (argv[7], "-b") == 0); + ASSERT (strcmp (argv[8], "foo") == 0); + ASSERT (strcmp (argv[9], "-q") == 0); + ASSERT (strcmp (argv[10], "johnny") == 0); + ASSERT (strcmp (argv[11], "bar") == 0); + ASSERT (argv[12] == NULL); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 5); + ASSERT (!output); + } + } + +#if GNULIB_TEST_GETOPT_GNU + /* Check that the '-' flag causes non-options to be returned in order. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "-abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 3); + ASSERT (strcmp (non_options[0], "donald") == 0); + ASSERT (strcmp (non_options[1], "duck") == 0); + ASSERT (strcmp (non_options[2], "bar") == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 7); + ASSERT (!output); + } + + /* Check that '--' ends the argument processing. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[20]; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "--"; + argv[argc++] = "-b"; + argv[argc++] = "foo"; + argv[argc++] = "-q"; + argv[argc++] = "johnny"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "-abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "--") == 0); + ASSERT (strcmp (argv[7], "-b") == 0); + ASSERT (strcmp (argv[8], "foo") == 0); + ASSERT (strcmp (argv[9], "-q") == 0); + ASSERT (strcmp (argv[10], "johnny") == 0); + ASSERT (strcmp (argv[11], "bar") == 0); + ASSERT (argv[12] == NULL); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0); + ASSERT (q_value == NULL); + ASSERT (!output); + if (non_options_count == 2) + { + /* glibc behaviour. */ + ASSERT (non_options_count == 2); + ASSERT (strcmp (non_options[0], "donald") == 0); + ASSERT (strcmp (non_options[1], "duck") == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 7); + } + else + { + /* Another valid behaviour. */ + ASSERT (non_options_count == 7); + ASSERT (strcmp (non_options[0], "donald") == 0); + ASSERT (strcmp (non_options[1], "duck") == 0); + ASSERT (strcmp (non_options[2], "-b") == 0); + ASSERT (strcmp (non_options[3], "foo") == 0); + ASSERT (strcmp (non_options[4], "-q") == 0); + ASSERT (strcmp (non_options[5], "johnny") == 0); + ASSERT (strcmp (non_options[6], "bar") == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 12); + } + } + + /* Check that the '-' flag has to come first. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "abp:q:-", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + if (posixly) + { + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 1); + ASSERT (!output); + } + else + { + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "-p") == 0); + ASSERT (strcmp (argv[2], "billy") == 0); + ASSERT (strcmp (argv[3], "-a") == 0); + ASSERT (strcmp (argv[4], "donald") == 0); + ASSERT (strcmp (argv[5], "duck") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 4); + ASSERT (!output); + } + } + + /* Check that the '+' flag causes the first non-option to terminate the + loop. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "+abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 1); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-+"; + argv[argc] = NULL; + optind = start; + getopt_loop (argc, argv, "+abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == '+'); + ASSERT (optind == 2); + ASSERT (output); + } + + /* Check that '--' ends the argument processing. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[20]; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "--"; + argv[argc++] = "-b"; + argv[argc++] = "foo"; + argv[argc++] = "-q"; + argv[argc++] = "johnny"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "+abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "--") == 0); + ASSERT (strcmp (argv[7], "-b") == 0); + ASSERT (strcmp (argv[8], "foo") == 0); + ASSERT (strcmp (argv[9], "-q") == 0); + ASSERT (strcmp (argv[10], "johnny") == 0); + ASSERT (strcmp (argv[11], "bar") == 0); + ASSERT (argv[12] == NULL); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 1); + ASSERT (!output); + } +#endif /* GNULIB_TEST_GETOPT_GNU */ + + /* Check that the '+' flag has to come first. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "abp:q:+", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + if (posixly) + { + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 1); + ASSERT (!output); + } + else + { + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "-p") == 0); + ASSERT (strcmp (argv[2], "billy") == 0); + ASSERT (strcmp (argv[3], "-a") == 0); + ASSERT (strcmp (argv[4], "donald") == 0); + ASSERT (strcmp (argv[5], "duck") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 4); + ASSERT (!output); + } + } + +#if GNULIB_TEST_GETOPT_GNU + /* If GNU extensions are supported, require compliance with POSIX + interpretation on leading '+' behavior. + http://austingroupbugs.net/view.php?id=191 */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "+:abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 1); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc] = NULL; + optind = start; + getopt_loop (argc, argv, "+:abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 'p'); + ASSERT (optind == 2); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-b"; + argv[argc++] = "-p"; + argv[argc] = NULL; + optind = start; + getopt_loop (argc, argv, "+:abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 0); + ASSERT (b_seen == 1); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 'p'); + ASSERT (optind == 3); + ASSERT (!output); + } + + /* Check that 'W' does not dump core: + https://sourceware.org/bugzilla/show_bug.cgi?id=12922 + Technically, POSIX says the presence of ';' in the opt-string + gives unspecified behavior, so we only test this when GNU compliance + is desired. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int argc = 0; + const char *argv[10]; + int pos = ftell (stderr); + + argv[argc++] = "program"; + argv[argc++] = "-W"; + argv[argc++] = "dummy"; + argv[argc] = NULL; + optind = start; + opterr = 1; + ASSERT (getopt (argc, (char **) argv, "W;") == 'W'); + ASSERT (ftell (stderr) == pos); + ASSERT (optind == 2); + } +#endif /* GNULIB_TEST_GETOPT_GNU */ +} diff --git a/gnulib-tests/test-getopt_long.h b/gnulib-tests/test-getopt_long.h new file mode 100644 index 0000000..eaa61b4 --- /dev/null +++ b/gnulib-tests/test-getopt_long.h @@ -0,0 +1,2144 @@ +/* Test of command line argument processing. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2009. */ + +static int a_seen; +static int b_seen; +static int q_seen; + +static const struct option long_options_required[] = + { + { "alpha", no_argument, NULL, 'a' }, + { "beta", no_argument, &b_seen, 1 }, + { "prune", required_argument, NULL, 'p' }, + { "quetsche", required_argument, &q_seen, 1 }, + { "xtremely-",no_argument, NULL, 1003 }, + { "xtra", no_argument, NULL, 1001 }, + { "xtreme", no_argument, NULL, 1002 }, + { "xtremely", no_argument, NULL, 1003 }, + { NULL, 0, NULL, 0 } + }; + +static const struct option long_options_optional[] = + { + { "alpha", no_argument, NULL, 'a' }, + { "beta", no_argument, &b_seen, 1 }, + { "prune", optional_argument, NULL, 'p' }, + { "quetsche", optional_argument, &q_seen, 1 }, + { NULL, 0, NULL, 0 } + }; + +static void +getopt_long_loop (int argc, const char **argv, + const char *options, const struct option *long_options, + const char **p_value, const char **q_value, + int *non_options_count, const char **non_options, + int *unrecognized) +{ + int option_index = -1; + int c; + + opterr = 0; + q_seen = 0; + while ((c = getopt_long (argc, (char **) argv, options, long_options, + &option_index)) + != -1) + { + switch (c) + { + case 0: + /* An option with a non-NULL flag pointer was processed. */ + if (q_seen) + *q_value = optarg; + break; + case 'a': + a_seen++; + break; + case 'b': + b_seen = 1; + break; + case 'p': + *p_value = optarg; + break; + case 'q': + *q_value = optarg; + break; + case '\1': + /* Must only happen with option '-' at the beginning. */ + ASSERT (options[0] == '-'); + non_options[(*non_options_count)++] = optarg; + break; + case ':': + /* Must only happen with option ':' at the beginning. */ + ASSERT (options[0] == ':' + || ((options[0] == '-' || options[0] == '+') + && options[1] == ':')); + FALLTHROUGH; + case '?': + *unrecognized = optopt; + break; + default: + *unrecognized = c; + break; + } + } +} + +/* Reduce casting, so we can use string literals elsewhere. + getopt_long takes an array of char*, but luckily does not modify + those elements, so we can pass const char*. */ +static int +do_getopt_long (int argc, const char **argv, const char *shortopts, + const struct option *longopts, int *longind) +{ + return getopt_long (argc, (char **) argv, shortopts, longopts, longind); +} + +static void +test_getopt_long (void) +{ + int start; + + /* Test disambiguation of options. */ + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "--x"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index); + ASSERT (c == '?'); + ASSERT (optopt == 0); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "--xt"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index); + ASSERT (c == '?'); + ASSERT (optopt == 0); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "--xtr"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index); + ASSERT (c == '?'); + ASSERT (optopt == 0); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "--xtra"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index); + ASSERT (c == 1001); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "--xtre"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index); + ASSERT (c == '?'); + ASSERT (optopt == 0); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "--xtrem"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index); + ASSERT (c == '?'); + ASSERT (optopt == 0); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "--xtreme"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index); + ASSERT (c == 1002); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "--xtremel"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index); + ASSERT (c == 1003); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "--xtremely"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index); + ASSERT (c == 1003); + } + + /* Check that -W handles unknown options. */ + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-W"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "W;", long_options_required, &option_index); + ASSERT (c == '?'); + ASSERT (optopt == 'W'); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-Wunknown"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "W;", long_options_required, &option_index); + /* glibc and BSD behave differently here, but for now, we allow + both behaviors since W support is not frequently used. */ + if (c == '?') + { + ASSERT (optopt == 0); + ASSERT (optarg == NULL); + } + else + { + ASSERT (c == 'W'); + ASSERT (strcmp (optarg, "unknown") == 0); + } + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-W"; + argv[argc++] = "unknown"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "W;", long_options_required, &option_index); + /* glibc and BSD behave differently here, but for now, we allow + both behaviors since W support is not frequently used. */ + if (c == '?') + { + ASSERT (optopt == 0); + ASSERT (optarg == NULL); + } + else + { + ASSERT (c == 'W'); + ASSERT (strcmp (optarg, "unknown") == 0); + } + } + + /* Test that 'W' does not dump core: + https://sourceware.org/bugzilla/show_bug.cgi?id=12922 */ + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-W"; + argv[argc++] = "dummy"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "W;", NULL, &option_index); + ASSERT (c == 'W'); + ASSERT (optind == 2); + } + + /* Test processing of boolean short options. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-a"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "ab", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-b"; + argv[argc++] = "-a"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "ab", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 1); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 3); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-ba"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "ab", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 1); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-ab"; + argv[argc++] = "-a"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "ab", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 2); + ASSERT (b_seen == 1); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 3); + } + + /* Test processing of boolean long options. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "--alpha"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "ab", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "--beta"; + argv[argc++] = "--alpha"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "ab", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 1); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 3); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "--alpha"; + argv[argc++] = "--beta"; + argv[argc++] = "--alpha"; + argv[argc++] = "--beta"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "ab", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 2); + ASSERT (b_seen == 1); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 5); + } + + /* Test processing of boolean long options via -W. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-Walpha"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abW;", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-W"; + argv[argc++] = "beta"; + argv[argc++] = "-W"; + argv[argc++] = "alpha"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "aW;b", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 1); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 5); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-Walpha"; + argv[argc++] = "-Wbeta"; + argv[argc++] = "-Walpha"; + argv[argc++] = "-Wbeta"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "W;ab", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 2); + ASSERT (b_seen == 1); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 5); + } + + /* Test processing of short options with arguments. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-pfoo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 3); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-ab"; + argv[argc++] = "-q"; + argv[argc++] = "baz"; + argv[argc++] = "-pfoo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 1); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value != NULL && strcmp (q_value, "baz") == 0); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 5); + } + + /* Test processing of long options with arguments. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "--p=foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "--p"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 3); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-ab"; + argv[argc++] = "--q"; + argv[argc++] = "baz"; + argv[argc++] = "--p=foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 1); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value != NULL && strcmp (q_value, "baz") == 0); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 5); + } + + /* Test processing of long options with arguments via -W. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-Wp=foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p:q:W;", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-W"; + argv[argc++] = "p"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p:W;q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 4); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-ab"; + argv[argc++] = "-Wq"; + argv[argc++] = "baz"; + argv[argc++] = "-W"; + argv[argc++] = "p=foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "W;abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 1); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value != NULL && strcmp (q_value, "baz") == 0); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 6); + } + + /* Test processing of short options with optional arguments. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-pfoo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p::q::", long_options_optional, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p::q::", long_options_optional, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp::q::", long_options_optional, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 3); + } + + /* Test processing of long options with optional arguments. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "--p=foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p::q::", long_options_optional, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "--p"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p::q::", long_options_optional, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "--p="; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p::q::", long_options_optional, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && *p_value == '\0'); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "--p"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp::q::", long_options_optional, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 3); + } + + /* Test processing of long options with optional arguments via -W. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-Wp=foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p::q::W;", long_options_optional, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-Wp"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p::q::W;", long_options_optional, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-Wp="; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "W;p::q::", long_options_optional, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && *p_value == '\0'); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-W"; + argv[argc++] = "p="; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "W;p::q::", long_options_optional, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && *p_value == '\0'); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 3); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-W"; + argv[argc++] = "p"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "W;abp::q::", long_options_optional, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + /* ASSERT (p_value == NULL); */ + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 4); + } + + /* Check that invalid options are recognized. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "-x"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 'x'); + ASSERT (optind == 5); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "-:"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == ':'); + ASSERT (optind == 5); + } + + /* Check that unexpected arguments are recognized. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "--a="; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 'a'); + ASSERT (optind == 4); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "--b="; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + /* When flag is non-zero, glibc sets optopt anyway, but BSD + leaves optopt unchanged. */ + ASSERT (unrecognized == 1 || unrecognized == 0); + ASSERT (optind == 4); + } + + /* Check that by default, non-options arguments are moved to the end. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "-p") == 0); + ASSERT (strcmp (argv[2], "billy") == 0); + ASSERT (strcmp (argv[3], "-a") == 0); + ASSERT (strcmp (argv[4], "donald") == 0); + ASSERT (strcmp (argv[5], "duck") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 4); + } + + /* Check that '--' ends the argument processing. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[20]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "--"; + argv[argc++] = "-b"; + argv[argc++] = "foo"; + argv[argc++] = "-q"; + argv[argc++] = "johnny"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "-p") == 0); + ASSERT (strcmp (argv[2], "billy") == 0); + ASSERT (strcmp (argv[3], "-a") == 0); + ASSERT (strcmp (argv[4], "--") == 0); + ASSERT (strcmp (argv[5], "donald") == 0); + ASSERT (strcmp (argv[6], "duck") == 0); + ASSERT (strcmp (argv[7], "-b") == 0); + ASSERT (strcmp (argv[8], "foo") == 0); + ASSERT (strcmp (argv[9], "-q") == 0); + ASSERT (strcmp (argv[10], "johnny") == 0); + ASSERT (strcmp (argv[11], "bar") == 0); + ASSERT (argv[12] == NULL); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 5); + } + + /* Check that the '-' flag causes non-options to be returned in order. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "-abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 3); + ASSERT (strcmp (non_options[0], "donald") == 0); + ASSERT (strcmp (non_options[1], "duck") == 0); + ASSERT (strcmp (non_options[2], "bar") == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 7); + } + + /* Check that '--' ends the argument processing. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[20]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "--"; + argv[argc++] = "-b"; + argv[argc++] = "foo"; + argv[argc++] = "-q"; + argv[argc++] = "johnny"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "-abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "--") == 0); + ASSERT (strcmp (argv[7], "-b") == 0); + ASSERT (strcmp (argv[8], "foo") == 0); + ASSERT (strcmp (argv[9], "-q") == 0); + ASSERT (strcmp (argv[10], "johnny") == 0); + ASSERT (strcmp (argv[11], "bar") == 0); + ASSERT (argv[12] == NULL); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0); + ASSERT (q_value == NULL); + if (non_options_count == 2) + { + /* glibc behaviour. */ + ASSERT (non_options_count == 2); + ASSERT (strcmp (non_options[0], "donald") == 0); + ASSERT (strcmp (non_options[1], "duck") == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 7); + } + else + { + /* Another valid behaviour. */ + ASSERT (non_options_count == 7); + ASSERT (strcmp (non_options[0], "donald") == 0); + ASSERT (strcmp (non_options[1], "duck") == 0); + ASSERT (strcmp (non_options[2], "-b") == 0); + ASSERT (strcmp (non_options[3], "foo") == 0); + ASSERT (strcmp (non_options[4], "-q") == 0); + ASSERT (strcmp (non_options[5], "johnny") == 0); + ASSERT (strcmp (non_options[6], "bar") == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 12); + } + } + + /* Check that the '-' flag has to come first. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp:q:-", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "-p") == 0); + ASSERT (strcmp (argv[2], "billy") == 0); + ASSERT (strcmp (argv[3], "-a") == 0); + ASSERT (strcmp (argv[4], "donald") == 0); + ASSERT (strcmp (argv[5], "duck") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 4); + } + + /* Check that the '+' flag causes the first non-option to terminate the + loop. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "+abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 1); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-+"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "+abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == '+'); + ASSERT (optind == 2); + } + + /* Check that '--' ends the argument processing. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[20]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "--"; + argv[argc++] = "-b"; + argv[argc++] = "foo"; + argv[argc++] = "-q"; + argv[argc++] = "johnny"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "+abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "--") == 0); + ASSERT (strcmp (argv[7], "-b") == 0); + ASSERT (strcmp (argv[8], "foo") == 0); + ASSERT (strcmp (argv[9], "-q") == 0); + ASSERT (strcmp (argv[10], "johnny") == 0); + ASSERT (strcmp (argv[11], "bar") == 0); + ASSERT (argv[12] == NULL); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 1); + } + + /* Check that the '+' flag has to come first. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp:q:+", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "-p") == 0); + ASSERT (strcmp (argv[2], "billy") == 0); + ASSERT (strcmp (argv[3], "-a") == 0); + ASSERT (strcmp (argv[4], "donald") == 0); + ASSERT (strcmp (argv[5], "duck") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 4); + } +} + +/* Test behavior of getopt_long when POSIXLY_CORRECT is set in the + environment. Options with optional arguments should not change + behavior just because of an environment variable. + https://lists.gnu.org/r/bug-m4/2006-09/msg00028.html */ +static void +test_getopt_long_posix (void) +{ + int start; + + /* Check that POSIXLY_CORRECT stops parsing the same as leading '+'. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 1); + } + + /* Check that POSIXLY_CORRECT doesn't change optional arguments. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p::", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + + /* Check that leading - still sees options after non-options. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-a"; + argv[argc++] = "billy"; + argv[argc++] = "-b"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "-ab", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 1); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 1); + ASSERT (strcmp (non_options[0], "billy") == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 4); + } +} + +/* Reduce casting, so we can use string literals elsewhere. + getopt_long_only takes an array of char*, but luckily does not + modify those elements, so we can pass const char*. */ +static int +do_getopt_long_only (int argc, const char **argv, const char *shortopts, + const struct option *longopts, int *longind) +{ + return getopt_long_only (argc, (char **) argv, shortopts, longopts, longind); +} + +static void +test_getopt_long_only (void) +{ + /* Test disambiguation of options. */ + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-x"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long_only (argc, argv, "ab", long_options_required, + &option_index); + ASSERT (c == '?'); + ASSERT (optopt == 0); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-x"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long_only (argc, argv, "abx", long_options_required, + &option_index); + ASSERT (c == 'x'); + ASSERT (optopt == 0); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "--x"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long_only (argc, argv, "abx", long_options_required, + &option_index); + ASSERT (c == '?'); + ASSERT (optopt == 0); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-b"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + b_seen = 0; + c = do_getopt_long_only (argc, argv, "abx", long_options_required, + &option_index); + ASSERT (c == 'b'); + ASSERT (b_seen == 0); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "--b"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + b_seen = 0; + c = do_getopt_long_only (argc, argv, "abx", long_options_required, + &option_index); + ASSERT (c == 0); + ASSERT (b_seen == 1); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-xt"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long_only (argc, argv, "ab", long_options_required, + &option_index); + ASSERT (c == '?'); + ASSERT (optopt == 0); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-xt"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long_only (argc, argv, "abx", long_options_required, + &option_index); + ASSERT (c == '?'); + ASSERT (optopt == 0); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-xtra"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long_only (argc, argv, "ab", long_options_required, + &option_index); + ASSERT (c == 1001); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-xtreme"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long_only (argc, argv, "abx:", long_options_required, + &option_index); + ASSERT (c == 1002); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-xtremel"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long_only (argc, argv, "ab", long_options_required, + &option_index); + /* glibc getopt_long_only is intentionally different from + getopt_long when handling a prefix that is common to two + spellings, when both spellings have the same option directives. + BSD getopt_long_only treats both cases the same. */ + ASSERT (c == 1003 || c == '?'); + ASSERT (optind == 2); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-xtremel"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long_only (argc, argv, "abx::", long_options_required, + &option_index); + /* glibc getopt_long_only is intentionally different from + getopt_long when handling a prefix that is common to two + spellings, when both spellings have the same option directives. + BSD getopt_long_only treats both cases the same. */ + ASSERT (c == 1003 || c == '?'); + ASSERT (optind == 2); + ASSERT (optarg == NULL); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-xtras"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long_only (argc, argv, "abx::", long_options_required, + &option_index); + ASSERT (c == 'x'); + ASSERT (strcmp (optarg, "tras") == 0); + } +} diff --git a/gnulib-tests/test-getprogname.c b/gnulib-tests/test-getprogname.c new file mode 100644 index 0000000..38163ea --- /dev/null +++ b/gnulib-tests/test-getprogname.c @@ -0,0 +1,58 @@ +/* Test the gnulib getprogname module. + Copyright (C) 2016-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include "getprogname.h" +#include <string.h> +#include <assert.h> + +#ifdef __hpux +# define STREQ(a, b) (strncmp (a, b, 14) == 0) +#else +# define STREQ(a, b) (strcmp (a, b) == 0) +#endif + +int +main (void) +{ + char const *p = getprogname (); + + /* libtool creates a temporary executable whose name is sometimes prefixed + with "lt-" (depends on the platform). But the name of the temporary + executable is a detail that should not be visible to the end user and to + the test suite. Remove this "lt-" prefix here. */ + if (strncmp (p, "lt-", 3) == 0) + p += 3; + + /* Note: You can make this test fail + a) by running it on a case-insensitive file system (such as on Windows, + Cygwin, or on Mac OS X with a case-insensitive HFS+ file system), + with an invocation that contains upper case characters, e.g. + test-GETPROGNAME, + b) by hardlinking or symlinking it to a different name (e.g. test-foo) + and invoking it through that name. + That's not the intended use. The Makefile always invokes it as + 'test-getprogname${EXEEXT}'. */ +#if defined __CYGWIN__ + /* The Cygwin getprogname() function strips the ".exe" suffix. */ + assert (STREQ (p, "test-getprogname")); +#else + assert (STREQ (p, "test-getprogname" EXEEXT)); +#endif + + return 0; +} diff --git a/gnulib-tests/test-getrusage.c b/gnulib-tests/test-getrusage.c new file mode 100644 index 0000000..a201236 --- /dev/null +++ b/gnulib-tests/test-getrusage.c @@ -0,0 +1,86 @@ +/* Test of getting resource utilization. + Copyright (C) 2012-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2012. */ + +#include <config.h> + +#include <sys/resource.h> + +#include "signature.h" +SIGNATURE_CHECK (getrusage, int, (int, struct rusage *)); + +#include <sys/time.h> + +#include "macros.h" + +volatile unsigned int counter; + +int +main (void) +{ + struct rusage before; + struct rusage after; + int ret; + + ret = getrusage (RUSAGE_SELF, &before); + ASSERT (ret == 0); + + /* Busy-loop for one second. */ + { + struct timeval t0; + ASSERT (gettimeofday (&t0, NULL) == 0); + + for (;;) + { + struct timeval t; + int i; + + for (i = 0; i < 1000000; i++) + counter++; + + ASSERT (gettimeofday (&t, NULL) == 0); + if (t.tv_sec - t0.tv_sec > 1 + || (t.tv_sec - t0.tv_sec == 1 && t.tv_usec >= t0.tv_usec)) + break; + } + } + + ret = getrusage (RUSAGE_SELF, &after); + ASSERT (ret == 0); + + ASSERT (after.ru_utime.tv_sec >= before.ru_utime.tv_sec); + ASSERT (after.ru_stime.tv_sec >= before.ru_stime.tv_sec); + { + /* Compute time spent during busy-looping (in usec). */ + unsigned int spent_utime = + (after.ru_utime.tv_sec > before.ru_utime.tv_sec + ? (after.ru_utime.tv_sec - before.ru_utime.tv_sec - 1) * 1000000U + + after.ru_utime.tv_usec + (1000000U - before.ru_utime.tv_usec) + : after.ru_utime.tv_usec - before.ru_utime.tv_usec); + unsigned int spent_stime = + (after.ru_stime.tv_sec > before.ru_stime.tv_sec + ? (after.ru_stime.tv_sec - before.ru_stime.tv_sec - 1) * 1000000U + + after.ru_stime.tv_usec + (1000000U - before.ru_stime.tv_usec) + : after.ru_stime.tv_usec - before.ru_stime.tv_usec); + + ASSERT (spent_utime + spent_stime <= 2 * 1000000U); + /* Assume that the load during this busy-looping was less than 100. */ + ASSERT (spent_utime + spent_stime > 10000U); + } + + return 0; +} diff --git a/gnulib-tests/test-gettimeofday.c b/gnulib-tests/test-gettimeofday.c new file mode 100644 index 0000000..4ce4107 --- /dev/null +++ b/gnulib-tests/test-gettimeofday.c @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2005, 2007, 2009-2020 Free Software Foundation, Inc. + * Written by Jim Meyering. + * + * 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <sys/time.h> + +#include "signature.h" +SIGNATURE_CHECK (gettimeofday, int, + (struct timeval *, GETTIMEOFDAY_TIMEZONE *)); + +#include <time.h> + +#include <stdio.h> +#include <string.h> + +int +main (void) +{ + time_t t = 0; + struct tm *lt; + struct tm saved_lt; + struct timeval tv; + lt = localtime (&t); + saved_lt = *lt; + gettimeofday (&tv, NULL); + if (memcmp (lt, &saved_lt, sizeof (struct tm)) != 0) + { + fprintf (stderr, "gettimeofday still clobbers the localtime buffer!\n"); + return 1; + } + return 0; +} diff --git a/gnulib-tests/test-hard-locale.c b/gnulib-tests/test-hard-locale.c new file mode 100644 index 0000000..e232123 --- /dev/null +++ b/gnulib-tests/test-hard-locale.c @@ -0,0 +1,109 @@ +/* Test of determination whether a locale is different from the "C" locale. + Copyright (C) 2019-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2019. */ + +#include <config.h> + +#include "hard-locale.h" + +#include <locale.h> +#include <stdbool.h> +#include <stdio.h> +#include <string.h> + +/* True if all locale names are accepted and all locales are trivial. + This is the case e.g. on OpenBSD 3.8. */ +static bool all_trivial; + +static int +test_one (const char *name, int failure_bitmask) +{ + if (setlocale (LC_ALL, name) != NULL) + { + bool expected; + + /* musl libc has special code for the C.UTF-8 locale; other than that, + all locale names are accepted and all locales are trivial. + OpenBSD returns the locale name that was set, but we don't know how it + behaves under the hood. Likewise for Haiku. */ +#if defined MUSL_LIBC || defined __OpenBSD__ || defined __HAIKU__ + expected = true; +#else + expected = !all_trivial; +#endif + if (hard_locale (LC_CTYPE) != expected) + { + if (expected) + fprintf (stderr, "Unexpected: The category LC_CTYPE of the locale '%s' is not equivalent to C or POSIX.\n", + name); + else + fprintf (stderr, "Unexpected: The category LC_CTYPE of the locale '%s' is equivalent to C or POSIX.\n", + name); + return failure_bitmask; + } + + /* On NetBSD 7.0, some locales such as de_DE.ISO8859-1 and de_DE.UTF-8 + have the LC_COLLATE category set to "C". + Similarly, on musl libc, with the C.UTF-8 locale. */ +#if defined __NetBSD__ + expected = false; +#elif defined MUSL_LIBC + expected = strcmp (name, "C.UTF-8") != 0; +#elif (defined __OpenBSD__ && HAVE_DUPLOCALE) || defined __HAIKU__ /* OpenBSD >= 6.2, Haiku */ + expected = true; +#else + expected = !all_trivial; +#endif + if (hard_locale (LC_COLLATE) != expected) + { + if (expected) + fprintf (stderr, "Unexpected: The category LC_COLLATE of the locale '%s' is not equivalent to C or POSIX.\n", + name); + else + fprintf (stderr, "Unexpected: The category LC_COLLATE of the locale '%s' is equivalent to C or POSIX.\n", + name); + return failure_bitmask; + } + } + return 0; +} + +int +main () +{ + int fail = 0; + + /* The initial locale is the "C" or "POSIX" locale. */ + if (hard_locale (LC_CTYPE) || hard_locale (LC_COLLATE)) + { + fprintf (stderr, "The initial locale should not be hard!\n"); + fail |= 1; + } + + all_trivial = (setlocale (LC_ALL, "foobar") != NULL); + + fail |= test_one ("de", 2); + fail |= test_one ("de_DE", 4); + fail |= test_one ("de_DE.ISO8859-1", 8); + fail |= test_one ("de_DE.iso88591", 8); + fail |= test_one ("de_DE.UTF-8", 16); + fail |= test_one ("de_DE.utf8", 16); + fail |= test_one ("german", 32); + fail |= test_one ("C.UTF-8", 64); + + return fail; +} diff --git a/gnulib-tests/test-hash.c b/gnulib-tests/test-hash.c new file mode 100644 index 0000000..67d9519 --- /dev/null +++ b/gnulib-tests/test-hash.c @@ -0,0 +1,263 @@ +/* + * Copyright (C) 2009-2020 Free Software Foundation, Inc. + * Written by Jim Meyering + * + * 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include "hash.h" +#include "hash-pjw.h" +#include "inttostr.h" + +#include <stdio.h> +#include <stdlib.h> +#include <stdbool.h> +#include <string.h> +#include <unistd.h> + +#include "macros.h" + +#define STREQ(a, b) (strcmp (a, b) == 0) +#define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array)) + +static bool +hash_compare_strings (void const *x, void const *y) +{ + ASSERT (x != y); + return STREQ (x, y) ? true : false; +} + +static void +hash_freer (void *x) +{ + free (x); +} + +static void +insert_new (Hash_table *ht, const void *ent) +{ + void *e = hash_insert (ht, ent); + ASSERT (e == ent); +} + +static bool +walk (void *ent, void *data) +{ + char *str = ent; + unsigned int *map = data; + switch (*str) + { + case 'a': *map |= 1; return true; + case 'b': *map |= 2; return true; + case 'c': *map |= 4; return true; + } + *map |= 8; + return false; +} + +static int +get_seed (char const *str, unsigned int *seed) +{ + size_t len = strlen (str); + if (len == 0 || strspn (str, "0123456789") != len || 10 < len) + return 1; + + *seed = atoi (str); + return 0; +} + +int +main (int argc, char **argv) +{ + unsigned int i; + unsigned int k; + unsigned int table_size[] = {1, 2, 3, 4, 5, 23, 53}; + Hash_table *ht; + Hash_tuning tuning; + + hash_reset_tuning (&tuning); + tuning.shrink_threshold = 0.3; + tuning.shrink_factor = 0.707; + tuning.growth_threshold = 1.5; + tuning.growth_factor = 2.0; + tuning.is_n_buckets = true; + + if (1 < argc) + { + unsigned int seed; + if (get_seed (argv[1], &seed) != 0) + { + fprintf (stderr, "invalid seed: %s\n", argv[1]); + exit (EXIT_FAILURE); + } + + srand (seed); + } + + for (i = 0; i < ARRAY_CARDINALITY (table_size); i++) + { + size_t sz = table_size[i]; + ht = hash_initialize (sz, NULL, hash_pjw, hash_compare_strings, NULL); + ASSERT (ht); + insert_new (ht, "a"); + { + char *str1 = strdup ("a"); + char *str2; + ASSERT (str1); + str2 = hash_insert (ht, str1); + ASSERT (str1 != str2); + ASSERT (STREQ (str1, str2)); + free (str1); + } + insert_new (ht, "b"); + insert_new (ht, "c"); + i = 0; + ASSERT (hash_do_for_each (ht, walk, &i) == 3); + ASSERT (i == 7); + { + void *buf[5] = { NULL }; + ASSERT (hash_get_entries (ht, NULL, 0) == 0); + ASSERT (hash_get_entries (ht, buf, 5) == 3); + ASSERT (STREQ (buf[0], "a") || STREQ (buf[0], "b") || STREQ (buf[0], "c")); + } + ASSERT (hash_delete (ht, "a")); + ASSERT (hash_delete (ht, "a") == NULL); + ASSERT (hash_delete (ht, "b")); + ASSERT (hash_delete (ht, "c")); + + ASSERT (hash_rehash (ht, 47)); + ASSERT (hash_rehash (ht, 467)); + + /* Free an empty table. */ + hash_clear (ht); + hash_free (ht); + + ht = hash_initialize (sz, NULL, hash_pjw, hash_compare_strings, NULL); + ASSERT (ht); + + insert_new (ht, "z"); + insert_new (ht, "y"); + insert_new (ht, "x"); + insert_new (ht, "w"); + insert_new (ht, "v"); + insert_new (ht, "u"); + + hash_clear (ht); + ASSERT (hash_get_n_entries (ht) == 0); + hash_free (ht); + + /* Test pointer hashing. */ + ht = hash_initialize (sz, NULL, NULL, NULL, NULL); + ASSERT (ht); + { + char *str = strdup ("a"); + ASSERT (str); + insert_new (ht, "a"); + insert_new (ht, str); + ASSERT (hash_lookup (ht, str) == str); + free (str); + } + hash_free (ht); + } + + hash_reset_tuning (&tuning); + tuning.shrink_threshold = 0.3; + tuning.shrink_factor = 0.707; + tuning.growth_threshold = 1.5; + tuning.growth_factor = 2.0; + tuning.is_n_buckets = true; + /* Invalid tuning. */ + ht = hash_initialize (4651, &tuning, hash_pjw, hash_compare_strings, + hash_freer); + ASSERT (!ht); + + /* Alternate tuning. */ + tuning.growth_threshold = 0.89; + + /* Run with default tuning, then with custom tuning settings. */ + for (k = 0; k < 2; k++) + { + Hash_tuning const *tune = (k == 0 ? NULL : &tuning); + /* Now, each entry is malloc'd. */ + ht = hash_initialize (4651, tune, hash_pjw, + hash_compare_strings, hash_freer); + ASSERT (ht); + for (i = 0; i < 10000; i++) + { + unsigned int op = rand () % 10; + switch (op) + { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + { + char buf[50]; + char const *p = uinttostr (i, buf); + char *p_dup = strdup (p); + ASSERT (p_dup); + insert_new (ht, p_dup); + } + break; + + case 6: + { + size_t n = hash_get_n_entries (ht); + ASSERT (hash_rehash (ht, n + rand () % 20)); + } + break; + + case 7: + { + size_t n = hash_get_n_entries (ht); + size_t delta = rand () % 20; + if (delta < n) + ASSERT (hash_rehash (ht, n - delta)); + } + break; + + case 8: + case 9: + { + /* Delete a random entry. */ + size_t n = hash_get_n_entries (ht); + if (n) + { + size_t kk = rand () % n; + void const *p; + void *v; + for (p = hash_get_first (ht); kk; + --kk, p = hash_get_next (ht, p)) + { + /* empty */ + } + ASSERT (p); + v = hash_delete (ht, p); + ASSERT (v); + free (v); + } + break; + } + } + ASSERT (hash_table_ok (ht)); + } + + hash_free (ht); + } + + return 0; +} diff --git a/gnulib-tests/test-i-ring.c b/gnulib-tests/test-i-ring.c new file mode 100644 index 0000000..a299917 --- /dev/null +++ b/gnulib-tests/test-i-ring.c @@ -0,0 +1,63 @@ +/* Test the simple ring buffer. + Copyright (C) 2006-2020 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 <https://www.gnu.org/licenses/>. */ + +/* written by Jim Meyering */ + +#include <config.h> + +#include "i-ring.h" + +#include "macros.h" + +int +main (void) +{ + int o; + I_ring ir; + i_ring_init (&ir, -1); + o = i_ring_push (&ir, 1); + ASSERT (o == -1); + o = i_ring_push (&ir, 2); + ASSERT (o == -1); + o = i_ring_push (&ir, 3); + ASSERT (o == -1); + o = i_ring_push (&ir, 4); + ASSERT (o == -1); + o = i_ring_push (&ir, 5); + ASSERT (o == 1); + o = i_ring_push (&ir, 6); + ASSERT (o == 2); + o = i_ring_push (&ir, 7); + ASSERT (o == 3); + + o = i_ring_pop (&ir); + ASSERT (o == 7); + o = i_ring_pop (&ir); + ASSERT (o == 6); + o = i_ring_pop (&ir); + ASSERT (o == 5); + o = i_ring_pop (&ir); + ASSERT (o == 4); + ASSERT (i_ring_empty (&ir)); + + o = i_ring_push (&ir, 8); + ASSERT (o == -1); + o = i_ring_pop (&ir); + ASSERT (o == 8); + ASSERT (i_ring_empty (&ir)); + + return 0; +} diff --git a/gnulib-tests/test-iconv-h.c b/gnulib-tests/test-iconv-h.c new file mode 100644 index 0000000..d044011 --- /dev/null +++ b/gnulib-tests/test-iconv-h.c @@ -0,0 +1,27 @@ +/* Test of <iconv.h> substitute. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#if HAVE_ICONV +# include <iconv.h> +#endif + +int +main () +{ + return 0; +} diff --git a/gnulib-tests/test-iconv.c b/gnulib-tests/test-iconv.c new file mode 100644 index 0000000..895f6de --- /dev/null +++ b/gnulib-tests/test-iconv.c @@ -0,0 +1,159 @@ +/* Test of character set conversion. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#if HAVE_ICONV +# include <iconv.h> + +# ifndef ICONV_CONST +# define ICONV_CONST /* empty */ +# endif + +#include "signature.h" +SIGNATURE_CHECK (iconv, size_t, (iconv_t, ICONV_CONST char **, size_t *, + char **, size_t *)); +SIGNATURE_CHECK (iconv_close, int, (iconv_t x)); +SIGNATURE_CHECK (iconv_open, iconv_t, (char const *, char const *)); + +#endif + +#include <errno.h> +#include <string.h> + +#include "macros.h" + +int +main () +{ +#if HAVE_ICONV + /* Assume that iconv() supports at least the encodings ASCII, ISO-8859-1, + and UTF-8. */ + iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1"); + iconv_t cd_utf8_to_88591 = iconv_open ("ISO-8859-1", "UTF-8"); + +#if defined __MVS__ && defined __IBMC__ + /* String literals below are in ASCII, not EBCDIC. */ +# pragma convert("ISO8859-1") +# define CONVERT_ENABLED +#endif + + ASSERT (cd_88591_to_utf8 != (iconv_t)(-1)); + ASSERT (cd_utf8_to_88591 != (iconv_t)(-1)); + + /* Test conversion from ISO-8859-1 to UTF-8 with no errors. */ + { + static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; + static const char expected[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237"; + char buf[50]; + const char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_88591_to_utf8, + (ICONV_CONST char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + ASSERT (res == 0 && inbytesleft == 0); + ASSERT (outptr == buf + strlen (expected)); + ASSERT (memcmp (buf, expected, strlen (expected)) == 0); + } + + /* Test conversion from ISO-8859-1 to UTF-8 with E2BIG. */ + { + static const char input[] = "\304"; + static char buf[2] = { (char)0xDE, (char)0xAD }; + const char *inptr = input; + size_t inbytesleft = 1; + char *outptr = buf; + size_t outbytesleft = 1; + size_t res = iconv (cd_88591_to_utf8, + (ICONV_CONST char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + ASSERT (res == (size_t)(-1) && errno == E2BIG); + ASSERT (inbytesleft == 1); + ASSERT (outbytesleft == 1); + ASSERT ((unsigned char) buf[1] == 0xAD); + ASSERT ((unsigned char) buf[0] == 0xDE); + } + + /* Test conversion from UTF-8 to ISO-8859-1 with no errors. */ + { + static const char input[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237"; + static const char expected[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; + char buf[50]; + const char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_utf8_to_88591, + (ICONV_CONST char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + ASSERT (res == 0 && inbytesleft == 0); + ASSERT (outptr == buf + strlen (expected)); + ASSERT (memcmp (buf, expected, strlen (expected)) == 0); + } + + /* Test conversion from UTF-8 to ISO-8859-1 with EILSEQ. */ + { + static const char input[] = "\342\202\254"; /* EURO SIGN */ + char buf[10]; + const char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_utf8_to_88591, + (ICONV_CONST char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + if (res == (size_t)(-1)) + { + ASSERT (errno == EILSEQ); + ASSERT (inbytesleft == strlen (input) && outptr == buf); + } + else + { + ASSERT (res == 1); + ASSERT (inbytesleft == 0); + } + } + + /* Test conversion from UTF-8 to ISO-8859-1 with EINVAL. */ + { + static const char input[] = "\342"; + char buf[10]; + const char *inptr = input; + size_t inbytesleft = 1; + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_utf8_to_88591, + (ICONV_CONST char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + ASSERT (res == (size_t)(-1) && errno == EINVAL); + ASSERT (inbytesleft == 1 && outptr == buf); + } + + iconv_close (cd_88591_to_utf8); + iconv_close (cd_utf8_to_88591); + +#ifdef CONVERT_ENABLED +# pragma convert(pop) +#endif + +#endif /* HAVE_ICONV */ + + return 0; +} diff --git a/gnulib-tests/test-ignore-value.c b/gnulib-tests/test-ignore-value.c new file mode 100644 index 0000000..f323a7b --- /dev/null +++ b/gnulib-tests/test-ignore-value.c @@ -0,0 +1,84 @@ +/* Test the "ignore-value" module. + + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake. */ + +#include <config.h> + +#include "ignore-value.h" + +#include <stdio.h> + +#ifndef _GL_ATTRIBUTE_RETURN_CHECK +# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4) +# define _GL_ATTRIBUTE_RETURN_CHECK +# else +# define _GL_ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__)) +# endif +#endif + +struct s { int i; }; +static char doChar (void) _GL_ATTRIBUTE_RETURN_CHECK; +static int doInt (void) _GL_ATTRIBUTE_RETURN_CHECK; +static off_t doOff (void) _GL_ATTRIBUTE_RETURN_CHECK; +static void *doPtr (void) _GL_ATTRIBUTE_RETURN_CHECK; +static struct s doStruct (void) _GL_ATTRIBUTE_RETURN_CHECK; + +static char +doChar (void) +{ + return 0; +} + +static int +doInt (void) +{ + return 0; +} + +static off_t +doOff (void) +{ + return 0; +} + +static void * +doPtr (void) +{ + return NULL; +} + +static struct s +doStruct (void) +{ + static struct s s1; + return s1; +} + +int +main (void) +{ + /* If this test can compile with -Werror and the same warnings as + the rest of the project, then we are properly silencing warnings + about ignored return values. */ + ignore_value (doChar ()); + ignore_value (doInt ()); + ignore_value (doOff ()); + ignore_value (doPtr ()); + ignore_value (doStruct ()); + return 0; +} diff --git a/gnulib-tests/test-inet_ntop.c b/gnulib-tests/test-inet_ntop.c new file mode 100644 index 0000000..0bbc4dd --- /dev/null +++ b/gnulib-tests/test-inet_ntop.c @@ -0,0 +1,56 @@ +/* Test of inet_ntop function. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2009. */ + +#include <config.h> + +#include <arpa/inet.h> + +#include "signature.h" +SIGNATURE_CHECK (inet_ntop, char const *, (int, void const *, char *, + socklen_t)); + +#include <netinet/in.h> +#include <sys/socket.h> +#include <string.h> + +#include "macros.h" + +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/gnulib-tests/test-inet_pton.c b/gnulib-tests/test-inet_pton.c new file mode 100644 index 0000000..8ae0fe2 --- /dev/null +++ b/gnulib-tests/test-inet_pton.c @@ -0,0 +1,58 @@ +/* Test of inet_pton function. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2009. */ + +#include <config.h> + +#include <arpa/inet.h> + +#include "signature.h" +SIGNATURE_CHECK (inet_pton, int, (int, const char *, void *)); + +#include <netinet/in.h> +#include <sys/socket.h> + +#include "macros.h" + +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/gnulib-tests/test-init.sh b/gnulib-tests/test-init.sh new file mode 100755 index 0000000..e9d2524 --- /dev/null +++ b/gnulib-tests/test-init.sh @@ -0,0 +1,74 @@ +#!/bin/sh +# Unit tests for init.sh +# Copyright (C) 2011-2020 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# 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 <https://www.gnu.org/licenses/>. */ + +: ${srcdir=.} +. "$srcdir/init.sh"; path_prepend_ . + +fail=0 + +test_compare() +{ + touch empty || fail=1 + echo xyz > in || fail=1 + + compare /dev/null /dev/null >out 2>err || fail=1 + test -s out && fail_ "out not empty: $(cat out)" + # "err" should be empty, too, but has "set -x" output when VERBOSE=yes + case $- in *x*) ;; *) test -s err && fail_ "err not empty: $(cat err)";; esac + + compare /dev/null empty >out 2>err || fail=1 + test -s out && fail_ "out not empty: $(cat out)" + case $- in *x*) ;; *) test -s err && fail_ "err not empty: $(cat err)";; esac + + compare in in >out 2>err || fail=1 + test -s out && fail_ "out not empty: $(cat out)" + case $- in *x*) ;; *) test -s err && fail_ "err not empty: $(cat err)";; esac + + compare /dev/null in >out 2>err && fail=1 + cat <<\EOF > exp +diff -u /dev/null in +--- /dev/null 1970-01-01 ++++ in 1970-01-01 ++xyz +EOF + compare exp out || fail=1 + case $- in *x*) ;; *) test -s err && fail_ "err not empty: $(cat err)";; esac + + compare empty in >out 2>err && fail=1 + # Compare against expected output only if compare is using diff -u. + if grep @ out >/dev/null; then + # Remove the TAB-date suffix on each --- and +++ line, + # for both the expected and the actual output files. + # Also remove the @@ line, since Solaris 5.10 and GNU diff formats differ: + # -@@ -0,0 +1 @@ + # +@@ -1,0 +1,1 @@ + # Also, remove space after leading '+', since AIX 7.1 diff outputs a space. + sed 's/ .*//;/^@@/d;s/^+ /+/' out > k && mv k out + cat <<\EOF > exp +--- empty ++++ in ++xyz +EOF + compare exp out || fail=1 + fi + case $- in *x*) ;; *) test -s err && fail_ "err not empty: $(cat err)";; esac +} + +test_compare + +Exit $fail diff --git a/gnulib-tests/test-ino-map.c b/gnulib-tests/test-ino-map.c new file mode 100644 index 0000000..5a7c74f --- /dev/null +++ b/gnulib-tests/test-ino-map.c @@ -0,0 +1,50 @@ +/* Test the ino-map module. + Copyright (C) 2010-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Jim Meyering. */ + +#include <config.h> + +#include "ino-map.h" + +#include "macros.h" + +int +main () +{ + enum { INO_MAP_INIT = 123 }; + struct ino_map *ino_map = ino_map_alloc (INO_MAP_INIT); + ASSERT (ino_map != NULL); + + ASSERT (ino_map_insert (ino_map, 42) == INO_MAP_INIT); + ASSERT (ino_map_insert (ino_map, 42) == INO_MAP_INIT); + ASSERT (ino_map_insert (ino_map, 398) == INO_MAP_INIT + 1); + ASSERT (ino_map_insert (ino_map, 398) == INO_MAP_INIT + 1); + ASSERT (ino_map_insert (ino_map, 0) == INO_MAP_INIT + 2); + ASSERT (ino_map_insert (ino_map, 0) == INO_MAP_INIT + 2); + + { + int i; + for (i = 0; i < 100; i++) + { + ASSERT (ino_map_insert (ino_map, 10000 + i) == INO_MAP_INIT + 3 + i); + } + } + + ino_map_free (ino_map); + + return 0; +} diff --git a/gnulib-tests/test-intprops.c b/gnulib-tests/test-intprops.c new file mode 100644 index 0000000..a56b18e --- /dev/null +++ b/gnulib-tests/test-intprops.c @@ -0,0 +1,441 @@ +/* Test intprops.h. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Paul Eggert. */ + +/* Tell gcc not to warn about the long expressions that the overflow + macros expand to, or about the (X < 0) expressions. */ +#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +# pragma GCC diagnostic ignored "-Woverlength-strings" +# pragma GCC diagnostic ignored "-Wtype-limits" + +/* Work around a bug in GCC 6.1 and earlier; see: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68971 */ +# pragma GCC diagnostic ignored "-Woverflow" + +#endif + +#include <config.h> + +#include "intprops.h" +#include "verify.h" + +#include <stdbool.h> +#include <inttypes.h> +#include <limits.h> + +#include "macros.h" + +/* Compile-time verification of expression X. + In this file, we need it as a statement, rather than as a declaration. */ +#define verify_stmt(x) do { verify (x); } while (0) + +/* VERIFY (X) uses a static assertion for compilers that are known to work, + and falls back on a dynamic assertion for other compilers. + These tests should be checkable via 'verify' rather than 'ASSERT', but + using 'verify' would run into a bug with HP-UX 11.23 cc; see + <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00401.html>. */ +#if __GNUC__ || __SUNPRO_C +# define VERIFY(x) verify_stmt (x) +#else +# define VERIFY(x) ASSERT (x) +#endif + +#define DONTCARE __LINE__ + +int int_minus_2 = -2; +int int_1 = 1; + +int +main (void) +{ + /* Use VERIFY for tests that must be integer constant expressions, + ASSERT otherwise. */ + + /* TYPE_IS_INTEGER. */ + ASSERT (TYPE_IS_INTEGER (bool)); + ASSERT (TYPE_IS_INTEGER (char)); + ASSERT (TYPE_IS_INTEGER (signed char)); + ASSERT (TYPE_IS_INTEGER (unsigned char)); + ASSERT (TYPE_IS_INTEGER (short int)); + ASSERT (TYPE_IS_INTEGER (unsigned short int)); + ASSERT (TYPE_IS_INTEGER (int)); + ASSERT (TYPE_IS_INTEGER (unsigned int)); + ASSERT (TYPE_IS_INTEGER (long int)); + ASSERT (TYPE_IS_INTEGER (unsigned long int)); + ASSERT (TYPE_IS_INTEGER (intmax_t)); + ASSERT (TYPE_IS_INTEGER (uintmax_t)); + ASSERT (! TYPE_IS_INTEGER (float)); + ASSERT (! TYPE_IS_INTEGER (double)); + ASSERT (! TYPE_IS_INTEGER (long double)); + + /* TYPE_SIGNED. */ + /* VERIFY (! TYPE_SIGNED (bool)); // not guaranteed by gnulib substitute */ + VERIFY (TYPE_SIGNED (signed char)); + VERIFY (! TYPE_SIGNED (unsigned char)); + VERIFY (TYPE_SIGNED (short int)); + VERIFY (! TYPE_SIGNED (unsigned short int)); + VERIFY (TYPE_SIGNED (int)); + VERIFY (! TYPE_SIGNED (unsigned int)); + VERIFY (TYPE_SIGNED (long int)); + VERIFY (! TYPE_SIGNED (unsigned long int)); + VERIFY (TYPE_SIGNED (intmax_t)); + VERIFY (! TYPE_SIGNED (uintmax_t)); + ASSERT (TYPE_SIGNED (float)); + ASSERT (TYPE_SIGNED (double)); + ASSERT (TYPE_SIGNED (long double)); + + /* Integer representation. Check that it is two's complement. */ + VERIFY (INT_MIN + INT_MAX < 0); + + /* TYPE_MINIMUM, TYPE_MAXIMUM. */ + VERIFY (TYPE_MINIMUM (char) == CHAR_MIN); + VERIFY (TYPE_MAXIMUM (char) == CHAR_MAX); + VERIFY (TYPE_MINIMUM (unsigned char) == 0); + VERIFY (TYPE_MAXIMUM (unsigned char) == UCHAR_MAX); + VERIFY (TYPE_MINIMUM (signed char) == SCHAR_MIN); + VERIFY (TYPE_MAXIMUM (signed char) == SCHAR_MAX); + VERIFY (TYPE_MINIMUM (short int) == SHRT_MIN); + VERIFY (TYPE_MAXIMUM (short int) == SHRT_MAX); + VERIFY (TYPE_MINIMUM (unsigned short int) == 0); + VERIFY (TYPE_MAXIMUM (unsigned short int) == USHRT_MAX); + VERIFY (TYPE_MINIMUM (int) == INT_MIN); + VERIFY (TYPE_MAXIMUM (int) == INT_MAX); + VERIFY (TYPE_MINIMUM (unsigned int) == 0); + VERIFY (TYPE_MAXIMUM (unsigned int) == UINT_MAX); + VERIFY (TYPE_MINIMUM (long int) == LONG_MIN); + VERIFY (TYPE_MAXIMUM (long int) == LONG_MAX); + VERIFY (TYPE_MINIMUM (unsigned long int) == 0); + VERIFY (TYPE_MAXIMUM (unsigned long int) == ULONG_MAX); + #ifdef LLONG_MAX + verify_stmt (TYPE_MINIMUM (long long int) == LLONG_MIN); + verify_stmt (TYPE_MAXIMUM (long long int) == LLONG_MAX); + verify_stmt (TYPE_MINIMUM (unsigned long long int) == 0); + verify_stmt (TYPE_MAXIMUM (unsigned long long int) == ULLONG_MAX); + #endif + VERIFY (TYPE_MINIMUM (intmax_t) == INTMAX_MIN); + VERIFY (TYPE_MAXIMUM (intmax_t) == INTMAX_MAX); + VERIFY (TYPE_MINIMUM (uintmax_t) == 0); + VERIFY (TYPE_MAXIMUM (uintmax_t) == UINTMAX_MAX); + + /* TYPE_WIDTH. */ + #ifdef CHAR_WIDTH + verify_stmt (TYPE_WIDTH (char) == CHAR_WIDTH); + verify_stmt (TYPE_WIDTH (signed char) == SCHAR_WIDTH); + verify_stmt (TYPE_WIDTH (unsigned char) == UCHAR_WIDTH); + verify_stmt (TYPE_WIDTH (short int) == SHRT_WIDTH); + verify_stmt (TYPE_WIDTH (unsigned short int) == USHRT_WIDTH); + verify_stmt (TYPE_WIDTH (int) == INT_WIDTH); + verify_stmt (TYPE_WIDTH (unsigned int) == UINT_WIDTH); + verify_stmt (TYPE_WIDTH (long int) == LONG_WIDTH); + verify_stmt (TYPE_WIDTH (unsigned long int) == ULONG_WIDTH); + #ifdef LLONG_WIDTH + verify_stmt (TYPE_WIDTH (long long int) == LLONG_WIDTH); + verify_stmt (TYPE_WIDTH (unsigned long long int) == ULLONG_WIDTH); + #endif + #endif + + /* INT_BITS_STRLEN_BOUND. */ + VERIFY (INT_BITS_STRLEN_BOUND (1) == 1); + VERIFY (INT_BITS_STRLEN_BOUND (2620) == 789); + + /* INT_STRLEN_BOUND, INT_BUFSIZE_BOUND. */ + #ifdef INT32_MAX /* POSIX guarantees int32_t; this ports to non-POSIX. */ + VERIFY (INT_STRLEN_BOUND (int32_t) == sizeof ("-2147483648") - 1); + VERIFY (INT_BUFSIZE_BOUND (int32_t) == sizeof ("-2147483648")); + #endif + #ifdef INT64_MAX + VERIFY (INT_STRLEN_BOUND (int64_t) == sizeof ("-9223372036854775808") - 1); + VERIFY (INT_BUFSIZE_BOUND (int64_t) == sizeof ("-9223372036854775808")); + #endif + + /* All the INT_<op>_RANGE_OVERFLOW tests are equally valid as + INT_<op>_OVERFLOW tests, so define macros to do both. OP is the + operation, OPNAME its symbolic name, A and B its operands, T the + result type, V the overflow flag, and VRES the result if V and if + two's complement. CHECK_BINOP is for most binary operatinos, + CHECK_SBINOP for binary +, -, * when the result type is signed, + and CHECK_UNOP for unary operations. */ + #define CHECK_BINOP(op, opname, a, b, t, v, vres) \ + VERIFY (INT_##opname##_RANGE_OVERFLOW (a, b, TYPE_MINIMUM (t), \ + TYPE_MAXIMUM (t)) \ + == (v)); \ + VERIFY (INT_##opname##_OVERFLOW (a, b) == (v)) + #define CHECK_SBINOP(op, opname, a, b, t, v, vres) \ + CHECK_BINOP(op, opname, a, b, t, v, vres); \ + { \ + t result; \ + ASSERT (INT_##opname##_WRAPV (a, b, &result) == (v)); \ + ASSERT (result == ((v) ? (vres) : ((a) op (b)))); \ + } + #define CHECK_UNOP(op, opname, a, t, v) \ + VERIFY (INT_##opname##_RANGE_OVERFLOW (a, TYPE_MINIMUM (t), \ + TYPE_MAXIMUM (t)) \ + == (v)); \ + VERIFY (INT_##opname##_OVERFLOW (a) == (v)) + + /* INT_<op>_RANGE_OVERFLOW, INT_<op>_OVERFLOW. */ + VERIFY (INT_ADD_RANGE_OVERFLOW (INT_MAX, 1, INT_MIN, INT_MAX)); + VERIFY (INT_ADD_OVERFLOW (INT_MAX, 1)); + + CHECK_SBINOP (+, ADD, INT_MAX, 1, int, true, INT_MIN); + CHECK_SBINOP (+, ADD, INT_MAX, -1, int, false, INT_MAX - 1); + CHECK_SBINOP (+, ADD, INT_MIN, 1, int, false, INT_MIN + 1); + CHECK_SBINOP (+, ADD, INT_MIN, -1, int, true, INT_MAX); + CHECK_BINOP (+, ADD, UINT_MAX, 1u, unsigned int, true, 0u); + CHECK_BINOP (+, ADD, 0u, 1u, unsigned int, false, 1u); + + CHECK_SBINOP (-, SUBTRACT, INT_MAX, 1, int, false, INT_MAX - 1); + CHECK_SBINOP (-, SUBTRACT, INT_MAX, -1, int, true, INT_MIN); + CHECK_SBINOP (-, SUBTRACT, INT_MIN, 1, int, true, INT_MAX); + CHECK_SBINOP (-, SUBTRACT, INT_MIN, -1, int, false, INT_MIN - -1); + CHECK_BINOP (-, SUBTRACT, UINT_MAX, 1u, unsigned int, false, UINT_MAX - 1u); + CHECK_BINOP (-, SUBTRACT, 0u, 1u, unsigned int, true, 0u - 1u); + + CHECK_UNOP (-, NEGATE, INT_MIN, int, true); + CHECK_UNOP (-, NEGATE, 0, int, false); + CHECK_UNOP (-, NEGATE, INT_MAX, int, false); + CHECK_UNOP (-, NEGATE, 0u, unsigned int, false); + CHECK_UNOP (-, NEGATE, 1u, unsigned int, true); + CHECK_UNOP (-, NEGATE, UINT_MAX, unsigned int, true); + + CHECK_SBINOP (*, MULTIPLY, INT_MAX, INT_MAX, int, true, 1); + CHECK_SBINOP (*, MULTIPLY, INT_MAX, INT_MIN, int, true, INT_MIN); + CHECK_SBINOP (*, MULTIPLY, INT_MIN, INT_MAX, int, true, INT_MIN); + CHECK_SBINOP (*, MULTIPLY, INT_MIN, INT_MIN, int, true, 0); + CHECK_SBINOP (*, MULTIPLY, -1, INT_MIN, int, + INT_NEGATE_OVERFLOW (INT_MIN), INT_MIN); +#if !defined __HP_cc + CHECK_SBINOP (*, MULTIPLY, LONG_MIN / INT_MAX, (long int) INT_MAX, + long int, false, LONG_MIN - LONG_MIN % INT_MAX); +#endif + + CHECK_BINOP (/, DIVIDE, INT_MIN, -1, int, + INT_NEGATE_OVERFLOW (INT_MIN), INT_MIN); + CHECK_BINOP (/, DIVIDE, INT_MAX, 1, int, false, INT_MAX); + CHECK_BINOP (/, DIVIDE, (unsigned int) INT_MIN, -1u, unsigned int, + false, INT_MIN / -1u); + + CHECK_BINOP (%, REMAINDER, INT_MIN, -1, int, INT_NEGATE_OVERFLOW (INT_MIN), 0); + CHECK_BINOP (%, REMAINDER, INT_MAX, 1, int, false, 0); + CHECK_BINOP (%, REMAINDER, (unsigned int) INT_MIN, -1u, unsigned int, + false, INT_MIN % -1u); + + CHECK_BINOP (<<, LEFT_SHIFT, UINT_MAX, 1, unsigned int, true, UINT_MAX << 1); + CHECK_BINOP (<<, LEFT_SHIFT, UINT_MAX / 2 + 1, 1, unsigned int, true, + (UINT_MAX / 2 + 1) << 1); + CHECK_BINOP (<<, LEFT_SHIFT, UINT_MAX / 2, 1, unsigned int, false, + (UINT_MAX / 2) << 1); + + /* INT_<op>_OVERFLOW and INT_<op>_WRAPV with mixed types. */ + #define CHECK_SUM(a, b, t, v, vres) \ + CHECK_SUM1 (a, b, t, v, vres); \ + CHECK_SUM1 (b, a, t, v, vres) + #define CHECK_SUM_WRAPV(a, b, t, v, vres, okres) \ + CHECK_SUM_WRAPV1 (a, b, t, v, vres, okres); \ + CHECK_SUM_WRAPV1 (b, a, t, v, vres, okres) + #define CHECK_SUM1(a, b, t, v, vres) \ + VERIFY (INT_ADD_OVERFLOW (a, b) == (v)); \ + CHECK_SUM_WRAPV1 (a, b, t, v, vres, (a) + (b)) + #define CHECK_SUM_WRAPV1(a, b, t, v, vres, okres) \ + { \ + t result; \ + ASSERT (INT_ADD_WRAPV (a, b, &result) == (v)); \ + ASSERT (result == ((v) ? (vres) : (okres))); \ + } + CHECK_SUM (-1, LONG_MIN, long int, true, LONG_MAX); + CHECK_SUM (-1, UINT_MAX, unsigned int, false, DONTCARE); + CHECK_SUM (-1L, INT_MIN, long int, INT_MIN == LONG_MIN, + INT_MIN == LONG_MIN ? INT_MAX : DONTCARE); + CHECK_SUM (0u, -1, unsigned int, true, 0u + -1); + CHECK_SUM (0u, 0, unsigned int, false, DONTCARE); + CHECK_SUM (0u, 1, unsigned int, false, DONTCARE); + CHECK_SUM (1, LONG_MAX, long int, true, LONG_MIN); + CHECK_SUM (1, UINT_MAX, unsigned int, true, 0u); + CHECK_SUM (1L, INT_MAX, long int, INT_MAX == LONG_MAX, + INT_MAX == LONG_MAX ? INT_MIN : DONTCARE); + CHECK_SUM (1u, INT_MAX, unsigned int, INT_MAX == UINT_MAX, 1u + INT_MAX); + CHECK_SUM (1u, INT_MIN, unsigned int, true, 1u + INT_MIN); + CHECK_SUM_WRAPV (-1, 1u, int, false, DONTCARE, 0); + CHECK_SUM_WRAPV (-1, 1ul, int, false, DONTCARE, 0); + CHECK_SUM_WRAPV (-1l, 1u, int, false, DONTCARE, 0); + CHECK_SUM_WRAPV (-100, 1000u, int, false, DONTCARE, 900); + CHECK_SUM_WRAPV (INT_MIN, UINT_MAX, int, false, DONTCARE, INT_MAX); + CHECK_SUM_WRAPV (1u, INT_MAX, int, true, INT_MIN, DONTCARE); + CHECK_SUM_WRAPV (INT_MAX, 1, long int, LONG_MAX <= INT_MAX, INT_MIN, + INT_MAX + 1L); + CHECK_SUM_WRAPV (UINT_MAX, 1, long int, LONG_MAX <= UINT_MAX, 0, + UINT_MAX + 1L); + CHECK_SUM_WRAPV (INT_MAX, 1, unsigned long int, ULONG_MAX <= INT_MAX, 0, + INT_MAX + 1uL); + CHECK_SUM_WRAPV (UINT_MAX, 1, unsigned long int, ULONG_MAX <= UINT_MAX, 0, + UINT_MAX + 1uL); + + { + long int result; + ASSERT (INT_ADD_WRAPV (1, INT_MAX, &result) == (INT_MAX == LONG_MAX)); + ASSERT (INT_ADD_WRAPV (-1, INT_MIN, &result) == (INT_MIN == LONG_MIN)); + } + + #define CHECK_DIFFERENCE(a, b, t, v, vres) \ + VERIFY (INT_SUBTRACT_OVERFLOW (a, b) == (v)) + #define CHECK_SDIFFERENCE(a, b, t, v, vres) \ + CHECK_DIFFERENCE (a, b, t, v, vres); \ + CHECK_SDIFFERENCE_WRAPV (a, b, t, v, vres) + #define CHECK_SDIFFERENCE_WRAPV(a, b, t, v, vres) \ + { \ + t result; \ + ASSERT (INT_SUBTRACT_WRAPV (a, b, &result) == (v)); \ + ASSERT (result == ((v) ? (vres) : ((a) - (b)))); \ + } + CHECK_DIFFERENCE (INT_MAX, 1u, unsigned int, UINT_MAX < INT_MAX - 1, + INT_MAX - 1u); + CHECK_DIFFERENCE (UINT_MAX, 1, unsigned int, false, UINT_MAX - 1); + CHECK_DIFFERENCE (0u, -1, unsigned int, false, 0u - -1); + CHECK_DIFFERENCE (UINT_MAX, -1, unsigned int, true, UINT_MAX - -1); + CHECK_DIFFERENCE (INT_MIN, 1u, unsigned int, true, INT_MIN - 1u); + CHECK_DIFFERENCE (-1, 0u, unsigned int, true, -1 - 0u); + CHECK_SDIFFERENCE (-1, INT_MIN, int, false, -1 - INT_MIN); + CHECK_SDIFFERENCE (-1, INT_MAX, int, false, -1 - INT_MAX); + CHECK_SDIFFERENCE (0, INT_MIN, int, INT_MIN < -INT_MAX, INT_MIN); + CHECK_SDIFFERENCE (0, INT_MAX, int, false, 0 - INT_MAX); + CHECK_SDIFFERENCE_WRAPV (-1, 1u, int, false, DONTCARE); + CHECK_SDIFFERENCE_WRAPV (-1, 1ul, int, false, DONTCARE); + CHECK_SDIFFERENCE_WRAPV (-1l, 1u, int, false, DONTCARE); + CHECK_SDIFFERENCE_WRAPV (0u, INT_MAX, int, false, DONTCARE); + CHECK_SDIFFERENCE_WRAPV (1u, INT_MIN, int, true, 1u - INT_MIN); + { + long int result; + ASSERT (INT_SUBTRACT_WRAPV (INT_MAX, -1, &result) == (INT_MAX == LONG_MAX)); + ASSERT (INT_SUBTRACT_WRAPV (INT_MIN, 1, &result) == (INT_MAX == LONG_MAX)); + } + + #define CHECK_PRODUCT(a, b, t, v, vres) \ + CHECK_PRODUCT1 (a, b, t, v, vres); \ + CHECK_PRODUCT1 (b, a, t, v, vres) + #define CHECK_SPRODUCT(a, b, t, v, vres) \ + CHECK_SPRODUCT1 (a, b, t, v, vres); \ + CHECK_SPRODUCT1 (b, a, t, v, vres) + #define CHECK_SPRODUCT_WRAPV(a, b, t, v, vres) \ + CHECK_SPRODUCT_WRAPV1 (a, b, t, v, vres); \ + CHECK_SPRODUCT_WRAPV1 (b, a, t, v, vres) + #define CHECK_PRODUCT1(a, b, t, v, vres) \ + VERIFY (INT_MULTIPLY_OVERFLOW (a, b) == (v)) + #define CHECK_SPRODUCT1(a, b, t, v, vres) \ + CHECK_PRODUCT1 (a, b, t, v, vres); \ + CHECK_SPRODUCT_WRAPV1 (a, b, t, v, vres) + #define CHECK_SPRODUCT_WRAPV1(a, b, t, v, vres) \ + { \ + t result; \ + ASSERT (INT_MULTIPLY_WRAPV (a, b, &result) == (v)); \ + ASSERT (result == ((v) ? (vres) : ((a) * (b)))); \ + } + CHECK_PRODUCT (-1, 1u, unsigned int, true, -1 * 1u); + CHECK_SPRODUCT (-1, INT_MIN, int, INT_NEGATE_OVERFLOW (INT_MIN), INT_MIN); + CHECK_PRODUCT (-1, UINT_MAX, unsigned int, true, -1 * UINT_MAX); + CHECK_SPRODUCT (-32768, LONG_MAX / -32768 - 1, long int, true, LONG_MIN); + CHECK_SPRODUCT (-12345, LONG_MAX / -12345, long int, false, DONTCARE); + CHECK_SPRODUCT (0, -1, int, false, DONTCARE); + CHECK_SPRODUCT (0, 0, int, false, DONTCARE); + CHECK_PRODUCT (0, 0u, unsigned int, false, DONTCARE); + CHECK_SPRODUCT (0, 1, int, false, DONTCARE); + CHECK_SPRODUCT (0, INT_MAX, int, false, DONTCARE); + CHECK_SPRODUCT (0, INT_MIN, int, false, DONTCARE); + CHECK_PRODUCT (0, UINT_MAX, unsigned int, false, DONTCARE); + CHECK_PRODUCT (0u, -1, unsigned int, false, DONTCARE); + CHECK_PRODUCT (0u, 0, unsigned int, false, DONTCARE); + CHECK_PRODUCT (0u, 0u, unsigned int, false, DONTCARE); + CHECK_PRODUCT (0u, 1, unsigned int, false, DONTCARE); + CHECK_PRODUCT (0u, INT_MAX, unsigned int, false, DONTCARE); + CHECK_PRODUCT (0u, INT_MIN, unsigned int, false, DONTCARE); + CHECK_PRODUCT (0u, UINT_MAX, unsigned int, false, DONTCARE); + CHECK_SPRODUCT (1, INT_MAX, int, false, DONTCARE); + CHECK_SPRODUCT (1, INT_MIN, int, false, DONTCARE); + CHECK_PRODUCT (1, UINT_MAX, unsigned int, false, DONTCARE); + CHECK_PRODUCT (1u, INT_MIN, unsigned int, true, 1u * INT_MIN); + CHECK_PRODUCT (1u, INT_MAX, unsigned int, UINT_MAX < INT_MAX, 1u * INT_MAX); + CHECK_PRODUCT (INT_MAX, UINT_MAX, unsigned int, true, INT_MAX * UINT_MAX); + CHECK_PRODUCT (INT_MAX, ULONG_MAX, unsigned long int, true, + INT_MAX * ULONG_MAX); +#if !defined __HP_cc + CHECK_SPRODUCT (INT_MIN, LONG_MAX / INT_MIN - 1, long int, true, LONG_MIN); + CHECK_SPRODUCT (INT_MIN, LONG_MAX / INT_MIN, long int, false, DONTCARE); +#endif + CHECK_PRODUCT (INT_MIN, UINT_MAX, unsigned int, true, INT_MIN * UINT_MAX); + CHECK_PRODUCT (INT_MIN, ULONG_MAX, unsigned long int, true, + INT_MIN * ULONG_MAX); + CHECK_SPRODUCT_WRAPV (-1, INT_MAX + 1u, int, false, DONTCARE); + CHECK_SPRODUCT_WRAPV (-1, 1u, int, false, DONTCARE); + CHECK_SPRODUCT (0, ULONG_MAX, int, false, DONTCARE); + CHECK_SPRODUCT (0u, LONG_MIN, int, false, DONTCARE); + { + long int result; + ASSERT (INT_MULTIPLY_WRAPV (INT_MAX, INT_MAX, &result) + == (LONG_MAX / INT_MAX < INT_MAX)); + ASSERT (INT_MULTIPLY_WRAPV (INT_MAX, INT_MAX, &result) + || result == INT_MAX * (long int) INT_MAX); + ASSERT (INT_MULTIPLY_WRAPV (INT_MIN, INT_MIN, &result) + || result == INT_MIN * (long int) INT_MIN); + } + +# ifdef LLONG_MAX + { + long long int result; + ASSERT (INT_MULTIPLY_WRAPV (LONG_MAX, LONG_MAX, &result) + == (LLONG_MAX / LONG_MAX < LONG_MAX)); + ASSERT (INT_MULTIPLY_WRAPV (LONG_MAX, LONG_MAX, &result) + || result == LONG_MAX * (long long int) LONG_MAX); + ASSERT (INT_MULTIPLY_WRAPV (LONG_MIN, LONG_MIN, &result) + || result == LONG_MIN * (long long int) LONG_MIN); + } +# endif + + /* Check for GCC bug 91450. */ + { + unsigned long long result; + ASSERT (INT_MULTIPLY_WRAPV (int_minus_2, int_1, &result) && result == -2); + } + + #define CHECK_QUOTIENT(a, b, v) VERIFY (INT_DIVIDE_OVERFLOW (a, b) == (v)) + + CHECK_QUOTIENT (INT_MIN, -1L, INT_MIN == LONG_MIN); + CHECK_QUOTIENT (INT_MIN, UINT_MAX, false); + CHECK_QUOTIENT (INTMAX_MIN, UINTMAX_MAX, false); + CHECK_QUOTIENT (INTMAX_MIN, UINT_MAX, false); + CHECK_QUOTIENT (-11, 10u, true); + CHECK_QUOTIENT (-10, 10u, true); + CHECK_QUOTIENT (-9, 10u, false); + CHECK_QUOTIENT (11u, -10, true); + CHECK_QUOTIENT (10u, -10, true); + CHECK_QUOTIENT (9u, -10, false); + + #define CHECK_REMAINDER(a, b, v) VERIFY (INT_REMAINDER_OVERFLOW (a, b) == (v)) + + CHECK_REMAINDER (INT_MIN, -1L, INT_MIN == LONG_MIN); + CHECK_REMAINDER (-1, UINT_MAX, true); + CHECK_REMAINDER ((intmax_t) -1, UINTMAX_MAX, true); + CHECK_REMAINDER (INTMAX_MIN, UINT_MAX, + (INTMAX_MAX < UINT_MAX + && - (unsigned int) INTMAX_MIN % UINT_MAX != 0)); + CHECK_REMAINDER (INT_MIN, ULONG_MAX, INT_MIN % ULONG_MAX != 1); + CHECK_REMAINDER (1u, -1, false); + CHECK_REMAINDER (37*39u, -39, false); + CHECK_REMAINDER (37*39u + 1, -39, true); + CHECK_REMAINDER (37*39u - 1, -39, true); + CHECK_REMAINDER (LONG_MAX, -INT_MAX, false); + + return 0; +} diff --git a/gnulib-tests/test-inttostr.c b/gnulib-tests/test-inttostr.c new file mode 100644 index 0000000..b6043e6 --- /dev/null +++ b/gnulib-tests/test-inttostr.c @@ -0,0 +1,94 @@ +/* Test inttostr functions, and incidentally, INT_BUFSIZE_BOUND + Copyright (C) 2010-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Jim Meyering. */ + +#include <config.h> + +#include "inttostr.h" +#include "intprops.h" +#include <inttypes.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "macros.h" + +#define STREQ(a, b) (strcmp (a, b) == 0) +#define IS_TIGHT(T) (_GL_SIGNED_TYPE_OR_EXPR (T) == TYPE_SIGNED (T)) +#define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9) + +/* Verify that an inttostr function works as advertised. + Convert maximum and minimum (per-type, T) values using both snprintf -- + with a cast to intmax_t or uintmax_t -- and FN, and compare the + resulting strings. Use malloc for the inttostr buffer, so that if + we ever exceed the usually-tight INT_BUFSIZE_BOUND, tools like + valgrind will detect the failure. */ +#define CK(T, Fn) \ + do \ + { \ + char ref[100]; \ + char *buf = malloc (INT_BUFSIZE_BOUND (T)); \ + char const *p; \ + ASSERT (buf); \ + *buf = '\0'; \ + ASSERT \ + ((TYPE_SIGNED (T) \ + ? snprintf (ref, sizeof ref, "%jd", (intmax_t) TYPE_MINIMUM (T)) \ + : snprintf (ref, sizeof ref, "%ju", (uintmax_t) TYPE_MINIMUM (T))) \ + < sizeof ref); \ + ASSERT (STREQ ((p = Fn (TYPE_MINIMUM (T), buf)), ref)); \ + /* Ensure that INT_BUFSIZE_BOUND is tight for signed types. */ \ + ASSERT (! TYPE_SIGNED (T) || (p == buf && *p == '-')); \ + ASSERT \ + ((TYPE_SIGNED (T) \ + ? snprintf (ref, sizeof ref, "%jd", (intmax_t) TYPE_MAXIMUM (T)) \ + : snprintf (ref, sizeof ref, "%ju", (uintmax_t) TYPE_MAXIMUM (T))) \ + < sizeof ref); \ + ASSERT (STREQ ((p = Fn (TYPE_MAXIMUM (T), buf)), ref)); \ + /* For unsigned types, the bound is not always tight. */ \ + ASSERT (! IS_TIGHT (T) || TYPE_SIGNED (T) \ + || (p == buf && ISDIGIT (*p))); \ + free (buf); \ + } \ + while (0) + +int +main (void) +{ + size_t b_size = 2; + char *b = malloc (b_size); + ASSERT (b); + + /* Ideally we would rely on the snprintf-posix module, in which case + this guard would not be required, but due to limitations in gnulib's + implementation (see modules/snprintf-posix), we cannot. */ + if (snprintf (b, b_size, "%ju", (uintmax_t) 3) == 1 + && b[0] == '3' && b[1] == '\0') + { + CK (int, inttostr); + CK (unsigned int, uinttostr); + CK (off_t, offtostr); + CK (uintmax_t, umaxtostr); + CK (intmax_t, imaxtostr); + free (b); + return 0; + } + + /* snprintf doesn't accept %ju; skip this test. */ + free (b); + return 77; +} diff --git a/gnulib-tests/test-inttypes.c b/gnulib-tests/test-inttypes.c new file mode 100644 index 0000000..21db820 --- /dev/null +++ b/gnulib-tests/test-inttypes.c @@ -0,0 +1,118 @@ +/* Test of <inttypes.h> substitute. + Copyright (C) 2006-2007, 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <inttypes.h> + +#include <stddef.h> + +/* Tests for macros supposed to be defined in inttypes.h. */ + +const char *k = /* implicit string concatenation */ +#ifdef INT8_MAX + PRId8 PRIi8 +#endif +#ifdef UINT8_MAX + PRIo8 PRIu8 PRIx8 PRIX8 +#endif +#ifdef INT16_MAX + PRId16 PRIi16 +#endif +#ifdef UINT16_MAX + PRIo16 PRIu16 PRIx16 PRIX16 +#endif +#ifdef INT32_MAX + PRId32 PRIi32 +#endif +#ifdef UINT32_MAX + PRIo32 PRIu32 PRIx32 PRIX32 +#endif +#ifdef INT64_MAX + PRId64 PRIi64 +#endif +#ifdef UINT64_MAX + PRIo64 PRIu64 PRIx64 PRIX64 +#endif + PRIdLEAST8 PRIiLEAST8 PRIoLEAST8 PRIuLEAST8 PRIxLEAST8 PRIXLEAST8 + PRIdLEAST16 PRIiLEAST16 PRIoLEAST16 PRIuLEAST16 PRIxLEAST16 PRIXLEAST16 + PRIdLEAST32 PRIiLEAST32 PRIoLEAST32 PRIuLEAST32 PRIxLEAST32 PRIXLEAST32 + PRIdLEAST64 PRIiLEAST64 + PRIoLEAST64 PRIuLEAST64 PRIxLEAST64 PRIXLEAST64 + PRIdFAST8 PRIiFAST8 PRIoFAST8 PRIuFAST8 PRIxFAST8 PRIXFAST8 + PRIdFAST16 PRIiFAST16 PRIoFAST16 PRIuFAST16 PRIxFAST16 PRIXFAST16 + PRIdFAST32 PRIiFAST32 PRIoFAST32 PRIuFAST32 PRIxFAST32 PRIXFAST32 + PRIdFAST64 PRIiFAST64 + PRIoFAST64 PRIuFAST64 PRIxFAST64 PRIXFAST64 + PRIdMAX PRIiMAX PRIoMAX PRIuMAX PRIxMAX PRIXMAX +#ifdef INTPTR_MAX + PRIdPTR PRIiPTR +#endif +#ifdef UINTPTR_MAX + PRIoPTR PRIuPTR PRIxPTR PRIXPTR +#endif + ; +const char *l = /* implicit string concatenation */ +#ifdef INT8_MAX + SCNd8 SCNi8 +#endif +#ifdef UINT8_MAX + SCNo8 SCNu8 SCNx8 +#endif +#ifdef INT16_MAX + SCNd16 SCNi16 +#endif +#ifdef UINT16_MAX + SCNo16 SCNu16 SCNx16 +#endif +#ifdef INT32_MAX + SCNd32 SCNi32 +#endif +#ifdef UINT32_MAX + SCNo32 SCNu32 SCNx32 +#endif +#ifdef INT64_MAX + SCNd64 SCNi64 +#endif +#ifdef UINT64_MAX + SCNo64 SCNu64 SCNx64 +#endif + SCNdLEAST8 SCNiLEAST8 SCNoLEAST8 SCNuLEAST8 SCNxLEAST8 + SCNdLEAST16 SCNiLEAST16 SCNoLEAST16 SCNuLEAST16 SCNxLEAST16 + SCNdLEAST32 SCNiLEAST32 SCNoLEAST32 SCNuLEAST32 SCNxLEAST32 + SCNdLEAST64 SCNiLEAST64 + SCNoLEAST64 SCNuLEAST64 SCNxLEAST64 + SCNdFAST8 SCNiFAST8 SCNoFAST8 SCNuFAST8 SCNxFAST8 + SCNdFAST16 SCNiFAST16 SCNoFAST16 SCNuFAST16 SCNxFAST16 + SCNdFAST32 SCNiFAST32 SCNoFAST32 SCNuFAST32 SCNxFAST32 + SCNdFAST64 SCNiFAST64 + SCNoFAST64 SCNuFAST64 SCNxFAST64 + SCNdMAX SCNiMAX SCNoMAX SCNuMAX SCNxMAX +#ifdef INTPTR_MAX + SCNdPTR SCNiPTR +#endif +#ifdef UINTPTR_MAX + SCNoPTR SCNuPTR SCNxPTR +#endif + ; + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tests/test-ioctl.c b/gnulib-tests/test-ioctl.c new file mode 100644 index 0000000..e09b009 --- /dev/null +++ b/gnulib-tests/test-ioctl.c @@ -0,0 +1,51 @@ +/* Test of ioctl() function. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +/* Specification. */ +#include <sys/ioctl.h> + +#include "signature.h" +SIGNATURE_CHECK (ioctl, int, (int, int, ...)); + +#include <errno.h> +#include <unistd.h> + +#include "macros.h" + +int +main (void) +{ +#ifdef FIONREAD + /* Test behaviour for invalid file descriptors. */ + { + int value; + errno = 0; + ASSERT (ioctl (-1, FIONREAD, &value) == -1); + ASSERT (errno == EBADF); + } + { + int value; + close (99); + errno = 0; + ASSERT (ioctl (99, FIONREAD, &value) == -1); + ASSERT (errno == EBADF); + } +#endif + + return 0; +} diff --git a/gnulib-tests/test-isatty.c b/gnulib-tests/test-isatty.c new file mode 100644 index 0000000..f626cd5 --- /dev/null +++ b/gnulib-tests/test-isatty.c @@ -0,0 +1,99 @@ +/* Test isatty() function. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (isatty, int, (int)); + +#include <errno.h> +#include <fcntl.h> + +#include "macros.h" + +/* The name of the "always silent" device. */ +#if defined _WIN32 && ! defined __CYGWIN__ +/* Native Windows API. */ +# define DEV_NULL "NUL" +#else +/* Unix API. */ +# define DEV_NULL "/dev/null" +#endif + +int +main (void) +{ + const char *file = "test-isatty.txt"; + + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (isatty (-1) == 0); + ASSERT (errno == EBADF + || errno == 0 /* seen on IRIX 6.5, Solaris 10 */ + ); + } + { + close (99); + errno = 0; + ASSERT (isatty (99) == 0); + ASSERT (errno == EBADF + || errno == 0 /* seen on IRIX 6.5, Solaris 10 */ + ); + } + + /* Test behaviour for regular files. */ + { + int fd; + + fd = open (file, O_WRONLY|O_CREAT|O_TRUNC, 0644); + ASSERT (0 <= fd); + ASSERT (write (fd, "hello", 5) == 5); + ASSERT (close (fd) == 0); + + fd = open (file, O_RDONLY); + ASSERT (0 <= fd); + ASSERT (! isatty (fd)); + ASSERT (close (fd) == 0); + } + + /* Test behaviour for pipes. */ + { + int fd[2]; + + ASSERT (pipe (fd) == 0); + ASSERT (! isatty (fd[0])); + ASSERT (! isatty (fd[1])); + ASSERT (close (fd[0]) == 0); + ASSERT (close (fd[1]) == 0); + } + + /* Test behaviour for /dev/null. */ + { + int fd; + + fd = open (DEV_NULL, O_RDONLY); + ASSERT (0 <= fd); + ASSERT (! isatty (fd)); + ASSERT (close (fd) == 0); + } + + ASSERT (unlink (file) == 0); + + return 0; +} diff --git a/gnulib-tests/test-isblank.c b/gnulib-tests/test-isblank.c new file mode 100644 index 0000000..7dd9136 --- /dev/null +++ b/gnulib-tests/test-isblank.c @@ -0,0 +1,50 @@ +/* Test of isblank() function. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2009. */ + +#include <config.h> + +#include <ctype.h> + +#include "signature.h" +SIGNATURE_CHECK (isblank, int, (int)); + +#include <limits.h> +#include <stdio.h> + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + unsigned int c; + + /* Verify the property in the "C" locale. + POSIX specifies in + <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html> + that + - in all locales, the blank characters include the <space> and <tab> + characters, + - in the "POSIX" locale (which is usually the same as the "C" locale), + the blank characters include only the ASCII <space> and <tab> + characters. */ + for (c = 0; c <= UCHAR_MAX; c++) + ASSERT (!isblank (c) == !(c == ' ' || c == '\t')); + ASSERT (!isblank (EOF)); + + return 0; +} diff --git a/gnulib-tests/test-isnand-nolibm.c b/gnulib-tests/test-isnand-nolibm.c new file mode 100644 index 0000000..8502500 --- /dev/null +++ b/gnulib-tests/test-isnand-nolibm.c @@ -0,0 +1,21 @@ +/* Test of isnand() substitute. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include "isnand-nolibm.h" + +#include "test-isnand.h" diff --git a/gnulib-tests/test-isnand.h b/gnulib-tests/test-isnand.h new file mode 100644 index 0000000..7d2e19c --- /dev/null +++ b/gnulib-tests/test-isnand.h @@ -0,0 +1,63 @@ +/* Test of isnand() substitute. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <limits.h> + +#include "minus-zero.h" +#include "infinity.h" +#include "nan.h" +#include "macros.h" + +int +main () +{ + /* Finite values. */ + ASSERT (!isnand (3.141)); + ASSERT (!isnand (3.141e30)); + ASSERT (!isnand (3.141e-30)); + ASSERT (!isnand (-2.718)); + ASSERT (!isnand (-2.718e30)); + ASSERT (!isnand (-2.718e-30)); + ASSERT (!isnand (0.0)); + ASSERT (!isnand (minus_zerod)); + /* Infinite values. */ + ASSERT (!isnand (Infinityd ())); + ASSERT (!isnand (- Infinityd ())); + /* Quiet NaN. */ + ASSERT (isnand (NaNd ())); +#if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT + /* Signalling NaN. */ + { + #define NWORDS \ + ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) + typedef union { double value; unsigned int word[NWORDS]; } memory_double; + memory_double m; + m.value = NaNd (); +# if DBL_EXPBIT0_BIT > 0 + m.word[DBL_EXPBIT0_WORD] ^= (unsigned int) 1 << (DBL_EXPBIT0_BIT - 1); +# else + m.word[DBL_EXPBIT0_WORD + (DBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)] + ^= (unsigned int) 1 << (sizeof (unsigned int) * CHAR_BIT - 1); +# endif + m.word[DBL_EXPBIT0_WORD + (DBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)] + |= (unsigned int) 1 << DBL_EXPBIT0_BIT; + ASSERT (isnand (m.value)); + } +#endif + return 0; +} diff --git a/gnulib-tests/test-isnanf-nolibm.c b/gnulib-tests/test-isnanf-nolibm.c new file mode 100644 index 0000000..3c2c971 --- /dev/null +++ b/gnulib-tests/test-isnanf-nolibm.c @@ -0,0 +1,21 @@ +/* Test of isnanf() substitute. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include "isnanf-nolibm.h" + +#include "test-isnanf.h" diff --git a/gnulib-tests/test-isnanf.h b/gnulib-tests/test-isnanf.h new file mode 100644 index 0000000..e5c5594 --- /dev/null +++ b/gnulib-tests/test-isnanf.h @@ -0,0 +1,65 @@ +/* Test of isnanf() substitute. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <limits.h> + +#include "minus-zero.h" +#include "infinity.h" +#include "nan.h" +#include "macros.h" + +int +main () +{ + /* Finite values. */ + ASSERT (!isnanf (3.141f)); + ASSERT (!isnanf (3.141e30f)); + ASSERT (!isnanf (3.141e-30f)); + ASSERT (!isnanf (-2.718f)); + ASSERT (!isnanf (-2.718e30f)); + ASSERT (!isnanf (-2.718e-30f)); + ASSERT (!isnanf (0.0f)); + ASSERT (!isnanf (minus_zerof)); + /* Infinite values. */ + ASSERT (!isnanf (Infinityf ())); + ASSERT (!isnanf (- Infinityf ())); + /* Quiet NaN. */ + ASSERT (isnanf (NaNf ())); +#if defined FLT_EXPBIT0_WORD && defined FLT_EXPBIT0_BIT + /* Signalling NaN. */ + { + #define NWORDS \ + ((sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) + typedef union { float value; unsigned int word[NWORDS]; } memory_float; + memory_float m; + m.value = NaNf (); +# if FLT_EXPBIT0_BIT > 0 + m.word[FLT_EXPBIT0_WORD] ^= (unsigned int) 1 << (FLT_EXPBIT0_BIT - 1); +# else + m.word[FLT_EXPBIT0_WORD + (FLT_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)] + ^= (unsigned int) 1 << (sizeof (unsigned int) * CHAR_BIT - 1); +# endif + if (FLT_EXPBIT0_WORD < NWORDS / 2) + m.word[FLT_EXPBIT0_WORD + 1] |= (unsigned int) 1 << FLT_EXPBIT0_BIT; + else + m.word[0] |= (unsigned int) 1; + ASSERT (isnanf (m.value)); + } +#endif + return 0; +} diff --git a/gnulib-tests/test-isnanl-nolibm.c b/gnulib-tests/test-isnanl-nolibm.c new file mode 100644 index 0000000..49e9420 --- /dev/null +++ b/gnulib-tests/test-isnanl-nolibm.c @@ -0,0 +1,23 @@ +/* Test of isnanl() substitute. + Copyright (C) 2007, 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include "isnanl-nolibm.h" + +#include "test-isnanl.h" diff --git a/gnulib-tests/test-isnanl.h b/gnulib-tests/test-isnanl.h new file mode 100644 index 0000000..89030b9 --- /dev/null +++ b/gnulib-tests/test-isnanl.h @@ -0,0 +1,130 @@ +/* Test of isnanl() substitute. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <float.h> +#include <limits.h> + +#include "minus-zero.h" +#include "infinity.h" +#include "nan.h" +#include "macros.h" + +int +main () +{ + #define NWORDS \ + ((sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) + typedef union { unsigned int word[NWORDS]; long double value; } + memory_long_double; + + /* Finite values. */ + ASSERT (!isnanl (3.141L)); + ASSERT (!isnanl (3.141e30L)); + ASSERT (!isnanl (3.141e-30L)); + ASSERT (!isnanl (-2.718L)); + ASSERT (!isnanl (-2.718e30L)); + ASSERT (!isnanl (-2.718e-30L)); + ASSERT (!isnanl (0.0L)); + ASSERT (!isnanl (minus_zerol)); + /* Infinite values. */ + ASSERT (!isnanl (Infinityl ())); + ASSERT (!isnanl (- Infinityl ())); + /* Quiet NaN. */ + ASSERT (isnanl (NaNl ())); + +#if defined LDBL_EXPBIT0_WORD && defined LDBL_EXPBIT0_BIT + /* A bit pattern that is different from a Quiet NaN. With a bit of luck, + it's a Signalling NaN. */ + { +#if defined __powerpc__ && LDBL_MANT_DIG == 106 + /* This is PowerPC "double double", a pair of two doubles. Inf and Nan are + represented as the corresponding 64-bit IEEE values in the first double; + the second is ignored. Manipulate only the first double. */ + #undef NWORDS + #define NWORDS \ + ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) +#endif + + memory_long_double m; + m.value = NaNl (); +# if LDBL_EXPBIT0_BIT > 0 + m.word[LDBL_EXPBIT0_WORD] ^= (unsigned int) 1 << (LDBL_EXPBIT0_BIT - 1); +# else + m.word[LDBL_EXPBIT0_WORD + (LDBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)] + ^= (unsigned int) 1 << (sizeof (unsigned int) * CHAR_BIT - 1); +# endif + m.word[LDBL_EXPBIT0_WORD + (LDBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)] + |= (unsigned int) 1 << LDBL_EXPBIT0_BIT; + ASSERT (isnanl (m.value)); + } +#endif + +#if ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE +/* Representation of an 80-bit 'long double' as an initializer for a sequence + of 'unsigned int' words. */ +# ifdef WORDS_BIGENDIAN +# define LDBL80_WORDS(exponent,manthi,mantlo) \ + { ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), \ + ((unsigned int) (manthi) << 16) | ((unsigned int) (mantlo) >> 16), \ + (unsigned int) (mantlo) << 16 \ + } +# else +# define LDBL80_WORDS(exponent,manthi,mantlo) \ + { mantlo, manthi, exponent } +# endif + { /* Quiet NaN. */ + static memory_long_double x = + { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) }; + ASSERT (isnanl (x.value)); + } + { + /* Signalling NaN. */ + static memory_long_double x = + { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) }; + ASSERT (isnanl (x.value)); + } + /* isnanl should return something for noncanonical values. */ + { /* Pseudo-NaN. */ + static memory_long_double x = + { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) }; + ASSERT (isnanl (x.value) || !isnanl (x.value)); + } + { /* Pseudo-Infinity. */ + static memory_long_double x = + { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; + ASSERT (isnanl (x.value) || !isnanl (x.value)); + } + { /* Pseudo-Zero. */ + static memory_long_double x = + { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; + ASSERT (isnanl (x.value) || !isnanl (x.value)); + } + { /* Unnormalized number. */ + static memory_long_double x = + { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; + ASSERT (isnanl (x.value) || !isnanl (x.value)); + } + { /* Pseudo-Denormal. */ + static memory_long_double x = + { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; + ASSERT (isnanl (x.value) || !isnanl (x.value)); + } +#endif + + return 0; +} diff --git a/gnulib-tests/test-iswblank.c b/gnulib-tests/test-iswblank.c new file mode 100644 index 0000000..40c58db --- /dev/null +++ b/gnulib-tests/test-iswblank.c @@ -0,0 +1,35 @@ +/* Test of iswblank() function. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <wctype.h> + +#include "macros.h" + +/* Check that WEOF is defined. */ +wint_t e = WEOF; + +int +main (void) +{ + /* Check that the function exist as a function or as a macro. */ + (void) iswblank (0); + /* Check that the isw* functions map WEOF to 0. */ + ASSERT (!iswblank (e)); + + return 0; +} diff --git a/gnulib-tests/test-iswdigit.c b/gnulib-tests/test-iswdigit.c new file mode 100644 index 0000000..a7f8ef5 --- /dev/null +++ b/gnulib-tests/test-iswdigit.c @@ -0,0 +1,233 @@ +/* Test of iswdigit() function. + Copyright (C) 2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <wctype.h> + +#include "signature.h" +SIGNATURE_CHECK (iswdigit, int, (wint_t)); + +#include <locale.h> +#include <stdlib.h> +#include <string.h> +#include <wchar.h> + +#include "macros.h" + +/* Returns the value of iswdigit for the multibyte character s[0..n-1]. */ +static int +for_character (const char *s, size_t n) +{ + mbstate_t state; + wchar_t wc; + size_t ret; + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, s, n, &state); + if (ret == n) + return iswdigit (wc); + else + return 0; +} + +int +main (int argc, char *argv[]) +{ + int is; + char buf[4]; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test WEOF. */ + is = iswdigit (WEOF); + ASSERT (is == 0); + + /* Test single-byte characters. + ISO C 99 sections 7.25.2.1.5 and 5.2.1 specify that the decimal digits + include only the ASCII 0 ... 9 characters. */ + { + int c; + + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + buf[0] = (unsigned char) c; + is = for_character (buf, 1); + switch (c) + { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + ASSERT (is != 0); + break; + default: + ASSERT (is == 0); + break; + } + break; + } + } + + if (argc > 1) + switch (argv[1][0]) + { + case '0': + /* C locale; tested above. */ + return 0; + + case '1': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\262", 1); + ASSERT (is == 0); + /* U+00B3 SUPERSCRIPT THREE */ + is = for_character ("\263", 1); + ASSERT (is == 0); + /* U+00B9 SUPERSCRIPT ONE */ + is = for_character ("\271", 1); + ASSERT (is == 0); + } + return 0; + + case '2': + /* Locale encoding is EUC-JP. */ + { + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\243\261", 2); + ASSERT (is == 0); + } + return 0; + + case '3': + /* Locale encoding is UTF-8. */ + { + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\302\262", 2); + ASSERT (is == 0); + /* U+00B3 SUPERSCRIPT THREE */ + is = for_character ("\302\263", 2); + ASSERT (is == 0); + /* U+00B9 SUPERSCRIPT ONE */ + is = for_character ("\302\271", 2); + ASSERT (is == 0); + /* U+0663 ARABIC-INDIC DIGIT THREE */ + is = for_character ("\331\243", 2); + ASSERT (is == 0); + /* U+2070 SUPERSCRIPT ZERO */ + is = for_character ("\342\201\260", 3); + ASSERT (is == 0); + /* U+2079 SUPERSCRIPT NINE */ + is = for_character ("\342\201\271", 3); + ASSERT (is == 0); + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\357\274\221", 3); + ASSERT (is == 0); + /* U+1D7D1 MATHEMATICAL BOLD DIGIT THREE */ + is = for_character ("\360\235\237\221", 4); + ASSERT (is == 0); + /* U+1D7DB MATHEMATICAL DOUBLE-STRUCK DIGIT THREE */ + is = for_character ("\360\235\237\233", 4); + ASSERT (is == 0); + /* U+1D7E5 MATHEMATICAL SANS-SERIF DIGIT THREE */ + is = for_character ("\360\235\237\245", 4); + ASSERT (is == 0); + /* U+1D7EF MATHEMATICAL SANS-SERIF BOLD DIGIT THREE */ + is = for_character ("\360\235\237\257", 4); + ASSERT (is == 0); + /* U+1D7F9 MATHEMATICAL MONOSPACE DIGIT THREE */ + is = for_character ("\360\235\237\271", 4); + ASSERT (is == 0); + /* U+E0033 TAG DIGIT THREE */ + is = for_character ("\363\240\200\263", 4); + ASSERT (is == 0); + } + return 0; + + case '4': + /* Locale encoding is GB18030. */ + { + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\201\060\205\065", 4); + ASSERT (is == 0); + /* U+00B3 SUPERSCRIPT THREE */ + is = for_character ("\201\060\205\066", 4); + ASSERT (is == 0); + /* U+00B9 SUPERSCRIPT ONE */ + is = for_character ("\201\060\206\061", 4); + ASSERT (is == 0); + /* U+0663 ARABIC-INDIC DIGIT THREE */ + is = for_character ("\201\061\211\071", 4); + ASSERT (is == 0); + /* U+2070 SUPERSCRIPT ZERO */ + is = for_character ("\201\066\255\062", 4); + ASSERT (is == 0); + /* U+2079 SUPERSCRIPT NINE */ + is = for_character ("\201\066\256\061", 4); + ASSERT (is == 0); + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\243\261", 2); + ASSERT (is == 0); + /* U+1D7D1 MATHEMATICAL BOLD DIGIT THREE */ + is = for_character ("\224\063\353\071", 4); + ASSERT (is == 0); + /* U+1D7DB MATHEMATICAL DOUBLE-STRUCK DIGIT THREE */ + is = for_character ("\224\063\354\071", 4); + ASSERT (is == 0); + /* U+1D7E5 MATHEMATICAL SANS-SERIF DIGIT THREE */ + is = for_character ("\224\063\355\071", 4); + ASSERT (is == 0); + /* U+1D7EF MATHEMATICAL SANS-SERIF BOLD DIGIT THREE */ + is = for_character ("\224\063\356\071", 4); + ASSERT (is == 0); + /* U+1D7F9 MATHEMATICAL MONOSPACE DIGIT THREE */ + is = for_character ("\224\063\357\071", 4); + ASSERT (is == 0); + /* U+E0033 TAG DIGIT THREE */ + is = for_character ("\323\066\232\071", 4); + ASSERT (is == 0); + } + return 0; + + } + + return 1; +} diff --git a/gnulib-tests/test-iswdigit.sh b/gnulib-tests/test-iswdigit.sh new file mode 100755 index 0000000..1bde602 --- /dev/null +++ b/gnulib-tests/test-iswdigit.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# Test in the POSIX locale. +LC_ALL=C ${CHECKER} ./test-iswdigit${EXEEXT} 0 || exit 1 +LC_ALL=POSIX ${CHECKER} ./test-iswdigit${EXEEXT} 0 || exit 1 + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: ${LOCALE_FR=fr_FR} +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR \ + ${CHECKER} ./test-iswdigit${EXEEXT} 1 \ + || exit 1 +fi + +# Test whether a specific EUC-JP locale is installed. +: ${LOCALE_JA=ja_JP} +if test $LOCALE_JA != none; then + LC_ALL=$LOCALE_JA \ + ${CHECKER} ./test-iswdigit${EXEEXT} 2 \ + || exit 1 +fi + +# Test whether a specific UTF-8 locale is installed. +: ${LOCALE_FR_UTF8=fr_FR.UTF-8} +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 \ + ${CHECKER} ./test-iswdigit${EXEEXT} 3 \ + || exit 1 +fi + +# Test whether a specific GB18030 locale is installed. +: ${LOCALE_ZH_CN=zh_CN.GB18030} +if test $LOCALE_ZH_CN != none; then + LC_ALL=$LOCALE_ZH_CN \ + ${CHECKER} ./test-iswdigit${EXEEXT} 4 \ + || exit 1 +fi + +exit 0 diff --git a/gnulib-tests/test-iswxdigit.c b/gnulib-tests/test-iswxdigit.c new file mode 100644 index 0000000..77aa0f0 --- /dev/null +++ b/gnulib-tests/test-iswxdigit.c @@ -0,0 +1,259 @@ +/* Test of iswxdigit() function. + Copyright (C) 2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <wctype.h> + +#include "signature.h" +SIGNATURE_CHECK (iswxdigit, int, (wint_t)); + +#include <locale.h> +#include <stdlib.h> +#include <string.h> +#include <wchar.h> + +#include "macros.h" + +/* Returns the value of iswxdigit for the multibyte character s[0..n-1]. */ +static int +for_character (const char *s, size_t n) +{ + mbstate_t state; + wchar_t wc; + size_t ret; + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, s, n, &state); + if (ret == n) + return iswxdigit (wc); + else + return 0; +} + +int +main (int argc, char *argv[]) +{ + int is; + char buf[4]; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test WEOF. */ + is = iswxdigit (WEOF); + ASSERT (is == 0); + + /* Test single-byte characters. + ISO C 99 sections 7.25.2.1.12 and 6.4.4.1 specify that the hexadecimal + digits include only the ASCII 0 ... 9 A ... F a ... f characters. */ + { + int c; + + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + buf[0] = (unsigned char) c; + is = for_character (buf, 1); + switch (c) + { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': + ASSERT (is != 0); + break; + default: + ASSERT (is == 0); + break; + } + break; + } + } + + if (argc > 1) + switch (argv[1][0]) + { + case '0': + /* C locale; tested above. */ + return 0; + + case '1': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\262", 1); + ASSERT (is == 0); + /* U+00B3 SUPERSCRIPT THREE */ + is = for_character ("\263", 1); + ASSERT (is == 0); + /* U+00B9 SUPERSCRIPT ONE */ + is = for_character ("\271", 1); + ASSERT (is == 0); + } + return 0; + + case '2': + /* Locale encoding is EUC-JP. */ + { + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\243\261", 2); + ASSERT (is == 0); + /* U+FF21 FULLWIDTH LATIN CAPITAL LETTER A */ + is = for_character ("\243\301", 2); + ASSERT (is == 0); + /* U+FF41 FULLWIDTH LATIN SMALL LETTER A */ + is = for_character ("\243\341", 2); + ASSERT (is == 0); + } + return 0; + + case '3': + /* Locale encoding is UTF-8. */ + { + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\302\262", 2); + ASSERT (is == 0); + /* U+00B3 SUPERSCRIPT THREE */ + is = for_character ("\302\263", 2); + ASSERT (is == 0); + /* U+00B9 SUPERSCRIPT ONE */ + is = for_character ("\302\271", 2); + ASSERT (is == 0); + /* U+0663 ARABIC-INDIC DIGIT THREE */ + is = for_character ("\331\243", 2); + ASSERT (is == 0); + /* U+2070 SUPERSCRIPT ZERO */ + is = for_character ("\342\201\260", 3); + ASSERT (is == 0); + /* U+2079 SUPERSCRIPT NINE */ + is = for_character ("\342\201\271", 3); + ASSERT (is == 0); + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\357\274\221", 3); + ASSERT (is == 0); + /* U+FF21 FULLWIDTH LATIN CAPITAL LETTER A */ + is = for_character ("\357\274\241", 3); + ASSERT (is == 0); + /* U+FF41 FULLWIDTH LATIN SMALL LETTER A */ + is = for_character ("\357\275\201", 3); + ASSERT (is == 0); + /* U+1D7D1 MATHEMATICAL BOLD DIGIT THREE */ + is = for_character ("\360\235\237\221", 4); + ASSERT (is == 0); + /* U+1D7DB MATHEMATICAL DOUBLE-STRUCK DIGIT THREE */ + is = for_character ("\360\235\237\233", 4); + ASSERT (is == 0); + /* U+1D7E5 MATHEMATICAL SANS-SERIF DIGIT THREE */ + is = for_character ("\360\235\237\245", 4); + ASSERT (is == 0); + /* U+1D7EF MATHEMATICAL SANS-SERIF BOLD DIGIT THREE */ + is = for_character ("\360\235\237\257", 4); + ASSERT (is == 0); + /* U+1D7F9 MATHEMATICAL MONOSPACE DIGIT THREE */ + is = for_character ("\360\235\237\271", 4); + ASSERT (is == 0); + /* U+E0033 TAG DIGIT THREE */ + is = for_character ("\363\240\200\263", 4); + ASSERT (is == 0); + /* U+E0041 TAG LATIN CAPITAL LETTER A */ + is = for_character ("\363\240\201\201", 4); + ASSERT (is == 0); + } + return 0; + + case '4': + /* Locale encoding is GB18030. */ + { + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\201\060\205\065", 4); + ASSERT (is == 0); + /* U+00B3 SUPERSCRIPT THREE */ + is = for_character ("\201\060\205\066", 4); + ASSERT (is == 0); + /* U+00B9 SUPERSCRIPT ONE */ + is = for_character ("\201\060\206\061", 4); + ASSERT (is == 0); + /* U+0663 ARABIC-INDIC DIGIT THREE */ + is = for_character ("\201\061\211\071", 4); + ASSERT (is == 0); + /* U+2070 SUPERSCRIPT ZERO */ + is = for_character ("\201\066\255\062", 4); + ASSERT (is == 0); + /* U+2079 SUPERSCRIPT NINE */ + is = for_character ("\201\066\256\061", 4); + ASSERT (is == 0); + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\243\261", 2); + ASSERT (is == 0); + /* U+FF21 FULLWIDTH LATIN CAPITAL LETTER A */ + is = for_character ("\243\301", 2); + ASSERT (is == 0); + /* U+FF41 FULLWIDTH LATIN SMALL LETTER A */ + is = for_character ("\243\341", 2); + ASSERT (is == 0); + /* U+1D7D1 MATHEMATICAL BOLD DIGIT THREE */ + is = for_character ("\224\063\353\071", 4); + ASSERT (is == 0); + /* U+1D7DB MATHEMATICAL DOUBLE-STRUCK DIGIT THREE */ + is = for_character ("\224\063\354\071", 4); + ASSERT (is == 0); + /* U+1D7E5 MATHEMATICAL SANS-SERIF DIGIT THREE */ + is = for_character ("\224\063\355\071", 4); + ASSERT (is == 0); + /* U+1D7EF MATHEMATICAL SANS-SERIF BOLD DIGIT THREE */ + is = for_character ("\224\063\356\071", 4); + ASSERT (is == 0); + /* U+1D7F9 MATHEMATICAL MONOSPACE DIGIT THREE */ + is = for_character ("\224\063\357\071", 4); + ASSERT (is == 0); + /* U+E0033 TAG DIGIT THREE */ + is = for_character ("\323\066\232\071", 4); + ASSERT (is == 0); + /* U+E0041 TAG LATIN CAPITAL LETTER A */ + is = for_character ("\323\066\234\063", 4); + ASSERT (is == 0); + } + return 0; + + } + + return 1; +} diff --git a/gnulib-tests/test-iswxdigit.sh b/gnulib-tests/test-iswxdigit.sh new file mode 100755 index 0000000..f545438 --- /dev/null +++ b/gnulib-tests/test-iswxdigit.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# Test in the POSIX locale. +LC_ALL=C ${CHECKER} ./test-iswxdigit${EXEEXT} 0 || exit 1 +LC_ALL=POSIX ${CHECKER} ./test-iswxdigit${EXEEXT} 0 || exit 1 + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: ${LOCALE_FR=fr_FR} +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR \ + ${CHECKER} ./test-iswxdigit${EXEEXT} 1 \ + || exit 1 +fi + +# Test whether a specific EUC-JP locale is installed. +: ${LOCALE_JA=ja_JP} +if test $LOCALE_JA != none; then + LC_ALL=$LOCALE_JA \ + ${CHECKER} ./test-iswxdigit${EXEEXT} 2 \ + || exit 1 +fi + +# Test whether a specific UTF-8 locale is installed. +: ${LOCALE_FR_UTF8=fr_FR.UTF-8} +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 \ + ${CHECKER} ./test-iswxdigit${EXEEXT} 3 \ + || exit 1 +fi + +# Test whether a specific GB18030 locale is installed. +: ${LOCALE_ZH_CN=zh_CN.GB18030} +if test $LOCALE_ZH_CN != none; then + LC_ALL=$LOCALE_ZH_CN \ + ${CHECKER} ./test-iswxdigit${EXEEXT} 4 \ + || exit 1 +fi + +exit 0 diff --git a/gnulib-tests/test-langinfo.c b/gnulib-tests/test-langinfo.c new file mode 100644 index 0000000..4f3bbb0 --- /dev/null +++ b/gnulib-tests/test-langinfo.c @@ -0,0 +1,92 @@ +/* Test of <langinfo.h> substitute. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2009. */ + +#include <config.h> + +#include <langinfo.h> + +/* Check that all the nl_item values are defined. */ +int items[] = + { + /* nl_langinfo items of the LC_CTYPE category */ + CODESET, + /* nl_langinfo items of the LC_NUMERIC category */ + RADIXCHAR, + THOUSEP, + /* nl_langinfo items of the LC_TIME category */ + D_T_FMT, + D_FMT, + T_FMT, + T_FMT_AMPM, + AM_STR, + PM_STR, + DAY_1, + DAY_2, + DAY_3, + DAY_4, + DAY_5, + DAY_6, + DAY_7, + ABDAY_1, + ABDAY_2, + ABDAY_3, + ABDAY_4, + ABDAY_5, + ABDAY_6, + ABDAY_7, + MON_1, + MON_2, + MON_3, + MON_4, + MON_5, + MON_6, + MON_7, + MON_8, + MON_9, + MON_10, + MON_11, + MON_12, + ABMON_1, + ABMON_2, + ABMON_3, + ABMON_4, + ABMON_5, + ABMON_6, + ABMON_7, + ABMON_8, + ABMON_9, + ABMON_10, + ABMON_11, + ABMON_12, + ERA, + ERA_D_FMT, + ERA_D_T_FMT, + ERA_T_FMT, + ALT_DIGITS, + /* nl_langinfo items of the LC_MONETARY category */ + CRNCYSTR, + /* nl_langinfo items of the LC_MESSAGES category */ + YESEXPR, + NOEXPR + }; + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tests/test-lchmod.c b/gnulib-tests/test-lchmod.c new file mode 100644 index 0000000..783e608 --- /dev/null +++ b/gnulib-tests/test-lchmod.c @@ -0,0 +1,67 @@ +/* Test changing the protections of a file. + Copyright (C) 2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <sys/stat.h> + +#include "signature.h" +SIGNATURE_CHECK (lchmod, int, (const char *, mode_t)); + +#include <errno.h> +#include <fcntl.h> +#include <sys/stat.h> +#include <unistd.h> + +#include "macros.h" + +#define BASE "test-lchmod." + +int +main (void) +{ + /* Test that lchmod works on non-symlinks. */ + { + struct stat statbuf; + unlink (BASE "file"); + ASSERT (close (creat (BASE "file", 0600)) == 0); + ASSERT (lchmod (BASE "file", 0400) == 0); + ASSERT (stat (BASE "file", &statbuf) >= 0); + ASSERT ((statbuf.st_mode & 0700) == 0400); + /* Clean up. */ + ASSERT (chmod (BASE "file", 0600) == 0); + ASSERT (unlink (BASE "file") == 0); + } + + /* Test that lchmod on symlinks does not modify the symlink target. */ + { + unlink (BASE "file"); + unlink (BASE "link"); + if (symlink (BASE "file", BASE "link") == 0) + { + struct stat statbuf; + ASSERT (close (creat (BASE "file", 0600)) == 0); + lchmod (BASE "link", 0400); + ASSERT (stat (BASE "file", &statbuf) >= 0); + ASSERT ((statbuf.st_mode & 0700) == 0600); + } + /* Clean up. */ + unlink (BASE "file"); + unlink (BASE "link"); + } + + return 0; +} diff --git a/gnulib-tests/test-lchown.c b/gnulib-tests/test-lchown.c new file mode 100644 index 0000000..b817267 --- /dev/null +++ b/gnulib-tests/test-lchown.c @@ -0,0 +1,49 @@ +/* Tests of lchown. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (lchown, int, (char const *, uid_t, gid_t)); + +#include <fcntl.h> +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/stat.h> + +#include "mgetgroups.h" +#include "stat-time.h" +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-lchown.t" + +#include "test-lchown.h" + +int +main (void) +{ + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + return test_lchown (lchown, true); +} diff --git a/gnulib-tests/test-lchown.h b/gnulib-tests/test-lchown.h new file mode 100644 index 0000000..cf29e29 --- /dev/null +++ b/gnulib-tests/test-lchown.h @@ -0,0 +1,260 @@ +/* Tests of lchown. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include "nap.h" + +#if !HAVE_GETEGID +# define getegid() ((gid_t) -1) +#endif + +#ifndef HAVE_LCHMOD +# define HAVE_LCHMOD 0 +#endif + +#ifndef CHOWN_CHANGE_TIME_BUG +# define CHOWN_CHANGE_TIME_BUG 0 +#endif + +/* This file is designed to test lchown(n,o,g) and + chownat(AT_FDCWD,n,o,g,AT_SYMLINK_NOFOLLOW). FUNC is the function + to test. Assumes that BASE and ASSERT are already defined, and + that appropriate headers are already included. If PRINT, warn + before skipping symlink tests with status 77. */ + +static int +test_lchown (int (*func) (char const *, uid_t, gid_t), bool print) +{ + struct stat st1; + struct stat st2; + gid_t *gids = NULL; + int gids_count; + int result; + + /* Solaris 8 is interesting - if the current process belongs to + multiple groups, the current directory is owned by a group that + the current process belongs to but different than getegid(), and + the current directory does not have the S_ISGID bit, then regular + files created in the directory belong to the directory's group, + but symlinks belong to the current effective group id. If + S_ISGID is set, then both files and symlinks belong to the + directory's group. However, it is possible to run the testsuite + from within a directory owned by a group we don't belong to, in + which case all things that we create belong to the current + effective gid. So, work around the issues by creating a + subdirectory (we are guaranteed that the subdirectory will be + owned by one of our current groups), change ownership of that + directory to the current effective gid (which will thus succeed), + then create all other files within that directory (eliminating + questions on whether inheritance or current id triumphs, since + the two methods resolve to the same gid). */ + ASSERT (mkdir (BASE "dir", 0700) == 0); + ASSERT (stat (BASE "dir", &st1) == 0); + + /* Filter out mingw and file systems which have no concept of groups. */ + result = func (BASE "dir", st1.st_uid, getegid ()); + if (result == -1 && (errno == ENOSYS || errno == EPERM)) + { + ASSERT (rmdir (BASE "dir") == 0); + if (print) + fputs ("skipping test: no support for ownership\n", stderr); + return 77; + } + ASSERT (result == 0); + + ASSERT (close (creat (BASE "dir/file", 0600)) == 0); + ASSERT (stat (BASE "dir/file", &st1) == 0); + ASSERT (st1.st_uid != (uid_t) -1); + ASSERT (st1.st_gid != (gid_t) -1); + ASSERT (st1.st_gid == getegid ()); + + /* Sanity check of error cases. */ + errno = 0; + ASSERT (func ("", -1, -1) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func ("no_such", -1, -1) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func ("no_such/", -1, -1) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func (BASE "dir/file/", -1, -1) == -1); + ASSERT (errno == ENOTDIR); + + /* Check that -1 does not alter ownership. */ + ASSERT (func (BASE "dir/file", -1, st1.st_gid) == 0); + ASSERT (func (BASE "dir/file", st1.st_uid, -1) == 0); + ASSERT (func (BASE "dir/file", (uid_t) -1, (gid_t) -1) == 0); + ASSERT (stat (BASE "dir/file", &st2) == 0); + ASSERT (st1.st_uid == st2.st_uid); + ASSERT (st1.st_gid == st2.st_gid); + + /* Even if the values aren't changing, ctime is required to change + if at least one argument is not -1. */ + nap (); + ASSERT (func (BASE "dir/file", st1.st_uid, st1.st_gid) == 0); + ASSERT (stat (BASE "dir/file", &st2) == 0); + ASSERT (st1.st_ctime < st2.st_ctime + || (st1.st_ctime == st2.st_ctime + && get_stat_ctime_ns (&st1) < get_stat_ctime_ns (&st2))); + + /* Test symlink behavior. */ + if (symlink ("link", BASE "dir/link2")) + { + ASSERT (unlink (BASE "dir/file") == 0); + ASSERT (rmdir (BASE "dir") == 0); + if (print) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + result = func (BASE "dir/link2", -1, -1); + if (result == -1 && (errno == ENOSYS || errno == EOPNOTSUPP)) + { + ASSERT (unlink (BASE "dir/file") == 0); + ASSERT (unlink (BASE "dir/link2") == 0); + ASSERT (rmdir (BASE "dir") == 0); + if (print) + fputs ("skipping test: symlink ownership not supported\n", stderr); + return 77; + } + ASSERT (result == 0); + errno = 0; + ASSERT (func (BASE "dir/link2/", st1.st_uid, st1.st_gid) == -1); + ASSERT (errno == ENOENT); + ASSERT (symlink ("file", BASE "dir/link") == 0); + ASSERT (mkdir (BASE "dir/sub", 0700) == 0); + ASSERT (symlink ("sub", BASE "dir/link3") == 0); + + /* For non-privileged users, lchown can only portably succeed at + changing group ownership of a file we own. If we belong to at + least two groups, then verifying the correct change is simple. + But if we belong to only one group, then we fall back on the + other observable effect of lchown: the ctime must be updated. */ + gids_count = mgetgroups (NULL, st1.st_gid, &gids); + if (1 < gids_count) + { + ASSERT (gids[1] != st1.st_gid); + ASSERT (gids[1] != (gid_t) -1); + ASSERT (lstat (BASE "dir/link", &st2) == 0); + ASSERT (st1.st_uid == st2.st_uid); + ASSERT (st1.st_gid == st2.st_gid); + ASSERT (lstat (BASE "dir/link2", &st2) == 0); + ASSERT (st1.st_uid == st2.st_uid); + ASSERT (st1.st_gid == st2.st_gid); + + errno = 0; + ASSERT (func (BASE "dir/link2/", -1, gids[1]) == -1); + ASSERT (errno == ENOTDIR); + ASSERT (stat (BASE "dir/file", &st2) == 0); + ASSERT (st1.st_uid == st2.st_uid); + ASSERT (st1.st_gid == st2.st_gid); + ASSERT (lstat (BASE "dir/link", &st2) == 0); + ASSERT (st1.st_uid == st2.st_uid); + ASSERT (st1.st_gid == st2.st_gid); + ASSERT (lstat (BASE "dir/link2", &st2) == 0); + ASSERT (st1.st_uid == st2.st_uid); + ASSERT (st1.st_gid == st2.st_gid); + + ASSERT (func (BASE "dir/link2", -1, gids[1]) == 0); + ASSERT (stat (BASE "dir/file", &st2) == 0); + ASSERT (st1.st_uid == st2.st_uid); + ASSERT (st1.st_gid == st2.st_gid); + ASSERT (lstat (BASE "dir/link", &st2) == 0); + ASSERT (st1.st_uid == st2.st_uid); + ASSERT (st1.st_gid == st2.st_gid); + ASSERT (lstat (BASE "dir/link2", &st2) == 0); + ASSERT (st1.st_uid == st2.st_uid); + ASSERT (gids[1] == st2.st_gid); + + /* Trailing slash follows through to directory. */ + ASSERT (lstat (BASE "dir/link3", &st2) == 0); + ASSERT (st1.st_uid == st2.st_uid); + ASSERT (st1.st_gid == st2.st_gid); + ASSERT (lstat (BASE "dir/sub", &st2) == 0); + ASSERT (st1.st_uid == st2.st_uid); + ASSERT (st1.st_gid == st2.st_gid); + + ASSERT (func (BASE "dir/link3/", -1, gids[1]) == 0); + ASSERT (lstat (BASE "dir/link3", &st2) == 0); + ASSERT (st1.st_uid == st2.st_uid); + ASSERT (st1.st_gid == st2.st_gid); + ASSERT (lstat (BASE "dir/sub", &st2) == 0); + ASSERT (st1.st_uid == st2.st_uid); + ASSERT (gids[1] == st2.st_gid); + } + else if (!CHOWN_CHANGE_TIME_BUG || HAVE_LCHMOD) + { + /* If we don't have lchmod, and lchown fails to change ctime, + then we can't test this part of lchown. */ + struct stat l1; + struct stat l2; + ASSERT (stat (BASE "dir/file", &st1) == 0); + ASSERT (lstat (BASE "dir/link", &l1) == 0); + ASSERT (lstat (BASE "dir/link2", &l2) == 0); + + nap (); + errno = 0; + ASSERT (func (BASE "dir/link2/", -1, st1.st_gid) == -1); + ASSERT (errno == ENOTDIR); + ASSERT (stat (BASE "dir/file", &st2) == 0); + ASSERT (st1.st_ctime == st2.st_ctime); + ASSERT (get_stat_ctime_ns (&st1) == get_stat_ctime_ns (&st2)); + ASSERT (lstat (BASE "dir/link", &st2) == 0); + ASSERT (l1.st_ctime == st2.st_ctime); + ASSERT (get_stat_ctime_ns (&l1) == get_stat_ctime_ns (&st2)); + ASSERT (lstat (BASE "dir/link2", &st2) == 0); + ASSERT (l2.st_ctime == st2.st_ctime); + ASSERT (get_stat_ctime_ns (&l2) == get_stat_ctime_ns (&st2)); + + ASSERT (func (BASE "dir/link2", -1, st1.st_gid) == 0); + ASSERT (stat (BASE "dir/file", &st2) == 0); + ASSERT (st1.st_ctime == st2.st_ctime); + ASSERT (get_stat_ctime_ns (&st1) == get_stat_ctime_ns (&st2)); + ASSERT (lstat (BASE "dir/link", &st2) == 0); + ASSERT (l1.st_ctime == st2.st_ctime); + ASSERT (get_stat_ctime_ns (&l1) == get_stat_ctime_ns (&st2)); + ASSERT (lstat (BASE "dir/link2", &st2) == 0); + ASSERT (l2.st_ctime < st2.st_ctime + || (l2.st_ctime == st2.st_ctime + && get_stat_ctime_ns (&l2) < get_stat_ctime_ns (&st2))); + + /* Trailing slash follows through to directory. */ + ASSERT (lstat (BASE "dir/sub", &st1) == 0); + ASSERT (lstat (BASE "dir/link3", &l1) == 0); + nap (); + ASSERT (func (BASE "dir/link3/", -1, st1.st_gid) == 0); + ASSERT (lstat (BASE "dir/link3", &st2) == 0); + ASSERT (l1.st_ctime == st2.st_ctime); + ASSERT (get_stat_ctime_ns (&l1) == get_stat_ctime_ns (&st2)); + ASSERT (lstat (BASE "dir/sub", &st2) == 0); + ASSERT (st1.st_ctime < st2.st_ctime + || (st1.st_ctime == st2.st_ctime + && get_stat_ctime_ns (&st1) < get_stat_ctime_ns (&st2))); + } + + /* Cleanup. */ + free (gids); + ASSERT (unlink (BASE "dir/file") == 0); + ASSERT (unlink (BASE "dir/link") == 0); + ASSERT (unlink (BASE "dir/link2") == 0); + ASSERT (unlink (BASE "dir/link3") == 0); + ASSERT (rmdir (BASE "dir/sub") == 0); + ASSERT (rmdir (BASE "dir") == 0); + return 0; +} diff --git a/gnulib-tests/test-limits-h.c b/gnulib-tests/test-limits-h.c new file mode 100644 index 0000000..2629c96 --- /dev/null +++ b/gnulib-tests/test-limits-h.c @@ -0,0 +1,117 @@ +/* Test of <limits.h> substitute. + Copyright 2016-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Paul Eggert. */ + +#include <config.h> + +#include <limits.h> + +#include "verify.h" + +#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +# pragma GCC diagnostic ignored "-Woverlength-strings" +#endif + +#define verify_width(width, min, max) \ + verify ((max) >> ((width) - 1 - ((min) < 0)) == 1) + +/* Macros borrowed from intprops.h. */ +#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) +#define TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT) +#define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t)) +#define TYPE_MAXIMUM(t) \ + ((t) (! TYPE_SIGNED (t) \ + ? (t) -1 \ + : ((((t) 1 << (TYPE_WIDTH (t) - 2)) - 1) * 2 + 1))) + +/* Type width macros. */ + +int type_bits[] = + { + CHAR_BIT, + WORD_BIT, + LONG_BIT + }; +verify_width (CHAR_BIT, CHAR_MIN, CHAR_MAX); +verify_width (WORD_BIT, INT_MIN, INT_MAX); +verify_width (LONG_BIT, LONG_MIN, LONG_MAX); + +/* Numerical limit macros. */ + +char limits1[] = { CHAR_MIN, CHAR_MAX }; +verify (TYPE_MINIMUM (char) == CHAR_MIN); +verify (TYPE_MAXIMUM (char) == CHAR_MAX); + +signed char limits2[] = { SCHAR_MIN, SCHAR_MAX }; +verify (TYPE_MINIMUM (signed char) == SCHAR_MIN); +verify (TYPE_MAXIMUM (signed char) == SCHAR_MAX); + +unsigned char limits3[] = { UCHAR_MAX }; +verify (TYPE_MINIMUM (unsigned char) == 0); +verify (TYPE_MAXIMUM (unsigned char) == UCHAR_MAX); + +short limits4[] = { SHRT_MIN, SHRT_MAX }; +verify (TYPE_MINIMUM (short int) == SHRT_MIN); +verify (TYPE_MAXIMUM (short int) == SHRT_MAX); + +unsigned short limits5[] = { USHRT_MAX }; +verify (TYPE_MINIMUM (unsigned short int) == 0); +verify (TYPE_MAXIMUM (unsigned short int) == USHRT_MAX); + +int limits6[] = { INT_MIN, INT_MAX }; +verify (TYPE_MINIMUM (int) == INT_MIN); +verify (TYPE_MAXIMUM (int) == INT_MAX); + +unsigned int limits7[] = { UINT_MAX }; +verify (TYPE_MINIMUM (unsigned int) == 0); +verify (TYPE_MAXIMUM (unsigned int) == UINT_MAX); + +long limits8[] = { LONG_MIN, LONG_MAX }; +verify (TYPE_MINIMUM (long int) == LONG_MIN); +verify (TYPE_MAXIMUM (long int) == LONG_MAX); + +unsigned long limits9[] = { ULONG_MAX }; +verify (TYPE_MINIMUM (unsigned long int) == 0); +verify (TYPE_MAXIMUM (unsigned long int) == ULONG_MAX); + +long long limits10[] = { LLONG_MIN, LLONG_MAX }; +verify (TYPE_MINIMUM (long long int) == LLONG_MIN); +verify (TYPE_MAXIMUM (long long int) == LLONG_MAX); + +unsigned long long limits11[] = { ULLONG_MAX }; +verify (TYPE_MINIMUM (unsigned long long int) == 0); +verify (TYPE_MAXIMUM (unsigned long long int) == ULLONG_MAX); + +/* Macros specified by ISO/IEC TS 18661-1:2014. */ + +verify_width (CHAR_WIDTH, CHAR_MIN, CHAR_MAX); +verify_width (SCHAR_WIDTH, SCHAR_MIN, SCHAR_MAX); +verify_width (UCHAR_WIDTH, 0, UCHAR_MAX); +verify_width (SHRT_WIDTH, SHRT_MIN, SHRT_MAX); +verify_width (USHRT_WIDTH, 0, USHRT_MAX); +verify_width (INT_WIDTH, INT_MIN, INT_MAX); +verify_width (UINT_WIDTH, 0, UINT_MAX); +verify_width (LONG_WIDTH, LONG_MIN, LONG_MAX); +verify_width (ULONG_WIDTH, 0, ULONG_MAX); +verify_width (LLONG_WIDTH, LLONG_MIN, LLONG_MAX); +verify_width (ULLONG_WIDTH, 0, ULLONG_MAX); + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tests/test-link.c b/gnulib-tests/test-link.c new file mode 100644 index 0000000..5e192dc --- /dev/null +++ b/gnulib-tests/test-link.c @@ -0,0 +1,47 @@ +/* Test of link() function. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (link, int, (char const *, char const *)); + +#include <errno.h> +#include <fcntl.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> +#include <unistd.h> + +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-link.t" + +#include "test-link.h" + +int +main (void) +{ + /* Remove any garbage left from previous partial runs. */ + ignore_value (system ("rm -rf " BASE "*")); + + return test_link (link, true); +} diff --git a/gnulib-tests/test-link.h b/gnulib-tests/test-link.h new file mode 100644 index 0000000..a244077 --- /dev/null +++ b/gnulib-tests/test-link.h @@ -0,0 +1,182 @@ +/* Test of link() function. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* This file is designed to test both link(a,b) and + linkat(AT_FDCWD,a,AT_FDCWD,b,0). FUNC is the function to test. + Assumes that BASE and ASSERT are already defined, and that + appropriate headers are already included. If PRINT, warn before + skipping tests with status 77. This test does not try to create + hard links to symlinks, but does test other aspects of symlink. */ + +static int +test_link (int (*func) (char const *, char const *), bool print) +{ + int fd; + int ret; + + /* Create first file. */ + fd = open (BASE "a", O_CREAT | O_EXCL | O_WRONLY, 0600); + ASSERT (0 <= fd); + ASSERT (write (fd, "hello", 5) == 5); + ASSERT (close (fd) == 0); + + /* Not all file systems support link. Mingw doesn't have reliable + st_nlink on hard links, but our implementation does fail with + EPERM on poor file systems, and we can detect the inferior stat() + via st_ino. Cygwin 1.5.x copies rather than links files on those + file systems, but there, st_nlink and st_ino are reliable. */ + ret = func (BASE "a", BASE "b"); + if (!ret) + { + struct stat st; + ASSERT (stat (BASE "b", &st) == 0); + if (st.st_ino && st.st_nlink != 2) + { + ASSERT (unlink (BASE "b") == 0); + errno = EPERM; + ret = -1; + } + } + if (ret == -1) + { + /* If the device does not support hard links, errno is + EPERM on Linux, EOPNOTSUPP on FreeBSD. */ + switch (errno) + { + case EPERM: + case EOPNOTSUPP: + if (print) + fputs ("skipping test: " + "hard links not supported on this file system\n", + stderr); + ASSERT (unlink (BASE "a") == 0); + return 77; + default: + perror ("link"); + return 1; + } + } + ASSERT (ret == 0); + + /* Now, for some behavior tests. Modify the contents of 'b', and + ensure that 'a' can see it, both while 'b' exists and after. */ + fd = open (BASE "b", O_APPEND | O_WRONLY); + ASSERT (0 <= fd); + ASSERT (write (fd, "world", 5) == 5); + ASSERT (close (fd) == 0); + { + char buf[11] = { 0 }; + fd = open (BASE "a", O_RDONLY); + ASSERT (0 <= fd); + ASSERT (read (fd, buf, 10) == 10); + ASSERT (strcmp (buf, "helloworld") == 0); + ASSERT (close (fd) == 0); + ASSERT (unlink (BASE "b") == 0); + fd = open (BASE "a", O_RDONLY); + ASSERT (0 <= fd); + ASSERT (read (fd, buf, 10) == 10); + ASSERT (strcmp (buf, "helloworld") == 0); + ASSERT (close (fd) == 0); + } + + /* Test for various error conditions. */ + ASSERT (mkdir (BASE "d", 0700) == 0); + errno = 0; + ASSERT (func (BASE "a", ".") == -1); + ASSERT (errno == EEXIST || errno == EINVAL); + errno = 0; + ASSERT (func (BASE "a", BASE "a") == -1); + ASSERT (errno == EEXIST); + ASSERT (func (BASE "a", BASE "b") == 0); + errno = 0; + ASSERT (func (BASE "a", BASE "b") == -1); + ASSERT (errno == EEXIST); + errno = 0; + ASSERT (func (BASE "a", BASE "d") == -1); + ASSERT (errno == EEXIST); + errno = 0; + ASSERT (func (BASE "c", BASE "e") == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func (BASE "a", BASE "c/.") == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func (BASE "a/", BASE "c") == -1); + ASSERT (errno == ENOTDIR || errno == EINVAL); + errno = 0; + ASSERT (func (BASE "a", BASE "c/") == -1); + ASSERT (errno == ENOTDIR || errno == ENOENT || errno == EINVAL); + + /* Most platforms reject hard links to directories, and even on + those that do permit it, most users can't create them. We assume + that if this test is run as root and we managed to create a hard + link, then unlink better be able to clean it up. */ + { + int result; + errno = 0; + result = func (BASE "d", BASE "c"); + if (result == 0) + { + /* Probably root on Solaris. */ + ASSERT (unlink (BASE "c") == 0); + } + else + { + /* Most everyone else. */ + ASSERT (errno == EPERM || errno == EACCES || errno == EISDIR); + errno = 0; + ASSERT (func (BASE "d/.", BASE "c") == -1); + ASSERT (errno == EPERM || errno == EACCES || errno == EISDIR + || errno == EINVAL); + errno = 0; + ASSERT (func (BASE "d/.//", BASE "c") == -1); + ASSERT (errno == EPERM || errno == EACCES || errno == EISDIR + || errno == EINVAL); + } + } + ASSERT (unlink (BASE "a") == 0); + errno = 0; + ASSERT (unlink (BASE "c") == -1); + ASSERT (errno == ENOENT); + ASSERT (rmdir (BASE "d") == 0); + + /* Test invalid use of symlink. */ + if (symlink (BASE "a", BASE "link") != 0) + { + ASSERT (unlink (BASE "b") == 0); + if (print) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + errno = 0; + ASSERT (func (BASE "b", BASE "link/") == -1); + ASSERT (errno == ENOTDIR || errno == ENOENT || errno == EEXIST + || errno == EINVAL); + errno = 0; + ASSERT (func (BASE "b", BASE "link") == -1); + ASSERT (errno == EEXIST); + ASSERT (rename (BASE "b", BASE "a") == 0); + errno = 0; + ASSERT (func (BASE "link/", BASE "b") == -1); + ASSERT (errno == ENOTDIR || errno == EEXIST || errno == EINVAL); + + /* Clean up. */ + ASSERT (unlink (BASE "a") == 0); + ASSERT (unlink (BASE "link") == 0); + + return 0; +} diff --git a/gnulib-tests/test-linkat.c b/gnulib-tests/test-linkat.c new file mode 100644 index 0000000..c14f851 --- /dev/null +++ b/gnulib-tests/test-linkat.c @@ -0,0 +1,383 @@ +/* Tests of linkat. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (linkat, int, (int, char const *, int, char const *, int)); + +#include <fcntl.h> +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> + +#include "areadlink.h" +#include "filenamecat.h" +#include "same-inode.h" +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-linkat.t" + +#include "test-link.h" + +static int dfd1 = AT_FDCWD; +static int dfd2 = AT_FDCWD; +static int flag = AT_SYMLINK_FOLLOW; + +/* Wrapper to test linkat like link. */ +static int +do_link (char const *name1, char const *name2) +{ + return linkat (dfd1, name1, dfd2, name2, flag); +} + +/* Can we expect that link() and linkat(), when called on a symlink, + increment the link count of that symlink? */ +#if LINK_FOLLOWS_SYMLINKS == 0 +# define EXPECT_LINK_HARDLINKS_SYMLINKS 1 +#elif LINK_FOLLOWS_SYMLINKS == -1 +extern int __xpg4; +# define EXPECT_LINK_HARDLINKS_SYMLINKS (__xpg4 == 0) +#else +# define EXPECT_LINK_HARDLINKS_SYMLINKS 0 +#endif + +/* Wrapper to see if two symlinks act the same. */ +static void +check_same_link (char const *name1, char const *name2) +{ + struct stat st1; + struct stat st2; + char *contents1; + char *contents2; + ASSERT (lstat (name1, &st1) == 0); + ASSERT (lstat (name2, &st2) == 0); + contents1 = areadlink_with_size (name1, st1.st_size); + contents2 = areadlink_with_size (name2, st2.st_size); + ASSERT (contents1); + ASSERT (contents2); + ASSERT (strcmp (contents1, contents2) == 0); + if (EXPECT_LINK_HARDLINKS_SYMLINKS) + ASSERT (SAME_INODE (st1, st2)); + free (contents1); + free (contents2); +} + +int +main (void) +{ + int i; + int dfd; + char *cwd; + int result; + + /* Clean up any trash from prior testsuite runs. */ + ignore_value (system ("rm -rf " BASE "*")); + + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (linkat (-1, "foo", AT_FDCWD, "bar", 0) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (linkat (99, "foo", AT_FDCWD, "bar", 0) == -1); + ASSERT (errno == EBADF); + } + ASSERT (close (creat (BASE "oo", 0600)) == 0); + { + errno = 0; + ASSERT (linkat (AT_FDCWD, BASE "oo", -1, "bar", 0) == -1); + ASSERT (errno == EBADF); + } + { + errno = 0; + ASSERT (linkat (AT_FDCWD, BASE "oo", 99, "bar", 0) == -1); + ASSERT (errno == EBADF); + } + ASSERT (unlink (BASE "oo") == 0); + + /* Test basic link functionality, without mentioning symlinks. */ + result = test_link (do_link, true); + dfd1 = open (".", O_RDONLY); + ASSERT (0 <= dfd1); + ASSERT (test_link (do_link, false) == result); + dfd2 = dfd1; + ASSERT (test_link (do_link, false) == result); + dfd1 = AT_FDCWD; + ASSERT (test_link (do_link, false) == result); + flag = 0; + ASSERT (test_link (do_link, false) == result); + dfd1 = dfd2; + ASSERT (test_link (do_link, false) == result); + dfd2 = AT_FDCWD; + ASSERT (test_link (do_link, false) == result); + ASSERT (close (dfd1) == 0); + dfd1 = AT_FDCWD; + ASSERT (test_link (do_link, false) == result); + + /* Create locations to manipulate. */ + ASSERT (mkdir (BASE "sub1", 0700) == 0); + ASSERT (mkdir (BASE "sub2", 0700) == 0); + ASSERT (close (creat (BASE "00", 0600)) == 0); + cwd = getcwd (NULL, 0); + ASSERT (cwd); + + dfd = open (BASE "sub1", O_RDONLY); + ASSERT (0 <= dfd); + ASSERT (chdir (BASE "sub2") == 0); + + /* There are 16 possible scenarios, based on whether an fd is + AT_FDCWD or real, whether a file is absolute or relative, coupled + with whether flag is set for 32 iterations. + + To ensure that we test all of the code paths (rather than + triggering early normalization optimizations), we use a loop to + repeatedly rename a file in the parent directory, use an fd open + on subdirectory 1, all while executing in subdirectory 2; all + relative names are thus given with a leading "../". Finally, the + last scenario (two relative paths given, neither one AT_FDCWD) + has two paths, based on whether the two fds are equivalent, so we + do the other variant after the loop. */ + for (i = 0; i < 32; i++) + { + int fd1 = (i & 8) ? dfd : AT_FDCWD; + char *file1 = mfile_name_concat ((i & 4) ? ".." : cwd, BASE "xx", NULL); + int fd2 = (i & 2) ? dfd : AT_FDCWD; + char *file2 = mfile_name_concat ((i & 1) ? ".." : cwd, BASE "xx", NULL); + ASSERT (file1); + ASSERT (file2); + flag = (i & 0x10 ? AT_SYMLINK_FOLLOW : 0); + + ASSERT (sprintf (strchr (file1, '\0') - 2, "%02d", i) == 2); + ASSERT (sprintf (strchr (file2, '\0') - 2, "%02d", i + 1) == 2); + ASSERT (linkat (fd1, file1, fd2, file2, flag) == 0); + ASSERT (unlinkat (fd1, file1, 0) == 0); + free (file1); + free (file2); + } + dfd2 = open ("..", O_RDONLY); + ASSERT (0 <= dfd2); + ASSERT (linkat (dfd, "../" BASE "32", dfd2, BASE "33", 0) == 0); + ASSERT (linkat (dfd, "../" BASE "33", dfd2, BASE "34", + AT_SYMLINK_FOLLOW) == 0); + ASSERT (close (dfd2) == 0); + + /* Now we change back to the parent directory, and set dfd to ".", + in order to test behavior on symlinks. */ + ASSERT (chdir ("..") == 0); + ASSERT (close (dfd) == 0); + if (symlink (BASE "sub1", BASE "link1")) + { + ASSERT (unlink (BASE "32") == 0); + ASSERT (unlink (BASE "33") == 0); + ASSERT (unlink (BASE "34") == 0); + ASSERT (rmdir (BASE "sub1") == 0); + ASSERT (rmdir (BASE "sub2") == 0); + free (cwd); + if (!result) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return result; + } + dfd = open (".", O_RDONLY); + ASSERT (0 <= dfd); + ASSERT (symlink (BASE "34", BASE "link2") == 0); + ASSERT (symlink (BASE "link3", BASE "link3") == 0); + ASSERT (symlink (BASE "nowhere", BASE "link4") == 0); + + /* Link cannot overwrite existing files. */ + errno = 0; + ASSERT (linkat (dfd, BASE "link1", dfd, BASE "sub1", 0) == -1); + ASSERT (errno == EEXIST); + errno = 0; + ASSERT (linkat (dfd, BASE "link1/", dfd, BASE "sub1", 0) == -1); + ASSERT (errno == EEXIST || errno == EPERM || errno == EACCES); + errno = 0; + ASSERT (linkat (dfd, BASE "link1", dfd, BASE "sub1/", 0) == -1); + ASSERT (errno == EEXIST || errno == ENOTDIR); + errno = 0; + ASSERT (linkat (dfd, BASE "link1", dfd, BASE "sub1", + AT_SYMLINK_FOLLOW) == -1); + ASSERT (errno == EEXIST || errno == EPERM || errno == EACCES); + errno = 0; + ASSERT (linkat (dfd, BASE "link1/", dfd, BASE "sub1", + AT_SYMLINK_FOLLOW) == -1); + ASSERT (errno == EEXIST || errno == EPERM || errno == EACCES + || errno == EINVAL); + errno = 0; + ASSERT (linkat (dfd, BASE "link1", dfd, BASE "sub1/", + AT_SYMLINK_FOLLOW) == -1); + ASSERT (errno == EEXIST || errno == EPERM || errno == EACCES + || errno == EINVAL); + errno = 0; + ASSERT (linkat (dfd, BASE "link1", dfd, BASE "link2", 0) == -1); + ASSERT (errno == EEXIST); + errno = 0; + ASSERT (linkat (dfd, BASE "link1", dfd, BASE "link2", + AT_SYMLINK_FOLLOW) == -1); + ASSERT (errno == EEXIST || errno == EPERM || errno == EACCES); + errno = 0; + ASSERT (linkat (dfd, BASE "link1", dfd, BASE "link3", 0) == -1); + ASSERT (errno == EEXIST || errno == ELOOP); + errno = 0; + ASSERT (linkat (dfd, BASE "link1", dfd, BASE "link3", + AT_SYMLINK_FOLLOW) == -1); + ASSERT (errno == EEXIST || errno == EPERM || errno == EACCES + || errno == ELOOP); + errno = 0; + ASSERT (linkat (dfd, BASE "link2", dfd, BASE "link3", 0) == -1); + ASSERT (errno == EEXIST || errno == ELOOP); + errno = 0; + ASSERT (linkat (dfd, BASE "link2", dfd, BASE "link3", + AT_SYMLINK_FOLLOW) == -1); + ASSERT (errno == EEXIST || errno == ELOOP); + + /* AT_SYMLINK_FOLLOW only follows first argument, not second. */ + errno = 0; + ASSERT (linkat (dfd, BASE "link1", dfd, BASE "link4", 0) == -1); + ASSERT (errno == EEXIST); + ASSERT (linkat (dfd, BASE "link1", dfd, BASE "link4", + AT_SYMLINK_FOLLOW) == -1); + ASSERT (errno == EEXIST || errno == EPERM || errno == EACCES); + errno = 0; + ASSERT (linkat (dfd, BASE "34", dfd, BASE "link4", 0) == -1); + ASSERT (errno == EEXIST); + errno = 0; + ASSERT (linkat (dfd, BASE "34", dfd, BASE "link4", AT_SYMLINK_FOLLOW) == -1); + ASSERT (errno == EEXIST); + + /* Trailing slash handling. */ + errno = 0; + ASSERT (linkat (dfd, BASE "link2/", dfd, BASE "link5", 0) == -1); + ASSERT (errno == ENOTDIR); + errno = 0; + ASSERT (linkat (dfd, BASE "link2/", dfd, BASE "link5", + AT_SYMLINK_FOLLOW) == -1); + ASSERT (errno == ENOTDIR || errno == EINVAL); + errno = 0; + ASSERT (linkat (dfd, BASE "link3/", dfd, BASE "link5", 0) == -1); + ASSERT (errno == ELOOP); + errno = 0; + ASSERT (linkat (dfd, BASE "link3/", dfd, BASE "link5", + AT_SYMLINK_FOLLOW) == -1); + ASSERT (errno == ELOOP || errno == EINVAL); + errno = 0; + ASSERT (linkat (dfd, BASE "link4/", dfd, BASE "link5", 0) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (linkat (dfd, BASE "link4/", dfd, BASE "link5", + AT_SYMLINK_FOLLOW) == -1); + ASSERT (errno == ENOENT || errno == EINVAL); + + /* Check for hard links to symlinks. */ + ASSERT (linkat (dfd, BASE "link1", dfd, BASE "link5", 0) == 0); + check_same_link (BASE "link1", BASE "link5"); + ASSERT (unlink (BASE "link5") == 0); + errno = 0; + ASSERT (linkat (dfd, BASE "link1", dfd, BASE "link5", + AT_SYMLINK_FOLLOW) == -1); + ASSERT (errno == EPERM || errno == EACCES); + ASSERT (linkat (dfd, BASE "link2", dfd, BASE "link5", 0) == 0); + check_same_link (BASE "link2", BASE "link5"); + ASSERT (unlink (BASE "link5") == 0); + ASSERT (linkat (dfd, BASE "link2", dfd, BASE "file", AT_SYMLINK_FOLLOW) == 0); + errno = 0; + ASSERT (areadlink (BASE "file") == NULL); + ASSERT (errno == EINVAL); + ASSERT (unlink (BASE "file") == 0); + ASSERT (linkat (dfd, BASE "link3", dfd, BASE "link5", 0) == 0); + check_same_link (BASE "link3", BASE "link5"); + ASSERT (unlink (BASE "link5") == 0); + errno = 0; + ASSERT (linkat (dfd, BASE "link3", dfd, BASE "link5", + AT_SYMLINK_FOLLOW) == -1); + ASSERT (errno == ELOOP); + ASSERT (linkat (dfd, BASE "link4", dfd, BASE "link5", 0) == 0); + check_same_link (BASE "link4", BASE "link5"); + ASSERT (unlink (BASE "link5") == 0); + errno = 0; + ASSERT (linkat (dfd, BASE "link4", dfd, BASE "link5", + AT_SYMLINK_FOLLOW) == -1); + ASSERT (errno == ENOENT); + + /* Check that symlink to symlink to file is followed all the way. */ + ASSERT (symlink (BASE "link2", BASE "link5") == 0); + ASSERT (linkat (dfd, BASE "link5", dfd, BASE "link6", 0) == 0); + check_same_link (BASE "link5", BASE "link6"); + ASSERT (unlink (BASE "link6") == 0); + ASSERT (linkat (dfd, BASE "link5", dfd, BASE "file", AT_SYMLINK_FOLLOW) == 0); + errno = 0; + ASSERT (areadlink (BASE "file") == NULL); + ASSERT (errno == EINVAL); + ASSERT (unlink (BASE "file") == 0); + ASSERT (unlink (BASE "link5") == 0); + ASSERT (symlink (BASE "link3", BASE "link5") == 0); + errno = 0; + ASSERT (linkat (dfd, BASE "link5", dfd, BASE "file", + AT_SYMLINK_FOLLOW) == -1); + ASSERT (errno == ELOOP); + ASSERT (unlink (BASE "link5") == 0); + ASSERT (symlink (BASE "link4", BASE "link5") == 0); + errno = 0; + ASSERT (linkat (dfd, BASE "link5", dfd, BASE "file", + AT_SYMLINK_FOLLOW) == -1); + ASSERT (errno == ENOENT); + + /* Now for some real fun with directory crossing. */ + ASSERT (symlink (cwd, BASE "sub1/link") == 0); + ASSERT (symlink (".././/" BASE "sub1/link/" BASE "link2", + BASE "sub2/link") == 0); + ASSERT (close (dfd) == 0); + dfd = open (BASE "sub1", O_RDONLY); + ASSERT (0 <= dfd); + dfd2 = open (BASE "sub2", O_RDONLY); + ASSERT (0 < dfd2); + ASSERT (linkat (dfd, "../" BASE "sub2/link", dfd2, "./..//" BASE "sub1/file", + AT_SYMLINK_FOLLOW) == 0); + errno = 0; + ASSERT (areadlink (BASE "sub1/file") == NULL); + ASSERT (errno == EINVAL); + + /* Cleanup. */ + ASSERT (close (dfd) == 0); + ASSERT (close (dfd2) == 0); + ASSERT (unlink (BASE "sub1/file") == 0); + ASSERT (unlink (BASE "sub1/link") == 0); + ASSERT (unlink (BASE "sub2/link") == 0); + ASSERT (unlink (BASE "32") == 0); + ASSERT (unlink (BASE "33") == 0); + ASSERT (unlink (BASE "34") == 0); + ASSERT (rmdir (BASE "sub1") == 0); + ASSERT (rmdir (BASE "sub2") == 0); + ASSERT (unlink (BASE "link1") == 0); + ASSERT (unlink (BASE "link2") == 0); + ASSERT (unlink (BASE "link3") == 0); + ASSERT (unlink (BASE "link4") == 0); + ASSERT (unlink (BASE "link5") == 0); + free (cwd); + return result; +} diff --git a/gnulib-tests/test-listen.c b/gnulib-tests/test-listen.c new file mode 100644 index 0000000..74d31ea --- /dev/null +++ b/gnulib-tests/test-listen.c @@ -0,0 +1,49 @@ +/* Test listen() function. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <sys/socket.h> + +#include "signature.h" +SIGNATURE_CHECK (listen, int, (int, int)); + +#include <errno.h> +#include <unistd.h> + +#include "sockets.h" +#include "macros.h" + +int +main (void) +{ + (void) gl_sockets_startup (SOCKETS_1_1); + + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (listen (-1, 1) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (listen (99 ,1) == -1); + ASSERT (errno == EBADF); + } + + return 0; +} diff --git a/gnulib-tests/test-localcharset.c b/gnulib-tests/test-localcharset.c new file mode 100644 index 0000000..b2dd51c --- /dev/null +++ b/gnulib-tests/test-localcharset.c @@ -0,0 +1,39 @@ +/* Manual test of localcharset() function. + Copyright (C) 2018-2020 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 <https://www.gnu.org/licenses/>. */ + +/* This program prints the result of locale_charset in the current locale. + One way to use it is: + $ for l in `locale -a`; do + echo -n "$l "; LANG=$l ./test-localcharset; + done \ + | sort -k 2 + */ + +#include <config.h> + +#include "localcharset.h" + +#include <locale.h> +#include <stdio.h> + +int +main (void) +{ + setlocale (LC_ALL, ""); + printf ("%s\n", locale_charset ()); + + return 0; +} diff --git a/gnulib-tests/test-locale.c b/gnulib-tests/test-locale.c new file mode 100644 index 0000000..264d7b6 --- /dev/null +++ b/gnulib-tests/test-locale.c @@ -0,0 +1,80 @@ +/* Test of <locale.h> substitute. + Copyright (C) 2007, 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <locale.h> + +#include "verify.h" + +int a[] = + { + LC_ALL, + LC_COLLATE, + LC_CTYPE, + LC_MESSAGES, + LC_MONETARY, + LC_NUMERIC, + LC_TIME + }; + +/* Check that the 'struct lconv' type is defined. */ +struct lconv l; +int ls; + +/* Check that NULL can be passed through varargs as a pointer type, + per POSIX 2008. */ +verify (sizeof NULL == sizeof (void *)); + +int +main () +{ +#if HAVE_WORKING_NEWLOCALE + /* Check that the locale_t type and the LC_GLOBAL_LOCALE macro are defined. */ + locale_t b = LC_GLOBAL_LOCALE; + (void) b; +#endif + + /* Check that 'struct lconv' has the ISO C and POSIX specified members. */ + ls += sizeof (*l.decimal_point); + ls += sizeof (*l.thousands_sep); + ls += sizeof (*l.grouping); + ls += sizeof (*l.mon_decimal_point); + ls += sizeof (*l.mon_thousands_sep); + ls += sizeof (*l.mon_grouping); + ls += sizeof (*l.positive_sign); + ls += sizeof (*l.negative_sign); + ls += sizeof (*l.currency_symbol); + ls += sizeof (l.frac_digits); + ls += sizeof (l.p_cs_precedes); + ls += sizeof (l.p_sign_posn); + ls += sizeof (l.p_sep_by_space); + ls += sizeof (l.n_cs_precedes); + ls += sizeof (l.n_sign_posn); + ls += sizeof (l.n_sep_by_space); + ls += sizeof (*l.int_curr_symbol); + ls += sizeof (l.int_frac_digits); + ls += sizeof (l.int_p_cs_precedes); + ls += sizeof (l.int_p_sign_posn); + ls += sizeof (l.int_p_sep_by_space); + ls += sizeof (l.int_n_cs_precedes); + ls += sizeof (l.int_n_sign_posn); + ls += sizeof (l.int_n_sep_by_space); + + return 0; +} diff --git a/gnulib-tests/test-localeconv.c b/gnulib-tests/test-localeconv.c new file mode 100644 index 0000000..ab54dde --- /dev/null +++ b/gnulib-tests/test-localeconv.c @@ -0,0 +1,72 @@ +/* Test of localeconv() function. + Copyright (C) 2012-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2012. */ + +#include <config.h> + +#include <locale.h> + +#include "signature.h" +SIGNATURE_CHECK (localeconv, struct lconv *, (void)); + +#include <limits.h> +#include <string.h> + +#include "macros.h" + +int +main () +{ + /* Test localeconv() result in the "C" locale. */ + { + struct lconv *l = localeconv (); + + ASSERT (STREQ (l->decimal_point, ".")); + ASSERT (STREQ (l->thousands_sep, "")); +#if !((defined __FreeBSD__ || defined __DragonFly__) || defined __sun || defined __CYGWIN__) + ASSERT (STREQ (l->grouping, "")); +#endif + + ASSERT (STREQ (l->mon_decimal_point, "")); + ASSERT (STREQ (l->mon_thousands_sep, "")); +#if !((defined __FreeBSD__ || defined __DragonFly__) || defined __sun || defined __CYGWIN__) + ASSERT (STREQ (l->mon_grouping, "")); +#endif + ASSERT (STREQ (l->positive_sign, "")); + ASSERT (STREQ (l->negative_sign, "")); + + ASSERT (STREQ (l->currency_symbol, "")); + ASSERT (l->frac_digits == CHAR_MAX); + ASSERT (l->p_cs_precedes == CHAR_MAX); + ASSERT (l->p_sign_posn == CHAR_MAX); + ASSERT (l->p_sep_by_space == CHAR_MAX); + ASSERT (l->n_cs_precedes == CHAR_MAX); + ASSERT (l->n_sign_posn == CHAR_MAX); + ASSERT (l->n_sep_by_space == CHAR_MAX); + + ASSERT (STREQ (l->int_curr_symbol, "")); + ASSERT (l->int_frac_digits == CHAR_MAX); + ASSERT (l->int_p_cs_precedes == CHAR_MAX); + ASSERT (l->int_p_sign_posn == CHAR_MAX); + ASSERT (l->int_p_sep_by_space == CHAR_MAX); + ASSERT (l->int_n_cs_precedes == CHAR_MAX); + ASSERT (l->int_n_sign_posn == CHAR_MAX); + ASSERT (l->int_n_sep_by_space == CHAR_MAX); + } + + return 0; +} diff --git a/gnulib-tests/test-localename.c b/gnulib-tests/test-localename.c new file mode 100644 index 0000000..6ff10d9 --- /dev/null +++ b/gnulib-tests/test-localename.c @@ -0,0 +1,816 @@ +/* Test of gl_locale_name function and its variants. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include "localename.h" + +#include <locale.h> +#include <stdlib.h> +#include <string.h> + +#include "macros.h" + +#if HAVE_WORKING_NEWLOCALE && HAVE_WORKING_USELOCALE && !HAVE_FAKE_LOCALES +# define HAVE_GOOD_USELOCALE 1 +#endif + + +#if HAVE_GOOD_USELOCALE + +static struct { int cat; int mask; const char *string; } const categories[] = + { + { LC_CTYPE, LC_CTYPE_MASK, "LC_CTYPE" }, + { LC_NUMERIC, LC_NUMERIC_MASK, "LC_NUMERIC" }, + { LC_TIME, LC_TIME_MASK, "LC_TIME" }, + { LC_COLLATE, LC_COLLATE_MASK, "LC_COLLATE" }, + { LC_MONETARY, LC_MONETARY_MASK, "LC_MONETARY" }, + { LC_MESSAGES, LC_MESSAGES_MASK, "LC_MESSAGES" } +# ifdef LC_PAPER + , { LC_PAPER, LC_PAPER_MASK, "LC_PAPER" } +# endif +# ifdef LC_NAME + , { LC_NAME, LC_NAME_MASK, "LC_NAME" } +# endif +# ifdef LC_ADDRESS + , { LC_ADDRESS, LC_ADDRESS_MASK, "LC_ADDRESS" } +# endif +# ifdef LC_TELEPHONE + , { LC_TELEPHONE, LC_TELEPHONE_MASK, "LC_TELEPHONE" } +# endif +# ifdef LC_MEASUREMENT + , { LC_MEASUREMENT, LC_MEASUREMENT_MASK, "LC_MEASUREMENT" } +# endif +# ifdef LC_IDENTIFICATION + , { LC_IDENTIFICATION, LC_IDENTIFICATION_MASK, "LC_IDENTIFICATION" } +# endif + }; + +#endif + +/* Test the gl_locale_name() function. */ +static void +test_locale_name (void) +{ + const char *ret; + const char *name; + + /* Check that gl_locale_name returns non-NULL. */ + ASSERT (gl_locale_name (LC_MESSAGES, "LC_MESSAGES") != NULL); + + /* Get into a defined state, */ + setlocale (LC_ALL, "en_US.UTF-8"); +#if HAVE_GOOD_USELOCALE + uselocale (LC_GLOBAL_LOCALE); +#endif + + /* Check that when all environment variables are unset, + gl_locale_name returns the default locale. */ + unsetenv ("LC_ALL"); + unsetenv ("LC_CTYPE"); + unsetenv ("LC_MESSAGES"); + unsetenv ("LC_NUMERIC"); + unsetenv ("LANG"); + /* Need also to unset all environment variables that specify standard or + non-standard locale categories. Otherwise, on glibc systems, when some + of these variables are set and reference a nonexistent locale, the + setlocale (LC_ALL, "") call below would fail. */ + unsetenv ("LC_COLLATE"); + unsetenv ("LC_MONETARY"); + unsetenv ("LC_TIME"); + unsetenv ("LC_ADDRESS"); + unsetenv ("LC_IDENTIFICATION"); + unsetenv ("LC_MEASUREMENT"); + unsetenv ("LC_NAME"); + unsetenv ("LC_PAPER"); + unsetenv ("LC_TELEPHONE"); + ret = setlocale (LC_ALL, ""); + ASSERT (ret != NULL); + ASSERT (strcmp (gl_locale_name (LC_MESSAGES, "LC_MESSAGES"), + gl_locale_name_default ()) == 0); + ASSERT (strcmp (gl_locale_name (LC_NUMERIC, "LC_NUMERIC"), + gl_locale_name_default ()) == 0); + + /* Check that an empty environment variable is treated like an unset + environment variable. */ + + setenv ("LC_ALL", "", 1); + unsetenv ("LC_CTYPE"); + unsetenv ("LC_MESSAGES"); + unsetenv ("LANG"); + setlocale (LC_ALL, ""); + ASSERT (strcmp (gl_locale_name (LC_MESSAGES, "LC_MESSAGES"), + gl_locale_name_default ()) == 0); + + unsetenv ("LC_ALL"); + setenv ("LC_CTYPE", "", 1); + unsetenv ("LC_MESSAGES"); + unsetenv ("LANG"); + setlocale (LC_ALL, ""); + ASSERT (strcmp (gl_locale_name (LC_MESSAGES, "LC_MESSAGES"), + gl_locale_name_default ()) == 0); + + unsetenv ("LC_ALL"); + unsetenv ("LC_CTYPE"); + setenv ("LC_MESSAGES", "", 1); + unsetenv ("LANG"); + setlocale (LC_ALL, ""); + ASSERT (strcmp (gl_locale_name (LC_MESSAGES, "LC_MESSAGES"), + gl_locale_name_default ()) == 0); + + unsetenv ("LC_ALL"); + unsetenv ("LC_CTYPE"); + unsetenv ("LC_MESSAGES"); + setenv ("LANG", "", 1); + setlocale (LC_ALL, ""); + ASSERT (strcmp (gl_locale_name (LC_MESSAGES, "LC_MESSAGES"), + gl_locale_name_default ()) == 0); + + /* Check that LC_ALL overrides the others, and LANG is overridden by the + others. */ + + setenv ("LC_ALL", "C", 1); + unsetenv ("LC_CTYPE"); + unsetenv ("LC_MESSAGES"); + unsetenv ("LANG"); + setlocale (LC_ALL, ""); + ASSERT (strcmp (gl_locale_name (LC_MESSAGES, "LC_MESSAGES"), "C") == 0); + + unsetenv ("LC_ALL"); + setenv ("LC_CTYPE", "C", 1); + setenv ("LC_MESSAGES", "C", 1); + unsetenv ("LANG"); + setlocale (LC_ALL, ""); + ASSERT (strcmp (gl_locale_name (LC_MESSAGES, "LC_MESSAGES"), "C") == 0); + + unsetenv ("LC_ALL"); + unsetenv ("LC_CTYPE"); + unsetenv ("LC_MESSAGES"); + setenv ("LANG", "C", 1); + setlocale (LC_ALL, ""); + ASSERT (strcmp (gl_locale_name (LC_MESSAGES, "LC_MESSAGES"), "C") == 0); + + /* Check mixed situations. */ + + unsetenv ("LC_ALL"); + unsetenv ("LC_CTYPE"); + setenv ("LC_MESSAGES", "fr_FR.UTF-8", 1); + setenv ("LANG", "de_DE.UTF-8", 1); + if (setlocale (LC_ALL, "") != NULL) + { + name = gl_locale_name (LC_CTYPE, "LC_CTYPE"); +#if defined _WIN32 && !defined __CYGWIN__ + /* On native Windows, here, + gl_locale_name_thread (LC_CTYPE, "LC_CTYPE") + returns NULL and + gl_locale_name_posix (LC_CTYPE, "LC_CTYPE") + returns either "de_DE" or "de_DE.UTF-8". */ + ASSERT (strcmp (name, "de_DE") == 0 || strcmp (name, "de_DE.UTF-8") == 0); +#else + ASSERT (strcmp (name, "de_DE.UTF-8") == 0); +#endif + name = gl_locale_name (LC_MESSAGES, "LC_MESSAGES"); + ASSERT (strcmp (name, "fr_FR.UTF-8") == 0); + } + + unsetenv ("LC_ALL"); + unsetenv ("LC_CTYPE"); + setenv ("LC_MESSAGES", "fr_FR.UTF-8", 1); + unsetenv ("LANG"); + if (setlocale (LC_ALL, "") != NULL) + { + name = gl_locale_name (LC_CTYPE, "LC_CTYPE"); + ASSERT (strcmp (name, gl_locale_name_default ()) == 0); + name = gl_locale_name (LC_MESSAGES, "LC_MESSAGES"); + ASSERT (strcmp (name, "fr_FR.UTF-8") == 0); + } + +#if HAVE_GOOD_USELOCALE + /* Check that gl_locale_name considers the thread locale. */ + { + locale_t locale = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL); + if (locale != NULL) + { + uselocale (locale); + name = gl_locale_name (LC_CTYPE, "LC_CTYPE"); + ASSERT (strcmp (name, "fr_FR.UTF-8") == 0); + name = gl_locale_name (LC_MESSAGES, "LC_MESSAGES"); + ASSERT (strcmp (name, "fr_FR.UTF-8") == 0); + uselocale (LC_GLOBAL_LOCALE); + freelocale (locale); + } + } + + /* Check that gl_locale_name distinguishes different categories of the + thread locale, and that the name is the right one for each. */ + { + unsigned int i; + + for (i = 0; i < SIZEOF (categories); i++) + { + int category_mask = categories[i].mask; + locale_t loc = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL); + if (loc != NULL) + { + locale_t locale = newlocale (category_mask, "de_DE.UTF-8", loc); + if (locale == NULL) + freelocale (loc); + else + { + unsigned int j; + + uselocale (locale); + for (j = 0; j < SIZEOF (categories); j++) + { + const char *name_j = + gl_locale_name (categories[j].cat, categories[j].string); + if (j == i) + ASSERT (strcmp (name_j, "de_DE.UTF-8") == 0); + else + ASSERT (strcmp (name_j, "fr_FR.UTF-8") == 0); + } + uselocale (LC_GLOBAL_LOCALE); + freelocale (locale); + } + } + } + } +#endif +} + +/* Test the gl_locale_name_thread() function. */ +static void +test_locale_name_thread (void) +{ + /* Get into a defined state, */ + setlocale (LC_ALL, "en_US.UTF-8"); + +#if HAVE_GOOD_USELOCALE + /* Check that gl_locale_name_thread returns NULL when no thread locale is + set. */ + uselocale (LC_GLOBAL_LOCALE); + ASSERT (gl_locale_name_thread (LC_CTYPE, "LC_CTYPE") == NULL); + ASSERT (gl_locale_name_thread (LC_MESSAGES, "LC_MESSAGES") == NULL); + + /* Check that gl_locale_name_thread considers the thread locale. */ + { + locale_t locale = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL); + if (locale != NULL) + { + const char *name; + + uselocale (locale); + name = gl_locale_name_thread (LC_CTYPE, "LC_CTYPE"); + ASSERT (strcmp (name, "fr_FR.UTF-8") == 0); + name = gl_locale_name_thread (LC_MESSAGES, "LC_MESSAGES"); + ASSERT (strcmp (name, "fr_FR.UTF-8") == 0); + uselocale (LC_GLOBAL_LOCALE); + freelocale (locale); + } + } + + /* Check that gl_locale_name_thread distinguishes different categories of the + thread locale, and that the name is the right one for each. */ + { + unsigned int i; + + for (i = 0; i < SIZEOF (categories); i++) + { + int category_mask = categories[i].mask; + locale_t loc = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL); + if (loc != NULL) + { + locale_t locale = newlocale (category_mask, "de_DE.UTF-8", loc); + if (locale == NULL) + freelocale (loc); + else + { + unsigned int j; + + uselocale (locale); + for (j = 0; j < SIZEOF (categories); j++) + { + const char *name_j = + gl_locale_name_thread (categories[j].cat, + categories[j].string); + if (j == i) + ASSERT (strcmp (name_j, "de_DE.UTF-8") == 0); + else + ASSERT (strcmp (name_j, "fr_FR.UTF-8") == 0); + } + uselocale (LC_GLOBAL_LOCALE); + freelocale (locale); + } + } + } + } + + /* Check that gl_locale_name_thread returns a string that is allocated with + indefinite extent. */ + { + /* Try many locale names in turn, in order to defeat possible caches. */ + static const char * const choices[] = + { + "C", + "POSIX", + "af_ZA", + "af_ZA.UTF-8", + "am_ET", + "am_ET.UTF-8", + "be_BY", + "be_BY.UTF-8", + "bg_BG", + "bg_BG.UTF-8", + "ca_ES", + "ca_ES.UTF-8", + "cs_CZ", + "cs_CZ.UTF-8", + "da_DK", + "da_DK.UTF-8", + "de_AT", + "de_AT.UTF-8", + "de_CH", + "de_CH.UTF-8", + "de_DE", + "de_DE.UTF-8", + "el_GR", + "el_GR.UTF-8", + "en_AU", + "en_AU.UTF-8", + "en_CA", + "en_CA.UTF-8", + "en_GB", + "en_GB.UTF-8", + "en_IE", + "en_IE.UTF-8", + "en_NZ", + "en_NZ.UTF-8", + "en_US", + "en_US.UTF-8", + "es_ES", + "es_ES.UTF-8", + "et_EE", + "et_EE.UTF-8", + "eu_ES", + "eu_ES.UTF-8", + "fi_FI", + "fi_FI.UTF-8", + "fr_BE", + "fr_BE.UTF-8", + "fr_CA", + "fr_CA.UTF-8", + "fr_CH", + "fr_CH.UTF-8", + "fr_FR", + "fr_FR.UTF-8", + "he_IL", + "he_IL.UTF-8", + "hr_HR", + "hr_HR.UTF-8", + "hu_HU", + "hu_HU.UTF-8", + "hy_AM", + "is_IS", + "is_IS.UTF-8", + "it_CH", + "it_CH.UTF-8", + "it_IT", + "it_IT.UTF-8", + "ja_JP.UTF-8", + "kk_KZ", + "kk_KZ.UTF-8", + "ko_KR.UTF-8", + "lt_LT", + "lt_LT.UTF-8", + "nl_BE", + "nl_BE.UTF-8", + "nl_NL", + "nl_NL.UTF-8", + "no_NO", + "no_NO.UTF-8", + "pl_PL", + "pl_PL.UTF-8", + "pt_BR", + "pt_BR.UTF-8", + "pt_PT", + "pt_PT.UTF-8", + "ro_RO", + "ro_RO.UTF-8", + "ru_RU", + "ru_RU.UTF-8", + "sk_SK", + "sk_SK.UTF-8", + "sl_SI", + "sl_SI.UTF-8", + "sv_SE", + "sv_SE.UTF-8", + "tr_TR", + "tr_TR.UTF-8", + "uk_UA", + "uk_UA.UTF-8", + "zh_CN", + "zh_CN.UTF-8", + "zh_HK", + "zh_HK.UTF-8", + "zh_TW", + "zh_TW.UTF-8" + }; + /* Remember which locales are available. */ + unsigned char /* bool */ available[SIZEOF (choices)]; + /* Array of remembered results of gl_locale_name_thread. */ + const char *unsaved_names[SIZEOF (choices)][SIZEOF (categories)]; + /* Array of remembered results of gl_locale_name_thread, stored in safe + memory. */ + char *saved_names[SIZEOF (choices)][SIZEOF (categories)]; + unsigned int j; + + for (j = 0; j < SIZEOF (choices); j++) + { + locale_t locale = newlocale (LC_ALL_MASK, choices[j], NULL); + available[j] = (locale != NULL); + if (locale != NULL) + { + unsigned int i; + + uselocale (locale); + for (i = 0; i < SIZEOF (categories); i++) + { + unsaved_names[j][i] = gl_locale_name_thread (categories[i].cat, categories[i].string); + saved_names[j][i] = strdup (unsaved_names[j][i]); + } + uselocale (LC_GLOBAL_LOCALE); + freelocale (locale); + } + } + /* Verify the unsaved_names are still valid. */ + for (j = 0; j < SIZEOF (choices); j++) + if (available[j]) + { + unsigned int i; + + for (i = 0; i < SIZEOF (categories); i++) + ASSERT (strcmp (unsaved_names[j][i], saved_names[j][i]) == 0); + } + /* Allocate many locales, without freeing them. This is an attempt at + overwriting as much of the previously allocated memory as possible. */ + for (j = SIZEOF (choices); j > 0; ) + { + j--; + if (available[j]) + { + locale_t locale = newlocale (LC_ALL_MASK, choices[j], NULL); + unsigned int i; + + ASSERT (locale != NULL); + uselocale (locale); + for (i = 0; i < SIZEOF (categories); i++) + { + const char *name = gl_locale_name_thread (categories[i].cat, categories[i].string); + ASSERT (strcmp (unsaved_names[j][i], name) == 0); + } + uselocale (LC_GLOBAL_LOCALE); + freelocale (locale); + } + } + /* Verify the unsaved_names are still valid. */ + for (j = 0; j < SIZEOF (choices); j++) + if (available[j]) + { + unsigned int i; + + for (i = 0; i < SIZEOF (categories); i++) + { + ASSERT (strcmp (unsaved_names[j][i], saved_names[j][i]) == 0); + free (saved_names[j][i]); + } + } + } +#else + /* Check that gl_locale_name_thread always returns NULL. */ + ASSERT (gl_locale_name_thread (LC_CTYPE, "LC_CTYPE") == NULL); + ASSERT (gl_locale_name_thread (LC_MESSAGES, "LC_MESSAGES") == NULL); +#endif +} + +/* Test the gl_locale_name_posix() function. */ +static void +test_locale_name_posix (void) +{ + const char *ret; + const char *name; + + /* Get into a defined state, */ + setlocale (LC_ALL, "en_US.UTF-8"); +#if HAVE_GOOD_USELOCALE + uselocale (LC_GLOBAL_LOCALE); +#endif + + /* Check that when all environment variables are unset, + gl_locale_name_posix returns either NULL or the default locale. */ + unsetenv ("LC_ALL"); + unsetenv ("LC_CTYPE"); + unsetenv ("LC_MESSAGES"); + unsetenv ("LC_NUMERIC"); + unsetenv ("LANG"); + /* Need also to unset all environment variables that specify standard or + non-standard locale categories. Otherwise, on glibc systems, when some + of these variables are set and reference a nonexistent locale, the + setlocale (LC_ALL, "") call below would fail. */ + unsetenv ("LC_COLLATE"); + unsetenv ("LC_MONETARY"); + unsetenv ("LC_TIME"); + unsetenv ("LC_ADDRESS"); + unsetenv ("LC_IDENTIFICATION"); + unsetenv ("LC_MEASUREMENT"); + unsetenv ("LC_NAME"); + unsetenv ("LC_PAPER"); + unsetenv ("LC_TELEPHONE"); + ret = setlocale (LC_ALL, ""); + ASSERT (ret != NULL); + name = gl_locale_name_posix (LC_MESSAGES, "LC_MESSAGES"); + ASSERT (name == NULL || strcmp (name, gl_locale_name_default ()) == 0); + name = gl_locale_name_posix (LC_NUMERIC, "LC_NUMERIC"); + ASSERT (name == NULL || strcmp (name, gl_locale_name_default ()) == 0); + + /* Check that an empty environment variable is treated like an unset + environment variable. */ + + setenv ("LC_ALL", "", 1); + unsetenv ("LC_CTYPE"); + unsetenv ("LC_MESSAGES"); + unsetenv ("LANG"); + setlocale (LC_ALL, ""); + name = gl_locale_name_posix (LC_MESSAGES, "LC_MESSAGES"); + ASSERT (name == NULL || strcmp (name, gl_locale_name_default ()) == 0); + + unsetenv ("LC_ALL"); + setenv ("LC_CTYPE", "", 1); + unsetenv ("LC_MESSAGES"); + unsetenv ("LANG"); + setlocale (LC_ALL, ""); + name = gl_locale_name_posix (LC_MESSAGES, "LC_MESSAGES"); + ASSERT (name == NULL || strcmp (name, gl_locale_name_default ()) == 0); + + unsetenv ("LC_ALL"); + unsetenv ("LC_CTYPE"); + setenv ("LC_MESSAGES", "", 1); + unsetenv ("LANG"); + setlocale (LC_ALL, ""); + name = gl_locale_name_posix (LC_MESSAGES, "LC_MESSAGES"); + ASSERT (name == NULL || strcmp (name, gl_locale_name_default ()) == 0); + + unsetenv ("LC_ALL"); + unsetenv ("LC_CTYPE"); + unsetenv ("LC_MESSAGES"); + setenv ("LANG", "", 1); + setlocale (LC_ALL, ""); + name = gl_locale_name_posix (LC_MESSAGES, "LC_MESSAGES"); + ASSERT (name == NULL || strcmp (name, gl_locale_name_default ()) == 0); + + /* Check that LC_ALL overrides the others, and LANG is overridden by the + others. */ + + setenv ("LC_ALL", "C", 1); + unsetenv ("LC_CTYPE"); + unsetenv ("LC_MESSAGES"); + unsetenv ("LANG"); + setlocale (LC_ALL, ""); + name = gl_locale_name_posix (LC_MESSAGES, "LC_MESSAGES"); + ASSERT (strcmp (name, "C") == 0); + + unsetenv ("LC_ALL"); + setenv ("LC_CTYPE", "C", 1); + setenv ("LC_MESSAGES", "C", 1); + unsetenv ("LANG"); + setlocale (LC_ALL, ""); + name = gl_locale_name_posix (LC_MESSAGES, "LC_MESSAGES"); + ASSERT (strcmp (name, "C") == 0); + + unsetenv ("LC_ALL"); + unsetenv ("LC_CTYPE"); + unsetenv ("LC_MESSAGES"); + setenv ("LANG", "C", 1); + setlocale (LC_ALL, ""); + name = gl_locale_name_posix (LC_MESSAGES, "LC_MESSAGES"); + ASSERT (strcmp (name, "C") == 0); + + /* Check mixed situations. */ + + unsetenv ("LC_ALL"); + unsetenv ("LC_CTYPE"); + setenv ("LC_MESSAGES", "fr_FR.UTF-8", 1); + setenv ("LANG", "de_DE.UTF-8", 1); + if (setlocale (LC_ALL, "") != NULL) + { + name = gl_locale_name_posix (LC_CTYPE, "LC_CTYPE"); +#if defined _WIN32 && !defined __CYGWIN__ + ASSERT (strcmp (name, "de_DE") == 0 || strcmp (name, "de_DE.UTF-8") == 0); +#else + ASSERT (strcmp (name, "de_DE.UTF-8") == 0); +#endif + name = gl_locale_name_posix (LC_MESSAGES, "LC_MESSAGES"); + ASSERT (strcmp (name, "fr_FR.UTF-8") == 0); + } + + unsetenv ("LC_ALL"); + unsetenv ("LC_CTYPE"); + setenv ("LC_MESSAGES", "fr_FR.UTF-8", 1); + unsetenv ("LANG"); + if (setlocale (LC_ALL, "") != NULL) + { + name = gl_locale_name_posix (LC_CTYPE, "LC_CTYPE"); + ASSERT (name == NULL || strcmp (name, gl_locale_name_default ()) == 0); + name = gl_locale_name_posix (LC_MESSAGES, "LC_MESSAGES"); + ASSERT (strcmp (name, "fr_FR.UTF-8") == 0); + } + +#if HAVE_GOOD_USELOCALE + /* Check that gl_locale_name_posix ignores the thread locale. */ + { + locale_t locale = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL); + if (locale != NULL) + { + unsetenv ("LC_ALL"); + unsetenv ("LC_CTYPE"); + unsetenv ("LC_MESSAGES"); + setenv ("LANG", "C", 1); + setlocale (LC_ALL, ""); + uselocale (locale); + name = gl_locale_name_posix (LC_MESSAGES, "LC_MESSAGES"); + ASSERT (strcmp (name, "C") == 0); + uselocale (LC_GLOBAL_LOCALE); + freelocale (locale); + } + } +#endif +} + +/* Test the gl_locale_name_environ() function. */ +static void +test_locale_name_environ (void) +{ + const char *name; + + /* Get into a defined state, */ + setlocale (LC_ALL, "en_US.UTF-8"); +#if HAVE_GOOD_USELOCALE + uselocale (LC_GLOBAL_LOCALE); +#endif + + /* Check that when all environment variables are unset, + gl_locale_name_environ returns NULL. */ + unsetenv ("LC_ALL"); + unsetenv ("LC_CTYPE"); + unsetenv ("LC_MESSAGES"); + unsetenv ("LC_NUMERIC"); + unsetenv ("LANG"); + ASSERT (gl_locale_name_environ (LC_MESSAGES, "LC_MESSAGES") == NULL); + ASSERT (gl_locale_name_environ (LC_NUMERIC, "LC_NUMERIC") == NULL); + + /* Check that an empty environment variable is treated like an unset + environment variable. */ + + setenv ("LC_ALL", "", 1); + unsetenv ("LC_CTYPE"); + unsetenv ("LC_MESSAGES"); + unsetenv ("LANG"); + ASSERT (gl_locale_name_environ (LC_MESSAGES, "LC_MESSAGES") == NULL); + + unsetenv ("LC_ALL"); + setenv ("LC_CTYPE", "", 1); + unsetenv ("LC_MESSAGES"); + unsetenv ("LANG"); + ASSERT (gl_locale_name_environ (LC_MESSAGES, "LC_MESSAGES") == NULL); + + unsetenv ("LC_ALL"); + unsetenv ("LC_CTYPE"); + setenv ("LC_MESSAGES", "", 1); + unsetenv ("LANG"); + ASSERT (gl_locale_name_environ (LC_MESSAGES, "LC_MESSAGES") == NULL); + + unsetenv ("LC_ALL"); + unsetenv ("LC_CTYPE"); + unsetenv ("LC_MESSAGES"); + setenv ("LANG", "", 1); + ASSERT (gl_locale_name_environ (LC_MESSAGES, "LC_MESSAGES") == NULL); + + /* Check that LC_ALL overrides the others, and LANG is overridden by the + others. */ + + setenv ("LC_ALL", "C", 1); + unsetenv ("LC_CTYPE"); + unsetenv ("LC_MESSAGES"); + unsetenv ("LANG"); + name = gl_locale_name_environ (LC_MESSAGES, "LC_MESSAGES"); + ASSERT (strcmp (name, "C") == 0); + + unsetenv ("LC_ALL"); + setenv ("LC_CTYPE", "C", 1); + setenv ("LC_MESSAGES", "C", 1); + unsetenv ("LANG"); + name = gl_locale_name_environ (LC_MESSAGES, "LC_MESSAGES"); + ASSERT (strcmp (name, "C") == 0); + + unsetenv ("LC_ALL"); + unsetenv ("LC_CTYPE"); + unsetenv ("LC_MESSAGES"); + setenv ("LANG", "C", 1); + name = gl_locale_name_environ (LC_MESSAGES, "LC_MESSAGES"); + ASSERT (strcmp (name, "C") == 0); + + /* Check mixed situations. */ + + unsetenv ("LC_ALL"); + unsetenv ("LC_CTYPE"); + setenv ("LC_MESSAGES", "fr_FR.UTF-8", 1); + setenv ("LANG", "de_DE.UTF-8", 1); + name = gl_locale_name_environ (LC_CTYPE, "LC_CTYPE"); + ASSERT (strcmp (name, "de_DE.UTF-8") == 0); + name = gl_locale_name_environ (LC_MESSAGES, "LC_MESSAGES"); + ASSERT (strcmp (name, "fr_FR.UTF-8") == 0); + + unsetenv ("LC_ALL"); + unsetenv ("LC_CTYPE"); + setenv ("LC_MESSAGES", "fr_FR.UTF-8", 1); + unsetenv ("LANG"); + name = gl_locale_name_environ (LC_CTYPE, "LC_CTYPE"); + ASSERT (name == NULL); + name = gl_locale_name_environ (LC_MESSAGES, "LC_MESSAGES"); + ASSERT (strcmp (name, "fr_FR.UTF-8") == 0); + +#if HAVE_GOOD_USELOCALE + /* Check that gl_locale_name_environ ignores the thread locale. */ + { + locale_t locale = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL); + if (locale != NULL) + { + unsetenv ("LC_ALL"); + unsetenv ("LC_CTYPE"); + unsetenv ("LC_MESSAGES"); + setenv ("LANG", "C", 1); + setlocale (LC_ALL, ""); + uselocale (locale); + name = gl_locale_name_environ (LC_MESSAGES, "LC_MESSAGES"); + ASSERT (strcmp (name, "C") == 0); + uselocale (LC_GLOBAL_LOCALE); + freelocale (locale); + } + } +#endif +} + +/* Test the gl_locale_name_default() function. */ +static void +test_locale_name_default (void) +{ + const char *name = gl_locale_name_default (); + + ASSERT (name != NULL); + + /* Only Mac OS X and Windows have a facility for the user to set the default + locale. */ +#if !((defined __APPLE__ && defined __MACH__) || (defined _WIN32 || defined __CYGWIN__)) + ASSERT (strcmp (name, "C") == 0); +#endif + +#if HAVE_GOOD_USELOCALE + /* Check that gl_locale_name_default ignores the thread locale. */ + { + locale_t locale = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL); + if (locale != NULL) + { + uselocale (locale); + ASSERT (strcmp (gl_locale_name_default (), name) == 0); + uselocale (LC_GLOBAL_LOCALE); + freelocale (locale); + } + } +#endif +} + +int +main () +{ + test_locale_name (); + test_locale_name_thread (); + test_locale_name_posix (); + test_locale_name_environ (); + test_locale_name_default (); + + return 0; +} diff --git a/gnulib-tests/test-lock.c b/gnulib-tests/test-lock.c new file mode 100644 index 0000000..7325c89 --- /dev/null +++ b/gnulib-tests/test-lock.c @@ -0,0 +1,770 @@ +/* Test of locking in multithreaded situations. + Copyright (C) 2005, 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2005. */ + +#include <config.h> + +#if USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS || USE_WINDOWS_THREADS + +#if USE_ISOC_THREADS +# define TEST_ISOC_THREADS 1 +#endif +#if USE_POSIX_THREADS +# define TEST_POSIX_THREADS 1 +#endif +#if USE_ISOC_AND_POSIX_THREADS +# define TEST_ISOC_AND_POSIX_THREADS 1 +#endif +#if USE_WINDOWS_THREADS +# define TEST_WINDOWS_THREADS 1 +#endif + +/* Whether to enable locking. + Uncomment this to get a test program without locking, to verify that + it crashes. */ +#define ENABLE_LOCKING 1 + +/* Which tests to perform. + Uncomment some of these, to verify that all tests crash if no locking + is enabled. */ +#define DO_TEST_LOCK 1 +#define DO_TEST_RWLOCK 1 +#define DO_TEST_RECURSIVE_LOCK 1 +#define DO_TEST_ONCE 1 + +/* Whether to help the scheduler through explicit yield(). + Uncomment this to see if the operating system has a fair scheduler. */ +#define EXPLICIT_YIELD 1 + +/* Whether to use 'volatile' on some variables that communicate information + between threads. If set to 0, a semaphore or a lock is used to protect + these variables. If set to 1, 'volatile' is used; this is theoretically + equivalent but can lead to much slower execution (e.g. 30x slower total + run time on a 40-core machine), because 'volatile' does not imply any + synchronization/communication between different CPUs. */ +#define USE_VOLATILE 0 + +#if USE_POSIX_THREADS && HAVE_SEMAPHORE_H +/* Whether to use a semaphore to communicate information between threads. + If set to 0, a lock is used. If set to 1, a semaphore is used. + Uncomment this to reduce the dependencies of this test. */ +# define USE_SEMAPHORE 1 +/* Mac OS X provides only named semaphores (sem_open); its facility for + unnamed semaphores (sem_init) does not work. */ +# if defined __APPLE__ && defined __MACH__ +# define USE_NAMED_SEMAPHORE 1 +# else +# define USE_UNNAMED_SEMAPHORE 1 +# endif +#endif + +/* Whether to print debugging messages. */ +#define ENABLE_DEBUGGING 0 + +/* Number of simultaneous threads. */ +#define THREAD_COUNT 10 + +/* Number of operations performed in each thread. + This is quite high, because with a smaller count, say 5000, we often get + an "OK" result even without ENABLE_LOCKING (on Linux/x86). */ +#define REPEAT_COUNT 50000 + +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#if !ENABLE_LOCKING +# undef USE_ISOC_THREADS +# undef USE_POSIX_THREADS +# undef USE_ISOC_AND_POSIX_THREADS +# undef USE_WINDOWS_THREADS +#endif +#include "glthread/lock.h" + +#if !ENABLE_LOCKING +# if TEST_ISOC_THREADS +# define USE_ISOC_THREADS 1 +# endif +# if TEST_POSIX_THREADS +# define USE_POSIX_THREADS 1 +# endif +# if TEST_ISOC_AND_POSIX_THREADS +# define USE_ISOC_AND_POSIX_THREADS 1 +# endif +# if TEST_WINDOWS_THREADS +# define USE_WINDOWS_THREADS 1 +# endif +#endif + +#include "glthread/thread.h" +#include "glthread/yield.h" +#if USE_SEMAPHORE +# include <errno.h> +# include <fcntl.h> +# include <semaphore.h> +# include <unistd.h> +#endif + +#if HAVE_DECL_ALARM +# include <signal.h> +# include <unistd.h> +#endif + +#if ENABLE_DEBUGGING +# define dbgprintf printf +#else +# define dbgprintf if (0) printf +#endif + +#if EXPLICIT_YIELD +# define yield() gl_thread_yield () +#else +# define yield() +#endif + +#if USE_VOLATILE +struct atomic_int { + volatile int value; +}; +static void +init_atomic_int (struct atomic_int *ai) +{ +} +static int +get_atomic_int_value (struct atomic_int *ai) +{ + return ai->value; +} +static void +set_atomic_int_value (struct atomic_int *ai, int new_value) +{ + ai->value = new_value; +} +#elif USE_SEMAPHORE +/* This atomic_int implementation can only support the values 0 and 1. + It is initially 0 and can be set to 1 only once. */ +# if USE_UNNAMED_SEMAPHORE +struct atomic_int { + sem_t semaphore; +}; +#define atomic_int_semaphore(ai) (&(ai)->semaphore) +static void +init_atomic_int (struct atomic_int *ai) +{ + sem_init (&ai->semaphore, 0, 0); +} +# endif +# if USE_NAMED_SEMAPHORE +struct atomic_int { + sem_t *semaphore; +}; +#define atomic_int_semaphore(ai) ((ai)->semaphore) +static void +init_atomic_int (struct atomic_int *ai) +{ + sem_t *s; + unsigned int count; + for (count = 0; ; count++) + { + char name[80]; + /* Use getpid() in the name, so that different processes running at the + same time will not interfere. Use ai in the name, so that different + atomic_int in the same process will not interfere. Use a count in + the name, so that even in the (unlikely) case that a semaphore with + the specified name already exists, we can try a different name. */ + sprintf (name, "test-lock-%lu-%p-%u", + (unsigned long) getpid (), ai, count); + s = sem_open (name, O_CREAT | O_EXCL, 0600, 0); + if (s == SEM_FAILED) + { + if (errno == EEXIST) + /* Retry with a different name. */ + continue; + else + { + perror ("sem_open failed"); + abort (); + } + } + else + { + /* Try not to leave a semaphore hanging around on the file system + eternally, if we can avoid it. */ + sem_unlink (name); + break; + } + } + ai->semaphore = s; +} +# endif +static int +get_atomic_int_value (struct atomic_int *ai) +{ + if (sem_trywait (atomic_int_semaphore (ai)) == 0) + { + if (sem_post (atomic_int_semaphore (ai))) + abort (); + return 1; + } + else if (errno == EAGAIN) + return 0; + else + abort (); +} +static void +set_atomic_int_value (struct atomic_int *ai, int new_value) +{ + if (new_value == 0) + /* It's already initialized with 0. */ + return; + /* To set the value 1: */ + if (sem_post (atomic_int_semaphore (ai))) + abort (); +} +#else +struct atomic_int { + gl_lock_define (, lock) + int value; +}; +static void +init_atomic_int (struct atomic_int *ai) +{ + gl_lock_init (ai->lock); +} +static int +get_atomic_int_value (struct atomic_int *ai) +{ + gl_lock_lock (ai->lock); + int ret = ai->value; + gl_lock_unlock (ai->lock); + return ret; +} +static void +set_atomic_int_value (struct atomic_int *ai, int new_value) +{ + gl_lock_lock (ai->lock); + ai->value = new_value; + gl_lock_unlock (ai->lock); +} +#endif + +#define ACCOUNT_COUNT 4 + +static int account[ACCOUNT_COUNT]; + +static int +random_account (void) +{ + return ((unsigned int) rand () >> 3) % ACCOUNT_COUNT; +} + +static void +check_accounts (void) +{ + int i, sum; + + sum = 0; + for (i = 0; i < ACCOUNT_COUNT; i++) + sum += account[i]; + if (sum != ACCOUNT_COUNT * 1000) + abort (); +} + + +/* ------------------- Test normal (non-recursive) locks ------------------- */ + +/* Test normal locks by having several bank accounts and several threads + which shuffle around money between the accounts and another thread + checking that all the money is still there. */ + +gl_lock_define_initialized(static, my_lock) + +static void * +lock_mutator_thread (void *arg) +{ + int repeat; + + for (repeat = REPEAT_COUNT; repeat > 0; repeat--) + { + int i1, i2, value; + + dbgprintf ("Mutator %p before lock\n", gl_thread_self_pointer ()); + gl_lock_lock (my_lock); + dbgprintf ("Mutator %p after lock\n", gl_thread_self_pointer ()); + + i1 = random_account (); + i2 = random_account (); + value = ((unsigned int) rand () >> 3) % 10; + account[i1] += value; + account[i2] -= value; + + dbgprintf ("Mutator %p before unlock\n", gl_thread_self_pointer ()); + gl_lock_unlock (my_lock); + dbgprintf ("Mutator %p after unlock\n", gl_thread_self_pointer ()); + + dbgprintf ("Mutator %p before check lock\n", gl_thread_self_pointer ()); + gl_lock_lock (my_lock); + check_accounts (); + gl_lock_unlock (my_lock); + dbgprintf ("Mutator %p after check unlock\n", gl_thread_self_pointer ()); + + yield (); + } + + dbgprintf ("Mutator %p dying.\n", gl_thread_self_pointer ()); + return NULL; +} + +static struct atomic_int lock_checker_done; + +static void * +lock_checker_thread (void *arg) +{ + while (get_atomic_int_value (&lock_checker_done) == 0) + { + dbgprintf ("Checker %p before check lock\n", gl_thread_self_pointer ()); + gl_lock_lock (my_lock); + check_accounts (); + gl_lock_unlock (my_lock); + dbgprintf ("Checker %p after check unlock\n", gl_thread_self_pointer ()); + + yield (); + } + + dbgprintf ("Checker %p dying.\n", gl_thread_self_pointer ()); + return NULL; +} + +static void +test_lock (void) +{ + int i; + gl_thread_t checkerthread; + gl_thread_t threads[THREAD_COUNT]; + + /* Initialization. */ + for (i = 0; i < ACCOUNT_COUNT; i++) + account[i] = 1000; + init_atomic_int (&lock_checker_done); + set_atomic_int_value (&lock_checker_done, 0); + + /* Spawn the threads. */ + checkerthread = gl_thread_create (lock_checker_thread, NULL); + for (i = 0; i < THREAD_COUNT; i++) + threads[i] = gl_thread_create (lock_mutator_thread, NULL); + + /* Wait for the threads to terminate. */ + for (i = 0; i < THREAD_COUNT; i++) + gl_thread_join (threads[i], NULL); + set_atomic_int_value (&lock_checker_done, 1); + gl_thread_join (checkerthread, NULL); + check_accounts (); +} + + +/* ----------------- Test read-write (non-recursive) locks ----------------- */ + +/* Test read-write locks by having several bank accounts and several threads + which shuffle around money between the accounts and several other threads + that check that all the money is still there. */ + +gl_rwlock_define_initialized(static, my_rwlock) + +static void * +rwlock_mutator_thread (void *arg) +{ + int repeat; + + for (repeat = REPEAT_COUNT; repeat > 0; repeat--) + { + int i1, i2, value; + + dbgprintf ("Mutator %p before wrlock\n", gl_thread_self_pointer ()); + gl_rwlock_wrlock (my_rwlock); + dbgprintf ("Mutator %p after wrlock\n", gl_thread_self_pointer ()); + + i1 = random_account (); + i2 = random_account (); + value = ((unsigned int) rand () >> 3) % 10; + account[i1] += value; + account[i2] -= value; + + dbgprintf ("Mutator %p before unlock\n", gl_thread_self_pointer ()); + gl_rwlock_unlock (my_rwlock); + dbgprintf ("Mutator %p after unlock\n", gl_thread_self_pointer ()); + + yield (); + } + + dbgprintf ("Mutator %p dying.\n", gl_thread_self_pointer ()); + return NULL; +} + +static struct atomic_int rwlock_checker_done; + +static void * +rwlock_checker_thread (void *arg) +{ + while (get_atomic_int_value (&rwlock_checker_done) == 0) + { + dbgprintf ("Checker %p before check rdlock\n", gl_thread_self_pointer ()); + gl_rwlock_rdlock (my_rwlock); + check_accounts (); + gl_rwlock_unlock (my_rwlock); + dbgprintf ("Checker %p after check unlock\n", gl_thread_self_pointer ()); + + yield (); + } + + dbgprintf ("Checker %p dying.\n", gl_thread_self_pointer ()); + return NULL; +} + +static void +test_rwlock (void) +{ + int i; + gl_thread_t checkerthreads[THREAD_COUNT]; + gl_thread_t threads[THREAD_COUNT]; + + /* Initialization. */ + for (i = 0; i < ACCOUNT_COUNT; i++) + account[i] = 1000; + init_atomic_int (&rwlock_checker_done); + set_atomic_int_value (&rwlock_checker_done, 0); + + /* Spawn the threads. */ + for (i = 0; i < THREAD_COUNT; i++) + checkerthreads[i] = gl_thread_create (rwlock_checker_thread, NULL); + for (i = 0; i < THREAD_COUNT; i++) + threads[i] = gl_thread_create (rwlock_mutator_thread, NULL); + + /* Wait for the threads to terminate. */ + for (i = 0; i < THREAD_COUNT; i++) + gl_thread_join (threads[i], NULL); + set_atomic_int_value (&rwlock_checker_done, 1); + for (i = 0; i < THREAD_COUNT; i++) + gl_thread_join (checkerthreads[i], NULL); + check_accounts (); +} + + +/* -------------------------- Test recursive locks -------------------------- */ + +/* Test recursive locks by having several bank accounts and several threads + which shuffle around money between the accounts (recursively) and another + thread checking that all the money is still there. */ + +gl_recursive_lock_define_initialized(static, my_reclock) + +static void +recshuffle (void) +{ + int i1, i2, value; + + dbgprintf ("Mutator %p before lock\n", gl_thread_self_pointer ()); + gl_recursive_lock_lock (my_reclock); + dbgprintf ("Mutator %p after lock\n", gl_thread_self_pointer ()); + + i1 = random_account (); + i2 = random_account (); + value = ((unsigned int) rand () >> 3) % 10; + account[i1] += value; + account[i2] -= value; + + /* Recursive with probability 0.5. */ + if (((unsigned int) rand () >> 3) % 2) + recshuffle (); + + dbgprintf ("Mutator %p before unlock\n", gl_thread_self_pointer ()); + gl_recursive_lock_unlock (my_reclock); + dbgprintf ("Mutator %p after unlock\n", gl_thread_self_pointer ()); +} + +static void * +reclock_mutator_thread (void *arg) +{ + int repeat; + + for (repeat = REPEAT_COUNT; repeat > 0; repeat--) + { + recshuffle (); + + dbgprintf ("Mutator %p before check lock\n", gl_thread_self_pointer ()); + gl_recursive_lock_lock (my_reclock); + check_accounts (); + gl_recursive_lock_unlock (my_reclock); + dbgprintf ("Mutator %p after check unlock\n", gl_thread_self_pointer ()); + + yield (); + } + + dbgprintf ("Mutator %p dying.\n", gl_thread_self_pointer ()); + return NULL; +} + +static struct atomic_int reclock_checker_done; + +static void * +reclock_checker_thread (void *arg) +{ + while (get_atomic_int_value (&reclock_checker_done) == 0) + { + dbgprintf ("Checker %p before check lock\n", gl_thread_self_pointer ()); + gl_recursive_lock_lock (my_reclock); + check_accounts (); + gl_recursive_lock_unlock (my_reclock); + dbgprintf ("Checker %p after check unlock\n", gl_thread_self_pointer ()); + + yield (); + } + + dbgprintf ("Checker %p dying.\n", gl_thread_self_pointer ()); + return NULL; +} + +static void +test_recursive_lock (void) +{ + int i; + gl_thread_t checkerthread; + gl_thread_t threads[THREAD_COUNT]; + + /* Initialization. */ + for (i = 0; i < ACCOUNT_COUNT; i++) + account[i] = 1000; + init_atomic_int (&reclock_checker_done); + set_atomic_int_value (&reclock_checker_done, 0); + + /* Spawn the threads. */ + checkerthread = gl_thread_create (reclock_checker_thread, NULL); + for (i = 0; i < THREAD_COUNT; i++) + threads[i] = gl_thread_create (reclock_mutator_thread, NULL); + + /* Wait for the threads to terminate. */ + for (i = 0; i < THREAD_COUNT; i++) + gl_thread_join (threads[i], NULL); + set_atomic_int_value (&reclock_checker_done, 1); + gl_thread_join (checkerthread, NULL); + check_accounts (); +} + + +/* ------------------------ Test once-only execution ------------------------ */ + +/* Test once-only execution by having several threads attempt to grab a + once-only task simultaneously (triggered by releasing a read-write lock). */ + +gl_once_define(static, fresh_once) +static int ready[THREAD_COUNT]; +static gl_lock_t ready_lock[THREAD_COUNT]; +#if ENABLE_LOCKING +static gl_rwlock_t fire_signal[REPEAT_COUNT]; +#else +static volatile int fire_signal_state; +#endif +static gl_once_t once_control; +static int performed; +gl_lock_define_initialized(static, performed_lock) + +static void +once_execute (void) +{ + gl_lock_lock (performed_lock); + performed++; + gl_lock_unlock (performed_lock); +} + +static void * +once_contender_thread (void *arg) +{ + int id = (int) (intptr_t) arg; + int repeat; + + for (repeat = 0; repeat <= REPEAT_COUNT; repeat++) + { + /* Tell the main thread that we're ready. */ + gl_lock_lock (ready_lock[id]); + ready[id] = 1; + gl_lock_unlock (ready_lock[id]); + + if (repeat == REPEAT_COUNT) + break; + + dbgprintf ("Contender %p waiting for signal for round %d\n", + gl_thread_self_pointer (), repeat); +#if ENABLE_LOCKING + /* Wait for the signal to go. */ + gl_rwlock_rdlock (fire_signal[repeat]); + /* And don't hinder the others (if the scheduler is unfair). */ + gl_rwlock_unlock (fire_signal[repeat]); +#else + /* Wait for the signal to go. */ + while (fire_signal_state <= repeat) + yield (); +#endif + dbgprintf ("Contender %p got the signal for round %d\n", + gl_thread_self_pointer (), repeat); + + /* Contend for execution. */ + gl_once (once_control, once_execute); + } + + return NULL; +} + +static void +test_once (void) +{ + int i, repeat; + gl_thread_t threads[THREAD_COUNT]; + + /* Initialize all variables. */ + for (i = 0; i < THREAD_COUNT; i++) + { + ready[i] = 0; + gl_lock_init (ready_lock[i]); + } +#if ENABLE_LOCKING + for (i = 0; i < REPEAT_COUNT; i++) + gl_rwlock_init (fire_signal[i]); +#else + fire_signal_state = 0; +#endif + +#if ENABLE_LOCKING + /* Block all fire_signals. */ + for (i = REPEAT_COUNT-1; i >= 0; i--) + gl_rwlock_wrlock (fire_signal[i]); +#endif + + /* Spawn the threads. */ + for (i = 0; i < THREAD_COUNT; i++) + threads[i] = + gl_thread_create (once_contender_thread, (void *) (intptr_t) i); + + for (repeat = 0; repeat <= REPEAT_COUNT; repeat++) + { + /* Wait until every thread is ready. */ + dbgprintf ("Main thread before synchronizing for round %d\n", repeat); + for (;;) + { + int ready_count = 0; + for (i = 0; i < THREAD_COUNT; i++) + { + gl_lock_lock (ready_lock[i]); + ready_count += ready[i]; + gl_lock_unlock (ready_lock[i]); + } + if (ready_count == THREAD_COUNT) + break; + yield (); + } + dbgprintf ("Main thread after synchronizing for round %d\n", repeat); + + if (repeat > 0) + { + /* Check that exactly one thread executed the once_execute() + function. */ + if (performed != 1) + abort (); + } + + if (repeat == REPEAT_COUNT) + break; + + /* Preparation for the next round: Initialize once_control. */ + memcpy (&once_control, &fresh_once, sizeof (gl_once_t)); + + /* Preparation for the next round: Reset the performed counter. */ + performed = 0; + + /* Preparation for the next round: Reset the ready flags. */ + for (i = 0; i < THREAD_COUNT; i++) + { + gl_lock_lock (ready_lock[i]); + ready[i] = 0; + gl_lock_unlock (ready_lock[i]); + } + + /* Signal all threads simultaneously. */ + dbgprintf ("Main thread giving signal for round %d\n", repeat); +#if ENABLE_LOCKING + gl_rwlock_unlock (fire_signal[repeat]); +#else + fire_signal_state = repeat + 1; +#endif + } + + /* Wait for the threads to terminate. */ + for (i = 0; i < THREAD_COUNT; i++) + gl_thread_join (threads[i], NULL); +} + + +/* -------------------------------------------------------------------------- */ + +int +main () +{ +#if HAVE_DECL_ALARM + /* Declare failure if test takes too long, by using default abort + caused by SIGALRM. */ + int alarm_value = 600; + signal (SIGALRM, SIG_DFL); + alarm (alarm_value); +#endif + +#if DO_TEST_LOCK + printf ("Starting test_lock ..."); fflush (stdout); + test_lock (); + printf (" OK\n"); fflush (stdout); +#endif +#if DO_TEST_RWLOCK + printf ("Starting test_rwlock ..."); fflush (stdout); + test_rwlock (); + printf (" OK\n"); fflush (stdout); +#endif +#if DO_TEST_RECURSIVE_LOCK + printf ("Starting test_recursive_lock ..."); fflush (stdout); + test_recursive_lock (); + printf (" OK\n"); fflush (stdout); +#endif +#if DO_TEST_ONCE + printf ("Starting test_once ..."); fflush (stdout); + test_once (); + printf (" OK\n"); fflush (stdout); +#endif + + return 0; +} + +#else + +/* No multithreading available. */ + +#include <stdio.h> + +int +main () +{ + fputs ("Skipping test: multithreading not enabled\n", stderr); + return 77; +} + +#endif diff --git a/gnulib-tests/test-lseek.c b/gnulib-tests/test-lseek.c new file mode 100644 index 0000000..fd9e60e --- /dev/null +++ b/gnulib-tests/test-lseek.c @@ -0,0 +1,109 @@ +/* Test of lseek() function. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake, 2007. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (lseek, off_t, (int, off_t, int)); + +#include <errno.h> + +#include "macros.h" + +/* ARGC must be 2; *ARGV[1] is '0' if stdin and stdout are files, '1' + if they are pipes, and '2' if they are closed. Check for proper + semantics of lseek. */ +int +main (int argc, char **argv) +{ + if (argc != 2) + return 2; + switch (*argv[1]) + { + case '0': /* regular files */ + ASSERT (lseek (0, (off_t)2, SEEK_SET) == 2); + ASSERT (lseek (0, (off_t)-4, SEEK_CUR) == -1); + ASSERT (errno == EINVAL); + errno = 0; +#if ! defined __BEOS__ + /* POSIX says that the last lseek call, when failing, does not change + the current offset. But BeOS sets it to 0. */ + ASSERT (lseek (0, (off_t)0, SEEK_CUR) == 2); +#endif +#if 0 /* leads to SIGSYS on IRIX 6.5 */ + ASSERT (lseek (0, (off_t)0, (SEEK_SET | SEEK_CUR | SEEK_END) + 1) == -1); + ASSERT (errno == EINVAL); +#endif + ASSERT (lseek (1, (off_t)2, SEEK_SET) == 2); + errno = 0; + ASSERT (lseek (1, (off_t)-4, SEEK_CUR) == -1); + ASSERT (errno == EINVAL); + errno = 0; +#if ! defined __BEOS__ + /* POSIX says that the last lseek call, when failing, does not change + the current offset. But BeOS sets it to 0. */ + ASSERT (lseek (1, (off_t)0, SEEK_CUR) == 2); +#endif +#if 0 /* leads to SIGSYS on IRIX 6.5 */ + ASSERT (lseek (1, (off_t)0, (SEEK_SET | SEEK_CUR | SEEK_END) + 1) == -1); + ASSERT (errno == EINVAL); +#endif + break; + + case '1': /* pipes */ + errno = 0; + ASSERT (lseek (0, (off_t)0, SEEK_CUR) == -1); + ASSERT (errno == ESPIPE); + errno = 0; + ASSERT (lseek (1, (off_t)0, SEEK_CUR) == -1); + ASSERT (errno == ESPIPE); + break; + + case '2': /* closed */ + /* Explicitly close file descriptors 0 and 1. The <&- and >&- in the + invoking shell are not enough on HP-UX. */ + close (0); + close (1); + + errno = 0; + ASSERT (lseek (0, (off_t)0, SEEK_CUR) == -1); + ASSERT (errno == EBADF); + + errno = 0; + ASSERT (lseek (1, (off_t)0, SEEK_CUR) == -1); + ASSERT (errno == EBADF); + + /* Test behaviour for invalid file descriptors. */ + errno = 0; + ASSERT (lseek (-1, (off_t)0, SEEK_CUR) == -1); + ASSERT (errno == EBADF); + + close (99); + errno = 0; + ASSERT (lseek (99, (off_t)0, SEEK_CUR) == -1); + ASSERT (errno == EBADF); + + break; + + default: + return 1; + } + return 0; +} diff --git a/gnulib-tests/test-lseek.sh b/gnulib-tests/test-lseek.sh new file mode 100755 index 0000000..ff206c6 --- /dev/null +++ b/gnulib-tests/test-lseek.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +tmpfiles= +trap 'rm -fr $tmpfiles' 1 2 3 15 + +tmpfiles=t-lseek.tmp +# seekable files +${CHECKER} ./test-lseek${EXEEXT} 0 < "$srcdir/test-lseek.sh" > t-lseek.tmp || exit 1 + +# pipes +echo hi | { ${CHECKER} ./test-lseek${EXEEXT} 1; echo $? > t-lseek.tmp; cat > /dev/null; } | cat +test "`cat t-lseek.tmp`" = "0" || exit 1 + +# closed descriptors +${CHECKER} ./test-lseek${EXEEXT} 2 <&- >&- || exit 1 + +rm -rf $tmpfiles +exit 0 diff --git a/gnulib-tests/test-lstat.c b/gnulib-tests/test-lstat.c new file mode 100644 index 0000000..a7b928a --- /dev/null +++ b/gnulib-tests/test-lstat.c @@ -0,0 +1,60 @@ +/* Test of lstat() function. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Simon Josefsson, 2008; and Eric Blake, 2009. */ + +#include <config.h> + +#include <sys/stat.h> + +/* Caution: lstat may be a function-like macro. Although this + signature check must pass, it may be the signature of the real (and + broken) lstat rather than rpl_lstat. Most code should not use the + address of lstat. */ +#include "signature.h" +SIGNATURE_CHECK (lstat, int, (char const *, struct stat *)); + +#include <fcntl.h> +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "same-inode.h" +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-lstat.t" + +#include "test-lstat.h" + +/* Wrapper around lstat, which works even if lstat is a function-like + macro, where test_lstat_func(lstat) would do the wrong thing. */ +static int +do_lstat (char const *name, struct stat *st) +{ + return lstat (name, st); +} + +int +main (void) +{ + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + return test_lstat_func (do_lstat, true); +} diff --git a/gnulib-tests/test-lstat.h b/gnulib-tests/test-lstat.h new file mode 100644 index 0000000..f9ad11d --- /dev/null +++ b/gnulib-tests/test-lstat.h @@ -0,0 +1,122 @@ +/* Test of lstat() function. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Simon Josefsson, 2008; and Eric Blake, 2009. */ + +/* This file is designed to test both lstat(n,buf) and + fstatat(AT_FDCWD,n,buf,AT_SYMLINK_NOFOLLOW). FUNC is the function + to test. Assumes that BASE and ASSERT are already defined, and + that appropriate headers are already included. If PRINT, warn + before skipping symlink tests with status 77. */ + +static int +test_lstat_func (int (*func) (char const *, struct stat *), bool print) +{ + struct stat st1; + struct stat st2; + + /* Test for common directories. */ + ASSERT (func (".", &st1) == 0); + ASSERT (func ("./", &st2) == 0); +#if !(defined _WIN32 && !defined __CYGWIN__ && !_GL_WINDOWS_STAT_INODES) + ASSERT (SAME_INODE (st1, st2)); +#endif + ASSERT (S_ISDIR (st1.st_mode)); + ASSERT (S_ISDIR (st2.st_mode)); + ASSERT (func ("/", &st1) == 0); + ASSERT (func ("///", &st2) == 0); +#if !(defined _WIN32 && !defined __CYGWIN__ && !_GL_WINDOWS_STAT_INODES) + ASSERT (SAME_INODE (st1, st2)); +#endif + ASSERT (S_ISDIR (st1.st_mode)); + ASSERT (S_ISDIR (st2.st_mode)); + ASSERT (func ("..", &st1) == 0); + ASSERT (S_ISDIR (st1.st_mode)); + + /* Test for error conditions. */ + errno = 0; + ASSERT (func ("", &st1) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func ("nosuch", &st1) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func ("nosuch/", &st1) == -1); + ASSERT (errno == ENOENT); + + ASSERT (close (creat (BASE "file", 0600)) == 0); + ASSERT (func (BASE "file", &st1) == 0); + ASSERT (S_ISREG (st1.st_mode)); + errno = 0; + ASSERT (func (BASE "file/", &st1) == -1); + ASSERT (errno == ENOTDIR); + + /* Now for some symlink tests, where supported. We set up: + link1 -> directory + link2 -> file + link3 -> dangling + link4 -> loop + then test behavior both with and without trailing slash. + */ + if (symlink (".", BASE "link1") != 0) + { + ASSERT (unlink (BASE "file") == 0); + if (print) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + ASSERT (symlink (BASE "file", BASE "link2") == 0); + ASSERT (symlink (BASE "nosuch", BASE "link3") == 0); + ASSERT (symlink (BASE "link4", BASE "link4") == 0); + + ASSERT (func (BASE "link1", &st1) == 0); + ASSERT (S_ISLNK (st1.st_mode)); + ASSERT (func (BASE "link1/", &st1) == 0); + ASSERT (stat (BASE "link1", &st2) == 0); + ASSERT (S_ISDIR (st1.st_mode)); + ASSERT (S_ISDIR (st2.st_mode)); +#if !(defined _WIN32 && !defined __CYGWIN__ && !_GL_WINDOWS_STAT_INODES) + ASSERT (SAME_INODE (st1, st2)); +#endif + + ASSERT (func (BASE "link2", &st1) == 0); + ASSERT (S_ISLNK (st1.st_mode)); + errno = 0; + ASSERT (func (BASE "link2/", &st1) == -1); + ASSERT (errno == ENOTDIR); + + ASSERT (func (BASE "link3", &st1) == 0); + ASSERT (S_ISLNK (st1.st_mode)); + errno = 0; + ASSERT (func (BASE "link3/", &st1) == -1); + ASSERT (errno == ENOENT); + + ASSERT (func (BASE "link4", &st1) == 0); + ASSERT (S_ISLNK (st1.st_mode)); + errno = 0; + ASSERT (func (BASE "link4/", &st1) == -1); + ASSERT (errno == ELOOP); + + /* Cleanup. */ + ASSERT (unlink (BASE "file") == 0); + ASSERT (unlink (BASE "link1") == 0); + ASSERT (unlink (BASE "link2") == 0); + ASSERT (unlink (BASE "link3") == 0); + ASSERT (unlink (BASE "link4") == 0); + + return 0; +} diff --git a/gnulib-tests/test-lutimens.h b/gnulib-tests/test-lutimens.h new file mode 100644 index 0000000..90aa514 --- /dev/null +++ b/gnulib-tests/test-lutimens.h @@ -0,0 +1,230 @@ +/* Test of file timestamp modification functions. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +#include "test-utimens-common.h" + +/* This file is designed to test both lutimens(a,b) and + utimensat(AT_FDCWD,a,b,AT_SYMLINK_NOFOLLOW). FUNC is the function + to test. Assumes that BASE and ASSERT are already defined. If + PRINT, warn before skipping tests with status 77. */ +static int +test_lutimens (int (*func) (char const *, struct timespec const *), bool print) +{ + int result; + int saved_errno; + struct stat st1; + struct stat st2; + bool atime_supported = true; + + /* Non-symlinks should be handled just like utimens. */ + errno = 0; + ASSERT (func ("no_such", NULL) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func ("no_such/", NULL) == -1); + ASSERT (errno == ENOENT || errno == ENOTDIR); + errno = 0; + ASSERT (func ("", NULL) == -1); + ASSERT (errno == ENOENT); + ASSERT (close (creat (BASE "file", 0600)) == 0); + ASSERT (stat (BASE "file", &st1) == 0); + ASSERT (st1.st_atime != Y2K); + ASSERT (st1.st_mtime != Y2K); + { + struct timespec ts[2]; + ts[0].tv_sec = Y2K; + ts[0].tv_nsec = 0; + ts[1] = ts[0]; + errno = 0; + ASSERT (func (BASE "file/", ts) == -1); + ASSERT (errno == ENOTDIR); + ASSERT (stat (BASE "file", &st2) == 0); + ASSERT (st1.st_atime == st2.st_atime); + ASSERT (st1.st_mtime == st2.st_mtime); + } + { + struct timespec ts[2]; + ts[0].tv_sec = Y2K; + ts[0].tv_nsec = 0; + ts[1] = ts[0]; + nap (); + ASSERT (func (BASE "file", ts) == 0); + } + ASSERT (stat (BASE "file", &st2) == 0); + ASSERT (st2.st_atime == Y2K); + ASSERT (st2.st_mtime == Y2K); + if (check_ctime) + ASSERT (ctime_compare (&st1, &st2) < 0); + + /* Play with symlink timestamps. */ + if (symlink (BASE "file", BASE "link")) + { + ASSERT (unlink (BASE "file") == 0); + if (print) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + errno = 0; + result = func (BASE "link", NULL); + saved_errno = errno; + /* Make sure we did not reference through link by accident. */ + ASSERT (stat (BASE "file", &st1) == 0); + ASSERT (st1.st_atime == Y2K); + ASSERT (st1.st_mtime == Y2K); + ASSERT (lstat (BASE "link", &st1) == 0); + ASSERT (st1.st_atime != Y2K); + ASSERT (st1.st_mtime != Y2K); + ASSERT (unlink (BASE "file") == 0); + if (result == -1 && saved_errno == ENOSYS) + { + ASSERT (unlink (BASE "link") == 0); + if (print) + fputs ("skipping test: " + "setting symlink time not supported on this file system\n", + stderr); + return 77; + } + ASSERT (!result); + ASSERT (lstat (BASE "link", &st1) == 0); + /* On cygwin, lstat() changes atime of symlinks, so that lutimens + can only effectively modify mtime. */ + nap (); + ASSERT (lstat (BASE "link", &st2) == 0); + if (st1.st_atime != st2.st_atime + || get_stat_atime_ns (&st1) != get_stat_atime_ns (&st2)) + atime_supported = false; + ASSERT (st1.st_ctime == st2.st_ctime); + ASSERT (get_stat_ctime_ns (&st1) == get_stat_ctime_ns (&st2)); + + /* Invalid arguments. */ + { + struct timespec ts[2]; + ts[0].tv_sec = Y2K; + ts[0].tv_nsec = UTIME_BOGUS_POS; + ts[1].tv_sec = Y2K; + ts[1].tv_nsec = 0; + errno = 0; + ASSERT (func (BASE "link", ts) == -1); + ASSERT (errno == EINVAL); + } + { + struct timespec ts[2]; + ts[0].tv_sec = Y2K; + ts[0].tv_nsec = 0; + ts[1].tv_sec = Y2K; + ts[1].tv_nsec = UTIME_BOGUS_NEG; + errno = 0; + ASSERT (func (BASE "link", ts) == -1); + ASSERT (errno == EINVAL); + } + ASSERT (lstat (BASE "link", &st2) == 0); + if (atime_supported) + { + ASSERT (st1.st_atime == st2.st_atime); + ASSERT (get_stat_atime_ns (&st1) == get_stat_atime_ns (&st2)); + } + ASSERT (utimecmp (BASE "link", &st1, &st2, 0) == 0); + + /* Set both times. */ + { + struct timespec ts[2]; + ts[0].tv_sec = Y2K; + ts[0].tv_nsec = BILLION / 2 - 1; + ts[1].tv_sec = Y2K; + ts[1].tv_nsec = BILLION - 1; + nap (); + ASSERT (func (BASE "link", ts) == 0); + ASSERT (lstat (BASE "link", &st2) == 0); + if (atime_supported) + { + ASSERT (st2.st_atime == Y2K); + ASSERT (0 <= get_stat_atime_ns (&st2)); + ASSERT (get_stat_atime_ns (&st2) < BILLION / 2); + } + ASSERT (st2.st_mtime == Y2K); + ASSERT (0 <= get_stat_mtime_ns (&st2)); + ASSERT (get_stat_mtime_ns (&st2) < BILLION); + if (check_ctime) + ASSERT (ctime_compare (&st1, &st2) < 0); + } + + /* Play with UTIME_OMIT, UTIME_NOW. */ + { + struct stat st3; + struct timespec ts[2]; + ts[0].tv_sec = BILLION; + ts[0].tv_nsec = UTIME_OMIT; + ts[1].tv_sec = 0; + ts[1].tv_nsec = UTIME_NOW; + nap (); + ASSERT (func (BASE "link", ts) == 0); + ASSERT (lstat (BASE "link", &st3) == 0); + if (atime_supported) + { + ASSERT (st3.st_atime == Y2K); + ASSERT (0 <= get_stat_atime_ns (&st3)); + ASSERT (get_stat_atime_ns (&st3) < BILLION / 2); + } + ASSERT (utimecmp (BASE "link", &st1, &st3, 0) <= 0); + if (check_ctime) + ASSERT (ctime_compare (&st2, &st3) < 0); + nap (); + ts[0].tv_nsec = 0; + ts[1].tv_nsec = UTIME_OMIT; + ASSERT (func (BASE "link", ts) == 0); + ASSERT (lstat (BASE "link", &st2) == 0); + if (atime_supported) + { + ASSERT (st2.st_atime == BILLION); + ASSERT (get_stat_atime_ns (&st2) == 0); + } + ASSERT (st3.st_mtime == st2.st_mtime); + ASSERT (get_stat_mtime_ns (&st3) == get_stat_mtime_ns (&st2)); + if (check_ctime) + ASSERT (ctime_compare (&st3, &st2) < 0); + } + + /* Symlink to directory. */ + ASSERT (unlink (BASE "link") == 0); + ASSERT (symlink (BASE "dir", BASE "link") == 0); + ASSERT (mkdir (BASE "dir", 0700) == 0); + { + struct timespec ts[2]; + ts[0].tv_sec = Y2K; + ts[0].tv_nsec = 0; + ts[1] = ts[0]; + ASSERT (func (BASE "link/", ts) == 0); + } + /* On cygwin 1.5, stat() changes atime of directories, so only check + mtime. */ + ASSERT (stat (BASE "dir", &st1) == 0); + ASSERT (st1.st_mtime == Y2K); + ASSERT (lstat (BASE "link", &st1) == 0); + ASSERT (st1.st_atime != Y2K); + ASSERT (st1.st_mtime != Y2K); + ASSERT (func (BASE "link", NULL) == 0); + ASSERT (stat (BASE "dir", &st1) == 0); + ASSERT (st1.st_mtime == Y2K); + ASSERT (lstat (BASE "link", &st1) == 0); + ASSERT (st1.st_atime != Y2K); + ASSERT (st1.st_mtime != Y2K); + + /* Cleanup. */ + ASSERT (rmdir (BASE "dir") == 0); + ASSERT (unlink (BASE "link") == 0); + return 0; +} diff --git a/gnulib-tests/test-malloc-gnu.c b/gnulib-tests/test-malloc-gnu.c new file mode 100644 index 0000000..a03e42c --- /dev/null +++ b/gnulib-tests/test-malloc-gnu.c @@ -0,0 +1,31 @@ +/* Test of malloc function. + Copyright (C) 2010-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdlib.h> + +int +main () +{ + /* Check that malloc (0) is not a NULL pointer. */ + char *p = malloc (0); + if (p == NULL) + return 1; + + free (p); + return 0; +} diff --git a/gnulib-tests/test-malloca.c b/gnulib-tests/test-malloca.c new file mode 100644 index 0000000..a546add --- /dev/null +++ b/gnulib-tests/test-malloca.c @@ -0,0 +1,62 @@ +/* Test of safe automatic memory allocation. + Copyright (C) 2005, 2007, 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2005. */ + +#include <config.h> + +#include "malloca.h" + +#include <stdlib.h> + +static void +do_allocation (int n) +{ + void *ptr = malloca (n); + freea (ptr); + safe_alloca (n); +} + +void (*func) (int) = do_allocation; + +int +main () +{ + int i; + + /* This slows down malloc a lot. */ + unsetenv ("MALLOC_PERTURB_"); + + /* Repeat a lot of times, to make sure there's no memory leak. */ + for (i = 0; i < 50000; i++) + { + /* Try various values. + n = 0 gave a crash on Alpha with gcc-2.5.8. + Some versions of Mac OS X have a stack size limit of 512 KB. */ + func (34); + func (134); + func (399); + func (510823); + func (129321); + func (0); + func (4070); + func (4095); + func (1); + func (16582); + } + + return 0; +} diff --git a/gnulib-tests/test-math.c b/gnulib-tests/test-math.c new file mode 100644 index 0000000..656b04d --- /dev/null +++ b/gnulib-tests/test-math.c @@ -0,0 +1,104 @@ +/* Test of <math.h> substitute. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <math.h> + +#ifndef NAN +# error NAN should be defined +choke me +#endif + +#ifndef HUGE_VALF +# error HUGE_VALF should be defined +choke me +#endif + +#ifndef HUGE_VAL +# error HUGE_VAL should be defined +choke me +#endif + +#ifndef HUGE_VALL +# error HUGE_VALL should be defined +choke me +#endif + +#ifndef FP_ILOGB0 +# error FP_ILOGB0 should be defined +choke me +#endif + +#ifndef FP_ILOGBNAN +# error FP_ILOGBNAN should be defined +choke me +#endif + +#include <limits.h> + +#include "macros.h" + +#if 0 +/* Check that NAN expands into a constant expression. */ +static float n = NAN; +#endif + +/* Compare two numbers with ==. + This is a separate function because IRIX 6.5 "cc -O" miscompiles an + 'x == x' test. */ +static int +numeric_equalf (float x, float y) +{ + return x == y; +} +static int +numeric_equald (double x, double y) +{ + return x == y; +} +static int +numeric_equall (long double x, long double y) +{ + return x == y; +} + +int +main (void) +{ + double d = NAN; + double zero = 0.0; + ASSERT (!numeric_equald (d, d)); + + d = HUGE_VAL; + ASSERT (numeric_equald (d, 1.0 / zero)); + + ASSERT (numeric_equalf (HUGE_VALF, HUGE_VALF + HUGE_VALF)); + + ASSERT (numeric_equald (HUGE_VAL, HUGE_VAL + HUGE_VAL)); + + ASSERT (numeric_equall (HUGE_VALL, HUGE_VALL + HUGE_VALL)); + + /* Check the value of FP_ILOGB0. */ + ASSERT (FP_ILOGB0 == INT_MIN || FP_ILOGB0 == - INT_MAX); + + /* Check the value of FP_ILOGBNAN. */ + ASSERT (FP_ILOGBNAN == INT_MIN || FP_ILOGBNAN == INT_MAX); + + return 0; +} diff --git a/gnulib-tests/test-mbrtowc-w32-1.sh b/gnulib-tests/test-mbrtowc-w32-1.sh new file mode 100755 index 0000000..fec9ead --- /dev/null +++ b/gnulib-tests/test-mbrtowc-w32-1.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP1252 locale. +${CHECKER} ./test-mbrtowc-w32${EXEEXT} French_France 1252 diff --git a/gnulib-tests/test-mbrtowc-w32-2.sh b/gnulib-tests/test-mbrtowc-w32-2.sh new file mode 100755 index 0000000..c55a0ec --- /dev/null +++ b/gnulib-tests/test-mbrtowc-w32-2.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP1256 locale. +${CHECKER} ./test-mbrtowc-w32${EXEEXT} "Arabic_Saudi Arabia" 1256 diff --git a/gnulib-tests/test-mbrtowc-w32-3.sh b/gnulib-tests/test-mbrtowc-w32-3.sh new file mode 100755 index 0000000..c49f4bd --- /dev/null +++ b/gnulib-tests/test-mbrtowc-w32-3.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP932 locale. +${CHECKER} ./test-mbrtowc-w32${EXEEXT} Japanese_Japan 932 diff --git a/gnulib-tests/test-mbrtowc-w32-4.sh b/gnulib-tests/test-mbrtowc-w32-4.sh new file mode 100755 index 0000000..3e78615 --- /dev/null +++ b/gnulib-tests/test-mbrtowc-w32-4.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP950 locale. +${CHECKER} ./test-mbrtowc-w32${EXEEXT} Chinese_Taiwan 950 diff --git a/gnulib-tests/test-mbrtowc-w32-5.sh b/gnulib-tests/test-mbrtowc-w32-5.sh new file mode 100755 index 0000000..c6ba222 --- /dev/null +++ b/gnulib-tests/test-mbrtowc-w32-5.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP936 locale. +${CHECKER} ./test-mbrtowc-w32${EXEEXT} Chinese_China 936 diff --git a/gnulib-tests/test-mbrtowc-w32-6.sh b/gnulib-tests/test-mbrtowc-w32-6.sh new file mode 100755 index 0000000..c2e8dfe --- /dev/null +++ b/gnulib-tests/test-mbrtowc-w32-6.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a GB18030 locale. +${CHECKER} ./test-mbrtowc-w32${EXEEXT} Chinese_China 54936 diff --git a/gnulib-tests/test-mbrtowc-w32-7.sh b/gnulib-tests/test-mbrtowc-w32-7.sh new file mode 100755 index 0000000..2c5d555 --- /dev/null +++ b/gnulib-tests/test-mbrtowc-w32-7.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test some UTF-8 locales. +${CHECKER} ./test-mbrtowc-w32${EXEEXT} French_France Japanese_Japan Chinese_Taiwan Chinese_China 65001 diff --git a/gnulib-tests/test-mbrtowc-w32.c b/gnulib-tests/test-mbrtowc-w32.c new file mode 100644 index 0000000..17908ed --- /dev/null +++ b/gnulib-tests/test-mbrtowc-w32.c @@ -0,0 +1,734 @@ +/* Test of conversion of multibyte character to wide character. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <wchar.h> + +#include <errno.h> +#include <locale.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "localcharset.h" +#include "macros.h" + +#if defined _WIN32 && !defined __CYGWIN__ + +static int +test_one_locale (const char *name, int codepage) +{ + mbstate_t state; + wchar_t wc; + size_t ret; + +# if 1 + /* Portable code to set the locale. */ + { + char name_with_codepage[1024]; + + sprintf (name_with_codepage, "%s.%d", name, codepage); + + /* Set the locale. */ + if (setlocale (LC_ALL, name_with_codepage) == NULL) + return 77; + } +# else + /* Hacky way to set a locale.codepage combination that setlocale() refuses + to set. */ + { + /* Codepage of the current locale, set with setlocale(). + Not necessarily the same as GetACP(). */ + extern __declspec(dllimport) unsigned int __lc_codepage; + + /* Set the locale. */ + if (setlocale (LC_ALL, name) == NULL) + return 77; + + /* Clobber the codepage and MB_CUR_MAX, both set by setlocale(). */ + __lc_codepage = codepage; + switch (codepage) + { + case 1252: + case 1256: + MB_CUR_MAX = 1; + break; + case 932: + case 950: + case 936: + MB_CUR_MAX = 2; + break; + case 54936: + case 65001: + MB_CUR_MAX = 4; + break; + } + + /* Test whether the codepage is really available. */ + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, " ", 1, &state) == (size_t)(-1)) + return 77; + } +# endif + + /* Test zero-length input. */ + { + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "x", 0, &state); + /* gnulib's implementation returns (size_t)(-2). + The AIX 5.1 implementation returns (size_t)(-1). + glibc's implementation returns 0. */ + ASSERT (ret == (size_t)(-2) || ret == (size_t)(-1) || ret == 0); + ASSERT (mbsinit (&state)); + } + + /* Test NUL byte input. */ + { + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "", 1, &state); + ASSERT (ret == 0); + ASSERT (wc == 0); + ASSERT (mbsinit (&state)); + ret = mbrtowc (NULL, "", 1, &state); + ASSERT (ret == 0); + ASSERT (mbsinit (&state)); + } + + /* Test single-byte input. */ + { + int c; + char buf[1]; + + memset (&state, '\0', sizeof (mbstate_t)); + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + buf[0] = c; + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, buf, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == c); + ASSERT (mbsinit (&state)); + ret = mbrtowc (NULL, buf, 1, &state); + ASSERT (ret == 1); + ASSERT (mbsinit (&state)); + break; + } + } + + /* Test special calling convention, passing a NULL pointer. */ + { + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, NULL, 5, &state); + ASSERT (ret == 0); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (mbsinit (&state)); + } + + switch (codepage) + { + case 1252: + /* Locale encoding is CP1252, an extension of ISO-8859-1. */ + { + char input[] = "B\374\337er"; /* "Büßer" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'B'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 1, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == (unsigned char) '\374'); + ASSERT (wc == 0x00FC); + ASSERT (mbsinit (&state)); + input[1] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 2, 3, &state); + ASSERT (ret == 1); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 2, 3, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == (unsigned char) '\337'); + ASSERT (wc == 0x00DF); + ASSERT (mbsinit (&state)); + input[2] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 3, 2, &state); + ASSERT (ret == 1); + ASSERT (wc == 'e'); + ASSERT (mbsinit (&state)); + input[3] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 4, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'r'); + ASSERT (mbsinit (&state)); + } + return 0; + + case 1256: + /* Locale encoding is CP1256, not the same as ISO-8859-6. */ + { + char input[] = "x\302\341\346y"; /* "xآلوy" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'x'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 1, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == (unsigned char) '\302'); + ASSERT (wc == 0x0622); + ASSERT (mbsinit (&state)); + input[1] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 2, 3, &state); + ASSERT (ret == 1); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 2, 3, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == (unsigned char) '\341'); + ASSERT (wc == 0x0644); + ASSERT (mbsinit (&state)); + input[2] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 3, 2, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == (unsigned char) '\346'); + ASSERT (wc == 0x0648); + ASSERT (mbsinit (&state)); + input[3] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 4, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'y'); + ASSERT (mbsinit (&state)); + } + return 0; + + case 932: + /* Locale encoding is CP932, similar to Shift_JIS. */ + { + char input[] = "<\223\372\226\173\214\352>"; /* "<日本語>" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '<'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 2, &state); + ASSERT (ret == 2); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x65E5); + ASSERT (mbsinit (&state)); + input[1] = '\0'; + input[2] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 3, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[3] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 4, 4, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x672C); + ASSERT (mbsinit (&state)); + input[4] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 5, 3, &state); + ASSERT (ret == 2); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 5, 3, &state); + ASSERT (ret == 2); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x8A9E); + ASSERT (mbsinit (&state)); + input[5] = '\0'; + input[6] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 7, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '>'); + ASSERT (mbsinit (&state)); + + /* Test some invalid input. */ + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\377", 1, &state); /* 0xFF */ + ASSERT ((ret == (size_t)-1 && errno == EILSEQ) || ret == (size_t)-2); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\225\377", 2, &state); /* 0x95 0xFF */ + ASSERT ((ret == (size_t)-1 && errno == EILSEQ) || (ret == 2 && wc == 0x30FB)); + } + return 0; + + case 950: + /* Locale encoding is CP950, similar to Big5. */ + { + char input[] = "<\244\351\245\273\273\171>"; /* "<日本語>" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '<'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 2, &state); + ASSERT (ret == 2); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x65E5); + ASSERT (mbsinit (&state)); + input[1] = '\0'; + input[2] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 3, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[3] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 4, 4, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x672C); + ASSERT (mbsinit (&state)); + input[4] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 5, 3, &state); + ASSERT (ret == 2); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 5, 3, &state); + ASSERT (ret == 2); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x8A9E); + ASSERT (mbsinit (&state)); + input[5] = '\0'; + input[6] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 7, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '>'); + ASSERT (mbsinit (&state)); + + /* Test some invalid input. */ + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\377", 1, &state); /* 0xFF */ + ASSERT ((ret == (size_t)-1 && errno == EILSEQ) || ret == (size_t)-2); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\225\377", 2, &state); /* 0x95 0xFF */ + ASSERT ((ret == (size_t)-1 && errno == EILSEQ) || (ret == 2 && wc == '?')); + } + return 0; + + case 936: + /* Locale encoding is CP936 = GBK, an extension of GB2312. */ + { + char input[] = "<\310\325\261\276\325\132>"; /* "<日本語>" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '<'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 2, &state); + ASSERT (ret == 2); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x65E5); + ASSERT (mbsinit (&state)); + input[1] = '\0'; + input[2] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 3, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[3] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 4, 4, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x672C); + ASSERT (mbsinit (&state)); + input[4] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 5, 3, &state); + ASSERT (ret == 2); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 5, 3, &state); + ASSERT (ret == 2); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x8A9E); + ASSERT (mbsinit (&state)); + input[5] = '\0'; + input[6] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 7, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '>'); + ASSERT (mbsinit (&state)); + + /* Test some invalid input. */ + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\377", 1, &state); /* 0xFF */ + ASSERT ((ret == (size_t)-1 && errno == EILSEQ) || ret == (size_t)-2); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\225\377", 2, &state); /* 0x95 0xFF */ + ASSERT ((ret == (size_t)-1 && errno == EILSEQ) || (ret == 2 && wc == '?')); + } + return 0; + + case 54936: + /* Locale encoding is CP54936 = GB18030. */ + if (strcmp (locale_charset (), "GB18030") != 0) + return 77; + { + char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'B'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[1] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 2, 7, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x00FC); + ASSERT (mbsinit (&state)); + input[2] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 3, 6, &state); + ASSERT (ret == 4); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 3, 6, &state); + ASSERT (ret == 4); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x00DF); + ASSERT (mbsinit (&state)); + input[3] = '\0'; + input[4] = '\0'; + input[5] = '\0'; + input[6] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 7, 2, &state); + ASSERT (ret == 1); + ASSERT (wc == 'e'); + ASSERT (mbsinit (&state)); + input[7] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 8, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'r'); + ASSERT (mbsinit (&state)); + + /* Test some invalid input. */ + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\377", 1, &state); /* 0xFF */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\225\377", 2, &state); /* 0x95 0xFF */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\201\045", 2, &state); /* 0x81 0x25 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\201\060\377", 3, &state); /* 0x81 0x30 0xFF */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\201\060\377\064", 4, &state); /* 0x81 0x30 0xFF 0x34 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\201\060\211\072", 4, &state); /* 0x81 0x30 0x89 0x3A */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + } + return 0; + + case 65001: + /* Locale encoding is CP65001 = UTF-8. */ + if (strcmp (locale_charset (), "UTF-8") != 0) + return 77; + { + char input[] = "B\303\274\303\237er"; /* "Büßer" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'B'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[1] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 2, 5, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x00FC); + ASSERT (mbsinit (&state)); + input[2] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 3, 4, &state); + ASSERT (ret == 2); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 3, 4, &state); + ASSERT (ret == 2); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x00DF); + ASSERT (mbsinit (&state)); + input[3] = '\0'; + input[4] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 5, 2, &state); + ASSERT (ret == 1); + ASSERT (wc == 'e'); + ASSERT (mbsinit (&state)); + input[5] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 6, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'r'); + ASSERT (mbsinit (&state)); + + /* Test some invalid input. */ + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\377", 1, &state); /* 0xFF */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\303\300", 2, &state); /* 0xC3 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\343\300", 2, &state); /* 0xE3 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\343\300\200", 3, &state); /* 0xE3 0xC0 0x80 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\343\200\300", 3, &state); /* 0xE3 0x80 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\363\300", 2, &state); /* 0xF3 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\363\300\200\200", 4, &state); /* 0xF3 0xC0 0x80 0x80 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\363\200\300", 3, &state); /* 0xF3 0x80 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\363\200\300\200", 4, &state); /* 0xF3 0x80 0xC0 0x80 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\363\200\200\300", 4, &state); /* 0xF3 0x80 0x80 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + } + return 0; + + default: + return 1; + } +} + +int +main (int argc, char *argv[]) +{ + int codepage = atoi (argv[argc - 1]); + int result; + int i; + + result = 77; + for (i = 1; i < argc - 1; i++) + { + int ret = test_one_locale (argv[i], codepage); + + if (ret != 77) + result = ret; + } + + if (result == 77) + { + fprintf (stderr, "Skipping test: found no locale with codepage %d\n", + codepage); + } + return result; +} + +#else + +int +main (int argc, char *argv[]) +{ + fputs ("Skipping test: not a native Windows system\n", stderr); + return 77; +} + +#endif diff --git a/gnulib-tests/test-mbrtowc.c b/gnulib-tests/test-mbrtowc.c new file mode 100644 index 0000000..09fbda7 --- /dev/null +++ b/gnulib-tests/test-mbrtowc.c @@ -0,0 +1,357 @@ +/* Test of conversion of multibyte character to wide character. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2008. */ + +#include <config.h> + +#include <wchar.h> + +#include "signature.h" +SIGNATURE_CHECK (mbrtowc, size_t, (wchar_t *, char const *, size_t, + mbstate_t *)); + +#include <locale.h> +#include <stdio.h> +#include <string.h> + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + mbstate_t state; + wchar_t wc; + size_t ret; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test zero-length input. */ + { + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "x", 0, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (mbsinit (&state)); + } + + /* Test NUL byte input. */ + { + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "", 1, &state); + ASSERT (ret == 0); + ASSERT (wc == 0); + ASSERT (mbsinit (&state)); + ret = mbrtowc (NULL, "", 1, &state); + ASSERT (ret == 0); + ASSERT (mbsinit (&state)); + } + + /* Test single-byte input. */ + { + int c; + char buf[1]; + + memset (&state, '\0', sizeof (mbstate_t)); + for (c = 0; c < 0x100; c++) + switch (c) + { + default: + if (! (c && 1 < argc && argv[1][0] == '5')) + break; + FALLTHROUGH; + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set", or argv[1] starts + with '5' so we are testing all nonnull bytes. */ + buf[0] = c; + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, buf, 1, &state); + ASSERT (ret == 1); + if (c < 0x80) + /* c is an ASCII character. */ + ASSERT (wc == c); + else + /* argv[1] starts with '5', that is, we are testing the C or POSIX + locale. + On most platforms, the bytes 0x80..0xFF map to U+0080..U+00FF. + But on musl libc, the bytes 0x80..0xFF map to U+DF80..U+DFFF. */ + ASSERT (wc == (btowc (c) == 0xDF00 + c ? btowc (c) : c)); + ASSERT (mbsinit (&state)); + ret = mbrtowc (NULL, buf, 1, &state); + ASSERT (ret == 1); + ASSERT (mbsinit (&state)); + break; + } + } + + /* Test special calling convention, passing a NULL pointer. */ + { + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, NULL, 5, &state); + ASSERT (ret == 0); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (mbsinit (&state)); + } + + if (argc > 1) + switch (argv[1][0]) + { + case '1': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + char input[] = "B\374\337er"; /* "Büßer" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'B'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 1, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == (unsigned char) '\374'); + ASSERT (mbsinit (&state)); + input[1] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 2, 3, &state); + ASSERT (ret == 1); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 2, 3, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == (unsigned char) '\337'); + ASSERT (mbsinit (&state)); + input[2] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 3, 2, &state); + ASSERT (ret == 1); + ASSERT (wc == 'e'); + ASSERT (mbsinit (&state)); + input[3] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 4, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'r'); + ASSERT (mbsinit (&state)); + } + return 0; + + case '2': + /* Locale encoding is UTF-8. */ + { + char input[] = "B\303\274\303\237er"; /* "Büßer" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'B'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[1] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 2, 5, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == EOF); + ASSERT (mbsinit (&state)); + input[2] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 3, 4, &state); + ASSERT (ret == 2); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 3, 4, &state); + ASSERT (ret == 2); + ASSERT (wctob (wc) == EOF); + ASSERT (mbsinit (&state)); + input[3] = '\0'; + input[4] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 5, 2, &state); + ASSERT (ret == 1); + ASSERT (wc == 'e'); + ASSERT (mbsinit (&state)); + input[5] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 6, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'r'); + ASSERT (mbsinit (&state)); + } + return 0; + + case '3': + /* Locale encoding is EUC-JP. */ + { + char input[] = "<\306\374\313\334\270\354>"; /* "<日本語>" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '<'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 2, &state); + ASSERT (ret == 2); + ASSERT (wctob (wc) == EOF); + ASSERT (mbsinit (&state)); + input[1] = '\0'; + input[2] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 3, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[3] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 4, 4, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == EOF); + ASSERT (mbsinit (&state)); + input[4] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 5, 3, &state); + ASSERT (ret == 2); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 5, 3, &state); + ASSERT (ret == 2); + ASSERT (wctob (wc) == EOF); + ASSERT (mbsinit (&state)); + input[5] = '\0'; + input[6] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 7, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '>'); + ASSERT (mbsinit (&state)); + } + return 0; + + case '4': + /* Locale encoding is GB18030. */ + { + char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'B'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[1] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 2, 7, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == EOF); + ASSERT (mbsinit (&state)); + input[2] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 3, 6, &state); + ASSERT (ret == 4); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 3, 6, &state); + ASSERT (ret == 4); + ASSERT (wctob (wc) == EOF); + ASSERT (mbsinit (&state)); + input[3] = '\0'; + input[4] = '\0'; + input[5] = '\0'; + input[6] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 7, 2, &state); + ASSERT (ret == 1); + ASSERT (wc == 'e'); + ASSERT (mbsinit (&state)); + input[7] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 8, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'r'); + ASSERT (mbsinit (&state)); + } + return 0; + + case '5': + /* C locale; tested above. */ + return 0; + } + + return 1; +} diff --git a/gnulib-tests/test-mbrtowc1.sh b/gnulib-tests/test-mbrtowc1.sh new file mode 100755 index 0000000..00b108b --- /dev/null +++ b/gnulib-tests/test-mbrtowc1.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: ${LOCALE_FR=fr_FR} +if test $LOCALE_FR = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no traditional french locale is installed" + else + echo "Skipping test: no traditional french locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR \ +${CHECKER} ./test-mbrtowc${EXEEXT} 1 diff --git a/gnulib-tests/test-mbrtowc2.sh b/gnulib-tests/test-mbrtowc2.sh new file mode 100755 index 0000000..5036930 --- /dev/null +++ b/gnulib-tests/test-mbrtowc2.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific UTF-8 locale is installed. +: ${LOCALE_FR_UTF8=fr_FR.UTF-8} +if test $LOCALE_FR_UTF8 = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no french Unicode locale is installed" + else + echo "Skipping test: no french Unicode locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR_UTF8 \ +${CHECKER} ./test-mbrtowc${EXEEXT} 2 diff --git a/gnulib-tests/test-mbrtowc3.sh b/gnulib-tests/test-mbrtowc3.sh new file mode 100755 index 0000000..2773fa7 --- /dev/null +++ b/gnulib-tests/test-mbrtowc3.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific EUC-JP locale is installed. +: ${LOCALE_JA=ja_JP} +if test $LOCALE_JA = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no traditional japanese locale is installed" + else + echo "Skipping test: no traditional japanese locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_JA \ +${CHECKER} ./test-mbrtowc${EXEEXT} 3 diff --git a/gnulib-tests/test-mbrtowc4.sh b/gnulib-tests/test-mbrtowc4.sh new file mode 100755 index 0000000..92f641c --- /dev/null +++ b/gnulib-tests/test-mbrtowc4.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific GB18030 locale is installed. +: ${LOCALE_ZH_CN=zh_CN.GB18030} +if test $LOCALE_ZH_CN = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no transitional chinese locale is installed" + else + echo "Skipping test: no transitional chinese locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_ZH_CN \ +${CHECKER} ./test-mbrtowc${EXEEXT} 4 diff --git a/gnulib-tests/test-mbrtowc5.sh b/gnulib-tests/test-mbrtowc5.sh new file mode 100755 index 0000000..490496d --- /dev/null +++ b/gnulib-tests/test-mbrtowc5.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# Test whether the POSIX locale has encoding errors. +LC_ALL=C \ +${CHECKER} ./test-mbrtowc${EXEEXT} 5 || exit +LC_ALL=POSIX \ +${CHECKER} ./test-mbrtowc${EXEEXT} 5 diff --git a/gnulib-tests/test-mbsalign.c b/gnulib-tests/test-mbsalign.c new file mode 100644 index 0000000..1595dca --- /dev/null +++ b/gnulib-tests/test-mbsalign.c @@ -0,0 +1,138 @@ +/* Test that mbsalign works as advertised. + Copyright (C) 2010-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Pádraig Brady. */ + +#include <config.h> + +#include "mbsalign.h" +#include "macros.h" +#include <stdlib.h> +#include <locale.h> + +int +main (void) +{ + char dest[4 * 16 + 1]; + size_t width, n; + + /* Test unibyte truncation. */ + width = 4; + n = mbsalign ("t\tés", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0); + ASSERT (n == 4); + + /* Test center alignment. */ + width = 4; + n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_CENTER, 0); + ASSERT (*dest == ' ' && *(dest + n - 1) == ' '); + ASSERT (n == 4); + + /* Test center alignment, with no trailing padding. */ + width = 4; + n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_CENTER, + MBA_NO_RIGHT_PAD); + ASSERT (n == 3); + ASSERT (*dest == ' ' && *(dest + n - 1) == 's'); + + /* Test left alignment, with no trailing padding. (truncate only). */ + width = 4; + n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_LEFT, + MBA_NO_RIGHT_PAD); + ASSERT (n == 2); + ASSERT (*dest == 'e' && *(dest + n - 1) == 's'); + + /* Test center alignment, with no padding. (truncate only). */ + width = 4; + n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_CENTER, + MBA_NO_LEFT_PAD | MBA_NO_RIGHT_PAD); + ASSERT (n == 2); + ASSERT (*dest == 'e' && *(dest + n - 1) == 's'); + + /* Test center alignment, with no left padding. (may be useful for RTL?) */ + width = 4; + n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_CENTER, + MBA_NO_LEFT_PAD); + ASSERT (n == 3); + ASSERT (*dest == 'e' && *(dest + n - 1) == ' '); + + if (setlocale (LC_ALL, "en_US.UTF8")) + { + /* Check invalid input is flagged. */ + width = 4; + n = mbsalign ("t\xe1\xe2s", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0); + ASSERT (n == (size_t) -1); + + /* Check invalid input is treated as unibyte */ + width = 4; + n = mbsalign ("t\xe1\xe2s", dest, sizeof dest, &width, + MBS_ALIGN_LEFT, MBA_UNIBYTE_FALLBACK); + ASSERT (n == 4); + + /* Test multibyte center alignment. */ + width = 4; + n = mbsalign ("és", dest, sizeof dest, &width, MBS_ALIGN_CENTER, 0); + ASSERT (n == 5); + ASSERT (*dest == ' ' && *(dest + n - 1) == ' '); + + /* Test multibyte left alignment. */ + width = 4; + n = mbsalign ("és", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0); + ASSERT (n == 5); + ASSERT (*(dest + n - 1) == ' ' && *(dest + n - 2) == ' '); + + /* Test multibyte right alignment. */ + width = 4; + n = mbsalign ("és", dest, sizeof dest, &width, MBS_ALIGN_RIGHT, 0); + ASSERT (n == 5); + ASSERT (*(dest) == ' ' && *(dest + 1) == ' '); + + /* multibyte multicell truncation. */ + width = 4; /* cells */ + n = mbsalign ("日月火水", dest, sizeof dest, &width, + MBS_ALIGN_LEFT, 0); + ASSERT (n == 6); /* 2 characters */ + + /* multibyte unicell truncation. */ + width = 3; /* cells */ + n = mbsalign ("¹²³⁴", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0); + ASSERT (n == 6); /* 3 characters */ + + /* Check independence from dest buffer. */ + width = 4; /* cells */ + n = mbsalign ("¹²³⁴", dest, 0, &width, MBS_ALIGN_LEFT, 0); + ASSERT (n == 9); /* 4 characters */ + + /* Check that width is updated with cells required before padding. */ + width = 4; /* cells */ + n = mbsalign ("¹²³", dest, 0, &width, MBS_ALIGN_LEFT, 0); + ASSERT (width == 3); + + /* Test case where output is larger than input + (as tab converted to multi byte replacement char). */ + width = 4; + n = mbsalign ("t\tés" /* 6 including NUL */ , dest, sizeof dest, + &width, MBS_ALIGN_LEFT, 0); + ASSERT (n == 7); + + /* Test forced unibyte truncation. */ + width = 4; + n = mbsalign ("t\tés", dest, sizeof dest, &width, MBS_ALIGN_LEFT, + MBA_UNIBYTE_ONLY); + ASSERT (n == 4); + } + + return 0; +} diff --git a/gnulib-tests/test-mbscasecmp.c b/gnulib-tests/test-mbscasecmp.c new file mode 100644 index 0000000..8a49a21 --- /dev/null +++ b/gnulib-tests/test-mbscasecmp.c @@ -0,0 +1,55 @@ +/* Test of case-insensitive string comparison function. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <string.h> + +#include <locale.h> + +#include "macros.h" + +int +main () +{ + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + ASSERT (mbscasecmp ("paragraph", "Paragraph") == 0); + + ASSERT (mbscasecmp ("paragrapH", "parAgRaph") == 0); + + ASSERT (mbscasecmp ("paragraph", "paraLyzed") < 0); + ASSERT (mbscasecmp ("paraLyzed", "paragraph") > 0); + + ASSERT (mbscasecmp ("para", "paragraph") < 0); + ASSERT (mbscasecmp ("paragraph", "para") > 0); + + /* The following tests shows how mbscasecmp() is different from + strcasecmp(). */ + + ASSERT (mbscasecmp ("\303\266zg\303\274r", "\303\226ZG\303\234R") == 0); /* özgür */ + ASSERT (mbscasecmp ("\303\226ZG\303\234R", "\303\266zg\303\274r") == 0); /* özgür */ + + /* This test shows how strings of different size can compare equal. */ + ASSERT (mbscasecmp ("turkish", "TURK\304\260SH") == 0); + ASSERT (mbscasecmp ("TURK\304\260SH", "turkish") == 0); + + return 0; +} diff --git a/gnulib-tests/test-mbscasecmp.sh b/gnulib-tests/test-mbscasecmp.sh new file mode 100755 index 0000000..5201951 --- /dev/null +++ b/gnulib-tests/test-mbscasecmp.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific Turkish locale is installed. +: ${LOCALE_TR_UTF8=tr_TR.UTF-8} +if test $LOCALE_TR_UTF8 = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no turkish Unicode locale is installed" + else + echo "Skipping test: no turkish Unicode locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_TR_UTF8 \ +${CHECKER} ./test-mbscasecmp${EXEEXT} diff --git a/gnulib-tests/test-mbschr.c b/gnulib-tests/test-mbschr.c new file mode 100644 index 0000000..86d26ae --- /dev/null +++ b/gnulib-tests/test-mbschr.c @@ -0,0 +1,68 @@ +/* Test of searching a string for a character. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <string.h> + +#include <locale.h> + +#include "macros.h" + +int +main () +{ + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Tests with a character < 0x30. */ + { + const char input[] = "\312\276\300\375 \312\276\300\375 \312\276\300\375"; /* "示例 示例 示例" */ + const char *result = mbschr (input, ' '); + ASSERT (result == input + 4); + } + + { + const char input[] = "\312\276\300\375"; /* "示例" */ + const char *result = mbschr (input, ' '); + ASSERT (result == NULL); + } + + /* Tests with a character >= 0x30. */ + { + const char input[] = "\272\305123\324\313\320\320\241\243"; /* "号123运行。" */ + const char *result = mbschr (input, '2'); + ASSERT (result == input + 3); + } + + /* This test shows how mbschr() is different from strchr(). */ + { + const char input[] = "\203\062\332\066123\324\313\320\320\241\243"; /* "씋123运行。" */ + const char *result = mbschr (input, '2'); + ASSERT (result == input + 5); + } + + { + const char input[] = "\312\300\275\347\304\343\272\303\243\241"; /* "世界你好!" */ + const char *result = mbschr (input, '!'); + ASSERT (result == NULL); + } + + return 0; +} diff --git a/gnulib-tests/test-mbschr.sh b/gnulib-tests/test-mbschr.sh new file mode 100755 index 0000000..7b04fe3 --- /dev/null +++ b/gnulib-tests/test-mbschr.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific GB18030 locale is installed. +: ${LOCALE_ZH_CN=zh_CN.GB18030} +if test $LOCALE_ZH_CN = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no chinese GB18030 locale is installed" + else + echo "Skipping test: no chinese GB18030 locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_ZH_CN \ +${CHECKER} ./test-mbschr${EXEEXT} diff --git a/gnulib-tests/test-mbsinit.c b/gnulib-tests/test-mbsinit.c new file mode 100644 index 0000000..44beca3 --- /dev/null +++ b/gnulib-tests/test-mbsinit.c @@ -0,0 +1,55 @@ +/* Test of test for initial conversion state. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2008. */ + +#include <config.h> + +#include <wchar.h> + +#include "signature.h" +SIGNATURE_CHECK (mbsinit, int, (const mbstate_t *)); + +#include <locale.h> + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + static mbstate_t state; + + ASSERT (mbsinit (NULL)); + + ASSERT (mbsinit (&state)); + + if (argc > 1) + { + static const char input[1] = "\303"; + wchar_t wc; + size_t ret; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (!mbsinit (&state)); + } + + return 0; +} diff --git a/gnulib-tests/test-mbsinit.sh b/gnulib-tests/test-mbsinit.sh new file mode 100755 index 0000000..7308714 --- /dev/null +++ b/gnulib-tests/test-mbsinit.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific UTF-8 locale is installed. +: ${LOCALE_FR_UTF8=fr_FR.UTF-8} +if test $LOCALE_FR_UTF8 = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no french Unicode locale is installed" + else + echo "Skipping test: no french Unicode locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR_UTF8 \ +${CHECKER} ./test-mbsinit${EXEEXT} diff --git a/gnulib-tests/test-mbsrtowcs.c b/gnulib-tests/test-mbsrtowcs.c new file mode 100644 index 0000000..8afabe6 --- /dev/null +++ b/gnulib-tests/test-mbsrtowcs.c @@ -0,0 +1,293 @@ +/* Test of conversion of string to wide string. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2008. */ + +#include <config.h> + +#include <wchar.h> + +#include "signature.h" +SIGNATURE_CHECK (mbsrtowcs, size_t, (wchar_t *, char const **, size_t, + mbstate_t *)); + +#include <locale.h> +#include <stdio.h> +#include <string.h> + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + mbstate_t state; + wchar_t wc; + size_t ret; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test NUL byte input. */ + { + const char *src; + + memset (&state, '\0', sizeof (mbstate_t)); + + src = ""; + ret = mbsrtowcs (NULL, &src, 0, &state); + ASSERT (ret == 0); + ASSERT (mbsinit (&state)); + + src = ""; + ret = mbsrtowcs (NULL, &src, 1, &state); + ASSERT (ret == 0); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + src = ""; + ret = mbsrtowcs (&wc, &src, 0, &state); + ASSERT (ret == 0); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + src = ""; + ret = mbsrtowcs (&wc, &src, 1, &state); + ASSERT (ret == 0); + ASSERT (wc == 0); + ASSERT (mbsinit (&state)); + } + + if (argc > 1) + { + int unlimited; + + for (unlimited = 0; unlimited < 2; unlimited++) + { + #define BUFSIZE 10 + wchar_t buf[BUFSIZE]; + const char *src; + mbstate_t temp_state; + + { + size_t i; + for (i = 0; i < BUFSIZE; i++) + buf[i] = (wchar_t) 0xBADFACE; + } + + switch (argv[1][0]) + { + case '1': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + char input[] = "B\374\337er"; /* "Büßer" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'B'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 1, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == (unsigned char) '\374'); + ASSERT (mbsinit (&state)); + input[1] = '\0'; + + src = input + 2; + temp_state = state; + ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 1, &temp_state); + ASSERT (ret == 3); + ASSERT (src == input + 2); + ASSERT (mbsinit (&state)); + + src = input + 2; + ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 1, &state); + ASSERT (ret == (unlimited ? 3 : 1)); + ASSERT (src == (unlimited ? NULL : input + 3)); + ASSERT (wctob (buf[0]) == (unsigned char) '\337'); + if (unlimited) + { + ASSERT (buf[1] == 'e'); + ASSERT (buf[2] == 'r'); + ASSERT (buf[3] == 0); + ASSERT (buf[4] == (wchar_t) 0xBADFACE); + } + else + ASSERT (buf[1] == (wchar_t) 0xBADFACE); + ASSERT (mbsinit (&state)); + } + break; + + case '2': + /* Locale encoding is UTF-8. */ + { + char input[] = "B\303\274\303\237er"; /* "Büßer" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'B'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[1] = '\0'; + + src = input + 2; + temp_state = state; + ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 2, &temp_state); + ASSERT (ret == 4); + ASSERT (src == input + 2); + ASSERT (!mbsinit (&state)); + + src = input + 2; + ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 2, &state); + ASSERT (ret == (unlimited ? 4 : 2)); + ASSERT (src == (unlimited ? NULL : input + 5)); + ASSERT (wctob (buf[0]) == EOF); + ASSERT (wctob (buf[1]) == EOF); + if (unlimited) + { + ASSERT (buf[2] == 'e'); + ASSERT (buf[3] == 'r'); + ASSERT (buf[4] == 0); + ASSERT (buf[5] == (wchar_t) 0xBADFACE); + } + else + ASSERT (buf[2] == (wchar_t) 0xBADFACE); + ASSERT (mbsinit (&state)); + } + break; + + case '3': + /* Locale encoding is EUC-JP. */ + { + char input[] = "<\306\374\313\334\270\354>"; /* "<日本語>" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '<'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 2, &state); + ASSERT (ret == 2); + ASSERT (wctob (wc) == EOF); + ASSERT (mbsinit (&state)); + input[1] = '\0'; + input[2] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 3, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[3] = '\0'; + + src = input + 4; + temp_state = state; + ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 2, &temp_state); + ASSERT (ret == 3); + ASSERT (src == input + 4); + ASSERT (!mbsinit (&state)); + + src = input + 4; + ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 2, &state); + ASSERT (ret == (unlimited ? 3 : 2)); + ASSERT (src == (unlimited ? NULL : input + 7)); + ASSERT (wctob (buf[0]) == EOF); + ASSERT (wctob (buf[1]) == EOF); + if (unlimited) + { + ASSERT (buf[2] == '>'); + ASSERT (buf[3] == 0); + ASSERT (buf[4] == (wchar_t) 0xBADFACE); + } + else + ASSERT (buf[2] == (wchar_t) 0xBADFACE); + ASSERT (mbsinit (&state)); + } + break; + + case '4': + /* Locale encoding is GB18030. */ + { + char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'B'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[1] = '\0'; + + src = input + 2; + temp_state = state; + ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 2, &temp_state); + ASSERT (ret == 4); + ASSERT (src == input + 2); + ASSERT (!mbsinit (&state)); + + src = input + 2; + ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 2, &state); + ASSERT (ret == (unlimited ? 4 : 2)); + ASSERT (src == (unlimited ? NULL : input + 7)); + ASSERT (wctob (buf[0]) == EOF); + ASSERT (wctob (buf[1]) == EOF); + if (unlimited) + { + ASSERT (buf[2] == 'e'); + ASSERT (buf[3] == 'r'); + ASSERT (buf[4] == 0); + ASSERT (buf[5] == (wchar_t) 0xBADFACE); + } + else + ASSERT (buf[2] == (wchar_t) 0xBADFACE); + ASSERT (mbsinit (&state)); + } + break; + + default: + return 1; + } + } + + return 0; + } + + return 1; +} diff --git a/gnulib-tests/test-mbsrtowcs1.sh b/gnulib-tests/test-mbsrtowcs1.sh new file mode 100755 index 0000000..66ba231 --- /dev/null +++ b/gnulib-tests/test-mbsrtowcs1.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: ${LOCALE_FR=fr_FR} +if test $LOCALE_FR = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no traditional french locale is installed" + else + echo "Skipping test: no traditional french locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR \ +${CHECKER} ./test-mbsrtowcs${EXEEXT} 1 diff --git a/gnulib-tests/test-mbsrtowcs2.sh b/gnulib-tests/test-mbsrtowcs2.sh new file mode 100755 index 0000000..6786efd --- /dev/null +++ b/gnulib-tests/test-mbsrtowcs2.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific UTF-8 locale is installed. +: ${LOCALE_FR_UTF8=fr_FR.UTF-8} +if test $LOCALE_FR_UTF8 = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no french Unicode locale is installed" + else + echo "Skipping test: no french Unicode locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR_UTF8 \ +${CHECKER} ./test-mbsrtowcs${EXEEXT} 2 diff --git a/gnulib-tests/test-mbsrtowcs3.sh b/gnulib-tests/test-mbsrtowcs3.sh new file mode 100755 index 0000000..54e9832 --- /dev/null +++ b/gnulib-tests/test-mbsrtowcs3.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific EUC-JP locale is installed. +: ${LOCALE_JA=ja_JP} +if test $LOCALE_JA = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no traditional japanese locale is installed" + else + echo "Skipping test: no traditional japanese locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_JA \ +${CHECKER} ./test-mbsrtowcs${EXEEXT} 3 diff --git a/gnulib-tests/test-mbsrtowcs4.sh b/gnulib-tests/test-mbsrtowcs4.sh new file mode 100755 index 0000000..8acda08 --- /dev/null +++ b/gnulib-tests/test-mbsrtowcs4.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific GB18030 locale is installed. +: ${LOCALE_ZH_CN=zh_CN.GB18030} +if test $LOCALE_ZH_CN = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no transitional chinese locale is installed" + else + echo "Skipping test: no transitional chinese locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_ZH_CN \ +${CHECKER} ./test-mbsrtowcs${EXEEXT} 4 diff --git a/gnulib-tests/test-mbsstr1.c b/gnulib-tests/test-mbsstr1.c new file mode 100644 index 0000000..91b8048 --- /dev/null +++ b/gnulib-tests/test-mbsstr1.c @@ -0,0 +1,128 @@ +/* Test of searching in a string. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <string.h> + +#include <stdlib.h> + +#include "macros.h" + +int +main () +{ + /* This test is executed in the C locale. */ + + { + const char input[] = "foo"; + const char *result = mbsstr (input, ""); + ASSERT (result == input); + } + + { + const char input[] = "foo"; + const char *result = mbsstr (input, "o"); + ASSERT (result == input + 1); + } + + { + const char input[] = "ABC ABCDAB ABCDABCDABDE"; + const char *result = mbsstr (input, "ABCDABD"); + ASSERT (result == input + 15); + } + + { + const char input[] = "ABC ABCDAB ABCDABCDABDE"; + const char *result = mbsstr (input, "ABCDABE"); + ASSERT (result == NULL); + } + + /* Check that a very long haystack is handled quickly if the needle is + short and occurs near the beginning. */ + { + size_t repeat = 10000; + size_t m = 1000000; + const char *needle = + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + char *haystack = (char *) malloc (m + 1); + if (haystack != NULL) + { + memset (haystack, 'A', m); + haystack[0] = 'B'; + haystack[m] = '\0'; + + for (; repeat > 0; repeat--) + { + ASSERT (mbsstr (haystack, needle) == haystack + 1); + } + + free (haystack); + } + } + + /* Check that a very long needle is discarded quickly if the haystack is + short. */ + { + size_t repeat = 10000; + size_t m = 1000000; + const char *haystack = + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB"; + char *needle = (char *) malloc (m + 1); + if (needle != NULL) + { + memset (needle, 'A', m); + needle[m] = '\0'; + + for (; repeat > 0; repeat--) + { + ASSERT (mbsstr (haystack, needle) == NULL); + } + + free (needle); + } + } + + /* Check that the asymptotic worst-case complexity is not quadratic. */ + { + size_t m = 1000000; + char *haystack = (char *) malloc (2 * m + 2); + char *needle = (char *) malloc (m + 2); + if (haystack != NULL && needle != NULL) + { + const char *result; + + memset (haystack, 'A', 2 * m); + haystack[2 * m] = 'B'; + haystack[2 * m + 1] = '\0'; + + memset (needle, 'A', m); + needle[m] = 'B'; + needle[m + 1] = '\0'; + + result = mbsstr (haystack, needle); + ASSERT (result == haystack + m); + } + free (needle); + free (haystack); + } + + return 0; +} diff --git a/gnulib-tests/test-mbsstr2.c b/gnulib-tests/test-mbsstr2.c new file mode 100644 index 0000000..c891bf4 --- /dev/null +++ b/gnulib-tests/test-mbsstr2.c @@ -0,0 +1,141 @@ +/* Test of searching in a string. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <string.h> + +#include <locale.h> +#include <stdlib.h> + +#include "macros.h" + +int +main () +{ + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + { + const char input[] = "f\303\266\303\266"; + const char *result = mbsstr (input, ""); + ASSERT (result == input); + } + + { + const char input[] = "f\303\266\303\266"; + const char *result = mbsstr (input, "\303\266"); + ASSERT (result == input + 1); + } + + { + const char input[] = "f\303\266\303\266"; + const char *result = mbsstr (input, "\266\303"); + ASSERT (result == NULL); + } + + { + const char input[] = "\303\204BC \303\204BCD\303\204B \303\204BCD\303\204BCD\303\204BDE"; /* "ÄBC ÄBCDÄB ÄBCDÄBCDÄBDE" */ + const char *result = mbsstr (input, "\303\204BCD\303\204BD"); /* "ÄBCDÄBD" */ + ASSERT (result == input + 19); + } + + { + const char input[] = "\303\204BC \303\204BCD\303\204B \303\204BCD\303\204BCD\303\204BDE"; /* "ÄBC ÄBCDÄB ÄBCDÄBCDÄBDE" */ + const char *result = mbsstr (input, "\303\204BCD\303\204BE"); /* "ÄBCDÄBE" */ + ASSERT (result == NULL); + } + + /* Check that a very long haystack is handled quickly if the needle is + short and occurs near the beginning. */ + { + size_t repeat = 10000; + size_t m = 1000000; + const char *needle = + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + char *haystack = (char *) malloc (m + 1); + if (haystack != NULL) + { + memset (haystack, 'A', m); + haystack[0] = '\303'; haystack[1] = '\204'; + haystack[m] = '\0'; + + for (; repeat > 0; repeat--) + { + ASSERT (mbsstr (haystack, needle) == haystack + 2); + } + + free (haystack); + } + } + + /* Check that a very long needle is discarded quickly if the haystack is + short. */ + { + size_t repeat = 10000; + size_t m = 1000000; + const char *haystack = + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "A\303\207A\303\207A\303\207A\303\207A\303\207A\303\207A\303\207" + "A\303\207A\303\207A\303\207A\303\207A\303\207A\303\207A\303\207" + "A\303\207A\303\207A\303\207A\303\207A\303\207A\303\207A\303\207" + "A\303\207A\303\207A\303\207A\303\207A\303\207A\303\207A\303\207" + "A\303\207A\303\207A\303\207A\303\207A\303\207A\303\207"; + char *needle = (char *) malloc (m + 1); + if (needle != NULL) + { + memset (needle, 'A', m); + needle[m] = '\0'; + + for (; repeat > 0; repeat--) + { + ASSERT (mbsstr (haystack, needle) == NULL); + } + + free (needle); + } + } + + /* Check that the asymptotic worst-case complexity is not quadratic. */ + { + size_t m = 1000000; + char *haystack = (char *) malloc (2 * m + 3); + char *needle = (char *) malloc (m + 3); + if (haystack != NULL && needle != NULL) + { + const char *result; + + memset (haystack, 'A', 2 * m); + haystack[2 * m] = '\303'; haystack[2 * m + 1] = '\207'; + haystack[2 * m + 2] = '\0'; + + memset (needle, 'A', m); + needle[m] = '\303'; needle[m + 1] = '\207'; + needle[m + 2] = '\0'; + + result = mbsstr (haystack, needle); + ASSERT (result == haystack + m); + } + free (needle); + free (haystack); + } + + return 0; +} diff --git a/gnulib-tests/test-mbsstr2.sh b/gnulib-tests/test-mbsstr2.sh new file mode 100755 index 0000000..5ef7139 --- /dev/null +++ b/gnulib-tests/test-mbsstr2.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific UTF-8 locale is installed. +: ${LOCALE_FR_UTF8=fr_FR.UTF-8} +if test $LOCALE_FR_UTF8 = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no french Unicode locale is installed" + else + echo "Skipping test: no french Unicode locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR_UTF8 \ +${CHECKER} ./test-mbsstr2${EXEEXT} diff --git a/gnulib-tests/test-mbsstr3.c b/gnulib-tests/test-mbsstr3.c new file mode 100644 index 0000000..944b3aa --- /dev/null +++ b/gnulib-tests/test-mbsstr3.c @@ -0,0 +1,81 @@ +/* Test of searching in a string. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <string.h> + +#include <locale.h> + +#include "macros.h" + +int +main () +{ + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Tests with a character < 0x30. */ + { + const char input[] = "\312\276\300\375 \312\276\300\375 \312\276\300\375"; /* "示例 示例 示例" */ + const char *result = mbsstr (input, " "); + ASSERT (result == input + 4); + } + + { + const char input[] = "\312\276\300\375"; /* "示例" */ + const char *result = mbsstr (input, " "); + ASSERT (result == NULL); + } + + /* Tests with a character >= 0x30. */ + { + const char input[] = "\272\305123\324\313\320\320\241\243"; /* "号123运行。" */ + const char *result = mbsstr (input, "2"); + ASSERT (result == input + 3); + } + + /* The following tests show how mbsstr() is different from strstr(). */ + + { + const char input[] = "\313\320\320\320"; /* "诵行" */ + const char *result = mbsstr (input, "\320\320"); /* "行" */ + ASSERT (result == input + 2); + } + + { + const char input[] = "\203\062\332\066123\324\313\320\320\241\243"; /* "씋123运行。" */ + const char *result = mbsstr (input, "2"); + ASSERT (result == input + 5); + } + + { + const char input[] = "\312\276\300\375 \312\276\300\375 \312\276\300\375"; /* "示例 示例 示例" */ + const char *result = mbsstr (input, "\276\300"); /* "纠" */ + ASSERT (result == NULL); + } + + { + const char input[] = "\312\276\300\375 \312\276\300\375 \312\276\300\375"; /* "示例 示例 示例" */ + const char *result = mbsstr (input, "\375 "); /* invalid multibyte sequence */ + ASSERT (result == NULL); + } + + return 0; +} diff --git a/gnulib-tests/test-mbsstr3.sh b/gnulib-tests/test-mbsstr3.sh new file mode 100755 index 0000000..539f9c0 --- /dev/null +++ b/gnulib-tests/test-mbsstr3.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific GB18030 locale is installed. +: ${LOCALE_ZH_CN=zh_CN.GB18030} +if test $LOCALE_ZH_CN = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no chinese GB18030 locale is installed" + else + echo "Skipping test: no chinese GB18030 locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_ZH_CN \ +${CHECKER} ./test-mbsstr3${EXEEXT} diff --git a/gnulib-tests/test-md5.c b/gnulib-tests/test-md5.c new file mode 100644 index 0000000..53d3eda --- /dev/null +++ b/gnulib-tests/test-md5.c @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2005, 2009-2020 Free Software Foundation, Inc. + * Written by Simon Josefsson + * + * 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Simon Josefsson. */ + +#include <config.h> + +#include "md5.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include "macros.h" + +#define TESTFILE "test-md5.data" +#include "test-digest.h" + +int +main (void) +{ + /* Test vectors from RFC 1321. */ + + const char *in1 = "abc"; + const char *out1 = + "\x90\x01\x50\x98\x3C\xD2\x4F\xB0\xD6\x96\x3F\x7D\x28\xE1\x7F\x72"; + const char *in2 = "message digest"; + const char *out2 = + "\xF9\x6B\x69\x7D\x7C\xB7\x93\x8D\x52\x5A\x2F\x31\xAA\xF1\x61\xD0"; + char buf[MD5_DIGEST_SIZE]; + + if (memcmp (md5_buffer (in1, strlen (in1), buf), out1, MD5_DIGEST_SIZE) != 0) + { + size_t i; + printf ("expected:\n"); + for (i = 0; i < MD5_DIGEST_SIZE; i++) + printf ("%02x ", out1[i] & 0xFFu); + printf ("\ncomputed:\n"); + for (i = 0; i < MD5_DIGEST_SIZE; i++) + printf ("%02x ", buf[i] & 0xFFu); + printf ("\n"); + return 1; + } + + if (memcmp (md5_buffer (in2, strlen (in2), buf), out2, MD5_DIGEST_SIZE) != 0) + { + size_t i; + printf ("expected:\n"); + for (i = 0; i < MD5_DIGEST_SIZE; i++) + printf ("%02x ", out2[i] & 0xFFu); + printf ("\ncomputed:\n"); + for (i = 0; i < MD5_DIGEST_SIZE; i++) + printf ("%02x ", buf[i] & 0xFFu); + printf ("\n"); + return 1; + } + + /* Test md5_stream. */ + test_digest_on_files (md5_stream, "md5_stream", 16, + "\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04\xe9\x80\x09\x98\xec\xf8\x42\x7e", + "\x0d\x70\x06\xcd\x05\x5e\x94\xcf\x61\x45\x87\xe1\xd2\xae\x0c\x8e", + "\xec\x99\x67\x9b\xff\xc0\xf9\xb0\x6d\x18\x30\x6b\x06\xd6\x56\x23"); + + return 0; +} diff --git a/gnulib-tests/test-memcasecmp.c b/gnulib-tests/test-memcasecmp.c new file mode 100644 index 0000000..00df2f7 --- /dev/null +++ b/gnulib-tests/test-memcasecmp.c @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2008-2020 Free Software Foundation, Inc. + * Written by Simon Josefsson and Bruno Haible + * + * 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include "memcasecmp.h" + +#include <string.h> + +#include "zerosize-ptr.h" +#include "macros.h" + +int +main (void) +{ + /* Test equal / not equal distinction. */ + ASSERT (memcasecmp (zerosize_ptr (), zerosize_ptr (), 0) == 0); + ASSERT (memcasecmp ("foo", "foobar", 2) == 0); + ASSERT (memcasecmp ("foo", "foobar", 3) == 0); + ASSERT (memcasecmp ("foo", "foobar", 4) != 0); + ASSERT (memcasecmp ("foo", "bar", 1) != 0); + ASSERT (memcasecmp ("foo", "bar", 3) != 0); + + /* Test less / equal / greater distinction. */ + ASSERT (memcasecmp ("foo", "moo", 4) < 0); + ASSERT (memcasecmp ("moo", "foo", 4) > 0); + ASSERT (memcasecmp ("oomph", "oops", 3) < 0); + ASSERT (memcasecmp ("oops", "oomph", 3) > 0); + ASSERT (memcasecmp ("foo", "foobar", 4) < 0); + ASSERT (memcasecmp ("foobar", "foo", 4) > 0); + + /* Test embedded NULs. */ + ASSERT (memcasecmp ("1\0", "2\0", 2) < 0); + ASSERT (memcasecmp ("2\0", "1\0", 2) > 0); + ASSERT (memcasecmp ("x\0""1", "x\0""2", 3) < 0); + ASSERT (memcasecmp ("x\0""2", "x\0""1", 3) > 0); + + /* The Next x86 OpenStep bug shows up only when comparing 16 bytes + or more and with at least one buffer not starting on a 4-byte boundary. + William Lewis provided this test program. */ + { + char foo[21]; + char bar[21]; + int i; + for (i = 0; i < 4; i++) + { + char *a = foo + i; + char *b = bar + i; + strcpy (a, "--------01111111"); + strcpy (b, "--------10000000"); + ASSERT (memcasecmp (a, b, 16) < 0); + } + } + + return 0; +} diff --git a/gnulib-tests/test-memchr.c b/gnulib-tests/test-memchr.c new file mode 100644 index 0000000..ab8d2c0 --- /dev/null +++ b/gnulib-tests/test-memchr.c @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2008-2020 Free Software Foundation, Inc. + * Written by Eric Blake and Bruno Haible + * + * 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <string.h> + +#include "signature.h" +SIGNATURE_CHECK (memchr, void *, (void const *, int, size_t)); + +#include <stdlib.h> + +#include "zerosize-ptr.h" +#include "macros.h" + +/* Calculating void * + int is not portable, so this wrapper converts + to char * to make the tests easier to write. */ +#define MEMCHR (char *) memchr + +int +main (void) +{ + size_t n = 0x100000; + char *input = malloc (n); + ASSERT (input); + + input[0] = 'a'; + input[1] = 'b'; + memset (input + 2, 'c', 1024); + memset (input + 1026, 'd', n - 1028); + input[n - 2] = 'e'; + input[n - 1] = 'a'; + + /* Basic behavior tests. */ + ASSERT (MEMCHR (input, 'a', n) == input); + + ASSERT (MEMCHR (input, 'a', 0) == NULL); + ASSERT (MEMCHR (zerosize_ptr (), 'a', 0) == NULL); + + ASSERT (MEMCHR (input, 'b', n) == input + 1); + ASSERT (MEMCHR (input, 'c', n) == input + 2); + ASSERT (MEMCHR (input, 'd', n) == input + 1026); + + ASSERT (MEMCHR (input + 1, 'a', n - 1) == input + n - 1); + ASSERT (MEMCHR (input + 1, 'e', n - 1) == input + n - 2); + ASSERT (MEMCHR (input + 1, 0x789abc00 | 'e', n - 1) == input + n - 2); + + ASSERT (MEMCHR (input, 'f', n) == NULL); + ASSERT (MEMCHR (input, '\0', n) == NULL); + + /* Check that a very long haystack is handled quickly if the byte is + found near the beginning. */ + { + size_t repeat = 10000; + for (; repeat > 0; repeat--) + { + ASSERT (MEMCHR (input, 'c', n) == input + 2); + } + } + + /* Alignment tests. */ + { + int i, j; + for (i = 0; i < 32; i++) + { + for (j = 0; j < 256; j++) + input[i + j] = j; + for (j = 0; j < 256; j++) + { + ASSERT (MEMCHR (input + i, j, 256) == input + i + j); + } + } + } + + /* Check that memchr() does not read past the first occurrence of the + byte being searched. See the Austin Group's clarification + <https://www.opengroup.org/austin/docs/austin_454.txt>. + Test both '\0' and something else, since some implementations + special-case searching for NUL. + */ + { + char *page_boundary = (char *) zerosize_ptr (); + /* Too small, and we miss cache line boundary tests; too large, + and the test takes cubically longer to complete. */ + int limit = 257; + + if (page_boundary != NULL) + { + for (n = 1; n <= limit; n++) + { + char *mem = page_boundary - n; + memset (mem, 'X', n); + ASSERT (MEMCHR (mem, 'U', n) == NULL); + ASSERT (MEMCHR (mem, 0, n) == NULL); + + { + size_t i; + size_t k; + + for (i = 0; i < n; i++) + { + mem[i] = 'U'; + for (k = i + 1; k < n + limit; k++) + ASSERT (MEMCHR (mem, 'U', k) == mem + i); + mem[i] = 0; + for (k = i + 1; k < n + limit; k++) + ASSERT (MEMCHR (mem, 0, k) == mem + i); + mem[i] = 'X'; + } + } + } + } + } + + free (input); + + return 0; +} diff --git a/gnulib-tests/test-memchr2.c b/gnulib-tests/test-memchr2.c new file mode 100644 index 0000000..47428f2 --- /dev/null +++ b/gnulib-tests/test-memchr2.c @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2008-2020 Free Software Foundation, Inc. + * Written by Eric Blake + * + * 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include "memchr2.h" + +#include <stdlib.h> +#include <string.h> + +#include "zerosize-ptr.h" +#include "macros.h" + +/* Calculating void * + int is not portable, so this wrapper converts + to char * to make the tests easier to write. */ +#define MEMCHR2 (char *) memchr2 + +int +main (void) +{ + size_t n = 0x100000; + char *input = malloc (n); + ASSERT (input); + + input[0] = 'a'; + input[1] = 'b'; + memset (input + 2, 'c', 1024); + memset (input + 1026, 'd', n - 1028); + input[n - 2] = 'e'; + input[n - 1] = 'a'; + + /* Basic behavior tests. */ + ASSERT (MEMCHR2 (input, 'a', 'b', n) == input); + ASSERT (MEMCHR2 (input, 'b', 'a', n) == input); + + ASSERT (MEMCHR2 (input, 'a', 'b', 0) == NULL); + ASSERT (MEMCHR2 (zerosize_ptr (), 'a', 'b', 0) == NULL); + + ASSERT (MEMCHR2 (input, 'b', 'd', n) == input + 1); + ASSERT (MEMCHR2 (input + 2, 'b', 'd', n - 2) == input + 1026); + + ASSERT (MEMCHR2 (input, 'd', 'e', n) == input + 1026); + ASSERT (MEMCHR2 (input, 'e', 'd', n) == input + 1026); + + ASSERT (MEMCHR2 (input + 1, 'a', 'e', n - 1) == input + n - 2); + ASSERT (MEMCHR2 (input + 1, 'e', 'a', n - 1) == input + n - 2); + + ASSERT (MEMCHR2 (input, 'f', 'g', n) == NULL); + ASSERT (MEMCHR2 (input, 'f', '\0', n) == NULL); + + ASSERT (MEMCHR2 (input, 'a', 'a', n) == input); + ASSERT (MEMCHR2 (input + 1, 'a', 'a', n - 1) == input + n - 1); + ASSERT (MEMCHR2 (input, 'f', 'f', n) == NULL); + + /* Check that a very long haystack is handled quickly if one of the + two bytes is found near the beginning. */ + { + size_t repeat = 10000; + for (; repeat > 0; repeat--) + { + ASSERT (MEMCHR2 (input, 'c', 'e', n) == input + 2); + ASSERT (MEMCHR2 (input, 'e', 'c', n) == input + 2); + ASSERT (MEMCHR2 (input, 'c', '\0', n) == input + 2); + ASSERT (MEMCHR2 (input, '\0', 'c', n) == input + 2); + } + } + + /* Alignment tests. */ + { + int i, j; + for (i = 0; i < 32; i++) + { + for (j = 0; j < 256; j++) + input[i + j] = j; + for (j = 0; j < 256; j++) + { + ASSERT (MEMCHR2 (input + i, j, 0xff, 256) == input + i + j); + ASSERT (MEMCHR2 (input + i, 0xff, j, 256) == input + i + j); + } + } + } + + free (input); + + return 0; +} diff --git a/gnulib-tests/test-memcoll.c b/gnulib-tests/test-memcoll.c new file mode 100644 index 0000000..62b5533 --- /dev/null +++ b/gnulib-tests/test-memcoll.c @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2008-2020 Free Software Foundation, Inc. + * Written by Simon Josefsson and Bruno Haible + * + * 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include "memcoll.h" + +#include <string.h> + +#include "macros.h" + +int +main (void) +{ + /* Test equal / not equal distinction. */ + ASSERT (memcoll0 ("", 1, "", 1) == 0); + ASSERT (memcoll0 ("fo", 3, "fo", 3) == 0); + ASSERT (memcoll0 ("foo", 4, "foo", 4) == 0); + ASSERT (memcoll0 ("foo\0", 5, "foob", 5) != 0); + ASSERT (memcoll0 ("f", 2, "b", 2) != 0); + ASSERT (memcoll0 ("foo", 4, "bar", 4) != 0); + + /* Test less / equal / greater distinction. */ + ASSERT (memcoll0 ("foo\0", 5, "moo\0", 5) < 0); + ASSERT (memcoll0 ("moo\0", 5, "foo\0", 5) > 0); + ASSERT (memcoll0 ("oom", 4, "oop", 4) < 0); + ASSERT (memcoll0 ("oop", 4, "oom", 4) > 0); + ASSERT (memcoll0 ("foo\0", 5, "foob", 5) < 0); + ASSERT (memcoll0 ("foob", 5, "foo\0", 5) > 0); + + /* Test embedded NULs. */ + ASSERT (memcoll0 ("1\0", 3, "2\0", 3) < 0); + ASSERT (memcoll0 ("2\0", 3, "1\0", 3) > 0); + ASSERT (memcoll0 ("x\0""1", 4, "x\0""2", 4) < 0); + ASSERT (memcoll0 ("x\0""2", 4, "x\0""1", 4) > 0); + + return 0; +} diff --git a/gnulib-tests/test-memrchr.c b/gnulib-tests/test-memrchr.c new file mode 100644 index 0000000..001134b --- /dev/null +++ b/gnulib-tests/test-memrchr.c @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2008-2020 Free Software Foundation, Inc. + * Written by Eric Blake and Bruno Haible + * + * 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <string.h> + +#include "signature.h" +SIGNATURE_CHECK (memrchr, void *, (void const *, int, size_t)); + +#include <stdlib.h> + +#include "zerosize-ptr.h" +#include "macros.h" + +/* Calculating void * + int is not portable, so this wrapper converts + to char * to make the tests easier to write. */ +#define MEMRCHR (char *) memrchr + +int +main (void) +{ + size_t n = 0x100000; + char *input = malloc (n); + ASSERT (input); + + input[n - 1] = 'a'; + input[n - 2] = 'b'; + memset (input + n - 1026, 'c', 1024); + memset (input + 2, 'd', n - 1028); + input[1] = 'e'; + input[0] = 'a'; + + /* Basic behavior tests. */ + ASSERT (MEMRCHR (input, 'a', n) == input + n - 1); + + ASSERT (MEMRCHR (input, 'a', 0) == NULL); + ASSERT (MEMRCHR (zerosize_ptr (), 'a', 0) == NULL); + + ASSERT (MEMRCHR (input, 'b', n) == input + n - 2); + ASSERT (MEMRCHR (input, 'c', n) == input + n - 3); + ASSERT (MEMRCHR (input, 'd', n) == input + n - 1027); + + ASSERT (MEMRCHR (input, 'a', n - 1) == input); + ASSERT (MEMRCHR (input, 'e', n - 1) == input + 1); + + ASSERT (MEMRCHR (input, 'f', n) == NULL); + ASSERT (MEMRCHR (input, '\0', n) == NULL); + + /* Check that a very long haystack is handled quickly if the byte is + found near the end. */ + { + size_t repeat = 10000; + for (; repeat > 0; repeat--) + { + ASSERT (MEMRCHR (input, 'c', n) == input + n - 3); + } + } + + /* Alignment tests. */ + { + int i, j; + for (i = 0; i < 32; i++) + { + for (j = 0; j < 256; j++) + input[i + j] = j; + for (j = 0; j < 256; j++) + { + ASSERT (MEMRCHR (input + i, j, 256) == input + i + j); + } + } + } + + free (input); + + return 0; +} diff --git a/gnulib-tests/test-mkdir.c b/gnulib-tests/test-mkdir.c new file mode 100644 index 0000000..9ce5817 --- /dev/null +++ b/gnulib-tests/test-mkdir.c @@ -0,0 +1,47 @@ +/* Tests of mkdir. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <sys/stat.h> + +#include "signature.h" +SIGNATURE_CHECK (mkdir, int, (char const *, mode_t)); + +#include <fcntl.h> +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-mkdir.t" + +#include "test-mkdir.h" + +int +main (void) +{ + /* Clean up any trash from prior testsuite runs. */ + ignore_value (system ("rm -rf " BASE "*")); + + return test_mkdir (mkdir, true); +} diff --git a/gnulib-tests/test-mkdir.h b/gnulib-tests/test-mkdir.h new file mode 100644 index 0000000..7da2706 --- /dev/null +++ b/gnulib-tests/test-mkdir.h @@ -0,0 +1,98 @@ +/* Test of mkdir() function. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* This file is designed to test both mkdir(a,b) and + mkdirat(AT_FDCWD,a,b). FUNC is the function to test. Assumes that + BASE and ASSERT are already defined, and that appropriate headers + are already included. If PRINT, warn before skipping tests with + status 77 when symlinks are unsupported. */ + +static int +test_mkdir (int (*func) (char const *, mode_t), bool print) +{ + /* Test basic error handling. */ + ASSERT (close (creat (BASE "file", 0600)) == 0); + errno = 0; + ASSERT (func (BASE "file", 0700) == -1); + ASSERT (errno == EEXIST); + errno = 0; + ASSERT (func (BASE "file/", 0700) == -1); + ASSERT (errno == ENOTDIR || errno == EEXIST); + errno = 0; + ASSERT (func (BASE "file/dir", 0700) == -1); + ASSERT (errno == ENOTDIR || errno == ENOENT || errno == EOPNOTSUPP); + ASSERT (unlink (BASE "file") == 0); + errno = 0; + ASSERT (func ("", 0700) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func (BASE "dir/sub", 0700) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func (BASE "dir/.", 0700) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func (BASE "dir/.//", 0700) == -1); + ASSERT (errno == ENOENT); + + /* Test trailing slash handling. */ + ASSERT (func (BASE "dir", 0700) == 0); + errno = 0; + ASSERT (func (BASE "dir", 0700) == -1); + ASSERT (errno == EEXIST); + ASSERT (rmdir (BASE "dir") == 0); + ASSERT (func (BASE "dir/", 0700) == 0); + errno = 0; + ASSERT (func (BASE "dir/", 0700) == -1); + ASSERT (errno == EEXIST); + ASSERT (rmdir (BASE "dir") == 0); + + /* Test symlink behavior. POSIX requires the creation of + directories through a dangling symlink with trailing slash, but + GNU does not yet implement that, so we support either behavior + for now. */ + if (symlink (BASE "dir", BASE "link")) + { + if (print) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + errno = 0; + ASSERT (func (BASE "link", 0700) == -1); + ASSERT (errno == EEXIST); + { + int result; + errno = 0; + result = func (BASE "link/", 0700); + if (!result) + ASSERT (rmdir (BASE "dir") == 0); + else + { + ASSERT (result == -1); + ASSERT (errno == EEXIST); + errno = 0; + ASSERT (rmdir (BASE "dir") == -1); + ASSERT (errno == ENOENT); + } + } + errno = 0; + ASSERT (func (BASE "link/.", 0700) == -1); + ASSERT (errno == ENOENT); + ASSERT (unlink (BASE "link") == 0); + + return 0; +} diff --git a/gnulib-tests/test-mkfifo.c b/gnulib-tests/test-mkfifo.c new file mode 100644 index 0000000..2c7fd2c --- /dev/null +++ b/gnulib-tests/test-mkfifo.c @@ -0,0 +1,47 @@ +/* Tests of mkfifo. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <sys/stat.h> + +#include "signature.h" +SIGNATURE_CHECK (mkfifo, int, (char const *, mode_t)); + +#include <fcntl.h> +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-mkfifo.t" + +#include "test-mkfifo.h" + +int +main (void) +{ + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + return test_mkfifo (mkfifo, true); +} diff --git a/gnulib-tests/test-mkfifo.h b/gnulib-tests/test-mkfifo.h new file mode 100644 index 0000000..91d5cd2 --- /dev/null +++ b/gnulib-tests/test-mkfifo.h @@ -0,0 +1,77 @@ +/* Tests of mkfifo and friends. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +/* This file is designed to test mkfifo(n,m), mknod(n,m|S_IFIFO,0), + mkfifoat(AT_FDCWD,n,m), and mknodat(AT_FDCWD,n,m|S_IFIFO,0). FUNC + is the function to test. Assumes that BASE and ASSERT are already + defined, and that appropriate headers are already included. If + PRINT, warn before skipping symlink tests with status 77. */ + +static int +test_mkfifo (int (*func) (char const *, mode_t), bool print) +{ + int result = func (BASE "fifo", 0600); + struct stat st; + if (result == -1 && errno == ENOSYS) + { + if (print) + fputs ("skipping test: no support for named fifos\n", stderr); + return 77; + } + ASSERT (result == 0); + ASSERT (stat (BASE "fifo", &st) == 0); + ASSERT (S_ISFIFO (st.st_mode)); + + /* Sanity checks of failures. */ + errno = 0; + ASSERT (func ("", S_IRUSR | S_IWUSR) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func (".", 0600) == -1); + /* Allow HP-UX 11.11's EISDIR, even though POSIX says it's wrong, + since it doesn't really hurt anything and we lack the energy to + fix it. */ + ASSERT (errno == EEXIST || errno == EINVAL || errno == EISDIR); + errno = 0; + ASSERT (func (BASE "fifo", 0600) == -1); + ASSERT (errno == EEXIST); + ASSERT (unlink (BASE "fifo") == 0); + errno = 0; + ASSERT (func (BASE "fifo/", 0600) == -1); + ASSERT (errno == ENOENT || errno == ENOTDIR); + + /* Test trailing slash behavior. */ + if (symlink (BASE "fifo", BASE "link")) + { + if (print) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + errno = 0; + ASSERT (func (BASE "link", 0600) == -1); + ASSERT (errno == EEXIST); + errno = 0; + ASSERT (func (BASE "link/", 0600) == -1); + ASSERT (errno == EEXIST || errno == ENOENT || errno == ENOTDIR); + errno = 0; + ASSERT (unlink (BASE "fifo") == -1); + ASSERT (errno == ENOENT); + ASSERT (unlink (BASE "link") == 0); + return 0; +} diff --git a/gnulib-tests/test-mknod.c b/gnulib-tests/test-mknod.c new file mode 100644 index 0000000..8dee3b0 --- /dev/null +++ b/gnulib-tests/test-mknod.c @@ -0,0 +1,56 @@ +/* Tests of mknod. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <sys/stat.h> + +#include "signature.h" +SIGNATURE_CHECK (mknod, int, (char const *, mode_t, dev_t)); + +#include <fcntl.h> +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-mknod.t" + +#include "test-mkfifo.h" + +/* Wrapper around mknod, to create fifos. */ +static int +do_mknod (char const *name, mode_t mode) +{ + return mknod (name, mode | S_IFIFO, 0); +} + +int +main (void) +{ + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + /* We can only portably test creation of fifos. Anything else + requires root privileges and knowledge of device numbers. */ + return test_mkfifo (do_mknod, true); +} diff --git a/gnulib-tests/test-nanosleep.c b/gnulib-tests/test-nanosleep.c new file mode 100644 index 0000000..e82e45d --- /dev/null +++ b/gnulib-tests/test-nanosleep.c @@ -0,0 +1,83 @@ +/* Test of nanosleep() function. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <time.h> + +#include "signature.h" +SIGNATURE_CHECK (nanosleep, int, (struct timespec const *, struct timespec *)); + +#include <errno.h> +#include <signal.h> +#include <unistd.h> + +#include "macros.h" + +#if HAVE_DECL_ALARM +static void +handle_alarm (int sig) +{ + if (sig != SIGALRM) + _exit (1); +} +#endif + +int +main (void) +{ + struct timespec ts; + + ts.tv_sec = 1000; + ts.tv_nsec = -1; + errno = 0; + ASSERT (nanosleep (&ts, NULL) == -1); + ASSERT (errno == EINVAL); + ts.tv_nsec = 1000000000; + errno = 0; + ASSERT (nanosleep (&ts, NULL) == -1); + ASSERT (errno == EINVAL); + + ts.tv_sec = 0; + ts.tv_nsec = 1; + ASSERT (nanosleep (&ts, &ts) == 0); + /* Remaining time is only defined on EINTR failure; but on success, + it is typically either 0 or unchanged from input. At any rate, + it shouldn't be randomly changed to unrelated values. */ + ASSERT (ts.tv_sec == 0); + ASSERT (ts.tv_nsec == 0 || ts.tv_nsec == 1); + ts.tv_nsec = 0; + ASSERT (nanosleep (&ts, NULL) == 0); + +#if HAVE_DECL_ALARM + { + const time_t pentecost = 50 * 24 * 60 * 60; /* 50 days. */ + signal (SIGALRM, handle_alarm); + alarm (1); + ts.tv_sec = pentecost; + ts.tv_nsec = 999999999; + errno = 0; + ASSERT (nanosleep (&ts, &ts) == -1); + ASSERT (errno == EINTR); + ASSERT (pentecost - 10 < ts.tv_sec && ts.tv_sec <= pentecost); + ASSERT (0 <= ts.tv_nsec && ts.tv_nsec <= 999999999); + } +#endif + + return 0; +} diff --git a/gnulib-tests/test-netdb.c b/gnulib-tests/test-netdb.c new file mode 100644 index 0000000..b606eb5 --- /dev/null +++ b/gnulib-tests/test-netdb.c @@ -0,0 +1,32 @@ +/* Test of <netdb.h> substitute. + Copyright (C) 2007-2008, 2010-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Simon Josefsson <simon@josefsson.org>, 2008. */ + +#include <config.h> +#include <netdb.h> + +/* Check that the 'struct hostent' type is defined. */ +struct hostent t1; + +/* Check that the 'socklen_t' type is defined. */ +socklen_t t2; + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tests/test-netinet_in.c b/gnulib-tests/test-netinet_in.c new file mode 100644 index 0000000..f170410 --- /dev/null +++ b/gnulib-tests/test-netinet_in.c @@ -0,0 +1,27 @@ +/* Test of <netinet/in.h> substitute. + Copyright (C) 2007, 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <netinet/in.h> + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tests/test-nl_langinfo-mt.c b/gnulib-tests/test-nl_langinfo-mt.c new file mode 100644 index 0000000..de6cd99 --- /dev/null +++ b/gnulib-tests/test-nl_langinfo-mt.c @@ -0,0 +1,255 @@ +/* Multithread-safety test for nl_langinfo(). + Copyright (C) 2019-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2019. */ + +#include <config.h> + +#if USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS || USE_WINDOWS_THREADS + +/* Specification. */ +#include <langinfo.h> + +#include <locale.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +#include "glthread/thread.h" + + +/* Some common locale names. */ + +#if defined _WIN32 && !defined __CYGWIN__ +# define ENGLISH "English_United States" +# define FRENCH "French_France" +# define GERMAN "German_Germany" +# define ENCODING ".1252" +#else +# define ENGLISH "en_US" +# define FRENCH "fr_FR" +# define GERMAN "de_DE" +# if defined __sgi +# define ENCODING ".ISO8859-15" +# elif defined __hpux +# define ENCODING ".utf8" +# else +# define ENCODING ".UTF-8" +# endif +#endif + +static const char LOCALE1[] = ENGLISH ENCODING; +static const char LOCALE2[] = FRENCH ENCODING; +static const char LOCALE3[] = GERMAN ENCODING; + +static char *expected1; + +static void * +thread1_func (void *arg) +{ + for (;;) + { + const char *value = nl_langinfo (CODESET); + if (strcmp (expected1, value) != 0) + { + fprintf (stderr, "thread1 disturbed by threadN!\n"); fflush (stderr); + abort (); + } + } + + /*NOTREACHED*/ + return NULL; +} + +static char *expected2; + +static void * +thread2_func (void *arg) +{ + for (;;) + { + const char *value = nl_langinfo (PM_STR); + if (strcmp (expected2, value) != 0) + { + fprintf (stderr, "thread2 disturbed by threadN!\n"); fflush (stderr); + abort (); + } + } + + /*NOTREACHED*/ + return NULL; +} + +static char *expected3; + +static void * +thread3_func (void *arg) +{ + for (;;) + { + const char *value = nl_langinfo (DAY_2); + if (strcmp (expected3, value) != 0) + { + fprintf (stderr, "thread3 disturbed by threadN!\n"); fflush (stderr); + abort (); + } + } + + /*NOTREACHED*/ + return NULL; +} + +static char *expected4; + +static void * +thread4_func (void *arg) +{ + for (;;) + { + const char *value = nl_langinfo (ALTMON_2); + if (strcmp (expected4, value) != 0) + { + fprintf (stderr, "thread4 disturbed by threadN!\n"); fflush (stderr); + abort (); + } + } + + /*NOTREACHED*/ + return NULL; +} + +static char *expected5; + +static void * +thread5_func (void *arg) +{ + for (;;) + { + const char *value = nl_langinfo (CRNCYSTR); + if (strcmp (expected5, value) != 0) + { + fprintf (stderr, "thread5 disturbed by threadN!\n"); fflush (stderr); + abort (); + } + } + + /*NOTREACHED*/ + return NULL; +} + +static char *expected6; + +static void * +thread6_func (void *arg) +{ + for (;;) + { + const char *value = nl_langinfo (RADIXCHAR); + if (strcmp (expected6, value) != 0) + { + fprintf (stderr, "thread6 disturbed by threadN!\n"); fflush (stderr); + abort (); + } + } + + /*NOTREACHED*/ + return NULL; +} + +static void * +threadN_func (void *arg) +{ + for (;;) + { + nl_langinfo (CODESET); /* LC_CTYPE */ /* locale charmap */ + nl_langinfo (AM_STR); /* LC_TIME */ /* locale -k am_pm */ + nl_langinfo (PM_STR); /* LC_TIME */ /* locale -k am_pm */ + nl_langinfo (DAY_2); /* LC_TIME */ /* locale -k day */ + nl_langinfo (DAY_5); /* LC_TIME */ /* locale -k day */ + nl_langinfo (ALTMON_2); /* LC_TIME */ /* locale -k alt_mon */ + nl_langinfo (ALTMON_9); /* LC_TIME */ /* locale -k alt_mon */ + nl_langinfo (CRNCYSTR); /* LC_MONETARY */ /* locale -k currency_symbol */ + nl_langinfo (RADIXCHAR); /* LC_NUMERIC */ /* locale -k decimal_point */ + nl_langinfo (THOUSEP); /* LC_NUMERIC */ /* locale -k thousands_sep */ + } + + /*NOTREACHED*/ + return NULL; +} + +int +main (int argc, char *argv[]) +{ + if (setlocale (LC_ALL, LOCALE1) == NULL) + { + fprintf (stderr, "Skipping test: LOCALE1 not recognized\n"); + return 77; + } + if (setlocale (LC_MONETARY, LOCALE2) == NULL) + { + fprintf (stderr, "Skipping test: LOCALE2 not recognized\n"); + return 77; + } + if (setlocale (LC_NUMERIC, LOCALE3) == NULL) + { + fprintf (stderr, "Skipping test: LOCALE3 not recognized\n"); + return 77; + } + + expected1 = strdup (nl_langinfo (CODESET)); + expected2 = strdup (nl_langinfo (PM_STR)); + expected3 = strdup (nl_langinfo (DAY_2)); + expected4 = strdup (nl_langinfo (ALTMON_2)); + expected5 = strdup (nl_langinfo (CRNCYSTR)); + expected6 = strdup (nl_langinfo (RADIXCHAR)); + + /* Create the checker threads. */ + gl_thread_create (thread1_func, NULL); + gl_thread_create (thread2_func, NULL); + gl_thread_create (thread3_func, NULL); + gl_thread_create (thread4_func, NULL); + gl_thread_create (thread5_func, NULL); + gl_thread_create (thread6_func, NULL); + /* Create the disturber thread. */ + gl_thread_create (threadN_func, NULL); + + /* Let them run for 2 seconds. */ + { + struct timespec duration; + duration.tv_sec = (argc > 1 ? atoi (argv[1]) : 2); + duration.tv_nsec = 0; + + nanosleep (&duration, NULL); + } + + return 0; +} + +#else + +/* No multithreading available. */ + +#include <stdio.h> + +int +main () +{ + fputs ("Skipping test: multithreading not enabled\n", stderr); + return 77; +} + +#endif diff --git a/gnulib-tests/test-nl_langinfo.c b/gnulib-tests/test-nl_langinfo.c new file mode 100644 index 0000000..e21d003 --- /dev/null +++ b/gnulib-tests/test-nl_langinfo.c @@ -0,0 +1,152 @@ +/* Test of nl_langinfo replacement. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2009. */ + +#include <config.h> + +#include <langinfo.h> + +#include "signature.h" +SIGNATURE_CHECK (nl_langinfo, char *, (nl_item)); + +#include <locale.h> +#include <stdlib.h> +#include <string.h> + +#include "c-strcase.h" +#include "macros.h" + +/* For GCC >= 4.3, silence the warnings + "comparison of unsigned expression >= 0 is always true" + in this file. */ +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif + +int +main (int argc, char *argv[]) +{ + int pass = atoi (argv[1]); + /* pass locale + 0 C + 1 traditional French locale + 2 French UTF-8 locale + */ + + setlocale (LC_ALL, ""); + + /* nl_langinfo items of the LC_CTYPE category */ + ASSERT (strlen (nl_langinfo (CODESET)) > 0); + if (pass == 2) + { + const char *codeset = nl_langinfo (CODESET); + ASSERT (c_strcasecmp (codeset, "UTF-8") == 0 || c_strcasecmp (codeset, "UTF8") == 0); + } + /* nl_langinfo items of the LC_NUMERIC category */ + ASSERT (strlen (nl_langinfo (RADIXCHAR)) > 0); + ASSERT (strlen (nl_langinfo (THOUSEP)) >= 0); + /* nl_langinfo items of the LC_TIME category */ + ASSERT (strlen (nl_langinfo (D_T_FMT)) > 0); + ASSERT (strlen (nl_langinfo (D_FMT)) > 0); + ASSERT (strlen (nl_langinfo (T_FMT)) > 0); + ASSERT (strlen (nl_langinfo (T_FMT_AMPM)) >= (pass == 0 ? 1 : 0)); + ASSERT (strlen (nl_langinfo (AM_STR)) >= (pass == 0 ? 1 : 0)); + ASSERT (strlen (nl_langinfo (PM_STR)) >= (pass == 0 ? 1 : 0)); + ASSERT (strlen (nl_langinfo (DAY_1)) > 0); + ASSERT (strlen (nl_langinfo (DAY_2)) > 0); + ASSERT (strlen (nl_langinfo (DAY_3)) > 0); + ASSERT (strlen (nl_langinfo (DAY_4)) > 0); + ASSERT (strlen (nl_langinfo (DAY_5)) > 0); + ASSERT (strlen (nl_langinfo (DAY_6)) > 0); + ASSERT (strlen (nl_langinfo (DAY_7)) > 0); + ASSERT (strlen (nl_langinfo (ABDAY_1)) > 0); + ASSERT (strlen (nl_langinfo (ABDAY_2)) > 0); + ASSERT (strlen (nl_langinfo (ABDAY_3)) > 0); + ASSERT (strlen (nl_langinfo (ABDAY_4)) > 0); + ASSERT (strlen (nl_langinfo (ABDAY_5)) > 0); + ASSERT (strlen (nl_langinfo (ABDAY_6)) > 0); + ASSERT (strlen (nl_langinfo (ABDAY_7)) > 0); + ASSERT (strlen (nl_langinfo (MON_1)) > 0); + ASSERT (strlen (nl_langinfo (MON_2)) > 0); + ASSERT (strlen (nl_langinfo (MON_3)) > 0); + ASSERT (strlen (nl_langinfo (MON_4)) > 0); + ASSERT (strlen (nl_langinfo (MON_5)) > 0); + ASSERT (strlen (nl_langinfo (MON_6)) > 0); + ASSERT (strlen (nl_langinfo (MON_7)) > 0); + ASSERT (strlen (nl_langinfo (MON_8)) > 0); + ASSERT (strlen (nl_langinfo (MON_9)) > 0); + ASSERT (strlen (nl_langinfo (MON_10)) > 0); + ASSERT (strlen (nl_langinfo (MON_11)) > 0); + ASSERT (strlen (nl_langinfo (MON_12)) > 0); + ASSERT (strlen (nl_langinfo (ALTMON_1)) > 0); + ASSERT (strlen (nl_langinfo (ALTMON_2)) > 0); + ASSERT (strlen (nl_langinfo (ALTMON_3)) > 0); + ASSERT (strlen (nl_langinfo (ALTMON_4)) > 0); + ASSERT (strlen (nl_langinfo (ALTMON_5)) > 0); + ASSERT (strlen (nl_langinfo (ALTMON_6)) > 0); + ASSERT (strlen (nl_langinfo (ALTMON_7)) > 0); + ASSERT (strlen (nl_langinfo (ALTMON_8)) > 0); + ASSERT (strlen (nl_langinfo (ALTMON_9)) > 0); + ASSERT (strlen (nl_langinfo (ALTMON_10)) > 0); + ASSERT (strlen (nl_langinfo (ALTMON_11)) > 0); + ASSERT (strlen (nl_langinfo (ALTMON_12)) > 0); + /* In the tested locales, alternate month names and month names ought to be + the same. */ + ASSERT (strcmp (nl_langinfo (ALTMON_1), nl_langinfo (MON_1)) == 0); + ASSERT (strcmp (nl_langinfo (ALTMON_2), nl_langinfo (MON_2)) == 0); + ASSERT (strcmp (nl_langinfo (ALTMON_3), nl_langinfo (MON_3)) == 0); + ASSERT (strcmp (nl_langinfo (ALTMON_4), nl_langinfo (MON_4)) == 0); + ASSERT (strcmp (nl_langinfo (ALTMON_5), nl_langinfo (MON_5)) == 0); + ASSERT (strcmp (nl_langinfo (ALTMON_6), nl_langinfo (MON_6)) == 0); + ASSERT (strcmp (nl_langinfo (ALTMON_7), nl_langinfo (MON_7)) == 0); + ASSERT (strcmp (nl_langinfo (ALTMON_8), nl_langinfo (MON_8)) == 0); + ASSERT (strcmp (nl_langinfo (ALTMON_9), nl_langinfo (MON_9)) == 0); + ASSERT (strcmp (nl_langinfo (ALTMON_10), nl_langinfo (MON_10)) == 0); + ASSERT (strcmp (nl_langinfo (ALTMON_11), nl_langinfo (MON_11)) == 0); + ASSERT (strcmp (nl_langinfo (ALTMON_12), nl_langinfo (MON_12)) == 0); + ASSERT (strlen (nl_langinfo (ABMON_1)) > 0); + ASSERT (strlen (nl_langinfo (ABMON_2)) > 0); + ASSERT (strlen (nl_langinfo (ABMON_3)) > 0); + ASSERT (strlen (nl_langinfo (ABMON_4)) > 0); + ASSERT (strlen (nl_langinfo (ABMON_5)) > 0); + ASSERT (strlen (nl_langinfo (ABMON_6)) > 0); + ASSERT (strlen (nl_langinfo (ABMON_7)) > 0); + ASSERT (strlen (nl_langinfo (ABMON_8)) > 0); + ASSERT (strlen (nl_langinfo (ABMON_9)) > 0); + ASSERT (strlen (nl_langinfo (ABMON_10)) > 0); + ASSERT (strlen (nl_langinfo (ABMON_11)) > 0); + ASSERT (strlen (nl_langinfo (ABMON_12)) > 0); + ASSERT (strlen (nl_langinfo (ERA)) >= 0); + ASSERT (strlen (nl_langinfo (ERA_D_FMT)) >= 0); + ASSERT (strlen (nl_langinfo (ERA_D_T_FMT)) >= 0); + ASSERT (strlen (nl_langinfo (ERA_T_FMT)) >= 0); + ASSERT (nl_langinfo (ALT_DIGITS) != NULL); + /* nl_langinfo items of the LC_MONETARY category */ + { + const char *currency = nl_langinfo (CRNCYSTR); + ASSERT (strlen (currency) >= 0); +#if !defined __NetBSD__ + if (pass > 0) + ASSERT (strlen (currency) >= 1); +#endif + } + /* nl_langinfo items of the LC_MESSAGES category */ + ASSERT (strlen (nl_langinfo (YESEXPR)) > 0); + ASSERT (strlen (nl_langinfo (NOEXPR)) > 0); + + return 0; +} diff --git a/gnulib-tests/test-nl_langinfo.sh b/gnulib-tests/test-nl_langinfo.sh new file mode 100755 index 0000000..b1ce46c --- /dev/null +++ b/gnulib-tests/test-nl_langinfo.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +LC_ALL=C ${CHECKER} ./test-nl_langinfo${EXEEXT} 0 || exit 1 + +# Test whether a specific traditional locale is installed. +: ${LOCALE_FR=fr_FR} +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR ${CHECKER} ./test-nl_langinfo${EXEEXT} 1 || exit 1 +fi + +# Test whether a specific UTF-8 locale is installed. +: ${LOCALE_FR_UTF8=fr_FR.UTF-8} +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 ${CHECKER} ./test-nl_langinfo${EXEEXT} 2 || exit 1 +fi + +exit 0 diff --git a/gnulib-tests/test-nstrftime.c b/gnulib-tests/test-nstrftime.c new file mode 100644 index 0000000..cb9e2d6 --- /dev/null +++ b/gnulib-tests/test-nstrftime.c @@ -0,0 +1,264 @@ +/* Test that nstrftime works as required. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Jim Meyering. */ + +#include <config.h> + +#include "strftime.h" + +#include <errno.h> +#include <stdio.h> +#include <string.h> +#include <time.h> +#include <unistd.h> + +#include "macros.h" +#define STREQ(a, b) (strcmp (a, b) == 0) + +/* Support for settings like TZ='<+00>0' was added in IEEE Std 1003.1-2001. */ +#define TZ_ANGLE_BRACKETS_SHOULD_WORK (200112 <= _POSIX_VERSION) + +struct posixtm_test +{ + time_t in; + int in_ns; + char const *fmt; + char const *exp; +}; + +static struct posixtm_test const T[] = + { + { 1300000000, 0, "%F", "2011-03-13" }, + { 0, 10, "%T.%N", "00:00:00.000000010" }, + { 56, 123456789, "%T.%12N", "00:00:56.123456789000" }, + { 0, 0, NULL, NULL } + }; + +static int +posixtm_test (void) +{ + int fail = 0; + unsigned int i; + + for (i = 0; T[i].fmt; i++) + { + char buf[1000]; + time_t t = T[i].in; + struct tm *tm = gmtime (&t); + size_t n; + + ASSERT (tm); + + n = nstrftime (buf, sizeof buf, T[i].fmt, tm, 0, T[i].in_ns); + if (n == 0) + { + fail = 1; + printf ("nstrftime failed with format %s\n", T[i].fmt); + } + + if (! STREQ (buf, T[i].exp)) + { + fail = 1; + printf ("%s: result mismatch: got %s, expected %s\n", + T[i].fmt, buf, T[i].exp); + } + } + + return fail; +} + +struct tzalloc_test +{ + timezone_t tz; + char const *setting; +}; + +static struct tzalloc_test TZ[] = + { +#define Pacific 0 + { 0, "PST8PDT,M3.2.0,M11.1.0" }, +#define Arizona 1 + { 0, "MST7" }, +#define UTC 2 + { 0, 0 }, +#define CentEur 3 + { 0, "CET-1CEST,M3.5.0,M10.5.0/3" }, +#define Japan 4 + { 0, "JST-9" }, +#define NZ 5 + { 0, "NZST-12NZDT,M9.5.0,M4.1.0/3" }, +#define Unknown 6 + { 0, "<-00>0" }, + { 0 } + }; + +struct localtime_rz_test +{ + /* Input parameters. */ + struct tzalloc_test *tza; + time_t t; + + /* Expected result. */ + char const *exp; + + /* Determines if an incorrectly unset tm_isdst + results in failure or just a warning. */ + int ahistorical; +}; + +static struct localtime_rz_test LT[] = + { + { TZ+Pacific, 0, "1969-12-31 16:00:00 -0800 (PST)", 0 }, + { TZ+Arizona, 0, "1969-12-31 17:00:00 -0700 (MST)", 0 }, + { TZ+UTC , 0, "1970-01-01 00:00:00 +0000 (UTC)", 0 }, + { TZ+CentEur, 0, "1970-01-01 01:00:00 +0100 (CET)", 0 }, + { TZ+Japan , 0, "1970-01-01 09:00:00 +0900 (JST)", 0 }, + { TZ+NZ , 0, "1970-01-01 13:00:00 +1300 (NZDT)", 1 }, + { TZ+Pacific, 500000001, "1985-11-04 16:53:21 -0800 (PST)", 0 }, + { TZ+Arizona, 500000001, "1985-11-04 17:53:21 -0700 (MST)", 0 }, + { TZ+UTC , 500000001, "1985-11-05 00:53:21 +0000 (UTC)", 0 }, + { TZ+CentEur, 500000001, "1985-11-05 01:53:21 +0100 (CET)", 1 }, + { TZ+Japan , 500000001, "1985-11-05 09:53:21 +0900 (JST)", 0 }, + { TZ+NZ , 500000001, "1985-11-05 13:53:21 +1300 (NZDT)", 0 }, + { TZ+Pacific, 1000000002, "2001-09-08 18:46:42 -0700 (PDT)", 0 }, + { TZ+Arizona, 1000000002, "2001-09-08 18:46:42 -0700 (MST)", 0 }, + { TZ+UTC , 1000000002, "2001-09-09 01:46:42 +0000 (UTC)", 0 }, + { TZ+CentEur, 1000000002, "2001-09-09 03:46:42 +0200 (CEST)", 0 }, + { TZ+Japan , 1000000002, "2001-09-09 10:46:42 +0900 (JST)", 0 }, + { TZ+NZ , 1000000002, "2001-09-09 13:46:42 +1200 (NZST)", 0 }, +#if TZ_ANGLE_BRACKETS_SHOULD_WORK + { TZ+Unknown, 0, "1970-01-01 00:00:00 -0000 (-00)", 0 }, + { TZ+Unknown, 500000001, "1985-11-05 00:53:21 -0000 (-00)", 0 }, + { TZ+Unknown, 1000000002, "2001-09-09 01:46:42 -0000 (-00)", 0 }, +#endif + { 0 } + }; + +static int +tzalloc_test (void) +{ + int fail = 0; + int i; + + for (i = 0; LT[i].tza; i++) + { + struct tzalloc_test *tza = LT[i].tza; + long lt = LT[i].t; + timezone_t tz = tza->tz; + char const *setting; + static char const format[] = "%Y-%m-%d %H:%M:%S %z (%Z)"; + char buf[1000]; + struct tm tm; + size_t n; + + if (!tz && tza->setting) + { + tz = tzalloc (tza->setting); + if (!tz) + { + fail = 1; + printf ("%s: tzalloc: %s\n", TZ[i].setting, strerror (errno)); + continue; + } + tza->tz = tz; + } + + setting = tza->setting ? tza->setting : "UTC0"; + + if (!localtime_rz (tz, <[i].t, &tm)) + { + fail = 1; + printf ("%s: %ld: localtime_rz: %s\n", setting, lt, + strerror (errno)); + continue; + } + + n = nstrftime (buf, sizeof buf, format, &tm, tz, 0); + if (n == 0) + { + fail = 1; + printf ("%s: %ld: nstrftime failed\n", setting, lt); + continue; + } + + if (! (STREQ (buf, LT[i].exp) + || (!tz && n == strlen (LT[i].exp) + && memcmp (buf, LT[i].exp, n - sizeof "(GMT)" + 1) == 0 + && STREQ (buf + n - sizeof "(GMT)" + 1, "(GMT)")))) + { + /* Don't fail for unhandled dst in ahistorical entries, + as gnulib doesn't currently fix that issue, seen on Darwin 14. */ + if (!LT[i].ahistorical || tm.tm_isdst) + fail = 1; + printf ("%s: expected \"%s\", got \"%s\"\n", + setting, LT[i].exp, buf); + } + } + + return fail; +} + + +static int +quarter_test (void) +{ + int result = 0; + size_t mon; + + /* Check %q. */ + for (mon = 1; mon <= 12; mon++) + { + char out[2]; + char exp[2] = {0,}; + struct tm qtm = { .tm_mon = mon - 1 }; + char fmt[3] = {'%','q','\0'}; + + size_t r = nstrftime (out, sizeof (out), fmt, &qtm, 0, 0); + if (r == 0) + { + puts ("nstrftime(\"%q\") failed"); + result = 1; + break; + } + + exp[0] = mon < 4 ? '1' : mon < 7 ? '2' : mon < 10 ? '3' : '4'; + if (strcmp (out, exp) != 0) + { + printf ("nstrftime %%q: expected \"%s\", got \"%s\"\n", exp, out); + result = 1; + break; + } + } + + return result; +} + +int +main (void) +{ + int fail = 0; + fail |= posixtm_test (); + fail |= tzalloc_test (); + fail |= quarter_test (); + return fail; +} + +/* +Local Variables: +indent-tabs-mode: nil +End: +*/ diff --git a/gnulib-tests/test-once.c b/gnulib-tests/test-once.c new file mode 100644 index 0000000..271bea4 --- /dev/null +++ b/gnulib-tests/test-once.c @@ -0,0 +1,43 @@ +/* Test of once-only execution in multithreaded situations. + Copyright (C) 2018-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2018. */ + +#include <config.h> + +#include "glthread/lock.h" + +#include "macros.h" + +gl_once_define(static, a_once) + +static int a; + +static void +a_init (void) +{ + a = 42; +} + +int +main () +{ + gl_once (a_once, a_init); + + ASSERT (a == 42); + + return 0; +} diff --git a/gnulib-tests/test-open.c b/gnulib-tests/test-open.c new file mode 100644 index 0000000..30d9764 --- /dev/null +++ b/gnulib-tests/test-open.c @@ -0,0 +1,41 @@ +/* Test of opening a file descriptor. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <fcntl.h> + +#include "signature.h" +SIGNATURE_CHECK (open, int, (char const *, int, ...)); + +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <unistd.h> + +#include "macros.h" + +#define BASE "test-open.t" + +#include "test-open.h" + +int +main (void) +{ + return test_open (open, true); +} diff --git a/gnulib-tests/test-open.h b/gnulib-tests/test-open.h new file mode 100644 index 0000000..c57054f --- /dev/null +++ b/gnulib-tests/test-open.h @@ -0,0 +1,113 @@ +/* Test of opening a file descriptor. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +/* Make test_open always inline if we're using Fortify, which defines + __always_inline to do that. Do nothing otherwise. This works + around a glibc bug whereby 'open' cannot be used as a function + pointer when _FORTIFY_SOURCE is positive. */ + +#if __GLIBC__ && defined __always_inline +# define ALWAYS_INLINE __always_inline +#else +# define ALWAYS_INLINE +#endif + +/* This file is designed to test both open(n,buf[,mode]) and + openat(AT_FDCWD,n,buf[,mode]). FUNC is the function to test. + Assumes that BASE and ASSERT are already defined, and that + appropriate headers are already included. If PRINT, warn before + skipping symlink tests with status 77. */ + +static ALWAYS_INLINE int +test_open (int (*func) (char const *, int, ...), bool print) +{ + int fd; + + /* Remove anything from prior partial run. */ + unlink (BASE "file"); + unlink (BASE "e.exe"); + unlink (BASE "link"); + + /* Cannot create directory. */ + errno = 0; + ASSERT (func ("nonexist.ent/", O_CREAT | O_RDONLY, 0600) == -1); + ASSERT (errno == ENOTDIR || errno == EISDIR || errno == ENOENT + || errno == EINVAL); + + /* Create a regular file. */ + fd = func (BASE "file", O_CREAT | O_RDONLY, 0600); + ASSERT (0 <= fd); + ASSERT (close (fd) == 0); + + /* Create an executable regular file. */ + fd = func (BASE "e.exe", O_CREAT | O_RDONLY, 0700); + ASSERT (0 <= fd); + ASSERT (close (fd) == 0); + + /* Trailing slash handling. */ + errno = 0; + ASSERT (func (BASE "file/", O_RDONLY) == -1); + ASSERT (errno == ENOTDIR || errno == EISDIR || errno == EINVAL); + + /* Directories cannot be opened for writing. */ + errno = 0; + ASSERT (func (".", O_WRONLY) == -1); + ASSERT (errno == EISDIR || errno == EACCES); + + /* /dev/null must exist, and be writable. */ + fd = func ("/dev/null", O_RDONLY); + ASSERT (0 <= fd); + { + char c; + ASSERT (read (fd, &c, 1) == 0); + } + ASSERT (close (fd) == 0); + fd = func ("/dev/null", O_WRONLY); + ASSERT (0 <= fd); + ASSERT (write (fd, "c", 1) == 1); + ASSERT (close (fd) == 0); + + /* Although O_NONBLOCK on regular files can be ignored, it must not + cause a failure. */ + fd = func (BASE "file", O_NONBLOCK | O_RDONLY); + ASSERT (0 <= fd); + ASSERT (close (fd) == 0); + + /* Symlink handling, where supported. */ + if (symlink (BASE "file", BASE "link") != 0) + { + ASSERT (unlink (BASE "file") == 0); + if (print) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + errno = 0; + ASSERT (func (BASE "link/", O_RDONLY) == -1); + ASSERT (errno == ENOTDIR); + fd = func (BASE "link", O_RDONLY); + ASSERT (0 <= fd); + ASSERT (close (fd) == 0); + + /* Cleanup. */ + ASSERT (unlink (BASE "file") == 0); + ASSERT (unlink (BASE "e.exe") == 0); + ASSERT (unlink (BASE "link") == 0); + + return 0; +} diff --git a/gnulib-tests/test-openat-safer.c b/gnulib-tests/test-openat-safer.c new file mode 100644 index 0000000..dc98fbd --- /dev/null +++ b/gnulib-tests/test-openat-safer.c @@ -0,0 +1,125 @@ +/* Test that openat_safer leave standard fds alone. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include "fcntl--.h" + +#include <errno.h> +#include <stdio.h> +#include <sys/stat.h> +#include <unistd.h> + +/* This test intentionally closes stderr. So, we arrange to have fd 10 + (outside the range of interesting fd's during the test) set up to + duplicate the original stderr. */ + +#define BACKUP_STDERR_FILENO 10 +#define ASSERT_STREAM myerr +#include "macros.h" + +static FILE *myerr; + +#define witness "test-openat-safer.txt" + +int +main (void) +{ + int i; + int j; + int dfd; + int fd; + char buf[2]; + + /* We close fd 2 later, so save it in fd 10. */ + if (dup2 (STDERR_FILENO, BACKUP_STDERR_FILENO) != BACKUP_STDERR_FILENO + || (myerr = fdopen (BACKUP_STDERR_FILENO, "w")) == NULL) + return 2; + + /* Create handle for future use. */ + dfd = openat (AT_FDCWD, ".", O_RDONLY); + ASSERT (STDERR_FILENO < dfd); + + /* Create file for later checks. */ + remove (witness); + fd = openat (dfd, witness, O_WRONLY | O_CREAT | O_EXCL, 0600); + ASSERT (STDERR_FILENO < fd); + ASSERT (write (fd, "hi", 2) == 2); + ASSERT (close (fd) == 0); + + /* Four iterations, with progressively more standard descriptors + closed. */ + for (i = -1; i <= STDERR_FILENO; i++) + { + ASSERT (fchdir (dfd) == 0); + if (0 <= i) + ASSERT (close (i) == 0); + + /* Execute once in ".", once in "..". */ + for (j = 0; j <= 1; j++) + { + if (j) + ASSERT (chdir ("..") == 0); + + /* Check for error detection. */ + errno = 0; + ASSERT (openat (AT_FDCWD, "", O_RDONLY) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (openat (dfd, "", O_RDONLY) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (openat (-1, ".", O_RDONLY) == -1); + ASSERT (errno == EBADF); + + /* Check for trailing slash and /dev/null handling. */ + errno = 0; + ASSERT (openat (dfd, "nonexist.ent/", O_CREAT | O_RDONLY, + S_IRUSR | S_IWUSR) == -1); + ASSERT (errno == ENOTDIR || errno == EISDIR || errno == ENOENT + || errno == EINVAL); + errno = 0; + ASSERT (openat (dfd, witness "/", O_RDONLY) == -1); + ASSERT (errno == ENOTDIR || errno == EISDIR || errno == EINVAL); +#if defined __linux__ || defined __ANDROID__ + /* Using a bad directory is okay for absolute paths. */ + fd = openat (-1, "/dev/null", O_WRONLY); + ASSERT (STDERR_FILENO < fd); +#endif + /* Using a non-directory is wrong for relative paths. */ + errno = 0; + fd = open ("/dev/null", O_RDONLY); + ASSERT (STDERR_FILENO < fd); + ASSERT (openat (fd, ".", O_RDONLY) == -1); + ASSERT (errno == EBADF || errno == ENOTDIR); + ASSERT (close (fd) == 0); + + /* Check for our witness file. */ + fd = openat (dfd, witness, O_RDONLY | O_NOFOLLOW); + ASSERT (STDERR_FILENO < fd); + ASSERT (read (fd, buf, 2) == 2); + ASSERT (buf[0] == 'h' && buf[1] == 'i'); + ASSERT (close (fd) == 0); + } + } + ASSERT (fchdir (dfd) == 0); + ASSERT (unlink (witness) == 0); + ASSERT (close (dfd) == 0); + + return 0; +} diff --git a/gnulib-tests/test-openat.c b/gnulib-tests/test-openat.c new file mode 100644 index 0000000..2d7d747 --- /dev/null +++ b/gnulib-tests/test-openat.c @@ -0,0 +1,99 @@ +/* Test that openat works. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <fcntl.h> + +#include "signature.h" +SIGNATURE_CHECK (openat, int, (int, char const *, int, ...)); + +#include <errno.h> +#include <stdarg.h> +#include <stdbool.h> +#include <stdio.h> +#include <unistd.h> + +#include "macros.h" + +#define BASE "test-openat.t" + +#include "test-open.h" + +static int dfd = AT_FDCWD; + +/* Wrapper around openat to test open behavior. */ +static int +do_open (char const *name, int flags, ...) +{ + if (flags & O_CREAT) + { + mode_t mode = 0; + 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); + return openat (dfd, name, flags, mode); + } + return openat (dfd, name, flags); +} + +int +main (int argc _GL_UNUSED, char *argv[]) +{ + int result; + + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (openat (-1, "foo", O_RDONLY) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (openat (99, "foo", O_RDONLY) == -1); + ASSERT (errno == EBADF); + } + + /* Basic checks. */ + result = test_open (do_open, false); + dfd = open (".", O_RDONLY); + ASSERT (0 <= dfd); + ASSERT (test_open (do_open, false) == result); + ASSERT (close (dfd) == 0); + + /* Check that even when *-safer modules are in use, plain openat can + land in fd 0. Do this test last, since it is destructive to + stdin. */ + ASSERT (close (STDIN_FILENO) == 0); + ASSERT (openat (AT_FDCWD, ".", O_RDONLY) == STDIN_FILENO); + { + dfd = open (".", O_RDONLY); + ASSERT (STDIN_FILENO < dfd); + ASSERT (chdir ("..") == 0); + ASSERT (close (STDIN_FILENO) == 0); + ASSERT (openat (dfd, ".", O_RDONLY) == STDIN_FILENO); + ASSERT (close (dfd) == 0); + } + return result; +} diff --git a/gnulib-tests/test-parse-datetime.c b/gnulib-tests/test-parse-datetime.c new file mode 100644 index 0000000..920c9ae --- /dev/null +++ b/gnulib-tests/test-parse-datetime.c @@ -0,0 +1,452 @@ +/* Test of parse_datetime() function. + Copyright (C) 2008-2020 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, 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Simon Josefsson <simon@josefsson.org>, 2008. */ + +#include <config.h> + +#include "parse-datetime.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "macros.h" + +#ifdef DEBUG +#define LOG(str, now, res) \ + printf ("string '%s' diff %d %d\n", \ + str, res.tv_sec - now.tv_sec, res.tv_nsec - now.tv_nsec); +#else +#define LOG(str, now, res) (void) 0 +#endif + +static const char *const day_table[] = +{ + "SUNDAY", + "MONDAY", + "TUESDAY", + "WEDNESDAY", + "THURSDAY", + "FRIDAY", + "SATURDAY", + NULL +}; + + +#if ! HAVE_TM_GMTOFF +/* Shift A right by B bits portably, by dividing A by 2**B and + truncating towards minus infinity. A and B should be free of side + effects, and B should be in the range 0 <= B <= INT_BITS - 2, where + INT_BITS is the number of useful bits in an int. GNU code can + assume that INT_BITS is at least 32. + + ISO C99 says that A >> B is implementation-defined if A < 0. Some + implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift + right in the usual way when A < 0, so SHR falls back on division if + ordinary A >> B doesn't seem to be the usual signed shift. */ +#define SHR(a, b) \ + (-1 >> 1 == -1 \ + ? (a) >> (b) \ + : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0)) + +#define TM_YEAR_BASE 1900 + +/* Yield the difference between *A and *B, + measured in seconds, ignoring leap seconds. + The body of this function is taken directly from the GNU C Library; + see src/strftime.c. */ +static long int +tm_diff (struct tm const *a, struct tm const *b) +{ + /* Compute intervening leap days correctly even if year is negative. + Take care to avoid int overflow in leap day calculations. */ + int a4 = SHR (a->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (a->tm_year & 3); + int b4 = SHR (b->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (b->tm_year & 3); + int a100 = a4 / 25 - (a4 % 25 < 0); + int b100 = b4 / 25 - (b4 % 25 < 0); + int a400 = SHR (a100, 2); + int b400 = SHR (b100, 2); + int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400); + long int ayear = a->tm_year; + long int years = ayear - b->tm_year; + long int days = (365 * years + intervening_leap_days + + (a->tm_yday - b->tm_yday)); + return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour)) + + (a->tm_min - b->tm_min)) + + (a->tm_sec - b->tm_sec)); +} +#endif /* ! HAVE_TM_GMTOFF */ + +static long +gmt_offset (time_t s) +{ + long gmtoff; + +#if !HAVE_TM_GMTOFF + struct tm tm_local = *localtime (&s); + struct tm tm_gmt = *gmtime (&s); + + gmtoff = tm_diff (&tm_local, &tm_gmt); +#else + gmtoff = localtime (&s)->tm_gmtoff; +#endif + + return gmtoff; +} + +int +main (int argc _GL_UNUSED, char **argv) +{ + struct timespec result; + struct timespec result2; + struct timespec expected; + struct timespec now; + const char *p; + int i; + long gmtoff; + time_t ref_time = 1304250918; + + /* Set the time zone to US Eastern time with the 2012 rules. This + should disable any leap second support. Otherwise, there will be + a problem with glibc on sites that default to leap seconds; see + <https://bugs.gnu.org/12206>. */ + setenv ("TZ", "EST5EDT,M3.2.0,M11.1.0", 1); + + gmtoff = gmt_offset (ref_time); + + + /* ISO 8601 extended date and time of day representation, + 'T' separator, local time zone */ + p = "2011-05-01T11:55:18"; + expected.tv_sec = ref_time - gmtoff; + expected.tv_nsec = 0; + ASSERT (parse_datetime (&result, p, 0)); + LOG (p, expected, result); + ASSERT (expected.tv_sec == result.tv_sec + && expected.tv_nsec == result.tv_nsec); + + /* ISO 8601 extended date and time of day representation, + ' ' separator, local time zone */ + p = "2011-05-01 11:55:18"; + expected.tv_sec = ref_time - gmtoff; + expected.tv_nsec = 0; + ASSERT (parse_datetime (&result, p, 0)); + LOG (p, expected, result); + ASSERT (expected.tv_sec == result.tv_sec + && expected.tv_nsec == result.tv_nsec); + + + /* ISO 8601, extended date and time of day representation, + 'T' separator, UTC */ + p = "2011-05-01T11:55:18Z"; + expected.tv_sec = ref_time; + expected.tv_nsec = 0; + ASSERT (parse_datetime (&result, p, 0)); + LOG (p, expected, result); + ASSERT (expected.tv_sec == result.tv_sec + && expected.tv_nsec == result.tv_nsec); + + /* ISO 8601, extended date and time of day representation, + ' ' separator, UTC */ + p = "2011-05-01 11:55:18Z"; + expected.tv_sec = ref_time; + expected.tv_nsec = 0; + ASSERT (parse_datetime (&result, p, 0)); + LOG (p, expected, result); + ASSERT (expected.tv_sec == result.tv_sec + && expected.tv_nsec == result.tv_nsec); + + + /* ISO 8601 extended date and time of day representation, + 'T' separator, w/UTC offset */ + p = "2011-05-01T11:55:18-07:00"; + expected.tv_sec = 1304276118; + expected.tv_nsec = 0; + ASSERT (parse_datetime (&result, p, 0)); + LOG (p, expected, result); + ASSERT (expected.tv_sec == result.tv_sec + && expected.tv_nsec == result.tv_nsec); + + /* ISO 8601 extended date and time of day representation, + ' ' separator, w/UTC offset */ + p = "2011-05-01 11:55:18-07:00"; + expected.tv_sec = 1304276118; + expected.tv_nsec = 0; + ASSERT (parse_datetime (&result, p, 0)); + LOG (p, expected, result); + ASSERT (expected.tv_sec == result.tv_sec + && expected.tv_nsec == result.tv_nsec); + + + /* ISO 8601 extended date and time of day representation, + 'T' separator, w/hour only UTC offset */ + p = "2011-05-01T11:55:18-07"; + expected.tv_sec = 1304276118; + expected.tv_nsec = 0; + ASSERT (parse_datetime (&result, p, 0)); + LOG (p, expected, result); + ASSERT (expected.tv_sec == result.tv_sec + && expected.tv_nsec == result.tv_nsec); + + /* ISO 8601 extended date and time of day representation, + ' ' separator, w/hour only UTC offset */ + p = "2011-05-01 11:55:18-07"; + expected.tv_sec = 1304276118; + expected.tv_nsec = 0; + ASSERT (parse_datetime (&result, p, 0)); + LOG (p, expected, result); + ASSERT (expected.tv_sec == result.tv_sec + && expected.tv_nsec == result.tv_nsec); + + + now.tv_sec = 4711; + now.tv_nsec = 1267; + p = "now"; + ASSERT (parse_datetime (&result, p, &now)); + LOG (p, now, result); + ASSERT (now.tv_sec == result.tv_sec && now.tv_nsec == result.tv_nsec); + + now.tv_sec = 4711; + now.tv_nsec = 1267; + p = "tomorrow"; + ASSERT (parse_datetime (&result, p, &now)); + LOG (p, now, result); + ASSERT (now.tv_sec + 24 * 60 * 60 == result.tv_sec + && now.tv_nsec == result.tv_nsec); + + now.tv_sec = 4711; + now.tv_nsec = 1267; + p = "yesterday"; + ASSERT (parse_datetime (&result, p, &now)); + LOG (p, now, result); + ASSERT (now.tv_sec - 24 * 60 * 60 == result.tv_sec + && now.tv_nsec == result.tv_nsec); + + now.tv_sec = 4711; + now.tv_nsec = 1267; + p = "4 hours"; + ASSERT (parse_datetime (&result, p, &now)); + LOG (p, now, result); + ASSERT (now.tv_sec + 4 * 60 * 60 == result.tv_sec + && now.tv_nsec == result.tv_nsec); + + /* test if timezone is not being ignored for day offset */ + now.tv_sec = 4711; + now.tv_nsec = 1267; + p = "UTC+400 +24 hours"; + ASSERT (parse_datetime (&result, p, &now)); + LOG (p, now, result); + p = "UTC+400 +1 day"; + ASSERT (parse_datetime (&result2, p, &now)); + LOG (p, now, result2); + ASSERT (result.tv_sec == result2.tv_sec + && result.tv_nsec == result2.tv_nsec); + + /* test if several time zones formats are handled same way */ + now.tv_sec = 4711; + now.tv_nsec = 1267; + p = "UTC+14:00"; + ASSERT (parse_datetime (&result, p, &now)); + LOG (p, now, result); + p = "UTC+14"; + ASSERT (parse_datetime (&result2, p, &now)); + LOG (p, now, result2); + ASSERT (result.tv_sec == result2.tv_sec + && result.tv_nsec == result2.tv_nsec); + p = "UTC+1400"; + ASSERT (parse_datetime (&result2, p, &now)); + LOG (p, now, result2); + ASSERT (result.tv_sec == result2.tv_sec + && result.tv_nsec == result2.tv_nsec); + + now.tv_sec = 4711; + now.tv_nsec = 1267; + p = "UTC-14:00"; + ASSERT (parse_datetime (&result, p, &now)); + LOG (p, now, result); + p = "UTC-14"; + ASSERT (parse_datetime (&result2, p, &now)); + LOG (p, now, result2); + ASSERT (result.tv_sec == result2.tv_sec + && result.tv_nsec == result2.tv_nsec); + p = "UTC-1400"; + ASSERT (parse_datetime (&result2, p, &now)); + LOG (p, now, result2); + ASSERT (result.tv_sec == result2.tv_sec + && result.tv_nsec == result2.tv_nsec); + + now.tv_sec = 4711; + now.tv_nsec = 1267; + p = "UTC+0:15"; + ASSERT (parse_datetime (&result, p, &now)); + LOG (p, now, result); + p = "UTC+0015"; + ASSERT (parse_datetime (&result2, p, &now)); + LOG (p, now, result2); + ASSERT (result.tv_sec == result2.tv_sec + && result.tv_nsec == result2.tv_nsec); + + now.tv_sec = 4711; + now.tv_nsec = 1267; + p = "UTC-1:30"; + ASSERT (parse_datetime (&result, p, &now)); + LOG (p, now, result); + p = "UTC-130"; + ASSERT (parse_datetime (&result2, p, &now)); + LOG (p, now, result2); + ASSERT (result.tv_sec == result2.tv_sec + && result.tv_nsec == result2.tv_nsec); + + + /* TZ out of range should cause parse_datetime failure */ + now.tv_sec = 4711; + now.tv_nsec = 1267; + p = "UTC+25:00"; + ASSERT (!parse_datetime (&result, p, &now)); + + /* Check for several invalid countable dayshifts */ + now.tv_sec = 4711; + now.tv_nsec = 1267; + p = "UTC+4:00 +40 yesterday"; + ASSERT (!parse_datetime (&result, p, &now)); + p = "UTC+4:00 next yesterday"; + ASSERT (!parse_datetime (&result, p, &now)); + p = "UTC+4:00 tomorrow ago"; + ASSERT (!parse_datetime (&result, p, &now)); + p = "UTC+4:00 tomorrow hence"; + ASSERT (!parse_datetime (&result, p, &now)); + p = "UTC+4:00 40 now ago"; + ASSERT (!parse_datetime (&result, p, &now)); + p = "UTC+4:00 last tomorrow"; + ASSERT (!parse_datetime (&result, p, &now)); + p = "UTC+4:00 -4 today"; + ASSERT (!parse_datetime (&result, p, &now)); + + /* And check correct usage of dayshifts */ + now.tv_sec = 4711; + now.tv_nsec = 1267; + p = "UTC+400 tomorrow"; + ASSERT (parse_datetime (&result, p, &now)); + LOG (p, now, result); + p = "UTC+400 +1 day"; + ASSERT (parse_datetime (&result2, p, &now)); + LOG (p, now, result2); + ASSERT (result.tv_sec == result2.tv_sec + && result.tv_nsec == result2.tv_nsec); + p = "UTC+400 1 day hence"; + ASSERT (parse_datetime (&result2, p, &now)); + LOG (p, now, result2); + ASSERT (result.tv_sec == result2.tv_sec + && result.tv_nsec == result2.tv_nsec); + now.tv_sec = 4711; + now.tv_nsec = 1267; + p = "UTC+400 yesterday"; + ASSERT (parse_datetime (&result, p, &now)); + LOG (p, now, result); + p = "UTC+400 1 day ago"; + ASSERT (parse_datetime (&result2, p, &now)); + LOG (p, now, result2); + ASSERT (result.tv_sec == result2.tv_sec + && result.tv_nsec == result2.tv_nsec); + now.tv_sec = 4711; + now.tv_nsec = 1267; + p = "UTC+400 now"; + ASSERT (parse_datetime (&result, p, &now)); + LOG (p, now, result); + p = "UTC+400 +0 minutes"; /* silly, but simple "UTC+400" is different*/ + ASSERT (parse_datetime (&result2, p, &now)); + LOG (p, now, result2); + ASSERT (result.tv_sec == result2.tv_sec + && result.tv_nsec == result2.tv_nsec); + + /* Check that some "next Monday", "last Wednesday", etc. are correct. */ + setenv ("TZ", "UTC0", 1); + for (i = 0; day_table[i]; i++) + { + unsigned int thur2 = 7 * 24 * 3600; /* 2nd thursday */ + char tmp[32]; + sprintf (tmp, "NEXT %s", day_table[i]); + now.tv_sec = thur2 + 4711; + now.tv_nsec = 1267; + ASSERT (parse_datetime (&result, tmp, &now)); + LOG (tmp, now, result); + ASSERT (result.tv_nsec == 0); + ASSERT (result.tv_sec == thur2 + (i == 4 ? 7 : (i + 3) % 7) * 24 * 3600); + + sprintf (tmp, "LAST %s", day_table[i]); + now.tv_sec = thur2 + 4711; + now.tv_nsec = 1267; + ASSERT (parse_datetime (&result, tmp, &now)); + LOG (tmp, now, result); + ASSERT (result.tv_nsec == 0); + ASSERT (result.tv_sec == thur2 + ((i + 3) % 7 - 7) * 24 * 3600); + } + + p = "THURSDAY UTC+00"; /* The epoch was on Thursday. */ + now.tv_sec = 0; + now.tv_nsec = 0; + ASSERT (parse_datetime (&result, p, &now)); + LOG (p, now, result); + ASSERT (result.tv_sec == now.tv_sec + && result.tv_nsec == now.tv_nsec); + + p = "FRIDAY UTC+00"; + now.tv_sec = 0; + now.tv_nsec = 0; + ASSERT (parse_datetime (&result, p, &now)); + LOG (p, now, result); + ASSERT (result.tv_sec == 24 * 3600 + && result.tv_nsec == now.tv_nsec); + + /* Exercise a sign-extension bug. Before July 2012, an input + starting with a high-bit-set byte would be treated like "0". */ + ASSERT ( ! parse_datetime (&result, "\xb0", &now)); + + /* Exercise TZ="" parsing code. */ + /* These two would infloop or segfault before Feb 2014. */ + ASSERT ( ! parse_datetime (&result, "TZ=\"\"\"", &now)); + ASSERT ( ! parse_datetime (&result, "TZ=\"\" \"", &now)); + /* Exercise invalid patterns. */ + ASSERT ( ! parse_datetime (&result, "TZ=\"", &now)); + ASSERT ( ! parse_datetime (&result, "TZ=\"\\\"", &now)); + ASSERT ( ! parse_datetime (&result, "TZ=\"\\n", &now)); + ASSERT ( ! parse_datetime (&result, "TZ=\"\\n\"", &now)); + /* Exercise valid patterns. */ + ASSERT ( parse_datetime (&result, "TZ=\"\"", &now)); + ASSERT ( parse_datetime (&result, "TZ=\"\" ", &now)); + ASSERT ( parse_datetime (&result, " TZ=\"\"", &now)); + ASSERT ( parse_datetime (&result, "TZ=\"\\\\\"", &now)); + ASSERT ( parse_datetime (&result, "TZ=\"\\\"\"", &now)); + + /* Outlandishly-long time zone abbreviations should not cause problems. */ + { + static char const bufprefix[] = "TZ=\""; + enum { tzname_len = 2000 }; + static char const bufsuffix[] = "0\" 1970-01-01 01:02:03.123456789"; + enum { bufsize = sizeof bufprefix - 1 + tzname_len + sizeof bufsuffix }; + char buf[bufsize]; + memcpy (buf, bufprefix, sizeof bufprefix - 1); + memset (buf + sizeof bufprefix - 1, 'X', tzname_len); + strcpy (buf + bufsize - sizeof bufsuffix, bufsuffix); + ASSERT (parse_datetime (&result, buf, &now)); + LOG (buf, now, result); + ASSERT (result.tv_sec == 1 * 60 * 60 + 2 * 60 + 3 + && result.tv_nsec == 123456789); + } + + return 0; +} diff --git a/gnulib-tests/test-pathmax.c b/gnulib-tests/test-pathmax.c new file mode 100644 index 0000000..3c4bd56 --- /dev/null +++ b/gnulib-tests/test-pathmax.c @@ -0,0 +1,32 @@ +/* Test of "pathmax.h". + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2011. */ + +#include <config.h> + +#include "pathmax.h" + +/* Check that PATH_MAX is a constant if it is defined. */ +#ifdef PATH_MAX +int a = PATH_MAX; +#endif + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tests/test-perror.c b/gnulib-tests/test-perror.c new file mode 100644 index 0000000..a6263f2 --- /dev/null +++ b/gnulib-tests/test-perror.c @@ -0,0 +1,36 @@ +/* Test of perror() function. + Copyright (C) 2008-2020 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, 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (perror, void, (char const *)); + +#include <errno.h> + +int +main (int argc, char **argv) +{ + const char *prefix = (argc > 1 ? argv[1] : NULL); + + errno = EACCES; perror (prefix); + errno = ETIMEDOUT; perror (prefix); + errno = EOVERFLOW; perror (prefix); + + return 0; +} diff --git a/gnulib-tests/test-perror.sh b/gnulib-tests/test-perror.sh new file mode 100755 index 0000000..e776609 --- /dev/null +++ b/gnulib-tests/test-perror.sh @@ -0,0 +1,26 @@ +#!/bin/sh +: ${srcdir=.} +. "$srcdir/init.sh"; path_prepend_ . + +# Test NULL prefix. Result should not contain a number, except in lines that +# start with 'EDC' (IBM z/OS libc produces an error identifier before the +# error message). +${CHECKER} test-perror 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror.tmp +grep -v '^EDC' t-perror.tmp | grep '[0-9]' > /dev/null \ + && fail_ "result should not contain a number" + +# Test empty prefix. Result should be the same. +${CHECKER} test-perror '' 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror1.tmp +diff t-perror.tmp t-perror1.tmp \ + || fail_ "empty prefix should behave like NULL argument" + +# Test non-empty prefix. +${CHECKER} test-perror foo 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror3.tmp +sed -e 's/^/foo: /' < t-perror.tmp > t-perror2.tmp +diff t-perror2.tmp t-perror3.tmp || fail_ "prefix applied incorrectly" + +# Test exit status. +${CHECKER} test-perror >out 2>/dev/null || fail_ "unexpected exit status" +test -s out && fail_ "unexpected output" + +Exit 0 diff --git a/gnulib-tests/test-perror2.c b/gnulib-tests/test-perror2.c new file mode 100644 index 0000000..1d14eda --- /dev/null +++ b/gnulib-tests/test-perror2.c @@ -0,0 +1,136 @@ +/* Test of perror() function. + Copyright (C) 2011-2020 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, 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdio.h> + +#include <errno.h> +#include <string.h> +#include <unistd.h> + +/* This test intentionally parses stderr. So, we arrange to have fd 10 + (outside the range of interesting fd's during the test) set up to + duplicate the original stderr. */ +#define BACKUP_STDERR_FILENO 10 +#define ASSERT_STREAM myerr +#include "macros.h" + +static FILE *myerr; + +#define BASE "test-perror2" + +int +main (void) +{ + /* We change fd 2 later, so save it in fd 10. */ + if (dup2 (STDERR_FILENO, BACKUP_STDERR_FILENO) != BACKUP_STDERR_FILENO + || (myerr = fdopen (BACKUP_STDERR_FILENO, "w")) == NULL) + return 2; + + ASSERT (freopen (BASE ".tmp", "w+", stderr) == stderr); + + /* Test that perror does not clobber strerror buffer. */ + { + const char *msg1; + const char *msg2; + const char *msg3; + const char *msg4; + char *str1; + char *str2; + char *str3; + char *str4; + + msg1 = strerror (ENOENT); + ASSERT (msg1); + str1 = strdup (msg1); + ASSERT (str1); + + msg2 = strerror (ERANGE); + ASSERT (msg2); + str2 = strdup (msg2); + ASSERT (str2); + + msg3 = strerror (-4); + ASSERT (msg3); + str3 = strdup (msg3); + ASSERT (str3); + + msg4 = strerror (1729576); + ASSERT (msg4); + str4 = strdup (msg4); + ASSERT (str4); + + errno = EACCES; + perror (""); + errno = -5; + perror (""); + ASSERT (!ferror (stderr)); + ASSERT (msg1 == msg2 || msg1 == msg4 || STREQ (msg1, str1)); + ASSERT (msg2 == msg4 || STREQ (msg2, str2)); + ASSERT (msg3 == msg4 || STREQ (msg3, str3)); + ASSERT (STREQ (msg4, str4)); + + free (str1); + free (str2); + free (str3); + free (str4); + } + + /* Test that perror uses the same message as strerror. */ + { + int errs[] = { EACCES, 0, -3, }; + int i; + for (i = 0; i < SIZEOF (errs); i++) + { + char buf[256]; + char *err = strerror (errs[i]); + + ASSERT (err); + ASSERT (strlen (err) < sizeof buf); + rewind (stderr); + ASSERT (ftruncate (fileno (stderr), 0) == 0); + errno = errs[i]; + perror (NULL); + ASSERT (!ferror (stderr)); + rewind (stderr); + ASSERT (fgets (buf, sizeof buf, stderr) == buf); + ASSERT (strstr (buf, err)); + } + } + + /* Test that perror reports write failure. */ + { + ASSERT (freopen (BASE ".tmp", "r", stderr) == stderr); + ASSERT (setvbuf (stderr, NULL, _IONBF, BUFSIZ) == 0); + errno = -1; + ASSERT (!ferror (stderr)); + perror (NULL); +#if 0 + /* Commented out until cygwin behaves: + https://sourceware.org/ml/newlib/2011/msg00228.html */ + ASSERT (errno > 0); + /* Commented out until glibc behaves: + https://sourceware.org/bugzilla/show_bug.cgi?id=12792 */ + ASSERT (ferror (stderr)); +#endif + } + + ASSERT (fclose (stderr) == 0); + ASSERT (remove (BASE ".tmp") == 0); + + return 0; +} diff --git a/gnulib-tests/test-pipe.c b/gnulib-tests/test-pipe.c new file mode 100644 index 0000000..36ff480 --- /dev/null +++ b/gnulib-tests/test-pipe.c @@ -0,0 +1,108 @@ +/* Test of pipe. + Copyright (C) 2009-2020 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, 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (pipe, int, (int[2])); + +#include <fcntl.h> +#include <stdbool.h> + +#if defined _WIN32 && ! defined __CYGWIN__ +/* Get declarations of the native Windows API functions. */ +# define WIN32_LEAN_AND_MEAN +# include <windows.h> +/* Get _get_osfhandle. */ +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include <io.h> +# endif +#endif + +#include "binary-io.h" +#include "macros.h" + +/* Return true if FD is open. */ +static bool +is_open (int fd) +{ +#if defined _WIN32 && ! defined __CYGWIN__ + /* On native Windows, 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 +} + +/* Return true if FD is not inherited to child processes. */ +static bool +is_cloexec (int fd) +{ +#if defined _WIN32 && ! defined __CYGWIN__ + HANDLE h = (HANDLE) _get_osfhandle (fd); + DWORD flags; + ASSERT (GetHandleInformation (h, &flags)); + return (flags & HANDLE_FLAG_INHERIT) == 0; +#else + int flags; + ASSERT ((flags = fcntl (fd, F_GETFD)) >= 0); + return (flags & FD_CLOEXEC) != 0; +#endif +} + +/* Return true if FD is in non-blocking mode. */ +static bool +is_nonblocking (int fd) +{ +#if defined _WIN32 && ! defined __CYGWIN__ + /* We don't use the non-blocking mode for sockets here. */ + return 0; +#else + int flags; + ASSERT ((flags = fcntl (fd, F_GETFL)) >= 0); + return (flags & O_NONBLOCK) != 0; +#endif +} + +int +main () +{ + int fd[2]; + + fd[0] = -1; + fd[1] = -1; + ASSERT (pipe (fd) >= 0); + ASSERT (fd[0] >= 0); + ASSERT (fd[1] >= 0); + ASSERT (fd[0] != fd[1]); + ASSERT (is_open (fd[0])); + ASSERT (is_open (fd[1])); + ASSERT (!is_cloexec (fd[0])); + ASSERT (!is_cloexec (fd[1])); + ASSERT (!is_nonblocking (fd[0])); + ASSERT (!is_nonblocking (fd[1])); + + return 0; +} diff --git a/gnulib-tests/test-pipe2.c b/gnulib-tests/test-pipe2.c new file mode 100644 index 0000000..0c08b0d --- /dev/null +++ b/gnulib-tests/test-pipe2.c @@ -0,0 +1,147 @@ +/* Test of pipe2. + Copyright (C) 2009-2020 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, 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (pipe2, int, (int[2], int)); + +#include <fcntl.h> +#include <stdbool.h> + +#if defined _WIN32 && ! defined __CYGWIN__ +/* Get declarations of the native Windows API functions. */ +# define WIN32_LEAN_AND_MEAN +# include <windows.h> +/* Get _get_osfhandle. */ +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include <io.h> +# endif +#endif + +#include "binary-io.h" +#include "macros.h" +#if GNULIB_NONBLOCKING +# include "nonblocking.h" +#endif + +/* Return true if FD is open. */ +static bool +is_open (int fd) +{ +#if defined _WIN32 && ! defined __CYGWIN__ + /* On native Windows, 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 +} + +/* Return true if FD is not inherited to child processes. */ +static bool +is_cloexec (int fd) +{ +#if defined _WIN32 && ! defined __CYGWIN__ + HANDLE h = (HANDLE) _get_osfhandle (fd); + DWORD flags; + ASSERT (GetHandleInformation (h, &flags)); + return (flags & HANDLE_FLAG_INHERIT) == 0; +#else + int flags; + ASSERT ((flags = fcntl (fd, F_GETFD)) >= 0); + return (flags & FD_CLOEXEC) != 0; +#endif +} + +#if ! GNULIB_NONBLOCKING +static int +get_nonblocking_flag (int fd) +{ +# if defined _WIN32 && ! defined __CYGWIN__ + return 0; +# else +# ifndef F_GETFL +# error Please port fcntl to your platform +# endif + int flags; + ASSERT ((flags = fcntl (fd, F_GETFL)) >= 0); + return (flags & O_NONBLOCK) != 0; +# endif +} +#endif + +int +main () +{ + int use_nonblocking; + int use_cloexec; + + for (use_nonblocking = 0; use_nonblocking <= !!O_NONBLOCK; use_nonblocking++) + for (use_cloexec = 0; use_cloexec <= !!O_CLOEXEC; use_cloexec++) + { + int o_flags; + int fd[2]; + + o_flags = 0; + if (use_nonblocking) + o_flags |= O_NONBLOCK; + if (use_cloexec) + o_flags |= O_CLOEXEC; + + fd[0] = -1; + fd[1] = -1; + ASSERT (pipe2 (fd, o_flags) >= 0); + ASSERT (fd[0] >= 0); + ASSERT (fd[1] >= 0); + ASSERT (fd[0] != fd[1]); + ASSERT (is_open (fd[0])); + ASSERT (is_open (fd[1])); + if (use_cloexec) + { + ASSERT (is_cloexec (fd[0])); + ASSERT (is_cloexec (fd[1])); + } + else + { + ASSERT (!is_cloexec (fd[0])); + ASSERT (!is_cloexec (fd[1])); + } + if (use_nonblocking) + { + ASSERT (get_nonblocking_flag (fd[0]) == 1); + ASSERT (get_nonblocking_flag (fd[1]) == 1); + } + else + { + ASSERT (get_nonblocking_flag (fd[0]) == 0); + ASSERT (get_nonblocking_flag (fd[1]) == 0); + } + + ASSERT (close (fd[0]) == 0); + ASSERT (close (fd[1]) == 0); + } + + return 0; +} diff --git a/gnulib-tests/test-posixtm.c b/gnulib-tests/test-posixtm.c new file mode 100644 index 0000000..d9972a6 --- /dev/null +++ b/gnulib-tests/test-posixtm.c @@ -0,0 +1,191 @@ +/* Test that posixtime works as required. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Jim Meyering. */ + +#include <config.h> + +#include "posixtm.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdint.h> +#include <time.h> + +#include "intprops.h" +#include "macros.h" + +struct posixtm_test +{ + char const *in; + unsigned int syntax_bits; + bool valid; + int_least64_t t_expected; +}; + +/* Test mainly with syntax_bits == LY. */ +enum { LY = PDS_CENTURY | PDS_SECONDS }; + +static struct posixtm_test const T[] = + { + /* no year specified; cross-check via another posixtime call */ + { "12131415.16", LY, 1, 0}, /* ??? Dec 13 14:15:16 ???? */ + { "12131415", LY, 1, 0}, /* ??? Dec 13 14:15:00 ???? */ + + /* These two tests fail on 64-bit Solaris up through at least + Solaris 10, which is off by one day for timestamps before + 0001-01-01 00:00:00 UTC. */ + { "000001010000.00", LY, 1, + - INT64_C (62167219200)},/* Sat Jan 1 00:00:00 0 */ + { "000012312359.59", LY, 1, + - INT64_C (62135596801)},/* Fri Dec 31 23:59:59 0 */ + + { "000101010000.00", LY, 1, + - INT64_C (62135596800)},/* Sat Jan 1 00:00:00 1 */ + { "190112132045.51", LY, 1, + - INT64_C (2147483649)},/* Fri Dec 13 20:45:51 1901 */ + { "190112132045.52", LY, 1, + - INT64_C (2147483648)},/* Fri Dec 13 20:45:52 1901 */ + { "190112132045.53", LY, 1, -2147483647}, /* Fri Dec 13 20:45:53 1901 */ + { "190112132046.52", LY, 1, -2147483588}, /* Fri Dec 13 20:46:52 1901 */ + { "190112132145.52", LY, 1, -2147480048}, /* Fri Dec 13 21:45:52 1901 */ + { "190112142045.52", LY, 1, -2147397248}, /* Sat Dec 14 20:45:52 1901 */ + { "190201132045.52", LY, 1, -2144805248}, /* Mon Jan 13 20:45:52 1902 */ + { "196912312359.59", LY, 1, -1}, /* Wed Dec 31 23:59:59 1969 */ + { "197001010000.00", LY, 1, 0}, /* Thu Jan 1 00:00:00 1970 */ + { "197001010000.01", LY, 1, 1}, /* Thu Jan 1 00:00:01 1970 */ + { "197001010001.00", LY, 1, 60}, /* Thu Jan 1 00:01:00 1970 */ + { "197001010000.60", LY, 1, 60}, /* Thu Jan 1 00:01:00 1970 */ + { "197001010100.00", LY, 1, 3600}, /* Thu Jan 1 01:00:00 1970 */ + { "197001020000.00", LY, 1, 86400}, /* Fri Jan 2 00:00:00 1970 */ + { "197002010000.00", LY, 1, 2678400}, /* Sun Feb 1 00:00:00 1970 */ + { "197101010000.00", LY, 1, 31536000}, /* Fri Jan 1 00:00:00 1971 */ + { "197001000000.00", LY, 0, 0}, /* -- */ + { "197000010000.00", LY, 0, 0}, /* -- */ + { "197001010060.00", LY, 0, 0}, /* -- */ + { "197001012400.00", LY, 0, 0}, /* -- */ + { "197001320000.00", LY, 0, 0}, /* -- */ + { "197013010000.00", LY, 0, 0}, /* -- */ + { "203801190314.06", LY, 1, 2147483646}, /* Tue Jan 19 03:14:06 2038 */ + { "203801190314.07", LY, 1, 2147483647}, /* Tue Jan 19 03:14:07 2038 */ + { "203801190314.08", LY, 1, + INT64_C ( 2147483648)},/* Tue Jan 19 03:14:08 2038 */ + { "999912312359.59", LY, 1, + INT64_C (253402300799)},/* Fri Dec 31 23:59:59 9999 */ + { "1112131415", LY, 1, 1323785700}, /* Tue Dec 13 14:15:00 2011 */ + { "1112131415.16", LY, 1, 1323785716}, /* Tue Dec 13 14:15:16 2011 */ + { "201112131415.16", LY, 1, 1323785716}, /* Tue Dec 13 14:15:16 2011 */ + { "191112131415.16", LY, 1, -1831974284}, /* Wed Dec 13 14:15:16 1911 */ + { "203712131415.16", LY, 1, 2144326516}, /* Sun Dec 13 14:15:16 2037 */ + { "3712131415.16", LY, 1, 2144326516}, /* Sun Dec 13 14:15:16 2037 */ + { "6812131415.16", LY, 1, + INT64_C ( 3122633716)},/* Thu Dec 13 14:15:16 2068 */ + { "6912131415.16", LY, 1, -1590284}, /* Sat Dec 13 14:15:16 1969 */ + { "7012131415.16", LY, 1, 29945716}, /* Sun Dec 13 14:15:16 1970 */ + { "1213141599", PDS_TRAILING_YEAR, + 1, 945094500}, /* Mon Dec 13 14:15:00 1999 */ + { "1213141500", PDS_TRAILING_YEAR, + 1, 976716900}, /* Wed Dec 13 14:15:00 2000 */ + { NULL, 0, 0, 0} + }; + +int +main (void) +{ + unsigned int i; + int fail = 0; + char curr_year_str[30]; + struct tm *tm; + time_t t_now; + int err; + size_t n_bytes; + + /* The above test data requires Universal Time, e.g., TZ="UTC0". */ + err = setenv ("TZ", "UTC0", 1); + ASSERT (err == 0); + + t_now = time (NULL); + ASSERT (t_now != (time_t) -1); + tm = localtime (&t_now); + ASSERT (tm); + n_bytes = strftime (curr_year_str, sizeof curr_year_str, "%Y", tm); + ASSERT (0 < n_bytes); + + for (i = 0; T[i].in; i++) + { + time_t t_out; + time_t t_exp; + bool ok; + + /* Some tests assume that time_t is signed. + If it is unsigned and the result is negative, skip the test. */ + if (T[i].t_expected < 0 && ! TYPE_SIGNED (time_t)) + { + printf ("skipping %s: result is negative, " + "but your time_t is unsigned\n", T[i].in); + continue; + } + + if (! (TYPE_MINIMUM (time_t) <= T[i].t_expected + && T[i].t_expected <= TYPE_MAXIMUM (time_t))) + { + printf ("skipping %s: result is out of range of your time_t\n", + T[i].in); + continue; + } + + t_exp = T[i].t_expected; + + /* If an input string does not specify the year number, determine + the expected output by calling posixtime with an otherwise + equivalent string that starts with the current year. */ + if (8 <= strlen (T[i].in) + && (T[i].in[8] == '.' || T[i].in[8] == '\0')) + { + char tmp_buf[20]; + stpcpy (stpcpy (tmp_buf, curr_year_str), T[i].in); + ASSERT (posixtime (&t_exp, tmp_buf, T[i].syntax_bits)); + } + + ok = posixtime (&t_out, T[i].in, T[i].syntax_bits); + if (ok != !!T[i].valid) + { + printf ("%s return value mismatch: got %d, expected %d\n", + T[i].in, !!ok, T[i].valid); + fail = 1; + continue; + } + + if (!ok) + continue; + + if (t_out != t_exp) + { + printf ("%s mismatch (-: actual; +:expected)\n-%12ld\n+%12ld\n", + T[i].in, t_out, t_exp); + fail = 1; + } + } + + return fail; +} + +/* +Local Variables: +indent-tabs-mode: nil +End: +*/ diff --git a/gnulib-tests/test-printf-frexp.c b/gnulib-tests/test-printf-frexp.c new file mode 100644 index 0000000..8bacb89 --- /dev/null +++ b/gnulib-tests/test-printf-frexp.c @@ -0,0 +1,119 @@ +/* Test of splitting a double into fraction and mantissa. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include "printf-frexp.h" + +#include <float.h> + +#include "macros.h" + +static double +my_ldexp (double x, int d) +{ + for (; d > 0; d--) + x *= 2.0; + for (; d < 0; d++) + x *= 0.5; + return x; +} + +int +main () +{ + int i; + /* The use of 'volatile' guarantees that excess precision bits are dropped + when dealing with denormalized numbers. It is necessary on x86 systems + where double-floats are not IEEE compliant by default, to avoid that the + results become platform and compiler option dependent. 'volatile' is a + portable alternative to gcc's -ffloat-store option. */ + volatile double x; + + for (i = 1, x = 1.0; i <= DBL_MAX_EXP; i++, x *= 2.0) + { + int exp = -9999; + double mantissa = printf_frexp (x, &exp); + ASSERT (exp == i - 1); + ASSERT (mantissa == 1.0); + } + for (i = 1, x = 1.0; i >= DBL_MIN_EXP; i--, x *= 0.5) + { + int exp = -9999; + double mantissa = printf_frexp (x, &exp); + ASSERT (exp == i - 1); + ASSERT (mantissa == 1.0); + } + for (; i >= DBL_MIN_EXP - 100 && x > 0.0; i--, x *= 0.5) + { + int exp = -9999; + double mantissa = printf_frexp (x, &exp); + ASSERT (exp == DBL_MIN_EXP - 1); + ASSERT (mantissa == my_ldexp (1.0, i - DBL_MIN_EXP)); + } + + for (i = 1, x = 1.01; i <= DBL_MAX_EXP; i++, x *= 2.0) + { + int exp = -9999; + double mantissa = printf_frexp (x, &exp); + ASSERT (exp == i - 1); + ASSERT (mantissa == 1.01); + } + for (i = 1, x = 1.01; i >= DBL_MIN_EXP; i--, x *= 0.5) + { + int exp = -9999; + double mantissa = printf_frexp (x, &exp); + ASSERT (exp == i - 1); + ASSERT (mantissa == 1.01); + } + for (; i >= DBL_MIN_EXP - 100 && x > 0.0; i--, x *= 0.5) + { + int exp = -9999; + double mantissa = printf_frexp (x, &exp); + ASSERT (exp == DBL_MIN_EXP - 1); + ASSERT (mantissa >= my_ldexp (1.0, i - DBL_MIN_EXP)); + ASSERT (mantissa <= my_ldexp (2.0, i - DBL_MIN_EXP)); + ASSERT (mantissa == my_ldexp (x, - exp)); + } + + for (i = 1, x = 1.73205; i <= DBL_MAX_EXP; i++, x *= 2.0) + { + int exp = -9999; + double mantissa = printf_frexp (x, &exp); + ASSERT (exp == i - 1); + ASSERT (mantissa == 1.73205); + } + for (i = 1, x = 1.73205; i >= DBL_MIN_EXP; i--, x *= 0.5) + { + int exp = -9999; + double mantissa = printf_frexp (x, &exp); + ASSERT (exp == i - 1); + ASSERT (mantissa == 1.73205); + } + for (; i >= DBL_MIN_EXP - 100 && x > 0.0; i--, x *= 0.5) + { + int exp = -9999; + double mantissa = printf_frexp (x, &exp); + ASSERT (exp == DBL_MIN_EXP - 1); + ASSERT (mantissa >= my_ldexp (1.0, i - DBL_MIN_EXP)); + ASSERT (mantissa <= my_ldexp (2.0, i - DBL_MIN_EXP)); + ASSERT (mantissa == my_ldexp (x, - exp)); + } + + return 0; +} diff --git a/gnulib-tests/test-printf-frexpl.c b/gnulib-tests/test-printf-frexpl.c new file mode 100644 index 0000000..f9b9318 --- /dev/null +++ b/gnulib-tests/test-printf-frexpl.c @@ -0,0 +1,134 @@ +/* Test of splitting a 'long double' into fraction and mantissa. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include "printf-frexpl.h" + +#include <float.h> + +#include "fpucw.h" +#include "macros.h" + +/* On MIPS IRIX machines, LDBL_MIN_EXP is -1021, but the smallest reliable + exponent for 'long double' is -964. Similarly, on PowerPC machines, + LDBL_MIN_EXP is -1021, but the smallest reliable exponent for 'long double' + is -968. For exponents below that, the precision may be truncated to the + precision used for 'double'. */ +#ifdef __sgi +# define MIN_NORMAL_EXP (LDBL_MIN_EXP + 57) +# define MIN_SUBNORMAL_EXP MIN_NORMAL_EXP +#elif defined __ppc || defined __ppc__ || defined __powerpc || defined __powerpc__ +# define MIN_NORMAL_EXP (LDBL_MIN_EXP + 53) +# define MIN_SUBNORMAL_EXP MIN_NORMAL_EXP +#else +# define MIN_NORMAL_EXP LDBL_MIN_EXP +# define MIN_SUBNORMAL_EXP (LDBL_MIN_EXP - 100) +#endif + +static long double +my_ldexp (long double x, int d) +{ + for (; d > 0; d--) + x *= 2.0L; + for (; d < 0; d++) + x *= 0.5L; + return x; +} + +int +main () +{ + int i; + long double x; + DECL_LONG_DOUBLE_ROUNDING + + BEGIN_LONG_DOUBLE_ROUNDING (); + + for (i = 1, x = 1.0L; i <= LDBL_MAX_EXP; i++, x *= 2.0L) + { + int exp = -9999; + long double mantissa = printf_frexpl (x, &exp); + ASSERT (exp == i - 1); + ASSERT (mantissa == 1.0L); + } + for (i = 1, x = 1.0L; i >= MIN_NORMAL_EXP; i--, x *= 0.5L) + { + int exp = -9999; + long double mantissa = printf_frexpl (x, &exp); + ASSERT (exp == i - 1); + ASSERT (mantissa == 1.0L); + } + for (; i >= MIN_SUBNORMAL_EXP && x > 0.0L; i--, x *= 0.5L) + { + int exp = -9999; + long double mantissa = printf_frexpl (x, &exp); + ASSERT (exp == LDBL_MIN_EXP - 1); + ASSERT (mantissa == my_ldexp (1.0L, i - LDBL_MIN_EXP)); + } + + for (i = 1, x = 1.01L; i <= LDBL_MAX_EXP; i++, x *= 2.0L) + { + int exp = -9999; + long double mantissa = printf_frexpl (x, &exp); + ASSERT (exp == i - 1); + ASSERT (mantissa == 1.01L); + } + for (i = 1, x = 1.01L; i >= MIN_NORMAL_EXP; i--, x *= 0.5L) + { + int exp = -9999; + long double mantissa = printf_frexpl (x, &exp); + ASSERT (exp == i - 1); + ASSERT (mantissa == 1.01L); + } + for (; i >= MIN_SUBNORMAL_EXP && x > 0.0L; i--, x *= 0.5L) + { + int exp = -9999; + long double mantissa = printf_frexpl (x, &exp); + ASSERT (exp == LDBL_MIN_EXP - 1); + ASSERT (mantissa >= my_ldexp (1.0L, i - LDBL_MIN_EXP)); + ASSERT (mantissa <= my_ldexp (2.0L, i - LDBL_MIN_EXP)); + ASSERT (mantissa == my_ldexp (x, - exp)); + } + + for (i = 1, x = 1.73205L; i <= LDBL_MAX_EXP; i++, x *= 2.0L) + { + int exp = -9999; + long double mantissa = printf_frexpl (x, &exp); + ASSERT (exp == i - 1); + ASSERT (mantissa == 1.73205L); + } + for (i = 1, x = 1.73205L; i >= MIN_NORMAL_EXP; i--, x *= 0.5L) + { + int exp = -9999; + long double mantissa = printf_frexpl (x, &exp); + ASSERT (exp == i - 1); + ASSERT (mantissa == 1.73205L); + } + for (; i >= MIN_SUBNORMAL_EXP && x > 0.0L; i--, x *= 0.5L) + { + int exp = -9999; + long double mantissa = printf_frexpl (x, &exp); + ASSERT (exp == LDBL_MIN_EXP - 1); + ASSERT (mantissa >= my_ldexp (1.0L, i - LDBL_MIN_EXP)); + ASSERT (mantissa <= my_ldexp (2.0L, i - LDBL_MIN_EXP)); + ASSERT (mantissa == my_ldexp (x, - exp)); + } + + return 0; +} diff --git a/gnulib-tests/test-printf-posix.h b/gnulib-tests/test-printf-posix.h new file mode 100644 index 0000000..5b08ebe --- /dev/null +++ b/gnulib-tests/test-printf-posix.h @@ -0,0 +1,155 @@ +/* Test of POSIX compatible vsprintf() and sprintf() functions. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include "infinity.h" + +static void +test_function (int (*my_printf) (const char *, ...)) +{ + /* Here we don't test output that may be platform dependent. + The bulk of the tests is done as part of the 'vasnprintf-posix' module. */ + + /* Test support of size specifiers as in C99. */ + + my_printf ("%ju %d\n", (uintmax_t) 12345671, 33, 44, 55); + + my_printf ("%zu %d\n", (size_t) 12345672, 33, 44, 55); + + my_printf ("%tu %d\n", (ptrdiff_t) 12345673, 33, 44, 55); + + /* Test the support of the 'a' and 'A' conversion specifier for hexadecimal + output of floating-point numbers. */ + + /* Positive zero. */ + my_printf ("%a %d\n", 0.0, 33, 44, 55); + + /* Positive infinity. */ + my_printf ("%a %d\n", Infinityd (), 33, 44, 55); + + /* Negative infinity. */ + my_printf ("%a %d\n", - Infinityd (), 33, 44, 55); + + /* FLAG_ZERO with infinite number. */ + /* "0000000inf 33" is not a valid result; see + <https://lists.gnu.org/r/bug-gnulib/2007-04/msg00107.html> */ + my_printf ("%010a %d\n", Infinityd (), 33, 44, 55); + + /* Test the support of the %f format directive. */ + + /* A positive number. */ + my_printf ("%f %d\n", 12.75, 33, 44, 55); + + /* A larger positive number. */ + my_printf ("%f %d\n", 1234567.0, 33, 44, 55); + + /* A negative number. */ + my_printf ("%f %d\n", -0.03125, 33, 44, 55); + + /* Positive zero. */ + my_printf ("%f %d\n", 0.0, 33, 44, 55); + + /* FLAG_ZERO. */ + my_printf ("%015f %d\n", 1234.0, 33, 44, 55); + + /* Precision. */ + my_printf ("%.f %d\n", 1234.0, 33, 44, 55); + + /* Precision with no rounding. */ + my_printf ("%.2f %d\n", 999.95, 33, 44, 55); + + /* Precision with rounding. */ + my_printf ("%.2f %d\n", 999.996, 33, 44, 55); + + /* A positive number. */ + my_printf ("%Lf %d\n", 12.75L, 33, 44, 55); + + /* A larger positive number. */ + my_printf ("%Lf %d\n", 1234567.0L, 33, 44, 55); + + /* A negative number. */ + my_printf ("%Lf %d\n", -0.03125L, 33, 44, 55); + + /* Positive zero. */ + my_printf ("%Lf %d\n", 0.0L, 33, 44, 55); + + /* FLAG_ZERO. */ + my_printf ("%015Lf %d\n", 1234.0L, 33, 44, 55); + + /* Precision. */ + my_printf ("%.Lf %d\n", 1234.0L, 33, 44, 55); + + /* Precision with no rounding. */ + my_printf ("%.2Lf %d\n", 999.95L, 33, 44, 55); + + /* Precision with rounding. */ + my_printf ("%.2Lf %d\n", 999.996L, 33, 44, 55); + + /* Test the support of the %F format directive. */ + + /* A positive number. */ + my_printf ("%F %d\n", 12.75, 33, 44, 55); + + /* A larger positive number. */ + my_printf ("%F %d\n", 1234567.0, 33, 44, 55); + + /* A negative number. */ + my_printf ("%F %d\n", -0.03125, 33, 44, 55); + + /* Positive zero. */ + my_printf ("%F %d\n", 0.0, 33, 44, 55); + + /* FLAG_ZERO. */ + my_printf ("%015F %d\n", 1234.0, 33, 44, 55); + + /* Precision. */ + my_printf ("%.F %d\n", 1234.0, 33, 44, 55); + + /* Precision with no rounding. */ + my_printf ("%.2F %d\n", 999.95, 33, 44, 55); + + /* Precision with rounding. */ + my_printf ("%.2F %d\n", 999.996, 33, 44, 55); + + /* A positive number. */ + my_printf ("%LF %d\n", 12.75L, 33, 44, 55); + + /* A larger positive number. */ + my_printf ("%LF %d\n", 1234567.0L, 33, 44, 55); + + /* A negative number. */ + my_printf ("%LF %d\n", -0.03125L, 33, 44, 55); + + /* Positive zero. */ + my_printf ("%LF %d\n", 0.0L, 33, 44, 55); + + /* FLAG_ZERO. */ + my_printf ("%015LF %d\n", 1234.0L, 33, 44, 55); + + /* Precision. */ + my_printf ("%.LF %d\n", 1234.0L, 33, 44, 55); + + /* Precision with no rounding. */ + my_printf ("%.2LF %d\n", 999.95L, 33, 44, 55); + + /* Precision with rounding. */ + my_printf ("%.2LF %d\n", 999.996L, 33, 44, 55); + + /* Test the support of the POSIX/XSI format strings with positions. */ + + my_printf ("%2$d %1$d\n", 33, 55); +} diff --git a/gnulib-tests/test-printf-posix.output b/gnulib-tests/test-printf-posix.output new file mode 100644 index 0000000..618825b --- /dev/null +++ b/gnulib-tests/test-printf-posix.output @@ -0,0 +1,40 @@ +12345671 33 +12345672 33 +12345673 33 +0x0p+0 33 +inf 33 +-inf 33 + inf 33 +12.750000 33 +1234567.000000 33 +-0.031250 33 +0.000000 33 +00001234.000000 33 +1234 33 +999.95 33 +1000.00 33 +12.750000 33 +1234567.000000 33 +-0.031250 33 +0.000000 33 +00001234.000000 33 +1234 33 +999.95 33 +1000.00 33 +12.750000 33 +1234567.000000 33 +-0.031250 33 +0.000000 33 +00001234.000000 33 +1234 33 +999.95 33 +1000.00 33 +12.750000 33 +1234567.000000 33 +-0.031250 33 +0.000000 33 +00001234.000000 33 +1234 33 +999.95 33 +1000.00 33 +55 33 diff --git a/gnulib-tests/test-priv-set.c b/gnulib-tests/test-priv-set.c new file mode 100644 index 0000000..210cf1f --- /dev/null +++ b/gnulib-tests/test-priv-set.c @@ -0,0 +1,88 @@ +/* Test the priv-set module. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by David Bartley <dtbartle@csclub.uwaterloo.ca>, 2007. */ + +#include <config.h> + +#include "priv-set.h" + +#if HAVE_GETPPRIV && HAVE_PRIV_H +# include <priv.h> +#endif +#include <unistd.h> +#include <errno.h> +#include <sys/types.h> + +#include "macros.h" + +int +main (void) +{ +#if HAVE_GETPPRIV && HAVE_PRIV_H + priv_set_t *set; + + ASSERT (set = priv_allocset ()); + ASSERT (getppriv (PRIV_EFFECTIVE, set) == 0); + ASSERT (priv_ismember (set, PRIV_PROC_EXEC) == 1); + + /* Do a series of removes and restores making sure that the results are + consistent with our ismember function and solaris' priv_ismember. */ + ASSERT (priv_set_ismember (PRIV_PROC_EXEC) == 1); + ASSERT (getppriv (PRIV_EFFECTIVE, set) == 0); + ASSERT (priv_ismember (set, PRIV_PROC_EXEC) == 1); + ASSERT (priv_set_restore (PRIV_PROC_EXEC) == -1); + ASSERT (errno == EINVAL); + ASSERT (priv_set_ismember (PRIV_PROC_EXEC) == 1); + ASSERT (getppriv (PRIV_EFFECTIVE, set) == 0); + ASSERT (priv_ismember (set, PRIV_PROC_EXEC) == 1); + ASSERT (priv_set_remove (PRIV_PROC_EXEC) == 0); + ASSERT (priv_set_ismember (PRIV_PROC_EXEC) == 0); + ASSERT (getppriv (PRIV_EFFECTIVE, set) == 0); + ASSERT (priv_ismember (set, PRIV_PROC_EXEC) == 0); + ASSERT (priv_set_remove (PRIV_PROC_EXEC) == -1); + ASSERT (errno == EINVAL); + ASSERT (priv_set_ismember (PRIV_PROC_EXEC) == 0); + ASSERT (getppriv (PRIV_EFFECTIVE, set) == 0); + ASSERT (priv_ismember (set, PRIV_PROC_EXEC) == 0); + ASSERT (priv_set_restore (PRIV_PROC_EXEC) == 0); + ASSERT (priv_set_ismember (PRIV_PROC_EXEC) == 1); + ASSERT (getppriv (PRIV_EFFECTIVE, set) == 0); + ASSERT (priv_ismember (set, PRIV_PROC_EXEC) == 1); + ASSERT (priv_set_restore (PRIV_PROC_EXEC) == -1); + ASSERT (errno == EINVAL); + ASSERT (priv_set_ismember (PRIV_PROC_EXEC) == 1); + ASSERT (getppriv (PRIV_EFFECTIVE, set) == 0); + ASSERT (priv_ismember (set, PRIV_PROC_EXEC) == 1); + + /* Test the priv_set_linkdir wrappers. */ + ASSERT (getppriv (PRIV_EFFECTIVE, set) == 0); + if (priv_ismember (set, PRIV_SYS_LINKDIR)) + { + ASSERT (priv_set_restore_linkdir () == -1); + ASSERT (errno == EINVAL); + ASSERT (priv_set_remove_linkdir () == 0); + ASSERT (priv_set_remove_linkdir () == -1); + ASSERT (errno == EINVAL); + ASSERT (priv_set_restore_linkdir () == 0); + } +#else + ASSERT (priv_set_restore_linkdir () == -1); + ASSERT (priv_set_remove_linkdir () == -1); +#endif + + return 0; +} diff --git a/gnulib-tests/test-pthread-cond.c b/gnulib-tests/test-pthread-cond.c new file mode 100644 index 0000000..dee37af --- /dev/null +++ b/gnulib-tests/test-pthread-cond.c @@ -0,0 +1,238 @@ +/* Test of condition variables in multithreaded situations. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#if USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS || USE_WINDOWS_THREADS + +/* Which tests to perform. + Uncomment some of these, to verify that all tests crash if no locking + is enabled. */ +#define DO_TEST_COND 1 +#define DO_TEST_TIMEDCOND 1 + +/* Whether to help the scheduler through explicit sched_yield(). + Uncomment this to see if the operating system has a fair scheduler. */ +#define EXPLICIT_YIELD 1 + +/* Whether to print debugging messages. */ +#define ENABLE_DEBUGGING 0 + +#include <pthread.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/time.h> + +#if EXPLICIT_YIELD +# include <sched.h> +#endif + +#if HAVE_DECL_ALARM +# include <signal.h> +# include <unistd.h> +#endif + +#include "macros.h" + +#if ENABLE_DEBUGGING +# define dbgprintf printf +#else +# define dbgprintf if (0) printf +#endif + +#if EXPLICIT_YIELD +# define yield() sched_yield () +#else +# define yield() +#endif + + +/* + * Condition check + */ +static int cond_value = 0; +static pthread_cond_t condtest; +static pthread_mutex_t lockcond; + +static void * +pthread_cond_wait_routine (void *arg) +{ + ASSERT (pthread_mutex_lock (&lockcond) == 0); + while (!cond_value) + { + ASSERT (pthread_cond_wait (&condtest, &lockcond) == 0); + } + ASSERT (pthread_mutex_unlock (&lockcond) == 0); + + cond_value = 2; + + return NULL; +} + +static void +test_pthread_cond_wait () +{ + struct timespec remain; + pthread_t thread; + int ret; + + remain.tv_sec = 2; + remain.tv_nsec = 0; + + cond_value = 0; + + ASSERT (pthread_create (&thread, NULL, pthread_cond_wait_routine, NULL) == 0); + do + { + yield (); + ret = nanosleep (&remain, &remain); + ASSERT (ret >= -1); + } + while (ret == -1 && (remain.tv_sec != 0 || remain.tv_nsec != 0)); + + /* signal condition */ + ASSERT (pthread_mutex_lock (&lockcond) == 0); + cond_value = 1; + ASSERT (pthread_cond_signal (&condtest) == 0); + ASSERT (pthread_mutex_unlock (&lockcond) == 0); + + ASSERT (pthread_join (thread, NULL) == 0); + + if (cond_value != 2) + abort (); +} + + +/* + * Timed Condition check + */ +static int cond_timeout; + +static void +get_ts (struct timespec *ts) +{ + struct timeval now; + + gettimeofday (&now, NULL); + + ts->tv_sec = now.tv_sec + 1; + ts->tv_nsec = now.tv_usec * 1000; +} + +static void * +pthread_cond_timedwait_routine (void *arg) +{ + int ret; + struct timespec ts; + + ASSERT (pthread_mutex_lock (&lockcond) == 0); + while (!cond_value) + { + get_ts (&ts); + ret = pthread_cond_timedwait (&condtest, &lockcond, &ts); + if (ret == ETIMEDOUT) + cond_timeout = 1; + } + ASSERT (pthread_mutex_unlock (&lockcond) == 0); + + return NULL; +} + +static void +test_pthread_cond_timedwait (void) +{ + struct timespec remain; + pthread_t thread; + int ret; + + remain.tv_sec = 2; + remain.tv_nsec = 0; + + cond_value = cond_timeout = 0; + + ASSERT (pthread_create (&thread, NULL, pthread_cond_timedwait_routine, NULL) + == 0); + do + { + yield (); + ret = nanosleep (&remain, &remain); + ASSERT (ret >= -1); + } + while (ret == -1 && (remain.tv_sec != 0 || remain.tv_nsec != 0)); + + /* signal condition */ + ASSERT (pthread_mutex_lock (&lockcond) == 0); + cond_value = 1; + ASSERT (pthread_cond_signal (&condtest) == 0); + ASSERT (pthread_mutex_unlock (&lockcond) == 0); + + ASSERT (pthread_join (thread, NULL) == 0); + + if (!cond_timeout) + abort (); +} + +int +main () +{ +#if HAVE_DECL_ALARM + /* Declare failure if test takes too long, by using default abort + caused by SIGALRM. */ + int alarm_value = 600; + signal (SIGALRM, SIG_DFL); + alarm (alarm_value); +#endif + + ASSERT (pthread_cond_init (&condtest, NULL) == 0); + + { + pthread_mutexattr_t attr; + + ASSERT (pthread_mutexattr_init (&attr) == 0); + ASSERT (pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_NORMAL) == 0); + ASSERT (pthread_mutex_init (&lockcond, &attr) == 0); + ASSERT (pthread_mutexattr_destroy (&attr) == 0); + } + +#if DO_TEST_COND + printf ("Starting test_pthread_cond_wait ..."); fflush (stdout); + test_pthread_cond_wait (); + printf (" OK\n"); fflush (stdout); +#endif +#if DO_TEST_TIMEDCOND + printf ("Starting test_pthread_cond_timedwait ..."); fflush (stdout); + test_pthread_cond_timedwait (); + printf (" OK\n"); fflush (stdout); +#endif + + return 0; +} + +#else + +/* No multithreading available. */ + +#include <stdio.h> + +int +main () +{ + fputs ("Skipping test: multithreading not enabled\n", stderr); + return 77; +} + +#endif diff --git a/gnulib-tests/test-pthread-mutex.c b/gnulib-tests/test-pthread-mutex.c new file mode 100644 index 0000000..55eeb88 --- /dev/null +++ b/gnulib-tests/test-pthread-mutex.c @@ -0,0 +1,524 @@ +/* Test of locking in multithreaded situations. + Copyright (C) 2005, 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2005. */ + +#include <config.h> + +#if USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS || USE_WINDOWS_THREADS + +/* Whether to enable locking. + Uncomment this to get a test program without locking, to verify that + it crashes. */ +#define ENABLE_LOCKING 1 + +/* Which tests to perform. + Uncomment some of these, to verify that all tests crash if no locking + is enabled. */ +#define DO_TEST_LOCK 1 +#define DO_TEST_RECURSIVE_LOCK 1 + +/* Whether to help the scheduler through explicit sched_yield(). + Uncomment this to see if the operating system has a fair scheduler. */ +#define EXPLICIT_YIELD 1 + +/* Whether to use 'volatile' on some variables that communicate information + between threads. If set to 0, a semaphore or a lock is used to protect + these variables. If set to 1, 'volatile' is used; this is theoretically + equivalent but can lead to much slower execution (e.g. 30x slower total + run time on a 40-core machine), because 'volatile' does not imply any + synchronization/communication between different CPUs. */ +#define USE_VOLATILE 0 + +#if USE_POSIX_THREADS && HAVE_SEMAPHORE_H +/* Whether to use a semaphore to communicate information between threads. + If set to 0, a lock is used. If set to 1, a semaphore is used. + Uncomment this to reduce the dependencies of this test. */ +# define USE_SEMAPHORE 1 +/* Mac OS X provides only named semaphores (sem_open); its facility for + unnamed semaphores (sem_init) does not work. */ +# if defined __APPLE__ && defined __MACH__ +# define USE_NAMED_SEMAPHORE 1 +# else +# define USE_UNNAMED_SEMAPHORE 1 +# endif +#endif + +/* Whether to print debugging messages. */ +#define ENABLE_DEBUGGING 0 + +/* Number of simultaneous threads. */ +#define THREAD_COUNT 10 + +/* Number of operations performed in each thread. + This is quite high, because with a smaller count, say 5000, we often get + an "OK" result even without ENABLE_LOCKING (on Linux/x86). */ +#define REPEAT_COUNT 50000 + +#include <pthread.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#if EXPLICIT_YIELD +# include <sched.h> +#endif + +#if USE_SEMAPHORE +# include <errno.h> +# include <fcntl.h> +# include <semaphore.h> +# include <unistd.h> +#endif + +#if HAVE_DECL_ALARM +# include <signal.h> +# include <unistd.h> +#endif + +#include "macros.h" + +#if ENABLE_DEBUGGING +# define dbgprintf printf +#else +# define dbgprintf if (0) printf +#endif + +#if EXPLICIT_YIELD +# define yield() sched_yield () +#else +# define yield() +#endif + +#if USE_VOLATILE +struct atomic_int { + volatile int value; +}; +static void +init_atomic_int (struct atomic_int *ai) +{ +} +static int +get_atomic_int_value (struct atomic_int *ai) +{ + return ai->value; +} +static void +set_atomic_int_value (struct atomic_int *ai, int new_value) +{ + ai->value = new_value; +} +#elif USE_SEMAPHORE +/* This atomic_int implementation can only support the values 0 and 1. + It is initially 0 and can be set to 1 only once. */ +# if USE_UNNAMED_SEMAPHORE +struct atomic_int { + sem_t semaphore; +}; +#define atomic_int_semaphore(ai) (&(ai)->semaphore) +static void +init_atomic_int (struct atomic_int *ai) +{ + sem_init (&ai->semaphore, 0, 0); +} +# endif +# if USE_NAMED_SEMAPHORE +struct atomic_int { + sem_t *semaphore; +}; +#define atomic_int_semaphore(ai) ((ai)->semaphore) +static void +init_atomic_int (struct atomic_int *ai) +{ + sem_t *s; + unsigned int count; + for (count = 0; ; count++) + { + char name[80]; + /* Use getpid() in the name, so that different processes running at the + same time will not interfere. Use ai in the name, so that different + atomic_int in the same process will not interfere. Use a count in + the name, so that even in the (unlikely) case that a semaphore with + the specified name already exists, we can try a different name. */ + sprintf (name, "test-lock-%lu-%p-%u", + (unsigned long) getpid (), ai, count); + s = sem_open (name, O_CREAT | O_EXCL, 0600, 0); + if (s == SEM_FAILED) + { + if (errno == EEXIST) + /* Retry with a different name. */ + continue; + else + { + perror ("sem_open failed"); + abort (); + } + } + else + { + /* Try not to leave a semaphore hanging around on the file system + eternally, if we can avoid it. */ + sem_unlink (name); + break; + } + } + ai->semaphore = s; +} +# endif +static int +get_atomic_int_value (struct atomic_int *ai) +{ + if (sem_trywait (atomic_int_semaphore (ai)) == 0) + { + if (sem_post (atomic_int_semaphore (ai))) + abort (); + return 1; + } + else if (errno == EAGAIN) + return 0; + else + abort (); +} +static void +set_atomic_int_value (struct atomic_int *ai, int new_value) +{ + if (new_value == 0) + /* It's already initialized with 0. */ + return; + /* To set the value 1: */ + if (sem_post (atomic_int_semaphore (ai))) + abort (); +} +#else +struct atomic_int { + pthread_mutex_t lock; + int value; +}; +static void +init_atomic_int (struct atomic_int *ai) +{ + pthread_mutexattr_t attr; + + ASSERT (pthread_mutexattr_init (&attr) == 0); + ASSERT (pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_NORMAL) == 0); + ASSERT (pthread_mutex_init (&ai->lock, &attr) == 0); + ASSERT (pthread_mutexattr_destroy (&attr) == 0); +} +static int +get_atomic_int_value (struct atomic_int *ai) +{ + ASSERT (pthread_mutex_lock (&ai->lock) == 0); + int ret = ai->value; + ASSERT (pthread_mutex_unlock (&ai->lock) == 0); + return ret; +} +static void +set_atomic_int_value (struct atomic_int *ai, int new_value) +{ + ASSERT (pthread_mutex_lock (&ai->lock) == 0); + ai->value = new_value; + ASSERT (pthread_mutex_unlock (&ai->lock) == 0); +} +#endif + +/* Returns a reference to the current thread as a pointer, for debugging. */ +#if defined __MVS__ + /* On IBM z/OS, pthread_t is a struct with an 8-byte '__' field. + The first three bytes of this field appear to uniquely identify a + pthread_t, though not necessarily representing a pointer. */ +# define pthread_self_pointer() (*((void **) pthread_self ().__)) +#else +# define pthread_self_pointer() ((void *) (uintptr_t) pthread_self ()) +#endif + +#define ACCOUNT_COUNT 4 + +static int account[ACCOUNT_COUNT]; + +static int +random_account (void) +{ + return ((unsigned int) rand () >> 3) % ACCOUNT_COUNT; +} + +static void +check_accounts (void) +{ + int i, sum; + + sum = 0; + for (i = 0; i < ACCOUNT_COUNT; i++) + sum += account[i]; + if (sum != ACCOUNT_COUNT * 1000) + abort (); +} + + +/* ------------------- Test normal (non-recursive) locks ------------------- */ + +/* Test normal locks by having several bank accounts and several threads + which shuffle around money between the accounts and another thread + checking that all the money is still there. */ + +static pthread_mutex_t my_lock; + +static void * +lock_mutator_thread (void *arg) +{ + int repeat; + + for (repeat = REPEAT_COUNT; repeat > 0; repeat--) + { + int i1, i2, value; + + dbgprintf ("Mutator %p before lock\n", pthread_self_pointer ()); + ASSERT (pthread_mutex_lock (&my_lock) == 0); + dbgprintf ("Mutator %p after lock\n", pthread_self_pointer ()); + + i1 = random_account (); + i2 = random_account (); + value = ((unsigned int) rand () >> 3) % 10; + account[i1] += value; + account[i2] -= value; + + dbgprintf ("Mutator %p before unlock\n", pthread_self_pointer ()); + ASSERT (pthread_mutex_unlock (&my_lock) == 0); + dbgprintf ("Mutator %p after unlock\n", pthread_self_pointer ()); + + dbgprintf ("Mutator %p before check lock\n", pthread_self_pointer ()); + ASSERT (pthread_mutex_lock (&my_lock) == 0); + check_accounts (); + ASSERT (pthread_mutex_unlock (&my_lock) == 0); + dbgprintf ("Mutator %p after check unlock\n", pthread_self_pointer ()); + + yield (); + } + + dbgprintf ("Mutator %p dying.\n", pthread_self_pointer ()); + return NULL; +} + +static struct atomic_int lock_checker_done; + +static void * +lock_checker_thread (void *arg) +{ + while (get_atomic_int_value (&lock_checker_done) == 0) + { + dbgprintf ("Checker %p before check lock\n", pthread_self_pointer ()); + ASSERT (pthread_mutex_lock (&my_lock) == 0); + check_accounts (); + ASSERT (pthread_mutex_unlock (&my_lock) == 0); + dbgprintf ("Checker %p after check unlock\n", pthread_self_pointer ()); + + yield (); + } + + dbgprintf ("Checker %p dying.\n", pthread_self_pointer ()); + return NULL; +} + +static void +test_pthread_mutex_normal (void) +{ + int i; + pthread_t checkerthread; + pthread_t threads[THREAD_COUNT]; + + /* Initialization. */ + for (i = 0; i < ACCOUNT_COUNT; i++) + account[i] = 1000; + init_atomic_int (&lock_checker_done); + set_atomic_int_value (&lock_checker_done, 0); + + /* Spawn the threads. */ + ASSERT (pthread_create (&checkerthread, NULL, lock_checker_thread, NULL) + == 0); + for (i = 0; i < THREAD_COUNT; i++) + ASSERT (pthread_create (&threads[i], NULL, lock_mutator_thread, NULL) == 0); + + /* Wait for the threads to terminate. */ + for (i = 0; i < THREAD_COUNT; i++) + ASSERT (pthread_join (threads[i], NULL) == 0); + set_atomic_int_value (&lock_checker_done, 1); + ASSERT (pthread_join (checkerthread, NULL) == 0); + check_accounts (); +} + + +/* -------------------------- Test recursive locks -------------------------- */ + +/* Test recursive locks by having several bank accounts and several threads + which shuffle around money between the accounts (recursively) and another + thread checking that all the money is still there. */ + +static pthread_mutex_t my_reclock; + +static void +recshuffle (void) +{ + int i1, i2, value; + + dbgprintf ("Mutator %p before lock\n", pthread_self_pointer ()); + ASSERT (pthread_mutex_lock (&my_reclock) == 0); + dbgprintf ("Mutator %p after lock\n", pthread_self_pointer ()); + + i1 = random_account (); + i2 = random_account (); + value = ((unsigned int) rand () >> 3) % 10; + account[i1] += value; + account[i2] -= value; + + /* Recursive with probability 0.5. */ + if (((unsigned int) rand () >> 3) % 2) + recshuffle (); + + dbgprintf ("Mutator %p before unlock\n", pthread_self_pointer ()); + ASSERT (pthread_mutex_unlock (&my_reclock) == 0); + dbgprintf ("Mutator %p after unlock\n", pthread_self_pointer ()); +} + +static void * +reclock_mutator_thread (void *arg) +{ + int repeat; + + for (repeat = REPEAT_COUNT; repeat > 0; repeat--) + { + recshuffle (); + + dbgprintf ("Mutator %p before check lock\n", pthread_self_pointer ()); + ASSERT (pthread_mutex_lock (&my_reclock) == 0); + check_accounts (); + ASSERT (pthread_mutex_unlock (&my_reclock) == 0); + dbgprintf ("Mutator %p after check unlock\n", pthread_self_pointer ()); + + yield (); + } + + dbgprintf ("Mutator %p dying.\n", pthread_self_pointer ()); + return NULL; +} + +static struct atomic_int reclock_checker_done; + +static void * +reclock_checker_thread (void *arg) +{ + while (get_atomic_int_value (&reclock_checker_done) == 0) + { + dbgprintf ("Checker %p before check lock\n", pthread_self_pointer ()); + ASSERT (pthread_mutex_lock (&my_reclock) == 0); + check_accounts (); + ASSERT (pthread_mutex_unlock (&my_reclock) == 0); + dbgprintf ("Checker %p after check unlock\n", pthread_self_pointer ()); + + yield (); + } + + dbgprintf ("Checker %p dying.\n", pthread_self_pointer ()); + return NULL; +} + +static void +test_pthread_mutex_recursive (void) +{ + int i; + pthread_t checkerthread; + pthread_t threads[THREAD_COUNT]; + + /* Initialization. */ + for (i = 0; i < ACCOUNT_COUNT; i++) + account[i] = 1000; + init_atomic_int (&reclock_checker_done); + set_atomic_int_value (&reclock_checker_done, 0); + + /* Spawn the threads. */ + ASSERT (pthread_create (&checkerthread, NULL, reclock_checker_thread, NULL) + == 0); + for (i = 0; i < THREAD_COUNT; i++) + ASSERT (pthread_create (&threads[i], NULL, reclock_mutator_thread, NULL) + == 0); + + /* Wait for the threads to terminate. */ + for (i = 0; i < THREAD_COUNT; i++) + ASSERT (pthread_join (threads[i], NULL) == 0); + set_atomic_int_value (&reclock_checker_done, 1); + ASSERT (pthread_join (checkerthread, NULL) == 0); + check_accounts (); +} + + +/* -------------------------------------------------------------------------- */ + +int +main () +{ +#if HAVE_DECL_ALARM + /* Declare failure if test takes too long, by using default abort + caused by SIGALRM. */ + int alarm_value = 600; + signal (SIGALRM, SIG_DFL); + alarm (alarm_value); +#endif + + { + pthread_mutexattr_t attr; + + ASSERT (pthread_mutexattr_init (&attr) == 0); + ASSERT (pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_NORMAL) == 0); + ASSERT (pthread_mutex_init (&my_lock, &attr) == 0); + ASSERT (pthread_mutexattr_destroy (&attr) == 0); + } + + { + pthread_mutexattr_t attr; + + ASSERT (pthread_mutexattr_init (&attr) == 0); + ASSERT (pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE) == 0); + ASSERT (pthread_mutex_init (&my_reclock, &attr) == 0); + ASSERT (pthread_mutexattr_destroy (&attr) == 0); + } + +#if DO_TEST_LOCK + printf ("Starting test_pthread_mutex_normal ..."); fflush (stdout); + test_pthread_mutex_normal (); + printf (" OK\n"); fflush (stdout); +#endif +#if DO_TEST_RECURSIVE_LOCK + printf ("Starting test_pthread_mutex_recursive ..."); fflush (stdout); + test_pthread_mutex_recursive (); + printf (" OK\n"); fflush (stdout); +#endif + + return 0; +} + +#else + +/* No multithreading available. */ + +#include <stdio.h> + +int +main () +{ + fputs ("Skipping test: multithreading not enabled\n", stderr); + return 77; +} + +#endif diff --git a/gnulib-tests/test-pthread-thread.c b/gnulib-tests/test-pthread-thread.c new file mode 100644 index 0000000..a274d78 --- /dev/null +++ b/gnulib-tests/test-pthread-thread.c @@ -0,0 +1,73 @@ +/* Test of pthread_create () function. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2011. */ + +#include <config.h> + +#include <pthread.h> + +#include <stdio.h> +#include <string.h> + +#include "macros.h" + +static pthread_t main_thread_before; +static pthread_t main_thread_after; +static pthread_t worker_thread; + +#define MAGIC ((void *) 1266074729) +static volatile int work_done; + +static void * +worker_thread_func (void *arg) +{ + work_done = 1; + return MAGIC; +} + +int +main () +{ + main_thread_before = pthread_self (); + + if (pthread_create (&worker_thread, NULL, worker_thread_func, NULL) == 0) + { + void *ret; + + /* Check that pthread_self () has the same value before than after the + first call to pthread_create (). */ + main_thread_after = pthread_self (); + ASSERT (memcmp (&main_thread_before, &main_thread_after, + sizeof (pthread_t)) + == 0); + + ASSERT (pthread_join (worker_thread, &ret) == 0); + + /* Check the return value of the thread. */ + ASSERT (ret == MAGIC); + + /* Check that worker_thread_func () has finished executing. */ + ASSERT (work_done); + + return 0; + } + else + { + fputs ("pthread_create failed\n", stderr); + return 1; + } +} diff --git a/gnulib-tests/test-pthread.c b/gnulib-tests/test-pthread.c new file mode 100644 index 0000000..800ad04 --- /dev/null +++ b/gnulib-tests/test-pthread.c @@ -0,0 +1,90 @@ +/* Test of <pthread.h> substitute. + Copyright (C) 2019-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2019. */ + +#include <config.h> + +#include <pthread.h> + +#include "verify.h" + +/* Check that the types are all defined. */ + +pthread_t t1; +pthread_attr_t t2; + +pthread_once_t t3 = PTHREAD_ONCE_INIT; + +pthread_mutex_t t4 = PTHREAD_MUTEX_INITIALIZER; +pthread_mutexattr_t t5; + +pthread_rwlock_t t6 = PTHREAD_RWLOCK_INITIALIZER; +pthread_rwlockattr_t t7; + +pthread_cond_t t8 = PTHREAD_COND_INITIALIZER; +pthread_condattr_t t9; + +pthread_key_t t10; + +pthread_spinlock_t t11; + +#ifdef TODO /* Not implemented in gnulib yet */ +pthread_barrier_t t12; +pthread_barrierattr_t t13; +#endif + +/* Check that the various macros are defined. */ + +/* Constants for pthread_attr_setdetachstate(). */ +int ds[] = { PTHREAD_CREATE_JOINABLE, PTHREAD_CREATE_DETACHED }; + +/* Constants for pthread_exit(). */ +void *canceled = PTHREAD_CANCELED; + +/* Constants for pthread_mutexattr_settype(). */ +int mt[] = { + PTHREAD_MUTEX_DEFAULT, + PTHREAD_MUTEX_NORMAL, + PTHREAD_MUTEX_RECURSIVE, + PTHREAD_MUTEX_ERRORCHECK +}; + +#ifdef TODO /* Not implemented in gnulib yet */ + +/* Constants for pthread_mutexattr_setrobust(). */ +int mr[] = { PTHREAD_MUTEX_ROBUST, PTHREAD_MUTEX_STALLED }; + +/* Constants for pthread_barrierattr_setpshared(). */ +int bp[] = { PTHREAD_PROCESS_SHARED, PTHREAD_PROCESS_PRIVATE }; + +/* Constants for pthread_barrier_wait(). */ +int bw[] = { PTHREAD_BARRIER_SERIAL_THREAD }; + +/* Constants for pthread_setcancelstate(). */ +int cs[] = { PTHREAD_CANCEL_ENABLE, PTHREAD_CANCEL_DISABLE }; + +/* Constants for pthread_setcanceltype(). */ +int ct[] = { PTHREAD_CANCEL_DEFERRED, PTHREAD_CANCEL_ASYNCHRONOUS }; + +#endif + + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tests/test-pthread_sigmask1.c b/gnulib-tests/test-pthread_sigmask1.c new file mode 100644 index 0000000..c1df429 --- /dev/null +++ b/gnulib-tests/test-pthread_sigmask1.c @@ -0,0 +1,95 @@ +/* Test of pthread_sigmask in a single-threaded program. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2011. */ + +#include <config.h> + +#include <signal.h> + +#include "signature.h" +SIGNATURE_CHECK (pthread_sigmask, int, (int, const sigset_t *, sigset_t *)); + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "macros.h" + +#if !(defined _WIN32 && !defined __CYGWIN__) + +static volatile int sigint_occurred; + +static void +sigint_handler (int sig) +{ + sigint_occurred++; +} + +int +main (int argc, char *argv[]) +{ + sigset_t set; + int pid = getpid (); + char command[80]; + + signal (SIGINT, sigint_handler); + + sigemptyset (&set); + sigaddset (&set, SIGINT); + + /* Check error handling. */ + ASSERT (pthread_sigmask (1729, &set, NULL) == EINVAL); + + /* Block SIGINT. */ + ASSERT (pthread_sigmask (SIG_BLOCK, &set, NULL) == 0); + + /* Request a SIGINT signal from outside. */ + sprintf (command, "sh -c 'sleep 1; kill -%d %d' &", SIGINT, pid); + ASSERT (system (command) == 0); + + /* Wait. */ + sleep (2); + + /* The signal should not have arrived yet, because it is blocked. */ + ASSERT (sigint_occurred == 0); + + /* Unblock SIGINT. */ + ASSERT (pthread_sigmask (SIG_UNBLOCK, &set, NULL) == 0); + + /* The signal should have arrived now, because POSIX says + "If there are any pending unblocked signals after the call to + pthread_sigmask(), at least one of those signals shall be delivered + before the call to pthread_sigmask() returns." */ + ASSERT (sigint_occurred == 1); + + return 0; +} + +#else + +/* On native Windows, getpid() values and the arguments that are passed to + the (Cygwin?) 'kill' program are not necessarily related. */ + +int +main () +{ + fputs ("Skipping test: native Windows platform\n", stderr); + return 77; +} + +#endif diff --git a/gnulib-tests/test-pthread_sigmask2.c b/gnulib-tests/test-pthread_sigmask2.c new file mode 100644 index 0000000..1877458 --- /dev/null +++ b/gnulib-tests/test-pthread_sigmask2.c @@ -0,0 +1,105 @@ +/* Test of pthread_sigmask in a multi-threaded program. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2011. */ + +#include <config.h> + +#include <signal.h> + +#include <errno.h> +#include <pthread.h> +#include <stdio.h> +#include <unistd.h> + +#include "macros.h" + +#if USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS + +static pthread_t main_thread; +static pthread_t killer_thread; + +static void * +killer_thread_func (void *arg) +{ + sleep (1); + pthread_kill (main_thread, SIGINT); + return NULL; +} + +static volatile int sigint_occurred; + +static void +sigint_handler (int sig) +{ + sigint_occurred++; +} + +int +main (int argc, char *argv[]) +{ + sigset_t set; + + signal (SIGINT, sigint_handler); + + sigemptyset (&set); + sigaddset (&set, SIGINT); + + /* Check error handling. */ + /* This call returns 0 on NetBSD 8.0. */ +#if !defined __NetBSD__ + ASSERT (pthread_sigmask (1729, &set, NULL) == EINVAL); +#endif + + /* Block SIGINT. */ + ASSERT (pthread_sigmask (SIG_BLOCK, &set, NULL) == 0); + + /* Request a SIGINT signal from another thread. */ + main_thread = pthread_self (); + ASSERT (pthread_create (&killer_thread, NULL, killer_thread_func, NULL) == 0); + + /* Wait. */ + sleep (2); + + /* The signal should not have arrived yet, because it is blocked. */ + ASSERT (sigint_occurred == 0); + + /* Unblock SIGINT. */ + ASSERT (pthread_sigmask (SIG_UNBLOCK, &set, NULL) == 0); + + /* The signal should have arrived now, because POSIX says + "If there are any pending unblocked signals after the call to + pthread_sigmask(), at least one of those signals shall be delivered + before the call to pthread_sigmask() returns." */ + ASSERT (sigint_occurred == 1); + + /* Clean up the thread. This avoid a "ThreadSanitizer: thread leak" warning + from "gcc -fsanitize=thread". */ + ASSERT (pthread_join (killer_thread, NULL) == 0); + + return 0; +} + +#else + +int +main () +{ + fputs ("Skipping test: POSIX threads not enabled\n", stderr); + return 77; +} + +#endif diff --git a/gnulib-tests/test-quotearg-simple.c b/gnulib-tests/test-quotearg-simple.c new file mode 100644 index 0000000..e1c8ba8 --- /dev/null +++ b/gnulib-tests/test-quotearg-simple.c @@ -0,0 +1,366 @@ +/* Test of quotearg family of functions. + Copyright (C) 2008-2020 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, 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2008. */ + +#include <config.h> + +#include "quotearg.h" + +#include <ctype.h> +#include <stdbool.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> + +#include "localcharset.h" +#include "macros.h" +#include "zerosize-ptr.h" + +#include "test-quotearg.h" + +static struct result_groups results_g[] = { + /* literal_quoting_style */ + { { "", "\0""1\0", 3, "simple", " \t\n'\"\033?""?/\\", "a:b", "a\\b", + "a' b", LQ RQ, LQ RQ }, + { "", "1", 1, "simple", " \t\n'\"\033?""?/\\", "a:b", "a\\b", + "a' b", LQ RQ, LQ RQ }, + { "", "1", 1, "simple", " \t\n'\"\033?""?/\\", "a:b", "a\\b", + "a' b", LQ RQ, LQ RQ } }, + + /* shell_quoting_style */ + { { "''", "\0""1\0", 3, "simple", "' \t\n'\\''\"\033?""?/\\'", "a:b", + "'a\\b'", "\"a' b\"", LQ RQ, LQ RQ }, + { "''", "1", 1, "simple", "' \t\n'\\''\"\033?""?/\\'", "a:b", + "'a\\b'", "\"a' b\"", LQ RQ, LQ RQ }, + { "''", "1", 1, "simple", "' \t\n'\\''\"\033?""?/\\'", "'a:b'", + "'a\\b'", "\"a' b\"", LQ RQ, LQ RQ } }, + + /* shell_always_quoting_style */ + { { "''", "'\0""1\0'", 5, "'simple'", "' \t\n'\\''\"\033?""?/\\'", "'a:b'", + "'a\\b'", "\"a' b\"", "'" LQ RQ "'", "'" LQ RQ "'" }, + { "''", "'1'", 3, "'simple'", "' \t\n'\\''\"\033?""?/\\'", "'a:b'", + "'a\\b'", "\"a' b\"", "'" LQ RQ "'", "'" LQ RQ "'" }, + { "''", "'1'", 3, "'simple'", "' \t\n'\\''\"\033?""?/\\'", "'a:b'", + "'a\\b'", "\"a' b\"", "'" LQ RQ "'", "'" LQ RQ "'" } }, + + /* shell_escape_quoting_style */ + { { "''", "''$'\\0''1'$'\\0'", 15, "simple", + "' '$'\\t\\n'\\''\"'$'\\033''?""?/\\'", "a:b", + "'a\\b'", "\"a' b\"", "''$'" LQ_ENC RQ_ENC "'", LQ RQ }, + { "''", "''$'\\0''1'$'\\0'", 15, "simple", + "' '$'\\t\\n'\\''\"'$'\\033''?""?/\\'", "a:b", + "'a\\b'", "\"a' b\"", "''$'" LQ_ENC RQ_ENC "'", LQ RQ }, + { "''", "''$'\\0''1'$'\\0'", 15, "simple", + "' '$'\\t\\n'\\''\"'$'\\033''?""?/\\'", "'a:b'", + "'a\\b'", "\"a' b\"", "''$'" LQ_ENC RQ_ENC "'", LQ RQ } }, + + /* shell_escape_always_quoting_style */ + { { "''", "''$'\\0''1'$'\\0'", 15, "'simple'", + "' '$'\\t\\n'\\''\"'$'\\033''?""?/\\'", "'a:b'", + "'a\\b'", "\"a' b\"", "''$'" LQ_ENC RQ_ENC "'", "'" LQ RQ "'" }, + { "''", "''$'\\0''1'$'\\0'", 15, "'simple'", + "' '$'\\t\\n'\\''\"'$'\\033''?""?/\\'", "'a:b'", + "'a\\b'", "\"a' b\"", "''$'" LQ_ENC RQ_ENC "'", "'" LQ RQ "'" }, + { "''", "''$'\\0''1'$'\\0'", 15, "'simple'", + "' '$'\\t\\n'\\''\"'$'\\033''?""?/\\'", "'a:b'", + "'a\\b'", "\"a' b\"", "''$'" LQ_ENC RQ_ENC "'", "'" LQ RQ "'" } }, + + /* c_quoting_style */ + { { "\"\"", "\"\\0001\\0\"", 9, "\"simple\"", + "\" \\t\\n'\\\"\\033?""?/\\\\\"", "\"a:b\"", "\"a\\\\b\"", + "\"a' b\"", "\"" LQ_ENC RQ_ENC "\"", "\"" LQ RQ "\"" }, + { "\"\"", "\"\\0001\\0\"", 9, "\"simple\"", + "\" \\t\\n'\\\"\\033?""?/\\\\\"", "\"a:b\"", "\"a\\\\b\"", + "\"a' b\"", "\"" LQ_ENC RQ_ENC "\"", "\"" LQ RQ "\"" }, + { "\"\"", "\"\\0001\\0\"", 9, "\"simple\"", + "\" \\t\\n'\\\"\\033?""?/\\\\\"", "\"a\\:b\"", "\"a\\\\b\"", + "\"a' b\"", "\"" LQ_ENC RQ_ENC "\"", "\"" LQ RQ "\"" } }, + + /* c_maybe_quoting_style */ + { { "", "\"\\0001\\0\"", 9, "simple", "\" \\t\\n'\\\"\\033?""?/\\\\\"", + "a:b", "a\\b", "a' b", "\"" LQ_ENC RQ_ENC "\"", LQ RQ }, + { "", "\"\\0001\\0\"", 9, "simple", "\" \\t\\n'\\\"\\033?""?/\\\\\"", + "a:b", "a\\b", "a' b", "\"" LQ_ENC RQ_ENC "\"", LQ RQ }, + { "", "\"\\0001\\0\"", 9, "simple", "\" \\t\\n'\\\"\\033?""?/\\\\\"", + "\"a:b\"", "a\\b", "a' b", "\"" LQ_ENC RQ_ENC "\"", LQ RQ } }, + + /* escape_quoting_style */ + { { "", "\\0001\\0", 7, "simple", " \\t\\n'\"\\033?""?/\\\\", "a:b", + "a\\\\b", "a' b", LQ_ENC RQ_ENC, LQ RQ }, + { "", "\\0001\\0", 7, "simple", " \\t\\n'\"\\033?""?/\\\\", "a:b", + "a\\\\b", "a' b", LQ_ENC RQ_ENC, LQ RQ }, + { "", "\\0001\\0", 7, "simple", " \\t\\n'\"\\033?""?/\\\\", "a\\:b", + "a\\\\b", "a' b", LQ_ENC RQ_ENC, LQ RQ } }, + + /* locale_quoting_style */ + { { "''", "'\\0001\\0'", 9, "'simple'", "' \\t\\n\\'\"\\033?""?/\\\\'", + "'a:b'", "'a\\\\b'", "'a\\' b'", "'" LQ_ENC RQ_ENC "'", "'" LQ RQ "'" }, + { "''", "'\\0001\\0'", 9, "'simple'", "' \\t\\n\\'\"\\033?""?/\\\\'", + "'a:b'", "'a\\\\b'", "'a\\' b'", "'" LQ_ENC RQ_ENC "'", "'" LQ RQ "'" }, + { "''", "'\\0001\\0'", 9, "'simple'", "' \\t\\n\\'\"\\033?""?/\\\\'", + "'a\\:b'", "'a\\\\b'", "'a\\' b'", + "'" LQ_ENC RQ_ENC "'", "'" LQ RQ "'" } }, + + /* clocale_quoting_style */ + { { "\"\"", "\"\\0001\\0\"", 9, "\"simple\"", + "\" \\t\\n'\\\"\\033?""?/\\\\\"", "\"a:b\"", "\"a\\\\b\"", + "\"a' b\"", "\"" LQ_ENC RQ_ENC "\"", "\"" LQ RQ "\"" }, + { "\"\"", "\"\\0001\\0\"", 9, "\"simple\"", + "\" \\t\\n'\\\"\\033?""?/\\\\\"", "\"a:b\"", "\"a\\\\b\"", + "\"a' b\"", "\"" LQ_ENC RQ_ENC "\"", "\"" LQ RQ "\"" }, + { "\"\"", "\"\\0001\\0\"", 9, "\"simple\"", + "\" \\t\\n'\\\"\\033?""?/\\\\\"", "\"a\\:b\"", "\"a\\\\b\"", + "\"a' b\"", "\"" LQ_ENC RQ_ENC "\"", "\"" LQ RQ "\"" } } +}; + +static struct result_groups flag_results[] = { + /* literal_quoting_style and QA_ELIDE_NULL_BYTES */ + { { "", "1", 1, "simple", " \t\n'\"\033?""?/\\", "a:b", "a\\b", "a' b", + LQ RQ, LQ RQ }, + { "", "1", 1, "simple", " \t\n'\"\033?""?/\\", "a:b", "a\\b", "a' b", + LQ RQ, LQ RQ }, + { "", "1", 1, "simple", " \t\n'\"\033?""?/\\", "a:b", "a\\b", "a' b", + LQ RQ, LQ RQ } }, + + /* c_quoting_style and QA_ELIDE_OUTER_QUOTES */ + { { "", "\"\\0001\\0\"", 9, "simple", "\" \\t\\n'\\\"\\033?""?/\\\\\"", + "a:b", "a\\b", "a' b", "\"" LQ_ENC RQ_ENC "\"", LQ RQ }, + { "", "\"\\0001\\0\"", 9, "simple", "\" \\t\\n'\\\"\\033?""?/\\\\\"", + "a:b", "a\\b", "a' b", "\"" LQ_ENC RQ_ENC "\"", LQ RQ }, + { "", "\"\\0001\\0\"", 9, "simple", "\" \\t\\n'\\\"\\033?""?/\\\\\"", + "\"a:b\"", "a\\b", "a' b", "\"" LQ_ENC RQ_ENC "\"", LQ RQ } }, + + /* c_quoting_style and QA_SPLIT_TRIGRAPHS */ + { { "\"\"", "\"\\0001\\0\"", 9, "\"simple\"", + "\" \\t\\n'\\\"\\033?\"\"?/\\\\\"", "\"a:b\"", "\"a\\\\b\"", + "\"a' b\"", "\"" LQ_ENC RQ_ENC "\"", "\"" LQ RQ "\"" }, + { "\"\"", "\"\\0001\\0\"", 9, "\"simple\"", + "\" \\t\\n'\\\"\\033?\"\"?/\\\\\"", "\"a:b\"", "\"a\\\\b\"", + "\"a' b\"", "\"" LQ_ENC RQ_ENC "\"", "\"" LQ RQ "\"" }, + { "\"\"", "\"\\0001\\0\"", 9, "\"simple\"", + "\" \\t\\n'\\\"\\033?\"\"?/\\\\\"", "\"a\\:b\"", "\"a\\\\b\"", + "\"a' b\"", "\"" LQ_ENC RQ_ENC "\"", "\"" LQ RQ "\"" } } +}; + +static char const *custom_quotes[][2] = { + { "", "" }, + { "'", "'" }, + { "(", ")" }, + { ":", " " }, + { " ", ":" }, + { "# ", "\n" }, + { "\"'", "'\"" } +}; + +static struct result_groups custom_results[] = { + /* left_quote = right_quote = "" */ + { { "", "\\0001\\0", 7, "simple", + " \\t\\n'\"\\033?""?/\\\\", "a:b", "a\\\\b", + "a' b", LQ_ENC RQ_ENC, LQ RQ }, + { "", "\\0001\\0", 7, "simple", + " \\t\\n'\"\\033?""?/\\\\", "a:b", "a\\\\b", + "a' b", LQ_ENC RQ_ENC, LQ RQ }, + { "", "\\0001\\0", 7, "simple", + " \\t\\n'\"\\033?""?/\\\\", "a\\:b", "a\\\\b", + "a' b", LQ_ENC RQ_ENC, LQ RQ } }, + + /* left_quote = right_quote = "'" */ + { { "''", "'\\0001\\0'", 9, "'simple'", + "' \\t\\n\\'\"\\033?""?/\\\\'", "'a:b'", "'a\\\\b'", + "'a\\' b'", "'" LQ_ENC RQ_ENC "'", "'" LQ RQ "'" }, + { "''", "'\\0001\\0'", 9, "'simple'", + "' \\t\\n\\'\"\\033?""?/\\\\'", "'a:b'", "'a\\\\b'", + "'a\\' b'", "'" LQ_ENC RQ_ENC "'", "'" LQ RQ "'" }, + { "''", "'\\0001\\0'", 9, "'simple'", + "' \\t\\n\\'\"\\033?""?/\\\\'", "'a\\:b'", "'a\\\\b'", + "'a\\' b'", "'" LQ_ENC RQ_ENC "'", "'" LQ RQ "'" } }, + + /* left_quote = "(" and right_quote = ")" */ + { { "()", "(\\0001\\0)", 9, "(simple)", + "( \\t\\n'\"\\033?""?/\\\\)", "(a:b)", "(a\\\\b)", + "(a' b)", "(" LQ_ENC RQ_ENC ")", "(" LQ RQ ")" }, + { "()", "(\\0001\\0)", 9, "(simple)", + "( \\t\\n'\"\\033?""?/\\\\)", "(a:b)", "(a\\\\b)", + "(a' b)", "(" LQ_ENC RQ_ENC ")", "(" LQ RQ ")" }, + { "()", "(\\0001\\0)", 9, "(simple)", + "( \\t\\n'\"\\033?""?/\\\\)", "(a\\:b)", "(a\\\\b)", + "(a' b)", "(" LQ_ENC RQ_ENC ")", "(" LQ RQ ")" } }, + + /* left_quote = ":" and right_quote = " " */ + { { ": ", ":\\0001\\0 ", 9, ":simple ", + ":\\ \\t\\n'\"\\033?""?/\\\\ ", ":a:b ", ":a\\\\b ", + ":a'\\ b ", ":" LQ_ENC RQ_ENC " ", ":" LQ RQ " " }, + { ": ", ":\\0001\\0 ", 9, ":simple ", + ":\\ \\t\\n'\"\\033?""?/\\\\ ", ":a:b ", ":a\\\\b ", + ":a'\\ b ", ":" LQ_ENC RQ_ENC " ", ":" LQ RQ " " }, + { ": ", ":\\0001\\0 ", 9, ":simple ", + ":\\ \\t\\n'\"\\033?""?/\\\\ ", ":a\\:b ", ":a\\\\b ", + ":a'\\ b ", ":" LQ_ENC RQ_ENC " ", ":" LQ RQ " " } }, + + /* left_quote = " " and right_quote = ":" */ + { { " :", " \\0001\\0:", 9, " simple:", + " \\t\\n'\"\\033?""?/\\\\:", " a\\:b:", " a\\\\b:", + " a' b:", " " LQ_ENC RQ_ENC ":", " " LQ RQ ":" }, + { " :", " \\0001\\0:", 9, " simple:", + " \\t\\n'\"\\033?""?/\\\\:", " a\\:b:", " a\\\\b:", + " a' b:", " " LQ_ENC RQ_ENC ":", " " LQ RQ ":" }, + { " :", " \\0001\\0:", 9, " simple:", + " \\t\\n'\"\\033?""?/\\\\:", " a\\:b:", " a\\\\b:", + " a' b:", " " LQ_ENC RQ_ENC ":", " " LQ RQ ":" } }, + + /* left_quote = "# " and right_quote = "\n" */ + { { "# \n", "# \\0001\\0\n", 10, "# simple\n", + "# \\t\\n'\"\\033?""?/\\\\\n", "# a:b\n", "# a\\\\b\n", + "# a' b\n", "# " LQ_ENC RQ_ENC "\n", "# " LQ RQ "\n" }, + { "# \n", "# \\0001\\0\n", 10, "# simple\n", + "# \\t\\n'\"\\033?""?/\\\\\n", "# a:b\n", "# a\\\\b\n", + "# a' b\n", "# " LQ_ENC RQ_ENC "\n", "# " LQ RQ "\n" }, + { "# \n", "# \\0001\\0\n", 10, "# simple\n", + "# \\t\\n'\"\\033?""?/\\\\\n", "# a\\:b\n", "# a\\\\b\n", + "# a' b\n", "# " LQ_ENC RQ_ENC "\n", "# " LQ RQ "\n" } }, + + /* left_quote = "\"'" and right_quote = "'\"" */ + { { "\"''\"", "\"'\\0001\\0'\"", 11, "\"'simple'\"", + "\"' \\t\\n\\'\"\\033?""?/\\\\'\"", "\"'a:b'\"", "\"'a\\\\b'\"", + "\"'a' b'\"", "\"'" LQ_ENC RQ_ENC "'\"", "\"'" LQ RQ "'\"" }, + { "\"''\"", "\"'\\0001\\0'\"", 11, "\"'simple'\"", + "\"' \\t\\n\\'\"\\033?""?/\\\\'\"", "\"'a:b'\"", "\"'a\\\\b'\"", + "\"'a' b'\"", "\"'" LQ_ENC RQ_ENC "'\"", "\"'" LQ RQ "'\"" }, + { "\"''\"", "\"'\\0001\\0'\"", 11, "\"'simple'\"", + "\"' \\t\\n\\'\"\\033?""?/\\\\'\"", "\"'a\\:b'\"", "\"'a\\\\b'\"", + "\"'a' b'\"", "\"'" LQ_ENC RQ_ENC "'\"", "\"'" LQ RQ "'\"" } } +}; + +static char * +use_quote_double_quotes (const char *str, size_t *len) +{ + char *p = *len == SIZE_MAX ? quotearg_char (str, '"') + : quotearg_char_mem (str, *len, '"'); + *len = strlen (p); + return p; +} + +int +main (int argc _GL_UNUSED, char *argv[]) +{ + int i; + bool ascii_only = MB_CUR_MAX == 1 && !isprint ((unsigned char) LQ[0]); + + /* This part of the program is hard-wired to the C locale since it + does not call setlocale. However, according to POSIX, the use of + 8-bit bytes in a character context in the C locale gives + unspecified results (that is, the C locale charset is allowed to + be unibyte with 8-bit bytes rejected [ASCII], unibyte with 8-bit + bytes being characters [often ISO-8859-1], or multibyte [often + UTF-8]). We assume that the latter two cases will be + indistinguishable in this test - that is, the LQ and RQ sequences + will pass through unchanged in either type of charset. So when + testing for quoting of str7, use the ascii_only flag to decide + what to expect for the 8-bit data being quoted. */ + ASSERT (!isprint ('\033')); + for (i = literal_quoting_style; i <= clocale_quoting_style; i++) + { + set_quoting_style (NULL, (enum quoting_style) i); + if (!(i == locale_quoting_style || i == clocale_quoting_style) + || (strcmp (locale_charset (), "ASCII") == 0 + || strcmp (locale_charset (), "ANSI_X3.4-1968") == 0)) + { + compare_strings (use_quotearg_buffer, &results_g[i].group1, + ascii_only); + compare_strings (use_quotearg, &results_g[i].group2, + ascii_only); + if (i == c_quoting_style) + compare_strings (use_quote_double_quotes, &results_g[i].group2, + ascii_only); + compare_strings (use_quotearg_colon, &results_g[i].group3, + ascii_only); + } + } + + set_quoting_style (NULL, literal_quoting_style); + ASSERT (set_quoting_flags (NULL, QA_ELIDE_NULL_BYTES) == 0); + compare_strings (use_quotearg_buffer, &flag_results[0].group1, ascii_only); + compare_strings (use_quotearg, &flag_results[0].group2, ascii_only); + compare_strings (use_quotearg_colon, &flag_results[0].group3, ascii_only); + + set_quoting_style (NULL, c_quoting_style); + ASSERT (set_quoting_flags (NULL, QA_ELIDE_OUTER_QUOTES) + == QA_ELIDE_NULL_BYTES); + compare_strings (use_quotearg_buffer, &flag_results[1].group1, ascii_only); + compare_strings (use_quotearg, &flag_results[1].group2, ascii_only); + compare_strings (use_quote_double_quotes, &flag_results[1].group2, + ascii_only); + compare_strings (use_quotearg_colon, &flag_results[1].group3, ascii_only); + + ASSERT (set_quoting_flags (NULL, QA_SPLIT_TRIGRAPHS) + == QA_ELIDE_OUTER_QUOTES); + compare_strings (use_quotearg_buffer, &flag_results[2].group1, ascii_only); + compare_strings (use_quotearg, &flag_results[2].group2, ascii_only); + compare_strings (use_quote_double_quotes, &flag_results[2].group2, + ascii_only); + compare_strings (use_quotearg_colon, &flag_results[2].group3, ascii_only); + + ASSERT (set_quoting_flags (NULL, 0) == QA_SPLIT_TRIGRAPHS); + + for (i = 0; i < sizeof custom_quotes / sizeof *custom_quotes; ++i) + { + set_custom_quoting (NULL, + custom_quotes[i][0], custom_quotes[i][1]); + compare_strings (use_quotearg_buffer, &custom_results[i].group1, + ascii_only); + compare_strings (use_quotearg, &custom_results[i].group2, ascii_only); + compare_strings (use_quotearg_colon, &custom_results[i].group3, + ascii_only); + } + + { + /* Trigger the bug whereby quotearg_buffer would read beyond the NUL + that defines the end of the string being quoted. Use an input + string whose NUL is the last byte before an unreadable page. */ + char *z = zerosize_ptr (); + + if (z) + { + size_t q_len = 1024; + char *q = malloc (q_len + 1); + char buf[10]; + memset (q, 'Q', q_len); + q[q_len] = 0; + + /* Z points to the boundary between a readable/writable page + and one that is neither readable nor writable. Position + our string so its NUL is at the end of the writable one. */ + char const *str = "____"; + size_t s_len = strlen (str); + z -= s_len + 1; + memcpy (z, str, s_len + 1); + + set_custom_quoting (NULL, q, q); + /* Whether this actually triggers a SEGV depends on the + implementation of memcmp: whether it compares only byte-at- + a-time, and from left to right (no SEGV) or some other way. */ + size_t n = quotearg_buffer (buf, sizeof buf, z, SIZE_MAX, NULL); + ASSERT (n == s_len + 2 * q_len); + ASSERT (memcmp (buf, q, sizeof buf) == 0); + free (q); + } + } + + quotearg_free (); + + return 0; +} diff --git a/gnulib-tests/test-quotearg.h b/gnulib-tests/test-quotearg.h new file mode 100644 index 0000000..dd7529a --- /dev/null +++ b/gnulib-tests/test-quotearg.h @@ -0,0 +1,128 @@ +/* Test of quotearg family of functions. + Copyright (C) 2008-2020 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, 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2008. */ + +struct result_strings { + char const *str1; /* Translation of "". */ + char const *str2; /* Translation of "\0""1\0". */ + size_t len2; /* Length of str2. */ + char const *str3; /* Translation of "simple". */ + char const *str4; /* Translation of " \t\n'\"\033?""?/\\". */ + char const *str5; /* Translation of "a:b". */ + char const *str6; /* Translation of "a\\b". */ + char const *str7; /* Translation of "a' b". */ + char const *str8a; /* Translation of LQ RQ, in ASCII charset. */ + char const *str8b; /* Translation of LQ RQ, in Latin1 or UTF-8 charset. */ +}; + +struct result_groups { + struct result_strings group1; /* Via quotearg_buffer. */ + struct result_strings group2; /* Via quotearg{,_mem}. */ + struct result_strings group3; /* Via quotearg_colon{,_mem}. */ +}; + +/* These quotes are borrowed from a pt_PT.utf8 translation. */ +# define LQ "\302\253" +# define RQ "\302\273" +# define LQ_ENC "\\302\\253" +# define RQ_ENC "\\302\\273" +# define RQ_ESC "\\\302\273" + +static struct result_strings inputs = { + "", "\0001\0", 3, "simple", " \t\n'\"\033?""?/\\", "a:b", "a\\b", + "a' b", LQ RQ, NULL +}; + +static void +compare (char const *a, size_t la, char const *b, size_t lb) +{ + ASSERT (la == lb); + ASSERT (memcmp (a, b, la) == 0); + ASSERT (b[lb] == '\0'); +} + +static void +compare_strings (char *(func) (char const *, size_t *), + struct result_strings *results, bool ascii_only) +{ + size_t len; + char *p; + + len = 0; + p = func (inputs.str1, &len); + compare (results->str1, strlen (results->str1), p, len); + + len = inputs.len2; + p = func (inputs.str2, &len); + compare (results->str2, results->len2, p, len); + + len = SIZE_MAX; + p = func (inputs.str3, &len); + compare (results->str3, strlen (results->str3), p, len); + + len = strlen (inputs.str4); + p = func (inputs.str4, &len); + compare (results->str4, strlen (results->str4), p, len); + + len = SIZE_MAX; + p = func (inputs.str5, &len); + compare (results->str5, strlen (results->str5), p, len); + + len = strlen (inputs.str6); + p = func (inputs.str6, &len); + compare (results->str6, strlen (results->str6), p, len); + + len = strlen (inputs.str7); + p = func (inputs.str7, &len); + compare (results->str7, strlen (results->str7), p, len); + + len = strlen (inputs.str8a); + p = func (inputs.str8a, &len); + if (ascii_only) + compare (results->str8a, strlen (results->str8a), p, len); + else + compare (results->str8b, strlen (results->str8b), p, len); +} + +static char * +use_quotearg_buffer (const char *str, size_t *len) +{ + static char buf[100]; + size_t size; + memset (buf, 0xa5, 100); + size = quotearg_buffer (buf, 100, str, *len, NULL); + *len = size; + ASSERT ((unsigned char) buf[size + 1] == 0xa5); + return buf; +} + +static char * +use_quotearg (const char *str, size_t *len) +{ + char *p = *len == SIZE_MAX ? quotearg (str) : quotearg_mem (str, *len); + *len = strlen (p); + return p; +} + +static char * +use_quotearg_colon (const char *str, size_t *len) +{ + char *p = (*len == SIZE_MAX ? quotearg_colon (str) + : quotearg_colon_mem (str, *len)); + *len = strlen (p); + return p; +} diff --git a/gnulib-tests/test-raise.c b/gnulib-tests/test-raise.c new file mode 100644 index 0000000..9135623 --- /dev/null +++ b/gnulib-tests/test-raise.c @@ -0,0 +1,50 @@ +/* Test raising a signal. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <signal.h> + +#include "signature.h" +SIGNATURE_CHECK (raise, int, (int)); + +#include <stdlib.h> + +#include "macros.h" + +/* It is safe to use _Noreturn here: exit() never returns, and GCC knows that + exit() is a non-returning function, even on platforms where its declaration + in <stdlib.h> does not have the 'noreturn' attribute. */ +static _Noreturn void +handler (int sig) +{ + exit (0); +} + +int +main (void) +{ + /* Test behaviour for invalid argument. */ + ASSERT (raise (-1) != 0); + + /* Test behaviour for SIGINT. */ + ASSERT (signal (SIGINT, handler) != SIG_ERR); + + raise (SIGINT); + + /* We should not get here, because the handler takes away the control. */ + exit (1); +} diff --git a/gnulib-tests/test-rand-isaac.c b/gnulib-tests/test-rand-isaac.c new file mode 100644 index 0000000..75b2d81 --- /dev/null +++ b/gnulib-tests/test-rand-isaac.c @@ -0,0 +1,591 @@ +/* Test the ISAAC or ISAAC64 pseudorandom number generator. + + Copyright (C) 2010-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Paul Eggert. */ + +#include <config.h> + +#include "rand-isaac.h" + +#include <fcntl.h> +#include <stdint.h> +#include <string.h> + +#include "macros.h" + +/* This expected output was generated by running the programs in + <http://burtleburtle.net/bob/rand/isaacafa.html>, as last modified + on 2010-01-22. The 32-bit numbers were output by rand.c, and the + 64-bit by isaac64.c, both on x86, as those programs are not + portable to 64-bit platforms. */ + +static isaac_word const expected[2][ISAAC_WORDS] = + { + #if ISAAC_BITS == 32 + { + UINT32_C (0xf650e4c8), UINT32_C (0xe448e96d), + UINT32_C (0x98db2fb4), UINT32_C (0xf5fad54f), + UINT32_C (0x433f1afb), UINT32_C (0xedec154a), + UINT32_C (0xd8370487), UINT32_C (0x46ca4f9a), + UINT32_C (0x5de3743e), UINT32_C (0x88381097), + UINT32_C (0xf1d444eb), UINT32_C (0x823cedb6), + UINT32_C (0x6a83e1e0), UINT32_C (0x4a5f6355), + UINT32_C (0xc7442433), UINT32_C (0x25890e2e), + UINT32_C (0x7452e319), UINT32_C (0x57161df6), + UINT32_C (0x38a824f3), UINT32_C (0x002ed713), + UINT32_C (0x29f55449), UINT32_C (0x51c08d83), + UINT32_C (0xd78cb99e), UINT32_C (0xa0cc74f3), + UINT32_C (0x8f651659), UINT32_C (0xcbc8b7c2), + UINT32_C (0xf5f71c69), UINT32_C (0x12ad6419), + UINT32_C (0xe5792e1b), UINT32_C (0x860536b8), + UINT32_C (0x09b3ce98), UINT32_C (0xd45d6d81), + UINT32_C (0xf3b26129), UINT32_C (0x17e38f85), + UINT32_C (0x29cf72ce), UINT32_C (0x349947b0), + UINT32_C (0xc998f9ff), UINT32_C (0xb5e13dae), + UINT32_C (0x32ae2a2b), UINT32_C (0xf7cf814c), + UINT32_C (0x8ebfa303), UINT32_C (0xcf22e064), + UINT32_C (0x0b923200), UINT32_C (0xeca4d58a), + UINT32_C (0xef53cec4), UINT32_C (0xd0f7b37d), + UINT32_C (0x9c411a2a), UINT32_C (0xffdf8a80), + UINT32_C (0xb40e27bc), UINT32_C (0xb4d2f976), + UINT32_C (0x44b89b08), UINT32_C (0xf37c71d5), + UINT32_C (0x1a70e7e9), UINT32_C (0x0bdb9c30), + UINT32_C (0x60dc5207), UINT32_C (0xb3c3f24b), + UINT32_C (0xd7386806), UINT32_C (0x229749b5), + UINT32_C (0x4e232cd0), UINT32_C (0x91dabc65), + UINT32_C (0xa70e1101), UINT32_C (0x8b87437e), + UINT32_C (0x5781414f), UINT32_C (0xcdbc62e2), + UINT32_C (0x8107c9ff), UINT32_C (0x69d2e4ae), + UINT32_C (0x3b18e752), UINT32_C (0xb143b688), + UINT32_C (0x6f4e0772), UINT32_C (0x95138769), + UINT32_C (0x943c3c74), UINT32_C (0xafc17a97), + UINT32_C (0x0fd43963), UINT32_C (0x6a529b0b), + UINT32_C (0xd8c58a6a), UINT32_C (0xa8bcc22d), + UINT32_C (0x2db35dfe), UINT32_C (0xa7a2f402), + UINT32_C (0x6cb167db), UINT32_C (0x538e1f4e), + UINT32_C (0x7275e277), UINT32_C (0x1d3b8e97), + UINT32_C (0xecc5dc91), UINT32_C (0x15e3a5b9), + UINT32_C (0x03696614), UINT32_C (0x30ab93ec), + UINT32_C (0xac9fe69d), UINT32_C (0x7bc76811), + UINT32_C (0x60eda8da), UINT32_C (0x28833522), + UINT32_C (0xd5295ebc), UINT32_C (0x5adb60e7), + UINT32_C (0xf7e1cdd0), UINT32_C (0x97166d14), + UINT32_C (0xb67ec13a), UINT32_C (0x210f3925), + UINT32_C (0x64af0fef), UINT32_C (0x0d028684), + UINT32_C (0x3aea3dec), UINT32_C (0xb058bafb), + UINT32_C (0xb8b0ccfc), UINT32_C (0xf2b5cc05), + UINT32_C (0xe3a662d9), UINT32_C (0x814bc24c), + UINT32_C (0x2364a1aa), UINT32_C (0x37c0ed05), + UINT32_C (0x2b36505c), UINT32_C (0x451e7ec8), + UINT32_C (0x5d2a542f), UINT32_C (0xe43d0fbb), + UINT32_C (0x91c8d925), UINT32_C (0x60d4d5f8), + UINT32_C (0x12a0594b), UINT32_C (0x9e8a51da), + UINT32_C (0xcd49ebdb), UINT32_C (0x1b0dcdc1), + UINT32_C (0xcd57c7f7), UINT32_C (0xe6344451), + UINT32_C (0x7ded386f), UINT32_C (0x2f36fa86), + UINT32_C (0xa6d12101), UINT32_C (0x33bc405d), + UINT32_C (0xb388d96c), UINT32_C (0xdb6dbe96), + UINT32_C (0xfe29661c), UINT32_C (0x13edc0cb), + UINT32_C (0xcb0eee4a), UINT32_C (0x70cc94ae), + UINT32_C (0xde11ed34), UINT32_C (0x0606cf9f), + UINT32_C (0x3a6ce389), UINT32_C (0x23d74f4e), + UINT32_C (0xa37f63ff), UINT32_C (0x917bdec2), + UINT32_C (0xd73f72d4), UINT32_C (0x0e7e0e67), + UINT32_C (0x3d77d9a2), UINT32_C (0x13add922), + UINT32_C (0x8891b3db), UINT32_C (0x01a9bd70), + UINT32_C (0x56a001e3), UINT32_C (0xd51f093d), + UINT32_C (0xcc033ce3), UINT32_C (0x5ad0d3b0), + UINT32_C (0x34105a8c), UINT32_C (0x6a123f57), + UINT32_C (0xbd2e5024), UINT32_C (0x7364944b), + UINT32_C (0xe89b1a3b), UINT32_C (0x21835c4d), + UINT32_C (0x9f39e2d9), UINT32_C (0xd405ded8), + UINT32_C (0x294d37e5), UINT32_C (0xbccaaeed), + UINT32_C (0x35a124b5), UINT32_C (0x6708a2bc), + UINT32_C (0xb00960ba), UINT32_C (0x2a98121a), + UINT32_C (0x4d8fae82), UINT32_C (0x0bb3263f), + UINT32_C (0x12595a19), UINT32_C (0x6a107589), + UINT32_C (0x0809e494), UINT32_C (0x21c171ec), + UINT32_C (0x884d6825), UINT32_C (0x14c8009b), + UINT32_C (0xb0b84e7b), UINT32_C (0x03fb88f4), + UINT32_C (0x28e7cb78), UINT32_C (0x9388b13b), + UINT32_C (0xdd2dc1d5), UINT32_C (0x848f520a), + UINT32_C (0x07c28cd1), UINT32_C (0x68a39358), + UINT32_C (0x72c9137d), UINT32_C (0x127dd430), + UINT32_C (0xc613f157), UINT32_C (0x8c2f0d55), + UINT32_C (0xf7d3f39f), UINT32_C (0x309bfb78), + UINT32_C (0x8406b137), UINT32_C (0x46c0a6f5), + UINT32_C (0x3718d597), UINT32_C (0x08607f04), + UINT32_C (0x76904b6d), UINT32_C (0x04db4e13), + UINT32_C (0xcd7411a7), UINT32_C (0xb510ce0e), + UINT32_C (0xbfc7f7cc), UINT32_C (0xb83f957a), + UINT32_C (0xfdfef62d), UINT32_C (0xc35e4580), + UINT32_C (0x3ff1e524), UINT32_C (0x4112d96c), + UINT32_C (0x02c9b944), UINT32_C (0xd5990dfb), + UINT32_C (0xe7e26581), UINT32_C (0x0d9c7e7e), + UINT32_C (0x826dfa89), UINT32_C (0x66f1e0ab), + UINT32_C (0x30bcc764), UINT32_C (0xeadebeac), + UINT32_C (0xed35e5ee), UINT32_C (0x0c571a7d), + UINT32_C (0xe4f3a26a), UINT32_C (0xf7f58f7b), + UINT32_C (0xadf6bc23), UINT32_C (0x5d023e65), + UINT32_C (0x1ed3ff4e), UINT32_C (0xec46b0b6), + UINT32_C (0xd2a93b51), UINT32_C (0xe75b41c9), + UINT32_C (0x7e315aeb), UINT32_C (0x61119a5a), + UINT32_C (0x53245b79), UINT32_C (0x33f6d7b1), + UINT32_C (0xcae8deba), UINT32_C (0x50fc8194), + UINT32_C (0xafa92a6d), UINT32_C (0xc87c8006), + UINT32_C (0x4188bfcd), UINT32_C (0x8bace62e), + UINT32_C (0x78ffa568), UINT32_C (0x5597ec0f), + UINT32_C (0xb4415f7d), UINT32_C (0x08294766), + UINT32_C (0xad567643), UINT32_C (0x09c36f90), + UINT32_C (0x3dde9f39), UINT32_C (0x4a0a283c), + UINT32_C (0x18080c8e), UINT32_C (0x080c79ec), + UINT32_C (0x79ae4c10), UINT32_C (0xcb9e1563), + UINT32_C (0x7cdd662f), UINT32_C (0x62d31911), + UINT32_C (0xa4ca0cf1), UINT32_C (0x5cf824cd), + UINT32_C (0x3b708f99), UINT32_C (0x1e16614c), + UINT32_C (0xb6b9d766), UINT32_C (0x5de87abb), + UINT32_C (0x7229ea81), UINT32_C (0xd5b2d750), + UINT32_C (0x56e6cd21), UINT32_C (0xfe1e42d5), + UINT32_C (0x96da2655), UINT32_C (0xc2b9aa36), + UINT32_C (0xb8f6fd4a), UINT32_C (0x6a158d10), + UINT32_C (0x01913fd3), UINT32_C (0xaf7d1fb8), + UINT32_C (0x0b5e435f), UINT32_C (0x90c10757), + UINT32_C (0x6554abda), UINT32_C (0x7a68710f) + }, + { + UINT32_C (0x82ac484f), UINT32_C (0xd7e1c7be), + UINT32_C (0x95c85eaa), UINT32_C (0x94a302f4), + UINT32_C (0x4d3cfbda), UINT32_C (0x786b2908), + UINT32_C (0x1010b275), UINT32_C (0x82d53d12), + UINT32_C (0x21e2a51c), UINT32_C (0x3d1e9150), + UINT32_C (0xb059261d), UINT32_C (0xd0638e1a), + UINT32_C (0x31860f05), UINT32_C (0x81f2864d), + UINT32_C (0xff4cfc35), UINT32_C (0x0451516d), + UINT32_C (0xbd086f26), UINT32_C (0xbc5654c1), + UINT32_C (0x65dfa427), UINT32_C (0xa82427f5), + UINT32_C (0x582e3014), UINT32_C (0xb8d2486d), + UINT32_C (0xc79a1749), UINT32_C (0x9a1d7745), + UINT32_C (0x8766bb54), UINT32_C (0x1e04a7f7), + UINT32_C (0x3d3dff8a), UINT32_C (0xd5ec6bf4), + UINT32_C (0xdbef7d9f), UINT32_C (0x36ec0ea3), + UINT32_C (0x1feb2e4f), UINT32_C (0x15cfcc5c), + UINT32_C (0xd8c423fb), UINT32_C (0xd0ef3cc9), + UINT32_C (0xeb244925), UINT32_C (0xba5590c8), + UINT32_C (0xa5f48ac4), UINT32_C (0x33c5321c), + UINT32_C (0x613b67b2), UINT32_C (0x479c3a22), + UINT32_C (0xe21339cc), UINT32_C (0x10d210aa), + UINT32_C (0x931dd7e2), UINT32_C (0xef05ee06), + UINT32_C (0xb82f2703), UINT32_C (0xa385cb2c), + UINT32_C (0x5d67133c), UINT32_C (0x877eb7b4), + UINT32_C (0x1e3437f7), UINT32_C (0x5afb43ae), + UINT32_C (0x53c078f3), UINT32_C (0x94d90481), + UINT32_C (0x1d964589), UINT32_C (0x08063a85), + UINT32_C (0xe1322228), UINT32_C (0x1956b1e5), + UINT32_C (0x31860f13), UINT32_C (0x2e7b022f), + UINT32_C (0x21182ca3), UINT32_C (0x96f703ac), + UINT32_C (0x46819e2e), UINT32_C (0x0d28fe52), + UINT32_C (0x3724d4dc), UINT32_C (0xa0eabe6b), + UINT32_C (0xc66699fd), UINT32_C (0xc6112fdd), + UINT32_C (0x19c1e69c), UINT32_C (0x04d3658a), + UINT32_C (0x4b55dd99), UINT32_C (0x31907d62), + UINT32_C (0xf854b522), UINT32_C (0x4d678f26), + UINT32_C (0x22ae0582), UINT32_C (0xeafed133), + UINT32_C (0xe4a51d21), UINT32_C (0x84bd6dd6), + UINT32_C (0xc1a51375), UINT32_C (0x3f28ee63), + UINT32_C (0xfb737b1a), UINT32_C (0x70a1660e), + UINT32_C (0x8a8dfaa3), UINT32_C (0x1be79937), + UINT32_C (0xf7476978), UINT32_C (0x513c1764), + UINT32_C (0x531ac6bf), UINT32_C (0x12c06908), + UINT32_C (0x001cdb95), UINT32_C (0x1a4b6a53), + UINT32_C (0xd067fce5), UINT32_C (0x12b2cfb6), + UINT32_C (0x9ddb477f), UINT32_C (0x740e0066), + UINT32_C (0x39ddf25a), UINT32_C (0xcc8bfa2d), + UINT32_C (0xf1b20eaf), UINT32_C (0x64f2632c), + UINT32_C (0x9783cdee), UINT32_C (0x63bfd4d8), + UINT32_C (0x0084cfe5), UINT32_C (0x75f4e9e2), + UINT32_C (0x19b48fd0), UINT32_C (0x6c48ddd8), + UINT32_C (0x7a36af93), UINT32_C (0x71865c4c), + UINT32_C (0x9ce0199d), UINT32_C (0x867027d7), + UINT32_C (0x2cb7b77f), UINT32_C (0x84ef01da), + UINT32_C (0x72f5972f), UINT32_C (0x040f7074), + UINT32_C (0xdf9afa29), UINT32_C (0xc921f94e), + UINT32_C (0x75c08a36), UINT32_C (0x18c1ef9a), + UINT32_C (0xd649a428), UINT32_C (0xc5b71937), + UINT32_C (0x8a30738a), UINT32_C (0xd97cd348), + UINT32_C (0x858129a6), UINT32_C (0x239e3b0a), + UINT32_C (0xbbb8abc4), UINT32_C (0x80fac4c2), + UINT32_C (0xecfcf20b), UINT32_C (0xd9d711f9), + UINT32_C (0xe2a4ef71), UINT32_C (0xb5fe87c0), + UINT32_C (0xbe8b06b2), UINT32_C (0xaafef5a7), + UINT32_C (0x9c15db3b), UINT32_C (0x0aeb8165), + UINT32_C (0x4389a84a), UINT32_C (0x253b1d7a), + UINT32_C (0x19047c79), UINT32_C (0x7cdc78a2), + UINT32_C (0xd20adf03), UINT32_C (0x56f55a71), + UINT32_C (0x3e730fa8), UINT32_C (0xfd8650d8), + UINT32_C (0x959e234e), UINT32_C (0xb7546681), + UINT32_C (0xdad1b22a), UINT32_C (0x142a6e85), + UINT32_C (0x8ef4bce6), UINT32_C (0x68235b9d), + UINT32_C (0x85a13f85), UINT32_C (0x74096ae7), + UINT32_C (0xa949bea2), UINT32_C (0x29322d0d), + UINT32_C (0xd5683858), UINT32_C (0x82846526), + UINT32_C (0x403dae08), UINT32_C (0x6dd1943a), + UINT32_C (0xe1279bff), UINT32_C (0x9e7e4f04), + UINT32_C (0x1c3a4524), UINT32_C (0x484525e4), + UINT32_C (0x81d4cc5f), UINT32_C (0xe24124c0), + UINT32_C (0x037464c0), UINT32_C (0xbf1bd691), + UINT32_C (0x26ceb003), UINT32_C (0x275ead3a), + UINT32_C (0xc5bde908), UINT32_C (0x26414ff3), + UINT32_C (0xa30519ad), UINT32_C (0xd7b43abe), + UINT32_C (0x2ce5d3d5), UINT32_C (0x88412761), + UINT32_C (0x97ca2070), UINT32_C (0xe5fbb9c7), + UINT32_C (0x276df0b4), UINT32_C (0x308f751f), + UINT32_C (0x37a97df6), UINT32_C (0xc9cd808c), + UINT32_C (0xfe4cb380), UINT32_C (0x3d469303), + UINT32_C (0xaee19096), UINT32_C (0xc0d5d42a), + UINT32_C (0x4e823ad3), UINT32_C (0xf5f9cc3b), + UINT32_C (0x4286619c), UINT32_C (0x9ca45e1c), + UINT32_C (0x66c97340), UINT32_C (0x891aec49), + UINT32_C (0x45bae606), UINT32_C (0xc798f047), + UINT32_C (0x52649d6c), UINT32_C (0xce86fdfc), + UINT32_C (0x80c6e402), UINT32_C (0xd6ec2f2b), + UINT32_C (0x27c82282), UINT32_C (0x1fe26ce0), + UINT32_C (0x92f57ea7), UINT32_C (0xde462f4d), + UINT32_C (0x07497cae), UINT32_C (0x5a48755c), + UINT32_C (0x721502dd), UINT32_C (0x6cbe7935), + UINT32_C (0x836d8003), UINT32_C (0x9ead7f70), + UINT32_C (0x9ab3a42f), UINT32_C (0x4c8652d6), + UINT32_C (0x32e39273), UINT32_C (0xe8fa3860), + UINT32_C (0x1da4f25a), UINT32_C (0x0cd6ef81), + UINT32_C (0x02503f7d), UINT32_C (0x8854a0a1), + UINT32_C (0x9a30c4e8), UINT32_C (0x88157153), + UINT32_C (0x05efe294), UINT32_C (0x57c4c925), + UINT32_C (0x2887d96f), UINT32_C (0xc1a71e3c), + UINT32_C (0xe9f84163), UINT32_C (0x2d0985de), + UINT32_C (0xd21e796c), UINT32_C (0x6fb5ce56), + UINT32_C (0x02614abf), UINT32_C (0xc3c7be2c), + UINT32_C (0xb54fed6f), UINT32_C (0xa617a083), + UINT32_C (0xc3142d8f), UINT32_C (0x6079e4ce), + UINT32_C (0xceffc147), UINT32_C (0x1d0cb81b), + UINT32_C (0xdc153e5f), UINT32_C (0xe36ef5bb), + UINT32_C (0xd531161a), UINT32_C (0x165b1015), + UINT32_C (0x7aa114ed), UINT32_C (0x3f7579b3), + UINT32_C (0xf7f395f1), UINT32_C (0xbc6172c7), + UINT32_C (0xa86f875e), UINT32_C (0x0e6c51b3), + UINT32_C (0xcdfec2af), UINT32_C (0x73c0e762), + UINT32_C (0x824c2009), UINT32_C (0xc5a87748), + UINT32_C (0x94d40125), UINT32_C (0x8aba3ffb), + UINT32_C (0xd32be060), UINT32_C (0x8c17eff0), + UINT32_C (0x21e2547e), UINT32_C (0x07cffad9), + UINT32_C (0x05340e15), UINT32_C (0xf3310c92), + UINT32_C (0x9d8d1908), UINT32_C (0x86ba527f), + UINT32_C (0xf943f672), UINT32_C (0xef73fbf0), + UINT32_C (0x46d95ca5), UINT32_C (0xc54cd95b), + UINT32_C (0x9d855e89), UINT32_C (0x4bb5af29) + } + #else + { + UINT64_C (0x12a8f216af9418c2), UINT64_C (0xd4490ad526f14431), + UINT64_C (0xb49c3b3995091a36), UINT64_C (0x5b45e522e4b1b4ef), + UINT64_C (0xa1e9300cd8520548), UINT64_C (0x49787fef17af9924), + UINT64_C (0x03219a39ee587a30), UINT64_C (0xebe9ea2adf4321c7), + UINT64_C (0x804456af10f5fb53), UINT64_C (0xd74bbe77e6116ac7), + UINT64_C (0x7c0828dd624ec390), UINT64_C (0x14a195640116f336), + UINT64_C (0x2eab8ca63ce802d7), UINT64_C (0xc6e57a78fbd986e0), + UINT64_C (0x58efc10b06a2068d), UINT64_C (0xabeeddb2dde06ff1), + UINT64_C (0x0b090a7560a968e3), UINT64_C (0x2cf9c8ca052f6e9f), + UINT64_C (0x116d0016cb948f09), UINT64_C (0xa59e0bd101731a28), + UINT64_C (0x63767572ae3d6174), UINT64_C (0xab4f6451cc1d45ec), + UINT64_C (0xc2a1e7b5b459aeb5), UINT64_C (0x2472f6207c2d0484), + UINT64_C (0xe699ed85b0dfb40d), UINT64_C (0xd4347f66ec8941c3), + UINT64_C (0xf4d14597e660f855), UINT64_C (0x8b889d624d44885d), + UINT64_C (0x258e5a80c7204c4b), UINT64_C (0xaf0c317d32adaa8a), + UINT64_C (0x9c4cd6257c5a3603), UINT64_C (0xeb3593803173e0ce), + UINT64_C (0x36f60e2ba4fa6800), UINT64_C (0x38b6525c21a42b0e), + UINT64_C (0xf4f5d05c10cab243), UINT64_C (0xcf3f4688801eb9aa), + UINT64_C (0x1ddc0325259b27de), UINT64_C (0xb9571fa04dc089c8), + UINT64_C (0xd7504dfa8816edbb), UINT64_C (0x1fe2cca76517db90), + UINT64_C (0x261e4e4c0a333a9d), UINT64_C (0x219b97e26ffc81bd), + UINT64_C (0x66b4835d9eafea22), UINT64_C (0x4cc317fb9cddd023), + UINT64_C (0x50b704cab602c329), UINT64_C (0xedb454e7badc0805), + UINT64_C (0x9e17e49642a3e4c1), UINT64_C (0x66c1a2a1a60cd889), + UINT64_C (0x7983eed3740847d5), UINT64_C (0x298af231c85bafab), + UINT64_C (0x2680b122baa28d97), UINT64_C (0x734de8181f6ec39a), + UINT64_C (0x53898e4c3910da55), UINT64_C (0x1761f93a44d5aefe), + UINT64_C (0xe4dbf0634473f5d2), UINT64_C (0x4ed0fe7e9dc91335), + UINT64_C (0xd18d8549d140caea), UINT64_C (0x1cfc8bed0d681639), + UINT64_C (0xca1e3785a9e724e5), UINT64_C (0xb67c1fa481680af8), + UINT64_C (0xdfea21ea9e7557e3), UINT64_C (0xd6b6d0ecc617c699), + UINT64_C (0xfa7e393983325753), UINT64_C (0xa09e8c8c35ab96de), + UINT64_C (0x8fe88b57305e2ab6), UINT64_C (0x89039d79d6fc5c5c), + UINT64_C (0x9bfb227ebdf4c5ce), UINT64_C (0x7f7cc39420a3a545), + UINT64_C (0x3f6c6af859d80055), UINT64_C (0xc8763c5b08d1908c), + UINT64_C (0x469356c504ec9f9d), UINT64_C (0x26e6db8ffdf5adfe), + UINT64_C (0x3a938fee32d29981), UINT64_C (0x2c5e9deb57ef4743), + UINT64_C (0x1e99b96e70a9be8b), UINT64_C (0x764dbeae7fa4f3a6), + UINT64_C (0xaac40a2703d9bea0), UINT64_C (0x1a8c1e992b941148), + UINT64_C (0x73aa8a564fb7ac9e), UINT64_C (0x604d51b25fbf70e2), + UINT64_C (0xdd69a0d8ab3b546d), UINT64_C (0x65ca5b96b7552210), + UINT64_C (0x2fd7e4b9e72cd38c), UINT64_C (0x51d2b1ab2ddfb636), + UINT64_C (0x9d1d84fcce371425), UINT64_C (0xa44cfe79ae538bbe), + UINT64_C (0xde68a2355b93cae6), UINT64_C (0x9fc10d0f989993e0), + UINT64_C (0x94ebc8abcfb56dae), UINT64_C (0xd7a023a73260b45c), + UINT64_C (0x72c8834a5957b511), UINT64_C (0x8f8419a348f296bf), + UINT64_C (0x1e152328f3318dea), UINT64_C (0x4838d65f6ef6748f), + UINT64_C (0xd6bf7baee43cac40), UINT64_C (0x13328503df48229f), + UINT64_C (0x7440fb816508c4fe), UINT64_C (0x9d266d6a1cc0542c), + UINT64_C (0x4dda48153c94938a), UINT64_C (0x74c04bf1790c0efe), + UINT64_C (0xe1925c71285279f5), UINT64_C (0x8a8e849eb32781a5), + UINT64_C (0x073973751f12dd5e), UINT64_C (0xa319ce15b0b4db31), + UINT64_C (0x6dd856d94d259236), UINT64_C (0x67378d8eccef96cb), + UINT64_C (0x9fc477de4ed681da), UINT64_C (0xf3b8b6675a6507ff), + UINT64_C (0xc3a9dc228caac9e9), UINT64_C (0xc37b45b3f8d6f2ba), + UINT64_C (0xb559eb1d04e5e932), UINT64_C (0x1b0cab936e65c744), + UINT64_C (0xaf08da9177dda93d), UINT64_C (0xac12fb171817eee7), + UINT64_C (0x1fff7ac80904bf45), UINT64_C (0xa9119b60369ffebd), + UINT64_C (0xbfced1b0048eac50), UINT64_C (0xb67b7896167b4c84), + UINT64_C (0x9b3cdb65f82ca382), UINT64_C (0xdbc27ab5447822bf), + UINT64_C (0x10dcd78e3851a492), UINT64_C (0xb438c2b67f98e5e9), + UINT64_C (0x43954b3252dc25e5), UINT64_C (0xab9090168dd05f34), + UINT64_C (0xce68341f79893389), UINT64_C (0x36833336d068f707), + UINT64_C (0xdcdd7d20903d0c25), UINT64_C (0xda3a361b1c5157b1), + UINT64_C (0x7f9d1a2e1ebe1327), UINT64_C (0x5d0a12f27ad310d1), + UINT64_C (0x3bc36e078f7515d7), UINT64_C (0x4da8979a0041e8a9), + UINT64_C (0x950113646d1d6e03), UINT64_C (0x7b4a38e32537df62), + UINT64_C (0x8a1b083821f40cb4), UINT64_C (0x3d5774a11d31ab39), + UINT64_C (0x7a76956c3eafb413), UINT64_C (0x7f5126dbba5e0ca7), + UINT64_C (0x12153635b2c0cf57), UINT64_C (0x7b3f0195fc6f290f), + UINT64_C (0x5544f7d774b14aef), UINT64_C (0x56c074a581ea17fe), + UINT64_C (0xe7f28ecd2d49eecd), UINT64_C (0xe479ee5b9930578c), + UINT64_C (0x9ff38fed72e9052f), UINT64_C (0x9f65789a6509a440), + UINT64_C (0x0981dcd296a8736d), UINT64_C (0x5873888850659ae7), + UINT64_C (0xc678b6d860284a1c), UINT64_C (0x63e22c147b9c3403), + UINT64_C (0x92fae24291f2b3f1), UINT64_C (0x829626e3892d95d7), + UINT64_C (0xcffe1939438e9b24), UINT64_C (0x79999cdff70902cb), + UINT64_C (0x8547eddfb81ccb94), UINT64_C (0x7b77497b32503b12), + UINT64_C (0x97fcaacbf030bc24), UINT64_C (0x6ced1983376fa72b), + UINT64_C (0x7e75d99d94a70f4d), UINT64_C (0xd2733c4335c6a72f), + UINT64_C (0xdbc0d2b6ab90a559), UINT64_C (0x94628d38d0c20584), + UINT64_C (0x64972d68dee33360), UINT64_C (0xb9c11d5b1e43a07e), + UINT64_C (0x2de0966daf2f8b1c), UINT64_C (0x2e18bc1ad9704a68), + UINT64_C (0xd4dba84729af48ad), UINT64_C (0xb7a0b174cff6f36e), + UINT64_C (0xe94c39a54a98307f), UINT64_C (0xaa70b5b4f89695a2), + UINT64_C (0x3bdbb92c43b17f26), UINT64_C (0xcccb7005c6b9c28d), + UINT64_C (0x18a6a990c8b35ebd), UINT64_C (0xfc7c95d827357afa), + UINT64_C (0x1fca8a92fd719f85), UINT64_C (0x1dd01aafcd53486a), + UINT64_C (0x49353fea39ba63b1), UINT64_C (0xf85b2b4fbcde44b7), + UINT64_C (0xbe7444e39328a0ac), UINT64_C (0x3e2b8bcbf016d66d), + UINT64_C (0x964e915cd5e2b207), UINT64_C (0x1725cabfcb045b00), + UINT64_C (0x7fbf21ec8a1f45ec), UINT64_C (0x11317ba87905e790), + UINT64_C (0x2fe4b17170e59750), UINT64_C (0xe8d9ecbe2cf3d73f), + UINT64_C (0xb57d2e985e1419c7), UINT64_C (0x0572b974f03ce0bb), + UINT64_C (0xa8d7e4dab780a08d), UINT64_C (0x4715ed43e8a45c0a), + UINT64_C (0xc330de426430f69d), UINT64_C (0x23b70edb1955c4bf), + UINT64_C (0x098954d51fff6580), UINT64_C (0x8107fccf064fcf56), + UINT64_C (0x852f54934da55cc9), UINT64_C (0x09c7e552bc76492f), + UINT64_C (0xe9f6760e32cd8021), UINT64_C (0xa3bc941d0a5061cb), + UINT64_C (0xba89142e007503b8), UINT64_C (0xdc842b7e2819e230), + UINT64_C (0xbbe83f4ecc2bdecb), UINT64_C (0xcd454f8f19c5126a), + UINT64_C (0xc62c58f97dd949bf), UINT64_C (0x693501d628297551), + UINT64_C (0xb9ab4ce57f2d34f3), UINT64_C (0x9255abb50d532280), + UINT64_C (0xebfafa33d7254b59), UINT64_C (0xe9f6082b05542e4e), + UINT64_C (0x35dd37d5871448af), UINT64_C (0xb03031a8b4516e84), + UINT64_C (0xb3f256d8aca0b0b9), UINT64_C (0x0fd22063edc29fca), + UINT64_C (0xd9a11fbb3d9808e4), UINT64_C (0x3a9bf55ba91f81ca), + UINT64_C (0xc8c93882f9475f5f), UINT64_C (0x947ae053ee56e63c), + UINT64_C (0xc7d9f16864a76e94), UINT64_C (0x7bd94e1d8e17debc), + UINT64_C (0xd873db391292ed4f), UINT64_C (0x30f5611484119414), + UINT64_C (0x565c31f7de89ea27), UINT64_C (0xd0e4366228b03343), + UINT64_C (0x325928ee6e6f8794), UINT64_C (0x6f423357e7c6a9f9), + UINT64_C (0x99170a5dc3115544), UINT64_C (0x59b97885e2f2ea28), + UINT64_C (0xbc4097b116c524d2), UINT64_C (0x7a13f18bbedc4ff5), + UINT64_C (0x071582401c38434d), UINT64_C (0xb422061193d6f6a7), + UINT64_C (0xb4b81b3fa97511e2), UINT64_C (0x65d34954daf3cebd), + UINT64_C (0xb344c470397bba52), UINT64_C (0xbac7a9a18531294b), + UINT64_C (0xecb53939887e8175), UINT64_C (0x565601c0364e3228), + UINT64_C (0xef1955914b609f93), UINT64_C (0x16f50edf91e513af), + UINT64_C (0x56963b0dca418fc0), UINT64_C (0xd60f6dcedc314222), + UINT64_C (0x364f6ffa464ee52e), UINT64_C (0x6c3b8e3e336139d3), + UINT64_C (0xf943aee7febf21b8), UINT64_C (0x088e049589c432e0), + UINT64_C (0xd49503536abca345), UINT64_C (0x3a6c27934e31188a), + UINT64_C (0x957baf61700cff4e), UINT64_C (0x37624ae5a48fa6e9), + UINT64_C (0x501f65edb3034d07), UINT64_C (0x907f30421d78c5de), + UINT64_C (0x1a804aadb9cfa741), UINT64_C (0x0ce2a38c344a6eed), + UINT64_C (0xd363eff5f0977996), UINT64_C (0x2cd16e2abd791e33), + UINT64_C (0x58627e1a149bba21), UINT64_C (0x7f9b6af1ebf78baf) + }, + { + UINT64_C (0xd20d8c88c8ffe65f), UINT64_C (0x917f1dd5f8886c61), + UINT64_C (0x56986e2ef3ed091b), UINT64_C (0x5fa7867caf35e149), + UINT64_C (0x81a1549fd6573da5), UINT64_C (0x96fbf83a12884624), + UINT64_C (0xe728e8c83c334074), UINT64_C (0xf1bcc3d275afe51a), + UINT64_C (0x71f1ce2490d20b07), UINT64_C (0xe6c42178c4bbb92e), + UINT64_C (0x0a9c32d5eae45305), UINT64_C (0x0c335248857fa9e7), + UINT64_C (0x142de49fff7a7c3d), UINT64_C (0x64a53dc924fe7ac9), + UINT64_C (0x9f6a419d382595f4), UINT64_C (0x150f361dab9dec26), + UINT64_C (0xc61bb3a141e50e8c), UINT64_C (0x2785338347f2ba08), + UINT64_C (0x7ca9723fbb2e8988), UINT64_C (0xce2f8642ca0712dc), + UINT64_C (0x59300222b4561e00), UINT64_C (0xc2b5a03f71471a6f), + UINT64_C (0xd5f9e858292504d5), UINT64_C (0x65fa4f227a2b6d79), + UINT64_C (0x93cbe0b699c2585d), UINT64_C (0x1d95b0a5fcf90bc6), + UINT64_C (0x17efee45b0dee640), UINT64_C (0x9e4c1269baa4bf37), + UINT64_C (0xd79476a84ee20d06), UINT64_C (0x0a56a5f0bfe39272), + UINT64_C (0x7eba726d8c94094b), UINT64_C (0x5e5637885f29bc2b), + UINT64_C (0xd586bd01c5c217f6), UINT64_C (0x233003b5a6cfe6ad), + UINT64_C (0x24c0e332b70019b0), UINT64_C (0x9da058c67844f20c), + UINT64_C (0xe4d9429322cd065a), UINT64_C (0x1fab64ea29a2ddf7), + UINT64_C (0x8af38731c02ba980), UINT64_C (0x7dc7785b8efdfc80), + UINT64_C (0x486289ddcc3d6780), UINT64_C (0x222bbfae61725606), + UINT64_C (0x2bc60a63a6f3b3f2), UINT64_C (0x177e00f9fc32f791), + UINT64_C (0x522e23f3925e319e), UINT64_C (0x9c2ed44081ce5fbd), + UINT64_C (0x964781ce734b3c84), UINT64_C (0xf05d129681949a4c), + UINT64_C (0x046e3ecaaf453ce9), UINT64_C (0x962aceefa82e1c84), + UINT64_C (0xf5b4b0b0d2deeeb4), UINT64_C (0x1af3dbe25d8f45da), + UINT64_C (0xf9f4892ed96bd438), UINT64_C (0xc4c118bfe78feaae), + UINT64_C (0x07a69afdcc42261a), UINT64_C (0xf8549e1a3aa5e00d), + UINT64_C (0x2102ae466ebb1148), UINT64_C (0xe87fbb46217a360e), + UINT64_C (0x310cb380db6f7503), UINT64_C (0xb5fdfc5d3132c498), + UINT64_C (0xdaf8e9829fe96b5f), UINT64_C (0xcac09afbddd2cdb4), + UINT64_C (0xb862225b055b6960), UINT64_C (0x55b6344cf97aafae), + UINT64_C (0xff577222c14f0a3a), UINT64_C (0x4e4b705b92903ba4), + UINT64_C (0x730499af921549ff), UINT64_C (0x13ae978d09fe5557), + UINT64_C (0xd9e92aa246bf719e), UINT64_C (0x7a4c10ec2158c4a6), + UINT64_C (0x49cad48cebf4a71e), UINT64_C (0xcf05daf5ac8d77b0), + UINT64_C (0xabbdcdd7ed5c0860), UINT64_C (0x9853eab63b5e0b35), + UINT64_C (0x352787baa0d7c22f), UINT64_C (0xc7f6aa2de59aea61), + UINT64_C (0x03727073c2e134b1), UINT64_C (0x5a0f544dd2b1fb18), + UINT64_C (0x74f85198b05a2e7d), UINT64_C (0x963ef2c96b33be31), + UINT64_C (0x4659d2b743848a2c), UINT64_C (0x19ebb029435dcb0f), + UINT64_C (0x4e9d2827355fc492), UINT64_C (0xccec0a73b49c9921), + UINT64_C (0x46c9feb55d120902), UINT64_C (0x8d2636b81555a786), + UINT64_C (0x30c05b1ba332f41c), UINT64_C (0xf6f7fd1431714200), + UINT64_C (0x1a4ff12616eefc89), UINT64_C (0x990a98fd5071d263), + UINT64_C (0x84547ddc3e203c94), UINT64_C (0x07a3aec79624c7da), + UINT64_C (0x8a328a1cedfe552c), UINT64_C (0xd1e649de1e7f268b), + UINT64_C (0x2d8d5432157064c8), UINT64_C (0x4ae7d6a36eb5dbcb), + UINT64_C (0x57e3306d881edb4f), UINT64_C (0x0a804d18b7097475), + UINT64_C (0xe74733427b72f0c1), UINT64_C (0x24b33c9d7ed25117), + UINT64_C (0xe805a1e290cf2456), UINT64_C (0x3b544ebe544c19f9), + UINT64_C (0x3e666e6f69ae2c15), UINT64_C (0xfb152fe3ff26da89), + UINT64_C (0xb49b52e587a1ee60), UINT64_C (0xac042e70f8b383f2), + UINT64_C (0x89c350c893ae7dc1), UINT64_C (0xb592bf39b0364963), + UINT64_C (0x190e714fada5156e), UINT64_C (0xec8177f83f900978), + UINT64_C (0x91b534f885818a06), UINT64_C (0x81536d601170fc20), + UINT64_C (0xd4c718bc4ae8ae5f), UINT64_C (0x9eedeca8e272b933), + UINT64_C (0x10e8b35af3eeab37), UINT64_C (0x0e09b88e1914f7af), + UINT64_C (0x3fa9ddfb67e2f199), UINT64_C (0xb10bb459132d0a26), + UINT64_C (0x2c046f22062dc67d), UINT64_C (0x5e90277e7cb39e2d), + UINT64_C (0xd6b04d3b7651dd7e), UINT64_C (0xe34a1d250e7a8d6b), + UINT64_C (0x53c065c6c8e63528), UINT64_C (0x1bdea12e35f6a8c9), + UINT64_C (0x21874b8b4d2dbc4f), UINT64_C (0x3a88a0fbbcb05c63), + UINT64_C (0x43ed7f5a0fae657d), UINT64_C (0x230e343dfba08d33), + UINT64_C (0xb5b4071dbfc73a66), UINT64_C (0x8f9887e6078735a1), + UINT64_C (0x08de8a1c7797da9b), UINT64_C (0xfcb6be43a9f2fe9b), + UINT64_C (0x049a7f41061a9e60), UINT64_C (0x9f91508bffcfc14a), + UINT64_C (0xe3273522064480ca), UINT64_C (0xcd04f3ff001a4778), + UINT64_C (0x6bfa9aae5ec05779), UINT64_C (0x371f77e76bb8417e), + UINT64_C (0x3550c2321fd6109c), UINT64_C (0xfb4a3d794a9a80d2), + UINT64_C (0xf43c732873f24c13), UINT64_C (0xaa9119ff184cccf4), + UINT64_C (0xb69e38a8965c6b65), UINT64_C (0x1f2b1d1f15f6dc9c), + UINT64_C (0x67fef95d92607890), UINT64_C (0x31865ced6120f37d), + UINT64_C (0x3a6853c7e70757a7), UINT64_C (0x32ab0edb696703d3), + UINT64_C (0xee97f453f06791ed), UINT64_C (0x6dc93d9526a50e68), + UINT64_C (0x78edefd694af1eed), UINT64_C (0x9c1169fa2777b874), + UINT64_C (0x50065e535a213cf6), UINT64_C (0xde0c89a556b9ae70), + UINT64_C (0xd1e0ccd25bb9c169), UINT64_C (0x6b17b224bad6bf27), + UINT64_C (0x6b02e63195ad0cf8), UINT64_C (0x455a4b4cfe30e3f5), + UINT64_C (0x9338e69c052b8e7b), UINT64_C (0x5092ef950a16da0b), + UINT64_C (0x7c45d833aff07862), UINT64_C (0xa5b1cfdba0ab4067), + UINT64_C (0x6ad047c430a12104), UINT64_C (0x6c47bec883a7de39), + UINT64_C (0x944f6de09134dfb6), UINT64_C (0x9aeba33ac6ecc6b0), + UINT64_C (0x52e762596bf68235), UINT64_C (0x22af003ab672e811), + UINT64_C (0xb5635c95ff7296e2), UINT64_C (0xed2df21216235097), + UINT64_C (0x4a29c6465a314cd1), UINT64_C (0xd83cc2687a19255f), + UINT64_C (0x506c11b9d90e8b1d), UINT64_C (0x57277707199b8175), + UINT64_C (0xcaf21ecd4377b28c), UINT64_C (0xc0c0f5a60ef4cdcf), + UINT64_C (0x93b633abfa3469f8), UINT64_C (0xe846963877671a17), + UINT64_C (0x59ac2c7873f910a3), UINT64_C (0x660d3257380841ee), + UINT64_C (0xd813f2fab7f5c5ca), UINT64_C (0x4112cf68649a260e), + UINT64_C (0x443f64ec5a371195), UINT64_C (0xb0774d261cc609db), + UINT64_C (0x720bf5f26f4d2eaa), UINT64_C (0x1c2559e30f0946be), + UINT64_C (0xe328e230e3e2b3fb), UINT64_C (0x087e79e5a57d1d13), + UINT64_C (0x08dd9bdfd96b9f63), UINT64_C (0x64d0e29eea8838b3), + UINT64_C (0xddf957bc36d8b9ca), UINT64_C (0x6ffe73e81b637fb3), + UINT64_C (0x1a4e4822eb4d7a59), UINT64_C (0x5d94337fbfaf7f5b), + UINT64_C (0xd30c088ba61ea5ef), UINT64_C (0x9d765e419fb69f6d), + UINT64_C (0x9e21f4f903b33fd9), UINT64_C (0xb4d8f77bc3e56167), + UINT64_C (0x733ea705fae4fa77), UINT64_C (0xa4ec0132764ca04b), + UINT64_C (0x7976033a39f7d952), UINT64_C (0x106f72fe81e2c590), + UINT64_C (0x8c90fd9b083f4558), UINT64_C (0xfd080d236da814ba), + UINT64_C (0x7b64978555326f9f), UINT64_C (0x60e8ed72c0dff5d1), + UINT64_C (0xb063e962e045f54d), UINT64_C (0x959f587d507a8359), + UINT64_C (0x758f450c88572e0b), UINT64_C (0x1b6baca2ae4e125b), + UINT64_C (0x61cf4f94c97df93d), UINT64_C (0x2738259634305c14), + UINT64_C (0xd39bb9c3a48db6cf), UINT64_C (0x8215e577001332c8), + UINT64_C (0xa1082c0466df6c0a), UINT64_C (0xef02cdd06ffdb432), + UINT64_C (0xfc87614baf287e07), UINT64_C (0x240ab57a8b888b20), + UINT64_C (0xbf8d5108e27e0d48), UINT64_C (0x61bdd1307c66e300), + UINT64_C (0xb925a6cd0421aff3), UINT64_C (0x3e003e616a6591e9), + UINT64_C (0x94c3251f06f90cf3), UINT64_C (0xbf84470805e69b5f), + UINT64_C (0x98f076a4f7a2322e), UINT64_C (0x70cb6af7c2d5bcf0), + UINT64_C (0xb64be8d8b25396c1), UINT64_C (0xa9aa4d20db084e9b), + UINT64_C (0x2e6d02c36017f67f), UINT64_C (0xefed53d75fd64e6b), + UINT64_C (0xd9f1f30ccd97fb09), UINT64_C (0xa2ebee47e2fbfce1), + UINT64_C (0xb8d91274b9e9d4fb), UINT64_C (0x1db956e450275779), + UINT64_C (0x4fc8e9560f91b123), UINT64_C (0x63573ff03e224774), + UINT64_C (0x0647dfedcd894a29), UINT64_C (0x7884d9bc6cb569d8), + UINT64_C (0x7fba195410e5ca30), UINT64_C (0x106c09b972d2e822), + UINT64_C (0x241260ed4ad1e87d), UINT64_C (0x64c8e531bff53b55), + UINT64_C (0xca672b91e9e4fa16), UINT64_C (0x3871700761b3f743), + UINT64_C (0xf95cffa23af5f6f4), UINT64_C (0x8d14dedb30be846e), + UINT64_C (0x3b097adaf088f94e), UINT64_C (0x21e0bd5026c619bf), + UINT64_C (0x1bda0492e7e4586e), UINT64_C (0xd23c8e176d113600), + UINT64_C (0x252f59cf0d9f04bb), UINT64_C (0xb3598080ce64a656), + UINT64_C (0x993e1de72d36d310), UINT64_C (0xa2853b80f17f58ee), + UINT64_C (0x1877b51e57a764d5), UINT64_C (0x001f837cc7350524) + } + #endif + }; + +int +main (int argc, char **argv) +{ + unsigned int i; + isaac_word r[ISAAC_WORDS]; + int iterations; + + /* Seed with zeros, and discard the first buffer of output, + as that's what the standard programs do. */ + static struct isaac_state s; + isaac_seed (&s); + isaac_refill (&s, r); + + for (i = 0; i < sizeof expected / sizeof expected[0]; i++) + { + isaac_refill (&s, r); + ASSERT (memcmp (r, expected[i], sizeof r) == 0); + } + + /* If invoked with a positive argument, run a benchmark; + if with a negative, run a do-nothing benchmark. */ + for (iterations = argc <= 1 ? 0 : strtol (argv[1], NULL, 10); + iterations != 0; + iterations += (iterations < 0 ? 1 : -1)) + if (0 <= iterations) + isaac_refill (&s, r); + + return 0; +} diff --git a/gnulib-tests/test-read-file.c b/gnulib-tests/test-read-file.c new file mode 100644 index 0000000..930cf4a --- /dev/null +++ b/gnulib-tests/test-read-file.c @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2006-2007, 2010-2020 Free Software Foundation, Inc. + * Written by Simon Josefsson + * + * 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include "read-file.h" + +#include <stdio.h> +#include <stdlib.h> +#include <sys/stat.h> + +#define FILE1 "/etc/resolv.conf" +#define FILE2 "/dev/null" + +int +main (void) +{ + struct stat statbuf; + int err = 0; + + /* We can perform the test only if the file exists and is readable. + Test whether it exists, then assume it is world-readable. */ + if (stat (FILE1, &statbuf) >= 0) + { + size_t len; + char *out = read_file (FILE1, &len); + + if (!out) + { + perror ("Could not read file"); + err = 1; + } + else + { + if (out[len] != '\0') + { + perror ("BAD: out[len] not zero"); + err = 1; + } + + if (S_ISREG (statbuf.st_mode)) + { + /* FILE1 is a regular file or a symlink to a regular file. */ + if (len != statbuf.st_size) + { + fprintf (stderr, "Read %lu from %s...\n", + (unsigned long) len, FILE1); + err = 1; + } + } + else + { + /* Assume FILE1 is not empty. */ + if (len == 0) + { + fprintf (stderr, "Read nothing from %s\n", FILE1); + err = 1; + } + } + free (out); + } + } + + /* We can perform the test only if the file exists and is readable. + Test whether it exists, then assume it is world-readable. */ + if (stat (FILE2, &statbuf) >= 0) + { + size_t len; + char *out = read_file (FILE2, &len); + + if (!out) + { + perror ("Could not read file"); + err = 1; + } + else + { + if (out[len] != '\0') + { + perror ("BAD: out[len] not zero"); + err = 1; + } + + /* /dev/null should always be empty. Ignore statbuf.st_size, since it + is not a regular file. */ + if (len != 0) + { + fprintf (stderr, "Read %lu from %s...\n", + (unsigned long) len, FILE2); + err = 1; + } + free (out); + } + } + + return err; +} diff --git a/gnulib-tests/test-read.c b/gnulib-tests/test-read.c new file mode 100644 index 0000000..872f34c --- /dev/null +++ b/gnulib-tests/test-read.c @@ -0,0 +1,73 @@ +/* Test the read() function. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (read, ssize_t, (int, void *, size_t)); + +#include <errno.h> +#include <fcntl.h> +#include <string.h> + +#include "macros.h" + +int +main (void) +{ + const char *filename = "test-read.tmp"; + int fd; + + /* Create a file with a simple contents. */ + fd = open (filename, O_CREAT | O_WRONLY, 0600); + ASSERT (fd >= 0); + ASSERT (write (fd, "Hello World", 11) == 11); + ASSERT (close (fd) == 0); + + /* Read from the middle of the file. */ + fd = open (filename, O_RDONLY); + ASSERT (fd >= 0); + ASSERT (lseek (fd, 6, SEEK_SET) == 6); + { + char buf[10]; + ssize_t ret = read (fd, buf, 10); + ASSERT (ret == 5); + ASSERT (memcmp (buf, "World", 5) == 0); + } + ASSERT (close (fd) == 0); + + /* Test behaviour for invalid file descriptors. */ + { + char byte; + errno = 0; + ASSERT (read (-1, &byte, 1) == -1); + ASSERT (errno == EBADF); + } + { + char byte; + close (99); + errno = 0; + ASSERT (read (99, &byte, 1) == -1); + ASSERT (errno == EBADF); + } + + /* Clean up. */ + unlink (filename); + + return 0; +} diff --git a/gnulib-tests/test-readlink.c b/gnulib-tests/test-readlink.c new file mode 100644 index 0000000..c625e9b --- /dev/null +++ b/gnulib-tests/test-readlink.c @@ -0,0 +1,48 @@ +/* Tests of readlink. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (readlink, ssize_t, (char const *, char *, size_t)); + +#include <fcntl.h> +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> + +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-readlink.t" + +#include "test-readlink.h" + +int +main (void) +{ + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + return test_readlink (readlink, true); +} diff --git a/gnulib-tests/test-readlink.h b/gnulib-tests/test-readlink.h new file mode 100644 index 0000000..f2e7bd2 --- /dev/null +++ b/gnulib-tests/test-readlink.h @@ -0,0 +1,119 @@ +/* Tests of readlink. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +/* This file is designed to test both readlink(a,b,c) and + readlinkat(AT_FDCWD,a,b,c). FUNC is the function to test. Assumes + that BASE and ASSERT are already defined, and that appropriate + headers are already included. If PRINT, warn before skipping + symlink tests with status 77. */ + +static int +test_readlink (ssize_t (*func) (char const *, char *, size_t), bool print) +{ + char buf[80]; + + /* Sanity checks of failures. Mingw lacks symlink, but readlink can + still distinguish between various errors. */ + memset (buf, 0xff, sizeof buf); + errno = 0; + ASSERT (func ("no_such", buf, sizeof buf) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func ("no_such/", buf, sizeof buf) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func ("", buf, sizeof buf) == -1); + ASSERT (errno == ENOENT || errno == EINVAL); + errno = 0; + ASSERT (func (".", buf, sizeof buf) == -1); + ASSERT (errno == EINVAL); + errno = 0; + ASSERT (func ("./", buf, sizeof buf) == -1); + ASSERT (errno == EINVAL); + ASSERT (close (creat (BASE "file", 0600)) == 0); + errno = 0; + ASSERT (func (BASE "file", buf, sizeof buf) == -1); + ASSERT (errno == EINVAL); + errno = 0; + ASSERT (func (BASE "file/", buf, sizeof buf) == -1); + ASSERT (errno == ENOTDIR || errno == EINVAL); /* AIX yields EINVAL */ + + /* Now test actual symlinks. */ + if (symlink (BASE "dir", BASE "link")) + { + ASSERT (unlink (BASE "file") == 0); + if (print) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + ASSERT (mkdir (BASE "dir", 0700) == 0); + errno = 0; + ASSERT (func (BASE "link/", buf, sizeof buf) == -1); + ASSERT (errno == EINVAL); + ASSERT (symlink (BASE "link", BASE "link2") == 0); + errno = 0; + ASSERT (func (BASE "link2/", buf, sizeof buf) == -1); + ASSERT (errno == EINVAL); + ASSERT (unlink (BASE "link2") == 0); + ASSERT (symlink (BASE "file", BASE "link2") == 0); + errno = 0; + ASSERT (func (BASE "link2/", buf, sizeof buf) == -1); + ASSERT (errno == ENOTDIR || errno == EINVAL); /* AIX yields EINVAL */ + ASSERT (unlink (BASE "file") == 0); + ASSERT (unlink (BASE "link2") == 0); + { + /* Up till now, no readlink has been successful, so buf should be + unchanged. */ + int i; + for (i = 0; i < sizeof buf; i++) + ASSERT (buf[i] == (char) 0xff); + } + { + size_t len = strlen (BASE "dir"); + /* When passing too small of a buffer, expect the truncated + length, or an ERANGE failure. However, a size of 0 is not + portable enough to test. */ + ssize_t result; + errno = 0; + result = readlink (BASE "link", buf, 1); + if (result == -1) + { + ASSERT (errno == ERANGE); + ASSERT (buf[0] == (char) 0xff); + } + else + { + ASSERT (result == 1); + ASSERT (buf[0] == BASE[0]); + } + ASSERT (buf[1] == (char) 0xff); + ASSERT (func (BASE "link", buf, len) == len); + ASSERT (strncmp (buf, BASE "dir", len) == 0); + ASSERT (buf[len] == (char) 0xff); + ASSERT (func (BASE "link", buf, sizeof buf) == len); + ASSERT (strncmp (buf, BASE "dir", len) == 0); + /* POSIX says rest of buf is unspecified; but in practice, it is + either left alone, or NUL-terminated. */ + ASSERT (buf[len] == '\0' || buf[len] == (char) 0xff); + } + ASSERT (rmdir (BASE "dir") == 0); + ASSERT (unlink (BASE "link") == 0); + + return 0; +} diff --git a/gnulib-tests/test-readlinkat.c b/gnulib-tests/test-readlinkat.c new file mode 100644 index 0000000..03b9000 --- /dev/null +++ b/gnulib-tests/test-readlinkat.c @@ -0,0 +1,121 @@ +/* Tests of readlinkat. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (readlinkat, ssize_t, (int, char const *, char *, size_t)); + +#include <fcntl.h> +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> + +#include "ignore-value.h" +#include "macros.h" + +#ifndef HAVE_SYMLINK +# define HAVE_SYMLINK 0 +#endif + +#define BASE "test-readlinkat.t" + +#include "test-readlink.h" + +static int dfd = AT_FDCWD; + +static ssize_t +do_readlink (char const *name, char *buf, size_t len) +{ + return readlinkat (dfd, name, buf, len); +} + +int +main (void) +{ + char buf[80]; + int result; + + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (readlinkat (-1, "foo", buf, sizeof buf) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (readlinkat (99, "foo", buf, sizeof buf) == -1); + ASSERT (errno == EBADF); + } + + /* Perform same checks as counterpart functions. */ + result = test_readlink (do_readlink, false); + dfd = openat (AT_FDCWD, ".", O_RDONLY); + ASSERT (0 <= dfd); + ASSERT (test_readlink (do_readlink, false) == result); + + /* Now perform some cross-directory checks. Skip everything else on + mingw. */ + if (HAVE_SYMLINK) + { + const char *contents = "don't matter!"; + ssize_t exp = strlen (contents); + + /* Create link while cwd is '.', then read it in '..'. */ + ASSERT (symlinkat (contents, AT_FDCWD, BASE "link") == 0); + errno = 0; + ASSERT (symlinkat (contents, dfd, BASE "link") == -1); + ASSERT (errno == EEXIST); + ASSERT (chdir ("..") == 0); + errno = 0; + ASSERT (readlinkat (AT_FDCWD, BASE "link", buf, sizeof buf) == -1); + ASSERT (errno == ENOENT); + ASSERT (readlinkat (dfd, BASE "link", buf, sizeof buf) == exp); + ASSERT (strncmp (contents, buf, exp) == 0); + ASSERT (unlinkat (dfd, BASE "link", 0) == 0); + + /* Create link while cwd is '..', then read it in '.'. */ + ASSERT (symlinkat (contents, dfd, BASE "link") == 0); + ASSERT (fchdir (dfd) == 0); + errno = 0; + ASSERT (symlinkat (contents, AT_FDCWD, BASE "link") == -1); + ASSERT (errno == EEXIST); + buf[0] = '\0'; + ASSERT (readlinkat (AT_FDCWD, BASE "link", buf, sizeof buf) == exp); + ASSERT (strncmp (contents, buf, exp) == 0); + buf[0] = '\0'; + ASSERT (readlinkat (dfd, BASE "link", buf, sizeof buf) == exp); + ASSERT (strncmp (contents, buf, exp) == 0); + ASSERT (unlink (BASE "link") == 0); + } + + ASSERT (close (dfd) == 0); + if (result == 77) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return result; +} diff --git a/gnulib-tests/test-readtokens.c b/gnulib-tests/test-readtokens.c new file mode 100644 index 0000000..a153983 --- /dev/null +++ b/gnulib-tests/test-readtokens.c @@ -0,0 +1,98 @@ +/* Test the readtokens module. + Copyright (C) 2012-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> +#include <stdbool.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <string.h> +#include <stdio.h> +#include <unistd.h> + +#include "readtokens.h" +#include "closeout.h" +#include "macros.h" + +static void +basic (void) +{ + char const *filename = "in.827"; + int fd = open (filename, O_CREAT | O_WRONLY, 0600); + ASSERT (fd >= 0); + ASSERT (write (fd, "a|b;c+d", 7) == 7); + ASSERT (close (fd) == 0); + + { + token_buffer tb; + FILE *fp = fopen (filename, "r"); + ASSERT (fp); + + init_tokenbuffer (&tb); + ASSERT (readtoken (fp, "|;", 2, &tb) == 1 && tb.buffer[0] == 'a'); + ASSERT (readtoken (fp, "|;", 2, &tb) == 1 && tb.buffer[0] == 'b'); + ASSERT (readtoken (fp, "+", 1, &tb) == 1 && tb.buffer[0] == 'c'); + ASSERT (readtoken (fp, "-", 1, &tb) == 1 && tb.buffer[0] == 'd'); + ASSERT (readtoken (fp, "%", 0, &tb) == (size_t) -1); + ASSERT ( ! ferror (fp)); + ASSERT (fclose (fp) == 0); + } +} + +int +main (int argc, char **argv) +{ + token_buffer tb; + char const *delim; + size_t delim_len; + + atexit (close_stdout); + + if (argc == 1) + { + basic (); + return 0; + } + + init_tokenbuffer (&tb); + + if (argc != 2) + return 99; + + delim = argv[1]; + delim_len = strlen (delim); + + if (STREQ (delim, "\\0")) + { + delim = ""; + delim_len = 1; + } + + while (1) + { + size_t token_length = readtoken (stdin, delim, delim_len, &tb); + if (token_length == (size_t) -1) + break; + fwrite (tb.buffer, 1, token_length, stdout); + putchar (':'); + } + putchar ('\n'); + free (tb.buffer); + + ASSERT ( ! ferror (stdin)); + + return 0; +} diff --git a/gnulib-tests/test-readtokens.sh b/gnulib-tests/test-readtokens.sh new file mode 100755 index 0000000..4c7821f --- /dev/null +++ b/gnulib-tests/test-readtokens.sh @@ -0,0 +1,23 @@ +#!/bin/sh +. "${srcdir=.}/init.sh"; path_prepend_ . + +fail=0 + +${CHECKER} test-readtokens || fail=1 + +# Simplest case. +echo a:b:c: > exp || fail=1 +printf a:b:c | ${CHECKER} test-readtokens : > out 2>&1 || fail=1 +compare exp out || fail=1 + +# Use NUL as the delimiter. +echo a:b:c: > exp || fail=1 +printf 'a\0b\0c' | ${CHECKER} test-readtokens '\0' > out 2>&1 || fail=1 +compare exp out || fail=1 + +# Two delimiter bytes, and adjacent delimiters in the input. +echo a:b:c: > exp || fail=1 +printf a:-:b-:c:: | ${CHECKER} test-readtokens :- > out 2>&1 || fail=1 +compare exp out || fail=1 + +Exit $fail diff --git a/gnulib-tests/test-realloc-gnu.c b/gnulib-tests/test-realloc-gnu.c new file mode 100644 index 0000000..4e110fc --- /dev/null +++ b/gnulib-tests/test-realloc-gnu.c @@ -0,0 +1,31 @@ +/* Test of realloc function. + Copyright (C) 2010-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdlib.h> + +int +main () +{ + /* Check that realloc (NULL, 0) is not a NULL pointer. */ + char *p = realloc (NULL, 0); + if (p == NULL) + return 1; + + free (p); + return 0; +} diff --git a/gnulib-tests/test-regex.c b/gnulib-tests/test-regex.c new file mode 100644 index 0000000..d3f429a --- /dev/null +++ b/gnulib-tests/test-regex.c @@ -0,0 +1,264 @@ +/* Test regular expressions + Copyright 1996-2001, 2003-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include "regex.h" + +#include <locale.h> +#include <limits.h> +#include <stdlib.h> +#include <string.h> +#if HAVE_DECL_ALARM +# include <unistd.h> +# include <signal.h> +#endif + +#include "localcharset.h" + +int +main (void) +{ + int result = 0; + static struct re_pattern_buffer regex; + unsigned char folded_chars[UCHAR_MAX + 1]; + int i; + const char *s; + struct re_registers regs; + +#if HAVE_DECL_ALARM + /* Some builds of glibc go into an infinite loop on this test. */ + int alarm_value = 2; + signal (SIGALRM, SIG_DFL); + alarm (alarm_value); +#endif + if (setlocale (LC_ALL, "en_US.UTF-8")) + { + { + /* https://sourceware.org/ml/libc-hacker/2006-09/msg00008.html + This test needs valgrind to catch the bug on Debian + GNU/Linux 3.1 x86, but it might catch the bug better + on other platforms and it shouldn't hurt to try the + test here. */ + static char const pat[] = "insert into"; + static char const data[] = + "\xFF\0\x12\xA2\xAA\xC4\xB1,K\x12\xC4\xB1*\xACK"; + re_set_syntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE + | RE_ICASE); + memset (®ex, 0, sizeof regex); + s = re_compile_pattern (pat, sizeof pat - 1, ®ex); + if (s) + result |= 1; + else + { + memset (®s, 0, sizeof regs); + if (re_search (®ex, data, sizeof data - 1, + 0, sizeof data - 1, ®s) + != -1) + result |= 1; + regfree (®ex); + free (regs.start); + free (regs.end); + } + } + + /* Check whether it's really a UTF-8 locale. + On mingw, the setlocale call succeeds but returns + "English_United States.1252", with locale_charset() returning + "CP1252". */ + if (strcmp (locale_charset (), "UTF-8") == 0) + { + /* This test is from glibc bug 15078. + The test case is from Andreas Schwab in + <https://sourceware.org/ml/libc-alpha/2013-01/msg00967.html>. + */ + static char const pat[] = "[^x]x"; + static char const data[] = + /* <U1000><U103B><U103D><U1014><U103A><U102F><U1015><U103A> */ + "\xe1\x80\x80" + "\xe1\x80\xbb" + "\xe1\x80\xbd" + "\xe1\x80\x94" + "\xe1\x80\xba" + "\xe1\x80\xaf" + "\xe1\x80\x95" + "\xe1\x80\xba" + "x"; + re_set_syntax (0); + memset (®ex, 0, sizeof regex); + s = re_compile_pattern (pat, sizeof pat - 1, ®ex); + if (s) + result |= 1; + else + { + memset (®s, 0, sizeof regs); + i = re_search (®ex, data, sizeof data - 1, + 0, sizeof data - 1, 0); + if (i != 0 && i != 21) + result |= 1; + regfree (®ex); + free (regs.start); + free (regs.end); + } + } + + if (! setlocale (LC_ALL, "C")) + return 1; + } + + /* This test is from glibc bug 3957, reported by Andrew Mackey. */ + re_set_syntax (RE_SYNTAX_EGREP | RE_HAT_LISTS_NOT_NEWLINE); + memset (®ex, 0, sizeof regex); + s = re_compile_pattern ("a[^x]b", 6, ®ex); + if (s) + result |= 2; + /* This should fail, but succeeds for glibc-2.5. */ + else + { + memset (®s, 0, sizeof regs); + if (re_search (®ex, "a\nb", 3, 0, 3, ®s) != -1) + result |= 2; + regfree (®ex); + free (regs.start); + free (regs.end); + } + + /* This regular expression is from Spencer ere test number 75 + in grep-2.3. */ + re_set_syntax (RE_SYNTAX_POSIX_EGREP); + memset (®ex, 0, sizeof regex); + for (i = 0; i <= UCHAR_MAX; i++) + folded_chars[i] = i; + regex.translate = folded_chars; + s = re_compile_pattern ("a[[:@:>@:]]b\n", 11, ®ex); + /* This should fail with _Invalid character class name_ error. */ + if (!s) + { + result |= 4; + regfree (®ex); + } + + /* Ensure that [b-a] is diagnosed as invalid, when + using RE_NO_EMPTY_RANGES. */ + re_set_syntax (RE_SYNTAX_POSIX_EGREP | RE_NO_EMPTY_RANGES); + memset (®ex, 0, sizeof regex); + s = re_compile_pattern ("a[b-a]", 6, ®ex); + if (s == 0) + { + result |= 8; + regfree (®ex); + } + + /* This should succeed, but does not for glibc-2.1.3. */ + memset (®ex, 0, sizeof regex); + s = re_compile_pattern ("{1", 2, ®ex); + if (s) + result |= 8; + else + regfree (®ex); + + /* The following example is derived from a problem report + against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>. */ + memset (®ex, 0, sizeof regex); + s = re_compile_pattern ("[an\371]*n", 7, ®ex); + if (s) + result |= 8; + /* This should match, but does not for glibc-2.2.1. */ + else + { + memset (®s, 0, sizeof regs); + if (re_match (®ex, "an", 2, 0, ®s) != 2) + result |= 8; + regfree (®ex); + free (regs.start); + free (regs.end); + } + + memset (®ex, 0, sizeof regex); + s = re_compile_pattern ("x", 1, ®ex); + if (s) + result |= 8; + /* glibc-2.2.93 does not work with a negative RANGE argument. */ + else + { + memset (®s, 0, sizeof regs); + if (re_search (®ex, "wxy", 3, 2, -2, ®s) != 1) + result |= 8; + regfree (®ex); + free (regs.start); + free (regs.end); + } + + /* The version of regex.c in older versions of gnulib + ignored RE_ICASE. Detect that problem too. */ + re_set_syntax (RE_SYNTAX_EMACS | RE_ICASE); + memset (®ex, 0, sizeof regex); + s = re_compile_pattern ("x", 1, ®ex); + if (s) + result |= 16; + else + { + memset (®s, 0, sizeof regs); + if (re_search (®ex, "WXY", 3, 0, 3, ®s) < 0) + result |= 16; + regfree (®ex); + free (regs.start); + free (regs.end); + } + + /* Catch a bug reported by Vin Shelton in + https://lists.gnu.org/r/bug-coreutils/2007-06/msg00089.html + */ + re_set_syntax (RE_SYNTAX_POSIX_BASIC + & ~RE_CONTEXT_INVALID_DUP + & ~RE_NO_EMPTY_RANGES); + memset (®ex, 0, sizeof regex); + s = re_compile_pattern ("[[:alnum:]_-]\\\\+$", 16, ®ex); + if (s) + result |= 32; + else + regfree (®ex); + + /* REG_STARTEND was added to glibc on 2004-01-15. + Reject older versions. */ + if (! REG_STARTEND) + result |= 64; + + /* Matching with the compiled form of this regexp would provoke + an assertion failure prior to glibc-2.28: + regexec.c:1375: pop_fail_stack: Assertion 'num >= 0' failed + With glibc-2.28, compilation fails and reports the invalid + back reference. */ + re_set_syntax (RE_SYNTAX_POSIX_EGREP); + memset (®ex, 0, sizeof regex); + s = re_compile_pattern ("0|()0|\\1|0", 10, ®ex); + if (!s || strcmp (s, "Invalid back reference")) + result |= 64; + +#if 0 + /* It would be nice to reject hosts whose regoff_t values are too + narrow (including glibc on hosts with 64-bit ptrdiff_t and + 32-bit int), but we should wait until glibc implements this + feature. Otherwise, support for equivalence classes and + multibyte collation symbols would always be broken except + when compiling --without-included-regex. */ + if (sizeof (regoff_t) < sizeof (ptrdiff_t) + || sizeof (regoff_t) < sizeof (ssize_t)) + result |= 64; +#endif + + return result; +} diff --git a/gnulib-tests/test-remove.c b/gnulib-tests/test-remove.c new file mode 100644 index 0000000..1003a45 --- /dev/null +++ b/gnulib-tests/test-remove.c @@ -0,0 +1,125 @@ +/* Tests of remove. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (remove, int, (char const *)); + +#include <fcntl.h> +#include <errno.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> +#include <unistd.h> + +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-remove.t" + +int +main (void) +{ + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + /* Setup. */ + ASSERT (mkdir (BASE "dir", 0700) == 0); + ASSERT (close (creat (BASE "dir/file", 0600)) == 0); + + /* Basic error conditions. */ + errno = 0; + ASSERT (remove ("") == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (remove ("nosuch") == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (remove ("nosuch/") == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (remove (".") == -1); + ASSERT (errno == EINVAL || errno == EBUSY); + /* Resulting errno after ".." or "/" is too varied to test; it is + reasonable to see any of EINVAL, EEXIST, ENOTEMPTY, EACCES. */ + ASSERT (remove ("..") == -1); + ASSERT (remove ("/") == -1); + ASSERT (remove ("///") == -1); + errno = 0; + ASSERT (remove (BASE "dir/file/") == -1); + ASSERT (errno == ENOTDIR); + + /* Non-empty directory. */ + errno = 0; + ASSERT (remove (BASE "dir") == -1); + ASSERT (errno == EEXIST || errno == ENOTEMPTY); + + /* Non-directory. */ + ASSERT (remove (BASE "dir/file") == 0); + + /* Empty directory. */ + errno = 0; + ASSERT (remove (BASE "dir/.//") == -1); + ASSERT (errno == EINVAL || errno == EBUSY || errno == EEXIST); + ASSERT (remove (BASE "dir") == 0); + + /* Test symlink behavior. Specifying trailing slash should remove + referent directory, or cause ENOTDIR failure, but not touch + symlink. */ + if (symlink (BASE "dir", BASE "link") != 0) + { + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + ASSERT (mkdir (BASE "dir", 0700) == 0); + errno = 0; + if (remove (BASE "link/") == 0) + { + struct stat st; + errno = 0; + ASSERT (stat (BASE "link", &st) == -1); + ASSERT (errno == ENOENT); + } + else + ASSERT (remove (BASE "dir") == 0); + { + struct stat st; + ASSERT (lstat (BASE "link", &st) == 0); + ASSERT (S_ISLNK (st.st_mode)); + } + ASSERT (remove (BASE "link") == 0); + /* Trailing slash on symlink to non-directory is an error. */ + ASSERT (symlink (BASE "loop", BASE "loop") == 0); + errno = 0; + ASSERT (remove (BASE "loop/") == -1); + ASSERT (errno == ELOOP || errno == ENOTDIR); + ASSERT (remove (BASE "loop") == 0); + ASSERT (close (creat (BASE "file", 0600)) == 0); + ASSERT (symlink (BASE "file", BASE "link") == 0); + errno = 0; + ASSERT (remove (BASE "link/") == -1); + ASSERT (errno == ENOTDIR); + ASSERT (remove (BASE "link") == 0); + ASSERT (remove (BASE "file") == 0); + + return 0; +} diff --git a/gnulib-tests/test-rename.c b/gnulib-tests/test-rename.c new file mode 100644 index 0000000..633a70f --- /dev/null +++ b/gnulib-tests/test-rename.c @@ -0,0 +1,47 @@ +/* Test of rename() function. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (rename, int, (char const *, char const *)); + +#include <dirent.h> +#include <errno.h> +#include <fcntl.h> +#include <stdbool.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> +#include <unistd.h> + +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-rename.t" + +#include "test-rename.h" + +int +main (void) +{ + /* Remove any garbage left from previous partial runs. */ + ignore_value (system ("rm -rf " BASE "*")); + + return test_rename (rename, true); +} diff --git a/gnulib-tests/test-rename.h b/gnulib-tests/test-rename.h new file mode 100644 index 0000000..844e107 --- /dev/null +++ b/gnulib-tests/test-rename.h @@ -0,0 +1,959 @@ +/* Test of rename() function. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* This file is designed to test both rename(a,b) and + renameat(AT_FDCWD,a,AT_FDCWD,b). FUNC is the function to test. + Assumes that BASE and ASSERT are already defined, and that + appropriate headers are already included. If PRINT, warn before + skipping symlink tests with status 77. */ + +/* Tests whether a file, given by a file name without slashes, exists in + the current directory, by scanning the directory entries. */ +static bool +dentry_exists (const char *filename) +{ + bool exists = false; + DIR *dir = opendir ("."); + + ASSERT (dir != NULL); + for (;;) + { + struct dirent *d = readdir (dir); + if (d == NULL) + break; + if (strcmp (d->d_name, filename) == 0) + { + exists = true; + break; + } + } + ASSERT (closedir (dir) == 0); + return exists; +} + +/* Asserts that a specific file, given by a file name without slashes, does + not exist in the current directory. */ +static void +assert_nonexistent (const char *filename) +{ + struct stat st; + + /* The usual way to test the presence of a file is via stat() or lstat(). */ + errno = 0; + if (stat (filename, &st) == -1) + ASSERT (errno == ENOENT); + else + { + /* But after renaming a directory over an empty directory on an NFS- + mounted file system, on Linux 2.6.18, for a period of 30 seconds the + old directory name is "present" according to stat() but "nonexistent" + according to dentry_exists(). */ + ASSERT (!dentry_exists (filename)); + /* Remove the old directory name, so that subsequent mkdir calls + succeed. */ + (void) rmdir (filename); + } +} + +static int +test_rename (int (*func) (char const *, char const *), bool print) +{ + /* Setup. */ + struct stat st; + int fd = creat (BASE "file", 0600); + ASSERT (0 <= fd); + ASSERT (write (fd, "hi", 2) == 2); + ASSERT (close (fd) == 0); + ASSERT (mkdir (BASE "dir", 0700) == 0); + + /* Files present here: + {BASE}file + {BASE}dir/ + */ + + /* Obvious errors. */ + + { /* Missing source. */ + { + errno = 0; + ASSERT (func (BASE "missing", BASE "missing") == -1); + ASSERT (errno == ENOENT); + } + { + errno = 0; + ASSERT (func (BASE "missing/", BASE "missing") == -1); + ASSERT (errno == ENOENT); + } + { + errno = 0; + ASSERT (func (BASE "missing", BASE "missing/") == -1); + ASSERT (errno == ENOENT); + } + } + { /* Empty operand. */ + { + errno = 0; + ASSERT (func ("", BASE "missing") == -1); + ASSERT (errno == ENOENT); + } + { + errno = 0; + ASSERT (func (BASE "file", "") == -1); + ASSERT (errno == ENOENT); + } + { + errno = 0; + ASSERT (func (BASE "", "") == -1); + ASSERT (errno == ENOENT); + } + } + + /* Files. */ + + { /* Trailing slash. */ + { + errno = 0; + ASSERT (func (BASE "file", BASE "file2/") == -1); + ASSERT (errno == ENOENT || errno == ENOTDIR); + } + { + errno = 0; + ASSERT (func (BASE "file/", BASE "file2") == -1); + ASSERT (errno == ENOTDIR); + } + { + errno = 0; + ASSERT (stat (BASE "file2", &st) == -1); + ASSERT (errno == ENOENT); + } + } + { /* Simple rename. */ + ASSERT (func (BASE "file", BASE "file2") == 0); + errno = 0; + ASSERT (stat (BASE "file", &st) == -1); + ASSERT (errno == ENOENT); + memset (&st, 0, sizeof st); + ASSERT (stat (BASE "file2", &st) == 0); + ASSERT (st.st_size == 2); + } + /* Files present here: + {BASE}file2 + {BASE}dir/ + */ + { /* Overwrite. */ + ASSERT (close (creat (BASE "file", 0600)) == 0); + errno = 0; + ASSERT (func (BASE "file2", BASE "file/") == -1); + ASSERT (errno == ENOTDIR); + ASSERT (func (BASE "file2", BASE "file") == 0); + memset (&st, 0, sizeof st); + ASSERT (stat (BASE "file", &st) == 0); + ASSERT (st.st_size == 2); + errno = 0; + ASSERT (stat (BASE "file2", &st) == -1); + ASSERT (errno == ENOENT); + } + /* Files present here: + {BASE}file + {BASE}dir/ + */ + + /* Directories. */ + + { /* Simple rename. */ + { + ASSERT (func (BASE "dir", BASE "dir2/") == 0); + errno = 0; + ASSERT (stat (BASE "dir", &st) == -1); + ASSERT (errno == ENOENT); + ASSERT (stat (BASE "dir2", &st) == 0); + } + /* Files present here: + {BASE}file + {BASE}dir2/ + */ + { + ASSERT (func (BASE "dir2/", BASE "dir") == 0); + ASSERT (stat (BASE "dir", &st) == 0); + errno = 0; + ASSERT (stat (BASE "dir2", &st) == -1); + ASSERT (errno == ENOENT); + } + /* Files present here: + {BASE}file + {BASE}dir/ + */ + { + ASSERT (func (BASE "dir", BASE "dir2") == 0); + errno = 0; + ASSERT (stat (BASE "dir", &st) == -1); + ASSERT (errno == ENOENT); + ASSERT (stat (BASE "dir2", &st) == 0); + } + /* Files present here: + {BASE}file + {BASE}dir2/ + */ + { /* Empty onto empty. */ + ASSERT (mkdir (BASE "dir", 0700) == 0); + /* Files present here: + {BASE}file + {BASE}dir/ + {BASE}dir2/ + */ + ASSERT (func (BASE "dir2", BASE "dir") == 0); + /* Files present here: + {BASE}file + {BASE}dir/ + */ + ASSERT (mkdir (BASE "dir2", 0700) == 0); + /* Files present here: + {BASE}file + {BASE}dir/ + {BASE}dir2/ + */ + ASSERT (func (BASE "dir2", BASE "dir/") == 0); + /* Files present here: + {BASE}file + {BASE}dir/ + */ + ASSERT (mkdir (BASE "dir2", 0700) == 0); + /* Files present here: + {BASE}file + {BASE}dir/ + {BASE}dir2/ + */ + ASSERT (func (BASE "dir2/", BASE "dir") == 0); + /* Files present here: + {BASE}file + {BASE}dir/ + */ + ASSERT (mkdir (BASE "dir2", 0700) == 0); + } + /* Files present here: + {BASE}file + {BASE}dir/ + {BASE}dir2/ + */ + { /* Empty onto full. */ + ASSERT (close (creat (BASE "dir/file", 0600)) == 0); + /* Files present here: + {BASE}file + {BASE}dir/ + {BASE}dir/file + {BASE}dir2/ + */ + { + errno = 0; + ASSERT (func (BASE "dir2", BASE "dir") == -1); + ASSERT (errno == EEXIST || errno == ENOTEMPTY); + } + { + errno = 0; + ASSERT (func (BASE "dir2/", BASE "dir") == -1); + ASSERT (errno == EEXIST || errno == ENOTEMPTY); + } + { + errno = 0; + ASSERT (func (BASE "dir2", BASE "dir/") == -1); + ASSERT (errno == EEXIST || errno == ENOTEMPTY); + } + } + { /* Full onto empty. */ + ASSERT (func (BASE "dir", BASE "dir2") == 0); + assert_nonexistent (BASE "dir"); + ASSERT (stat (BASE "dir2/file", &st) == 0); + /* Files present here: + {BASE}file + {BASE}dir2/ + {BASE}dir2/file + */ + ASSERT (mkdir (BASE "dir", 0700) == 0); + /* Files present here: + {BASE}file + {BASE}dir/ + {BASE}dir2/ + {BASE}dir2/file + */ + { + ASSERT (func (BASE "dir2/", BASE "dir") == 0); + ASSERT (stat (BASE "dir/file", &st) == 0); + errno = 0; + ASSERT (stat (BASE "dir2", &st) == -1); + ASSERT (errno == ENOENT); + } + /* Files present here: + {BASE}file + {BASE}dir/ + {BASE}dir/file + */ + ASSERT (mkdir (BASE "dir2", 0700) == 0); + /* Files present here: + {BASE}file + {BASE}dir/ + {BASE}dir/file + {BASE}dir2/ + */ + { + ASSERT (func (BASE "dir", BASE "dir2/") == 0); + assert_nonexistent (BASE "dir"); + ASSERT (stat (BASE "dir2/file", &st) == 0); + } + /* Files present here: + {BASE}file + {BASE}dir2/ + {BASE}dir2/file + */ + ASSERT (unlink (BASE "dir2/file") == 0); + } + /* Files present here: + {BASE}file + {BASE}dir2/ + */ + { /* Reject trailing dot. */ + { + errno = 0; + ASSERT (func (BASE "dir2", BASE "dir/.") == -1); + ASSERT (errno == EINVAL || errno == ENOENT); + } + ASSERT (mkdir (BASE "dir", 0700) == 0); + /* Files present here: + {BASE}file + {BASE}dir/ + {BASE}dir2/ + */ + { + errno = 0; + ASSERT (func (BASE "dir2", BASE "dir/.") == -1); + ASSERT (errno == EINVAL || errno == EBUSY || errno == EISDIR + || errno == ENOTEMPTY || errno == EEXIST + || errno == ENOENT /* WSL */); + } + { + errno = 0; + ASSERT (func (BASE "dir2/.", BASE "dir") == -1); + ASSERT (errno == EINVAL || errno == EBUSY || errno == EEXIST + || errno == ENOENT /* WSL */); + } + ASSERT (rmdir (BASE "dir") == 0); + /* Files present here: + {BASE}file + {BASE}dir2/ + */ + { + errno = 0; + ASSERT (func (BASE "dir2", BASE "dir/.//") == -1); + ASSERT (errno == EINVAL || errno == ENOENT); + } + ASSERT (mkdir (BASE "dir", 0700) == 0); + /* Files present here: + {BASE}file + {BASE}dir/ + {BASE}dir2/ + */ + { + errno = 0; + ASSERT (func (BASE "dir2", BASE "dir/.//") == -1); + ASSERT (errno == EINVAL || errno == EBUSY || errno == EISDIR + || errno == ENOTEMPTY || errno == EEXIST + || errno == ENOENT /* WSL */); + } + { + errno = 0; + ASSERT (func (BASE "dir2/.//", BASE "dir") == -1); + ASSERT (errno == EINVAL || errno == EBUSY || errno == EEXIST + || errno == ENOENT /* WSL */); + } + ASSERT (rmdir (BASE "dir2") == 0); + /* Files present here: + {BASE}file + {BASE}dir/ + */ + } + { /* Move into subdir. */ + { + errno = 0; + ASSERT (func (BASE "dir", BASE "dir/sub") == -1); + ASSERT (errno == EINVAL || errno == EACCES); + } + { + errno = 0; + ASSERT (stat (BASE "dir/sub", &st) == -1); + ASSERT (errno == ENOENT); + } + ASSERT (mkdir (BASE "dir/sub", 0700) == 0); + /* Files present here: + {BASE}file + {BASE}dir/ + {BASE}dir/sub/ + */ + { + errno = 0; + ASSERT (func (BASE "dir", BASE "dir/sub") == -1); + ASSERT (errno == EINVAL); + ASSERT (stat (BASE "dir/sub", &st) == 0); + } + ASSERT (rmdir (BASE "dir/sub") == 0); + } + } + /* Files present here: + {BASE}file + {BASE}dir/ + */ + + /* Mixing file and directory. */ + + { + { /* File onto dir. */ + { + errno = 0; + ASSERT (func (BASE "file", BASE "dir") == -1); + ASSERT (errno == EISDIR || errno == ENOTDIR); + } + { + errno = 0; + ASSERT (func (BASE "file", BASE "dir/") == -1); + ASSERT (errno == EISDIR || errno == ENOTDIR); + } + } + { /* Dir onto file. */ + { + errno = 0; + ASSERT (func (BASE "dir", BASE "file") == -1); + ASSERT (errno == ENOTDIR); + } + { + errno = 0; + ASSERT (func (BASE "dir/", BASE "file") == -1); + ASSERT (errno == ENOTDIR); + } + } + } + + /* Hard links. */ + + { /* File onto self. */ + ASSERT (func (BASE "file", BASE "file") == 0); + memset (&st, 0, sizeof st); + ASSERT (stat (BASE "file", &st) == 0); + ASSERT (st.st_size == 2); + } + /* Files present here: + {BASE}file + {BASE}dir/ + */ + { /* Empty dir onto self. */ + ASSERT (func (BASE "dir", BASE "dir") == 0); + ASSERT (stat (BASE "dir", &st) == 0); + } + /* Files present here: + {BASE}file + {BASE}dir/ + */ + ASSERT (close (creat (BASE "dir/file", 0600)) == 0); + /* Files present here: + {BASE}file + {BASE}dir/ + {BASE}dir/file + */ + { /* Full dir onto self. */ + ASSERT (func (BASE "dir", BASE "dir") == 0); + } + ASSERT (unlink (BASE "dir/file") == 0); + /* Files present here: + {BASE}file + {BASE}dir/ + */ + { + /* Not all file systems support link. Mingw doesn't have + reliable st_nlink on hard links, but our implementation does + fail with EPERM on poor file systems, and we can detect the + inferior stat() via st_ino. Cygwin 1.5.x copies rather than + links files on those file systems, but there, st_nlink and + st_ino are reliable. */ + int ret = link (BASE "file", BASE "file2"); + if (!ret) + { + memset (&st, 0, sizeof st); + ASSERT (stat (BASE "file2", &st) == 0); + if (st.st_ino && st.st_nlink != 2) + { + ASSERT (unlink (BASE "file2") == 0); + errno = EPERM; + ret = -1; + } + } + if (ret == -1) + { + /* If the device does not support hard links, errno is + EPERM on Linux, EOPNOTSUPP on FreeBSD. */ + switch (errno) + { + case EPERM: + case EOPNOTSUPP: + if (print) + fputs ("skipping test: " + "hard links not supported on this file system\n", + stderr); + ASSERT (unlink (BASE "file") == 0); + ASSERT (rmdir (BASE "dir") == 0); + return 77; + default: + perror ("link"); + return 1; + } + } + ASSERT (ret == 0); + } + /* Files present here: + {BASE}file + {BASE}file2 (hard link to file) + {BASE}dir/ + */ + { /* File onto hard link. */ + ASSERT (func (BASE "file", BASE "file2") == 0); + memset (&st, 0, sizeof st); + if (stat (BASE "file", &st) != 0) + { + /* This can happen on NetBSD. */ + ASSERT (errno == ENOENT); + ASSERT (link (BASE "file2", BASE "file") == 0); + ASSERT (stat (BASE "file", &st) == 0); + } + ASSERT (st.st_size == 2); + memset (&st, 0, sizeof st); + ASSERT (stat (BASE "file2", &st) == 0); + ASSERT (st.st_size == 2); + } + /* Files present here: + {BASE}file + {BASE}file2 + {BASE}dir/ + */ + ASSERT (unlink (BASE "file2") == 0); + /* Files present here: + {BASE}file + {BASE}dir/ + */ + + /* Symlinks. */ + + if (symlink (BASE "file", BASE "link1")) + { + if (print) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + ASSERT (unlink (BASE "file") == 0); + ASSERT (rmdir (BASE "dir") == 0); + return 77; + } + /* Files present here: + {BASE}file + {BASE}link1 -> {BASE}file + {BASE}dir/ + */ + { /* Simple rename. */ + ASSERT (func (BASE "link1", BASE "link2") == 0); + ASSERT (stat (BASE "file", &st) == 0); + errno = 0; + ASSERT (lstat (BASE "link1", &st) == -1); + ASSERT (errno == ENOENT); + memset (&st, 0, sizeof st); + ASSERT (lstat (BASE "link2", &st) == 0); + ASSERT (S_ISLNK (st.st_mode)); + } + /* Files present here: + {BASE}file + {BASE}link2 -> {BASE}file + {BASE}dir/ + */ + { /* Overwrite. */ + ASSERT (symlink (BASE "nowhere", BASE "link1") == 0); + /* Files present here: + {BASE}file + {BASE}link1 -> {BASE}nowhere + {BASE}link2 -> {BASE}file + {BASE}dir/ + */ + { + ASSERT (func (BASE "link2", BASE "link1") == 0); + memset (&st, 0, sizeof st); + ASSERT (stat (BASE "link1", &st) == 0); + ASSERT (st.st_size == 2); + errno = 0; + ASSERT (lstat (BASE "link2", &st) == -1); + ASSERT (errno == ENOENT); + } + } + /* Files present here: + {BASE}file + {BASE}link1 -> {BASE}file + {BASE}dir/ + */ + { /* Symlink loop. */ + ASSERT (symlink (BASE "link2", BASE "link2") == 0); + /* Files present here: + {BASE}file + {BASE}link1 -> {BASE}file + {BASE}link2 -> {BASE}link2 + {BASE}dir/ + */ + { + ASSERT (func (BASE "link2", BASE "link2") == 0); + } + { + errno = 0; + ASSERT (func (BASE "link2/", BASE "link2") == -1); + ASSERT (errno == ELOOP || errno == ENOTDIR); + } + ASSERT (func (BASE "link2", BASE "link3") == 0); + /* Files present here: + {BASE}file + {BASE}link1 -> {BASE}file + {BASE}link3 -> {BASE}link2 + {BASE}dir/ + */ + ASSERT (unlink (BASE "link3") == 0); + } + /* Files present here: + {BASE}file + {BASE}link1 -> {BASE}file + {BASE}dir/ + */ + { /* Dangling link. */ + ASSERT (symlink (BASE "nowhere", BASE "link2") == 0); + /* Files present here: + {BASE}file + {BASE}link1 -> {BASE}file + {BASE}link2 -> {BASE}nowhere + {BASE}dir/ + */ + { + ASSERT (func (BASE "link2", BASE "link3") == 0); + errno = 0; + ASSERT (lstat (BASE "link2", &st) == -1); + ASSERT (errno == ENOENT); + memset (&st, 0, sizeof st); + ASSERT (lstat (BASE "link3", &st) == 0); + } + } + /* Files present here: + {BASE}file + {BASE}link1 -> {BASE}file + {BASE}link3 -> {BASE}nowhere + {BASE}dir/ + */ + { /* Trailing slash on dangling. */ + { + errno = 0; + ASSERT (func (BASE "link3/", BASE "link2") == -1); + ASSERT (errno == ENOENT || errno == ENOTDIR); + } + { + errno = 0; + ASSERT (func (BASE "link3", BASE "link2/") == -1); + ASSERT (errno == ENOENT || errno == ENOTDIR); + } + { + errno = 0; + ASSERT (lstat (BASE "link2", &st) == -1); + ASSERT (errno == ENOENT); + } + memset (&st, 0, sizeof st); + ASSERT (lstat (BASE "link3", &st) == 0); + } + /* Files present here: + {BASE}file + {BASE}link1 -> {BASE}file + {BASE}link3 -> {BASE}nowhere + {BASE}dir/ + */ + { /* Trailing slash on link to file. */ + { + errno = 0; + ASSERT (func (BASE "link1/", BASE "link2") == -1); + ASSERT (errno == ENOTDIR); + } + { + errno = 0; + ASSERT (func (BASE "link1", BASE "link3/") == -1); + ASSERT (errno == ENOENT || errno == ENOTDIR); + } + } + /* Files present here: + {BASE}file + {BASE}link1 -> {BASE}file + {BASE}link3 -> {BASE}nowhere + {BASE}dir/ + */ + + /* Mixing symlink and file. */ + + { /* File onto link. */ + ASSERT (close (creat (BASE "file2", 0600)) == 0); + /* Files present here: + {BASE}file + {BASE}file2 + {BASE}link1 -> {BASE}file + {BASE}link3 -> {BASE}nowhere + {BASE}dir/ + */ + { + ASSERT (func (BASE "file2", BASE "link3") == 0); + errno = 0; + ASSERT (stat (BASE "file2", &st) == -1); + ASSERT (errno == ENOENT); + memset (&st, 0, sizeof st); + ASSERT (lstat (BASE "link3", &st) == 0); + ASSERT (S_ISREG (st.st_mode)); + } + /* Files present here: + {BASE}file + {BASE}link1 -> {BASE}file + {BASE}link3 + {BASE}dir/ + */ + ASSERT (unlink (BASE "link3") == 0); + } + /* Files present here: + {BASE}file + {BASE}link1 -> {BASE}file + {BASE}dir/ + */ + { /* Link onto file. */ + ASSERT (symlink (BASE "nowhere", BASE "link2") == 0); + /* Files present here: + {BASE}file + {BASE}link1 -> {BASE}file + {BASE}link2 -> {BASE}nowhere + {BASE}dir/ + */ + ASSERT (close (creat (BASE "file2", 0600)) == 0); + /* Files present here: + {BASE}file + {BASE}file2 + {BASE}link1 -> {BASE}file + {BASE}link2 -> {BASE}nowhere + {BASE}dir/ + */ + { + ASSERT (func (BASE "link2", BASE "file2") == 0); + errno = 0; + ASSERT (lstat (BASE "link2", &st) == -1); + ASSERT (errno == ENOENT); + memset (&st, 0, sizeof st); + ASSERT (lstat (BASE "file2", &st) == 0); + ASSERT (S_ISLNK (st.st_mode)); + } + /* Files present here: + {BASE}file + {BASE}file2 -> {BASE}nowhere + {BASE}link1 -> {BASE}file + {BASE}dir/ + */ + ASSERT (unlink (BASE "file2") == 0); + } + /* Files present here: + {BASE}file + {BASE}link1 -> {BASE}file + {BASE}dir/ + */ + { /* Trailing slash. */ + { + errno = 0; + ASSERT (func (BASE "file/", BASE "link1") == -1); + ASSERT (errno == ENOTDIR); + } + { + errno = 0; + ASSERT (func (BASE "file", BASE "link1/") == -1); + ASSERT (errno == ENOTDIR || errno == ENOENT); + } + { + errno = 0; + ASSERT (func (BASE "link1/", BASE "file") == -1); + ASSERT (errno == ENOTDIR); + } + { + errno = 0; + ASSERT (func (BASE "link1", BASE "file/") == -1); + ASSERT (errno == ENOTDIR || errno == ENOENT); + memset (&st, 0, sizeof st); + ASSERT (lstat (BASE "file", &st) == 0); + ASSERT (S_ISREG (st.st_mode)); + memset (&st, 0, sizeof st); + ASSERT (lstat (BASE "link1", &st) == 0); + ASSERT (S_ISLNK (st.st_mode)); + } + } + /* Files present here: + {BASE}file + {BASE}link1 -> {BASE}file + {BASE}dir/ + */ + + /* Mixing symlink and directory. */ + + { /* Directory onto link. */ + { + errno = 0; + ASSERT (func (BASE "dir", BASE "link1") == -1); + ASSERT (errno == ENOTDIR); + } + { + errno = 0; + ASSERT (func (BASE "dir/", BASE "link1") == -1); + ASSERT (errno == ENOTDIR); + } + { + errno = 0; + ASSERT (func (BASE "dir", BASE "link1/") == -1); + ASSERT (errno == ENOTDIR); + } + } + { /* Link onto directory. */ + { + errno = 0; + ASSERT (func (BASE "link1", BASE "dir") == -1); + ASSERT (errno == EISDIR || errno == ENOTDIR); + } + { + errno = 0; + ASSERT (func (BASE "link1", BASE "dir/") == -1); + ASSERT (errno == EISDIR || errno == ENOTDIR); + } + { + errno = 0; + ASSERT (func (BASE "link1/", BASE "dir") == -1); + ASSERT (errno == ENOTDIR); + memset (&st, 0, sizeof st); + ASSERT (lstat (BASE "link1", &st) == 0); + ASSERT (S_ISLNK (st.st_mode)); + memset (&st, 0, sizeof st); + ASSERT (lstat (BASE "dir", &st) == 0); + ASSERT (S_ISDIR (st.st_mode)); + } + } + /* Files present here: + {BASE}file + {BASE}link1 -> {BASE}file + {BASE}dir/ + */ + + /* POSIX requires rename("link-to-dir/","other") to rename "dir" and + leave "link-to-dir" dangling, but GNU rejects this. POSIX + requires rename("dir","dangling/") to create the directory so + that "dangling/" now resolves, but GNU rejects this. While we + prefer GNU behavior, we don't enforce it. However, we do test + that the system either follows POSIX in both cases, or follows + GNU. */ + { + int result; + ASSERT (symlink (BASE "dir2", BASE "link2") == 0); + /* Files present here: + {BASE}file + {BASE}link1 -> {BASE}file + {BASE}link2 -> {BASE}dir2 + {BASE}dir/ + */ + errno = 0; + result = func (BASE "dir", BASE "link2/"); + if (result == 0) + { + /* POSIX. */ + errno = 0; + ASSERT (lstat (BASE "dir", &st) == -1); + ASSERT (errno == ENOENT); + memset (&st, 0, sizeof st); + ASSERT (lstat (BASE "dir2", &st) == 0); + ASSERT (S_ISDIR (st.st_mode)); + memset (&st, 0, sizeof st); + ASSERT (lstat (BASE "link2", &st) == 0); + ASSERT (S_ISLNK (st.st_mode)); + /* Files present here: + {BASE}file + {BASE}link1 -> {BASE}file + {BASE}link2 -> {BASE}dir2 + {BASE}dir2/ + */ + { + ASSERT (func (BASE "link2/", BASE "dir") == 0); + memset (&st, 0, sizeof st); + ASSERT (lstat (BASE "dir", &st) == 0); + ASSERT (S_ISDIR (st.st_mode)); + errno = 0; + ASSERT (lstat (BASE "dir2", &st) == -1); + ASSERT (errno == ENOENT); + memset (&st, 0, sizeof st); + ASSERT (lstat (BASE "link2", &st) == 0); + ASSERT (S_ISLNK (st.st_mode)); + } + } + else + { + /* GNU. */ + ASSERT (result == -1); + ASSERT (errno == ENOTDIR); + memset (&st, 0, sizeof st); + ASSERT (lstat (BASE "dir", &st) == 0); + ASSERT (S_ISDIR (st.st_mode)); + errno = 0; + ASSERT (lstat (BASE "dir2", &st) == -1); + ASSERT (errno == ENOENT); + memset (&st, 0, sizeof st); + ASSERT (lstat (BASE "link2", &st) == 0); + ASSERT (S_ISLNK (st.st_mode)); + ASSERT (unlink (BASE "link2") == 0); + ASSERT (symlink (BASE "dir", BASE "link2") == 0); + /* Files present here: + {BASE}file + {BASE}link1 -> {BASE}file + {BASE}link2 -> {BASE}dir + {BASE}dir/ + */ + errno = 0; /* OpenBSD notices that link2/ and dir are the same. */ + result = func (BASE "link2/", BASE "dir"); + if (result) /* GNU/Linux rejects attempts to use link2/. */ + { + ASSERT (result == -1); + ASSERT (errno == ENOTDIR || errno == EISDIR); + } + memset (&st, 0, sizeof st); + ASSERT (lstat (BASE "dir", &st) == 0); + ASSERT (S_ISDIR (st.st_mode)); + errno = 0; + ASSERT (lstat (BASE "dir2", &st) == -1); + ASSERT (errno == ENOENT); + memset (&st, 0, sizeof st); + ASSERT (lstat (BASE "link2", &st) == 0); + ASSERT (S_ISLNK (st.st_mode)); + } + } + /* Files present here: + {BASE}file + {BASE}link1 -> {BASE}file + {BASE}link2 -> {BASE}dir or {BASE}dir2 + {BASE}dir/ + */ + + /* Clean up. */ + ASSERT (unlink (BASE "file") == 0); + ASSERT (rmdir (BASE "dir") == 0); + ASSERT (unlink (BASE "link1") == 0); + ASSERT (unlink (BASE "link2") == 0); + + return 0; +} diff --git a/gnulib-tests/test-renameat.c b/gnulib-tests/test-renameat.c new file mode 100644 index 0000000..b952a15 --- /dev/null +++ b/gnulib-tests/test-renameat.c @@ -0,0 +1,208 @@ +/* Tests of renameat. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (renameat, int, (int, char const *, int, char const *)); + +#include <dirent.h> +#include <fcntl.h> +#include <errno.h> +#include <stdbool.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/stat.h> + +#include "filenamecat.h" +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-renameat.t" + +#include "test-rename.h" + +static int dfd1 = AT_FDCWD; +static int dfd2 = AT_FDCWD; + +/* Wrapper to test renameat like rename. */ +static int +do_rename (char const *name1, char const *name2) +{ + return renameat (dfd1, name1, dfd2, name2); +} + +int +main (void) +{ + int i; + int dfd; + char *cwd; + int result; + + /* Clean up any trash from prior testsuite runs. */ + ignore_value (system ("rm -rf " BASE "*")); + + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (renameat (-1, "foo", AT_FDCWD, "bar") == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (renameat (99, "foo", AT_FDCWD, "bar") == -1); + ASSERT (errno == EBADF); + } + ASSERT (close (creat (BASE "oo", 0600)) == 0); + { + errno = 0; + ASSERT (renameat (AT_FDCWD, BASE "oo", -1, "bar") == -1); + ASSERT (errno == EBADF); + } + { + errno = 0; + ASSERT (renameat (AT_FDCWD, BASE "oo", 99, "bar") == -1); + ASSERT (errno == EBADF); + } + ASSERT (unlink (BASE "oo") == 0); + + /* Test basic rename functionality, using current directory. */ + result = test_rename (do_rename, false); + dfd1 = open (".", O_RDONLY); + ASSERT (0 <= dfd1); + ASSERT (test_rename (do_rename, false) == result); + dfd2 = dfd1; + ASSERT (test_rename (do_rename, false) == result); + dfd1 = AT_FDCWD; + ASSERT (test_rename (do_rename, false) == result); + ASSERT (close (dfd2) == 0); + + /* Create locations to manipulate. */ + ASSERT (mkdir (BASE "sub1", 0700) == 0); + ASSERT (mkdir (BASE "sub2", 0700) == 0); + dfd = creat (BASE "00", 0600); + ASSERT (0 <= dfd); + ASSERT (close (dfd) == 0); + cwd = getcwd (NULL, 0); + ASSERT (cwd); + + dfd = open (BASE "sub1", O_RDONLY); + ASSERT (0 <= dfd); + ASSERT (chdir (BASE "sub2") == 0); + + /* There are 16 possible scenarios, based on whether an fd is + AT_FDCWD or real, and whether a file is absolute or relative. + + To ensure that we test all of the code paths (rather than + triggering early normalization optimizations), we use a loop to + repeatedly rename a file in the parent directory, use an fd open + on subdirectory 1, all while executing in subdirectory 2; all + relative names are thus given with a leading "../". Finally, the + last scenario (two relative paths given, neither one AT_FDCWD) + has two paths, based on whether the two fds are equivalent, so we + do the other variant after the loop. */ + for (i = 0; i < 16; i++) + { + int fd1 = (i & 8) ? dfd : AT_FDCWD; + char *file1 = file_name_concat ((i & 4) ? ".." : cwd, BASE "xx", NULL); + int fd2 = (i & 2) ? dfd : AT_FDCWD; + char *file2 = file_name_concat ((i & 1) ? ".." : cwd, BASE "xx", NULL); + + ASSERT (sprintf (strchr (file1, '\0') - 2, "%02d", i) == 2); + ASSERT (sprintf (strchr (file2, '\0') - 2, "%02d", i + 1) == 2); + ASSERT (renameat (fd1, file1, fd2, file2) == 0); + free (file1); + free (file2); + } + dfd2 = open ("..", O_RDONLY); + ASSERT (0 <= dfd2); + ASSERT (renameat (dfd, "../" BASE "16", dfd2, BASE "17") == 0); + ASSERT (close (dfd2) == 0); + + /* Now we change back to the parent directory, and set dfd to "."; + using dfd in remaining tests will expose any bugs if emulation + via /proc/self/fd doesn't check for empty names. */ + ASSERT (chdir ("..") == 0); + ASSERT (close (dfd) == 0); + dfd = open (".", O_RDONLY); + ASSERT (0 <= dfd); + + ASSERT (close (creat (BASE "sub2/file", 0600)) == 0); + errno = 0; + ASSERT (renameat (dfd, BASE "sub1", dfd, BASE "sub2") == -1); + ASSERT (errno == EEXIST || errno == ENOTEMPTY); + ASSERT (unlink (BASE "sub2/file") == 0); + errno = 0; + ASSERT (renameat (dfd, BASE "sub2", dfd, BASE "sub1/.") == -1); + ASSERT (errno == EINVAL || errno == EISDIR || errno == EBUSY + || errno == ENOTEMPTY || errno == EEXIST + || errno == ENOENT /* WSL */); + errno = 0; + ASSERT (renameat (dfd, BASE "sub2/.", dfd, BASE "sub1") == -1); + ASSERT (errno == EINVAL || errno == EBUSY || errno == EEXIST + || errno == ENOENT /* WSL */); + errno = 0; + ASSERT (renameat (dfd, BASE "17", dfd, BASE "sub1") == -1); + ASSERT (errno == EISDIR); + errno = 0; + ASSERT (renameat (dfd, BASE "nosuch", dfd, BASE "18") == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (renameat (dfd, "", dfd, BASE "17") == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (renameat (dfd, BASE "17", dfd, "") == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (renameat (dfd, BASE "sub2", dfd, BASE "17") == -1); + ASSERT (errno == ENOTDIR); + errno = 0; + ASSERT (renameat (dfd, BASE "17/", dfd, BASE "18") == -1); + ASSERT (errno == ENOTDIR); + errno = 0; + ASSERT (renameat (dfd, BASE "17", dfd, BASE "18/") == -1); + ASSERT (errno == ENOTDIR || errno == ENOENT); + + /* Finally, make sure we can overwrite existing files. */ + ASSERT (close (creat (BASE "sub2/file", 0600)) == 0); + errno = 0; + ASSERT (renameat (dfd, BASE "sub2", dfd, BASE "sub1") == 0); + ASSERT (renameat (dfd, BASE "sub1/file", dfd, BASE "17") == 0); + + /* Cleanup. */ + ASSERT (close (dfd) == 0); + errno = 0; + ASSERT (unlink (BASE "sub1/file") == -1); + ASSERT (errno == ENOENT); + ASSERT (unlink (BASE "17") == 0); + ASSERT (rmdir (BASE "sub1") == 0); + errno = 0; + ASSERT (rmdir (BASE "sub2") == -1); + ASSERT (errno == ENOENT); + free (cwd); + + if (result) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return result; +} diff --git a/gnulib-tests/test-renameatu.c b/gnulib-tests/test-renameatu.c new file mode 100644 index 0000000..728a352 --- /dev/null +++ b/gnulib-tests/test-renameatu.c @@ -0,0 +1,211 @@ +/* Test renameatu. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <renameatu.h> + +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (renameatu, int, + (int, char const *, int, char const *, unsigned int)); + +#include <dirent.h> +#include <fcntl.h> +#include <errno.h> +#include <stdbool.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/stat.h> + +#include "filenamecat.h" +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-renameatu.t" + +#include "test-rename.h" + +static int dfd1 = AT_FDCWD; +static int dfd2 = AT_FDCWD; + +/* Wrapper to test renameatu like rename. */ +static int +do_rename (char const *name1, char const *name2) +{ + return renameatu (dfd1, name1, dfd2, name2, 0); +} + +int +main (void) +{ + int i; + int dfd; + char *cwd; + int result; + + /* Clean up any trash from prior testsuite runs. */ + ignore_value (system ("rm -rf " BASE "*")); + + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (renameatu (-1, "foo", AT_FDCWD, "bar", 0) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (renameatu (99, "foo", AT_FDCWD, "bar", 0) == -1); + ASSERT (errno == EBADF); + } + ASSERT (close (creat (BASE "oo", 0600)) == 0); + { + errno = 0; + ASSERT (renameatu (AT_FDCWD, BASE "oo", -1, "bar", 0) == -1); + ASSERT (errno == EBADF); + } + { + errno = 0; + ASSERT (renameatu (AT_FDCWD, BASE "oo", 99, "bar", 0) == -1); + ASSERT (errno == EBADF); + } + ASSERT (unlink (BASE "oo") == 0); + + /* Test basic rename functionality, using current directory. */ + result = test_rename (do_rename, false); + dfd1 = open (".", O_RDONLY); + ASSERT (0 <= dfd1); + ASSERT (test_rename (do_rename, false) == result); + dfd2 = dfd1; + ASSERT (test_rename (do_rename, false) == result); + dfd1 = AT_FDCWD; + ASSERT (test_rename (do_rename, false) == result); + ASSERT (close (dfd2) == 0); + + /* Create locations to manipulate. */ + ASSERT (mkdir (BASE "sub1", 0700) == 0); + ASSERT (mkdir (BASE "sub2", 0700) == 0); + dfd = creat (BASE "00", 0600); + ASSERT (0 <= dfd); + ASSERT (close (dfd) == 0); + cwd = getcwd (NULL, 0); + ASSERT (cwd); + + dfd = open (BASE "sub1", O_RDONLY); + ASSERT (0 <= dfd); + ASSERT (chdir (BASE "sub2") == 0); + + /* There are 16 possible scenarios, based on whether an fd is + AT_FDCWD or real, and whether a file is absolute or relative. + + To ensure that we test all of the code paths (rather than + triggering early normalization optimizations), we use a loop to + repeatedly rename a file in the parent directory, use an fd open + on subdirectory 1, all while executing in subdirectory 2; all + relative names are thus given with a leading "../". Finally, the + last scenario (two relative paths given, neither one AT_FDCWD) + has two paths, based on whether the two fds are equivalent, so we + do the other variant after the loop. */ + for (i = 0; i < 16; i++) + { + int fd1 = (i & 8) ? dfd : AT_FDCWD; + char *file1 = file_name_concat ((i & 4) ? ".." : cwd, BASE "xx", NULL); + int fd2 = (i & 2) ? dfd : AT_FDCWD; + char *file2 = file_name_concat ((i & 1) ? ".." : cwd, BASE "xx", NULL); + + ASSERT (sprintf (strchr (file1, '\0') - 2, "%02d", i) == 2); + ASSERT (sprintf (strchr (file2, '\0') - 2, "%02d", i + 1) == 2); + ASSERT (renameatu (fd1, file1, fd2, file2, 0) == 0); + free (file1); + free (file2); + } + dfd2 = open ("..", O_RDONLY); + ASSERT (0 <= dfd2); + ASSERT (renameatu (dfd, "../" BASE "16", dfd2, BASE "17", 0) == 0); + ASSERT (close (dfd2) == 0); + + /* Now we change back to the parent directory, and set dfd to "."; + using dfd in remaining tests will expose any bugs if emulation + via /proc/self/fd doesn't check for empty names. */ + ASSERT (chdir ("..") == 0); + ASSERT (close (dfd) == 0); + dfd = open (".", O_RDONLY); + ASSERT (0 <= dfd); + + ASSERT (close (creat (BASE "sub2/file", 0600)) == 0); + errno = 0; + ASSERT (renameatu (dfd, BASE "sub1", dfd, BASE "sub2", 0) == -1); + ASSERT (errno == EEXIST || errno == ENOTEMPTY); + ASSERT (unlink (BASE "sub2/file") == 0); + errno = 0; + ASSERT (renameatu (dfd, BASE "sub2", dfd, BASE "sub1/.", 0) == -1); + ASSERT (errno == EINVAL || errno == EISDIR || errno == EBUSY + || errno == ENOTEMPTY || errno == EEXIST + || errno == ENOENT /* WSL */); + errno = 0; + ASSERT (renameatu (dfd, BASE "sub2/.", dfd, BASE "sub1", 0) == -1); + ASSERT (errno == EINVAL || errno == EBUSY || errno == EEXIST + || errno == ENOENT /* WSL */); + errno = 0; + ASSERT (renameatu (dfd, BASE "17", dfd, BASE "sub1", 0) == -1); + ASSERT (errno == EISDIR); + errno = 0; + ASSERT (renameatu (dfd, BASE "nosuch", dfd, BASE "18", 0) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (renameatu (dfd, "", dfd, BASE "17", 0) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (renameatu (dfd, BASE "17", dfd, "", 0) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (renameatu (dfd, BASE "sub2", dfd, BASE "17", 0) == -1); + ASSERT (errno == ENOTDIR); + errno = 0; + ASSERT (renameatu (dfd, BASE "17/", dfd, BASE "18", 0) == -1); + ASSERT (errno == ENOTDIR); + errno = 0; + ASSERT (renameatu (dfd, BASE "17", dfd, BASE "18/", 0) == -1); + ASSERT (errno == ENOTDIR || errno == ENOENT); + + /* Finally, make sure we cannot overwrite existing files. */ + ASSERT (close (creat (BASE "sub2/file", 0600)) == 0); + errno = 0; + ASSERT ((renameatu (dfd, BASE "sub2", dfd, BASE "sub1", RENAME_NOREPLACE) + == -1) + && errno == EEXIST); + ASSERT ((renameatu (dfd, BASE "sub2/file", dfd, BASE "17", RENAME_NOREPLACE) + == -1) + && errno == EEXIST); + + /* Cleanup. */ + ASSERT (close (dfd) == 0); + ASSERT (unlink (BASE "sub2/file") == 0); + ASSERT (unlink (BASE "17") == 0); + ASSERT (rmdir (BASE "sub1") == 0); + ASSERT (rmdir (BASE "sub2") == 0); + free (cwd); + + if (result) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return result; +} diff --git a/gnulib-tests/test-rmdir.c b/gnulib-tests/test-rmdir.c new file mode 100644 index 0000000..0c787b9 --- /dev/null +++ b/gnulib-tests/test-rmdir.c @@ -0,0 +1,47 @@ +/* Tests of rmdir. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (rmdir, int, (char const *)); + +#include <fcntl.h> +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/stat.h> + +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-rmdir.t" + +#include "test-rmdir.h" + +int +main (void) +{ + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + return test_rmdir_func (rmdir, true); +} diff --git a/gnulib-tests/test-rmdir.h b/gnulib-tests/test-rmdir.h new file mode 100644 index 0000000..c5bdef2 --- /dev/null +++ b/gnulib-tests/test-rmdir.h @@ -0,0 +1,102 @@ +/* Tests of rmdir. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +/* This file is designed to test both rmdir(n) and + unlinkat(AT_FDCWD,n,AT_REMOVEDIR). FUNC is the function to test. + Assumes that BASE and ASSERT are already defined, and that + appropriate headers are already included. If PRINT, then warn + before returning status 77 when symlinks are unsupported. */ + +static int +test_rmdir_func (int (*func) (char const *name), bool print) +{ + /* Setup. */ + ASSERT (mkdir (BASE "dir", 0700) == 0); + ASSERT (close (creat (BASE "dir/file", 0600)) == 0); + + /* Basic error conditions. */ + errno = 0; + ASSERT (func ("") == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func (BASE "nosuch") == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func (BASE "nosuch/") == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func (".") == -1); + ASSERT (errno == EINVAL || errno == EBUSY); + /* Resulting errno after ".." or "/" is too varied to test; it is + reasonable to see any of EINVAL, EBUSY, EEXIST, ENOTEMPTY, + EACCES, EPERM. */ + ASSERT (func ("..") == -1); + ASSERT (func ("/") == -1); + ASSERT (func ("///") == -1); + errno = 0; + ASSERT (func (BASE "dir/file/") == -1); + ASSERT (errno == ENOTDIR); + + /* Non-empty directory. */ + errno = 0; + ASSERT (func (BASE "dir") == -1); + ASSERT (errno == EEXIST || errno == ENOTEMPTY); + + /* Non-directory. */ + errno = 0; + ASSERT (func (BASE "dir/file") == -1); + ASSERT (errno == ENOTDIR); + + /* Empty directory. */ + ASSERT (unlink (BASE "dir/file") == 0); + errno = 0; + ASSERT (func (BASE "dir/.//") == -1); + ASSERT (errno == EINVAL || errno == EBUSY || errno == EEXIST + || errno == ENOTEMPTY); + ASSERT (func (BASE "dir") == 0); + + /* Test symlink behavior. Specifying trailing slash should remove + referent directory (POSIX), or cause ENOTDIR failure (Linux), but + not touch symlink. We prefer the Linux behavior for its + intuitiveness (especially compared to rmdir("symlink-to-file/")), + but not enough to penalize POSIX systems with an rpl_rmdir. */ + if (symlink (BASE "dir", BASE "link") != 0) + { + if (print) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + ASSERT (mkdir (BASE "dir", 0700) == 0); + errno = 0; + if (func (BASE "link/") == 0) + { + struct stat st; + errno = 0; + ASSERT (stat (BASE "link", &st) == -1); + ASSERT (errno == ENOENT); + } + else + { + ASSERT (errno == ENOTDIR); + ASSERT (func (BASE "dir") == 0); + } + ASSERT (unlink (BASE "link") == 0); + + return 0; +} diff --git a/gnulib-tests/test-rwlock1.c b/gnulib-tests/test-rwlock1.c new file mode 100644 index 0000000..0ae78f2 --- /dev/null +++ b/gnulib-tests/test-rwlock1.c @@ -0,0 +1,170 @@ +/* Test of glthread_rwlock_rdlock function. + Copyright (C) 2017-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2005. + Inspired by + https://github.com/linux-test-project/ltp/blob/master/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-2.c + by Intel Corporation. */ + +#include <config.h> + +#if USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS || USE_WINDOWS_THREADS + +#include "glthread/lock.h" + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "glthread/thread.h" + +/* Verify that in a situation where + - an rwlock is taken by a reader and has a writer waiting, + - an additional reader requests the lock, + - the waiting writer and the requesting reader threads have the same + priority, + the requesting reader thread gets blocked, so that at some point the + waiting writer can acquire the lock. + Without such a guarantee, when there a N readers and each of the readers + spends more than 1/Nth of the time with the lock held, there is a high + probability that the waiting writer will not get the lock in a given finite + time, a phenomenon called "writer starvation". + Without such a guarantee, applications have a hard time avoiding writer + starvation. + + POSIX:2008 makes this requirement only for implementations that support TPS + (Thread Priority Scheduling) and only for the scheduling policies SCHED_FIFO + and SCHED_RR, see + https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_rwlock_rdlock.html + but test verifies the guarantee regardless of TPS and regardless of + scheduling policy. */ + +#define SUCCEED() exit (0) +#define FAILURE() exit (1) +#define UNEXPECTED(n) (fprintf (stderr, "Unexpected outcome %d\n", n), abort ()) + +/* The main thread creates the waiting writer and the requesting reader threads + in the default way; this guarantees that they have the same priority. + We can reuse the main thread as first reader thread. */ + +static gl_rwlock_t lock; +static gl_thread_t reader1; +static gl_thread_t writer; +static gl_thread_t reader2; +static gl_thread_t timer; +/* Used to pass control from writer to reader2 and from reader2 to timer, + as in a relay race. + Passing control from one running thread to another running thread + is most likely faster than to create the second thread. */ +static gl_lock_t baton; + +static void * +timer_func (void *ignored) +{ + /* Step 13 (can be before or after step 12): + The timer thread takes the baton, then waits a moment to make sure + it can tell whether the second reader thread is blocked at step 12. */ + if (glthread_lock_lock (&baton)) + UNEXPECTED (13); + usleep (100000); + /* By the time we get here, it's clear that the second reader thread is + blocked at step 12. This is the desired behaviour. */ + SUCCEED (); +} + +static void * +reader2_func (void *ignored) +{ + int err; + + /* Step 8 (can be before or after step 7): + The second reader thread takes the baton, then waits a moment to make sure + the writer thread has reached step 7. */ + if (glthread_lock_lock (&baton)) + UNEXPECTED (8); + usleep (100000); + /* Step 9 omitted. */ + /* Step 10: Launch a timer, to test whether the next call blocks. */ + if (glthread_create (&timer, timer_func, NULL)) + UNEXPECTED (10); + /* Step 11: Release the baton. */ + if (glthread_lock_unlock (&baton)) + UNEXPECTED (11); + /* Step 12: The second reader thread requests the lock. */ + err = glthread_rwlock_rdlock (&lock); + if (err == 0) + FAILURE (); + else + UNEXPECTED (12); +} + +static void * +writer_func (void *ignored) +{ + /* Step 4: Take the baton, so that the second reader thread does not go ahead + too early. */ + if (glthread_lock_lock (&baton)) + UNEXPECTED (4); + /* Step 5: Create the second reader thread. */ + if (glthread_create (&reader2, reader2_func, NULL)) + UNEXPECTED (5); + /* Step 6: Release the baton. */ + if (glthread_lock_unlock (&baton)) + UNEXPECTED (6); + /* Step 7: The writer thread requests the lock. */ + if (glthread_rwlock_wrlock (&lock)) + UNEXPECTED (7); + return NULL; +} + +int +main () +{ + reader1 = gl_thread_self (); + + /* Step 1: The main thread initializes the lock and the baton. */ + if (glthread_rwlock_init (&lock)) + UNEXPECTED (1); + if (glthread_lock_init (&baton)) + UNEXPECTED (1); + /* Step 2: The main thread acquires the lock as a reader. */ + if (glthread_rwlock_rdlock (&lock)) + UNEXPECTED (2); + /* Step 3: Create the writer thread. */ + if (glthread_create (&writer, writer_func, NULL)) + UNEXPECTED (3); + /* Job done. Go to sleep. */ + for (;;) + { + sleep (1); + } +} + +#else + +/* No multithreading available. */ + +#include <stdio.h> + +int +main () +{ + fputs ("Skipping test: multithreading not enabled\n", stderr); + return 77; +} + +#endif diff --git a/gnulib-tests/test-sameacls.c b/gnulib-tests/test-sameacls.c new file mode 100644 index 0000000..cdb10f4 --- /dev/null +++ b/gnulib-tests/test-sameacls.c @@ -0,0 +1,714 @@ +/* Test whether two files have the same ACLs. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2008. */ + +#include <config.h> + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> + +#if HAVE_ACL_GET_FILE || HAVE_FACL || HAVE_GETACL || HAVE_ACLX_GET || HAVE_STATACL || HAVE_ACLSORT +# include <sys/types.h> +# include <sys/acl.h> +#endif +#if HAVE_ACLV_H +# include <sys/types.h> +# include <aclv.h> +#endif + +#include "read-file.h" +#include "xalloc.h" +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + const char *file1; + const char *file2; + + ASSERT (argc == 3); + + file1 = argv[1]; + file2 = argv[2]; + + /* Compare the contents of the two files. */ + { + size_t size1; + char *contents1; + size_t size2; + char *contents2; + + contents1 = read_file (file1, &size1); + if (contents1 == NULL) + { + fprintf (stderr, "error reading file %s: errno = %d\n", file1, errno); + fflush (stderr); + abort (); + } + contents2 = read_file (file2, &size2); + if (contents2 == NULL) + { + fprintf (stderr, "error reading file %s: errno = %d\n", file2, errno); + fflush (stderr); + abort (); + } + + if (size2 != size1) + { + fprintf (stderr, "files %s and %s have different sizes\n", + file1, file2); + fflush (stderr); + abort (); + } + if (memcmp (contents1, contents2, size1) != 0) + { + fprintf (stderr, "files %s and %s have different contents\n", + file1, file2); + fflush (stderr); + abort (); + } + + free (contents2); + free (contents1); + } + + /* Compare the access permissions of the two files, including ACLs. */ + { + struct stat statbuf1; + struct stat statbuf2; + + if (stat (file1, &statbuf1) < 0) + { + fprintf (stderr, "error accessing file %s: errno = %d\n", file1, errno); + fflush (stderr); + abort (); + } + if (stat (file2, &statbuf2) < 0) + { + fprintf (stderr, "error accessing file %s: errno = %d\n", file2, errno); + fflush (stderr); + abort (); + } + if (statbuf1.st_mode != statbuf2.st_mode) + { + fprintf (stderr, "files %s and %s have different access modes: %03o and %03o\n", + file1, file2, + (unsigned int) statbuf1.st_mode, (unsigned int) statbuf2.st_mode); + return 1; + } + } + { +#if HAVE_ACL_GET_FILE /* Linux, FreeBSD, Mac OS X, IRIX, Tru64 */ + static const int types[] = + { + ACL_TYPE_ACCESS +# if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */ + , ACL_TYPE_EXTENDED +# endif + }; + int t; + + for (t = 0; t < sizeof (types) / sizeof (types[0]); t++) + { + int type = types[t]; + acl_t acl1; + char *text1; + int errno1; + acl_t acl2; + char *text2; + int errno2; + + acl1 = acl_get_file (file1, type); + if (acl1 == (acl_t)NULL) + { + text1 = NULL; + errno1 = errno; + } + else + { + text1 = acl_to_text (acl1, NULL); + if (text1 == NULL) + errno1 = errno; + else + errno1 = 0; + } + acl2 = acl_get_file (file2, type); + if (acl2 == (acl_t)NULL) + { + text2 = NULL; + errno2 = errno; + } + else + { + text2 = acl_to_text (acl2, NULL); + if (text2 == NULL) + errno2 = errno; + else + errno2 = 0; + } + + if (acl1 != (acl_t)NULL) + { + if (acl2 != (acl_t)NULL) + { + if (text1 != NULL) + { + if (text2 != NULL) + { + if (strcmp (text1, text2) != 0) + { + fprintf (stderr, "files %s and %s have different ACLs:\n%s\n%s\n", + file1, file2, text1, text2); + return 1; + } + } + else + { + fprintf (stderr, "file %s has a valid ACL, but file %s has an invalid ACL\n", + file1, file2); + return 1; + } + } + else + { + if (text2 != NULL) + { + fprintf (stderr, "file %s has an invalid ACL, but file %s has a valid ACL\n", + file1, file2); + return 1; + } + else + { + if (errno1 != errno2) + { + fprintf (stderr, "files %s and %s have differently invalid ACLs, errno = %d vs. %d\n", + file1, file2, errno1, errno2); + return 1; + } + } + } + } + else + { + fprintf (stderr, "file %s has an ACL, but file %s has no ACL\n", + file1, file2); + return 1; + } + } + else + { + if (acl2 != (acl_t)NULL) + { + fprintf (stderr, "file %s has no ACL, but file %s has an ACL\n", + file1, file2); + return 1; + } + } + acl_free (text2); + if (acl2 != (acl_t)NULL) + acl_free (acl2); + acl_free (text1); + if (acl1 != (acl_t)NULL) + acl_free (acl1); + } +#elif HAVE_FACL && defined GETACL /* Solaris, Cygwin, not HP-UX */ + int count1; + int count2; + + count1 = acl (file1, GETACLCNT, 0, NULL); + if (count1 < 0 && errno == ENOSYS) /* Can happen on Solaris 10 with ZFS */ + count1 = 0; + count2 = acl (file2, GETACLCNT, 0, NULL); + if (count2 < 0 && errno == ENOSYS) /* Can happen on Solaris 10 with ZFS */ + count2 = 0; + + if (count1 < 0) + { + fprintf (stderr, "error accessing the ACLs of file %s\n", file1); + fflush (stderr); + abort (); + } + if (count2 < 0) + { + fprintf (stderr, "error accessing the ACLs of file %s\n", file2); + fflush (stderr); + abort (); + } + if (count1 != count2) + { + fprintf (stderr, "files %s and %s have different number of ACLs: %d and %d\n", + file1, file2, count1, count2); + return 1; + } + else + { + aclent_t *entries1 = XNMALLOC (count1, aclent_t); + aclent_t *entries2 = XNMALLOC (count2, aclent_t); + int i; + + if (count1 > 0 && acl (file1, GETACL, count1, entries1) < count1) + { + fprintf (stderr, "error retrieving the ACLs of file %s\n", file1); + fflush (stderr); + abort (); + } + if (count2 > 0 && acl (file2, GETACL, count2, entries2) < count1) + { + fprintf (stderr, "error retrieving the ACLs of file %s\n", file2); + fflush (stderr); + abort (); + } + for (i = 0; i < count1; i++) + { + if (entries1[i].a_type != entries2[i].a_type) + { + fprintf (stderr, "files %s and %s: different ACL entry #%d: different types %d and %d\n", + file1, file2, i, entries1[i].a_type, entries2[i].a_type); + return 1; + } + if (entries1[i].a_id != entries2[i].a_id) + { + fprintf (stderr, "files %s and %s: different ACL entry #%d: different ids %d and %d\n", + file1, file2, i, (int)entries1[i].a_id, (int)entries2[i].a_id); + return 1; + } + if (entries1[i].a_perm != entries2[i].a_perm) + { + fprintf (stderr, "files %s and %s: different ACL entry #%d: different permissions %03o and %03o\n", + file1, file2, i, (unsigned int) entries1[i].a_perm, (unsigned int) entries2[i].a_perm); + return 1; + } + } + free (entries2); + free (entries1); + } +# ifdef ACE_GETACL + count1 = acl (file1, ACE_GETACLCNT, 0, NULL); + if (count1 < 0 && errno == EINVAL) + count1 = 0; + count2 = acl (file2, ACE_GETACLCNT, 0, NULL); + if (count2 < 0 && errno == EINVAL) + count2 = 0; + if (count1 < 0) + { + fprintf (stderr, "error accessing the ACE-ACLs of file %s\n", file1); + fflush (stderr); + abort (); + } + if (count2 < 0) + { + fprintf (stderr, "error accessing the ACE-ACLs of file %s\n", file2); + fflush (stderr); + abort (); + } + { + ace_t *entries1 = XNMALLOC (count1, ace_t); + ace_t *entries2 = XNMALLOC (count2, ace_t); + int ret; + int i; + + ret = acl (file1, ACE_GETACL, count1, entries1); + if (ret < 0 && errno == EINVAL) + count1 = 0; + else if (ret < count1) + { + fprintf (stderr, "error retrieving the ACE-ACLs of file %s\n", file1); + fflush (stderr); + abort (); + } + ret = acl (file2, ACE_GETACL, count2, entries2); + if (ret < 0 && errno == EINVAL) + count2 = 0; + else if (ret < count2) + { + fprintf (stderr, "error retrieving the ACE-ACLs of file %s\n", file2); + fflush (stderr); + abort (); + } + + if (count1 != count2) + { + fprintf (stderr, "files %s and %s have different number of ACE-ACLs: %d and %d\n", + file1, file2, count1, count2); + return 1; + } + + for (i = 0; i < count1; i++) + { + if (entries1[i].a_type != entries2[i].a_type) + { + fprintf (stderr, "files %s and %s: different ACE-ACL entry #%d: different types %d and %d\n", + file1, file2, i, entries1[i].a_type, entries2[i].a_type); + return 1; + } + if (entries1[i].a_who != entries2[i].a_who) + { + fprintf (stderr, "files %s and %s: different ACE-ACL entry #%d: different ids %d and %d\n", + file1, file2, i, (int)entries1[i].a_who, (int)entries2[i].a_who); + return 1; + } + if (entries1[i].a_access_mask != entries2[i].a_access_mask) + { + fprintf (stderr, "files %s and %s: different ACE-ACL entry #%d: different access masks %03o and %03o\n", + file1, file2, i, (unsigned int) entries1[i].a_access_mask, (unsigned int) entries2[i].a_access_mask); + return 1; + } + if (entries1[i].a_flags != entries2[i].a_flags) + { + fprintf (stderr, "files %s and %s: different ACE-ACL entry #%d: different flags 0x%x and 0x%x\n", + file1, file2, i, (unsigned int) entries1[i].a_flags, (unsigned int) entries2[i].a_flags); + return 1; + } + } + free (entries2); + free (entries1); + } +# endif +#elif HAVE_GETACL /* HP-UX */ + int count1; + int count2; + + count1 = getacl (file1, 0, NULL); + if (count1 < 0 + && (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP)) + count1 = 0; + count2 = getacl (file2, 0, NULL); + if (count2 < 0 + && (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP)) + count2 = 0; + + if (count1 < 0) + { + fprintf (stderr, "error accessing the ACLs of file %s\n", file1); + fflush (stderr); + abort (); + } + if (count2 < 0) + { + fprintf (stderr, "error accessing the ACLs of file %s\n", file2); + fflush (stderr); + abort (); + } + if (count1 != count2) + { + fprintf (stderr, "files %s and %s have different number of ACLs: %d and %d\n", + file1, file2, count1, count2); + return 1; + } + else if (count1 > 0) + { + struct acl_entry *entries1 = XNMALLOC (count1, struct acl_entry); + struct acl_entry *entries2 = XNMALLOC (count2, struct acl_entry); + int i; + + if (getacl (file1, count1, entries1) < count1) + { + fprintf (stderr, "error retrieving the ACLs of file %s\n", file1); + fflush (stderr); + abort (); + } + if (getacl (file2, count2, entries2) < count1) + { + fprintf (stderr, "error retrieving the ACLs of file %s\n", file2); + fflush (stderr); + abort (); + } + for (i = 0; i < count1; i++) + { + if (entries1[i].uid != entries2[i].uid) + { + fprintf (stderr, "files %s and %s: different ACL entry #%d: different uids %d and %d\n", + file1, file2, i, (int)entries1[i].uid, (int)entries2[i].uid); + return 1; + } + if (entries1[i].gid != entries2[i].gid) + { + fprintf (stderr, "files %s and %s: different ACL entry #%d: different gids %d and %d\n", + file1, file2, i, (int)entries1[i].gid, (int)entries2[i].gid); + return 1; + } + if (entries1[i].mode != entries2[i].mode) + { + fprintf (stderr, "files %s and %s: different ACL entry #%d: different permissions %03o and %03o\n", + file1, file2, i, (unsigned int) entries1[i].mode, (unsigned int) entries2[i].mode); + return 1; + } + } + free (entries2); + free (entries1); + } + +# if HAVE_ACLV_H /* HP-UX >= 11.11 */ + { + struct acl dummy_entries[NACLVENTRIES]; + + count1 = acl ((char *) file1, ACL_CNT, NACLVENTRIES, dummy_entries); + if (count1 < 0 + && (errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL)) + count1 = 0; + count2 = acl ((char *) file2, ACL_CNT, NACLVENTRIES, dummy_entries); + if (count2 < 0 + && (errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL)) + count2 = 0; + } + + if (count1 < 0) + { + fprintf (stderr, "error accessing the ACLs of file %s\n", file1); + fflush (stderr); + abort (); + } + if (count2 < 0) + { + fprintf (stderr, "error accessing the ACLs of file %s\n", file2); + fflush (stderr); + abort (); + } + if (count1 != count2) + { + fprintf (stderr, "files %s and %s have different number of ACLs: %d and %d\n", + file1, file2, count1, count2); + return 1; + } + else if (count1 > 0) + { + struct acl *entries1 = XNMALLOC (count1, struct acl); + struct acl *entries2 = XNMALLOC (count2, struct acl); + int i; + + if (acl ((char *) file1, ACL_GET, count1, entries1) < count1) + { + fprintf (stderr, "error retrieving the ACLs of file %s\n", file1); + fflush (stderr); + abort (); + } + if (acl ((char *) file2, ACL_GET, count2, entries2) < count1) + { + fprintf (stderr, "error retrieving the ACLs of file %s\n", file2); + fflush (stderr); + abort (); + } + for (i = 0; i < count1; i++) + { + if (entries1[i].a_type != entries2[i].a_type) + { + fprintf (stderr, "files %s and %s: different ACL entry #%d: different types %d and %d\n", + file1, file2, i, entries1[i].a_type, entries2[i].a_type); + return 1; + } + if (entries1[i].a_id != entries2[i].a_id) + { + fprintf (stderr, "files %s and %s: different ACL entry #%d: different ids %d and %d\n", + file1, file2, i, (int)entries1[i].a_id, (int)entries2[i].a_id); + return 1; + } + if (entries1[i].a_perm != entries2[i].a_perm) + { + fprintf (stderr, "files %s and %s: different ACL entry #%d: different permissions %03o and %03o\n", + file1, file2, i, (unsigned int) entries1[i].a_perm, (unsigned int) entries2[i].a_perm); + return 1; + } + } + free (entries2); + free (entries1); + } +# endif +#elif HAVE_ACLX_GET /* AIX */ + acl_type_t type1; + char acl1[1000]; + size_t aclsize1 = sizeof (acl1); + mode_t mode1; + char text1[1000]; + size_t textsize1 = sizeof (text1); + acl_type_t type2; + char acl2[1000]; + size_t aclsize2 = sizeof (acl2); + mode_t mode2; + char text2[1000]; + size_t textsize2 = sizeof (text2); + + /* The docs say that type1 being 0 is equivalent to ACL_ANY, but it is not + true, in AIX 5.3. */ + type1.u64 = ACL_ANY; + if (aclx_get (file1, 0, &type1, acl1, &aclsize1, &mode1) < 0) + { + if (errno == ENOSYS) + text1[0] = '\0'; + else + { + fprintf (stderr, "error accessing the ACLs of file %s\n", file1); + fflush (stderr); + abort (); + } + } + else + if (aclx_printStr (text1, &textsize1, acl1, aclsize1, type1, file1, 0) < 0) + { + fprintf (stderr, "cannot convert the ACLs of file %s to text\n", file1); + fflush (stderr); + abort (); + } + + /* The docs say that type2 being 0 is equivalent to ACL_ANY, but it is not + true, in AIX 5.3. */ + type2.u64 = ACL_ANY; + if (aclx_get (file2, 0, &type2, acl2, &aclsize2, &mode2) < 0) + { + if (errno == ENOSYS) + text2[0] = '\0'; + else + { + fprintf (stderr, "error accessing the ACLs of file %s\n", file2); + fflush (stderr); + abort (); + } + } + else + if (aclx_printStr (text2, &textsize2, acl2, aclsize2, type2, file2, 0) < 0) + { + fprintf (stderr, "cannot convert the ACLs of file %s to text\n", file2); + fflush (stderr); + abort (); + } + + if (strcmp (text1, text2) != 0) + { + fprintf (stderr, "files %s and %s have different ACLs:\n%s\n%s\n", + file1, file2, text1, text2); + return 1; + } +#elif HAVE_STATACL /* older AIX */ + union { struct acl a; char room[4096]; } acl1; + union { struct acl a; char room[4096]; } acl2; + unsigned int i; + + if (statacl (file1, STX_NORMAL, &acl1.a, sizeof (acl1)) < 0) + { + fprintf (stderr, "error accessing the ACLs of file %s\n", file1); + fflush (stderr); + abort (); + } + if (statacl (file2, STX_NORMAL, &acl2.a, sizeof (acl2)) < 0) + { + fprintf (stderr, "error accessing the ACLs of file %s\n", file2); + fflush (stderr); + abort (); + } + + if (acl1.a.acl_len != acl2.a.acl_len) + { + fprintf (stderr, "files %s and %s have different ACL lengths: %u and %u\n", + file1, file2, acl1.a.acl_len, acl2.a.acl_len); + return 1; + } + if (acl1.a.acl_mode != acl2.a.acl_mode) + { + fprintf (stderr, "files %s and %s have different ACL modes: %03o and %03o\n", + file1, file2, acl1.a.acl_mode, acl2.a.acl_mode); + return 1; + } + if (acl1.a.u_access != acl2.a.u_access + || acl1.a.g_access != acl2.a.g_access + || acl1.a.o_access != acl2.a.o_access) + { + fprintf (stderr, "files %s and %s have different ACL access masks: %03o %03o %03o and %03o %03o %03o\n", + file1, file2, + acl1.a.u_access, acl1.a.g_access, acl1.a.o_access, + acl2.a.u_access, acl2.a.g_access, acl2.a.o_access); + return 1; + } + if (memcmp (acl1.a.acl_ext, acl2.a.acl_ext, acl1.a.acl_len) != 0) + { + fprintf (stderr, "files %s and %s have different ACL entries\n", + file1, file2); + return 1; + } +#elif HAVE_ACLSORT /* NonStop Kernel */ + int count1; + int count2; + + count1 = acl ((char *) file1, ACL_CNT, NACLENTRIES, NULL); + count2 = acl ((char *) file2, ACL_CNT, NACLENTRIES, NULL); + + if (count1 < 0) + { + fprintf (stderr, "error accessing the ACLs of file %s\n", file1); + fflush (stderr); + abort (); + } + if (count2 < 0) + { + fprintf (stderr, "error accessing the ACLs of file %s\n", file2); + fflush (stderr); + abort (); + } + if (count1 != count2) + { + fprintf (stderr, "files %s and %s have different number of ACLs: %d and %d\n", + file1, file2, count1, count2); + return 1; + } + else if (count1 > 0) + { + struct acl *entries1 = XNMALLOC (count1, struct acl); + struct acl *entries2 = XNMALLOC (count2, struct acl); + int i; + + if (acl ((char *) file1, ACL_GET, count1, entries1) < count1) + { + fprintf (stderr, "error retrieving the ACLs of file %s\n", file1); + fflush (stderr); + abort (); + } + if (acl ((char *) file2, ACL_GET, count2, entries2) < count1) + { + fprintf (stderr, "error retrieving the ACLs of file %s\n", file2); + fflush (stderr); + abort (); + } + for (i = 0; i < count1; i++) + { + if (entries1[i].a_type != entries2[i].a_type) + { + fprintf (stderr, "files %s and %s: different ACL entry #%d: different types %d and %d\n", + file1, file2, i, entries1[i].a_type, entries2[i].a_type); + return 1; + } + if (entries1[i].a_id != entries2[i].a_id) + { + fprintf (stderr, "files %s and %s: different ACL entry #%d: different ids %d and %d\n", + file1, file2, i, (int)entries1[i].a_id, (int)entries2[i].a_id); + return 1; + } + if (entries1[i].a_perm != entries2[i].a_perm) + { + fprintf (stderr, "files %s and %s: different ACL entry #%d: different permissions %03o and %03o\n", + file1, file2, i, (unsigned int) entries1[i].a_perm, (unsigned int) entries2[i].a_perm); + return 1; + } + } + free (entries2); + free (entries1); + } +#endif + } + + return 0; +} diff --git a/gnulib-tests/test-sched.c b/gnulib-tests/test-sched.c new file mode 100644 index 0000000..7fa4b66 --- /dev/null +++ b/gnulib-tests/test-sched.c @@ -0,0 +1,41 @@ +/* Test of <sched.h> substitute. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2008. */ + +#include <config.h> + +#include <sched.h> + +/* Check that 'struct sched_param' is defined. */ +static struct sched_param a; + +/* Check that the SCHED_* macros are defined and compile-time constants. */ +int b[] = { SCHED_FIFO, SCHED_RR, SCHED_OTHER }; + +/* Check that the types are all defined. */ +pid_t t1; + +static int f1; + +int +main () +{ + /* Check fields of 'struct sched_param'. */ + f1 = a.sched_priority; + + return 0; +} diff --git a/gnulib-tests/test-select-fd.c b/gnulib-tests/test-select-fd.c new file mode 100644 index 0000000..02f10c4 --- /dev/null +++ b/gnulib-tests/test-select-fd.c @@ -0,0 +1,72 @@ +/* Test of select() substitute, reading or writing from a given file descriptor. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2008. */ + +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <sys/select.h> + +int +main (int argc, char *argv[]) +{ + if (argc == 4) + { + char mode = argv[1][0]; + + if (mode == 'r' || mode == 'w') + { + int fd = atoi (argv[2]); + + if (fd >= 0) + { + const char *result_file_name = argv[3]; + FILE *result_file = fopen (result_file_name, "wb"); + + if (result_file != NULL) + { + fd_set fds; + struct timeval timeout; + int ret; + + FD_ZERO (&fds); + FD_SET (fd, &fds); + timeout.tv_sec = 0; + timeout.tv_usec = 10000; + ret = (mode == 'r' + ? select (fd + 1, &fds, NULL, NULL, &timeout) + : select (fd + 1, NULL, &fds, NULL, &timeout)); + if (ret < 0) + { + perror ("select failed"); + exit (1); + } + if ((ret == 0) != ! FD_ISSET (fd, &fds)) + { + fprintf (stderr, "incorrect return value\n"); + exit (1); + } + fprintf (result_file, "%d\n", ret); + exit (0); + } + } + } + } + fprintf (stderr, "Usage: test-select-fd mode fd result-file-name\n"); + exit (1); +} diff --git a/gnulib-tests/test-select-in.sh b/gnulib-tests/test-select-in.sh new file mode 100755 index 0000000..68176d3 --- /dev/null +++ b/gnulib-tests/test-select-in.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# Test select() on file descriptors opened for reading. + +# This test is known to fail on Solaris 2.6 and older, due to its handling +# of /dev/null. + +tmpfiles="" +trap 'rm -fr $tmpfiles' 1 2 3 15 + +tmpfiles="$tmpfiles t-select-in.tmp" + +# Regular files. + +rm -f t-select-in.tmp +${CHECKER} ./test-select-fd${EXEEXT} r 0 t-select-in.tmp < ./test-select-fd${EXEEXT} +test `cat t-select-in.tmp` = "1" || exit 1 + +# Pipes. + +rm -f t-select-in.tmp +{ sleep 1; echo abc; } | \ + { ${CHECKER} ./test-select-fd${EXEEXT} r 0 t-select-in.tmp; cat > /dev/null; } +test `cat t-select-in.tmp` = "0" || exit 1 + +rm -f t-select-in.tmp +echo abc | { sleep 1; ${CHECKER} ./test-select-fd${EXEEXT} r 0 t-select-in.tmp; } +test `cat t-select-in.tmp` = "1" || exit 1 + +# Special files. +# This part of the test is known to fail on Solaris 2.6 and older. + +rm -f t-select-in.tmp +${CHECKER} ./test-select-fd${EXEEXT} r 0 t-select-in.tmp < /dev/null +test `cat t-select-in.tmp` = "1" || exit 1 + +rm -fr $tmpfiles + +exit 0 diff --git a/gnulib-tests/test-select-out.sh b/gnulib-tests/test-select-out.sh new file mode 100755 index 0000000..dbeace5 --- /dev/null +++ b/gnulib-tests/test-select-out.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# Test select() on file descriptors opened for writing. + +tmpfiles="" +trap 'rm -fr $tmpfiles' 1 2 3 15 + +tmpfiles="$tmpfiles t-select-out.out t-select-out.tmp" + +# Regular files. + +rm -f t-select-out.tmp +${CHECKER} ./test-select-fd${EXEEXT} w 1 t-select-out.tmp > t-select-out.out +test `cat t-select-out.tmp` = "1" || exit 1 + +# Pipes. + +if false; then # This test fails on some platforms. + rm -f t-select-out.tmp + ( { echo abc; ${CHECKER} ./test-select-fd${EXEEXT} w 1 t-select-out.tmp; } | { sleep 1; cat; } ) > /dev/null + test `cat t-select-out.tmp` = "0" || exit 1 +fi + +rm -f t-select-out.tmp +( { sleep 1; echo abc; ${CHECKER} ./test-select-fd${EXEEXT} w 1 t-select-out.tmp; } | cat) > /dev/null +test `cat t-select-out.tmp` = "1" || exit 1 + +# Special files. + +rm -f t-select-out.tmp +${CHECKER} ./test-select-fd${EXEEXT} w 1 t-select-out.tmp > /dev/null +test `cat t-select-out.tmp` = "1" || exit 1 + +rm -fr $tmpfiles + +exit 0 diff --git a/gnulib-tests/test-select-stdin.c b/gnulib-tests/test-select-stdin.c new file mode 100644 index 0000000..aadba6e --- /dev/null +++ b/gnulib-tests/test-select-stdin.c @@ -0,0 +1,83 @@ +/* Test of select() substitute, reading from stdin. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2008. */ + +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <sys/select.h> +#include <sys/time.h> +#include <unistd.h> + +#include "macros.h" + +int +main (void) +{ + printf ("Applying select() from standard input. Press Ctrl-C to abort.\n"); + for (;;) + { + struct timeval before; + struct timeval after; + unsigned long spent_usec; + fd_set readfds; + struct timeval timeout; + int ret; + + gettimeofday (&before, NULL); + + FD_ZERO (&readfds); + FD_SET (0, &readfds); + timeout.tv_sec = 0; + timeout.tv_usec = 500000; + ret = select (1, &readfds, NULL, NULL, &timeout); + + gettimeofday (&after, NULL); + spent_usec = (after.tv_sec - before.tv_sec) * 1000000 + + after.tv_usec - before.tv_usec; + + if (ret < 0) + { + perror ("select failed"); + exit (1); + } + if ((ret == 0) != ! FD_ISSET (0, &readfds)) + { + fprintf (stderr, "incorrect return value\n"); + exit (1); + } + if (ret == 0) + { + if (spent_usec < 250000) + { + fprintf (stderr, "returned too early\n"); + exit (1); + } + /* Timeout */ + printf ("."); + ASSERT (fflush (stdout) == 0); + } + else + { + char c; + + printf ("Input available! Trying to read 1 byte...\n"); + ASSERT (read (0, &c, 1) == 1); + } + } +} diff --git a/gnulib-tests/test-select.c b/gnulib-tests/test-select.c new file mode 100644 index 0000000..55ad7bc --- /dev/null +++ b/gnulib-tests/test-select.c @@ -0,0 +1,34 @@ +/* Test of select() substitute. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Paolo Bonzini, 2008. */ + +#include <config.h> + +#include <sys/select.h> + +#include "signature.h" + +SIGNATURE_CHECK (select, int, (int, fd_set *, fd_set *, fd_set *, + struct timeval *)); + +#include "test-select.h" + +int +main (void) +{ + return test_function (select); +} diff --git a/gnulib-tests/test-select.h b/gnulib-tests/test-select.h new file mode 100644 index 0000000..45d0325 --- /dev/null +++ b/gnulib-tests/test-select.h @@ -0,0 +1,466 @@ +/* Test of select() substitute. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Paolo Bonzini, 2008. */ + +#include <stdio.h> +#include <string.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <unistd.h> +#include <fcntl.h> +#include <stdlib.h> +#include <stdbool.h> +#include <sys/ioctl.h> +#include <errno.h> + +#include "macros.h" + +#if defined _WIN32 && ! defined __CYGWIN__ +# define WINDOWS_NATIVE +#endif + +#ifdef HAVE_SYS_WAIT_H +# include <sys/wait.h> +#endif + +#define TEST_PORT 12345 + + +typedef int (*select_fn) (int, fd_set *, fd_set *, fd_set *, struct timeval *); + + +/* Minimal testing infrastructure. */ + +static int failures; + +static void +failed (const char *reason) +{ + if (++failures > 1) + printf (" "); + printf ("failed (%s)\n", reason); +} + +static int +test (void (*fn) (select_fn), select_fn my_select, const char *msg) +{ + failures = 0; + printf ("%s... ", msg); + fflush (stdout); + fn (my_select); + + if (!failures) + printf ("passed\n"); + + return failures; +} + + +/* Funny socket code. */ + +static int +open_server_socket (void) +{ + int s, x; + struct sockaddr_in ia; + + s = socket (AF_INET, SOCK_STREAM, 0); + + x = 1; + setsockopt (s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof (x)); + + memset (&ia, 0, sizeof (ia)); + ia.sin_family = AF_INET; + inet_pton (AF_INET, "127.0.0.1", &ia.sin_addr); + ia.sin_port = htons (TEST_PORT); + if (bind (s, (struct sockaddr *) &ia, sizeof (ia)) < 0) + { + perror ("bind"); + exit (77); + } + + if (listen (s, 1) < 0) + { + perror ("listen"); + exit (77); + } + + return s; +} + +static int +connect_to_socket (bool blocking) +{ + int s; + struct sockaddr_in ia; + + s = socket (AF_INET, SOCK_STREAM, 0); + + memset (&ia, 0, sizeof (ia)); + ia.sin_family = AF_INET; + inet_pton (AF_INET, "127.0.0.1", &ia.sin_addr); + ia.sin_port = htons (TEST_PORT); + + if (!blocking) + { +#ifdef WINDOWS_NATIVE + unsigned long iMode = 1; + ioctl (s, FIONBIO, (char *) &iMode); + +#elif defined F_GETFL + int oldflags = fcntl (s, F_GETFL, NULL); + + if (!(oldflags & O_NONBLOCK)) + fcntl (s, F_SETFL, oldflags | O_NONBLOCK); +#endif + } + + if (connect (s, (struct sockaddr *) &ia, sizeof (ia)) < 0 + && (blocking || errno != EINPROGRESS)) + { + perror ("connect"); + exit (77); + } + + return s; +} + + +/* A slightly more convenient interface to select(2). + Waits until a specific event occurs on a file descriptor FD. + EV is a bit mask of events to look for: + SEL_IN - input can be polled without blocking, + SEL_OUT - output can be provided without blocking, + SEL_EXC - an exception occurred, + A maximum wait time is specified by TIMEOUT. + *TIMEOUT = { 0, 0 } means to return immediately, + TIMEOUT = NULL means to wait indefinitely. */ + +enum { SEL_IN = 1, SEL_OUT = 2, SEL_EXC = 4 }; + +static int +do_select (int fd, int ev, struct timeval *timeout, select_fn my_select) +{ + fd_set rfds, wfds, xfds; + int r, rev; + + FD_ZERO (&rfds); + FD_ZERO (&wfds); + FD_ZERO (&xfds); + if (ev & SEL_IN) + FD_SET (fd, &rfds); + if (ev & SEL_OUT) + FD_SET (fd, &wfds); + if (ev & SEL_EXC) + FD_SET (fd, &xfds); + r = my_select (fd + 1, &rfds, &wfds, &xfds, timeout); + if (r < 0) + return r; + + rev = 0; + if (FD_ISSET (fd, &rfds)) + rev |= SEL_IN; + if (FD_ISSET (fd, &wfds)) + rev |= SEL_OUT; + if (FD_ISSET (fd, &xfds)) + rev |= SEL_EXC; + if (rev && r == 0) + failed ("select returned 0"); + if (rev & ~ev) + failed ("select returned unrequested events"); + + return rev; +} + +static int +do_select_nowait (int fd, int ev, select_fn my_select) +{ + struct timeval tv0; + tv0.tv_sec = 0; + tv0.tv_usec = 0; + return do_select (fd, ev, &tv0, my_select); +} + +static int +do_select_wait (int fd, int ev, select_fn my_select) +{ + return do_select (fd, ev, NULL, my_select); +} + + +/* Test select(2) for TTYs. */ + +#ifdef INTERACTIVE +static void +test_tty (select_fn my_select) +{ + if (do_select_nowait (0, SEL_IN, my_select) != 0) + failed ("can read"); + if (do_select_nowait (0, SEL_OUT, my_select) == 0) + failed ("cannot write"); + + if (do_select_wait (0, SEL_IN, my_select) == 0) + failed ("return with infinite timeout"); + + getchar (); + if (do_select_nowait (0, SEL_IN, my_select) != 0) + failed ("can read after getc"); +} +#endif + + +static int +do_select_bad_nfd_nowait (int nfd, select_fn my_select) +{ + struct timeval tv0; + tv0.tv_sec = 0; + tv0.tv_usec = 0; + errno = 0; + return my_select (nfd, NULL, NULL, NULL, &tv0); +} + +static void +test_bad_nfd (select_fn my_select) +{ + if (do_select_bad_nfd_nowait (-1, my_select) != -1 || errno != EINVAL) + failed ("invalid errno after negative nfds"); + /* Can't test FD_SETSIZE + 1 for EINVAL, since some systems allow + dynamically larger set size by redefining FD_SETSIZE anywhere up + to the actual maximum fd. */ +#if 0 + if (do_select_bad_nfd_nowait (FD_SETSIZE + 1, my_select) != -1 + || errno != EINVAL) + failed ("invalid errno after bogus nfds"); +#endif +} + +/* Test select(2) on invalid file descriptors. */ + +static int +do_select_bad_fd (int fd, int ev, struct timeval *timeout, select_fn my_select) +{ + fd_set rfds, wfds, xfds; + + FD_ZERO (&rfds); + FD_ZERO (&wfds); + FD_ZERO (&xfds); + if (ev & SEL_IN) + FD_SET (fd, &rfds); + if (ev & SEL_OUT) + FD_SET (fd, &wfds); + if (ev & SEL_EXC) + FD_SET (fd, &xfds); + errno = 0; + return my_select (fd + 1, &rfds, &wfds, &xfds, timeout); + /* In this case, when fd is invalid, on some platforms, the bit for fd + is left alone in the fd_set, whereas on other platforms it is cleared. + So, don't check the bit for fd here. */ +} + +static int +do_select_bad_fd_nowait (int fd, int ev, select_fn my_select) +{ + struct timeval tv0; + tv0.tv_sec = 0; + tv0.tv_usec = 0; + return do_select_bad_fd (fd, ev, &tv0, my_select); +} + +static void +test_bad_fd (select_fn my_select) +{ + /* This tests fails on OSF/1 and native Windows, even with fd = 16. */ +#if !(defined __osf__ || defined WINDOWS_NATIVE) + int fd; + + /* On Linux, Mac OS X, *BSD, values of fd like 99 or 399 are discarded + by the kernel early and therefore do *not* lead to EBADF, as required + by POSIX. */ +# if defined __linux__ || (defined __APPLE__ && defined __MACH__) || (defined __FreeBSD__ || defined __DragonFly__) || defined __OpenBSD__ || defined __NetBSD__ + fd = 14; +# else + fd = 99; +# endif + /* Even on the best POSIX compliant platforms, values of fd >= FD_SETSIZE + require an nfds argument that is > FD_SETSIZE and thus may lead to EINVAL, + not EBADF. */ + if (fd >= FD_SETSIZE) + fd = FD_SETSIZE - 1; + close (fd); + + if (do_select_bad_fd_nowait (fd, SEL_IN, my_select) == 0 || errno != EBADF) + failed ("invalid fd among rfds"); + if (do_select_bad_fd_nowait (fd, SEL_OUT, my_select) == 0 || errno != EBADF) + failed ("invalid fd among wfds"); + if (do_select_bad_fd_nowait (fd, SEL_EXC, my_select) == 0 || errno != EBADF) + failed ("invalid fd among xfds"); +#endif +} + + +/* Test select(2) for unconnected nonblocking sockets. */ + +static void +test_connect_first (select_fn my_select) +{ + int s = open_server_socket (); + struct sockaddr_in ia; + socklen_t addrlen; + + int c1, c2; + + if (do_select_nowait (s, SEL_IN | SEL_EXC, my_select) != 0) + failed ("can read, socket not connected"); + + c1 = connect_to_socket (false); + + if (do_select_wait (s, SEL_IN | SEL_EXC, my_select) != SEL_IN) + failed ("expecting readability on passive socket"); + if (do_select_nowait (s, SEL_IN | SEL_EXC, my_select) != SEL_IN) + failed ("expecting readability on passive socket"); + + addrlen = sizeof (ia); + c2 = accept (s, (struct sockaddr *) &ia, &addrlen); + ASSERT (close (s) == 0); + ASSERT (close (c1) == 0); + ASSERT (close (c2) == 0); +} + + +/* Test select(2) for unconnected blocking sockets. */ + +static void +test_accept_first (select_fn my_select) +{ +#ifndef WINDOWS_NATIVE + int s = open_server_socket (); + struct sockaddr_in ia; + socklen_t addrlen; + char buf[3]; + int c, pid; + + pid = fork (); + if (pid < 0) + return; + + if (pid == 0) + { + addrlen = sizeof (ia); + c = accept (s, (struct sockaddr *) &ia, &addrlen); + ASSERT (close (s) == 0); + ASSERT (write (c, "foo", 3) == 3); + ASSERT (read (c, buf, 3) == 3); + shutdown (c, SHUT_RD); + ASSERT (close (c) == 0); + exit (0); + } + else + { + ASSERT (close (s) == 0); + c = connect_to_socket (true); + if (do_select_nowait (c, SEL_OUT, my_select) != SEL_OUT) + failed ("cannot write after blocking connect"); + ASSERT (write (c, "foo", 3) == 3); + wait (&pid); + if (do_select_wait (c, SEL_IN, my_select) != SEL_IN) + failed ("cannot read data left in the socket by closed process"); + ASSERT (read (c, buf, 3) == 3); + ASSERT (write (c, "foo", 3) == 3); + (void) close (c); /* may fail with errno = ECONNRESET */ + } +#endif +} + + +/* Common code for pipes and connected sockets. */ + +static void +test_pair (int rd, int wd, select_fn my_select) +{ + char buf[3]; + if (do_select_wait (wd, SEL_IN | SEL_OUT | SEL_EXC, my_select) != SEL_OUT) + failed ("expecting writability before writing"); + if (do_select_nowait (wd, SEL_IN | SEL_OUT | SEL_EXC, my_select) != SEL_OUT) + failed ("expecting writability before writing"); + + ASSERT (write (wd, "foo", 3) == 3); + if (do_select_wait (rd, SEL_IN, my_select) != SEL_IN) + failed ("expecting readability after writing"); + if (do_select_nowait (rd, SEL_IN, my_select) != SEL_IN) + failed ("expecting readability after writing"); + + ASSERT (read (rd, buf, 3) == 3); +} + + +/* Test select(2) on connected sockets. */ + +static void +test_socket_pair (select_fn my_select) +{ + struct sockaddr_in ia; + + socklen_t addrlen = sizeof (ia); + int s = open_server_socket (); + int c1 = connect_to_socket (false); + int c2 = accept (s, (struct sockaddr *) &ia, &addrlen); + + ASSERT (close (s) == 0); + + test_pair (c1, c2, my_select); + ASSERT (close (c1) == 0); + ASSERT (write (c2, "foo", 3) == 3); + (void) close (c2); /* may fail with errno = ECONNRESET */ +} + + +/* Test select(2) on pipes. */ + +static void +test_pipe (select_fn my_select) +{ + int fd[2]; + + ASSERT (pipe (fd) == 0); + test_pair (fd[0], fd[1], my_select); + ASSERT (close (fd[0]) == 0); + ASSERT (close (fd[1]) == 0); +} + + +/* Do them all. */ + +static int +test_function (select_fn my_select) +{ + int result = 0; + +#ifdef INTERACTIVE + printf ("Please press Enter\n"); + test (test_tty, "TTY", my_select); +#endif + + result += test (test_bad_nfd, my_select, "Invalid nfd test"); + result += test (test_bad_fd, my_select, "Invalid fd test"); + result += test (test_connect_first, my_select, "Unconnected socket test"); + result += test (test_socket_pair, my_select, "Connected sockets test"); + result += test (test_accept_first, my_select, "General socket test with fork"); + result += test (test_pipe, my_select, "Pipe test"); + + return result; +} diff --git a/gnulib-tests/test-set-mode-acl-1.sh b/gnulib-tests/test-set-mode-acl-1.sh new file mode 100755 index 0000000..73a4010 --- /dev/null +++ b/gnulib-tests/test-set-mode-acl-1.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +# Test set-mode-acl on the file system of /var/tmp, which usually is a local +# file system. + +. "${srcdir=.}/init.sh"; path_prepend_ . + +if test -d /var/tmp; then + TMPDIR=/var/tmp +else + TMPDIR=/tmp +fi +test -d $TMPDIR || Exit 77 +export TMPDIR + +$BOURNE_SHELL "${srcdir}/test-set-mode-acl.sh" + +Exit $? diff --git a/gnulib-tests/test-set-mode-acl-2.sh b/gnulib-tests/test-set-mode-acl-2.sh new file mode 100755 index 0000000..2f7c8c0 --- /dev/null +++ b/gnulib-tests/test-set-mode-acl-2.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# Test set-mode-acl on the file system of the build directory, which may be +# a local file system or NFS mounted. + +. "${srcdir=.}/init.sh"; path_prepend_ . + +TMPDIR=`pwd` +export TMPDIR + +$BOURNE_SHELL "${srcdir}/test-set-mode-acl.sh" + +Exit $? diff --git a/gnulib-tests/test-set-mode-acl.c b/gnulib-tests/test-set-mode-acl.c new file mode 100644 index 0000000..638eda7 --- /dev/null +++ b/gnulib-tests/test-set-mode-acl.c @@ -0,0 +1,41 @@ +/* Test of setting an ACL equivalent to a mode. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2008. */ + +#include <config.h> + +#include "acl.h" + +#include <stdlib.h> + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + const char *file; + int mode; + + ASSERT (argc == 3); + + file = argv[1]; + mode = strtol (argv[2], NULL, 8); + + set_acl (file, -1, mode); + + return 0; +} diff --git a/gnulib-tests/test-set-mode-acl.sh b/gnulib-tests/test-set-mode-acl.sh new file mode 100755 index 0000000..fdcd64b --- /dev/null +++ b/gnulib-tests/test-set-mode-acl.sh @@ -0,0 +1,234 @@ +#!/bin/sh + +# Show all commands when run with environment variable VERBOSE=yes. +test -z "$VERBOSE" || set -x + +test "$USE_ACL" = 0 && + { + echo "Skipping test: insufficient ACL support" + exit 77 + } + +# func_tmpdir +# creates a temporary directory. +# Sets variable +# - tmp pathname of freshly created temporary directory +func_tmpdir () +{ + # Use the environment variable TMPDIR, falling back to /tmp. This allows + # users to specify a different temporary directory, for example, if their + # /tmp is filled up or too small. + : ${TMPDIR=/tmp} + { + # Use the mktemp program if available. If not available, hide the error + # message. + tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" + } || + { + # Use a simple mkdir command. It is guaranteed to fail if the directory + # already exists. $RANDOM is bash specific and expands to empty in shells + # other than bash, ksh and zsh. Its use does not increase security; + # rather, it minimizes the probability of failure in a very cluttered /tmp + # directory. + tmp=$TMPDIR/gl$$-$RANDOM + (umask 077 && mkdir "$tmp") + } || + { + echo "$0: cannot create a temporary directory in $TMPDIR" >&2 + exit 1 + } +} + +func_tmpdir +# builddir may already be set by the script that invokes this one. +case "$builddir" in + '') builddir=`pwd` ;; + /* | ?:*) ;; + *) builddir=`pwd`/$builddir ;; +esac +cd "$builddir" || + { + echo "$0: cannot determine build directory (unreadable parent dir?)" >&2 + exit 1 + } +# Switch to a temporary directory, to increase the likelihood that ACLs are +# supported on the current file system. (/tmp is usually locally mounted, +# whereas the build dir is sometimes NFS-mounted.) +( cd "$tmp" + + # Prepare tmpfile0. + rm -f tmpfile[0-9] + echo "Simple contents" > tmpfile0 + chmod 600 tmpfile0 + + # Classification of the platform according to the programs available for + # manipulating ACLs. + # Possible values are: + # linux, cygwin, freebsd, solaris, hpux, hpuxjfs, osf1, aix, macosx, irix, none. + # TODO: Support also native Windows platforms (mingw). + acl_flavor=none + if (getfacl tmpfile0 >/dev/null) 2>/dev/null; then + # Platforms with the getfacl and setfacl programs. + # Linux, FreeBSD, Solaris, Cygwin. + if (setfacl --help >/dev/null) 2>/dev/null; then + # Linux, Cygwin. + if (LC_ALL=C setfacl --help | grep ' --set-file' >/dev/null) 2>/dev/null; then + # Linux. + acl_flavor=linux + else + acl_flavor=cygwin + fi + else + # FreeBSD, Solaris. + if (LC_ALL=C setfacl 2>&1 | grep '\-x entries' >/dev/null) 2>/dev/null; then + # FreeBSD. + acl_flavor=freebsd + else + # Solaris. + acl_flavor=solaris + fi + fi + else + if (lsacl / >/dev/null) 2>/dev/null; then + # Platforms with the lsacl and chacl programs. + # HP-UX, sometimes also IRIX. + if (getacl tmpfile0 >/dev/null) 2>/dev/null; then + # HP-UX 11.11 or newer. + acl_flavor=hpuxjfs + else + # HP-UX 11.00. + acl_flavor=hpux + fi + else + if (getacl tmpfile0 >/dev/null) 2>/dev/null; then + # Tru64, NonStop Kernel. + if (getacl -m tmpfile0 >/dev/null) 2>/dev/null; then + # Tru64. + acl_flavor=osf1 + else + # NonStop Kernel. + acl_flavor=nsk + fi + else + if (aclget tmpfile0 >/dev/null) 2>/dev/null; then + # AIX. + acl_flavor=aix + else + if (fsaclctl -v >/dev/null) 2>/dev/null; then + # Mac OS X. + acl_flavor=macosx + else + if test -f /sbin/chacl; then + # IRIX. + acl_flavor=irix + fi + fi + fi + fi + fi + fi + + if test $acl_flavor != none; then + # A POSIX compliant 'id' program. + if test -f /usr/xpg4/bin/id; then + ID=/usr/xpg4/bin/id + else + ID=id + fi + # Use a user and group id different from the current one, to avoid + # redundant/ambiguous ACLs. + myuid=`$ID -u` + mygid=`$ID -g` + auid=1 + if test "$auid" = "$myuid"; then auid=2; fi + agid=1 + if test "$agid" = "$mygid"; then agid=2; fi + fi + + for mode in 700 400 200 100 644 650 605 011 4700 2070; do + rm -f tmpfile0 tmpfile1 tmpfile2 + + # Prepare a file with no ACL. + echo "Anything" > tmpfile0 + # If a mode is not supported (e.g. 2070 on FreeBSD), we skip testing it. + if chmod $mode tmpfile0 2>/dev/null; then + modestring0=`ls -l tmpfile0 | dd ibs=1 count=10 2>/dev/null` + + # Prepare a file with no ACL. + echo "Some contents" > tmpfile1 + chmod 600 tmpfile1 + + # Try to set the ACL to only the given mode. + ${CHECKER} "$builddir"/test-set-mode-acl${EXEEXT} tmpfile1 $mode + # Verify that tmpfile1 has no ACL and has the desired mode. + modestring=`ls -l tmpfile1 | dd ibs=1 count=10 2>/dev/null` + if test "x$modestring" != "x$modestring0"; then + echo "mode = $mode: tmpfile1 has wrong mode: $modestring" 1>&2 + exit 1 + fi + if test `${CHECKER} "$builddir"/test-file-has-acl${EXEEXT} tmpfile1` != no; then + echo "mode = $mode: tmpfile1 got an ACL" 1>&2 + exit 1 + fi + + if test $acl_flavor != none; then + + # Prepare a file with an ACL. + echo "Special contents" > tmpfile2 + chmod 600 tmpfile2 + # Set an ACL for a user (or group). + case $acl_flavor in + linux | freebsd | solaris) + setfacl -m user:$auid:1 tmpfile0 + ;; + cygwin) + setfacl -m group:0:1 tmpfile0 + ;; + hpux) + orig=`lsacl tmpfile0 | sed -e 's/ tmpfile0$//'` + chacl -r "${orig}($auid.%,--x)" tmpfile0 + ;; + hpuxjfs) + orig=`lsacl tmpfile0 | sed -e 's/ tmpfile0$//'` + chacl -r "${orig}($auid.%,--x)" tmpfile0 \ + || setacl -m user:$auid:1 tmpfile0 + ;; + osf1) + setacl -u user:$auid:1 tmpfile0 + ;; + nsk) + setacl -m user:$auid:1 tmpfile0 + ;; + aix) + { aclget tmpfile0 | sed -e 's/disabled$/enabled/'; echo " permit --x u:$auid"; } | aclput tmpfile0 + ;; + macosx) + /bin/chmod +a "user:daemon allow execute" tmpfile0 + ;; + irix) + /sbin/chacl user::rw-,group::---,other::---,user:$auid:--x tmpfile0 + ;; + esac + + # Try to set the ACL to only the given mode. + ${CHECKER} "$builddir"/test-set-mode-acl${EXEEXT} tmpfile2 $mode + # Verify that tmpfile2 has no ACL and has the desired mode. + modestring=`ls -l tmpfile2 | dd ibs=1 count=10 2>/dev/null` + if test "x$modestring" != "x$modestring0"; then + echo "mode = $mode: tmpfile2 has wrong mode: $modestring" 1>&2 + exit 1 + fi + if test `${CHECKER} "$builddir"/test-file-has-acl${EXEEXT} tmpfile2` != no; then + echo "mode = $mode: tmpfile2 still has an ACL" 1>&2 + exit 1 + fi + fi + fi + done + + rm -f tmpfile[0-9] +) || exit 1 + +rm -rf "$tmp" +exit 0 diff --git a/gnulib-tests/test-setenv.c b/gnulib-tests/test-setenv.c new file mode 100644 index 0000000..2114d9e --- /dev/null +++ b/gnulib-tests/test-setenv.c @@ -0,0 +1,56 @@ +/* Tests of setenv. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <stdlib.h> + +#include "signature.h" +SIGNATURE_CHECK (setenv, int, (char const *, char const *, int)); + +#include <errno.h> +#include <string.h> +#include <unistd.h> + +#include "macros.h" + +int +main (void) +{ + /* Test overwriting. */ + ASSERT (setenv ("a", "==", -1) == 0); + ASSERT (setenv ("a", "2", 0) == 0); + ASSERT (strcmp (getenv ("a"), "==") == 0); + + /* Required to fail with EINVAL. */ + errno = 0; + ASSERT (setenv ("", "", 1) == -1); + ASSERT (errno == EINVAL); + errno = 0; + ASSERT (setenv ("a=b", "", 0) == -1); + ASSERT (errno == EINVAL); +#if 0 + /* glibc and gnulib's implementation guarantee this, but POSIX no + longer requires it: http://austingroupbugs.net/view.php?id=185 */ + errno = 0; + ASSERT (setenv (NULL, "", 0) == -1); + ASSERT (errno == EINVAL); +#endif + + return 0; +} diff --git a/gnulib-tests/test-setlocale1.c b/gnulib-tests/test-setlocale1.c new file mode 100644 index 0000000..1dd41e3 --- /dev/null +++ b/gnulib-tests/test-setlocale1.c @@ -0,0 +1,61 @@ +/* Test of setting the current locale. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <locale.h> + +#include "signature.h" +SIGNATURE_CHECK (setlocale, char *, (int, const char *)); + +#include <stdlib.h> +#include <string.h> + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + char *name1; + char *name2; + + /* Try to set the locale by implicitly looking at the LC_ALL environment + variable. + configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + name1 = strdup (setlocale (LC_ALL, NULL)); + + /* Reset the locale. */ + if (setlocale (LC_ALL, "C") == NULL) + return 1; + + /* Try to set the locale by explicitly looking at the LC_ALL environment + variable. + configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL) + return 1; + + name2 = strdup (setlocale (LC_ALL, NULL)); + + /* Test that the two results are the same. */ + ASSERT (strcmp (name1, name2) == 0); + free (name1); + free (name2); + + return 0; +} diff --git a/gnulib-tests/test-setlocale1.sh b/gnulib-tests/test-setlocale1.sh new file mode 100755 index 0000000..53ad09f --- /dev/null +++ b/gnulib-tests/test-setlocale1.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +: ${LOCALE_FR=fr_FR} +: ${LOCALE_FR_UTF8=fr_FR.UTF-8} +: ${LOCALE_JA=ja_JP} +: ${LOCALE_ZH_CN=zh_CN.GB18030} + +if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none \ + && test $LOCALE_JA = none && test $LOCALE_ZH_CN = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no locale for testing is installed" + else + echo "Skipping test: no locale for testing is supported" + fi + exit 77 +fi + +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR ${CHECKER} ./test-setlocale1${EXEEXT} || exit 1 +fi + +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 ${CHECKER} ./test-setlocale1${EXEEXT} || exit 1 +fi + +if test $LOCALE_JA != none; then + LC_ALL=$LOCALE_JA ${CHECKER} ./test-setlocale1${EXEEXT} || exit 1 +fi + +if test $LOCALE_ZH_CN != none; then + LC_ALL=$LOCALE_ZH_CN ${CHECKER} ./test-setlocale1${EXEEXT} || exit 1 +fi + +exit 0 diff --git a/gnulib-tests/test-setlocale2.c b/gnulib-tests/test-setlocale2.c new file mode 100644 index 0000000..d634689 --- /dev/null +++ b/gnulib-tests/test-setlocale2.c @@ -0,0 +1,55 @@ +/* Test of setting the current locale. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <locale.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +int +main () +{ + /* Try to set the locale by implicitly looking at the LC_ALL environment + variable. */ + if (setlocale (LC_ALL, "") != NULL) + /* It was successful. Check whether LC_CTYPE is non-trivial. */ + if (strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) + { + fprintf (stderr, "setlocale did not fail for implicit %s\n", + getenv ("LC_ALL")); + return 1; + } + + /* Reset the locale. */ + if (setlocale (LC_ALL, "C") == NULL) + return 1; + + /* Try to set the locale by explicitly looking at the LC_ALL environment + variable. */ + if (setlocale (LC_ALL, getenv ("LC_ALL")) != NULL) + /* It was successful. Check whether LC_CTYPE is non-trivial. */ + if (strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) + { + fprintf (stderr, "setlocale did not fail for explicit %s\n", + getenv ("LC_ALL")); + return 1; + } + + return 0; +} diff --git a/gnulib-tests/test-setlocale2.sh b/gnulib-tests/test-setlocale2.sh new file mode 100755 index 0000000..79ea32f --- /dev/null +++ b/gnulib-tests/test-setlocale2.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +# Test locale names with likely unsupported encoding in Unix syntax. +for name in ar_SA.ISO-8859-1 fr_FR.CP1251 zh_TW.GB18030 zh_CN.BIG5; do + env LC_ALL=$name ${CHECKER} ./test-setlocale2${EXEEXT} 1 || exit 1 +done + +# Test locale names with likely unsupported encoding in native Windows syntax. +for name in "Arabic_Saudi Arabia.1252" "Arabic_Saudi Arabia.65001" \ + French_France.65001 Japanese_Japan.65001 Turkish_Turkey.65001 \ + Chinese_Taiwan.65001 Chinese_China.54936 Chinese_China.65001; do + # Here we use 'env' to set the LC_ALL environment variable, because on + # Solaris 11.0, the /bin/sh refuses to do it for Turkish_Turkey.65001. + env LC_ALL="$name" ${CHECKER} ./test-setlocale2${EXEEXT} 1 || exit 1 +done + +exit 0 diff --git a/gnulib-tests/test-setlocale_null-mt-all.c b/gnulib-tests/test-setlocale_null-mt-all.c new file mode 100644 index 0000000..19bdb55 --- /dev/null +++ b/gnulib-tests/test-setlocale_null-mt-all.c @@ -0,0 +1,169 @@ +/* Multithread-safety test for setlocale_null_r (LC_ALL, ...). + Copyright (C) 2019-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2019. */ + +#include <config.h> + +#if USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS || USE_WINDOWS_THREADS + +/* Specification. */ +#include <locale.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +#include "glthread/thread.h" + +/* We want to use the system's setlocale() function here, not the gnulib + override. */ +#undef setlocale + + +/* Some common locale names. */ + +#if defined _WIN32 && !defined __CYGWIN__ +# define ENGLISH "English_United States" +# define GERMAN "German_Germany" +# define FRENCH "French_France" +# define ENCODING ".1252" +#else +# define ENGLISH "en_US" +# define GERMAN "de_DE" +# define FRENCH "fr_FR" +# if defined __sgi +# define ENCODING ".ISO8859-15" +# elif defined __hpux +# define ENCODING ".utf8" +# else +# define ENCODING ".UTF-8" +# endif +#endif + +static const char LOCALE1[] = ENGLISH ENCODING; +static const char LOCALE2[] = GERMAN ENCODING; +static const char LOCALE3[] = FRENCH ENCODING; + +static char *expected; + +static void * +thread1_func (void *arg) +{ + for (;;) + { + char buf[SETLOCALE_NULL_ALL_MAX]; + + if (setlocale_null_r (LC_ALL, buf, sizeof (buf))) + abort (); + if (strcmp (expected, buf) != 0) + { + fprintf (stderr, "thread1 disturbed by thread2!\n"); fflush (stderr); + abort (); + } + } + + /*NOTREACHED*/ + return NULL; +} + +static void * +thread2_func (void *arg) +{ + for (;;) + { + char buf[SETLOCALE_NULL_ALL_MAX]; + + setlocale_null_r (LC_NUMERIC, buf, sizeof (buf)); + setlocale_null_r (LC_ALL, buf, sizeof (buf)); + } + + /*NOTREACHED*/ + return NULL; +} + +int +main (int argc, char *argv[]) +{ + if (setlocale (LC_ALL, LOCALE1) == NULL) + { + fprintf (stderr, "Skipping test: LOCALE1 not recognized\n"); + return 77; + } + if (setlocale (LC_NUMERIC, LOCALE2) == NULL) + { + fprintf (stderr, "Skipping test: LOCALE2 not recognized\n"); + return 77; + } + if (setlocale (LC_TIME, LOCALE3) == NULL) + { + fprintf (stderr, "Skipping test: LOCALE3 not recognized\n"); + return 77; + } + + expected = strdup (setlocale (LC_ALL, NULL)); + + /* Create the two threads. */ + gl_thread_create (thread1_func, NULL); + gl_thread_create (thread2_func, NULL); + + /* Let them run for 5 seconds. */ + { + struct timespec duration; + duration.tv_sec = 5; + duration.tv_nsec = 0; + + nanosleep (&duration, NULL); + } + + return 0; +} + +#else + +/* No multithreading available. */ + +#include <stdio.h> + +int +main () +{ + fputs ("Skipping test: multithreading not enabled\n", stderr); + return 77; +} + +#endif + +/* Without locking, the results of this test would be: +glibc OK +musl libc crash < 10 sec +macOS crash < 1 sec +FreeBSD crash < 1 sec +NetBSD crash < 2 sec +OpenBSD crash < 1 sec +AIX crash < 2 sec +HP-UX OK +IRIX OK +Solaris 10 OK +Solaris 11.0 OK +Solaris 11.4 OK +Solaris OpenIndiana OK +Haiku crash < 1 sec +Cygwin crash < 1 sec +mingw OK +MSVC OK (assuming compiler option /MD !) +*/ diff --git a/gnulib-tests/test-setlocale_null-mt-one.c b/gnulib-tests/test-setlocale_null-mt-one.c new file mode 100644 index 0000000..fd6083a --- /dev/null +++ b/gnulib-tests/test-setlocale_null-mt-one.c @@ -0,0 +1,169 @@ +/* Multithread-safety test for setlocale_null_r (LC_xxx, ...). + Copyright (C) 2019-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2019. */ + +#include <config.h> + +#if USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS || USE_WINDOWS_THREADS + +/* Specification. */ +#include <locale.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +#include "glthread/thread.h" + +/* We want to use the system's setlocale() function here, not the gnulib + override. */ +#undef setlocale + + +/* Some common locale names. */ + +#if defined _WIN32 && !defined __CYGWIN__ +# define ENGLISH "English_United States" +# define GERMAN "German_Germany" +# define FRENCH "French_France" +# define ENCODING ".1252" +#else +# define ENGLISH "en_US" +# define GERMAN "de_DE" +# define FRENCH "fr_FR" +# if defined __sgi +# define ENCODING ".ISO8859-15" +# elif defined __hpux +# define ENCODING ".utf8" +# else +# define ENCODING ".UTF-8" +# endif +#endif + +static const char LOCALE1[] = ENGLISH ENCODING; +static const char LOCALE2[] = GERMAN ENCODING; +static const char LOCALE3[] = FRENCH ENCODING; + +static char *expected; + +static void * +thread1_func (void *arg) +{ + for (;;) + { + char buf[SETLOCALE_NULL_MAX]; + + if (setlocale_null_r (LC_NUMERIC, buf, sizeof (buf))) + abort (); + if (strcmp (expected, buf) != 0) + { + fprintf (stderr, "thread1 disturbed by thread2!\n"); fflush (stderr); + abort (); + } + } + + /*NOTREACHED*/ + return NULL; +} + +static void * +thread2_func (void *arg) +{ + for (;;) + { + char buf[SETLOCALE_NULL_MAX]; + + setlocale_null_r (LC_NUMERIC, buf, sizeof (buf)); + setlocale_null_r (LC_TIME, buf, sizeof (buf)); + } + + /*NOTREACHED*/ + return NULL; +} + +int +main (int argc, char *argv[]) +{ + if (setlocale (LC_ALL, LOCALE1) == NULL) + { + fprintf (stderr, "Skipping test: LOCALE1 not recognized\n"); + return 77; + } + if (setlocale (LC_NUMERIC, LOCALE2) == NULL) + { + fprintf (stderr, "Skipping test: LOCALE2 not recognized\n"); + return 77; + } + if (setlocale (LC_TIME, LOCALE3) == NULL) + { + fprintf (stderr, "Skipping test: LOCALE3 not recognized\n"); + return 77; + } + + expected = strdup (setlocale (LC_NUMERIC, NULL)); + + /* Create the two threads. */ + gl_thread_create (thread1_func, NULL); + gl_thread_create (thread2_func, NULL); + + /* Let them run for 2 seconds. */ + { + struct timespec duration; + duration.tv_sec = 2; + duration.tv_nsec = 0; + + nanosleep (&duration, NULL); + } + + return 0; +} + +#else + +/* No multithreading available. */ + +#include <stdio.h> + +int +main () +{ + fputs ("Skipping test: multithreading not enabled\n", stderr); + return 77; +} + +#endif + +/* Without locking, the results of this test would be: +glibc OK +musl libc OK +macOS OK +FreeBSD OK +NetBSD OK +OpenBSD crash < 1 sec +AIX crash < 2 sec +HP-UX OK +IRIX OK +Solaris 10 OK +Solaris 11.0 OK +Solaris 11.4 OK +Solaris OpenIndiana OK +Haiku OK +Cygwin OK +mingw OK +MSVC OK (assuming compiler option /MD !) +*/ diff --git a/gnulib-tests/test-setlocale_null.c b/gnulib-tests/test-setlocale_null.c new file mode 100644 index 0000000..5a9329e --- /dev/null +++ b/gnulib-tests/test-setlocale_null.c @@ -0,0 +1,32 @@ +/* Test of setlocale_null_r function. + Copyright (C) 2019-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2019. */ + +#include <config.h> + +/* Specification. */ +#include <locale.h> + +/* Check that SETLOCALE_NULL_ALL_MAX is a constant expression. */ +static char buf[SETLOCALE_NULL_ALL_MAX]; + +int +main () +{ + /* Check that setlocale_null_r() can be used with $(LIB_SETLOCALE_NULL). */ + return setlocale_null_r (LC_ALL, buf, sizeof (buf)) != 0; +} diff --git a/gnulib-tests/test-setsockopt.c b/gnulib-tests/test-setsockopt.c new file mode 100644 index 0000000..d2456dd --- /dev/null +++ b/gnulib-tests/test-setsockopt.c @@ -0,0 +1,55 @@ +/* Test setsockopt() function. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <sys/socket.h> + +#include "signature.h" +SIGNATURE_CHECK (setsockopt, int, (int, int, int, const void *, socklen_t)); + +#include <errno.h> +#include <unistd.h> + +#include "sockets.h" +#include "macros.h" + +int +main (void) +{ + (void) gl_sockets_startup (SOCKETS_1_1); + + /* Test behaviour for invalid file descriptors. */ + { + int value = 1; + + errno = 0; + ASSERT (setsockopt (-1, SOL_SOCKET, SO_REUSEADDR, &value, sizeof (value)) + == -1); + ASSERT (errno == EBADF); + } + { + int value = 1; + + close (99); + errno = 0; + ASSERT (setsockopt (99, SOL_SOCKET, SO_REUSEADDR, &value, sizeof (value)) + == -1); + ASSERT (errno == EBADF); + } + + return 0; +} diff --git a/gnulib-tests/test-sha1.c b/gnulib-tests/test-sha1.c new file mode 100644 index 0000000..d729f09 --- /dev/null +++ b/gnulib-tests/test-sha1.c @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2005, 2008-2020 Free Software Foundation, Inc. + * Written by Simon Josefsson + * + * 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include "sha1.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include "macros.h" + +#define TESTFILE "test-sha1.data" +#include "test-digest.h" + +int +main (void) +{ + const char *in1 = "abcdefgh"; + const char *out1 = "\x42\x5a\xf1\x2a\x07\x43\x50\x2b" + "\x32\x2e\x93\xa0\x15\xbc\xf8\x68\xe3\x24\xd5\x6a"; + char buf[SHA1_DIGEST_SIZE]; + + if (memcmp (sha1_buffer (in1, strlen (in1), buf), + out1, SHA1_DIGEST_SIZE) != 0) + { + size_t i; + printf ("expected:\n"); + for (i = 0; i < SHA1_DIGEST_SIZE; i++) + printf ("%02x ", out1[i] & 0xFFu); + printf ("\ncomputed:\n"); + for (i = 0; i < SHA1_DIGEST_SIZE; i++) + printf ("%02x ", buf[i] & 0xFFu); + printf ("\n"); + return 1; + } + + /* Test sha1_stream. */ + test_digest_on_files (sha1_stream, "sha1_stream", 20, + "\xda\x39\xa3\xee\x5e\x6b\x4b\x0d\x32\x55\xbf\xef\x95\x60\x18\x90\xaf\xd8\x07\x09", + "\x9c\x04\xcd\x63\x72\x07\x7e\x9b\x11\xf7\x0c\xa1\x11\xc9\x80\x7d\xc7\x13\x7e\x4b", + "\x91\xab\x6b\x1b\x8d\x29\x25\x3c\xcb\x8d\xce\xb7\x7a\x25\x26\x2c\x92\xc9\x22\x09"); + + return 0; +} diff --git a/gnulib-tests/test-sha256.c b/gnulib-tests/test-sha256.c new file mode 100644 index 0000000..bfe1b44 --- /dev/null +++ b/gnulib-tests/test-sha256.c @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2018-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include "sha256.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include "macros.h" + +#define TESTFILE "test-sha256.data" +#include "test-digest.h" + +int +main (void) +{ + /* Test sha224_stream. */ + test_digest_on_files (sha224_stream, "sha224_stream", 28, + "\xd1\x4a\x02\x8c\x2a\x3a\x2b\xc9\x47\x61\x02\xbb\x28\x82\x34\xc4\x15\xa2\xb0\x1f\x82\x8e\xa6\x2a\xc5\xb3\xe4\x2f", + "\xe8\x87\x99\xb0\xd0\xd5\xbe\xcc\x67\x91\x83\x7f\xa9\x53\x88\xd4\x05\x6f\x12\x50\xa5\x11\xd1\x48\x29\x76\x66\x63", + "\x86\xa2\x5a\xc3\x6a\x70\x8e\xf3\x4e\x78\x55\xf0\xb1\x97\x8a\xa8\x61\x78\x6c\xb8\x87\xcd\x5c\xf1\x19\x3b\x53\xe4"); + + /* Test sha256_stream. */ + test_digest_on_files (sha256_stream, "sha256_stream", 32, + "\xe3\xb0\xc4\x42\x98\xfc\x1c\x14\x9a\xfb\xf4\xc8\x99\x6f\xb9\x24\x27\xae\x41\xe4\x64\x9b\x93\x4c\xa4\x95\x99\x1b\x78\x52\xb8\x55", + "\xb4\x7c\xc0\xf1\x04\xb6\x2d\x4c\x7c\x30\xbc\xd6\x8f\xd8\xe6\x76\x13\xe2\x87\xdc\x4a\xd8\xc3\x10\xef\x10\xcb\xad\xea\x9c\x43\x80", + "\xe5\x19\x95\xff\x0b\xc4\x95\xcf\x49\xdd\x31\x42\x0a\x6b\xe0\x6b\x38\xef\xef\x43\xab\xa6\xf4\x76\x64\x32\x99\x4a\x47\x1a\x0f\xb5"); + + return 0; +} diff --git a/gnulib-tests/test-sha512.c b/gnulib-tests/test-sha512.c new file mode 100644 index 0000000..661c29d --- /dev/null +++ b/gnulib-tests/test-sha512.c @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2018-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include "sha512.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include "macros.h" + +#define TESTFILE "test-sha512.data" +#include "test-digest.h" + +int +main (void) +{ + /* Test sha384_stream. */ + test_digest_on_files (sha384_stream, "sha384_stream", 48, + "\x38\xb0\x60\xa7\x51\xac\x96\x38\x4c\xd9\x32\x7e\xb1\xb1\xe3\x6a\x21\xfd\xb7\x11\x14\xbe\x07\x43\x4c\x0c\xc7\xbf\x63\xf6\xe1\xda\x27\x4e\xde\xbf\xe7\x6f\x65\xfb\xd5\x1a\xd2\xf1\x48\x98\xb9\x5b", + "\xd5\x1d\x28\xd0\x14\x1e\x56\xf6\x92\x95\x2e\xa1\x48\x61\x89\x8e\x2b\x41\x7b\x92\x28\x31\xe0\xf4\xbc\xdb\xc3\x26\xa7\xfe\x1e\x9d\x95\x63\x18\x2e\x83\xd3\xa8\xaf\x66\xf6\x85\x36\xe0\xd4\x2b\x88", + "\xab\x32\x29\xa1\xc8\x43\xce\x38\x85\x93\xb3\xa6\x7f\x5a\x36\xdc\xda\xf2\xac\x33\x22\x80\xee\xbc\x5b\x1b\x70\x8b\x9b\x96\x4b\xc1\x75\x60\x00\xae\xdc\xfd\x60\x70\x24\x7f\x0b\x8b\x3a\x89\xd3\xbb"); + + /* Test sha512_stream. */ + test_digest_on_files (sha512_stream, "sha512_stream", 64, + "\xcf\x83\xe1\x35\x7e\xef\xb8\xbd\xf1\x54\x28\x50\xd6\x6d\x80\x07\xd6\x20\xe4\x05\x0b\x57\x15\xdc\x83\xf4\xa9\x21\xd3\x6c\xe9\xce\x47\xd0\xd1\x3c\x5d\x85\xf2\xb0\xff\x83\x18\xd2\x87\x7e\xec\x2f\x63\xb9\x31\xbd\x47\x41\x7a\x81\xa5\x38\x32\x7a\xf9\x27\xda\x3e", + "\x02\x0d\xa0\xf4\xd8\xa4\xc8\xbf\xbc\x98\x27\x40\x27\x74\x00\x61\xd7\xdf\x52\xee\x07\x09\x1e\xd6\x59\x5a\x08\x3e\x0f\x45\x32\x7b\xbe\x59\x42\x43\x12\xd8\x6f\x21\x8b\x74\xed\x2e\x25\x50\x7a\xba\xf5\xc7\xa5\xfc\xf4\xca\xfc\xf9\x53\x8b\x70\x58\x08\xfd\x55\xec", + "\x38\x34\x58\xf3\xde\x68\x70\x33\x0c\xa4\xd4\x71\x4d\x0f\x41\xc5\xed\xc9\xf4\x67\x3e\x19\x0f\x87\x2b\x53\x72\x00\xa8\x35\x73\xf7\x0b\xf1\xf2\x0d\x9a\xa8\xd6\x08\x65\x2f\xe2\x28\xbd\x2d\x0c\xd5\xd6\xd4\xd3\xb2\x84\x3e\x32\x32\x5d\x62\x54\x7b\x39\xfd\x47\x04"); + + return 0; +} diff --git a/gnulib-tests/test-sigaction.c b/gnulib-tests/test-sigaction.c new file mode 100644 index 0000000..e48ba2b --- /dev/null +++ b/gnulib-tests/test-sigaction.c @@ -0,0 +1,122 @@ +/* Test of sigaction() function. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2008. */ + +#include <config.h> + +#include <signal.h> + +#include "signature.h" +SIGNATURE_CHECK (sigaction, int, (int, struct sigaction const *, + struct sigaction *)); + +#include <stddef.h> + +#include "macros.h" + +#ifndef SA_NOCLDSTOP +# define SA_NOCLDSTOP 0 +#endif +#ifndef SA_ONSTACK +# define SA_ONSTACK 0 +#endif +#ifndef SA_RESETHAND +# define SA_RESETHAND 0 +#endif +#ifndef SA_RESTART +# define SA_RESTART 0 +#endif +#ifndef SA_SIGINFO +# define SA_SIGINFO 0 +#endif +#ifndef SA_NOCLDWAIT +# define SA_NOCLDWAIT 0 +#endif + +/* Define a mask of flags required by POSIX. Some implementations + provide other flags as extensions, such as SA_RESTORER, that we + must ignore in this test. */ +#define MASK_SA_FLAGS (SA_NOCLDSTOP | SA_ONSTACK | SA_RESETHAND | SA_RESTART \ + | SA_SIGINFO | SA_NOCLDWAIT | SA_NODEFER) + +/* This test is unsafe in the presence of an asynchronous SIGABRT, + because we install a signal-handler that is intentionally not + async-safe. Hopefully, this does not lead to too many reports of + false failures, since people don't generally use 'kill -s SIGABRT' + to end a runaway program. */ + +static void +handler (int sig) +{ + static int entry_count; + struct sigaction sa; + ASSERT (sig == SIGABRT); + ASSERT (sigaction (SIGABRT, NULL, &sa) == 0); + ASSERT ((sa.sa_flags & SA_SIGINFO) == 0); + switch (entry_count++) + { + case 0: + ASSERT ((sa.sa_flags & SA_RESETHAND) == 0); + ASSERT (sa.sa_handler == handler); + break; + case 1: + /* This assertion fails on glibc-2.3.6 systems with LinuxThreads, + when this program is linked with -lpthread, due to the sigaction() + override in libpthread.so. */ +#if !(defined __GLIBC__ || defined __UCLIBC__) + ASSERT (sa.sa_handler == SIG_DFL); +#endif + break; + default: + ASSERT (0); + } +} + +int +main (void) +{ + struct sigaction sa; + struct sigaction old_sa; + sa.sa_handler = handler; + + sa.sa_flags = 0; + ASSERT (sigemptyset (&sa.sa_mask) == 0); + ASSERT (sigaction (SIGABRT, &sa, NULL) == 0); + ASSERT (raise (SIGABRT) == 0); + + sa.sa_flags = SA_RESETHAND | SA_NODEFER; + ASSERT (sigaction (SIGABRT, &sa, &old_sa) == 0); + ASSERT ((old_sa.sa_flags & MASK_SA_FLAGS) == 0); + ASSERT (old_sa.sa_handler == handler); + ASSERT (raise (SIGABRT) == 0); + + sa.sa_handler = SIG_DFL; + ASSERT (sigaction (SIGABRT, &sa, &old_sa) == 0); + ASSERT ((old_sa.sa_flags & SA_SIGINFO) == 0); +#if !(defined __GLIBC__ || defined __UCLIBC__) /* see above */ + ASSERT (old_sa.sa_handler == SIG_DFL); +#endif + + sa.sa_handler = SIG_IGN; + ASSERT (sigaction (SIGABRT, &sa, NULL) == 0); + ASSERT (raise (SIGABRT) == 0); + ASSERT (sigaction (SIGABRT, NULL, &old_sa) == 0); + ASSERT (old_sa.sa_handler == SIG_IGN); + ASSERT (raise (SIGABRT) == 0); + + return 0; +} diff --git a/gnulib-tests/test-signal-h.c b/gnulib-tests/test-signal-h.c new file mode 100644 index 0000000..a504f56 --- /dev/null +++ b/gnulib-tests/test-signal-h.c @@ -0,0 +1,129 @@ +/* Test of <signal.h> substitute. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <signal.h> + +/* Check for required types. */ +struct +{ + size_t a; + uid_t b; + volatile sig_atomic_t c; + sigset_t d; + pid_t e; +#if 0 + /* Not guaranteed by gnulib. */ + pthread_t f; + struct timespec g; +#endif +} s; + +/* Check that NSIG is defined. */ +int nsig = NSIG; + +int +main (void) +{ + switch (0) + { + /* The following are guaranteed by C. */ + case 0: + case SIGABRT: + case SIGFPE: + case SIGILL: + case SIGINT: + case SIGSEGV: + case SIGTERM: + /* The following is guaranteed by gnulib. */ +#if GNULIB_SIGPIPE || defined SIGPIPE + case SIGPIPE: +#endif + /* Ensure no conflict with other standardized names. */ +#ifdef SIGALRM + case SIGALRM: +#endif + /* On Haiku, SIGBUS is mistakenly equal to SIGSEGV. */ +#if defined SIGBUS && SIGBUS != SIGSEGV + case SIGBUS: +#endif +#ifdef SIGCHLD + case SIGCHLD: +#endif +#ifdef SIGCONT + case SIGCONT: +#endif +#ifdef SIGHUP + case SIGHUP: +#endif +#ifdef SIGKILL + case SIGKILL: +#endif +#ifdef SIGQUIT + case SIGQUIT: +#endif +#ifdef SIGSTOP + case SIGSTOP: +#endif +#ifdef SIGTSTP + case SIGTSTP: +#endif +#ifdef SIGTTIN + case SIGTTIN: +#endif +#ifdef SIGTTOU + case SIGTTOU: +#endif +#ifdef SIGUSR1 + case SIGUSR1: +#endif +#ifdef SIGUSR2 + case SIGUSR2: +#endif +#ifdef SIGSYS + case SIGSYS: +#endif +#ifdef SIGTRAP + case SIGTRAP: +#endif +#ifdef SIGURG + case SIGURG: +#endif +#ifdef SIGVTALRM + case SIGVTALRM: +#endif +#ifdef SIGXCPU + case SIGXCPU: +#endif +#ifdef SIGXFSZ + case SIGXFSZ: +#endif + /* SIGRTMIN and SIGRTMAX need not be compile-time constants. */ +#if 0 +# ifdef SIGRTMIN + case SIGRTMIN: +# endif +# ifdef SIGRTMAX + case SIGRTMAX: +# endif +#endif + ; + } + return s.a + s.b + s.c + s.e; +} diff --git a/gnulib-tests/test-signbit.c b/gnulib-tests/test-signbit.c new file mode 100644 index 0000000..658e98d --- /dev/null +++ b/gnulib-tests/test-signbit.c @@ -0,0 +1,187 @@ +/* Test of signbit() substitute. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <math.h> + +/* signbit must be a macro. */ +#ifndef signbit +# error missing declaration +#endif + +#include <float.h> +#include <limits.h> + +#include "minus-zero.h" +#include "infinity.h" +#include "macros.h" + +float zerof = 0.0f; +double zerod = 0.0; +long double zerol = 0.0L; + +static void +test_signbitf () +{ + /* Finite values. */ + ASSERT (!signbit (3.141f)); + ASSERT (!signbit (3.141e30f)); + ASSERT (!signbit (3.141e-30f)); + ASSERT (signbit (-2.718f)); + ASSERT (signbit (-2.718e30f)); + ASSERT (signbit (-2.718e-30f)); + /* Zeros. */ + ASSERT (!signbit (0.0f)); + if (1.0f / minus_zerof < 0) + ASSERT (signbit (minus_zerof)); + else + ASSERT (!signbit (minus_zerof)); + /* Infinite values. */ + ASSERT (!signbit (Infinityf ())); + ASSERT (signbit (- Infinityf ())); + /* Quiet NaN. */ + (void) signbit (zerof / zerof); +#if defined FLT_EXPBIT0_WORD && defined FLT_EXPBIT0_BIT + /* Signalling NaN. */ + { + #define NWORDS \ + ((sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) + typedef union { float value; unsigned int word[NWORDS]; } memory_float; + memory_float m; + m.value = zerof / zerof; +# if FLT_EXPBIT0_BIT > 0 + m.word[FLT_EXPBIT0_WORD] ^= (unsigned int) 1 << (FLT_EXPBIT0_BIT - 1); +# else + m.word[FLT_EXPBIT0_WORD + (FLT_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)] + ^= (unsigned int) 1 << (sizeof (unsigned int) * CHAR_BIT - 1); +# endif + if (FLT_EXPBIT0_WORD < NWORDS / 2) + m.word[FLT_EXPBIT0_WORD + 1] |= (unsigned int) 1 << FLT_EXPBIT0_BIT; + else + m.word[0] |= (unsigned int) 1; + (void) signbit (m.value); + #undef NWORDS + } +#endif +} + +static void +test_signbitd () +{ + /* Finite values. */ + ASSERT (!signbit (3.141)); + ASSERT (!signbit (3.141e30)); + ASSERT (!signbit (3.141e-30)); + ASSERT (signbit (-2.718)); + ASSERT (signbit (-2.718e30)); + ASSERT (signbit (-2.718e-30)); + /* Zeros. */ + ASSERT (!signbit (0.0)); + if (1.0 / minus_zerod < 0) + ASSERT (signbit (minus_zerod)); + else + ASSERT (!signbit (minus_zerod)); + /* Infinite values. */ + ASSERT (!signbit (Infinityd ())); + ASSERT (signbit (- Infinityd ())); + /* Quiet NaN. */ + (void) signbit (zerod / zerod); +#if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT + /* Signalling NaN. */ + { + #define NWORDS \ + ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) + typedef union { double value; unsigned int word[NWORDS]; } memory_double; + memory_double m; + m.value = zerod / zerod; +# if DBL_EXPBIT0_BIT > 0 + m.word[DBL_EXPBIT0_WORD] ^= (unsigned int) 1 << (DBL_EXPBIT0_BIT - 1); +# else + m.word[DBL_EXPBIT0_WORD + (DBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)] + ^= (unsigned int) 1 << (sizeof (unsigned int) * CHAR_BIT - 1); +# endif + m.word[DBL_EXPBIT0_WORD + (DBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)] + |= (unsigned int) 1 << DBL_EXPBIT0_BIT; + (void) signbit (m.value); + #undef NWORDS + } +#endif +} + +static void +test_signbitl () +{ + /* Finite values. */ + ASSERT (!signbit (3.141L)); + ASSERT (!signbit (3.141e30L)); + ASSERT (!signbit (3.141e-30L)); + ASSERT (signbit (-2.718L)); + ASSERT (signbit (-2.718e30L)); + ASSERT (signbit (-2.718e-30L)); + /* Zeros. */ + ASSERT (!signbit (0.0L)); + if (1.0L / minus_zerol < 0) + ASSERT (signbit (minus_zerol)); + else + ASSERT (!signbit (minus_zerol)); + /* Infinite values. */ + ASSERT (!signbit (Infinityl ())); + ASSERT (signbit (- Infinityl ())); + /* Quiet NaN. */ + (void) signbit (zerol / zerol); +#if defined LDBL_EXPBIT0_WORD && defined LDBL_EXPBIT0_BIT + /* Signalling NaN. */ + { + #define NWORDS \ + ((sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) + typedef union { long double value; unsigned int word[NWORDS]; } memory_long_double; + +#if defined __powerpc__ && LDBL_MANT_DIG == 106 + /* This is PowerPC "double double", a pair of two doubles. Inf and Nan are + represented as the corresponding 64-bit IEEE values in the first double; + the second is ignored. Manipulate only the first double. */ + #undef NWORDS + #define NWORDS \ + ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) +#endif + + memory_long_double m; + m.value = zerol / zerol; +# if LDBL_EXPBIT0_BIT > 0 + m.word[LDBL_EXPBIT0_WORD] ^= (unsigned int) 1 << (LDBL_EXPBIT0_BIT - 1); +# else + m.word[LDBL_EXPBIT0_WORD + (LDBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)] + ^= (unsigned int) 1 << (sizeof (unsigned int) * CHAR_BIT - 1); +# endif + m.word[LDBL_EXPBIT0_WORD + (LDBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)] + |= (unsigned int) 1 << LDBL_EXPBIT0_BIT; + (void) signbit (m.value); + #undef NWORDS + } +#endif +} + +int +main () +{ + test_signbitf (); + test_signbitd (); + test_signbitl (); + return 0; +} diff --git a/gnulib-tests/test-sigprocmask.c b/gnulib-tests/test-sigprocmask.c new file mode 100644 index 0000000..df3602e --- /dev/null +++ b/gnulib-tests/test-sigprocmask.c @@ -0,0 +1,102 @@ +/* Test of sigprocmask. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2011. */ + +#include <config.h> + +#include <signal.h> + +#include "signature.h" +SIGNATURE_CHECK (sigprocmask, int, (int, const sigset_t *, sigset_t *)); + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "macros.h" + +#if !(defined _WIN32 && !defined __CYGWIN__) + +static volatile int sigint_occurred; + +static void +sigint_handler (int sig) +{ + sigint_occurred++; +} + +int +main (int argc, char *argv[]) +{ + sigset_t set; + pid_t pid = getpid (); + char command[80]; + + if (sizeof (int) < sizeof pid && 0x7fffffff < pid) + { + fputs ("Skipping test: pid too large\n", stderr); + return 77; + } + + signal (SIGINT, sigint_handler); + + sigemptyset (&set); + sigaddset (&set, SIGINT); + + /* Check error handling. */ + ASSERT (sigprocmask (1729, &set, NULL) == -1); + ASSERT (errno == EINVAL); + + /* Block SIGINT. */ + ASSERT (sigprocmask (SIG_BLOCK, &set, NULL) == 0); + + /* Request a SIGINT signal from outside. */ + sprintf (command, "sh -c 'sleep 1; kill -%d %d' &", SIGINT, (int) pid); + ASSERT (system (command) == 0); + + /* Wait. */ + sleep (2); + + /* The signal should not have arrived yet, because it is blocked. */ + ASSERT (sigint_occurred == 0); + + /* Unblock SIGINT. */ + ASSERT (sigprocmask (SIG_UNBLOCK, &set, NULL) == 0); + + /* The signal should have arrived now, because POSIX says + "If there are any pending unblocked signals after the call to + sigprocmask(), at least one of those signals shall be delivered + before the call to sigprocmask() returns." */ + ASSERT (sigint_occurred == 1); + + return 0; +} + +#else + +/* On native Windows, getpid() values and the arguments that are passed to + the (Cygwin?) 'kill' program are not necessarily related. */ + +int +main () +{ + fputs ("Skipping test: native Windows platform\n", stderr); + return 77; +} + +#endif diff --git a/gnulib-tests/test-sleep.c b/gnulib-tests/test-sleep.c new file mode 100644 index 0000000..cb659ba --- /dev/null +++ b/gnulib-tests/test-sleep.c @@ -0,0 +1,58 @@ +/* Test of sleep() function. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (sleep, unsigned int, (unsigned int)); + +#include <signal.h> + +#include "macros.h" + +#if HAVE_DECL_ALARM +static void +handle_alarm (int sig) +{ + if (sig != SIGALRM) + _exit (1); +} +#endif + +int +main (void) +{ + ASSERT (sleep (1) <= 1); + + ASSERT (sleep (0) == 0); + +#if HAVE_DECL_ALARM + { + const unsigned int pentecost = 50 * 24 * 60 * 60; /* 50 days. */ + unsigned int remaining; + signal (SIGALRM, handle_alarm); + alarm (1); + remaining = sleep (pentecost); + ASSERT (pentecost - 10 < remaining && remaining <= pentecost); + } +#endif + + return 0; +} diff --git a/gnulib-tests/test-snprintf.c b/gnulib-tests/test-snprintf.c new file mode 100644 index 0000000..1cbab66 --- /dev/null +++ b/gnulib-tests/test-snprintf.c @@ -0,0 +1,72 @@ +/* Test of snprintf() function. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (snprintf, int, (char *, size_t, char const *, ...)); + +#include <string.h> + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + char buf[8]; + int size; + int retval; + + retval = snprintf (NULL, 0, "%d", 12345); + ASSERT (retval == 5); + + for (size = 0; size <= 8; size++) + { + memcpy (buf, "DEADBEEF", 8); + retval = snprintf (buf, size, "%d", 12345); + ASSERT (retval == 5); + if (size < 6) + { + if (size > 0) + { + ASSERT (memcmp (buf, "12345", size - 1) == 0); + ASSERT (buf[size - 1] == '\0' || buf[size - 1] == '0' + size); + } +#if !CHECK_SNPRINTF_POSIX + if (size > 0) +#endif + ASSERT (memcmp (buf + size, &"DEADBEEF"[size], 8 - size) == 0); + } + else + { + ASSERT (memcmp (buf, "12345\0EF", 8) == 0); + } + } + + /* Test the support of the POSIX/XSI format strings with positions. */ + { + char result[100]; + retval = snprintf (result, sizeof (result), "%2$d %1$d", 33, 55); + ASSERT (strcmp (result, "55 33") == 0); + ASSERT (retval == strlen (result)); + } + + return 0; +} diff --git a/gnulib-tests/test-sockets.c b/gnulib-tests/test-sockets.c new file mode 100644 index 0000000..cd35952 --- /dev/null +++ b/gnulib-tests/test-sockets.c @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2008-2020 Free Software Foundation, Inc. + * Written by Simon Josefsson. + * + * 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdio.h> + +#include "sockets.h" + +int +main (void) +{ + int err; + + err = gl_sockets_startup (SOCKETS_1_1); + if (err != 0) + { + printf ("wsastartup failed %d\n", err); + return 1; + } + + err = gl_sockets_cleanup (); + if (err != 0) + { + printf ("wsacleanup failed %d\n", err); + return 1; + } + + (void) gl_fd_to_handle (0); + + return 0; +} diff --git a/gnulib-tests/test-stat-time.c b/gnulib-tests/test-stat-time.c new file mode 100644 index 0000000..86d4346 --- /dev/null +++ b/gnulib-tests/test-stat-time.c @@ -0,0 +1,248 @@ +/* Test of <stat-time.h>. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by James Youngman <jay@gnu.org>, 2007. */ + +#include <config.h> + +#include "stat-time.h" + +#include <fcntl.h> +#include <signal.h> +#include <stdio.h> +#include <sys/stat.h> +#include <unistd.h> +#include <time.h> + +#include "macros.h" + +#define BASE "test-stat-time.t" +#include "nap.h" + +enum { NFILES = 4 }; + +static char filename_stamp1[50]; +static char filename_testfile[50]; +static char filename_stamp2[50]; +static char filename_stamp3[50]; + +/* Use file names that are different at each run. + This is necessary for test_birthtime() to pass on native Windows: + On this platform, the file system apparently remembers the creation time + of a file even after it is removed and created anew. See + "Windows NT Contains File System Tunneling Capabilities" + <https://support.microsoft.com/en-us/help/172190/> */ +static void +initialize_filenames (void) +{ + long t = (long) time (NULL); + sprintf (filename_stamp1, "t-stt-%ld-stamp1", t); + sprintf (filename_testfile, "t-stt-%ld-testfile", t); + sprintf (filename_stamp2, "t-stt-%ld-stamp2", t); + sprintf (filename_stamp3, "t-stt-%ld-stamp3", t); +} + +static int +force_unlink (const char *filename) +{ + /* This chmod is necessary on mingw, where unlink() of a read-only file + fails with EPERM. */ + chmod (filename, 0600); + return unlink (filename); +} + +static void +cleanup (int sig) +{ + /* Remove temporary files. */ + force_unlink (filename_stamp1); + force_unlink (filename_testfile); + force_unlink (filename_stamp2); + force_unlink (filename_stamp3); + + if (sig != 0) + _exit (1); +} + +static int +open_file (const char *filename, int flags) +{ + int fd = open (filename, flags | O_WRONLY, 0500); + if (fd >= 0) + { + close (fd); + return 1; + } + else + { + return 0; + } +} + +static void +create_file (const char *filename) +{ + ASSERT (open_file (filename, O_CREAT | O_EXCL)); +} + +static void +do_stat (const char *filename, struct stat *p) +{ + ASSERT (stat (filename, p) == 0); +} + +static void +prepare_test (struct stat *statinfo, struct timespec *modtimes) +{ + int i; + + create_file (filename_stamp1); + nap (); + create_file (filename_testfile); + nap (); + create_file (filename_stamp2); + nap (); + ASSERT (chmod (filename_testfile, 0400) == 0); + nap (); + create_file (filename_stamp3); + + do_stat (filename_stamp1, &statinfo[0]); + do_stat (filename_testfile, &statinfo[1]); + do_stat (filename_stamp2, &statinfo[2]); + do_stat (filename_stamp3, &statinfo[3]); + + /* Now use our access functions. */ + for (i = 0; i < NFILES; ++i) + { + modtimes[i] = get_stat_mtime (&statinfo[i]); + } +} + +static void +test_mtime (const struct stat *statinfo, struct timespec *modtimes) +{ + int i; + + /* Use the struct stat fields directly. */ + /* mtime(stamp1) < mtime(stamp2) */ + ASSERT (statinfo[0].st_mtime < statinfo[2].st_mtime + || (statinfo[0].st_mtime == statinfo[2].st_mtime + && (get_stat_mtime_ns (&statinfo[0]) + < get_stat_mtime_ns (&statinfo[2])))); + /* mtime(stamp2) < mtime(stamp3) */ + ASSERT (statinfo[2].st_mtime < statinfo[3].st_mtime + || (statinfo[2].st_mtime == statinfo[3].st_mtime + && (get_stat_mtime_ns (&statinfo[2]) + < get_stat_mtime_ns (&statinfo[3])))); + + /* Now check the result of the access functions. */ + /* mtime(stamp1) < mtime(stamp2) */ + ASSERT (modtimes[0].tv_sec < modtimes[2].tv_sec + || (modtimes[0].tv_sec == modtimes[2].tv_sec + && modtimes[0].tv_nsec < modtimes[2].tv_nsec)); + /* mtime(stamp2) < mtime(stamp3) */ + ASSERT (modtimes[2].tv_sec < modtimes[3].tv_sec + || (modtimes[2].tv_sec == modtimes[3].tv_sec + && modtimes[2].tv_nsec < modtimes[3].tv_nsec)); + + /* verify equivalence */ + for (i = 0; i < NFILES; ++i) + { + struct timespec ts; + ts = get_stat_mtime (&statinfo[i]); + ASSERT (ts.tv_sec == statinfo[i].st_mtime); + } +} + +#if defined _WIN32 && !defined __CYGWIN__ +/* Skip the ctime tests on native Windows platforms, because their + st_ctime is either the same as st_mtime (plus or minus an offset) + or set to the file _creation_ time, and is not influenced by rename + or chmod. */ +# define test_ctime(ignored) ((void) 0) +#else +static void +test_ctime (const struct stat *statinfo) +{ + /* On some buggy NFS clients, mtime and ctime are disproportionately + skewed from one another. Skip this test in that case. */ + if (statinfo[0].st_mtime != statinfo[0].st_ctime) + return; + + /* mtime(stamp2) < ctime(testfile) */ + ASSERT (statinfo[2].st_mtime < statinfo[1].st_ctime + || (statinfo[2].st_mtime == statinfo[1].st_ctime + && (get_stat_mtime_ns (&statinfo[2]) + < get_stat_ctime_ns (&statinfo[1])))); +} +#endif + +static void +test_birthtime (const struct stat *statinfo, + const struct timespec *modtimes, + struct timespec *birthtimes) +{ + int i; + + /* Collect the birth times. */ + for (i = 0; i < NFILES; ++i) + { + birthtimes[i] = get_stat_birthtime (&statinfo[i]); + if (birthtimes[i].tv_nsec < 0) + return; + } + + /* mtime(stamp1) < birthtime(testfile) */ + ASSERT (modtimes[0].tv_sec < birthtimes[1].tv_sec + || (modtimes[0].tv_sec == birthtimes[1].tv_sec + && modtimes[0].tv_nsec < birthtimes[1].tv_nsec)); + /* birthtime(testfile) < mtime(stamp2) */ + ASSERT (birthtimes[1].tv_sec < modtimes[2].tv_sec + || (birthtimes[1].tv_sec == modtimes[2].tv_sec + && birthtimes[1].tv_nsec < modtimes[2].tv_nsec)); +} + +int +main (void) +{ + struct stat statinfo[NFILES]; + struct timespec modtimes[NFILES]; + struct timespec birthtimes[NFILES]; + + initialize_filenames (); + +#ifdef SIGHUP + signal (SIGHUP, cleanup); +#endif +#ifdef SIGINT + signal (SIGINT, cleanup); +#endif +#ifdef SIGQUIT + signal (SIGQUIT, cleanup); +#endif +#ifdef SIGTERM + signal (SIGTERM, cleanup); +#endif + + cleanup (0); + prepare_test (statinfo, modtimes); + test_mtime (statinfo, modtimes); + test_ctime (statinfo); + test_birthtime (statinfo, modtimes, birthtimes); + + cleanup (0); + return 0; +} diff --git a/gnulib-tests/test-stat.c b/gnulib-tests/test-stat.c new file mode 100644 index 0000000..59cfca7 --- /dev/null +++ b/gnulib-tests/test-stat.c @@ -0,0 +1,56 @@ +/* Tests of stat. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <sys/stat.h> + +/* Caution: stat may be a function-like macro. Although this + signature check must pass, it may be the signature of the real (and + broken) stat rather than rpl_stat. Most code should not use the + address of stat. */ +#include "signature.h" +SIGNATURE_CHECK (stat, int, (char const *, struct stat *)); + +#include <fcntl.h> +#include <errno.h> +#include <stdbool.h> +#include <stdlib.h> +#include <stdio.h> +#include <unistd.h> + +#include "same-inode.h" +#include "macros.h" + +#define BASE "test-stat.t" + +#include "test-stat.h" + +/* Wrapper around stat, which works even if stat is a function-like + macro, where test_stat_func(stat) would do the wrong thing. */ +static int +do_stat (char const *name, struct stat *st) +{ + return stat (name, st); +} + +int +main (void) +{ + return test_stat_func (do_stat, true); +} diff --git a/gnulib-tests/test-stat.h b/gnulib-tests/test-stat.h new file mode 100644 index 0000000..264d739 --- /dev/null +++ b/gnulib-tests/test-stat.h @@ -0,0 +1,107 @@ +/* Tests of stat. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +/* This file is designed to test both stat(n,buf) and + fstatat(AT_FDCWD,n,buf,0). FUNC is the function to test. Assumes + that BASE and ASSERT are already defined, and that appropriate + headers are already included. If PRINT, warn before skipping + symlink tests with status 77. */ + +static int +test_stat_func (int (*func) (char const *, struct stat *), bool print) +{ + struct stat st1; + struct stat st2; + char *cwd = getcwd (NULL, 0); + + ASSERT (cwd); + ASSERT (func (".", &st1) == 0); + ASSERT (func ("./", &st2) == 0); +#if !(defined _WIN32 && !defined __CYGWIN__ && !_GL_WINDOWS_STAT_INODES) + ASSERT (SAME_INODE (st1, st2)); +#endif + ASSERT (func (cwd, &st2) == 0); +#if !(defined _WIN32 && !defined __CYGWIN__ && !_GL_WINDOWS_STAT_INODES) + ASSERT (SAME_INODE (st1, st2)); +#endif + ASSERT (func ("/", &st1) == 0); + ASSERT (func ("///", &st2) == 0); +#if !(defined _WIN32 && !defined __CYGWIN__ && !_GL_WINDOWS_STAT_INODES) + ASSERT (SAME_INODE (st1, st2)); +#endif + + errno = 0; + ASSERT (func ("", &st1) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func ("nosuch", &st1) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func ("nosuch/", &st1) == -1); + ASSERT (errno == ENOENT); + + ASSERT (close (creat (BASE "file", 0600)) == 0); + ASSERT (func (BASE "file", &st1) == 0); + errno = 0; + ASSERT (func (BASE "file/", &st1) == -1); + ASSERT (errno == ENOTDIR); + + /* Now for some symlink tests, where supported. We set up: + link1 -> directory + link2 -> file + link3 -> dangling + link4 -> loop + then test behavior with trailing slash. + */ + if (symlink (".", BASE "link1") != 0) + { + ASSERT (unlink (BASE "file") == 0); + if (print) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + ASSERT (symlink (BASE "file", BASE "link2") == 0); + ASSERT (symlink (BASE "nosuch", BASE "link3") == 0); + ASSERT (symlink (BASE "link4", BASE "link4") == 0); + + ASSERT (func (BASE "link1/", &st1) == 0); + ASSERT (S_ISDIR (st1.st_mode)); + + errno = 0; + ASSERT (func (BASE "link2/", &st1) == -1); + ASSERT (errno == ENOTDIR); + + errno = 0; + ASSERT (func (BASE "link3/", &st1) == -1); + ASSERT (errno == ENOENT); + + errno = 0; + ASSERT (func (BASE "link4/", &st1) == -1); + ASSERT (errno == ELOOP); + + /* Cleanup. */ + ASSERT (unlink (BASE "file") == 0); + ASSERT (unlink (BASE "link1") == 0); + ASSERT (unlink (BASE "link2") == 0); + ASSERT (unlink (BASE "link3") == 0); + ASSERT (unlink (BASE "link4") == 0); + free (cwd); + + return 0; +} diff --git a/gnulib-tests/test-statat.c b/gnulib-tests/test-statat.c new file mode 100644 index 0000000..ee17de7 --- /dev/null +++ b/gnulib-tests/test-statat.c @@ -0,0 +1,27 @@ +/* Tests of statat and lstatat. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include "openat.h" + +#include "signature.h" +SIGNATURE_CHECK (statat, int, (int, char const *, struct stat *)); +SIGNATURE_CHECK (lstatat, int, (int, char const *, struct stat *)); + +#define BASE "test-statat.t" +#define TEST_STATAT +#include "test-fstatat.c" diff --git a/gnulib-tests/test-stdalign.c b/gnulib-tests/test-stdalign.c new file mode 100644 index 0000000..65e5c6a --- /dev/null +++ b/gnulib-tests/test-stdalign.c @@ -0,0 +1,121 @@ +/* Test of <stdalign.h>. + Copyright 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Paul Eggert, inspired by Bruno Haible's test-alignof.c. */ + +#include <config.h> + +#include <stdalign.h> + +#include <stddef.h> +#include <stdint.h> + +#include "verify.h" + +#include "macros.h" + +typedef long double longdouble; +typedef struct { char a[1]; } struct1; +typedef struct { char a[2]; } struct2; +typedef struct { char a[3]; } struct3; +typedef struct { char a[4]; } struct4; + +verify (__alignof_is_defined == 1); +#ifndef alignof +# error "alignof is not a macro" +#endif + +#if __alignas_is_defined +verify (__alignas_is_defined == 1); +# ifndef alignas +# error "alignas is not a macro" +# endif +/* mingw can go up only to 8. 8 is all that GNU Emacs needs, so let's + limit the test to 8 for now. */ +# define TEST_ALIGNMENT 8 +#else +# define _Alignas(alignment) +# define alignas(alignment) +# define TEST_ALIGNMENT 1 +#endif + +#define CHECK_STATIC(type) \ + typedef struct { char slot1; type slot2; } type##_helper; \ + verify (alignof (type) == offsetof (type##_helper, slot2)); \ + verify (_Alignof (type) == alignof (type)); \ + const int type##_alignment = alignof (type); \ + type alignas (TEST_ALIGNMENT) static_##type##_alignas; \ + type _Alignas (TEST_ALIGNMENT) static_##type##_Alignas + +#define CHECK_ALIGNED(var) ASSERT ((uintptr_t) &(var) % TEST_ALIGNMENT == 0) + +CHECK_STATIC (char); +CHECK_STATIC (short); +CHECK_STATIC (int); +CHECK_STATIC (long); +#ifdef INT64_MAX +CHECK_STATIC (int64_t); +#endif +CHECK_STATIC (float); +CHECK_STATIC (double); +/* CHECK_STATIC (longdouble); */ +CHECK_STATIC (struct1); +CHECK_STATIC (struct2); +CHECK_STATIC (struct3); +CHECK_STATIC (struct4); + +int +main () +{ +#if defined __SUNPRO_C + /* Avoid a test failure due to Sun Studio Developer Bug Report #2125432. */ + fputs ("Skipping test: known Sun C compiler bug\n", stderr); + return 77; +#elif defined __HP_cc && __ia64 + /* Avoid a test failure due to HP-UX Itanium cc bug; see: + https://lists.gnu.org/r/bug-gnulib/2017-03/msg00078.html */ + fputs ("Skipping test: known HP-UX Itanium cc compiler bug\n", stderr); + return 77; +#else + CHECK_ALIGNED (static_char_alignas); + CHECK_ALIGNED (static_char_Alignas); + CHECK_ALIGNED (static_short_alignas); + CHECK_ALIGNED (static_short_Alignas); + CHECK_ALIGNED (static_int_alignas); + CHECK_ALIGNED (static_int_Alignas); + CHECK_ALIGNED (static_long_alignas); + CHECK_ALIGNED (static_long_Alignas); +# ifdef INT64_MAX + CHECK_ALIGNED (static_int64_t_alignas); + CHECK_ALIGNED (static_int64_t_Alignas); +# endif + CHECK_ALIGNED (static_float_alignas); + CHECK_ALIGNED (static_float_Alignas); + CHECK_ALIGNED (static_double_alignas); + CHECK_ALIGNED (static_double_Alignas); + /* CHECK_ALIGNED (static_longdouble_alignas); */ + /* CHECK_ALIGNED (static_longdouble_Alignas); */ + CHECK_ALIGNED (static_struct1_alignas); + CHECK_ALIGNED (static_struct1_Alignas); + CHECK_ALIGNED (static_struct2_alignas); + CHECK_ALIGNED (static_struct2_Alignas); + CHECK_ALIGNED (static_struct3_alignas); + CHECK_ALIGNED (static_struct3_Alignas); + CHECK_ALIGNED (static_struct4_alignas); + CHECK_ALIGNED (static_struct4_Alignas); + return 0; +#endif +} diff --git a/gnulib-tests/test-stdbool.c b/gnulib-tests/test-stdbool.c new file mode 100644 index 0000000..b128b55 --- /dev/null +++ b/gnulib-tests/test-stdbool.c @@ -0,0 +1,118 @@ +/* Test of <stdbool.h> substitute. + Copyright (C) 2002-2007, 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +/* We want this test to succeed even when using gcc's -Werror; but to + do that requires a pragma that didn't exist before 4.3.0. */ +#ifndef __GNUC__ +# define ADDRESS_CHECK_OKAY +#elif __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3) +/* No way to silence -Waddress. */ +#else +# pragma GCC diagnostic ignored "-Waddress" +# define ADDRESS_CHECK_OKAY +#endif + +#include <config.h> + +#include <stdbool.h> + +#ifndef bool + "error: bool is not defined" +#endif +#ifndef false + "error: false is not defined" +#endif +#if false + "error: false is not 0" +#endif +#ifndef true + "error: true is not defined" +#endif +#if true != 1 + "error: true is not 1" +#endif +#ifndef __bool_true_false_are_defined + "error: __bool_true_false_are_defined is not defined" +#endif + +/* Several tests cannot be guaranteed with gnulib's <stdbool.h>, at + least, not for all compilers and compiler options. */ +#if HAVE_STDBOOL_H || 3 <= __GNUC__ +struct s { _Bool s: 1; _Bool t; } s; +#endif + +char a[true == 1 ? 1 : -1]; +char b[false == 0 ? 1 : -1]; +char c[__bool_true_false_are_defined == 1 ? 1 : -1]; +#if HAVE_STDBOOL_H || 3 <= __GNUC__ /* See above. */ +char d[(bool) 0.5 == true ? 1 : -1]; +# ifdef ADDRESS_CHECK_OKAY /* Avoid gcc warning. */ +/* C99 may plausibly be interpreted as not requiring support for a cast from + a variable's address to bool in a static initializer. So treat it like a + GCC extension. */ +# ifdef __GNUC__ +bool e = &s; +# endif +# endif +char f[(_Bool) 0.0 == false ? 1 : -1]; +#endif +char g[true]; +char h[sizeof (_Bool)]; +#if HAVE_STDBOOL_H || 3 <= __GNUC__ /* See above. */ +char i[sizeof s.t]; +#endif +enum { j = false, k = true, l = false * true, m = true * 256 }; +_Bool n[m]; +char o[sizeof n == m * sizeof n[0] ? 1 : -1]; +char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; +/* Catch a bug in an HP-UX C compiler. See + https://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html + https://lists.gnu.org/r/bug-coreutils/2005-11/msg00161.html + */ +_Bool q = true; +_Bool *pq = &q; + +int +main () +{ + int error = 0; + +#if HAVE_STDBOOL_H || 3 <= __GNUC__ /* See above. */ +# ifdef ADDRESS_CHECK_OKAY /* Avoid gcc warning. */ + /* A cast from a variable's address to bool is valid in expressions. */ + { + bool e1 = &s; + if (!e1) + error = 1; + } +# endif +#endif + + /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 + reported by James Lemley on 2005-10-05; see + https://lists.gnu.org/r/bug-coreutils/2005-10/msg00086.html + This is a runtime test, since a corresponding compile-time + test would rely on initializer extensions. */ + { + char digs[] = "0123456789"; + if (&(digs + 5)[-2 + (bool) 1] != &digs[4]) + error = 1; + } + + return error; +} diff --git a/gnulib-tests/test-stddef.c b/gnulib-tests/test-stddef.c new file mode 100644 index 0000000..636c075 --- /dev/null +++ b/gnulib-tests/test-stddef.c @@ -0,0 +1,77 @@ +/* Test of <stddef.h> substitute. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <stddef.h> +#include <limits.h> +#include <stdalign.h> +#include "verify.h" + +/* Check that appropriate types are defined. */ +wchar_t a = 'c'; +ptrdiff_t b = 1; +size_t c = 2; +max_align_t x; + +/* Check that NULL can be passed through varargs as a pointer type, + per POSIX 2008. */ +verify (sizeof NULL == sizeof (void *)); + +/* Check that offsetof produces integer constants with correct type. */ +struct d +{ + char e; + char f; +}; +/* Solaris 10 has a bug where offsetof is under-parenthesized, and + cannot be used as an arbitrary expression. However, since it is + unlikely to bite real code, we ignore that short-coming. */ +/* verify (sizeof offsetof (struct d, e) == sizeof (size_t)); */ +verify (sizeof (offsetof (struct d, e)) == sizeof (size_t)); +verify (offsetof (struct d, f) == 1); + +/* offsetof promotes to an unsigned integer if and only if sizes do + not fit in int. */ +verify ((offsetof (struct d, e) < -1) == (INT_MAX < (size_t) -1)); + +/* Check max_align_t's alignment. */ +verify (alignof (double) <= alignof (max_align_t)); +verify (alignof (int) <= alignof (max_align_t)); +verify (alignof (long double) <= alignof (max_align_t)); +verify (alignof (long int) <= alignof (max_align_t)); +verify (alignof (ptrdiff_t) <= alignof (max_align_t)); +verify (alignof (size_t) <= alignof (max_align_t)); +verify (alignof (wchar_t) <= alignof (max_align_t)); +verify (alignof (struct d) <= alignof (max_align_t)); +#if defined __GNUC__ || defined __IBM__ALIGNOF__ +verify (__alignof__ (double) <= __alignof__ (max_align_t)); +verify (__alignof__ (int) <= __alignof__ (max_align_t)); +verify (__alignof__ (long double) <= __alignof__ (max_align_t)); +verify (__alignof__ (long int) <= __alignof__ (max_align_t)); +verify (__alignof__ (ptrdiff_t) <= __alignof__ (max_align_t)); +verify (__alignof__ (size_t) <= __alignof__ (max_align_t)); +verify (__alignof__ (wchar_t) <= __alignof__ (max_align_t)); +verify (__alignof__ (struct d) <= __alignof__ (max_align_t)); +#endif + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tests/test-stdint.c b/gnulib-tests/test-stdint.c new file mode 100644 index 0000000..6da84b2 --- /dev/null +++ b/gnulib-tests/test-stdint.c @@ -0,0 +1,428 @@ +/* Test of <stdint.h> substitute. + Copyright (C) 2006-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2006. */ + +#include <config.h> + +/* Whether to enable pedantic checks. */ +#define DO_PEDANTIC 0 + +#include <stdint.h> + +#include "verify.h" +#include "intprops.h" + +#if __GNUC__ >= 2 && DO_PEDANTIC +# define verify_same_types(expr1,expr2) \ + extern void _verify_func(__LINE__) (__typeof__ (expr1) *); \ + extern void _verify_func(__LINE__) (__typeof__ (expr2) *); +# define _verify_func(line) _verify_func2(line) +# define _verify_func2(line) verify_func_ ## line +#else +# define verify_same_types(expr1,expr2) extern void verify_func (int) +#endif + +/* 7.18.1.1. Exact-width integer types */ +/* 7.18.2.1. Limits of exact-width integer types */ + +int8_t a1[3] = { INT8_C (17), INT8_MIN, INT8_MAX }; +verify (TYPE_MINIMUM (int8_t) == INT8_MIN); +verify (TYPE_MAXIMUM (int8_t) == INT8_MAX); +verify_same_types (INT8_MIN, (int8_t) 0 + 0); +verify_same_types (INT8_MAX, (int8_t) 0 + 0); + +int16_t a2[3] = { INT16_C (17), INT16_MIN, INT16_MAX }; +verify (TYPE_MINIMUM (int16_t) == INT16_MIN); +verify (TYPE_MAXIMUM (int16_t) == INT16_MAX); +verify_same_types (INT16_MIN, (int16_t) 0 + 0); +verify_same_types (INT16_MAX, (int16_t) 0 + 0); + +int32_t a3[3] = { INT32_C (17), INT32_MIN, INT32_MAX }; +verify (TYPE_MINIMUM (int32_t) == INT32_MIN); +verify (TYPE_MAXIMUM (int32_t) == INT32_MAX); +verify_same_types (INT32_MIN, (int32_t) 0 + 0); +verify_same_types (INT32_MAX, (int32_t) 0 + 0); + +#ifdef INT64_MAX +int64_t a4[3] = { INT64_C (17), INT64_MIN, INT64_MAX }; +verify (TYPE_MINIMUM (int64_t) == INT64_MIN); +verify (TYPE_MAXIMUM (int64_t) == INT64_MAX); +verify_same_types (INT64_MIN, (int64_t) 0 + 0); +verify_same_types (INT64_MAX, (int64_t) 0 + 0); +#endif + +uint8_t b1[2] = { UINT8_C (17), UINT8_MAX }; +verify (TYPE_MAXIMUM (uint8_t) == UINT8_MAX); +verify_same_types (UINT8_MAX, (uint8_t) 0 + 0); + +uint16_t b2[2] = { UINT16_C (17), UINT16_MAX }; +verify (TYPE_MAXIMUM (uint16_t) == UINT16_MAX); +verify_same_types (UINT16_MAX, (uint16_t) 0 + 0); + +uint32_t b3[2] = { UINT32_C (17), UINT32_MAX }; +verify (TYPE_MAXIMUM (uint32_t) == UINT32_MAX); +verify_same_types (UINT32_MAX, (uint32_t) 0 + 0); + +#ifdef UINT64_MAX +uint64_t b4[2] = { UINT64_C (17), UINT64_MAX }; +verify (TYPE_MAXIMUM (uint64_t) == UINT64_MAX); +verify_same_types (UINT64_MAX, (uint64_t) 0 + 0); +#endif + +#if INT8_MIN && INT8_MAX && INT16_MIN && INT16_MAX && INT32_MIN && INT32_MAX +/* ok */ +#else +err or; +#endif + +#if UINT8_MAX && UINT16_MAX && UINT32_MAX +/* ok */ +#else +err or; +#endif + +/* 7.18.1.2. Minimum-width integer types */ +/* 7.18.2.2. Limits of minimum-width integer types */ + +int_least8_t c1[3] = { 17, INT_LEAST8_MIN, INT_LEAST8_MAX }; +verify (TYPE_MINIMUM (int_least8_t) == INT_LEAST8_MIN); +verify (TYPE_MAXIMUM (int_least8_t) == INT_LEAST8_MAX); +verify_same_types (INT_LEAST8_MIN, (int_least8_t) 0 + 0); +verify_same_types (INT_LEAST8_MAX, (int_least8_t) 0 + 0); + +int_least16_t c2[3] = { 17, INT_LEAST16_MIN, INT_LEAST16_MAX }; +verify (TYPE_MINIMUM (int_least16_t) == INT_LEAST16_MIN); +verify (TYPE_MAXIMUM (int_least16_t) == INT_LEAST16_MAX); +verify_same_types (INT_LEAST16_MIN, (int_least16_t) 0 + 0); +verify_same_types (INT_LEAST16_MAX, (int_least16_t) 0 + 0); + +int_least32_t c3[3] = { 17, INT_LEAST32_MIN, INT_LEAST32_MAX }; +verify (TYPE_MINIMUM (int_least32_t) == INT_LEAST32_MIN); +verify (TYPE_MAXIMUM (int_least32_t) == INT_LEAST32_MAX); +verify_same_types (INT_LEAST32_MIN, (int_least32_t) 0 + 0); +verify_same_types (INT_LEAST32_MAX, (int_least32_t) 0 + 0); + +#ifdef INT_LEAST64_MAX +int_least64_t c4[3] = { 17, INT_LEAST64_MIN, INT_LEAST64_MAX }; +verify (TYPE_MINIMUM (int_least64_t) == INT_LEAST64_MIN); +verify (TYPE_MAXIMUM (int_least64_t) == INT_LEAST64_MAX); +verify_same_types (INT_LEAST64_MIN, (int_least64_t) 0 + 0); +verify_same_types (INT_LEAST64_MAX, (int_least64_t) 0 + 0); +#endif + +uint_least8_t d1[2] = { 17, UINT_LEAST8_MAX }; +verify (TYPE_MAXIMUM (uint_least8_t) == UINT_LEAST8_MAX); +verify_same_types (UINT_LEAST8_MAX, (uint_least8_t) 0 + 0); + +uint_least16_t d2[2] = { 17, UINT_LEAST16_MAX }; +verify (TYPE_MAXIMUM (uint_least16_t) == UINT_LEAST16_MAX); +verify_same_types (UINT_LEAST16_MAX, (uint_least16_t) 0 + 0); + +uint_least32_t d3[2] = { 17, UINT_LEAST32_MAX }; +verify (TYPE_MAXIMUM (uint_least32_t) == UINT_LEAST32_MAX); +verify_same_types (UINT_LEAST32_MAX, (uint_least32_t) 0 + 0); + +#ifdef UINT_LEAST64_MAX +uint_least64_t d4[2] = { 17, UINT_LEAST64_MAX }; +verify (TYPE_MAXIMUM (uint_least64_t) == UINT_LEAST64_MAX); +verify_same_types (UINT_LEAST64_MAX, (uint_least64_t) 0 + 0); +#endif + +#if INT_LEAST8_MIN && INT_LEAST8_MAX && INT_LEAST16_MIN && INT_LEAST16_MAX && INT_LEAST32_MIN && INT_LEAST32_MAX +/* ok */ +#else +err or; +#endif + +#if UINT_LEAST8_MAX && UINT_LEAST16_MAX && UINT_LEAST32_MAX +/* ok */ +#else +err or; +#endif + +/* 7.18.1.3. Fastest minimum-width integer types */ +/* 7.18.2.3. Limits of fastest minimum-width integer types */ + +int_fast8_t e1[3] = { 17, INT_FAST8_MIN, INT_FAST8_MAX }; +verify (TYPE_MINIMUM (int_fast8_t) == INT_FAST8_MIN); +verify (TYPE_MAXIMUM (int_fast8_t) == INT_FAST8_MAX); +verify_same_types (INT_FAST8_MIN, (int_fast8_t) 0 + 0); +verify_same_types (INT_FAST8_MAX, (int_fast8_t) 0 + 0); + +int_fast16_t e2[3] = { 17, INT_FAST16_MIN, INT_FAST16_MAX }; +verify (TYPE_MINIMUM (int_fast16_t) == INT_FAST16_MIN); +verify (TYPE_MAXIMUM (int_fast16_t) == INT_FAST16_MAX); +verify_same_types (INT_FAST16_MIN, (int_fast16_t) 0 + 0); +verify_same_types (INT_FAST16_MAX, (int_fast16_t) 0 + 0); + +int_fast32_t e3[3] = { 17, INT_FAST32_MIN, INT_FAST32_MAX }; +verify (TYPE_MINIMUM (int_fast32_t) == INT_FAST32_MIN); +verify (TYPE_MAXIMUM (int_fast32_t) == INT_FAST32_MAX); +verify_same_types (INT_FAST32_MIN, (int_fast32_t) 0 + 0); +verify_same_types (INT_FAST32_MAX, (int_fast32_t) 0 + 0); + +#ifdef INT_FAST64_MAX +int_fast64_t e4[3] = { 17, INT_FAST64_MIN, INT_FAST64_MAX }; +verify (TYPE_MINIMUM (int_fast64_t) == INT_FAST64_MIN); +verify (TYPE_MAXIMUM (int_fast64_t) == INT_FAST64_MAX); +verify_same_types (INT_FAST64_MIN, (int_fast64_t) 0 + 0); +verify_same_types (INT_FAST64_MAX, (int_fast64_t) 0 + 0); +#endif + +uint_fast8_t f1[2] = { 17, UINT_FAST8_MAX }; +verify (TYPE_MAXIMUM (uint_fast8_t) == UINT_FAST8_MAX); +verify_same_types (UINT_FAST8_MAX, (uint_fast8_t) 0 + 0); + +uint_fast16_t f2[2] = { 17, UINT_FAST16_MAX }; +verify (TYPE_MAXIMUM (uint_fast16_t) == UINT_FAST16_MAX); +verify_same_types (UINT_FAST16_MAX, (uint_fast16_t) 0 + 0); + +uint_fast32_t f3[2] = { 17, UINT_FAST32_MAX }; +verify (TYPE_MAXIMUM (uint_fast32_t) == UINT_FAST32_MAX); +verify_same_types (UINT_FAST32_MAX, (uint_fast32_t) 0 + 0); + +#ifdef UINT_FAST64_MAX +uint_fast64_t f4[2] = { 17, UINT_FAST64_MAX }; +verify (TYPE_MAXIMUM (uint_fast64_t) == UINT_FAST64_MAX); +verify_same_types (UINT_FAST64_MAX, (uint_fast64_t) 0 + 0); +#endif + +#if INT_FAST8_MIN && INT_FAST8_MAX && INT_FAST16_MIN && INT_FAST16_MAX && INT_FAST32_MIN && INT_FAST32_MAX +/* ok */ +#else +err or; +#endif + +#if UINT_FAST8_MAX && UINT_FAST16_MAX && UINT_FAST32_MAX +/* ok */ +#else +err or; +#endif + +/* 7.18.1.4. Integer types capable of holding object pointers */ +/* 7.18.2.4. Limits of integer types capable of holding object pointers */ + +intptr_t g[3] = { 17, INTPTR_MIN, INTPTR_MAX }; +verify (sizeof (void *) <= sizeof (intptr_t)); +verify (TYPE_MINIMUM (intptr_t) == INTPTR_MIN); +verify (TYPE_MAXIMUM (intptr_t) == INTPTR_MAX); +verify_same_types (INTPTR_MIN, (intptr_t) 0 + 0); +verify_same_types (INTPTR_MAX, (intptr_t) 0 + 0); + +uintptr_t h[2] = { 17, UINTPTR_MAX }; +verify (sizeof (void *) <= sizeof (uintptr_t)); +verify (TYPE_MAXIMUM (uintptr_t) == UINTPTR_MAX); +verify_same_types (UINTPTR_MAX, (uintptr_t) 0 + 0); + +#if INTPTR_MIN && INTPTR_MAX && UINTPTR_MAX +/* ok */ +#else +err or; +#endif + +/* 7.18.1.5. Greatest-width integer types */ +/* 7.18.2.5. Limits of greatest-width integer types */ + +intmax_t i[3] = { INTMAX_C (17), INTMAX_MIN, INTMAX_MAX }; +verify (TYPE_MINIMUM (intmax_t) == INTMAX_MIN); +verify (TYPE_MAXIMUM (intmax_t) == INTMAX_MAX); +verify_same_types (INTMAX_MIN, (intmax_t) 0 + 0); +verify_same_types (INTMAX_MAX, (intmax_t) 0 + 0); + +uintmax_t j[2] = { UINTMAX_C (17), UINTMAX_MAX }; +verify (TYPE_MAXIMUM (uintmax_t) == UINTMAX_MAX); +verify_same_types (UINTMAX_MAX, (uintmax_t) 0 + 0); + +/* As of 2007, Sun C and HP-UX 10.20 cc don't support 'long long' constants in + the preprocessor. */ +#if !(defined __SUNPRO_C || (defined __hpux && !defined __GNUC__)) +#if INTMAX_MIN && INTMAX_MAX && UINTMAX_MAX +/* ok */ +#else +err or; +#endif +#endif + +/* 7.18.3. Limits of other integer types */ + +#include <stddef.h> + +verify (TYPE_MINIMUM (ptrdiff_t) == PTRDIFF_MIN); +verify (TYPE_MAXIMUM (ptrdiff_t) == PTRDIFF_MAX); +verify_same_types (PTRDIFF_MIN, (ptrdiff_t) 0 + 0); +verify_same_types (PTRDIFF_MAX, (ptrdiff_t) 0 + 0); + +#if PTRDIFF_MIN && PTRDIFF_MAX +/* ok */ +#else +err or; +#endif + +#include <signal.h> + +verify (TYPE_MINIMUM (sig_atomic_t) == SIG_ATOMIC_MIN); +verify (TYPE_MAXIMUM (sig_atomic_t) == SIG_ATOMIC_MAX); +verify_same_types (SIG_ATOMIC_MIN, (sig_atomic_t) 0 + 0); +verify_same_types (SIG_ATOMIC_MAX, (sig_atomic_t) 0 + 0); + +#if SIG_ATOMIC_MIN != 17 && SIG_ATOMIC_MAX +/* ok */ +#else +err or; +#endif + +verify (TYPE_MAXIMUM (size_t) == SIZE_MAX); +verify_same_types (SIZE_MAX, (size_t) 0 + 0); + +#if SIZE_MAX +/* ok */ +#else +err or; +#endif + +#if HAVE_WCHAR_T +verify (TYPE_MINIMUM (wchar_t) == WCHAR_MIN); +verify (TYPE_MAXIMUM (wchar_t) == WCHAR_MAX); +verify_same_types (WCHAR_MIN, (wchar_t) 0 + 0); +verify_same_types (WCHAR_MAX, (wchar_t) 0 + 0); + +# if WCHAR_MIN != 17 && WCHAR_MAX +/* ok */ +# else +err or; +# endif +#endif + +#if HAVE_WINT_T +# include <wchar.h> + +verify (TYPE_MINIMUM (wint_t) == WINT_MIN); +verify (TYPE_MAXIMUM (wint_t) == WINT_MAX); +verify_same_types (WINT_MIN, (wint_t) 0 + 0); +verify_same_types (WINT_MAX, (wint_t) 0 + 0); + +# if WINT_MIN != 17 && WINT_MAX +/* ok */ +# else +err or; +# endif +#endif + +/* 7.18.4. Macros for integer constants */ + +verify (INT8_C (17) == 17); +verify_same_types (INT8_C (17), (int_least8_t)0 + 0); +verify (UINT8_C (17) == 17); +verify_same_types (UINT8_C (17), (uint_least8_t)0 + 0); + +verify (INT16_C (17) == 17); +verify_same_types (INT16_C (17), (int_least16_t)0 + 0); +verify (UINT16_C (17) == 17); +verify_same_types (UINT16_C (17), (uint_least16_t)0 + 0); + +verify (INT32_C (17) == 17); +verify_same_types (INT32_C (17), (int_least32_t)0 + 0); +verify (UINT32_C (17) == 17); +verify_same_types (UINT32_C (17), (uint_least32_t)0 + 0); + +#ifdef INT64_C +verify (INT64_C (17) == 17); +verify_same_types (INT64_C (17), (int_least64_t)0 + 0); +#endif +#ifdef UINT64_C +verify (UINT64_C (17) == 17); +verify_same_types (UINT64_C (17), (uint_least64_t)0 + 0); +#endif + +verify (INTMAX_C (17) == 17); +verify_same_types (INTMAX_C (17), (intmax_t)0 + 0); +verify (UINTMAX_C (17) == 17); +verify_same_types (UINTMAX_C (17), (uintmax_t)0 + 0); + +/* Use _GL_VERIFY (with a fixed-length diagnostic string) rather than verify, + because the latter would require forming each stringified expression, and + many of these would be so long as to trigger a warning/error like this: + + test-stdint.c:407:1: error: string length '6980' is greater than the \ + length '4095' ISO C99 compilers are required to support \ + [-Werror=overlength-strings] + */ +#define verify_width(width, min, max) \ + _GL_VERIFY ((max) >> ((width) - 1 - ((min) < 0)) == 1, \ + "verify_width check") + +/* Macros specified by ISO/IEC TS 18661-1:2014. */ + +#ifdef INT8_MAX +verify_width (INT8_WIDTH, INT8_MIN, INT8_MAX); +#endif +#ifdef UINT8_MAX +verify_width (UINT8_WIDTH, 0, UINT8_MAX); +#endif +#ifdef INT16_MAX +verify_width (INT16_WIDTH, INT16_MIN, INT16_MAX); +#endif +#ifdef UINT16_MAX +verify_width (UINT16_WIDTH, 0, UINT16_MAX); +#endif +#ifdef INT32_MAX +verify_width (INT32_WIDTH, INT32_MIN, INT32_MAX); +#endif +#ifdef UINT32_MAX +verify_width (UINT32_WIDTH, 0, UINT32_MAX); +#endif +#ifdef INT64_MAX +verify_width (INT64_WIDTH, INT64_MIN, INT64_MAX); +#endif +#ifdef UINT64_MAX +verify_width (UINT64_WIDTH, 0, UINT64_MAX); +#endif +verify_width (INT_LEAST8_WIDTH, INT_LEAST8_MIN, INT_LEAST8_MAX); +verify_width (UINT_LEAST8_WIDTH, 0, UINT_LEAST8_MAX); +verify_width (INT_LEAST16_WIDTH, INT_LEAST16_MIN, INT_LEAST16_MAX); +verify_width (UINT_LEAST16_WIDTH, 0, UINT_LEAST16_MAX); +verify_width (INT_LEAST32_WIDTH, INT_LEAST32_MIN, INT_LEAST32_MAX); +verify_width (UINT_LEAST32_WIDTH, 0, UINT_LEAST32_MAX); +verify_width (INT_LEAST64_WIDTH, INT_LEAST64_MIN, INT_LEAST64_MAX); +verify_width (UINT_LEAST64_WIDTH, 0, UINT_LEAST64_MAX); +verify_width (INT_FAST8_WIDTH, INT_FAST8_MIN, INT_FAST8_MAX); +verify_width (UINT_FAST8_WIDTH, 0, UINT_FAST8_MAX); +verify_width (INT_FAST16_WIDTH, INT_FAST16_MIN, INT_FAST16_MAX); +verify_width (UINT_FAST16_WIDTH, 0, UINT_FAST16_MAX); +verify_width (INT_FAST32_WIDTH, INT_FAST32_MIN, INT_FAST32_MAX); +verify_width (UINT_FAST32_WIDTH, 0, UINT_FAST32_MAX); +verify_width (INT_FAST64_WIDTH, INT_FAST64_MIN, INT_FAST64_MAX); +verify_width (UINT_FAST64_WIDTH, 0, UINT_FAST64_MAX); +verify_width (INTPTR_WIDTH, INTPTR_MIN, INTPTR_MAX); +verify_width (UINTPTR_WIDTH, 0, UINTPTR_MAX); +verify_width (INTMAX_WIDTH, INTMAX_MIN, INTMAX_MAX); +verify_width (UINTMAX_WIDTH, 0, UINTMAX_MAX); +verify_width (PTRDIFF_WIDTH, PTRDIFF_MIN, PTRDIFF_MAX); +verify_width (SIZE_WIDTH, 0, SIZE_MAX); +verify_width (WCHAR_WIDTH, WCHAR_MIN, WCHAR_MAX); +#ifdef WINT_MAX +verify_width (WINT_WIDTH, WINT_MIN, WINT_MAX); +#endif +#ifdef SIG_ATOMIC_MAX +verify_width (SIG_ATOMIC_WIDTH, SIG_ATOMIC_MIN, SIG_ATOMIC_MAX); +#endif + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tests/test-stdio.c b/gnulib-tests/test-stdio.c new file mode 100644 index 0000000..55a34db --- /dev/null +++ b/gnulib-tests/test-stdio.c @@ -0,0 +1,43 @@ +/* Test of <stdio.h> substitute. + Copyright (C) 2007, 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <stdio.h> + +#include "verify.h" + +/* Check that the various SEEK_* macros are defined. */ +int sk[] = { SEEK_CUR, SEEK_END, SEEK_SET }; + +/* Check that NULL can be passed through varargs as a pointer type, + per POSIX 2008. */ +verify (sizeof NULL == sizeof (void *)); + +/* Check that the types are all defined. */ +fpos_t t1; +off_t t2; +size_t t3; +ssize_t t4; +va_list t5; + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tests/test-stdlib.c b/gnulib-tests/test-stdlib.c new file mode 100644 index 0000000..1314d77 --- /dev/null +++ b/gnulib-tests/test-stdlib.c @@ -0,0 +1,54 @@ +/* Test of <stdlib.h> substitute. + Copyright (C) 2007, 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <stdlib.h> + +#include "verify.h" + +/* Check that EXIT_SUCCESS is 0, per POSIX. */ +static int exitcode = EXIT_SUCCESS; +#if EXIT_SUCCESS +"oops" +#endif + +/* Check for GNU value (not guaranteed by POSIX, but is guaranteed by + gnulib). */ +#if EXIT_FAILURE != 1 +"oops" +#endif + +/* Check that NULL can be passed through varargs as a pointer type, + per POSIX 2008. */ +verify (sizeof NULL == sizeof (void *)); + +#if GNULIB_TEST_SYSTEM_POSIX +# include "test-sys_wait.h" +#else +# define test_sys_wait_macros() 0 +#endif + +int +main (void) +{ + if (test_sys_wait_macros ()) + return 1; + + return exitcode; +} diff --git a/gnulib-tests/test-strerror.c b/gnulib-tests/test-strerror.c new file mode 100644 index 0000000..16afe00 --- /dev/null +++ b/gnulib-tests/test-strerror.c @@ -0,0 +1,75 @@ +/* Test of strerror() function. + Copyright (C) 2007-2020 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, 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2007. */ + +#include <config.h> + +#include <string.h> + +#include "signature.h" +SIGNATURE_CHECK (strerror, char *, (int)); + +#include <errno.h> + +#include "macros.h" + +int +main (void) +{ + char *str; + + errno = 0; + str = strerror (EACCES); + ASSERT (str); + ASSERT (*str); + ASSERT (errno == 0); + + errno = 0; + str = strerror (ETIMEDOUT); + ASSERT (str); + ASSERT (*str); + ASSERT (errno == 0); + + errno = 0; + str = strerror (EOVERFLOW); + ASSERT (str); + ASSERT (*str); + ASSERT (errno == 0); + + /* POSIX requires strerror (0) to succeed. Reject use of "Unknown + error", but allow "Success", "No error", or even Solaris' "Error + 0" which are distinct patterns from true out-of-range strings. + http://austingroupbugs.net/view.php?id=382 */ + errno = 0; + str = strerror (0); + ASSERT (str); + ASSERT (*str); + ASSERT (errno == 0); + ASSERT (strstr (str, "nknown") == NULL); + ASSERT (strstr (str, "ndefined") == NULL); + + /* POSIX requires strerror to produce a non-NULL result for all + inputs; as an extension, we also guarantee a non-empty result. + Reporting EINVAL is optional. */ + errno = 0; + str = strerror (-3); + ASSERT (str); + ASSERT (*str); + ASSERT (errno == 0 || errno == EINVAL); + + return 0; +} diff --git a/gnulib-tests/test-strerror_r.c b/gnulib-tests/test-strerror_r.c new file mode 100644 index 0000000..b11d6fd --- /dev/null +++ b/gnulib-tests/test-strerror_r.c @@ -0,0 +1,181 @@ +/* Test of strerror_r() function. + Copyright (C) 2007-2020 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, 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <string.h> + +#include "signature.h" +SIGNATURE_CHECK (strerror_r, int, (int, char *, size_t)); + +#include <errno.h> + +#include "macros.h" + +int +main (void) +{ + char buf[100]; + int ret; + + /* Test results with valid errnum and enough room. */ + + errno = 0; + buf[0] = '\0'; + ASSERT (strerror_r (EACCES, buf, sizeof buf) == 0); + ASSERT (buf[0] != '\0'); + ASSERT (errno == 0); + ASSERT (strlen (buf) < sizeof buf); + + errno = 0; + buf[0] = '\0'; + ASSERT (strerror_r (ETIMEDOUT, buf, sizeof buf) == 0); + ASSERT (buf[0] != '\0'); + ASSERT (errno == 0); + ASSERT (strlen (buf) < sizeof buf); + + errno = 0; + buf[0] = '\0'; + ASSERT (strerror_r (EOVERFLOW, buf, sizeof buf) == 0); + ASSERT (buf[0] != '\0'); + ASSERT (errno == 0); + ASSERT (strlen (buf) < sizeof buf); + + /* POSIX requires strerror (0) to succeed. Reject use of "Unknown + error", but allow "Success", "No error", or even Solaris' "Error + 0" which are distinct patterns from true out-of-range strings. + http://austingroupbugs.net/view.php?id=382 */ + errno = 0; + buf[0] = '\0'; + ret = strerror_r (0, buf, sizeof buf); + ASSERT (ret == 0); + ASSERT (buf[0]); + ASSERT (errno == 0); + ASSERT (strstr (buf, "nknown") == NULL); + ASSERT (strstr (buf, "ndefined") == NULL); + + /* Test results with out-of-range errnum and enough room. POSIX + allows an empty string on success, and allows an unchanged buf on + error, but these are not useful, so we guarantee contents. */ + errno = 0; + buf[0] = '^'; + ret = strerror_r (-3, buf, sizeof buf); + ASSERT (ret == 0 || ret == EINVAL); + ASSERT (buf[0] != '^'); + ASSERT (*buf); + ASSERT (errno == 0); + ASSERT (strlen (buf) < sizeof buf); + + /* Test results with a too small buffer. POSIX requires an error; + only ERANGE for 0 and valid errors, and a choice of ERANGE or + EINVAL for out-of-range values. On error, POSIX permits buf to + be empty, unchanged, or unterminated, but these are not useful, + so we guarantee NUL-terminated truncated contents for all but + size 0. http://austingroupbugs.net/view.php?id=398. Also ensure + that no out-of-bounds writes occur. */ + { + int errs[] = { EACCES, 0, -3, }; + int j; + + buf[sizeof buf - 1] = '\0'; + for (j = 0; j < SIZEOF (errs); j++) + { + int err = errs[j]; + char buf2[sizeof buf] = ""; + size_t len; + size_t i; + + strerror_r (err, buf2, sizeof buf2); + len = strlen (buf2); + ASSERT (len < sizeof buf); + + for (i = 0; i <= len; i++) + { + memset (buf, '^', sizeof buf - 1); + errno = 0; + ret = strerror_r (err, buf, i); + ASSERT (errno == 0); + if (j == 2) + ASSERT (ret == ERANGE || ret == EINVAL); + else + ASSERT (ret == ERANGE); + if (i) + { + ASSERT (strncmp (buf, buf2, i - 1) == 0); + ASSERT (buf[i - 1] == '\0'); + } + ASSERT (strspn (buf + i, "^") == sizeof buf - 1 - i); + } + + strcpy (buf, "BADFACE"); + errno = 0; + ret = strerror_r (err, buf, len + 1); + ASSERT (ret != ERANGE); + ASSERT (errno == 0); + ASSERT (strcmp (buf, buf2) == 0); + } + } + +#if GNULIB_STRERROR + /* Test that strerror_r does not clobber strerror buffer. On some + platforms, this test can only succeed if gnulib also replaces + strerror. */ + { + const char *msg1; + const char *msg2; + const char *msg3; + const char *msg4; + char *str1; + char *str2; + char *str3; + char *str4; + + msg1 = strerror (ENOENT); + ASSERT (msg1); + str1 = strdup (msg1); + ASSERT (str1); + + msg2 = strerror (ERANGE); + ASSERT (msg2); + str2 = strdup (msg2); + ASSERT (str2); + + msg3 = strerror (-4); + ASSERT (msg3); + str3 = strdup (msg3); + ASSERT (str3); + + msg4 = strerror (1729576); + ASSERT (msg4); + str4 = strdup (msg4); + ASSERT (str4); + + strerror_r (EACCES, buf, sizeof buf); + strerror_r (-5, buf, sizeof buf); + ASSERT (msg1 == msg2 || msg1 == msg4 || STREQ (msg1, str1)); + ASSERT (msg2 == msg4 || STREQ (msg2, str2)); + ASSERT (msg3 == msg4 || STREQ (msg3, str3)); + ASSERT (STREQ (msg4, str4)); + + free (str1); + free (str2); + free (str3); + free (str4); + } +#endif + + return 0; +} diff --git a/gnulib-tests/test-striconv.c b/gnulib-tests/test-striconv.c new file mode 100644 index 0000000..683b037 --- /dev/null +++ b/gnulib-tests/test-striconv.c @@ -0,0 +1,180 @@ +/* Test of character set conversion. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include "striconv.h" + +#if HAVE_ICONV +# include <iconv.h> +#endif + +#include <errno.h> +#include <stdlib.h> +#include <string.h> + +#include "macros.h" + +int +main () +{ +#if HAVE_ICONV + /* Assume that iconv() supports at least the encodings ASCII, ISO-8859-1, + and UTF-8. */ + iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1"); + iconv_t cd_utf8_to_88591 = iconv_open ("ISO-8859-1", "UTF-8"); + + ASSERT (cd_88591_to_utf8 != (iconv_t)(-1)); + ASSERT (cd_utf8_to_88591 != (iconv_t)(-1)); + + /* ------------------------- Test mem_cd_iconv() ------------------------- */ + + /* Test conversion from ISO-8859-1 to UTF-8 with no errors. */ + { + static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; + static const char expected[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237"; + char *result = NULL; + size_t length = 0; + int retval = mem_cd_iconv (input, strlen (input), cd_88591_to_utf8, + &result, &length); + ASSERT (retval == 0); + ASSERT (length == strlen (expected)); + ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0); + free (result); + } + + /* Test conversion from UTF-8 to ISO-8859-1 with no errors. */ + { + static const char input[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237"; + static const char expected[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; + char *result = NULL; + size_t length = 0; + int retval = mem_cd_iconv (input, strlen (input), cd_utf8_to_88591, + &result, &length); + ASSERT (retval == 0); + ASSERT (length == strlen (expected)); + ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0); + free (result); + } + + /* Test conversion from UTF-8 to ISO-8859-1 with EILSEQ. */ + { + static const char input[] = "\342\202\254"; /* EURO SIGN */ + char *result = NULL; + size_t length = 0; + int retval = mem_cd_iconv (input, strlen (input), cd_utf8_to_88591, + &result, &length); + ASSERT (retval == -1 && errno == EILSEQ); + ASSERT (result == NULL); + } + + /* Test conversion from UTF-8 to ISO-8859-1 with EINVAL. */ + { + static const char input[] = "\342"; + char *result = NULL; + size_t length = 0; + int retval = mem_cd_iconv (input, strlen (input), cd_utf8_to_88591, + &result, &length); + ASSERT (retval == 0); + ASSERT (length == 0); + free (result); + } + + /* ------------------------- Test str_cd_iconv() ------------------------- */ + + /* Test conversion from ISO-8859-1 to UTF-8 with no errors. */ + { + static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; + static const char expected[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237"; + char *result = str_cd_iconv (input, cd_88591_to_utf8); + ASSERT (result != NULL); + ASSERT (strcmp (result, expected) == 0); + free (result); + } + + /* Test conversion from UTF-8 to ISO-8859-1 with no errors. */ + { + static const char input[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237"; + static const char expected[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; + char *result = str_cd_iconv (input, cd_utf8_to_88591); + ASSERT (result != NULL); + ASSERT (strcmp (result, expected) == 0); + free (result); + } + + /* Test conversion from UTF-8 to ISO-8859-1 with EILSEQ. */ + { + static const char input[] = "Costs: 27 \342\202\254"; /* EURO SIGN */ + char *result = str_cd_iconv (input, cd_utf8_to_88591); + ASSERT (result == NULL && errno == EILSEQ); + } + + /* Test conversion from UTF-8 to ISO-8859-1 with EINVAL. */ + { + static const char input[] = "\342"; + char *result = str_cd_iconv (input, cd_utf8_to_88591); + ASSERT (result != NULL); + ASSERT (strcmp (result, "") == 0); + free (result); + } + + iconv_close (cd_88591_to_utf8); + iconv_close (cd_utf8_to_88591); + + /* -------------------------- Test str_iconv() -------------------------- */ + + /* Test conversion from ISO-8859-1 to UTF-8 with no errors. */ + { + static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; + static const char expected[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237"; + char *result = str_iconv (input, "ISO-8859-1", "UTF-8"); + ASSERT (result != NULL); + ASSERT (strcmp (result, expected) == 0); + free (result); + } + + /* Test conversion from UTF-8 to ISO-8859-1 with no errors. */ + { + static const char input[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237"; + static const char expected[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; + char *result = str_iconv (input, "UTF-8", "ISO-8859-1"); + ASSERT (result != NULL); + ASSERT (strcmp (result, expected) == 0); + free (result); + } + + /* Test conversion from UTF-8 to ISO-8859-1 with EILSEQ. */ + { + static const char input[] = "Costs: 27 \342\202\254"; /* EURO SIGN */ + char *result = str_iconv (input, "UTF-8", "ISO-8859-1"); + ASSERT (result == NULL && errno == EILSEQ); + } + + /* Test conversion from UTF-8 to ISO-8859-1 with EINVAL. */ + { + static const char input[] = "\342"; + char *result = str_iconv (input, "UTF-8", "ISO-8859-1"); + ASSERT (result != NULL); + ASSERT (strcmp (result, "") == 0); + free (result); + } + +#endif + + return 0; +} diff --git a/gnulib-tests/test-string.c b/gnulib-tests/test-string.c new file mode 100644 index 0000000..2151f7a --- /dev/null +++ b/gnulib-tests/test-string.c @@ -0,0 +1,33 @@ +/* Test of <string.h> substitute. + Copyright (C) 2007, 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <string.h> + +#include "verify.h" + +/* Check that NULL can be passed through varargs as a pointer type, + per POSIX 2008. */ +verify (sizeof NULL == sizeof (void *)); + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tests/test-strncat.c b/gnulib-tests/test-strncat.c new file mode 100644 index 0000000..d36fe07 --- /dev/null +++ b/gnulib-tests/test-strncat.c @@ -0,0 +1,62 @@ +/* Test of strncat() function. + Copyright (C) 2010-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2010. */ + +#include <config.h> + +#include <string.h> + +#include "signature.h" +SIGNATURE_CHECK (strncat, char *, (char *, const char *, size_t)); + +#include <stdlib.h> + +#include "zerosize-ptr.h" +#include "macros.h" + +#define UNIT char +#define U_STRNCAT strncat +#define MAGIC ((char) 0xBA) +#include "unistr/test-strncat.h" + +int +main () +{ + /* Simple string. */ + { /* "Grüß Gott. Здравствуйте! x=(-b±sqrt(b²-4ac))/(2a) 日本語,中文,한글" + in UTF-8 encoding. */ + static const char input[] = + { 'G', 'r', (char) 0xC3, (char) 0xBC, (char) 0xC3, (char) 0x9F, ' ', + 'G', 'o', 't', 't', '.', ' ', (char) 0xD0, (char) 0x97, (char) 0xD0, + (char) 0xB4, (char) 0xD1, (char) 0x80, (char) 0xD0, (char) 0xB0, + (char) 0xD0, (char) 0xB2, (char) 0xD1, (char) 0x81, (char) 0xD1, + (char) 0x82, (char) 0xD0, (char) 0xB2, (char) 0xD1, (char) 0x83, + (char) 0xD0, (char) 0xB9, (char) 0xD1, (char) 0x82, (char) 0xD0, + (char) 0xB5, '!', ' ', 'x', '=', '(', '-', 'b', (char) 0xC2, + (char) 0xB1, 's', 'q', 'r', 't', '(', 'b', (char) 0xC2, (char) 0xB2, + '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ', + (char) 0xE6, (char) 0x97, (char) 0xA5, (char) 0xE6, (char) 0x9C, + (char) 0xAC, (char) 0xE8, (char) 0xAA, (char) 0x9E, ',', (char) 0xE4, + (char) 0xB8, (char) 0xAD, (char) 0xE6, (char) 0x96, (char) 0x87, ',', + (char) 0xED, (char) 0x95, (char) 0x9C, (char) 0xEA, (char) 0xB8, + (char) 0x80, '\0' + }; + check (input, SIZEOF (input)); + } + + return 0; +} diff --git a/gnulib-tests/test-strnlen.c b/gnulib-tests/test-strnlen.c new file mode 100644 index 0000000..662903b --- /dev/null +++ b/gnulib-tests/test-strnlen.c @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2010-2020 Free Software Foundation, Inc. + * Written by Eric Blake + * + * 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <string.h> + +#include "signature.h" +SIGNATURE_CHECK (strnlen, size_t, (char const *, size_t)); + +#include <stdlib.h> + +#include "zerosize-ptr.h" +#include "macros.h" + +int +main (void) +{ + size_t i; + char *page_boundary = (char *) zerosize_ptr (); + if (!page_boundary) + { + page_boundary = malloc (0x1000); + ASSERT (page_boundary); + page_boundary += 0x1000; + } + + /* Basic behavior tests. */ + ASSERT (strnlen ("a", 0) == 0); + ASSERT (strnlen ("a", 1) == 1); + ASSERT (strnlen ("a", 2) == 1); + ASSERT (strnlen ("", 0x100000) == 0); + + /* Memory fence and alignment testing. */ + for (i = 0; i < 512; i++) + { + char *start = page_boundary - i; + size_t j = i; + memset (start, 'x', i); + do + { + if (i != j) + { + start[j] = 0; + ASSERT (strnlen (start, i + j) == j); + } + ASSERT (strnlen (start, i) == j); + ASSERT (strnlen (start, j) == j); + } + while (j--); + } + + return 0; +} diff --git a/gnulib-tests/test-strsignal.c b/gnulib-tests/test-strsignal.c new file mode 100644 index 0000000..0316d40 --- /dev/null +++ b/gnulib-tests/test-strsignal.c @@ -0,0 +1,77 @@ +/* Test of strsignal() function. + Copyright (C) 2008-2020 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, 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Colin Watson <cjwatson@debian.org>, 2008. */ + +#include <config.h> + +#include <string.h> + +#include "signature.h" +SIGNATURE_CHECK (strsignal, char *, (int)); + +#include <signal.h> + +#include "macros.h" + +#if HAVE_DECL_SYS_SIGLIST +# define ASSERT_DESCRIPTION(got, expect) +#else +/* In this case, we can guarantee some signal descriptions. */ +# define ASSERT_DESCRIPTION(got, expect) ASSERT (!strcmp (got, expect)) +#endif + +int +main (void) +{ + /* Work around bug in cygwin 1.5.25 <string.h> by declaring str as + const char *, even though strsignal is supposed to return char *. + At any rate, this doesn't hurt, since POSIX 200x states that "The + string pointed to shall not be modified by the application." */ + const char *str; + + /* We try a couple of signals, since not all signals are supported + everywhere. Notwithstanding the #ifdef for neatness, SIGINT should in + fact be available on all platforms. */ + +#ifdef SIGHUP + str = strsignal (SIGHUP); + ASSERT (str); + ASSERT (*str); + ASSERT_DESCRIPTION (str, "Hangup"); +#endif + +#ifdef SIGINT + str = strsignal (SIGINT); + ASSERT (str); + ASSERT (*str); + ASSERT_DESCRIPTION (str, "Interrupt"); +#endif + + /* Test that for out-of-range signal numbers the result is usable. */ + + str = strsignal (-1); + ASSERT (str); + ASSERT (str != (char *) -1); + ASSERT (strlen (str)); + + str = strsignal (9249234); + ASSERT (str); + ASSERT (str != (char *) -1); + ASSERT (strlen (str)); + + return 0; +} diff --git a/gnulib-tests/test-strtod.c b/gnulib-tests/test-strtod.c new file mode 100644 index 0000000..c6b878c --- /dev/null +++ b/gnulib-tests/test-strtod.c @@ -0,0 +1,980 @@ +/* + * Copyright (C) 2008-2020 Free Software Foundation, Inc. + * Written by Eric Blake + * + * 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdlib.h> + +#include "signature.h" +SIGNATURE_CHECK (strtod, double, (char const *, char **)); + +#include <errno.h> +#include <float.h> +#include <math.h> +#include <string.h> + +#include "isnand-nolibm.h" +#include "minus-zero.h" +#include "macros.h" + +/* Avoid requiring -lm just for fabs. */ +#define FABS(d) ((d) < 0.0 ? -(d) : (d)) + +int +main (void) +{ + int status = 0; + /* Subject sequence empty or invalid. */ + { + const char input[] = ""; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.0); + ASSERT (!signbit (result)); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " "; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.0); + ASSERT (!signbit (result)); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " +"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.0); + ASSERT (!signbit (result)); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " ."; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.0); + ASSERT (!signbit (result)); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " .e0"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.0); + ASSERT (!signbit (result)); + ASSERT (ptr == input); /* IRIX 6.5, OSF/1 5.1 */ + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " +.e-0"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.0); + ASSERT (!signbit (result)); + ASSERT (ptr == input); /* IRIX 6.5, OSF/1 5.1 */ + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " in"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.0); + ASSERT (!signbit (result)); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " na"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.0); + ASSERT (!signbit (result)); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + + /* Simple floating point values. */ + { + const char input[] = "1"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = "1."; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = ".5"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.5); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = " 1"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "+1"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "-1"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == -1.0); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "1e0"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + { + const char input[] = "1e+0"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); + ASSERT (ptr == input + 4); + ASSERT (errno == 0); + } + { + const char input[] = "1e-0"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); + ASSERT (ptr == input + 4); + ASSERT (errno == 0); + } + { + const char input[] = "1e1"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 10.0); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + { + const char input[] = "5e-1"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.5); + ASSERT (ptr == input + 4); + ASSERT (errno == 0); + } + + /* Zero. */ + { + const char input[] = "0"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.0); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = ".0"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.0); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "0e0"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.0); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + { + const char input[] = "0e+9999999"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.0); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 10); + ASSERT (errno == 0); + } + { + const char input[] = "0e-9999999"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.0); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 10); + ASSERT (errno == 0); + } + { + const char input[] = "-0"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.0); + ASSERT (!!signbit (result) == !!signbit (minus_zerod)); /* IRIX 6.5, OSF/1 4.0 */ + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + + /* Suffixes. */ + { + const char input[] = "1f"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = "1.f"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "1e"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = "1e+"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = "1e-"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = "1E 2"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); /* HP-UX 11.11, IRIX 6.5, OSF/1 4.0 */ + ASSERT (ptr == input + 1); /* HP-UX 11.11, IRIX 6.5 */ + ASSERT (errno == 0); + } + { + const char input[] = "0x"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.0); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 1); /* glibc-2.3.6, Mac OS X 10.3, FreeBSD 6.2, AIX 7.1 */ + ASSERT (errno == 0); + } + { + const char input[] = "00x1"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.0); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "-0x"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.0); + ASSERT (!!signbit (result) == !!signbit (minus_zerod)); /* Mac OS X 10.3, FreeBSD 6.2, IRIX 6.5, OSF/1 4.0 */ + ASSERT (ptr == input + 2); /* glibc-2.3.6, Mac OS X 10.3, FreeBSD 6.2, AIX 7.1 */ + ASSERT (errno == 0); + } + { + const char input[] = "0xg"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.0); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 1); /* glibc-2.3.6, Mac OS X 10.3, FreeBSD 6.2, AIX 7.1 */ + ASSERT (errno == 0); + } + { + const char input[] = "0xp"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.0); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 1); /* glibc-2.3.6, Mac OS X 10.3, FreeBSD 6.2, AIX 7.1 */ + ASSERT (errno == 0); + } + { + const char input[] = "0XP"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.0); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 1); /* glibc-2.3.6, Mac OS X 10.3, FreeBSD 6.2, AIX 7.1 */ + ASSERT (errno == 0); + } + { + const char input[] = "0x."; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.0); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 1); /* glibc-2.3.6, Mac OS X 10.3, FreeBSD 6.2, AIX 7.1 */ + ASSERT (errno == 0); + } + { + const char input[] = "0xp+"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.0); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 1); /* glibc-2.3.6, Mac OS X 10.3, FreeBSD 6.2, AIX 7.1 */ + ASSERT (errno == 0); + } + { + const char input[] = "0xp+1"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.0); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 1); /* glibc-2.3.6, Mac OS X 10.3, FreeBSD 6.2, AIX 7.1 */ + ASSERT (errno == 0); + } + { + const char input[] = "0x.p+1"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.0); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 1); /* glibc-2.3.6, Mac OS X 10.3, FreeBSD 6.2, AIX 7.1 */ + ASSERT (errno == 0); + } + { + const char input[] = "1p+1"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = "1P+1"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + + /* Overflow/underflow. */ + { + const char input[] = "1E1000000"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == HUGE_VAL); + ASSERT (ptr == input + 9); /* OSF/1 5.1 */ + ASSERT (errno == ERANGE); + } + { + const char input[] = "-1E1000000"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == -HUGE_VAL); + ASSERT (ptr == input + 10); + ASSERT (errno == ERANGE); + } + { + const char input[] = "1E-100000"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (0.0 <= result && result <= DBL_MIN); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 9); + ASSERT (errno == ERANGE); + } + { + const char input[] = "-1E-100000"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (-DBL_MIN <= result && result <= 0.0); +#if 0 + /* FIXME - this is glibc bug 5995; POSIX allows returning positive + 0 on negative underflow, even though quality of implementation + demands preserving the sign. Disable this test until fixed + glibc is more prevalent. */ + ASSERT (!!signbit (result) == !!signbit (minus_zerod)); /* glibc-2.3.6, mingw */ +#endif + ASSERT (ptr == input + 10); + ASSERT (errno == ERANGE); + } + { + const char input[] = "1E 1000000"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); /* HP-UX 11.11, IRIX 6.5, OSF/1 4.0 */ + ASSERT (ptr == input + 1); /* HP-UX 11.11, IRIX 6.5 */ + ASSERT (errno == 0); + } + { + const char input[] = "0x1P 1000000"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); /* NetBSD 3.0, OpenBSD 4.0, AIX 7.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 10, mingw */ + ASSERT (ptr == input + 3); /* NetBSD 3.0, OpenBSD 4.0, AIX 7.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 10, mingw */ + ASSERT (errno == 0); + } + + /* Infinity. */ + { + const char input[] = "iNf"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == HUGE_VAL); /* OpenBSD 4.0, IRIX 6.5, OSF/1 5.1, mingw */ + ASSERT (ptr == input + 3); /* OpenBSD 4.0, HP-UX 11.00, IRIX 6.5, OSF/1 5.1, Solaris 9, mingw */ + ASSERT (errno == 0); /* HP-UX 11.11, OSF/1 4.0 */ + } + { + const char input[] = "-InF"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == -HUGE_VAL); /* OpenBSD 4.0, IRIX 6.5, OSF/1 5.1, mingw */ + ASSERT (ptr == input + 4); /* OpenBSD 4.0, HP-UX 11.00, IRIX 6.5, OSF/1 4.0, Solaris 9, mingw */ + ASSERT (errno == 0); /* HP-UX 11.11, OSF/1 4.0 */ + } + { + const char input[] = "infinite"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == HUGE_VAL); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ + ASSERT (ptr == input + 3); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ + ASSERT (errno == 0); /* OSF/1 4.0 */ + } + { + const char input[] = "infinitY"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == HUGE_VAL); /* OpenBSD 4.0, IRIX 6.5, OSF/1 5.1, mingw */ + ASSERT (ptr == input + 8); /* OpenBSD 4.0, HP-UX 11.00, IRIX 6.5, OSF/1 5.1, Solaris 9, mingw */ + ASSERT (errno == 0); /* HP-UX 11.11, OSF/1 4.0 */ + } + { + const char input[] = "infinitY."; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == HUGE_VAL); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ + ASSERT (ptr == input + 8); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ + ASSERT (errno == 0); /* OSF/1 4.0 */ + } + + /* NaN. Some processors set the sign bit of the default NaN, so all + we check is that using a sign changes the result. */ + { + const char input[] = "-nan"; + char *ptr1; + char *ptr2; + double result1; + double result2; + errno = 0; + result1 = strtod (input, &ptr1); + result2 = strtod (input + 1, &ptr2); +#if 1 /* All known CPUs support NaNs. */ + ASSERT (isnand (result1)); /* OpenBSD 4.0, IRIX 6.5, OSF/1 5.1, mingw */ + ASSERT (isnand (result2)); /* OpenBSD 4.0, IRIX 6.5, OSF/1 5.1, mingw */ +# if 0 + /* Sign bits of NaN is a portability sticking point, not worth + worrying about. */ + ASSERT (!!signbit (result1) != !!signbit (result2)); /* glibc-2.3.6, IRIX 6.5, OSF/1 5.1, mingw */ +# endif + ASSERT (ptr1 == input + 4); /* OpenBSD 4.0, IRIX 6.5, OSF/1 5.1, Solaris 2.5.1, mingw */ + ASSERT (ptr2 == input + 4); /* OpenBSD 4.0, IRIX 6.5, OSF/1 5.1, Solaris 2.5.1, mingw */ + ASSERT (errno == 0); /* HP-UX 11.11 */ +#else + ASSERT (result1 == 0.0); + ASSERT (result2 == 0.0); + ASSERT (!signbit (result1)); + ASSERT (!signbit (result2)); + ASSERT (ptr1 == input); + ASSERT (ptr2 == input + 1); + ASSERT (errno == 0 || errno == EINVAL); +#endif + } + { + const char input[] = "+nan("; + char *ptr1; + char *ptr2; + double result1; + double result2; + errno = 0; + result1 = strtod (input, &ptr1); + result2 = strtod (input + 1, &ptr2); +#if 1 /* All known CPUs support NaNs. */ + ASSERT (isnand (result1)); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ + ASSERT (isnand (result2)); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ + ASSERT (!!signbit (result1) == !!signbit (result2)); + ASSERT (ptr1 == input + 4); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 2.5.1, mingw */ + ASSERT (ptr2 == input + 4); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 2.5.1, mingw */ + ASSERT (errno == 0); +#else + ASSERT (result1 == 0.0); + ASSERT (result2 == 0.0); + ASSERT (!signbit (result1)); + ASSERT (!signbit (result2)); + ASSERT (ptr1 == input); + ASSERT (ptr2 == input + 1); + ASSERT (errno == 0 || errno == EINVAL); +#endif + } + { + const char input[] = "-nan()"; + char *ptr1; + char *ptr2; + double result1; + double result2; + errno = 0; + result1 = strtod (input, &ptr1); + result2 = strtod (input + 1, &ptr2); +#if 1 /* All known CPUs support NaNs. */ + ASSERT (isnand (result1)); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ + ASSERT (isnand (result2)); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ +# if 0 + /* Sign bits of NaN is a portability sticking point, not worth + worrying about. */ + ASSERT (!!signbit (result1) != !!signbit (result2)); /* glibc-2.3.6, IRIX 6.5, OSF/1 5.1, mingw */ +# endif + ASSERT (ptr1 == input + 6); /* glibc-2.3.6, Mac OS X 10.3, FreeBSD 6.2, OpenBSD 4.0, AIX 7.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ + ASSERT (ptr2 == input + 6); /* glibc-2.3.6, Mac OS X 10.3, FreeBSD 6.2, OpenBSD 4.0, AIX 7.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ + ASSERT (errno == 0); +#else + ASSERT (result1 == 0.0); + ASSERT (result2 == 0.0); + ASSERT (!signbit (result1)); + ASSERT (!signbit (result2)); + ASSERT (ptr1 == input); + ASSERT (ptr2 == input + 1); + ASSERT (errno == 0 || errno == EINVAL); +#endif + } + { + const char input[] = " nan()."; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); +#if 1 /* All known CPUs support NaNs. */ + ASSERT (isnand (result)); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ + ASSERT (ptr == input + 6); /* glibc-2.3.6, Mac OS X 10.3, FreeBSD 6.2, OpenBSD 4.0, AIX 7.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ + ASSERT (errno == 0); +#else + ASSERT (result == 0.0); + ASSERT (!signbit (result)); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); +#endif + } + { + /* The behavior of nan(0) is implementation-defined, but all + implementations we know of which handle optional + n-char-sequences handle nan(0) the same as nan(). */ + const char input[] = "-nan(0)."; + char *ptr1; + char *ptr2; + double result1; + double result2; + errno = 0; + result1 = strtod (input, &ptr1); + result2 = strtod (input + 1, &ptr2); +#if 1 /* All known CPUs support NaNs. */ + ASSERT (isnand (result1)); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ + ASSERT (isnand (result2)); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ +# if 0 + /* Sign bits of NaN is a portability sticking point, not worth + worrying about. */ + ASSERT (!!signbit (result1) != !!signbit (result2)); /* glibc-2.3.6, IRIX 6.5, OSF/1 5.1, mingw */ +# endif + ASSERT (ptr1 == input + 7); /* glibc-2.3.6, OpenBSD 4.0, AIX 7.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ + ASSERT (ptr2 == input + 7); /* glibc-2.3.6, OpenBSD 4.0, AIX 7.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ + ASSERT (errno == 0); +#else + ASSERT (result1 == 0.0); + ASSERT (result2 == 0.0); + ASSERT (!signbit (result1)); + ASSERT (!signbit (result2)); + ASSERT (ptr1 == input); + ASSERT (ptr2 == input + 1); + ASSERT (errno == 0 || errno == EINVAL); +#endif + } + + /* Hex. */ + { + const char input[] = "0xa"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 10.0); /* NetBSD 3.0, OpenBSD 4.0, AIX 5.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 10, mingw */ + ASSERT (ptr == input + 3); /* NetBSD 3.0, OpenBSD 4.0, AIX 5.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 10, mingw */ + ASSERT (errno == 0); + } + { + const char input[] = "0XA"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 10.0); /* NetBSD 3.0, OpenBSD 4.0, AIX 5.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 10, mingw */ + ASSERT (ptr == input + 3); /* NetBSD 3.0, OpenBSD 4.0, AIX 5.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 10, mingw */ + ASSERT (errno == 0); + } + { + const char input[] = "0x1p"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); /* NetBSD 3.0, OpenBSD 4.0, AIX 7.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 10, mingw */ + ASSERT (ptr == input + 3); /* NetBSD 3.0, OpenBSD 4.0, AIX 7.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 10, mingw */ + ASSERT (errno == 0); + } + { + const char input[] = "0x1p+"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); /* NetBSD 3.0, OpenBSD 4.0, AIX 5.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 10, mingw */ + ASSERT (ptr == input + 3); /* NetBSD 3.0, OpenBSD 4.0, AIX 5.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 10, mingw */ + ASSERT (errno == 0); + } + { + const char input[] = "0x1P+"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); /* NetBSD 3.0, OpenBSD 4.0, AIX 5.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 10, mingw */ + ASSERT (ptr == input + 3); /* NetBSD 3.0, OpenBSD 4.0, AIX 5.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 10, mingw */ + ASSERT (errno == 0); + } + { + const char input[] = "0x1p+1"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 2.0); /* NetBSD 3.0, OpenBSD 4.0, AIX 5.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 10, mingw */ + ASSERT (ptr == input + 6); /* NetBSD 3.0, OpenBSD 4.0, AIX 5.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 10, mingw */ + ASSERT (errno == 0); + } + { + const char input[] = "0X1P+1"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 2.0); /* NetBSD 3.0, OpenBSD 4.0, AIX 5.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 10, mingw */ + ASSERT (ptr == input + 6); /* NetBSD 3.0, OpenBSD 4.0, AIX 5.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 10, mingw */ + ASSERT (errno == 0); + } + { + const char input[] = "0x1p+1a"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 2.0); /* NetBSD 3.0, OpenBSD 4.0, AIX 5.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 10, mingw */ + ASSERT (ptr == input + 6); /* NetBSD 3.0, OpenBSD 4.0, AIX 5.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 10, mingw */ + ASSERT (errno == 0); + } + { + const char input[] = "0x1p 2"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); /* NetBSD 3.0, OpenBSD 4.0, AIX 7.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 10, mingw */ + ASSERT (ptr == input + 3); /* NetBSD 3.0, OpenBSD 4.0, AIX 7.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 10, mingw */ + ASSERT (errno == 0); + } + + /* Large buffers. */ + { + size_t m = 1000000; + char *input = malloc (m + 1); + if (input) + { + char *ptr; + double result; + memset (input, '\t', m - 1); + input[m - 1] = '1'; + input[m] = '\0'; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); + ASSERT (ptr == input + m); + ASSERT (errno == 0); + } + free (input); + } + { + size_t m = 1000000; + char *input = malloc (m + 1); + if (input) + { + char *ptr; + double result; + memset (input, '0', m - 1); + input[m - 1] = '1'; + input[m] = '\0'; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); + ASSERT (ptr == input + m); + ASSERT (errno == 0); + } + free (input); + } +#if 0 + /* Newlib has an artificial limit of 20000 for the exponent. TODO - + gnulib should fix this. */ + { + size_t m = 1000000; + char *input = malloc (m + 1); + if (input) + { + char *ptr; + double result; + input[0] = '.'; + memset (input + 1, '0', m - 10); + input[m - 9] = '1'; + input[m - 8] = 'e'; + input[m - 7] = '+'; + input[m - 6] = '9'; + input[m - 5] = '9'; + input[m - 4] = '9'; + input[m - 3] = '9'; + input[m - 2] = '9'; + input[m - 1] = '1'; + input[m] = '\0'; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); /* Mac OS X 10.3, FreeBSD 6.2, NetBSD 3.0, OpenBSD 4.0, IRIX 6.5, OSF/1 5.1, mingw */ + ASSERT (ptr == input + m); /* OSF/1 5.1 */ + ASSERT (errno == 0); /* Mac OS X 10.3, FreeBSD 6.2, NetBSD 3.0, OpenBSD 4.0, IRIX 6.5, OSF/1 5.1, mingw */ + } + free (input); + } + { + size_t m = 1000000; + char *input = malloc (m + 1); + if (input) + { + char *ptr; + double result; + input[0] = '1'; + memset (input + 1, '0', m - 9); + input[m - 8] = 'e'; + input[m - 7] = '-'; + input[m - 6] = '9'; + input[m - 5] = '9'; + input[m - 4] = '9'; + input[m - 3] = '9'; + input[m - 2] = '9'; + input[m - 1] = '1'; + input[m] = '\0'; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); /* Mac OS X 10.3, FreeBSD 6.2, NetBSD 3.0, OpenBSD 4.0, IRIX 6.5, OSF/1 5.1, mingw */ + ASSERT (ptr == input + m); + ASSERT (errno == 0); /* Mac OS X 10.3, FreeBSD 6.2, NetBSD 3.0, OpenBSD 4.0, IRIX 6.5, OSF/1 5.1, mingw */ + } + free (input); + } +#endif + { + size_t m = 1000000; + char *input = malloc (m + 1); + if (input) + { + char *ptr; + double result; + input[0] = '-'; + input[1] = '0'; + input[2] = 'e'; + input[3] = '1'; + memset (input + 4, '0', m - 3); + input[m] = '\0'; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.0); + ASSERT (!!signbit (result) == !!signbit (minus_zerod)); /* IRIX 6.5, OSF/1 4.0 */ + ASSERT (ptr == input + m); + ASSERT (errno == 0); + } + free (input); + } + + /* Rounding. */ + /* TODO - is it worth some tests of rounding for typical IEEE corner + cases, such as .5 ULP rounding up to the smallest denormal and + not causing underflow, or DBL_MIN - .5 ULP not causing an + infinite loop? */ + + return status; +} diff --git a/gnulib-tests/test-strtod1.c b/gnulib-tests/test-strtod1.c new file mode 100644 index 0000000..47c6939 --- /dev/null +++ b/gnulib-tests/test-strtod1.c @@ -0,0 +1,101 @@ +/* Test of strtod() in a French locale. + Copyright (C) 2019-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdlib.h> + +#include <errno.h> +#include <locale.h> + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + /* Try to set the locale by implicitly looking at the LC_ALL environment + variable. + configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + { + const char input[] = "1,"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.0); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = ",5"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 0.5); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "1,5"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result == 1.5); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + { + const char input[] = "1.5"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + /* On AIX 7.2, in the French locale, '.' is recognized as an alternate + radix character. */ + ASSERT ((ptr == input + 1 && result == 1.0) + || (ptr == input + 3 && result == 1.5)); + ASSERT (errno == 0); + } + { + const char input[] = "123.456,789"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + /* On AIX 7.2, in the French locale, '.' is recognized as an alternate + radix character. */ + ASSERT ((ptr == input + 3 && result == 123.0) + || (ptr == input + 7 && result > 123.45 && result < 123.46)); + ASSERT (errno == 0); + } + { + const char input[] = "123,456.789"; + char *ptr; + double result; + errno = 0; + result = strtod (input, &ptr); + ASSERT (result > 123.45 && result < 123.46); + ASSERT (ptr == input + 7); + ASSERT (errno == 0); + } + + return 0; +} diff --git a/gnulib-tests/test-strtod1.sh b/gnulib-tests/test-strtod1.sh new file mode 100755 index 0000000..2ec4ebf --- /dev/null +++ b/gnulib-tests/test-strtod1.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +: ${LOCALE_FR=fr_FR} +: ${LOCALE_FR_UTF8=fr_FR.UTF-8} + +if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no locale for testing is installed" + else + echo "Skipping test: no locale for testing is supported" + fi + exit 77 +fi + +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR ${CHECKER} ./test-strtod1${EXEEXT} || exit 1 +fi + +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 ${CHECKER} ./test-strtod1${EXEEXT} || exit 1 +fi + +exit 0 diff --git a/gnulib-tests/test-strtoimax.c b/gnulib-tests/test-strtoimax.c new file mode 100644 index 0000000..0ec4f8a --- /dev/null +++ b/gnulib-tests/test-strtoimax.c @@ -0,0 +1,181 @@ +/* + * Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <inttypes.h> + +#include "signature.h" +#ifndef strtoimax +SIGNATURE_CHECK (strtoimax, intmax_t, (const char *, char **, int)); +#endif + +#include <errno.h> + +#include "macros.h" + +int +main (void) +{ + /* Subject sequence empty or invalid. */ + { + const char input[] = ""; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " "; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " +"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " -"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + + /* Simple integer values. */ + { + const char input[] = "0"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = "+0"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "-0"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "23"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == 23); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = " 23"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == 23); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + { + const char input[] = "+23"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == 23); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + { + const char input[] = "-23"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == -23); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + + /* Large integer values. */ + { + const char input[] = "2147483647"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == 2147483647); + ASSERT (ptr == input + 10); + ASSERT (errno == 0); + } + { + const char input[] = "-2147483648"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == -2147483647 - 1); + ASSERT (ptr == input + 11); + ASSERT (errno == 0); + } + if (sizeof (intmax_t) > sizeof (int)) + { + const char input[] = "4294967295"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == (intmax_t) 65535 * (intmax_t) 65537); + ASSERT (ptr == input + 10); + ASSERT (errno == 0); + } + + return 0; +} diff --git a/gnulib-tests/test-strtold.c b/gnulib-tests/test-strtold.c new file mode 100644 index 0000000..9caf539 --- /dev/null +++ b/gnulib-tests/test-strtold.c @@ -0,0 +1,980 @@ +/* + * Copyright (C) 2008-2020 Free Software Foundation, Inc. + * Written by Eric Blake + * + * 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdlib.h> + +#include "signature.h" +SIGNATURE_CHECK (strtold, long double, (char const *, char **)); + +#include <errno.h> +#include <float.h> +#include <math.h> +#include <string.h> + +#include "isnanl-nolibm.h" +#include "minus-zero.h" +#include "macros.h" + +/* Avoid requiring -lm just for fabsl. */ +#define FABSL(d) ((d) < 0.0L ? -(d) : (d)) + +int +main (void) +{ + int status = 0; + /* Subject sequence empty or invalid. */ + { + const char input[] = ""; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.0L); + ASSERT (!signbit (result)); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " "; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.0L); + ASSERT (!signbit (result)); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " +"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.0L); + ASSERT (!signbit (result)); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " ."; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.0L); + ASSERT (!signbit (result)); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " .e0"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.0L); + ASSERT (!signbit (result)); + ASSERT (ptr == input); /* IRIX 6.5 */ + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " +.e-0"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.0L); + ASSERT (!signbit (result)); + ASSERT (ptr == input); /* IRIX 6.5 */ + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " in"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.0L); + ASSERT (!signbit (result)); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " na"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.0L); + ASSERT (!signbit (result)); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + + /* Simple floating point values. */ + { + const char input[] = "1"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = "1."; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = ".5"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.5L); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = " 1"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "+1"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "-1"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == -1.0L); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "1e0"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + { + const char input[] = "1e+0"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); + ASSERT (ptr == input + 4); + ASSERT (errno == 0); + } + { + const char input[] = "1e-0"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); + ASSERT (ptr == input + 4); + ASSERT (errno == 0); + } + { + const char input[] = "1e1"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 10.0L); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + { + const char input[] = "5e-1"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.5L); + ASSERT (ptr == input + 4); + ASSERT (errno == 0); + } + + /* Zero. */ + { + const char input[] = "0"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.0L); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = ".0"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.0L); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "0e0"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.0L); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + { + const char input[] = "0e+9999999"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.0L); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 10); + ASSERT (errno == 0); + } + { + const char input[] = "0e-9999999"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.0L); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 10); + ASSERT (errno == 0); + } + { + const char input[] = "-0"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.0L); + ASSERT (!!signbit (result) == !!signbit (minus_zerol)); /* IRIX 6.5 */ + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + + /* Suffixes. */ + { + const char input[] = "1f"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = "1.f"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "1e"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = "1e+"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = "1e-"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = "1E 2"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); /* HP-UX 11.31/ia64, IRIX 6.5 */ + ASSERT (ptr == input + 1); /* HP-UX 11.31/ia64, IRIX 6.5 */ + ASSERT (errno == 0); + } + { + const char input[] = "0x"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.0L); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 1); /* glibc-2.3.2, Mac OS X 10.5, Haiku */ + ASSERT (errno == 0); + } + { + const char input[] = "00x1"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.0L); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "-0x"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.0L); + ASSERT (!!signbit (result) == !!signbit (minus_zerol)); /* Mac OS X 10.5, IRIX 6.5 */ + ASSERT (ptr == input + 2); /* glibc-2.3.2, Mac OS X 10.5, Haiku */ + ASSERT (errno == 0); + } + { + const char input[] = "0xg"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.0L); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 1); /* glibc-2.3.2, Mac OS X 10.5, Haiku */ + ASSERT (errno == 0); + } + { + const char input[] = "0xp"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.0L); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 1); /* glibc-2.3.2, Mac OS X 10.5, Haiku */ + ASSERT (errno == 0); + } + { + const char input[] = "0XP"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.0L); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 1); /* glibc-2.3.2, Mac OS X 10.5, Haiku */ + ASSERT (errno == 0); + } + { + const char input[] = "0x."; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.0L); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 1); /* glibc-2.3.2, Mac OS X 10.5, Haiku */ + ASSERT (errno == 0); + } + { + const char input[] = "0xp+"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.0L); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 1); /* glibc-2.3.2, Mac OS X 10.5, Haiku */ + ASSERT (errno == 0); + } + { + const char input[] = "0xp+1"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.0L); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 1); /* glibc-2.3.2, Mac OS X 10.5, Haiku */ + ASSERT (errno == 0); + } + { + const char input[] = "0x.p+1"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.0L); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 1); /* glibc-2.3.2, Mac OS X 10.5, Haiku */ + ASSERT (errno == 0); + } + { + const char input[] = "1p+1"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = "1P+1"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + + /* Overflow/underflow. */ + { + const char input[] = "1E1000000"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == HUGE_VALL); + ASSERT (ptr == input + 9); + ASSERT (errno == ERANGE); + } + { + const char input[] = "-1E1000000"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == -HUGE_VALL); + ASSERT (ptr == input + 10); + ASSERT (errno == ERANGE); + } + { + const char input[] = "1E-100000"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (0.0L <= result && result <= LDBL_MIN); + ASSERT (!signbit (result)); + ASSERT (ptr == input + 9); + ASSERT (errno == ERANGE); + } + { + const char input[] = "-1E-100000"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (-LDBL_MIN <= result && result <= 0.0L); +#if 0 + /* FIXME - this is glibc bug 5995; POSIX allows returning positive + 0 on negative underflow, even though quality of implementation + demands preserving the sign. Disable this test until fixed + glibc is more prevalent. */ + ASSERT (!!signbit (result) == !!signbit (minus_zerol)); /* glibc-2.3.2, Haiku */ +#endif + ASSERT (ptr == input + 10); + ASSERT (errno == ERANGE); + } + { + const char input[] = "1E 1000000"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); /* HP-UX 11.31/ia64, IRIX 6.5 */ + ASSERT (ptr == input + 1); /* HP-UX 11.31/ia64, IRIX 6.5 */ + ASSERT (errno == 0); /* HP-UX 11.31/ia64, IRIX 6.5 */ + } + { + const char input[] = "0x1P 1000000"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); /* HP-UX 11.31/ia64, IRIX 6.5, mingw */ + ASSERT (ptr == input + 3); /* HP-UX 11.31/ia64, IRIX 6.5, mingw */ + ASSERT (errno == 0); + } + + /* Infinity. */ + { + const char input[] = "iNf"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == HUGE_VALL); /* IRIX 6.5 */ + ASSERT (ptr == input + 3); /* IRIX 6.5 */ + ASSERT (errno == 0); /* HP-UX 11.31/ia64 */ + } + { + const char input[] = "-InF"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == -HUGE_VALL); /* IRIX 6.5 */ + ASSERT (ptr == input + 4); /* IRIX 6.5 */ + ASSERT (errno == 0); /* HP-UX 11.31/ia64 */ + } + { + const char input[] = "infinite"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == HUGE_VALL); /* IRIX 6.5 */ + ASSERT (ptr == input + 3); /* IRIX 6.5 */ + ASSERT (errno == 0); /* HP-UX 11.31/ia64 */ + } + { + const char input[] = "infinitY"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == HUGE_VALL); /* IRIX 6.5 */ + ASSERT (ptr == input + 8); /* IRIX 6.5 */ + ASSERT (errno == 0); /* HP-UX 11.31/ia64 */ + } + { + const char input[] = "infinitY."; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == HUGE_VALL); /* IRIX 6.5 */ + ASSERT (ptr == input + 8); /* IRIX 6.5 */ + ASSERT (errno == 0); /* HP-UX 11.31/ia64 */ + } + + /* NaN. Some processors set the sign bit of the default NaN, so all + we check is that using a sign changes the result. */ + { + const char input[] = "-nan"; + char *ptr1; + char *ptr2; + long double result1; + long double result2; + errno = 0; + result1 = strtold (input, &ptr1); + result2 = strtold (input + 1, &ptr2); +#if 1 /* All known CPUs support NaNs. */ + ASSERT (isnanl (result1)); /* IRIX 6.5 */ + ASSERT (isnanl (result2)); /* IRIX 6.5 */ +# if 0 + /* Sign bits of NaN is a portability sticking point, not worth + worrying about. */ + ASSERT (!!signbit (result1) != !!signbit (result2)); +# endif + ASSERT (ptr1 == input + 4); /* IRIX 6.5 */ + ASSERT (ptr2 == input + 4); /* IRIX 6.5 */ + ASSERT (errno == 0); /* HP-UX 11.31/ia64 */ +#else + ASSERT (result1 == 0.0L); + ASSERT (result2 == 0.0L); + ASSERT (!signbit (result1)); + ASSERT (!signbit (result2)); + ASSERT (ptr1 == input); + ASSERT (ptr2 == input + 1); + ASSERT (errno == 0 || errno == EINVAL); +#endif + } + { + const char input[] = "+nan("; + char *ptr1; + char *ptr2; + long double result1; + long double result2; + errno = 0; + result1 = strtold (input, &ptr1); + result2 = strtold (input + 1, &ptr2); +#if 1 /* All known CPUs support NaNs. */ + ASSERT (isnanl (result1)); /* IRIX 6.5 */ + ASSERT (isnanl (result2)); /* IRIX 6.5 */ + ASSERT (!!signbit (result1) == !!signbit (result2)); + ASSERT (ptr1 == input + 4); /* Mac OS X 10.5, IRIX 6.5 */ + ASSERT (ptr2 == input + 4); /* Mac OS X 10.5, IRIX 6.5 */ + ASSERT (errno == 0); /* HP-UX 11.31/ia64 */ +#else + ASSERT (result1 == 0.0L); + ASSERT (result2 == 0.0L); + ASSERT (!signbit (result1)); + ASSERT (!signbit (result2)); + ASSERT (ptr1 == input); + ASSERT (ptr2 == input + 1); + ASSERT (errno == 0 || errno == EINVAL); +#endif + } + { + const char input[] = "-nan()"; + char *ptr1; + char *ptr2; + long double result1; + long double result2; + errno = 0; + result1 = strtold (input, &ptr1); + result2 = strtold (input + 1, &ptr2); +#if 1 /* All known CPUs support NaNs. */ + ASSERT (isnanl (result1)); /* IRIX 6.5 */ + ASSERT (isnanl (result2)); /* IRIX 6.5 */ +# if 0 + /* Sign bits of NaN is a portability sticking point, not worth + worrying about. */ + ASSERT (!!signbit (result1) != !!signbit (result2)); /* glibc-2.3.2, musl libc, OpenBSD 6.0, IRIX 6.5, mingw, Haiku */ +# endif + ASSERT (ptr1 == input + 6); /* glibc-2.3.2, IRIX 6.5, mingw, Haiku */ + ASSERT (ptr2 == input + 6); /* glibc-2.3.2, IRIX 6.5, mingw, Haiku */ + ASSERT (errno == 0); /* HP-UX 11.31/ia64, Haiku */ +#else + ASSERT (result1 == 0.0L); + ASSERT (result2 == 0.0L); + ASSERT (!signbit (result1)); + ASSERT (!signbit (result2)); + ASSERT (ptr1 == input); + ASSERT (ptr2 == input + 1); + ASSERT (errno == 0 || errno == EINVAL); +#endif + } + { + const char input[] = " nan()."; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); +#if 1 /* All known CPUs support NaNs. */ + ASSERT (isnanl (result)); /* IRIX 6.5 */ + ASSERT (ptr == input + 6); /* glibc-2.3.2, IRIX 6.5, mingw, Haiku */ + ASSERT (errno == 0); /* HP-UX 11.31/ia64, Haiku */ +#else + ASSERT (result == 0.0L); + ASSERT (!signbit (result)); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); +#endif + } + { + /* The behavior of nan(0) is implementation-defined, but all + implementations we know of which handle optional + n-char-sequences handle nan(0) the same as nan(). */ + const char input[] = "-nan(0)."; + char *ptr1; + char *ptr2; + long double result1; + long double result2; + errno = 0; + result1 = strtold (input, &ptr1); + result2 = strtold (input + 1, &ptr2); +#if 1 /* All known CPUs support NaNs. */ + ASSERT (isnanl (result1)); /* IRIX 6.5 */ + ASSERT (isnanl (result2)); /* IRIX 6.5 */ +# if 0 + /* Sign bits of NaN is a portability sticking point, not worth + worrying about. */ + ASSERT (!!signbit (result1) != !!signbit (result2)); +# endif + ASSERT (ptr1 == input + 7); /* glibc-2.3.2, IRIX 6.5, mingw, Haiku */ + ASSERT (ptr2 == input + 7); /* glibc-2.3.2, IRIX 6.5, mingw, Haiku */ + ASSERT (errno == 0); /* HP-UX 11.31/ia64 */ +#else + ASSERT (result1 == 0.0L); + ASSERT (result2 == 0.0L); + ASSERT (!signbit (result1)); + ASSERT (!signbit (result2)); + ASSERT (ptr1 == input); + ASSERT (ptr2 == input + 1); + ASSERT (errno == 0 || errno == EINVAL); +#endif + } + + /* Hex. */ + { + const char input[] = "0xa"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 10.0L); /* IRIX 6.5, mingw */ + ASSERT (ptr == input + 3); /* IRIX 6.5, mingw */ + ASSERT (errno == 0); + } + { + const char input[] = "0XA"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 10.0L); /* IRIX 6.5, mingw */ + ASSERT (ptr == input + 3); /* IRIX 6.5, mingw */ + ASSERT (errno == 0); + } + { + const char input[] = "0x1p"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); /* IRIX 6.5, mingw */ + ASSERT (ptr == input + 3); /* IRIX 6.5, mingw */ + ASSERT (errno == 0); + } + { + const char input[] = "0x1p+"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); /* IRIX 6.5, mingw */ + ASSERT (ptr == input + 3); /* IRIX 6.5, mingw */ + ASSERT (errno == 0); + } + { + const char input[] = "0x1P+"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); /* IRIX 6.5, mingw */ + ASSERT (ptr == input + 3); /* IRIX 6.5, mingw */ + ASSERT (errno == 0); + } + { + const char input[] = "0x1p+1"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 2.0L); /* IRIX 6.5, mingw */ + ASSERT (ptr == input + 6); /* IRIX 6.5, mingw */ + ASSERT (errno == 0); + } + { + const char input[] = "0X1P+1"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 2.0L); /* IRIX 6.5, mingw */ + ASSERT (ptr == input + 6); /* IRIX 6.5, mingw */ + ASSERT (errno == 0); + } + { + const char input[] = "0x1p+1a"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 2.0L); /* IRIX 6.5, mingw */ + ASSERT (ptr == input + 6); /* IRIX 6.5, mingw */ + ASSERT (errno == 0); + } + { + const char input[] = "0x1p 2"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); /* HP-UX 11.31/ia64, IRIX 6.5, mingw */ + ASSERT (ptr == input + 3); /* HP-UX 11.31/ia64, IRIX 6.5, mingw */ + ASSERT (errno == 0); + } + + /* Large buffers. */ + { + size_t m = 1000000; + char *input = malloc (m + 1); + if (input) + { + char *ptr; + long double result; + memset (input, '\t', m - 1); + input[m - 1] = '1'; + input[m] = '\0'; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); + ASSERT (ptr == input + m); + ASSERT (errno == 0); + } + free (input); + } + { + size_t m = 1000000; + char *input = malloc (m + 1); + if (input) + { + char *ptr; + long double result; + memset (input, '0', m - 1); + input[m - 1] = '1'; + input[m] = '\0'; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); + ASSERT (ptr == input + m); + ASSERT (errno == 0); + } + free (input); + } +#if 0 + /* Newlib has an artificial limit of 20000 for the exponent. TODO - + gnulib should fix this. */ + { + size_t m = 1000000; + char *input = malloc (m + 1); + if (input) + { + char *ptr; + long double result; + input[0] = '.'; + memset (input + 1, '0', m - 10); + input[m - 9] = '1'; + input[m - 8] = 'e'; + input[m - 7] = '+'; + input[m - 6] = '9'; + input[m - 5] = '9'; + input[m - 4] = '9'; + input[m - 3] = '9'; + input[m - 2] = '9'; + input[m - 1] = '1'; + input[m] = '\0'; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); /* Mac OS X 10.5, FreeBSD 11.0, NetBSD 7.1, OpenBSD 6.0, Minix 3.3, IRIX 6.5, mingw */ + ASSERT (ptr == input + m); + ASSERT (errno == 0); /* Mac OS X 10.5, FreeBSD 11.0, NetBSD 7.1, OpenBSD 6.0, Minix 3.3, IRIX 6.5, mingw */ + } + free (input); + } + { + size_t m = 1000000; + char *input = malloc (m + 1); + if (input) + { + char *ptr; + long double result; + input[0] = '1'; + memset (input + 1, '0', m - 9); + input[m - 8] = 'e'; + input[m - 7] = '-'; + input[m - 6] = '9'; + input[m - 5] = '9'; + input[m - 4] = '9'; + input[m - 3] = '9'; + input[m - 2] = '9'; + input[m - 1] = '1'; + input[m] = '\0'; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); /* Mac OS X 10.5, FreeBSD 11.0, NetBSD 7.1, OpenBSD 6.0, Minix 3.3, IRIX 6.5, mingw */ + ASSERT (ptr == input + m); + ASSERT (errno == 0); /* Mac OS X 10.5, FreeBSD 11.0, NetBSD 7.1, OpenBSD 6.0, Minix 3.3, IRIX 6.5, mingw */ + } + free (input); + } +#endif + { + size_t m = 1000000; + char *input = malloc (m + 1); + if (input) + { + char *ptr; + long double result; + input[0] = '-'; + input[1] = '0'; + input[2] = 'e'; + input[3] = '1'; + memset (input + 4, '0', m - 3); + input[m] = '\0'; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.0L); + ASSERT (!!signbit (result) == !!signbit (minus_zerol)); /* IRIX 6.5 */ + ASSERT (ptr == input + m); + ASSERT (errno == 0); + } + free (input); + } + + /* Rounding. */ + /* TODO - is it worth some tests of rounding for typical IEEE corner + cases, such as .5 ULP rounding up to the smallest denormal and + not causing underflow, or LDBL_MIN - .5 ULP not causing an + infinite loop? */ + + return status; +} diff --git a/gnulib-tests/test-strtold1.c b/gnulib-tests/test-strtold1.c new file mode 100644 index 0000000..9bc1b9d --- /dev/null +++ b/gnulib-tests/test-strtold1.c @@ -0,0 +1,101 @@ +/* Test of strtold() in a French locale. + Copyright (C) 2019-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdlib.h> + +#include <errno.h> +#include <locale.h> + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + /* Try to set the locale by implicitly looking at the LC_ALL environment + variable. + configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + { + const char input[] = "1,"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.0L); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = ",5"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 0.5L); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "1,5"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result == 1.5L); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + { + const char input[] = "1.5"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + /* On AIX 7.2, in the French locale, '.' is recognized as an alternate + radix character. */ + ASSERT ((ptr == input + 1 && result == 1.0L) + || (ptr == input + 3 && result == 1.5L)); + ASSERT (errno == 0); + } + { + const char input[] = "123.456,789"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + /* On AIX 7.2, in the French locale, '.' is recognized as an alternate + radix character. */ + ASSERT ((ptr == input + 3 && result == 123.0L) + || (ptr == input + 7 && result > 123.45L && result < 123.46L)); + ASSERT (errno == 0); + } + { + const char input[] = "123,456.789"; + char *ptr; + long double result; + errno = 0; + result = strtold (input, &ptr); + ASSERT (result > 123.45L && result < 123.46L); + ASSERT (ptr == input + 7); + ASSERT (errno == 0); + } + + return 0; +} diff --git a/gnulib-tests/test-strtold1.sh b/gnulib-tests/test-strtold1.sh new file mode 100755 index 0000000..3f4c4b9 --- /dev/null +++ b/gnulib-tests/test-strtold1.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +: ${LOCALE_FR=fr_FR} +: ${LOCALE_FR_UTF8=fr_FR.UTF-8} + +if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no locale for testing is installed" + else + echo "Skipping test: no locale for testing is supported" + fi + exit 77 +fi + +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR ${CHECKER} ./test-strtold1${EXEEXT} || exit 1 +fi + +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 ${CHECKER} ./test-strtold1${EXEEXT} || exit 1 +fi + +exit 0 diff --git a/gnulib-tests/test-strtoll.c b/gnulib-tests/test-strtoll.c new file mode 100644 index 0000000..12d8daf --- /dev/null +++ b/gnulib-tests/test-strtoll.c @@ -0,0 +1,181 @@ +/* + * Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdlib.h> + +#include "signature.h" +#ifndef strtoll +SIGNATURE_CHECK (strtoll, long long, (const char *, char **, int)); +#endif + +#include <errno.h> + +#include "macros.h" + +int +main (void) +{ + /* Subject sequence empty or invalid. */ + { + const char input[] = ""; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " "; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " +"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " -"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + + /* Simple integer values. */ + { + const char input[] = "0"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = "+0"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "-0"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "23"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 23); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = " 23"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 23); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + { + const char input[] = "+23"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 23); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + { + const char input[] = "-23"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == -23); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + + /* Large integer values. */ + { + const char input[] = "2147483647"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 2147483647); + ASSERT (ptr == input + 10); + ASSERT (errno == 0); + } + { + const char input[] = "-2147483648"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == -2147483647 - 1); + ASSERT (ptr == input + 11); + ASSERT (errno == 0); + } + if (sizeof (long long) > sizeof (int)) + { + const char input[] = "4294967295"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 65535LL * 65537LL); + ASSERT (ptr == input + 10); + ASSERT (errno == 0); + } + + return 0; +} diff --git a/gnulib-tests/test-strtoull.c b/gnulib-tests/test-strtoull.c new file mode 100644 index 0000000..8d8e0b5 --- /dev/null +++ b/gnulib-tests/test-strtoull.c @@ -0,0 +1,180 @@ +/* + * Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdlib.h> + +#include "signature.h" +#ifndef strtoull +SIGNATURE_CHECK (strtoull, unsigned long long, (const char *, char **, int)); +#endif + +#include <errno.h> + +#include "macros.h" + +int +main (void) +{ + /* Subject sequence empty or invalid. */ + { + const char input[] = ""; + char *ptr; + unsigned long long result; + errno = 0; + result = strtoull (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " "; + char *ptr; + unsigned long long result; + errno = 0; + result = strtoull (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " +"; + char *ptr; + unsigned long long result; + errno = 0; + result = strtoull (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " -"; + char *ptr; + unsigned long long result; + errno = 0; + result = strtoull (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + + /* Simple integer values. */ + { + const char input[] = "0"; + char *ptr; + unsigned long long result; + errno = 0; + result = strtoull (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = "+0"; + char *ptr; + unsigned long long result; + errno = 0; + result = strtoull (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "-0"; + char *ptr; + unsigned long long result; + errno = 0; + result = strtoull (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "23"; + char *ptr; + unsigned long long result; + errno = 0; + result = strtoull (input, &ptr, 10); + ASSERT (result == 23); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = " 23"; + char *ptr; + unsigned long long result; + errno = 0; + result = strtoull (input, &ptr, 10); + ASSERT (result == 23); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + { + const char input[] = "+23"; + char *ptr; + unsigned long long result; + errno = 0; + result = strtoull (input, &ptr, 10); + ASSERT (result == 23); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + { + const char input[] = "-23"; + char *ptr; + unsigned long long result; + errno = 0; + result = strtoull (input, &ptr, 10); + ASSERT (result == - 23ULL); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + + /* Large integer values. */ + { + const char input[] = "2147483647"; + char *ptr; + unsigned long long result; + errno = 0; + result = strtoull (input, &ptr, 10); + ASSERT (result == 2147483647); + ASSERT (ptr == input + 10); + ASSERT (errno == 0); + } + { + const char input[] = "-2147483648"; + char *ptr; + unsigned long long result; + errno = 0; + result = strtoull (input, &ptr, 10); + ASSERT (result == - 2147483648ULL); + ASSERT (ptr == input + 11); + ASSERT (errno == 0); + } + { + const char input[] = "4294967295"; + char *ptr; + unsigned long long result; + errno = 0; + result = strtoull (input, &ptr, 10); + ASSERT (result == 4294967295U); + ASSERT (ptr == input + 10); + ASSERT (errno == 0); + } + + return 0; +} diff --git a/gnulib-tests/test-strtoumax.c b/gnulib-tests/test-strtoumax.c new file mode 100644 index 0000000..e086c88 --- /dev/null +++ b/gnulib-tests/test-strtoumax.c @@ -0,0 +1,180 @@ +/* + * Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <inttypes.h> + +#include "signature.h" +#ifndef strtoumax +SIGNATURE_CHECK (strtoumax, uintmax_t, (const char *, char **, int)); +#endif + +#include <errno.h> + +#include "macros.h" + +int +main (void) +{ + /* Subject sequence empty or invalid. */ + { + const char input[] = ""; + char *ptr; + uintmax_t result; + errno = 0; + result = strtoumax (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " "; + char *ptr; + uintmax_t result; + errno = 0; + result = strtoumax (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " +"; + char *ptr; + uintmax_t result; + errno = 0; + result = strtoumax (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " -"; + char *ptr; + uintmax_t result; + errno = 0; + result = strtoumax (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + + /* Simple integer values. */ + { + const char input[] = "0"; + char *ptr; + uintmax_t result; + errno = 0; + result = strtoumax (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = "+0"; + char *ptr; + uintmax_t result; + errno = 0; + result = strtoumax (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "-0"; + char *ptr; + uintmax_t result; + errno = 0; + result = strtoumax (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "23"; + char *ptr; + uintmax_t result; + errno = 0; + result = strtoumax (input, &ptr, 10); + ASSERT (result == 23); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = " 23"; + char *ptr; + uintmax_t result; + errno = 0; + result = strtoumax (input, &ptr, 10); + ASSERT (result == 23); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + { + const char input[] = "+23"; + char *ptr; + uintmax_t result; + errno = 0; + result = strtoumax (input, &ptr, 10); + ASSERT (result == 23); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + { + const char input[] = "-23"; + char *ptr; + uintmax_t result; + errno = 0; + result = strtoumax (input, &ptr, 10); + ASSERT (result == - (uintmax_t) 23); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + + /* Large integer values. */ + { + const char input[] = "2147483647"; + char *ptr; + uintmax_t result; + errno = 0; + result = strtoumax (input, &ptr, 10); + ASSERT (result == 2147483647); + ASSERT (ptr == input + 10); + ASSERT (errno == 0); + } + { + const char input[] = "-2147483648"; + char *ptr; + uintmax_t result; + errno = 0; + result = strtoumax (input, &ptr, 10); + ASSERT (result == - (uintmax_t) 2147483648U); + ASSERT (ptr == input + 11); + ASSERT (errno == 0); + } + { + const char input[] = "4294967295"; + char *ptr; + uintmax_t result; + errno = 0; + result = strtoumax (input, &ptr, 10); + ASSERT (result == 4294967295U); + ASSERT (ptr == input + 10); + ASSERT (errno == 0); + } + + return 0; +} diff --git a/gnulib-tests/test-symlink.c b/gnulib-tests/test-symlink.c new file mode 100644 index 0000000..76ac63f --- /dev/null +++ b/gnulib-tests/test-symlink.c @@ -0,0 +1,47 @@ +/* Tests of symlink. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (symlink, int, (char const *, char const *)); + +#include <fcntl.h> +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/stat.h> + +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-symlink.t" + +#include "test-symlink.h" + +int +main (void) +{ + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + return test_symlink (symlink, true); +} diff --git a/gnulib-tests/test-symlink.h b/gnulib-tests/test-symlink.h new file mode 100644 index 0000000..da6b184 --- /dev/null +++ b/gnulib-tests/test-symlink.h @@ -0,0 +1,96 @@ +/* Tests of symlink. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +/* This file is designed to test both symlink(a,b) and + symlinkat(a,AT_FDCWD,b). FUNC is the function to test. Assumes + that BASE and ASSERT are already defined, and that appropriate + headers are already included. If PRINT, warn before skipping + symlink tests with status 77. */ + +static int +test_symlink (int (*func) (char const *, char const *), bool print) +{ + if (func ("nowhere", BASE "link1")) + { + if (print) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + + /* Some systems allow the creation of 0-length symlinks as a synonym + for "."; but most reject it. */ + { + int status; + errno = 0; + status = func ("", BASE "link2"); + if (status == -1) + ASSERT (errno == ENOENT || errno == EINVAL); + else + { + ASSERT (status == 0); + ASSERT (unlink (BASE "link2") == 0); + } + } + + /* Sanity checks of failures. */ + errno = 0; + ASSERT (func ("nowhere", "") == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func ("nowhere", ".") == -1); + ASSERT (errno == EEXIST || errno == EINVAL); + errno = 0; + ASSERT (func ("somewhere", BASE "link1") == -1); + ASSERT (errno == EEXIST); + errno = 0; + ASSERT (func ("nowhere", BASE "link2/") == -1); + ASSERT (errno == ENOTDIR || errno == ENOENT); + ASSERT (mkdir (BASE "dir", 0700) == 0); + errno = 0; + ASSERT (func ("nowhere", BASE "dir") == -1); + ASSERT (errno == EEXIST); + errno = 0; + ASSERT (func ("nowhere", BASE "dir/") == -1); + ASSERT (errno == EEXIST || errno == EINVAL + || errno == ENOENT /* Lustre FS on Linux */); + ASSERT (close (creat (BASE "file", 0600)) == 0); + errno = 0; + ASSERT (func ("nowhere", BASE "file") == -1); + ASSERT (errno == EEXIST); + errno = 0; + ASSERT (func ("nowhere", BASE "file/") == -1); + ASSERT (errno == EEXIST || errno == ENOTDIR || errno == ENOENT); + + /* Trailing slash must always be rejected. */ + ASSERT (unlink (BASE "link1") == 0); + ASSERT (func (BASE "link2", BASE "link1") == 0); + errno = 0; + ASSERT (func (BASE "nowhere", BASE "link1/") == -1); + ASSERT (errno == EEXIST || errno == ENOTDIR || errno == ENOENT); + errno = 0; + ASSERT (unlink (BASE "link2") == -1); + ASSERT (errno == ENOENT); + + /* Cleanup. */ + ASSERT (rmdir (BASE "dir") == 0); + ASSERT (unlink (BASE "file") == 0); + ASSERT (unlink (BASE "link1") == 0); + + return 0; +} diff --git a/gnulib-tests/test-symlinkat.c b/gnulib-tests/test-symlinkat.c new file mode 100644 index 0000000..a0eb265 --- /dev/null +++ b/gnulib-tests/test-symlinkat.c @@ -0,0 +1,89 @@ +/* Tests of symlinkat. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (symlinkat, int, (char const *, int, char const *)); + +#include <fcntl.h> +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> + +#include "ignore-value.h" +#include "macros.h" + +#ifndef HAVE_SYMLINK +# define HAVE_SYMLINK 0 +#endif + +#define BASE "test-symlinkat.t" + +#include "test-symlink.h" + +static int dfd = AT_FDCWD; + +static int +do_symlink (char const *contents, char const *name) +{ + return symlinkat (contents, dfd, name); +} + +int +main (void) +{ + int result; + + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (symlinkat ("foo", -1, "bar") == -1); + ASSERT (errno == EBADF + || errno == ENOSYS /* seen on mingw */ + ); + } + { + close (99); + errno = 0; + ASSERT (symlinkat ("foo", 99, "bar") == -1); + ASSERT (errno == EBADF + || errno == ENOSYS /* seen on mingw */ + ); + } + + /* Perform same checks as counterpart functions. */ + result = test_symlink (do_symlink, false); + dfd = openat (AT_FDCWD, ".", O_RDONLY); + ASSERT (0 <= dfd); + ASSERT (test_symlink (do_symlink, false) == result); + + ASSERT (close (dfd) == 0); + if (result == 77) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return result; +} diff --git a/gnulib-tests/test-sys_ioctl.c b/gnulib-tests/test-sys_ioctl.c new file mode 100644 index 0000000..3aeb375 --- /dev/null +++ b/gnulib-tests/test-sys_ioctl.c @@ -0,0 +1,27 @@ +/* Test of <sys/ioctl.h> substitute. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <sys/ioctl.h> + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tests/test-sys_resource.c b/gnulib-tests/test-sys_resource.c new file mode 100644 index 0000000..e4b3bfa --- /dev/null +++ b/gnulib-tests/test-sys_resource.c @@ -0,0 +1,72 @@ +/* Test of <sys/resource.h> substitute. + Copyright (C) 2012-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <sys/resource.h> + +/* Check that necessary types are defined. */ +#ifdef TODO /* Not implemented in gnulib yet */ +rlim_t t1; +struct rlimit t2; +#endif +struct rusage t3; +#ifdef TODO +struct timeval t4; +id_t t5; +time_t t10; +suseconds_t t11; +fd_set t12; +#endif + +/* Check that the necessary constants are defined. */ +#ifdef TODO /* Not implemented in gnulib yet */ +int prios[] = + { + PRIO_PROCESS, + PRIO_PGRP, + PRIO_USER + }; +int rlims[] = + { + RLIM_INFINITY, + RLIM_SAVED_MAX, + RLIM_SAVED_CUR + }; +#endif +int rusages[] = + { + RUSAGE_SELF, + RUSAGE_CHILDREN + }; +#ifdef TODO +int rlimits[] = + { + RLIMIT_CORE, + RLIMIT_CPU, + RLIMIT_DATA, + RLIMIT_FSIZE, + RLIMIT_NOFILE, + RLIMIT_STACK, + RLIMIT_AS + }; +#endif + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tests/test-sys_select.c b/gnulib-tests/test-sys_select.c new file mode 100644 index 0000000..01eced5 --- /dev/null +++ b/gnulib-tests/test-sys_select.c @@ -0,0 +1,59 @@ +/* Test of <sys/select.h> substitute. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <sys/select.h> + +#include "signature.h" + +/* The following may be macros without underlying functions, so only + check signature if they are not macros. */ +#ifndef FD_CLR +SIGNATURE_CHECK (FD_CLR, void, (int, fd_set *)); +#endif +#ifndef FD_ISSET +SIGNATURE_CHECK (FD_ISSET, void, (int, fd_set *)); +#endif +#ifndef FD_SET +SIGNATURE_CHECK (FD_SET, int, (int, fd_set *)); +#endif +#ifndef FD_ZERO +SIGNATURE_CHECK (FD_ZERO, void, (fd_set *)); +#endif + +/* Check that the 'struct timeval' type is defined. */ +struct timeval a; + +/* 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; + +int +main (void) +{ + /* Check that FD_ZERO can be used. This should not yield a warning + such as "warning: implicit declaration of function 'memset'". */ + fd_set fds; + FD_ZERO (&fds); + + return 0; +} diff --git a/gnulib-tests/test-sys_socket.c b/gnulib-tests/test-sys_socket.c new file mode 100644 index 0000000..82c1419 --- /dev/null +++ b/gnulib-tests/test-sys_socket.c @@ -0,0 +1,68 @@ +/* Test of <sys/socket.h> substitute. + Copyright (C) 2007, 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <sys/socket.h> + +#include <errno.h> + +#if HAVE_SHUTDOWN +/* Check some integer constant expressions. */ +int a[] = { SHUT_RD, SHUT_WR, SHUT_RDWR }; +#endif + +/* Check that the 'socklen_t' type is defined. */ +socklen_t t1; + +/* Check that the 'size_t' and 'ssize_t' types are defined. */ +size_t t2; +ssize_t t3; + +/* Check that 'struct iovec' is defined. */ +struct iovec io; + +/* Check that a minimal set of 'struct msghdr' is defined. */ +struct msghdr msg; + +int +main (void) +{ + struct sockaddr_storage x; + sa_family_t i; + + /* Check some errno values. */ + switch (ENOTSOCK) + { + case ENOTSOCK: + case EADDRINUSE: + case ENETRESET: + case ECONNABORTED: + case ECONNRESET: + case ENOTCONN: + case ESHUTDOWN: + break; + } + + x.ss_family = 42; + i = 42; + msg.msg_iov = &io; + + return (x.ss_family - i + msg.msg_namelen + msg.msg_iov->iov_len + + msg.msg_iovlen); +} diff --git a/gnulib-tests/test-sys_stat.c b/gnulib-tests/test-sys_stat.c new file mode 100644 index 0000000..a75f5f6 --- /dev/null +++ b/gnulib-tests/test-sys_stat.c @@ -0,0 +1,340 @@ +/* Test of <sys/stat.h> substitute. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <sys/stat.h> + +#include "verify.h" + +/* Check the existence of some macros. */ +int a[] = + { + S_IFMT, +#ifdef S_IFBLK /* missing on MSVC */ + S_IFBLK, +#endif + S_IFCHR, S_IFDIR, S_IFIFO, S_IFREG, +#ifdef S_IFLNK /* missing on native Windows and DJGPP */ + S_IFLNK, +#endif +#ifdef S_IFSOCK /* missing on native Windows and DJGPP */ + S_IFSOCK, +#endif + S_IRWXU, S_IRUSR, S_IWUSR, S_IXUSR, + S_IRWXG, S_IRGRP, S_IWGRP, S_IXGRP, + S_IRWXO, S_IROTH, S_IWOTH, S_IXOTH, + S_ISUID, S_ISGID, S_ISVTX, + S_ISBLK (S_IFREG), + S_ISCHR (S_IFREG), + S_ISDIR (S_IFREG), + S_ISFIFO (S_IFREG), + S_ISREG (S_IFREG), + S_ISLNK (S_IFREG), + S_ISSOCK (S_IFREG), + S_ISDOOR (S_IFREG), + S_ISMPB (S_IFREG), + S_ISMPX (S_IFREG), + S_ISNAM (S_IFREG), + S_ISNWK (S_IFREG), + S_ISPORT (S_IFREG), + S_ISCTG (S_IFREG), + S_ISOFD (S_IFREG), + S_ISOFL (S_IFREG), + S_ISWHT (S_IFREG) + }; + +/* Sanity checks. */ + +verify (S_IRWXU == (S_IRUSR | S_IWUSR | S_IXUSR)); +verify (S_IRWXG == (S_IRGRP | S_IWGRP | S_IXGRP)); +verify (S_IRWXO == (S_IROTH | S_IWOTH | S_IXOTH)); + +#ifdef S_IFBLK +verify (S_ISBLK (S_IFBLK)); +#endif +verify (!S_ISBLK (S_IFCHR)); +verify (!S_ISBLK (S_IFDIR)); +verify (!S_ISBLK (S_IFIFO)); +verify (!S_ISBLK (S_IFREG)); +#ifdef S_IFLNK +verify (!S_ISBLK (S_IFLNK)); +#endif +#ifdef S_IFSOCK +verify (!S_ISBLK (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +verify (!S_ISCHR (S_IFBLK)); +#endif +verify (S_ISCHR (S_IFCHR)); +verify (!S_ISCHR (S_IFDIR)); +verify (!S_ISCHR (S_IFIFO)); +verify (!S_ISCHR (S_IFREG)); +#ifdef S_IFLNK +verify (!S_ISCHR (S_IFLNK)); +#endif +#ifdef S_IFSOCK +verify (!S_ISCHR (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +verify (!S_ISDIR (S_IFBLK)); +#endif +verify (!S_ISDIR (S_IFCHR)); +verify (S_ISDIR (S_IFDIR)); +verify (!S_ISDIR (S_IFIFO)); +verify (!S_ISDIR (S_IFREG)); +#ifdef S_IFLNK +verify (!S_ISDIR (S_IFLNK)); +#endif +#ifdef S_IFSOCK +verify (!S_ISDIR (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +verify (!S_ISFIFO (S_IFBLK)); +#endif +verify (!S_ISFIFO (S_IFCHR)); +verify (!S_ISFIFO (S_IFDIR)); +verify (S_ISFIFO (S_IFIFO)); +verify (!S_ISFIFO (S_IFREG)); +#ifdef S_IFLNK +verify (!S_ISFIFO (S_IFLNK)); +#endif +#ifdef S_IFSOCK +verify (!S_ISFIFO (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +verify (!S_ISREG (S_IFBLK)); +#endif +verify (!S_ISREG (S_IFCHR)); +verify (!S_ISREG (S_IFDIR)); +verify (!S_ISREG (S_IFIFO)); +verify (S_ISREG (S_IFREG)); +#ifdef S_IFLNK +verify (!S_ISREG (S_IFLNK)); +#endif +#ifdef S_IFSOCK +verify (!S_ISREG (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +verify (!S_ISLNK (S_IFBLK)); +#endif +verify (!S_ISLNK (S_IFCHR)); +verify (!S_ISLNK (S_IFDIR)); +verify (!S_ISLNK (S_IFIFO)); +verify (!S_ISLNK (S_IFREG)); +#ifdef S_IFLNK +verify (S_ISLNK (S_IFLNK)); +#endif +#ifdef S_IFSOCK +verify (!S_ISLNK (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +verify (!S_ISSOCK (S_IFBLK)); +#endif +verify (!S_ISSOCK (S_IFCHR)); +verify (!S_ISSOCK (S_IFDIR)); +verify (!S_ISSOCK (S_IFIFO)); +verify (!S_ISSOCK (S_IFREG)); +#ifdef S_IFLNK +verify (!S_ISSOCK (S_IFLNK)); +#endif +#ifdef S_IFSOCK +verify (S_ISSOCK (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +verify (!S_ISDOOR (S_IFBLK)); +#endif +verify (!S_ISDOOR (S_IFCHR)); +verify (!S_ISDOOR (S_IFDIR)); +verify (!S_ISDOOR (S_IFIFO)); +verify (!S_ISDOOR (S_IFREG)); +#ifdef S_IFLNK +verify (!S_ISDOOR (S_IFLNK)); +#endif +#ifdef S_IFSOCK +verify (!S_ISDOOR (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +verify (!S_ISMPB (S_IFBLK)); +#endif +verify (!S_ISMPB (S_IFCHR)); +verify (!S_ISMPB (S_IFDIR)); +verify (!S_ISMPB (S_IFIFO)); +verify (!S_ISMPB (S_IFREG)); +#ifdef S_IFLNK +verify (!S_ISMPB (S_IFLNK)); +#endif +#ifdef S_IFSOCK +verify (!S_ISMPB (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +verify (!S_ISMPX (S_IFBLK)); +#endif +verify (!S_ISMPX (S_IFCHR)); +verify (!S_ISMPX (S_IFDIR)); +verify (!S_ISMPX (S_IFIFO)); +verify (!S_ISMPX (S_IFREG)); +#ifdef S_IFLNK +verify (!S_ISMPX (S_IFLNK)); +#endif +#ifdef S_IFSOCK +verify (!S_ISMPX (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +verify (!S_ISNAM (S_IFBLK)); +#endif +verify (!S_ISNAM (S_IFCHR)); +verify (!S_ISNAM (S_IFDIR)); +verify (!S_ISNAM (S_IFIFO)); +verify (!S_ISNAM (S_IFREG)); +#ifdef S_IFLNK +verify (!S_ISNAM (S_IFLNK)); +#endif +#ifdef S_IFSOCK +verify (!S_ISNAM (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +verify (!S_ISNWK (S_IFBLK)); +#endif +verify (!S_ISNWK (S_IFCHR)); +verify (!S_ISNWK (S_IFDIR)); +verify (!S_ISNWK (S_IFIFO)); +verify (!S_ISNWK (S_IFREG)); +#ifdef S_IFLNK +verify (!S_ISNWK (S_IFLNK)); +#endif +#ifdef S_IFSOCK +verify (!S_ISNWK (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +verify (!S_ISPORT (S_IFBLK)); +#endif +verify (!S_ISPORT (S_IFCHR)); +verify (!S_ISPORT (S_IFDIR)); +verify (!S_ISPORT (S_IFIFO)); +verify (!S_ISPORT (S_IFREG)); +#ifdef S_IFLNK +verify (!S_ISPORT (S_IFLNK)); +#endif +#ifdef S_IFSOCK +verify (!S_ISPORT (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +verify (!S_ISCTG (S_IFBLK)); +#endif +verify (!S_ISCTG (S_IFCHR)); +verify (!S_ISCTG (S_IFDIR)); +verify (!S_ISCTG (S_IFIFO)); +verify (!S_ISCTG (S_IFREG)); +#ifdef S_IFLNK +verify (!S_ISCTG (S_IFLNK)); +#endif +#ifdef S_IFSOCK +verify (!S_ISCTG (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +verify (!S_ISOFD (S_IFBLK)); +#endif +verify (!S_ISOFD (S_IFCHR)); +verify (!S_ISOFD (S_IFDIR)); +verify (!S_ISOFD (S_IFIFO)); +verify (!S_ISOFD (S_IFREG)); +#ifdef S_IFLNK +verify (!S_ISOFD (S_IFLNK)); +#endif +#ifdef S_IFSOCK +verify (!S_ISOFD (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +verify (!S_ISOFL (S_IFBLK)); +#endif +verify (!S_ISOFL (S_IFCHR)); +verify (!S_ISOFL (S_IFDIR)); +verify (!S_ISOFL (S_IFIFO)); +verify (!S_ISOFL (S_IFREG)); +#ifdef S_IFLNK +verify (!S_ISOFL (S_IFLNK)); +#endif +#ifdef S_IFSOCK +verify (!S_ISOFL (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +verify (!S_ISWHT (S_IFBLK)); +#endif +verify (!S_ISWHT (S_IFCHR)); +verify (!S_ISWHT (S_IFDIR)); +verify (!S_ISWHT (S_IFIFO)); +verify (!S_ISWHT (S_IFREG)); +#ifdef S_IFLNK +verify (!S_ISWHT (S_IFLNK)); +#endif +#ifdef S_IFSOCK +verify (!S_ISWHT (S_IFSOCK)); +#endif + +/* POSIX 2008 requires traditional encoding of permission constants. */ +verify (S_IRWXU == 00700); +verify (S_IRUSR == 00400); +verify (S_IWUSR == 00200); +verify (S_IXUSR == 00100); +verify (S_IRWXG == 00070); +verify (S_IRGRP == 00040); +verify (S_IWGRP == 00020); +verify (S_IXGRP == 00010); +verify (S_IRWXO == 00007); +verify (S_IROTH == 00004); +verify (S_IWOTH == 00002); +verify (S_IXOTH == 00001); +verify (S_ISUID == 04000); +verify (S_ISGID == 02000); +verify (S_ISVTX == 01000); + +#if ((0 <= UTIME_NOW && UTIME_NOW < 1000000000) \ + || (0 <= UTIME_OMIT && UTIME_OMIT < 1000000000) \ + || UTIME_NOW == UTIME_OMIT) +invalid UTIME macros +#endif + +/* Check the existence of some types. */ +nlink_t t1; +off_t t2; +mode_t t3; + +struct timespec st; + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tests/test-sys_time.c b/gnulib-tests/test-sys_time.c new file mode 100644 index 0000000..db9909b --- /dev/null +++ b/gnulib-tests/test-sys_time.c @@ -0,0 +1,34 @@ +/* Test of <sys/time.h> substitute. + Copyright (C) 2007, 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <sys/time.h> + +/* Check that the 'struct timeval' type is defined. */ +struct timeval a; + +/* 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) +{ + return 0; +} diff --git a/gnulib-tests/test-sys_types.c b/gnulib-tests/test-sys_types.c new file mode 100644 index 0000000..65d49dc --- /dev/null +++ b/gnulib-tests/test-sys_types.c @@ -0,0 +1,34 @@ +/* Test of <sys/types.h> substitute. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2011. */ + +#include <config.h> + +#include <sys/types.h> + +/* Check that the types are all defined. */ +pid_t t1; +size_t t2; +ssize_t t3; +off_t t4; +mode_t t5; + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tests/test-sys_uio.c b/gnulib-tests/test-sys_uio.c new file mode 100644 index 0000000..fc62cf3 --- /dev/null +++ b/gnulib-tests/test-sys_uio.c @@ -0,0 +1,32 @@ +/* Test of <sys/uio.h> substitute. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <eblake@redhat.com>, 2011. */ + +#include <config.h> + +#include <sys/uio.h> + +/* Check that necessary types are defined. */ +size_t a; +ssize_t b; +struct iovec c; + +int +main (void) +{ + return a + b + !!c.iov_base + c.iov_len; +} diff --git a/gnulib-tests/test-sys_utsname.c b/gnulib-tests/test-sys_utsname.c new file mode 100644 index 0000000..38efa5d --- /dev/null +++ b/gnulib-tests/test-sys_utsname.c @@ -0,0 +1,37 @@ +/* Test of <sys/utsname.h> substitute. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2009. */ + +#include <config.h> + +#include <sys/utsname.h> + +#include <string.h> + +int +main () +{ + struct utsname buf; + + strcpy (buf.sysname, "Linux"); + strcpy (buf.nodename, "hobbybox"); + strcpy (buf.release, "3.141.592"); + strcpy (buf.version, "GENERIC"); + strcpy (buf.machine, "i586"); + + return 0; +} diff --git a/gnulib-tests/test-sys_wait.c b/gnulib-tests/test-sys_wait.c new file mode 100644 index 0000000..443fef8 --- /dev/null +++ b/gnulib-tests/test-sys_wait.c @@ -0,0 +1,47 @@ +/* Test of <sys/wait.h> substitute. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <sys/wait.h> + +/* Check for existence of required types. */ +static pid_t a; + +#include "test-sys_wait.h" + +int +main (void) +{ + if (test_sys_wait_macros ()) + return 1; + +#if 0 + switch (WCONTINUED) + { + /* Gnulib doesn't guarantee these, yet. */ + case WCONTINUED: + case WEXITED: + case WNOWAIT: + case WSTOPPED: + break; + } +#endif + + return a ? 1 : 0; +} diff --git a/gnulib-tests/test-sys_wait.h b/gnulib-tests/test-sys_wait.h new file mode 100644 index 0000000..20c4f31 --- /dev/null +++ b/gnulib-tests/test-sys_wait.h @@ -0,0 +1,53 @@ +/* Test of macros shared between <sys/wait.h> and <stdlib.h>. + Copyright (C) 2010-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2010. */ + +static int +test_sys_wait_macros (void) +{ + /* Check subset of <sys/wait.h> macros that must be visible here. + Note that some of these macros are only portable when operating + on an lvalue. */ + int i; + for (i = 0; i < 0x8000; i = (i ? i << 1 : 1)) + { + /* POSIX requires that for all valid process statuses, that + exactly one of these three macros is true. But not all + possible 16-bit values map to valid process status. + Traditionally, 8 of the bits are for WIFEXITED, 7 of the bits + to tell between WIFSIGNALED and WIFSTOPPED, and either 0x80 + or 0x8000 to flag that core was also dumped. Since we don't + know which byte is WIFEXITED, we skip the both possible bits + that can signal core dump. */ + if (i == 0x80) + continue; + if (!!WIFSIGNALED (i) + !!WIFEXITED (i) + !!WIFSTOPPED (i) != 1) + return 1; + } + i = WEXITSTATUS (i) + WSTOPSIG (i) + WTERMSIG (i); + + switch (i) + { +#if 0 + /* Gnulib doesn't guarantee these, yet. */ + case WNOHANG: + case WUNTRACED: +#endif + break; + } + return 0; +} diff --git a/gnulib-tests/test-termios.c b/gnulib-tests/test-termios.c new file mode 100644 index 0000000..63223e6 --- /dev/null +++ b/gnulib-tests/test-termios.c @@ -0,0 +1,30 @@ +/* Test of <termios.h> substitute. + Copyright (C) 2010-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2010. */ + +#include <config.h> + +#include <termios.h> + +/* Check that the types are all defined. */ +pid_t t1; + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tests/test-thread_create.c b/gnulib-tests/test-thread_create.c new file mode 100644 index 0000000..320d64a --- /dev/null +++ b/gnulib-tests/test-thread_create.c @@ -0,0 +1,78 @@ +/* Test of gl_thread_create () macro. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2011. */ + +#include <config.h> + +#include "glthread/thread.h" + +#include <stdio.h> +#include <string.h> + +#include "macros.h" + +static gl_thread_t main_thread_before; +static gl_thread_t main_thread_after; +static gl_thread_t worker_thread; + +static int dummy; +static volatile int work_done; + +static void * +worker_thread_func (void *arg) +{ + work_done = 1; + return &dummy; +} + +int +main () +{ + main_thread_before = gl_thread_self (); + + if (glthread_create (&worker_thread, worker_thread_func, NULL) == 0) + { + void *ret; + + /* Check that gl_thread_self () has the same value before than after the + first call to gl_thread_create (). */ + main_thread_after = gl_thread_self (); + ASSERT (memcmp (&main_thread_before, &main_thread_after, + sizeof (gl_thread_t)) + == 0); + + gl_thread_join (worker_thread, &ret); + + /* Check the return value of the thread. */ + ASSERT (ret == &dummy); + + /* Check that worker_thread_func () has finished executing. */ + ASSERT (work_done); + + return 0; + } + else + { +#if USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS || USE_WINDOWS_THREADS + fputs ("glthread_create failed\n", stderr); + return 1; +#else + fputs ("Skipping test: multithreading not enabled\n", stderr); + return 77; +#endif + } +} diff --git a/gnulib-tests/test-thread_self.c b/gnulib-tests/test-thread_self.c new file mode 100644 index 0000000..f0c302b --- /dev/null +++ b/gnulib-tests/test-thread_self.c @@ -0,0 +1,39 @@ +/* Test of gl_thread_self () macro. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2011. */ + +#include <config.h> + +#include "glthread/thread.h" + +gl_thread_t main_thread; + +int +main () +{ + /* Check that gl_thread_self () can be used with just $(LIBTHREAD), not + $(LIBMULTITHREAD), i.e. in libraries that are multithread-safe but don't + create threads themselves. */ + /* This is not the case on AIX with --enable-threads=isoc+posix, because in + this case, $(LIBTHREAD) is empty whereas $(LIBMULTITHREAD) is '-lpthread'. + */ +#if !defined _AIX + main_thread = gl_thread_self (); +#endif + + return 0; +} diff --git a/gnulib-tests/test-time.c b/gnulib-tests/test-time.c new file mode 100644 index 0000000..1587c28 --- /dev/null +++ b/gnulib-tests/test-time.c @@ -0,0 +1,41 @@ +/* Test of <time.h> substitute. + Copyright (C) 2007, 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <time.h> + +#include "verify.h" + +/* Check that the types are all defined. */ +struct timespec t1; +#if 0 +/* POSIX:2008 does not require pid_t in <time.h> unconditionally, and indeed + it's missing on Mac OS X 10.5, FreeBSD 6.4, OpenBSD 4.9, mingw. */ +pid_t t2; +#endif + +/* Check that NULL can be passed through varargs as a pointer type, + per POSIX 2008. */ +verify (sizeof NULL == sizeof (void *)); + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tests/test-timespec.c b/gnulib-tests/test-timespec.c new file mode 100644 index 0000000..3d4672c --- /dev/null +++ b/gnulib-tests/test-timespec.c @@ -0,0 +1,167 @@ +/* Test timespec functions. + Copyright 2015-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Paul Eggert. */ + +#include <config.h> + +#include "timespec.h" + +#include "intprops.h" +#include "macros.h" + +#include <stdbool.h> +#include <limits.h> + +static struct { int s; int ns; } const prototype[] = + { + { INT_MIN, 0 }, + { INT_MIN, 1 }, + { INT_MIN, TIMESPEC_HZ - 1 }, + { INT_MIN + 1, 0 }, + { INT_MIN + 1, 1 }, + { INT_MIN + 1, TIMESPEC_HZ - 1 }, + { -1, 0 }, + { -1, 1 }, + { -1, TIMESPEC_HZ - 1 }, + { 0, 0 }, + { 0, 1 }, + { 0, TIMESPEC_HZ - 1 }, + { 1, 0 }, + { 1, 1 }, + { 1, TIMESPEC_HZ - 1 }, + { 1234567890, 0 }, + { 1234567890, 1 }, + { 1234567890, TIMESPEC_HZ - 1 }, + { INT_MAX - 1, 0 }, + { INT_MAX - 1, 1 }, + { INT_MAX - 1, TIMESPEC_HZ - 1 }, + { INT_MAX, 0 }, + { INT_MAX, 1 }, + { INT_MAX, TIMESPEC_HZ - 1 }, + { INT_MAX, 2 * TIMESPEC_HZ } + }; +enum { nprototypes = sizeof prototype / sizeof *prototype }; + +static bool +valid (struct timespec a) +{ + return 0 <= a.tv_nsec && a.tv_nsec < TIMESPEC_HZ; +} + +static int +sign (int i) +{ + return i < 0 ? -1 : 0 < i; +} + +static int +cmp (struct timespec a, struct timespec b) +{ + return sign (timespec_cmp (a, b)); +} + +static bool +eq (struct timespec a, struct timespec b) +{ + return timespec_cmp (a, b) == 0; +} + +static bool +extremal (struct timespec a) +{ + return ((a.tv_sec == TYPE_MINIMUM (time_t) && a.tv_nsec == 0) + || (a.tv_sec == TYPE_MAXIMUM (time_t) + && a.tv_nsec == TIMESPEC_HZ - 1)); +} + +int +main (void) +{ + int i, j, k; + struct timespec test[nprototypes + 1]; + int ntests; + int computed_hz = 1; + struct timespec prevroundtrip; + + test[0] = make_timespec (TYPE_MINIMUM (time_t), -1); + ntests = 1; + for (i = 0; i < nprototypes; i++) + { + int s = prototype[i].s; + if (TYPE_SIGNED (time_t) || 0 <= s) + { + time_t t = (s <= INT_MIN + 1 ? s - INT_MIN + TYPE_MINIMUM (time_t) + : INT_MAX - 1 <= s ? s - INT_MAX + TYPE_MAXIMUM (time_t) + : s); + test[ntests++] = make_timespec (t, prototype[i].ns); + } + } + + for (i = 0; i < LOG10_TIMESPEC_HZ; i++) + computed_hz *= 10; + ASSERT (computed_hz == TIMESPEC_HZ); + + for (i = 0; i < ntests; i++) + { + struct timespec a = test[i]; + + struct timespec roundtrip = dtotimespec (timespectod (a)); + if (i != 0) + ASSERT (cmp (prevroundtrip, roundtrip) <= 0); + prevroundtrip = roundtrip; + + ASSERT (sign (timespec_sign (a)) == cmp (a, make_timespec (0, 0))); + + if (valid (a)) + for (j = 0; j < ntests; j++) + { + struct timespec b = test[j]; + if (valid (b)) + { + struct timespec sum = timespec_add (a, b); + struct timespec diff = timespec_sub (a, b); + struct timespec rdiff = timespec_sub (b, a); + ASSERT (cmp (a, b) == sign (i - j)); + ASSERT (eq (sum, timespec_add (b, a))); + if (! extremal (sum)) + { + ASSERT (eq (a, timespec_sub (sum, b))); + ASSERT (eq (b, timespec_sub (sum, a))); + + for (k = 0; k < ntests; k++) + { + struct timespec c = test[k]; + if (valid (c)) + { + struct timespec sumbc = timespec_add (b, c); + if (! extremal (sumbc)) + ASSERT (eq (timespec_add (a, sumbc), + timespec_add (sum, c))); + } + } + } + if (! extremal (diff)) + ASSERT (eq (a, timespec_add (diff, b))); + if (! extremal (rdiff)) + ASSERT (eq (b, timespec_add (rdiff, a))); + + } + } + } + + return 0; +} diff --git a/gnulib-tests/test-tls.c b/gnulib-tests/test-tls.c new file mode 100644 index 0000000..0a62efc --- /dev/null +++ b/gnulib-tests/test-tls.c @@ -0,0 +1,538 @@ +/* Test of thread-local storage in multithreaded situations. + Copyright (C) 2005, 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2005. */ + +#include <config.h> + +#if USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS || USE_WINDOWS_THREADS + +#if USE_ISOC_THREADS || USE_ISOC_AND_POSIX_THREADS +# define TEST_ISOC_THREADS 1 +#endif +#if USE_POSIX_THREADS +# define TEST_POSIX_THREADS 1 +#endif +#if USE_WINDOWS_THREADS +# define TEST_WINDOWS_THREADS 1 +#endif + +/* Whether to help the scheduler through explicit yield(). + Uncomment this to see if the operating system has a fair scheduler. */ +#define EXPLICIT_YIELD 1 + +/* Whether to print debugging messages. */ +#define ENABLE_DEBUGGING 0 + +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "glthread/tls.h" +#include "glthread/thread.h" +#include "glthread/lock.h" +#include "glthread/yield.h" + +#if HAVE_DECL_ALARM +# include <signal.h> +# include <unistd.h> +#endif + +#if ENABLE_DEBUGGING +# define dbgprintf printf +#else +# define dbgprintf if (0) printf +#endif + +#if EXPLICIT_YIELD +# define yield() gl_thread_yield () +#else +# define yield() +#endif + +static void +perhaps_yield (void) +{ + /* This helps making the sequence of thread activations less predictable. */ + if ((((unsigned int) rand () >> 3) % 4) == 0) + yield (); +} + + +/* ----------------------- Test thread-local storage ----------------------- */ + +/* Number of simultaneous threads. */ +#define THREAD_COUNT 16 + +/* Number of operations performed in each thread. */ +#define REPEAT_COUNT 50000 + +#define KEYS_COUNT 4 + +static gl_tls_key_t mykeys[KEYS_COUNT]; + +static void * +worker_thread (void *arg) +{ + unsigned int id = (unsigned int) (uintptr_t) arg; + int i, j, repeat; + unsigned int values[KEYS_COUNT]; + + dbgprintf ("Worker %p started\n", gl_thread_self_pointer ()); + + /* Initialize the per-thread storage. */ + for (i = 0; i < KEYS_COUNT; i++) + { + values[i] = (((unsigned int) rand () >> 3) % 1000000) * THREAD_COUNT + id; + /* Hopefully no arithmetic overflow. */ + if ((values[i] % THREAD_COUNT) != id) + abort (); + } + perhaps_yield (); + + /* Verify that the initial value is NULL. */ + dbgprintf ("Worker %p before initial verify\n", gl_thread_self_pointer ()); + for (i = 0; i < KEYS_COUNT; i++) + if (gl_tls_get (mykeys[i]) != NULL) + abort (); + dbgprintf ("Worker %p after initial verify\n", gl_thread_self_pointer ()); + perhaps_yield (); + + /* Initialize the per-thread storage. */ + dbgprintf ("Worker %p before first tls_set\n", gl_thread_self_pointer ()); + for (i = 0; i < KEYS_COUNT; i++) + { + unsigned int *ptr = (unsigned int *) malloc (sizeof (unsigned int)); + *ptr = values[i]; + gl_tls_set (mykeys[i], ptr); + } + dbgprintf ("Worker %p after first tls_set\n", gl_thread_self_pointer ()); + perhaps_yield (); + + /* Shuffle around the pointers. */ + for (repeat = REPEAT_COUNT; repeat > 0; repeat--) + { + dbgprintf ("Worker %p doing value swapping\n", gl_thread_self_pointer ()); + i = ((unsigned int) rand () >> 3) % KEYS_COUNT; + j = ((unsigned int) rand () >> 3) % KEYS_COUNT; + if (i != j) + { + void *vi = gl_tls_get (mykeys[i]); + void *vj = gl_tls_get (mykeys[j]); + + gl_tls_set (mykeys[i], vj); + gl_tls_set (mykeys[j], vi); + } + perhaps_yield (); + } + + /* Verify that all the values are from this thread. */ + dbgprintf ("Worker %p before final verify\n", gl_thread_self_pointer ()); + for (i = 0; i < KEYS_COUNT; i++) + if ((*(unsigned int *) gl_tls_get (mykeys[i]) % THREAD_COUNT) != id) + abort (); + dbgprintf ("Worker %p after final verify\n", gl_thread_self_pointer ()); + perhaps_yield (); + + dbgprintf ("Worker %p dying.\n", gl_thread_self_pointer ()); + return NULL; +} + +static void +test_tls (void) +{ + int pass, i; + + for (pass = 0; pass < 2; pass++) + { + gl_thread_t threads[THREAD_COUNT]; + + if (pass == 0) + for (i = 0; i < KEYS_COUNT; i++) + gl_tls_key_init (mykeys[i], free); + else + for (i = KEYS_COUNT - 1; i >= 0; i--) + gl_tls_key_init (mykeys[i], free); + + /* Spawn the threads. */ + for (i = 0; i < THREAD_COUNT; i++) + threads[i] = gl_thread_create (worker_thread, (void *) (uintptr_t) i); + + /* Wait for the threads to terminate. */ + for (i = 0; i < THREAD_COUNT; i++) + gl_thread_join (threads[i], NULL); + + for (i = 0; i < KEYS_COUNT; i++) + gl_tls_key_destroy (mykeys[i]); + } +} + +#undef KEYS_COUNT +#undef REPEAT_COUNT +#undef THREAD_COUNT + + +/* --------------- Test thread-local storage with destructors --------------- */ + +/* Number of simultaneous threads. */ +#define THREAD_COUNT 10 + +/* Number of keys to allocate in each thread. */ +#define KEYS_COUNT 10 + +gl_lock_define_initialized(static, sumlock) +static uintptr_t sum; + +static void +inc_sum (uintptr_t value) +{ + gl_lock_lock (sumlock); + sum += value; + gl_lock_unlock (sumlock); +} + +static void +destructor0 (void *value) +{ + if ((((uintptr_t) value - 1) % 10) != 0) + abort (); + inc_sum ((uintptr_t) value); +} + +static void +destructor1 (void *value) +{ + if ((((uintptr_t) value - 1) % 10) != 1) + abort (); + inc_sum ((uintptr_t) value); +} + +static void +destructor2 (void *value) +{ + if ((((uintptr_t) value - 1) % 10) != 2) + abort (); + inc_sum ((uintptr_t) value); +} + +static void +destructor3 (void *value) +{ + if ((((uintptr_t) value - 1) % 10) != 3) + abort (); + inc_sum ((uintptr_t) value); +} + +static void +destructor4 (void *value) +{ + if ((((uintptr_t) value - 1) % 10) != 4) + abort (); + inc_sum ((uintptr_t) value); +} + +static void +destructor5 (void *value) +{ + if ((((uintptr_t) value - 1) % 10) != 5) + abort (); + inc_sum ((uintptr_t) value); +} + +static void +destructor6 (void *value) +{ + if ((((uintptr_t) value - 1) % 10) != 6) + abort (); + inc_sum ((uintptr_t) value); +} + +static void +destructor7 (void *value) +{ + if ((((uintptr_t) value - 1) % 10) != 7) + abort (); + inc_sum ((uintptr_t) value); +} + +static void +destructor8 (void *value) +{ + if ((((uintptr_t) value - 1) % 10) != 8) + abort (); + inc_sum ((uintptr_t) value); +} + +static void +destructor9 (void *value) +{ + if ((((uintptr_t) value - 1) % 10) != 9) + abort (); + inc_sum ((uintptr_t) value); +} + +static void (*destructor_table[10]) (void *) = + { + destructor0, + destructor1, + destructor2, + destructor3, + destructor4, + destructor5, + destructor6, + destructor7, + destructor8, + destructor9 + }; + +static gl_tls_key_t dtorcheck_keys[THREAD_COUNT][KEYS_COUNT]; + +/* Worker thread that uses destructors that verify that the destructor belongs + to the right thread. */ +static void * +dtorcheck1_thread (void *arg) +{ + unsigned int id = (unsigned int) (uintptr_t) arg; + gl_tls_key_t *keys = dtorcheck_keys[id]; /* an array of KEYS_COUNT keys */ + int i; + + for (i = 0; i < KEYS_COUNT; i++) + gl_tls_key_init (keys[i], destructor_table[i]); + + for (i = 0; i < KEYS_COUNT; i++) + gl_tls_set (keys[i], (void *) (uintptr_t) (10 * id + i + 1)); + + return NULL; +} + +static void +test_tls_dtorcheck1 (void) +{ + gl_thread_t threads[THREAD_COUNT]; + unsigned int id; + int i; + uintptr_t expected_sum; + + sum = 0; + + /* Spawn the threads. */ + for (id = 0; id < THREAD_COUNT; id++) + threads[id] = gl_thread_create (dtorcheck1_thread, (void *) (uintptr_t) id); + + /* Wait for the threads to terminate. */ + for (id = 0; id < THREAD_COUNT; id++) + gl_thread_join (threads[id], NULL); + + /* Clean up the keys. */ + for (id = 0; id < THREAD_COUNT; id++) + for (i = 0; i < KEYS_COUNT; i++) + gl_tls_key_destroy (dtorcheck_keys[id][i]); + + /* Check that the destructor was invoked for each key. */ + expected_sum = 10 * KEYS_COUNT * (THREAD_COUNT * (THREAD_COUNT - 1) / 2) + + THREAD_COUNT * (KEYS_COUNT * (KEYS_COUNT - 1) / 2) + + THREAD_COUNT * KEYS_COUNT; + if (sum != expected_sum) + abort (); +} + +/* Worker thread that uses destructors that verify that the destructor belongs + to the right key allocated within the thread. */ +static void * +dtorcheck2_thread (void *arg) +{ + unsigned int id = (unsigned int) (uintptr_t) arg; + gl_tls_key_t *keys = dtorcheck_keys[id]; /* an array of KEYS_COUNT keys */ + int i; + + for (i = 0; i < KEYS_COUNT; i++) + gl_tls_key_init (keys[i], destructor_table[id]); + + for (i = 0; i < KEYS_COUNT; i++) + gl_tls_set (keys[i], (void *) (uintptr_t) (10 * i + id + 1)); + + return NULL; +} + +static void +test_tls_dtorcheck2 (void) +{ + gl_thread_t threads[THREAD_COUNT]; + unsigned int id; + int i; + uintptr_t expected_sum; + + sum = 0; + + /* Spawn the threads. */ + for (id = 0; id < THREAD_COUNT; id++) + threads[id] = gl_thread_create (dtorcheck2_thread, (void *) (uintptr_t) id); + + /* Wait for the threads to terminate. */ + for (id = 0; id < THREAD_COUNT; id++) + gl_thread_join (threads[id], NULL); + + /* Clean up the keys. */ + for (id = 0; id < THREAD_COUNT; id++) + for (i = 0; i < KEYS_COUNT; i++) + gl_tls_key_destroy (dtorcheck_keys[id][i]); + + /* Check that the destructor was invoked for each key. */ + expected_sum = 10 * THREAD_COUNT * (KEYS_COUNT * (KEYS_COUNT - 1) / 2) + + KEYS_COUNT * (THREAD_COUNT * (THREAD_COUNT - 1) / 2) + + THREAD_COUNT * KEYS_COUNT; + if (sum != expected_sum) + abort (); +} + +#undef KEYS_COUNT +#undef THREAD_COUNT + + +/* --- Test thread-local storage with with races between init and destroy --- */ + +/* Number of simultaneous threads. */ +#define THREAD_COUNT 10 + +/* Number of keys to allocate in each thread. */ +#define KEYS_COUNT 10 + +/* Number of times to destroy and reallocate a key in each thread. */ +#define REPEAT_COUNT 100000 + +static gl_tls_key_t racecheck_keys[THREAD_COUNT][KEYS_COUNT]; + +/* Worker thread that does many destructions and reallocations of keys, and also + uses destructors that verify that the destructor belongs to the right key. */ +static void * +racecheck_thread (void *arg) +{ + unsigned int id = (unsigned int) (uintptr_t) arg; + gl_tls_key_t *keys = racecheck_keys[id]; /* an array of KEYS_COUNT keys */ + int repeat; + int i; + + dbgprintf ("Worker %p started\n", gl_thread_self_pointer ()); + + for (i = 0; i < KEYS_COUNT; i++) + { + gl_tls_key_init (keys[i], destructor_table[i]); + gl_tls_set (keys[i], (void *) (uintptr_t) (10 * id + i + 1)); + } + + for (repeat = REPEAT_COUNT; repeat > 0; repeat--) + { + i = ((unsigned int) rand () >> 3) % KEYS_COUNT; + dbgprintf ("Worker %p reallocating key %d\n", gl_thread_self_pointer (), i); + gl_tls_key_destroy (keys[i]); + gl_tls_key_init (keys[i], destructor_table[i]); + gl_tls_set (keys[i], (void *) (uintptr_t) (10 * id + i + 1)); + } + + dbgprintf ("Worker %p dying.\n", gl_thread_self_pointer ()); + return NULL; +} + +static void +test_tls_racecheck (void) +{ + gl_thread_t threads[THREAD_COUNT]; + unsigned int id; + int i; + uintptr_t expected_sum; + + sum = 0; + + /* Spawn the threads. */ + for (id = 0; id < THREAD_COUNT; id++) + threads[id] = gl_thread_create (racecheck_thread, (void *) (uintptr_t) id); + + /* Wait for the threads to terminate. */ + for (id = 0; id < THREAD_COUNT; id++) + gl_thread_join (threads[id], NULL); + + /* Clean up the keys. */ + for (id = 0; id < THREAD_COUNT; id++) + for (i = 0; i < KEYS_COUNT; i++) + gl_tls_key_destroy (racecheck_keys[id][i]); + + /* Check that the destructor was invoked for each key. */ + expected_sum = 10 * KEYS_COUNT * (THREAD_COUNT * (THREAD_COUNT - 1) / 2) + + THREAD_COUNT * (KEYS_COUNT * (KEYS_COUNT - 1) / 2) + + THREAD_COUNT * KEYS_COUNT; + if (sum != expected_sum) + abort (); +} + +#undef REPEAT_COUNT +#undef KEYS_COUNT +#undef THREAD_COUNT + + +/* -------------------------------------------------------------------------- */ + +int +main () +{ +#if HAVE_DECL_ALARM + /* Declare failure if test takes too long, by using default abort + caused by SIGALRM. */ + int alarm_value = 600; + signal (SIGALRM, SIG_DFL); + alarm (alarm_value); +#endif + + printf ("Starting test_tls ..."); fflush (stdout); + test_tls (); + printf (" OK\n"); fflush (stdout); + + printf ("Starting test_tls_dtorcheck1 ..."); fflush (stdout); + test_tls_dtorcheck1 (); + printf (" OK\n"); fflush (stdout); + + printf ("Starting test_tls_dtorcheck2 ..."); fflush (stdout); + test_tls_dtorcheck2 (); + printf (" OK\n"); fflush (stdout); + + /* This test hangs with the mingw-w64 winpthreads. */ +#if (defined _WIN32 && ! defined __CYGWIN__) && TEST_POSIX_THREADS + fputs ("Skipping test: it is known to hang with the mingw-w64 winpthreads.\n", + stderr); + exit (77); +#else + printf ("Starting test_tls_racecheck ..."); fflush (stdout); + test_tls_racecheck (); + printf (" OK\n"); fflush (stdout); +#endif + + return 0; +} + +#else + +/* No multithreading available. */ + +#include <stdio.h> + +int +main () +{ + fputs ("Skipping test: multithreading not enabled\n", stderr); + return 77; +} + +#endif diff --git a/gnulib-tests/test-u64.c b/gnulib-tests/test-u64.c new file mode 100644 index 0000000..d7dc5b8 --- /dev/null +++ b/gnulib-tests/test-u64.c @@ -0,0 +1,47 @@ +/* Test of <u64.h> + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Simon Josefsson <simon@josefsson.org>, 2009. */ + +#include <config.h> + +#include <u64.h> + +int +main (void) +{ + u64 i = u64init (42, 4711); + u64 j, k, l; + + j = u64hilo (42, 4711); + + if (u64lt (i, j) || u64lt (j, i)) + return 1; + + i = u64hilo (0, 42); + j = u64hilo (0, 43); + + if (!u64lt (i, j)) + return 1; + + k = u64plus (i, j); + l = u64hilo (0, 42 + 43); + + if (u64lt (k, l) || u64lt (l, k)) + return 1; + + return 0; +} diff --git a/gnulib-tests/test-uname.c b/gnulib-tests/test-uname.c new file mode 100644 index 0000000..96fd675 --- /dev/null +++ b/gnulib-tests/test-uname.c @@ -0,0 +1,64 @@ +/* Test of system information. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2009. */ + +#include <config.h> + +#include <sys/utsname.h> + +#include "signature.h" +SIGNATURE_CHECK (uname, int, (struct utsname *)); + +#include <stdio.h> +#include <string.h> + +#include "macros.h" + + +/* This program can be called with no arguments, then it performs a unit + test. Or it can be called with 1 argument, then it prints the uname + contents to standard output. */ + +int +main (int argc, char *argv[]) +{ + struct utsname buf; + + memset (&buf, '?', sizeof (buf)); + + ASSERT (uname (&buf) >= 0); + + /* Verify that every field's value is NUL terminated. */ + ASSERT (strlen (buf.sysname) < sizeof (buf.sysname)); + ASSERT (strlen (buf.nodename) < sizeof (buf.nodename)); + ASSERT (strlen (buf.release) < sizeof (buf.release)); + ASSERT (strlen (buf.version) < sizeof (buf.version)); + ASSERT (strlen (buf.machine) < sizeof (buf.machine)); + + if (argc > 1) + { + /* Show the result. */ + + printf ("uname -n = nodename = %s\n", buf.nodename); + printf ("uname -s = sysname = %s\n", buf.sysname); + printf ("uname -r = release = %s\n", buf.release); + printf ("uname -v = version = %s\n", buf.version); + printf ("uname -m = machine or cpu = %s\n", buf.machine); + } + + return 0; +} diff --git a/gnulib-tests/test-unistd.c b/gnulib-tests/test-unistd.c new file mode 100644 index 0000000..5ba7d5b --- /dev/null +++ b/gnulib-tests/test-unistd.c @@ -0,0 +1,56 @@ +/* Test of <unistd.h> substitute. + Copyright (C) 2007, 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <unistd.h> + +#include "verify.h" + +/* Check that NULL can be passed through varargs as a pointer type, + per POSIX 2008. */ +verify (sizeof NULL == sizeof (void *)); + +/* Check that the various SEEK_* macros are defined. */ +int sk[] = { SEEK_CUR, SEEK_END, SEEK_SET }; + +/* Check that the various *_FILENO macros are defined. */ +#if ! (defined STDIN_FILENO \ + && (STDIN_FILENO + STDOUT_FILENO + STDERR_FILENO == 3)) +missing or broken *_FILENO macros +#endif + +/* Check that the types are all defined. */ +size_t t1; +ssize_t t2; +#ifdef TODO /* Not implemented in gnulib yet */ +uid_t t3; +gid_t t4; +#endif +off_t t5; +pid_t t6; +#ifdef TODO +useconds_t t7; +intptr_t t8; +#endif + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tests/test-unlink.c b/gnulib-tests/test-unlink.c new file mode 100644 index 0000000..5689185 --- /dev/null +++ b/gnulib-tests/test-unlink.c @@ -0,0 +1,49 @@ +/* Tests of unlink. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (unlink, int, (char const *)); + +#include <fcntl.h> +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> + +#include "unlinkdir.h" +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-unlink.t" + +#include "test-unlink.h" + +int +main (void) +{ + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + return test_unlink_func (unlink, true); +} diff --git a/gnulib-tests/test-unlink.h b/gnulib-tests/test-unlink.h new file mode 100644 index 0000000..98c9a4f --- /dev/null +++ b/gnulib-tests/test-unlink.h @@ -0,0 +1,86 @@ +/* Tests of unlink. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +/* This file is designed to test both unlink(n) and + unlinkat(AT_FDCWD,n,0). FUNC is the function to test. Assumes + that BASE and ASSERT are already defined, and that appropriate + headers are already included. If PRINT, then warn before returning + status 77 when symlinks are unsupported. */ + +static int +test_unlink_func (int (*func) (char const *name), bool print) +{ + /* Setup. */ + ASSERT (mkdir (BASE "dir", 0700) == 0); + ASSERT (close (creat (BASE "dir/file", 0600)) == 0); + + /* Basic error conditions. */ + errno = 0; + ASSERT (func ("") == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func (BASE "nosuch") == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func (BASE "nosuch/") == -1); + ASSERT (errno == ENOENT); + /* Resulting errno after directories is rather varied across + implementations (EPERM, EINVAL, EACCES, EBUSY, EISDIR, ENOTSUP); + however, we must be careful to not attempt unlink on a directory + unless we know it must fail. */ + if (cannot_unlink_dir ()) + { + ASSERT (func (".") == -1); + ASSERT (func ("..") == -1); + ASSERT (func ("/") == -1); + ASSERT (func (BASE "dir") == -1); + ASSERT (mkdir (BASE "dir1", 0700) == 0); + ASSERT (func (BASE "dir1") == -1); + ASSERT (rmdir (BASE "dir1") == 0); + } + errno = 0; + ASSERT (func (BASE "dir/file/") == -1); + ASSERT (errno == ENOTDIR); + + /* Test symlink behavior. Specifying trailing slash will attempt + unlink of a directory, so only attempt it if we know it must + fail. */ + if (symlink (BASE "dir", BASE "link") != 0) + { + ASSERT (func (BASE "dir/file") == 0); + ASSERT (rmdir (BASE "dir") == 0); + if (print) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + if (cannot_unlink_dir ()) + ASSERT (func (BASE "link/") == -1); + ASSERT (func (BASE "link") == 0); + ASSERT (symlink (BASE "dir/file", BASE "link") == 0); + errno = 0; + ASSERT (func (BASE "link/") == -1); + ASSERT (errno == ENOTDIR); + /* Order here proves unlink of a symlink does not follow through to + the file. */ + ASSERT (func (BASE "link") == 0); + ASSERT (func (BASE "dir/file") == 0); + ASSERT (rmdir (BASE "dir") == 0); + + return 0; +} diff --git a/gnulib-tests/test-unlinkat.c b/gnulib-tests/test-unlinkat.c new file mode 100644 index 0000000..80e5e54 --- /dev/null +++ b/gnulib-tests/test-unlinkat.c @@ -0,0 +1,95 @@ +/* Tests of unlinkat. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (unlinkat, int, (int, char const *, int)); + +#include <fcntl.h> +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/stat.h> + +#include "unlinkdir.h" +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-unlinkat.t" + +#include "test-rmdir.h" +#include "test-unlink.h" + +static int dfd = AT_FDCWD; + +/* Wrapper around unlinkat to test rmdir behavior. */ +static int +rmdirat (char const *name) +{ + return unlinkat (dfd, name, AT_REMOVEDIR); +} + +/* Wrapper around unlinkat to test unlink behavior. */ +static int +unlinker (char const *name) +{ + return unlinkat (dfd, name, 0); +} + +int +main (int argc _GL_UNUSED, char *argv[]) +{ + /* FIXME: Add tests of fd other than ".". */ + int result1; + int result2; + + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (unlinkat (-1, "foo", 0) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (unlinkat (99, "foo", 0) == -1); + ASSERT (errno == EBADF); + } + + result1 = test_rmdir_func (rmdirat, false); + result2 = test_unlink_func (unlinker, false); + ASSERT (result1 == result2); + dfd = open (".", O_RDONLY); + ASSERT (0 <= dfd); + result2 = test_rmdir_func (rmdirat, false); + ASSERT (result1 == result2); + result2 = test_unlink_func (unlinker, false); + ASSERT (result1 == result2); + ASSERT (close (dfd) == 0); + if (result1 == 77) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return result1; +} diff --git a/gnulib-tests/test-unsetenv.c b/gnulib-tests/test-unsetenv.c new file mode 100644 index 0000000..f912e79 --- /dev/null +++ b/gnulib-tests/test-unsetenv.c @@ -0,0 +1,61 @@ +/* Tests of unsetenv. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <stdlib.h> + +#include "signature.h" +SIGNATURE_CHECK (unsetenv, int, (char const *)); + +#include <errno.h> +#include <string.h> +#include <unistd.h> + +#include "macros.h" + +int +main (void) +{ + char entry[] = "b=2"; + + /* Test removal when multiple entries present. */ + ASSERT (putenv ((char *) "a=1") == 0); + ASSERT (putenv (entry) == 0); + entry[0] = 'a'; /* Unspecified what getenv("a") would be at this point. */ + ASSERT (unsetenv ("a") == 0); /* Both entries will be removed. */ + ASSERT (getenv ("a") == NULL); + ASSERT (unsetenv ("a") == 0); + + /* Required to fail with EINVAL. */ + errno = 0; + ASSERT (unsetenv ("") == -1); + ASSERT (errno == EINVAL); + errno = 0; + ASSERT (unsetenv ("a=b") == -1); + ASSERT (errno == EINVAL); +#if 0 + /* glibc and gnulib's implementation guarantee this, but POSIX no + longer requires it: http://austingroupbugs.net/view.php?id=185 */ + errno = 0; + ASSERT (unsetenv (NULL) == -1); + ASSERT (errno == EINVAL); +#endif + + return 0; +} diff --git a/gnulib-tests/test-update-copyright.sh b/gnulib-tests/test-update-copyright.sh new file mode 100755 index 0000000..adba779 --- /dev/null +++ b/gnulib-tests/test-update-copyright.sh @@ -0,0 +1,561 @@ +#!/bin/sh +# Test suite for update-copyright. +# Copyright (C) 2009-2020 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# 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 <https://www.gnu.org/licenses/>. + +diffout=`diff -u /dev/null /dev/null 2>&1` +if test x"$diffout" = x"" && test $? -eq 0; then + compare() { diff -u "$@"; } +else + compare() { cmp "$@"; } +fi + +# Ensure the update-copyright program gets found. +PATH=$abs_aux_dir:$PATH +export PATH + +TMP_BASE=update-copyright.test +trap 'rm -f $TMP_BASE*' 0 1 2 3 15 + +## --------------------------------- ## +## Skip if user does not have perl. ## +## --------------------------------- ## + +TMP=$TMP_BASE +s=$TMP-script +cat <<\EOF > $s +#!/bin/sh +#! -*-perl-*- +# This is a prologue that allows to run a perl script as an executable +# on systems that are compliant to a POSIX version before POSIX:2017. +# On such systems, the usual invocation of an executable through execlp() +# or execvp() fails with ENOEXEC if it is a script that does not start +# with a #! line. The script interpreter mentioned in the #! line has +# to be /bin/sh, because on GuixSD systems that is the only program that +# has a fixed file name. The second line is essential for perl and is +# also useful for editing this file in Emacs. The next two lines below +# are valid code in both sh and perl. When executed by sh, they re-execute +# the script through the perl program found in $PATH. The '-x' option +# is essential as well; without it, perl would re-execute the script +# through /bin/sh. When executed by perl, the next two lines are a no-op. +eval 'exec perl -wSx -pi "$0" "$@"' + if 0; + +s/a/b/ +EOF +chmod a+x $s +echo a > $TMP-in +./$s $TMP-in 2>/dev/null && test b = "`cat $TMP-in 2>/dev/null`" || + { + printf '%s\n' "$0: skipping this test;" \ + 'your system has insufficient support for Perl' 1>&2 + exit 77 + } + +# Skip this test if Perl is too old. FIXME: 5.8.0 is just a guess. +# We have a report that 5.6.1 is inadequate and that 5.8.0 works. +perl -e 'require 5.8.0' || { + echo '$0: skipping this test; Perl version is too old' 1>&2 + exit 77 +} + +# Do not let a different envvar setting perturb results. +UPDATE_COPYRIGHT_MAX_LINE_LENGTH=72 +export UPDATE_COPYRIGHT_MAX_LINE_LENGTH + +## ----------------------------- ## +## Examples from documentation. ## +## ----------------------------- ## + +TMP=$TMP_BASE-ex +cat > $TMP.1 <<EOF +Copyright @copyright{} 1990-2005, 2007-2009 Free Software +Foundation, Inc. +EOF +cat > $TMP.2 <<EOF +# Copyright (C) 1990-2005, 2007-2009 Free Software +# Foundation, Inc. +EOF +cat > $TMP.3 <<EOF +/* + * Copyright © 90,2005,2007-2009 + * Free Software Foundation, Inc. + */ +EOF +cat > $TMP.4 <<EOF +## Copyright (C) 1990-2005, 2007-2009 Free Software +# Foundation, Inc. +EOF +cat > $TMP.5 <<EOF +Copyright (C) 1990-2005, 2007-2009 Acme, Inc. +EOF +cat > $TMP.6 <<EOF +## Copyright (C) 1990-2005, 2007-2009 Free Software +# Foundation, Inc. + +Copyright (C) 1990-2005, 2007-2009 Free Software Foundation, +Inc. +EOF +cat > $TMP.7 <<EOF +Copyright (C) 1990-2005, 2007-2009 Acme, Inc. + +# Copyright (C) 1990-2005, 2007-2009 Free Software +# Foundation, Inc. +EOF + +UPDATE_COPYRIGHT_YEAR=2009 \ + update-copyright $TMP.? 1> $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare - $TMP-stderr <<EOF || exit 1 +$TMP.4: warning: copyright statement not found +$TMP.5: warning: copyright statement not found +EOF +compare - $TMP.1 <<EOF || exit 1 +Copyright @copyright{} 1990-2005, 2007-2009 Free Software +Foundation, Inc. +EOF +compare - $TMP.2 <<EOF || exit 1 +# Copyright (C) 1990-2005, 2007-2009 Free Software +# Foundation, Inc. +EOF +compare - $TMP.3 <<EOF || exit 1 +/* + * Copyright © 90,2005,2007-2009 + * Free Software Foundation, Inc. + */ +EOF +compare - $TMP.4 <<EOF || exit 1 +## Copyright (C) 1990-2005, 2007-2009 Free Software +# Foundation, Inc. +EOF +compare - $TMP.5 <<EOF || exit 1 +Copyright (C) 1990-2005, 2007-2009 Acme, Inc. +EOF +compare - $TMP.6 <<EOF || exit 1 +## Copyright (C) 1990-2005, 2007-2009 Free Software +# Foundation, Inc. + +Copyright (C) 1990-2005, 2007-2009 Free Software Foundation, +Inc. +EOF +compare - $TMP.7 <<EOF || exit 1 +Copyright (C) 1990-2005, 2007-2009 Acme, Inc. + +# Copyright (C) 1990-2005, 2007-2009 Free Software +# Foundation, Inc. +EOF + +UPDATE_COPYRIGHT_YEAR=2010 UPDATE_COPYRIGHT_USE_INTERVALS=1 \ + update-copyright $TMP.? 1> $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare - $TMP-stderr <<EOF || exit 1 +$TMP.4: warning: copyright statement not found +$TMP.5: warning: copyright statement not found +EOF +compare - $TMP.1 <<EOF || exit 1 +Copyright @copyright{} 1990-2005, 2007-2010 Free Software Foundation, +Inc. +EOF +compare - $TMP.2 <<EOF || exit 1 +# Copyright (C) 1990-2005, 2007-2010 Free Software Foundation, Inc. +EOF +compare - $TMP.3 <<EOF || exit 1 +/* + * Copyright © 1990, 2005, 2007-2010 Free Software Foundation, Inc. + */ +EOF +compare - $TMP.4 <<EOF || exit 1 +## Copyright (C) 1990-2005, 2007-2009 Free Software +# Foundation, Inc. +EOF +compare - $TMP.5 <<EOF || exit 1 +Copyright (C) 1990-2005, 2007-2009 Acme, Inc. +EOF +compare - $TMP.6 <<EOF || exit 1 +## Copyright (C) 1990-2005, 2007-2009 Free Software +# Foundation, Inc. + +Copyright (C) 1990-2005, 2007-2010 Free Software Foundation, Inc. +EOF +compare - $TMP.7 <<EOF || exit 1 +Copyright (C) 1990-2005, 2007-2009 Acme, Inc. + +# Copyright (C) 1990-2005, 2007-2010 Free Software Foundation, Inc. +EOF + +UPDATE_COPYRIGHT_YEAR=2010 UPDATE_COPYRIGHT_FORCE=1 \ + update-copyright $TMP.? 1> $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare - $TMP-stderr <<EOF || exit 1 +$TMP.4: warning: copyright statement not found +$TMP.5: warning: copyright statement not found +EOF +compare - $TMP.1 <<EOF || exit 1 +Copyright @copyright{} 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, +1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 +Free Software Foundation, Inc. +EOF +compare - $TMP.2 <<EOF || exit 1 +# Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, +# 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 Free +# Software Foundation, Inc. +EOF +compare - $TMP.3 <<EOF || exit 1 +/* + * Copyright © 1990, 2005, 2007, 2008, 2009, 2010 Free Software + * Foundation, Inc. + */ +EOF +compare - $TMP.4 <<EOF || exit 1 +## Copyright (C) 1990-2005, 2007-2009 Free Software +# Foundation, Inc. +EOF +compare - $TMP.5 <<EOF || exit 1 +Copyright (C) 1990-2005, 2007-2009 Acme, Inc. +EOF +compare - $TMP.6 <<EOF || exit 1 +## Copyright (C) 1990-2005, 2007-2009 Free Software +# Foundation, Inc. + +Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, +1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 Free +Software Foundation, Inc. +EOF +compare - $TMP.7 <<EOF || exit 1 +Copyright (C) 1990-2005, 2007-2009 Acme, Inc. + +# Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, +# 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 Free +# Software Foundation, Inc. +EOF + +rm $TMP* + +## -------------- ## +## Current year. ## +## -------------- ## + +TMP=$TMP_BASE-current-year +YEAR=`date +%Y` +cat > $TMP <<EOF +'\" Copyright (C) 2006 +'\" Free Software Foundation, +'\" Inc. +EOF +update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP <<EOF || exit 1 +'\" Copyright (C) 2006, $YEAR Free Software Foundation, Inc. +EOF +UPDATE_COPYRIGHT_USE_INTERVALS=1 \ + update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP <<EOF || exit 1 +'\" Copyright (C) 2006, $YEAR Free Software Foundation, Inc. +EOF +rm $TMP* + +## ------------------ ## +## Surrounding text. ## +## ------------------ ## + +TMP=$TMP_BASE-surrounding-text +cat > $TMP <<EOF + Undisturbed text. +dnl Undisturbed text. +dnl Copyright (C) 89 +dnl Free Software Foundation, Inc. +dnl Undisturbed text. +EOF +UPDATE_COPYRIGHT_YEAR=2010 \ + update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP <<EOF || exit 1 + Undisturbed text. +dnl Undisturbed text. +dnl Copyright (C) 1989, 2010 Free Software Foundation, Inc. +dnl Undisturbed text. +EOF +rm $TMP* + +## --------------- ## +## Widest prefix. ## +## --------------- ## + +TMP=$TMP_BASE-widest-prefix +cat > $TMP <<EOF +#### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, +#### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, +#### 2008 Free Software Foundation, Inc. +EOF +UPDATE_COPYRIGHT_YEAR=2010 \ + update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP <<EOF || exit 1 +#### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, +#### 1985, 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, +#### 2006, 2007, 2008, 2010 Free Software Foundation, Inc. +EOF +UPDATE_COPYRIGHT_YEAR=2011 UPDATE_COPYRIGHT_USE_INTERVALS=1 \ + update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP <<EOF || exit 1 +#### Copyright (C) 1976-1988, 1999-2008, 2010-2011 Free Software +#### Foundation, Inc. +EOF +rm $TMP* + +## ------------------- ## +## Prefix too large. ## +## ------------------- ## + +TMP=$TMP_BASE-prefix-too-large +cat > $TMP <<EOF +#### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, +#### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, +#### 2008 Free Software Foundation, Inc. +EOF +UPDATE_COPYRIGHT_YEAR=2010 \ + update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare - $TMP-stderr <<EOF || exit 1 +$TMP: warning: copyright statement not found +EOF +compare - $TMP <<EOF || exit 1 +#### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, +#### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, +#### 2008 Free Software Foundation, Inc. +EOF +rm $TMP* + +## ------------- ## +## Blank lines. ## +## ------------- ## + +TMP=$TMP_BASE-blank-lines +cat > $TMP <<EOF +#Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, +# +#1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, +#2008 Free Software Foundation, Inc. + +Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, + +1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, +2008 Free Software Foundation, Inc. +EOF +UPDATE_COPYRIGHT_YEAR=2010 \ + update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare - $TMP-stderr <<EOF || exit 1 +$TMP: warning: copyright statement not found +EOF +compare - $TMP <<EOF || exit 1 +#Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, +# +#1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, +#2008 Free Software Foundation, Inc. + +Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, + +1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, +2008 Free Software Foundation, Inc. +EOF +rm $TMP* + +## -------------- ## +## Leading tabs. ## +## -------------- ## + +TMP=$TMP_BASE-leading-tabs +cat > $TMP <<EOF + Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 98, + 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free + Software Foundation, Inc. +EOF +UPDATE_COPYRIGHT_YEAR=2010 \ + update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP <<EOF || exit 1 + Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, + 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +EOF +UPDATE_COPYRIGHT_YEAR=2011 UPDATE_COPYRIGHT_USE_INTERVALS=1 \ + update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP <<EOF || exit 1 + Copyright (C) 1987-1988, 1991-2011 Free Software Foundation, + Inc. +EOF +rm $TMP* + +## -------------------- ## +## Unusual whitespace. ## +## -------------------- ## + +TMP=$TMP_BASE-unusual-ws +cat > $TMP <<EOF + # Copyright (C) 87-88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, + # 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, + # 2009 Free Software Foundation, Inc. +EOF +UPDATE_COPYRIGHT_YEAR=2010 \ + update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP <<EOF || exit 1 + # Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, + # 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, + # 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software + # Foundation, Inc. +EOF +UPDATE_COPYRIGHT_YEAR=2011 UPDATE_COPYRIGHT_USE_INTERVALS=1 \ + update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP <<EOF || exit 1 + # Copyright (C) 1987-1988, 1991-2011 Free Software + # Foundation, Inc. +EOF +UPDATE_COPYRIGHT_YEAR=2011 UPDATE_COPYRIGHT_USE_INTERVALS=2 \ + UPDATE_COPYRIGHT_FORCE=1 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP <<EOF || exit 1 + # Copyright (C) 1987-2011 Free Software Foundation, Inc. +EOF +rm $TMP* + +## --------- ## +## DOS EOL. ## +## --------- ## + +TMP=$TMP_BASE-dos-eol +tr @ '\015' > $TMP <<\EOF +Rem Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,@ +Rem 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,@ +Rem 2009 Free Software Foundation, Inc.@ +EOF +UPDATE_COPYRIGHT_YEAR=2010 \ + update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +tr @ '\015' > $TMP-exp <<\EOF +Rem Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997,@ +Rem 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,@ +Rem 2009, 2010 Free Software Foundation, Inc.@ +EOF +compare $TMP-exp $TMP || exit 1 +rm $TMP* + +## --------------- ## +## Omitted "(C)". ## +## --------------- ## + +TMP=$TMP_BASE-omitted-circle-c +cat > $TMP <<EOF + Copyright 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, + 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, + 2009 Free Software Foundation, Inc. +EOF +UPDATE_COPYRIGHT_YEAR=2010 \ + update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP <<EOF || exit 1 + Copyright 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, + 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + Free Software Foundation, Inc. +EOF +rm $TMP* + +## ------------------ ## +## C-style comments. ## +## ------------------ ## + +TMP=$TMP_BASE-c-style-comments +cat > $TMP.star <<EOF +/* Copyright 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, + * 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, + * 2009 Free Software Foundation, Inc. */ +EOF +cat > $TMP.space <<EOF + /*Copyright 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, + 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, + 2009 Free Software Foundation, Inc. */ +EOF +cat > $TMP.single-line <<EOF +/* Copyright 87, 1991, 1992 Free Software Foundation, Inc. */ +EOF +cat > $TMP.single-line-wrapped <<EOF + /* Copyright 1988, 1991, 1992, 1993 Free Software Foundation, Inc. */ +EOF +cat > $TMP.extra-text-star <<EOF + /* Copyright 1987, 1988, 1991, 1992 Free Software Foundation, Inc. End + * More comments. */ +EOF +cat > $TMP.extra-text-space <<EOF + /* Copyright 1987, 1988, 1991, 1992 Free Software Foundation, Inc. *** + * End of comments. */ +EOF +cat > $TMP.two-digit-final-is-substr-of-first <<EOF + /* Copyright 1991, 99 Free Software Foundation, Inc. */ +EOF +UPDATE_COPYRIGHT_YEAR=2010 \ + update-copyright $TMP.* 1> $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP.star <<EOF || exit 1 +/* Copyright 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, + * 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, + * 2009, 2010 Free Software Foundation, Inc. */ +EOF +compare - $TMP.space <<EOF || exit 1 + /*Copyright 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, + 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, + 2009, 2010 Free Software Foundation, Inc. */ +EOF +compare - $TMP.single-line <<EOF || exit 1 +/* Copyright 1987, 1991, 1992, 2010 Free Software Foundation, Inc. */ +EOF +compare - $TMP.single-line-wrapped <<EOF || exit 1 + /* Copyright 1988, 1991, 1992, 1993, 2010 Free Software Foundation, + * Inc. */ +EOF +compare - $TMP.extra-text-star <<EOF || exit 1 + /* Copyright 1987, 1988, 1991, 1992, 2010 Free Software Foundation, + * Inc. End + * More comments. */ +EOF +compare - $TMP.extra-text-space <<EOF || exit 1 + /* Copyright 1987, 1988, 1991, 1992, 2010 Free Software Foundation, + Inc. *** + * End of comments. */ +EOF +compare - $TMP.two-digit-final-is-substr-of-first <<EOF || exit 1 + /* Copyright 1991, 1999, 2010 Free Software Foundation, Inc. */ +EOF +rm $TMP* + +exit 0 diff --git a/gnulib-tests/test-userspec.c b/gnulib-tests/test-userspec.c new file mode 100644 index 0000000..546befc --- /dev/null +++ b/gnulib-tests/test-userspec.c @@ -0,0 +1,201 @@ +/* Test userspec.c + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Jim Meyering. */ + +#include <config.h> + +#include "userspec.h" + +#include <stdio.h> +#include <assert.h> +#include <string.h> +#include <stdlib.h> +#include <stdbool.h> +#include <sys/types.h> +#include <pwd.h> +#include <grp.h> + +#include "xalloc.h" + +#define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array)) + +struct test +{ + const char *in; + uid_t uid; + gid_t gid; + const char *user_name; + const char *group_name; + const char *result; +}; + +static struct test T[] = + { + { "", -1, -1, "", "", NULL}, + { ":", -1, -1, "", "", NULL}, + { "+0:+0", 0, 0, "", "", NULL}, + { ":+1", -1, 1, "", "", NULL}, + { "+1", 1, -1, "", "", NULL}, + { ":+0", -1, 0, "", "", NULL}, + { "+22:+42", 22, 42, "", "", NULL}, + /* (uint32_t)-1 should be invalid everywhere */ + { "+4294967295:+4294967295", 0, 0, NULL, NULL, "invalid user"}, + /* likewise, but with only the group being invalid */ + { "+0:+4294967295", 0, 0, NULL, NULL, "invalid group"}, + { ":+4294967295", 0, 0, NULL, NULL, "invalid group"}, + /* and only the user being invalid */ + { "+4294967295:+0", 0, 0, NULL, NULL, "invalid user"}, + /* and using 2^32 */ + { "+4294967296:+4294967296", 0, 0, NULL, NULL, "invalid user"}, + { "+0:+4294967296", 0, 0, NULL, NULL, "invalid group"}, + { ":+4294967296", 0, 0, NULL, NULL, "invalid group"}, + { "+4294967296:+0", 0, 0, NULL, NULL, "invalid user"}, + /* numeric user and no group is invalid */ + { "+4294967295:", 0, 0, NULL, NULL, "invalid spec"}, + { "+4294967296:", 0, 0, NULL, NULL, "invalid spec"}, + { "+1:", 0, 0, NULL, NULL, "invalid spec"}, + { "+0:", 0, 0, NULL, NULL, "invalid spec"}, + + /* "username:" must expand to UID:GID where GID is username's login group */ + /* Add an entry like the following to the table, if possible. + { "U_NAME:", UID,GID, U_NAME, G_NAME, NULL}, */ + { NULL, 0, 0, NULL, NULL, ""}, /* place-holder */ + + { NULL, 0, 0, NULL, NULL, ""} + }; + +#define STREQ(a, b) (strcmp (a, b) == 0) + +static char const * +maybe_null (char const *s) +{ + return s ? s : "NULL"; +} + +static bool +same_diag (char const *s, char const *t) +{ + if (s == NULL && t == NULL) + return true; + if (s == NULL || t == NULL) + return false; + return STREQ (s, t); +} + +int +main (void) +{ + unsigned int i; + int fail = 0; + + /* Find a UID that has both a user name and login group name, + but skip UID 0. */ + { + uid_t uid; + for (uid = 1200; 0 < uid; uid--) + { + struct group *gr; + struct passwd *pw = getpwuid (uid); + unsigned int j; + size_t len; + if (!pw || !pw->pw_name || !(gr = getgrgid (pw->pw_gid)) || !gr->gr_name) + continue; + j = ARRAY_CARDINALITY (T) - 2; + assert (T[j].in == NULL); + assert (T[j+1].in == NULL); + len = strlen (pw->pw_name); + + /* Store "username:" in T[j].in. */ + { + char *t = xmalloc (len + 1 + 1); + memcpy (t, pw->pw_name, len); + t[len] = ':'; + t[len+1] = '\0'; + T[j].in = t; + } + + T[j].uid = uid; + T[j].gid = gr->gr_gid; + T[j].user_name = xstrdup (pw->pw_name); + T[j].group_name = xstrdup (gr->gr_name); + T[j].result = NULL; + break; + } + } + + for (i = 0; T[i].in; i++) + { + uid_t uid = (uid_t) -1; + gid_t gid = (gid_t) -1; + char *user_name; + char *group_name; + char const *diag = parse_user_spec (T[i].in, &uid, &gid, + &user_name, &group_name); + free (user_name); + free (group_name); + if (!same_diag (diag, T[i].result)) + { + printf ("%s return value mismatch: got %s, expected %s\n", + T[i].in, maybe_null (diag), maybe_null (T[i].result)); + fail = 1; + continue; + } + + if (diag) + continue; + + if (uid != T[i].uid || gid != T[i].gid) + { + printf ("%s mismatch (-: expected uid,gid; +:actual)\n" + "-%3lu,%3lu\n+%3lu,%3lu\n", + T[i].in, + (unsigned long int) T[i].uid, + (unsigned long int) T[i].gid, + (unsigned long int) uid, + (unsigned long int) gid); + fail = 1; + } + + if (!T[i].result) + continue; + + /* Expected a non-NULL result diagnostic, yet got NULL. */ + diag = "NULL"; + printf ("%s diagnostic mismatch (-: expected diagnostic; +:actual)\n" + "-%s\n+%s\n", T[i].in, T[i].result, diag); + fail = 1; + } + + /* Ensure NULL parameters are ignored. */ + { + uid_t uid = (uid_t) -1; + char const *diag = parse_user_spec ("", &uid, NULL, NULL, NULL); + if (diag) + { + printf ("unexpected error: %s\n", diag); + fail = 1; + } + } + + return fail; +} + +/* +Local Variables: +indent-tabs-mode: nil +End: +*/ diff --git a/gnulib-tests/test-usleep.c b/gnulib-tests/test-usleep.c new file mode 100644 index 0000000..e135c31 --- /dev/null +++ b/gnulib-tests/test-usleep.c @@ -0,0 +1,40 @@ +/* Test of usleep() function. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (usleep, int, (useconds_t)); + +#include <time.h> + +#include "macros.h" + +int +main (void) +{ + time_t start = time (NULL); + ASSERT (usleep (1000000) == 0); + ASSERT (start < time (NULL)); + + ASSERT (usleep (0) == 0); + + return 0; +} diff --git a/gnulib-tests/test-utime-h.c b/gnulib-tests/test-utime-h.c new file mode 100644 index 0000000..2eea3c2 --- /dev/null +++ b/gnulib-tests/test-utime-h.c @@ -0,0 +1,32 @@ +/* Test of <utime.h> substitute. + Copyright (C) 2017-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2017. */ + +#include <config.h> + +#include <utime.h> + +/* Check that 'struct utimbuf' is defined. */ +struct utimbuf b; + +int +main (void) +{ + b.actime = b.modtime = 1493490248; /* 2017-04-29 18:24:08 GMT */ + + return 0; +} diff --git a/gnulib-tests/test-utime.c b/gnulib-tests/test-utime.c new file mode 100644 index 0000000..4cf5836 --- /dev/null +++ b/gnulib-tests/test-utime.c @@ -0,0 +1,142 @@ +/* Tests of utime. + Copyright (C) 2017-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <utime.h> + +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> + +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-utime.t" + +#include "test-utimens-common.h" + +/* If PRINT, warn before skipping tests with status 77. */ +static int +test_utime (bool print) +{ + struct stat st1; + struct stat st2; + + ASSERT (close (creat (BASE "file", 0600)) == 0); + ASSERT (stat (BASE "file", &st1) == 0); + nap (); + ASSERT (utime (BASE "file", NULL) == 0); + ASSERT (stat (BASE "file", &st2) == 0); + ASSERT (0 <= utimecmp (BASE "file", &st2, &st1, UTIMECMP_TRUNCATE_SOURCE)); + if (check_ctime) + ASSERT (ctime_compare (&st1, &st2) < 0); + { + /* On some NFS systems, the 'now' timestamp of creat or a NULL + utimbuf is determined by the server, but the 'now' timestamp + determined by time() is determined by the client; since the two + machines are not necessarily on the same clock, this is another + case where time can appear to go backwards. The rest of this + test cares about client time, so manually use time() to set + both times. */ + struct utimbuf ts; + ts.actime = ts.modtime = time (NULL); + ASSERT (utime (BASE "file", &ts) == 0); + ASSERT (stat (BASE "file", &st1) == 0); + nap (); + } + + /* Invalid arguments. */ + errno = 0; + ASSERT (utime ("no_such", NULL) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (utime ("no_such/", NULL) == -1); + ASSERT (errno == ENOENT || errno == ENOTDIR); + errno = 0; + ASSERT (utime ("", NULL) == -1); + ASSERT (errno == ENOENT); + { + struct utimbuf ts; + ts.actime = ts.modtime = Y2K; + errno = 0; + ASSERT (utime (BASE "file/", &ts) == -1); + ASSERT (errno == ENOTDIR || errno == EINVAL); + } + ASSERT (stat (BASE "file", &st2) == 0); + ASSERT (st1.st_atime == st2.st_atime); + ASSERT (get_stat_atime_ns (&st1) == get_stat_atime_ns (&st2)); + ASSERT (utimecmp (BASE "file", &st1, &st2, 0) == 0); + + /* Set both times. */ + { + struct utimbuf ts; + ts.actime = ts.modtime = Y2K; + ASSERT (utime (BASE "file", &ts) == 0); + ASSERT (stat (BASE "file", &st2) == 0); + ASSERT (st2.st_atime == Y2K); + ASSERT (0 <= get_stat_atime_ns (&st2)); + ASSERT (get_stat_atime_ns (&st2) < BILLION / 2); + ASSERT (st2.st_mtime == Y2K); + ASSERT (0 <= get_stat_mtime_ns (&st2)); + ASSERT (get_stat_mtime_ns (&st2) < BILLION); + if (check_ctime) + ASSERT (ctime_compare (&st1, &st2) < 0); + } + + /* Make sure this dereferences symlinks. */ + if (symlink (BASE "file", BASE "link")) + { + ASSERT (unlink (BASE "file") == 0); + if (print) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + ASSERT (lstat (BASE "link", &st1) == 0); + ASSERT (st1.st_mtime != Y2K); + errno = 0; + ASSERT (utime (BASE "link/", NULL) == -1); + ASSERT (errno == ENOTDIR); + { + struct utimbuf ts; + ts.actime = ts.modtime = Y2K; + ASSERT (utime (BASE "link", &ts) == 0); + ASSERT (lstat (BASE "link", &st2) == 0); + /* Can't compare atimes, since lstat() changes symlink atime on cygwin. */ + ASSERT (st1.st_mtime == st2.st_mtime); + ASSERT (stat (BASE "link", &st2) == 0); + ASSERT (st2.st_mtime == Y2K); + ASSERT (get_stat_mtime_ns (&st2) == 0); + } + + /* Cleanup. */ + ASSERT (unlink (BASE "link") == 0); + ASSERT (unlink (BASE "file") == 0); + return 0; +} + +int +main (void) +{ + int result1; /* Skip because of no symlink support. */ + + /* Clean up any trash from prior testsuite runs. */ + ignore_value (system ("rm -rf " BASE "*")); + + result1 = test_utime (true); + return result1; +} diff --git a/gnulib-tests/test-utimens-common.h b/gnulib-tests/test-utimens-common.h new file mode 100644 index 0000000..e923620 --- /dev/null +++ b/gnulib-tests/test-utimens-common.h @@ -0,0 +1,79 @@ +/* Test of file timestamp modification functions. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* This file defines some prerequisites useful to utime-related tests. */ + +#ifndef GL_TEST_UTIMENS_COMMON +# define GL_TEST_UTIMENS_COMMON + +# include <fcntl.h> +# include <errno.h> +# include <string.h> +# include <sys/stat.h> +# include <unistd.h> + +/* Gnulib modules. */ +# include "stat-time.h" +# include "timespec.h" +# include "utimecmp.h" + +/* Gnulib test header. */ +# include "nap.h" + +enum { + BILLION = 1000 * 1000 * 1000, + + Y2K = 946684800, /* Jan 1, 2000, in seconds since epoch. */ + + /* Bogus positive and negative tv_nsec values closest to valid + range, but without colliding with UTIME_NOW or UTIME_OMIT. */ + UTIME_BOGUS_POS = BILLION + ((UTIME_NOW == BILLION || UTIME_OMIT == BILLION) + ? (1 + (UTIME_NOW == BILLION + 1) + + (UTIME_OMIT == BILLION + 1)) + : 0), + UTIME_BOGUS_NEG = -1 - ((UTIME_NOW == -1 || UTIME_OMIT == -1) + ? (1 + (UTIME_NOW == -2) + (UTIME_OMIT == -2)) + : 0) +}; + +# if defined _WIN32 && !defined __CYGWIN__ +/* Skip ctime tests on native Windows, since it is either a copy of + mtime or birth time (depending on the file system), rather than a + properly tracked change time. See + <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/stat-functions>. */ +# define check_ctime 0 +# else +# define check_ctime 1 +# endif + +/* Compare two st_ctime values. Return -1, 0 or 1, respectively + when A's st_ctime is smaller than, equal to or greater than B's. */ +static int +ctime_compare (struct stat const *a, struct stat const *b) +{ + if (a->st_ctime < b->st_ctime) + return -1; + else if (b->st_ctime < a->st_ctime) + return 1; + else if (get_stat_ctime_ns (a) < get_stat_ctime_ns (b)) + return -1; + else if (get_stat_ctime_ns (b) < get_stat_ctime_ns (a)) + return 1; + else + return 0; +} + +#endif /* GL_TEST_UTIMENS_COMMON */ diff --git a/gnulib-tests/test-utimens.c b/gnulib-tests/test-utimens.c new file mode 100644 index 0000000..3d53b37 --- /dev/null +++ b/gnulib-tests/test-utimens.c @@ -0,0 +1,80 @@ +/* Tests of utimens. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include "utimens.h" + +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> + +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-utimens.t" + +#include "test-futimens.h" +#include "test-lutimens.h" +#include "test-utimens.h" + +/* Wrap fdutimens to behave like futimens. */ +static int +do_futimens (int fd, struct timespec const times[2]) +{ + return fdutimens (fd, NULL, times); +} + +/* Test the use of file descriptors alongside a name. */ +static int +do_fdutimens (char const *name, struct timespec const times[2]) +{ + int result; + int fd = open (name, O_WRONLY); + if (fd < 0) + fd = open (name, O_RDONLY); + errno = 0; + result = fdutimens (fd, name, times); + if (0 <= fd) + { + int saved_errno = errno; + close (fd); + errno = saved_errno; + } + return result; +} + +int +main (void) +{ + int result1; /* Skip because of no symlink support. */ + int result2; /* Skip because of no futimens support. */ + int result3; /* Skip because of no lutimens support. */ + + /* Clean up any trash from prior testsuite runs. */ + ignore_value (system ("rm -rf " BASE "*")); + + result1 = test_utimens (utimens, true); + ASSERT (test_utimens (do_fdutimens, false) == result1); + /* Print only one skip message. */ + result2 = test_futimens (do_futimens, result1 == 0); + result3 = test_lutimens (lutimens, (result1 + result2) == 0); + /* We expect 0/0, 0/77, or 77/77, but not 77/0. */ + ASSERT (result1 <= result3); + return result1 | result2 | result3; +} diff --git a/gnulib-tests/test-utimens.h b/gnulib-tests/test-utimens.h new file mode 100644 index 0000000..a05b232 --- /dev/null +++ b/gnulib-tests/test-utimens.h @@ -0,0 +1,184 @@ +/* Test of file timestamp modification functions. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +#include "test-utimens-common.h" + +/* This file is designed to test both utimens(a,b) and + utimensat(AT_FDCWD,a,b,0). FUNC is the function to test. Assumes + that BASE and ASSERT are already defined. If PRINT, warn before + skipping tests with status 77. */ +static int +test_utimens (int (*func) (char const *, struct timespec const *), bool print) +{ + struct stat st1; + struct stat st2; + + ASSERT (close (creat (BASE "file", 0600)) == 0); + /* If utimens truncates to worse resolution than the file system + supports, then time can appear to go backwards between now and a + follow-up utimens with UTIME_NOW or a NULL timespec. Use + UTIMECMP_TRUNCATE_SOURCE to compensate, with st1 as the + source. */ + ASSERT (stat (BASE "file", &st1) == 0); + nap (); + ASSERT (func (BASE "file", NULL) == 0); + ASSERT (stat (BASE "file", &st2) == 0); + ASSERT (0 <= utimecmp (BASE "file", &st2, &st1, UTIMECMP_TRUNCATE_SOURCE)); + if (check_ctime) + ASSERT (ctime_compare (&st1, &st2) < 0); + { + /* On some NFS systems, the 'now' timestamp of creat or a NULL + timespec is determined by the server, but the 'now' timestamp + determined by gettime() (as is done when using UTIME_NOW) is + determined by the client; since the two machines are not + necessarily on the same clock, this is another case where time + can appear to go backwards. The rest of this test cares about + client time, so manually use gettime() to set both times. */ + struct timespec ts[2]; + gettime (&ts[0]); + ts[1] = ts[0]; + ASSERT (func (BASE "file", ts) == 0); + ASSERT (stat (BASE "file", &st1) == 0); + nap (); + } + + /* Invalid arguments. */ + errno = 0; + ASSERT (func ("no_such", NULL) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func ("no_such/", NULL) == -1); + ASSERT (errno == ENOENT || errno == ENOTDIR); + errno = 0; + ASSERT (func ("", NULL) == -1); + ASSERT (errno == ENOENT); + { + struct timespec ts[2]; + ts[0].tv_sec = Y2K; + ts[0].tv_nsec = UTIME_BOGUS_POS; + ts[1].tv_sec = Y2K; + ts[1].tv_nsec = 0; + errno = 0; + ASSERT (func (BASE "file", ts) == -1); + ASSERT (errno == EINVAL); + } + { + struct timespec ts[2]; + ts[0].tv_sec = Y2K; + ts[0].tv_nsec = 0; + ts[1].tv_sec = Y2K; + ts[1].tv_nsec = UTIME_BOGUS_NEG; + errno = 0; + ASSERT (func (BASE "file", ts) == -1); + ASSERT (errno == EINVAL); + } + { + struct timespec ts[2]; + ts[0].tv_sec = Y2K; + ts[0].tv_nsec = 0; + ts[1] = ts[0]; + errno = 0; + ASSERT (func (BASE "file/", ts) == -1); + ASSERT (errno == ENOTDIR || errno == EINVAL); + } + ASSERT (stat (BASE "file", &st2) == 0); + ASSERT (st1.st_atime == st2.st_atime); + ASSERT (get_stat_atime_ns (&st1) == get_stat_atime_ns (&st2)); + ASSERT (utimecmp (BASE "file", &st1, &st2, 0) == 0); + + /* Set both times. */ + { + struct timespec ts[2]; + ts[0].tv_sec = Y2K; + ts[0].tv_nsec = BILLION / 2 - 1; + ts[1].tv_sec = Y2K; + ts[1].tv_nsec = BILLION - 1; + ASSERT (func (BASE "file", ts) == 0); + ASSERT (stat (BASE "file", &st2) == 0); + ASSERT (st2.st_atime == Y2K); + ASSERT (0 <= get_stat_atime_ns (&st2)); + ASSERT (get_stat_atime_ns (&st2) < BILLION / 2); + ASSERT (st2.st_mtime == Y2K); + ASSERT (0 <= get_stat_mtime_ns (&st2)); + ASSERT (get_stat_mtime_ns (&st2) < BILLION); + if (check_ctime) + ASSERT (ctime_compare (&st1, &st2) < 0); + } + + /* Play with UTIME_OMIT, UTIME_NOW. */ + { + struct stat st3; + struct timespec ts[2]; + ts[0].tv_sec = BILLION; + ts[0].tv_nsec = UTIME_OMIT; + ts[1].tv_sec = 0; + ts[1].tv_nsec = UTIME_NOW; + nap (); + ASSERT (func (BASE "file", ts) == 0); + ASSERT (stat (BASE "file", &st3) == 0); + ASSERT (st3.st_atime == Y2K); + ASSERT (0 <= get_stat_atime_ns (&st3)); + ASSERT (get_stat_atime_ns (&st3) < BILLION / 2); + /* See comment above about this utimecmp call. */ + ASSERT (0 <= utimecmp (BASE "file", &st3, &st1, UTIMECMP_TRUNCATE_SOURCE)); + if (check_ctime) + ASSERT (ctime_compare (&st2, &st3) < 0); + nap (); + ts[0].tv_nsec = 0; + ts[1].tv_nsec = UTIME_OMIT; + ASSERT (func (BASE "file", ts) == 0); + ASSERT (stat (BASE "file", &st2) == 0); + ASSERT (st2.st_atime == BILLION); + ASSERT (get_stat_atime_ns (&st2) == 0); + ASSERT (st3.st_mtime == st2.st_mtime); + ASSERT (get_stat_mtime_ns (&st3) == get_stat_mtime_ns (&st2)); + if (check_ctime) + ASSERT (ctime_compare (&st3, &st2) < 0); + } + + /* Make sure this dereferences symlinks. */ + if (symlink (BASE "file", BASE "link")) + { + ASSERT (unlink (BASE "file") == 0); + if (print) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + ASSERT (lstat (BASE "link", &st1) == 0); + ASSERT (st1.st_mtime != Y2K); + errno = 0; + ASSERT (func (BASE "link/", NULL) == -1); + ASSERT (errno == ENOTDIR); + { + struct timespec ts[2]; + ts[0].tv_sec = Y2K; + ts[0].tv_nsec = 0; + ts[1] = ts[0]; + ASSERT (func (BASE "link", ts) == 0); + ASSERT (lstat (BASE "link", &st2) == 0); + /* Can't compare atimes, since lstat() changes symlink atime on cygwin. */ + ASSERT (st1.st_mtime == st2.st_mtime); + ASSERT (stat (BASE "link", &st2) == 0); + ASSERT (st2.st_mtime == Y2K); + ASSERT (get_stat_mtime_ns (&st2) == 0); + } + + /* Cleanup. */ + ASSERT (unlink (BASE "link") == 0); + ASSERT (unlink (BASE "file") == 0); + return 0; +} diff --git a/gnulib-tests/test-utimensat.c b/gnulib-tests/test-utimensat.c new file mode 100644 index 0000000..6aced15 --- /dev/null +++ b/gnulib-tests/test-utimensat.c @@ -0,0 +1,128 @@ +/* Tests of utimensat. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <sys/stat.h> + +#include "signature.h" +SIGNATURE_CHECK (utimensat, int, (int, char const *, struct timespec const[2], + int)); + +#include <fcntl.h> +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include "stat-time.h" +#include "timespec.h" +#include "utimecmp.h" +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-utimensat.t" + +#include "test-lutimens.h" +#include "test-utimens.h" + +static int dfd = AT_FDCWD; + +/* Wrap utimensat to behave like utimens. */ +static int +do_utimensat (char const *name, struct timespec const times[2]) +{ + return utimensat (dfd, name, times, 0); +} + +/* Wrap utimensat to behave like lutimens. */ +static int +do_lutimensat (char const *name, struct timespec const times[2]) +{ + return utimensat (dfd, name, times, AT_SYMLINK_NOFOLLOW); +} + +int +main (void) +{ + int result1; /* Skip because of no symlink support. */ + int result2; /* Skip because of no lutimens support. */ + int fd; + + /* Clean up any trash from prior testsuite runs. */ + ignore_value (system ("rm -rf " BASE "*")); + + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (utimensat (-1, "foo", NULL, 0) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (utimensat (99, "foo", NULL, 0) == -1); + ASSERT (errno == EBADF); + } + + /* Basic tests. */ + result1 = test_utimens (do_utimensat, true); + result2 = test_lutimens (do_lutimensat, result1 == 0); + dfd = open (".", O_RDONLY); + ASSERT (0 <= dfd); + ASSERT (test_utimens (do_utimensat, false) == result1); + ASSERT (test_lutimens (do_lutimensat, false) == result2); + /* We expect 0/0, 0/77, or 77/77, but not 77/0. */ + ASSERT (result1 <= result2); + + /* Directory-relative tests. */ + ASSERT (mkdir (BASE "dir", 0700) == 0); + ASSERT (chdir (BASE "dir") == 0); + fd = creat ("file", 0600); + ASSERT (0 <= fd); + errno = 0; + ASSERT (utimensat (fd, ".", NULL, 0) == -1); + ASSERT (errno == ENOTDIR); + { + struct timespec ts[2]; + struct stat st; + ts[0].tv_sec = Y2K; + ts[0].tv_nsec = 0; + ts[1].tv_sec = Y2K; + ts[1].tv_nsec = 0; + ASSERT (utimensat (dfd, BASE "dir/file", ts, AT_SYMLINK_NOFOLLOW) == 0); + ASSERT (stat ("file", &st) == 0); + ASSERT (st.st_atime == Y2K); + ASSERT (get_stat_atime_ns (&st) == 0); + ASSERT (st.st_mtime == Y2K); + ASSERT (get_stat_mtime_ns (&st) == 0); + } + ASSERT (close (fd) == 0); + ASSERT (close (dfd) == 0); + errno = 0; + ASSERT (utimensat (dfd, ".", NULL, 0) == -1); + ASSERT (errno == EBADF); + + /* Cleanup. */ + ASSERT (chdir ("..") == 0); + ASSERT (unlink (BASE "dir/file") == 0); + ASSERT (rmdir (BASE "dir") == 0); + return result1 | result2; +} diff --git a/gnulib-tests/test-vasnprintf.c b/gnulib-tests/test-vasnprintf.c new file mode 100644 index 0000000..018f845 --- /dev/null +++ b/gnulib-tests/test-vasnprintf.c @@ -0,0 +1,121 @@ +/* Test of vasnprintf() and asnprintf() functions. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include "vasnprintf.h" + +#include <stdarg.h> +#include <stdlib.h> +#include <string.h> + +#include "macros.h" + +static void +test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) +{ + char buf[8]; + int size; + + for (size = 0; size <= 8; size++) + { + size_t length = size; + char *result = my_asnprintf (NULL, &length, "%d", 12345); + ASSERT (result != NULL); + ASSERT (strcmp (result, "12345") == 0); + ASSERT (length == 5); + free (result); + } + + for (size = 0; size <= 8; size++) + { + size_t length; + char *result; + + memcpy (buf, "DEADBEEF", 8); + length = size; + result = my_asnprintf (buf, &length, "%d", 12345); + ASSERT (result != NULL); + ASSERT (strcmp (result, "12345") == 0); + ASSERT (length == 5); + if (size < 5 + 1) + ASSERT (result != buf); + ASSERT (memcmp (buf + size, &"DEADBEEF"[size], 8 - size) == 0); + if (result != buf) + free (result); + } + + /* Note: This test assumes IEEE 754 representation of 'double' floats. */ + for (size = 0; size <= 8; size++) + { + size_t length; + char *result; + + memcpy (buf, "DEADBEEF", 8); + length = size; + result = my_asnprintf (buf, &length, "%2.0f", 1.6314159265358979e+125); + ASSERT (result != NULL); + /* The exact result and the result on glibc systems is + 163141592653589790215729350939528493057529598899734151772468186268423257777068536614838678161083520756952076273094236944990208 + On Cygwin, the result is + 163141592653589790215729350939528493057529600000000000000000000000000000000000000000000000000000000000000000000000000000000000 + On HP-UX 11.31 / hppa and IRIX 6.5, the result is + 163141592653589790000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + */ + ASSERT (strlen (result) == 126); + ASSERT (memcmp (result, "163141592653589790", 18) == 0); + ASSERT (length == 126); + if (size < 126 + 1) + ASSERT (result != buf); + ASSERT (memcmp (buf + size, &"DEADBEEF"[size], 8 - size) == 0); + if (result != buf) + free (result); + } +} + +static char * +my_asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) +{ + va_list args; + char *ret; + + va_start (args, format); + ret = vasnprintf (resultbuf, lengthp, format, args); + va_end (args); + return ret; +} + +static void +test_vasnprintf () +{ + test_function (my_asnprintf); +} + +static void +test_asnprintf () +{ + test_function (asnprintf); +} + +int +main (int argc, char *argv[]) +{ + test_vasnprintf (); + test_asnprintf (); + return 0; +} diff --git a/gnulib-tests/test-vasprintf-posix.c b/gnulib-tests/test-vasprintf-posix.c new file mode 100644 index 0000000..a250133 --- /dev/null +++ b/gnulib-tests/test-vasprintf-posix.c @@ -0,0 +1,3602 @@ +/* Test of POSIX compatible vasprintf() and asprintf() functions. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <stdio.h> + +#include <float.h> +#include <stdarg.h> +#include <stddef.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> + +#include "macros.h" +#include "minus-zero.h" +#include "infinity.h" +#include "nan.h" + +/* The SGI MIPS floating-point format does not distinguish 0.0 and -0.0. */ +static int +have_minus_zero () +{ + static double plus_zero = 0.0; + double minus_zero = minus_zerod; + return memcmp (&plus_zero, &minus_zero, sizeof (double)) != 0; +} + +/* Representation of an 80-bit 'long double' as an initializer for a sequence + of 'unsigned int' words. */ +#ifdef WORDS_BIGENDIAN +# define LDBL80_WORDS(exponent,manthi,mantlo) \ + { ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), \ + ((unsigned int) (manthi) << 16) | ((unsigned int) (mantlo) >> 16), \ + (unsigned int) (mantlo) << 16 \ + } +#else +# define LDBL80_WORDS(exponent,manthi,mantlo) \ + { mantlo, manthi, exponent } +#endif + +static int +strmatch (const char *pattern, const char *string) +{ + if (strlen (pattern) != strlen (string)) + return 0; + for (; *pattern != '\0'; pattern++, string++) + if (*pattern != '*' && *string != *pattern) + return 0; + return 1; +} + +/* Test whether string[start_index..end_index-1] is a valid textual + representation of NaN. */ +static int +strisnan (const char *string, size_t start_index, size_t end_index, int uppercase) +{ + if (start_index < end_index) + { + if (string[start_index] == '-') + start_index++; + if (start_index + 3 <= end_index + && memcmp (string + start_index, uppercase ? "NAN" : "nan", 3) == 0) + { + start_index += 3; + if (start_index == end_index + || (string[start_index] == '(' && string[end_index - 1] == ')')) + return 1; + } + } + return 0; +} + +static void +test_function (int (*my_asprintf) (char **, const char *, ...)) +{ + int repeat; + + /* Test return value convention. */ + + for (repeat = 0; repeat <= 8; repeat++) + { + char *result; + int retval = asprintf (&result, "%d", 12345); + ASSERT (retval == 5); + ASSERT (result != NULL); + ASSERT (strcmp (result, "12345") == 0); + free (result); + } + + /* Test support of size specifiers as in C99. */ + + { + char *result; + int retval = + my_asprintf (&result, "%ju %d", (uintmax_t) 12345671, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "12345671 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { + char *result; + int retval = + my_asprintf (&result, "%zu %d", (size_t) 12345672, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "12345672 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { + char *result; + int retval = + my_asprintf (&result, "%tu %d", (ptrdiff_t) 12345673, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "12345673 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { + char *result; + int retval = + my_asprintf (&result, "%Lg %d", (long double) 1.5, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1.5 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + /* Test the support of the 'a' and 'A' conversion specifier for hexadecimal + output of floating-point numbers. */ + + { /* A positive number. */ + char *result; + int retval = + my_asprintf (&result, "%a %d", 3.1416015625, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1.922p+1 33") == 0 + || strcmp (result, "0x3.244p+0 33") == 0 + || strcmp (result, "0x6.488p-1 33") == 0 + || strcmp (result, "0xc.91p-2 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* A negative number. */ + char *result; + int retval = + my_asprintf (&result, "%A %d", -3.1416015625, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "-0X1.922P+1 33") == 0 + || strcmp (result, "-0X3.244P+0 33") == 0 + || strcmp (result, "-0X6.488P-1 33") == 0 + || strcmp (result, "-0XC.91P-2 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Positive zero. */ + char *result; + int retval = + my_asprintf (&result, "%a %d", 0.0, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x0p+0 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Negative zero. */ + char *result; + int retval = + my_asprintf (&result, "%a %d", minus_zerod, 33, 44, 55); + ASSERT (result != NULL); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0x0p+0 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Positive infinity. */ + char *result; + int retval = + my_asprintf (&result, "%a %d", Infinityd (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "inf 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Negative infinity. */ + char *result; + int retval = + my_asprintf (&result, "%a %d", - Infinityd (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "-inf 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* NaN. */ + char *result; + int retval = + my_asprintf (&result, "%a %d", NaNd (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strlen (result) >= 3 + 3 + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Rounding near the decimal point. */ + char *result; + int retval = + my_asprintf (&result, "%.0a %d", 1.5, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1p+0 33") == 0 + || strcmp (result, "0x2p+0 33") == 0 + || strcmp (result, "0x3p-1 33") == 0 + || strcmp (result, "0x6p-2 33") == 0 + || strcmp (result, "0xcp-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Rounding with precision 0. */ + char *result; + int retval = + my_asprintf (&result, "%.0a %d", 1.51, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1p+0 33") == 0 + || strcmp (result, "0x2p+0 33") == 0 + || strcmp (result, "0x3p-1 33") == 0 + || strcmp (result, "0x6p-2 33") == 0 + || strcmp (result, "0xcp-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Rounding with precision 1. */ + char *result; + int retval = + my_asprintf (&result, "%.1a %d", 1.51, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1.8p+0 33") == 0 + || strcmp (result, "0x3.0p-1 33") == 0 + || strcmp (result, "0x6.1p-2 33") == 0 + || strcmp (result, "0xc.1p-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Rounding with precision 2. */ + char *result; + int retval = + my_asprintf (&result, "%.2a %d", 1.51, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1.83p+0 33") == 0 + || strcmp (result, "0x3.05p-1 33") == 0 + || strcmp (result, "0x6.0ap-2 33") == 0 + || strcmp (result, "0xc.14p-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Rounding with precision 3. */ + char *result; + int retval = + my_asprintf (&result, "%.3a %d", 1.51, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1.829p+0 33") == 0 + || strcmp (result, "0x3.052p-1 33") == 0 + || strcmp (result, "0x6.0a4p-2 33") == 0 + || strcmp (result, "0xc.148p-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Rounding can turn a ...FFF into a ...000. */ + char *result; + int retval = + my_asprintf (&result, "%.3a %d", 1.49999, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1.800p+0 33") == 0 + || strcmp (result, "0x3.000p-1 33") == 0 + || strcmp (result, "0x6.000p-2 33") == 0 + || strcmp (result, "0xc.000p-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Rounding can turn a ...FFF into a ...000. + This shows a Mac OS X 10.3.9 (Darwin 7.9) bug. */ + char *result; + int retval = + my_asprintf (&result, "%.1a %d", 1.999, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1.0p+1 33") == 0 + || strcmp (result, "0x2.0p+0 33") == 0 + || strcmp (result, "0x4.0p-1 33") == 0 + || strcmp (result, "0x8.0p-2 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Width. */ + char *result; + int retval = + my_asprintf (&result, "%10a %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, " 0x1.cp+0 33") == 0 + || strcmp (result, " 0x3.8p-1 33") == 0 + || strcmp (result, " 0x7p-2 33") == 0 + || strcmp (result, " 0xep-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Small precision. */ + char *result; + int retval = + my_asprintf (&result, "%.10a %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1.c000000000p+0 33") == 0 + || strcmp (result, "0x3.8000000000p-1 33") == 0 + || strcmp (result, "0x7.0000000000p-2 33") == 0 + || strcmp (result, "0xe.0000000000p-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Large precision. */ + char *result; + int retval = + my_asprintf (&result, "%.50a %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1.c0000000000000000000000000000000000000000000000000p+0 33") == 0 + || strcmp (result, "0x3.80000000000000000000000000000000000000000000000000p-1 33") == 0 + || strcmp (result, "0x7.00000000000000000000000000000000000000000000000000p-2 33") == 0 + || strcmp (result, "0xe.00000000000000000000000000000000000000000000000000p-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_LEFT. */ + char *result; + int retval = + my_asprintf (&result, "%-10a %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1.cp+0 33") == 0 + || strcmp (result, "0x3.8p-1 33") == 0 + || strcmp (result, "0x7p-2 33") == 0 + || strcmp (result, "0xep-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_SHOWSIGN. */ + char *result; + int retval = + my_asprintf (&result, "%+a %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "+0x1.cp+0 33") == 0 + || strcmp (result, "+0x3.8p-1 33") == 0 + || strcmp (result, "+0x7p-2 33") == 0 + || strcmp (result, "+0xep-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_SPACE. */ + char *result; + int retval = + my_asprintf (&result, "% a %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, " 0x1.cp+0 33") == 0 + || strcmp (result, " 0x3.8p-1 33") == 0 + || strcmp (result, " 0x7p-2 33") == 0 + || strcmp (result, " 0xep-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ALT. */ + char *result; + int retval = + my_asprintf (&result, "%#a %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1.cp+0 33") == 0 + || strcmp (result, "0x3.8p-1 33") == 0 + || strcmp (result, "0x7.p-2 33") == 0 + || strcmp (result, "0xe.p-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ALT. */ + char *result; + int retval = + my_asprintf (&result, "%#a %d", 1.0, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1.p+0 33") == 0 + || strcmp (result, "0x2.p-1 33") == 0 + || strcmp (result, "0x4.p-2 33") == 0 + || strcmp (result, "0x8.p-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with finite number. */ + char *result; + int retval = + my_asprintf (&result, "%010a %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x001.cp+0 33") == 0 + || strcmp (result, "0x003.8p-1 33") == 0 + || strcmp (result, "0x00007p-2 33") == 0 + || strcmp (result, "0x0000ep-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with infinite number. */ + char *result; + int retval = + my_asprintf (&result, "%010a %d", Infinityd (), 33, 44, 55); + ASSERT (result != NULL); + /* "0000000inf 33" is not a valid result; see + <https://lists.gnu.org/r/bug-gnulib/2007-04/msg00107.html> */ + ASSERT (strcmp (result, " inf 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with NaN. */ + char *result; + int retval = + my_asprintf (&result, "%050a %d", NaNd (), 33, 44, 55); + ASSERT (result != NULL); + /* "0000000nan 33" is not a valid result; see + <https://lists.gnu.org/r/bug-gnulib/2007-04/msg00107.html> */ + ASSERT (strlen (result) == 50 + 3 + && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* A positive number. */ + char *result; + int retval = + my_asprintf (&result, "%La %d", 3.1416015625L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1.922p+1 33") == 0 + || strcmp (result, "0x3.244p+0 33") == 0 + || strcmp (result, "0x6.488p-1 33") == 0 + || strcmp (result, "0xc.91p-2 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* A negative number. */ + char *result; + int retval = + my_asprintf (&result, "%LA %d", -3.1416015625L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "-0X1.922P+1 33") == 0 + || strcmp (result, "-0X3.244P+0 33") == 0 + || strcmp (result, "-0X6.488P-1 33") == 0 + || strcmp (result, "-0XC.91P-2 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Positive zero. */ + char *result; + int retval = + my_asprintf (&result, "%La %d", 0.0L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x0p+0 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Negative zero. */ + char *result; + int retval = + my_asprintf (&result, "%La %d", minus_zerol, 33, 44, 55); + ASSERT (result != NULL); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0x0p+0 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Positive infinity. */ + char *result; + int retval = + my_asprintf (&result, "%La %d", Infinityl (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "inf 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Negative infinity. */ + char *result; + int retval = + my_asprintf (&result, "%La %d", - Infinityl (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "-inf 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* NaN. */ + char *result; + int retval = + my_asprintf (&result, "%La %d", NaNl (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strlen (result) >= 3 + 3 + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } +#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE + { /* Quiet NaN. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%La %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strlen (result) >= 3 + 3 + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + { + /* Signalling NaN. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%La %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strlen (result) >= 3 + 3 + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + /* asprintf should print something for noncanonical values. */ + { /* Pseudo-NaN. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%La %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (retval == strlen (result)); + ASSERT (3 < retval && strcmp (result + retval - 3, " 33") == 0); + free (result); + } + { /* Pseudo-Infinity. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%La %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (retval == strlen (result)); + ASSERT (3 < retval && strcmp (result + retval - 3, " 33") == 0); + free (result); + } + { /* Pseudo-Zero. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%La %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (retval == strlen (result)); + ASSERT (3 < retval && strcmp (result + retval - 3, " 33") == 0); + free (result); + } + { /* Unnormalized number. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%La %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (retval == strlen (result)); + ASSERT (3 < retval && strcmp (result + retval - 3, " 33") == 0); + free (result); + } + { /* Pseudo-Denormal. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%La %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (retval == strlen (result)); + ASSERT (3 < retval && strcmp (result + retval - 3, " 33") == 0); + free (result); + } +#endif + + { /* Rounding near the decimal point. */ + char *result; + int retval = + my_asprintf (&result, "%.0La %d", 1.5L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x2p+0 33") == 0 + || strcmp (result, "0x3p-1 33") == 0 + || strcmp (result, "0x6p-2 33") == 0 + || strcmp (result, "0xcp-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Rounding with precision 0. */ + char *result; + int retval = + my_asprintf (&result, "%.0La %d", 1.51L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x2p+0 33") == 0 + || strcmp (result, "0x3p-1 33") == 0 + || strcmp (result, "0x6p-2 33") == 0 + || strcmp (result, "0xcp-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Rounding with precision 1. */ + char *result; + int retval = + my_asprintf (&result, "%.1La %d", 1.51L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1.8p+0 33") == 0 + || strcmp (result, "0x3.0p-1 33") == 0 + || strcmp (result, "0x6.1p-2 33") == 0 + || strcmp (result, "0xc.1p-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Rounding with precision 2. */ + char *result; + int retval = + my_asprintf (&result, "%.2La %d", 1.51L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1.83p+0 33") == 0 + || strcmp (result, "0x3.05p-1 33") == 0 + || strcmp (result, "0x6.0ap-2 33") == 0 + || strcmp (result, "0xc.14p-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Rounding with precision 3. */ + char *result; + int retval = + my_asprintf (&result, "%.3La %d", 1.51L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1.829p+0 33") == 0 + || strcmp (result, "0x3.052p-1 33") == 0 + || strcmp (result, "0x6.0a4p-2 33") == 0 + || strcmp (result, "0xc.148p-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Rounding can turn a ...FFF into a ...000. */ + char *result; + int retval = + my_asprintf (&result, "%.3La %d", 1.49999L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1.800p+0 33") == 0 + || strcmp (result, "0x3.000p-1 33") == 0 + || strcmp (result, "0x6.000p-2 33") == 0 + || strcmp (result, "0xc.000p-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Rounding can turn a ...FFF into a ...000. + This shows a Mac OS X 10.3.9 (Darwin 7.9) bug and a + glibc 2.4 bug <https://sourceware.org/bugzilla/show_bug.cgi?id=2908>. */ + char *result; + int retval = + my_asprintf (&result, "%.1La %d", 1.999L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1.0p+1 33") == 0 + || strcmp (result, "0x2.0p+0 33") == 0 + || strcmp (result, "0x4.0p-1 33") == 0 + || strcmp (result, "0x8.0p-2 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Width. */ + char *result; + int retval = + my_asprintf (&result, "%10La %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, " 0x1.cp+0 33") == 0 + || strcmp (result, " 0x3.8p-1 33") == 0 + || strcmp (result, " 0x7p-2 33") == 0 + || strcmp (result, " 0xep-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Small precision. */ + char *result; + int retval = + my_asprintf (&result, "%.10La %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1.c000000000p+0 33") == 0 + || strcmp (result, "0x3.8000000000p-1 33") == 0 + || strcmp (result, "0x7.0000000000p-2 33") == 0 + || strcmp (result, "0xe.0000000000p-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Large precision. */ + char *result; + int retval = + my_asprintf (&result, "%.50La %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1.c0000000000000000000000000000000000000000000000000p+0 33") == 0 + || strcmp (result, "0x3.80000000000000000000000000000000000000000000000000p-1 33") == 0 + || strcmp (result, "0x7.00000000000000000000000000000000000000000000000000p-2 33") == 0 + || strcmp (result, "0xe.00000000000000000000000000000000000000000000000000p-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_LEFT. */ + char *result; + int retval = + my_asprintf (&result, "%-10La %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1.cp+0 33") == 0 + || strcmp (result, "0x3.8p-1 33") == 0 + || strcmp (result, "0x7p-2 33") == 0 + || strcmp (result, "0xep-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_SHOWSIGN. */ + char *result; + int retval = + my_asprintf (&result, "%+La %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "+0x1.cp+0 33") == 0 + || strcmp (result, "+0x3.8p-1 33") == 0 + || strcmp (result, "+0x7p-2 33") == 0 + || strcmp (result, "+0xep-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_SPACE. */ + char *result; + int retval = + my_asprintf (&result, "% La %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, " 0x1.cp+0 33") == 0 + || strcmp (result, " 0x3.8p-1 33") == 0 + || strcmp (result, " 0x7p-2 33") == 0 + || strcmp (result, " 0xep-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ALT. */ + char *result; + int retval = + my_asprintf (&result, "%#La %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1.cp+0 33") == 0 + || strcmp (result, "0x3.8p-1 33") == 0 + || strcmp (result, "0x7.p-2 33") == 0 + || strcmp (result, "0xe.p-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ALT. */ + char *result; + int retval = + my_asprintf (&result, "%#La %d", 1.0L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1.p+0 33") == 0 + || strcmp (result, "0x2.p-1 33") == 0 + || strcmp (result, "0x4.p-2 33") == 0 + || strcmp (result, "0x8.p-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with finite number. */ + char *result; + int retval = + my_asprintf (&result, "%010La %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x001.cp+0 33") == 0 + || strcmp (result, "0x003.8p-1 33") == 0 + || strcmp (result, "0x00007p-2 33") == 0 + || strcmp (result, "0x0000ep-3 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with infinite number. */ + char *result; + int retval = + my_asprintf (&result, "%010La %d", Infinityl (), 33, 44, 55); + ASSERT (result != NULL); + /* "0000000inf 33" is not a valid result; see + <https://lists.gnu.org/r/bug-gnulib/2007-04/msg00107.html> */ + ASSERT (strcmp (result, " inf 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with NaN. */ + char *result; + int retval = + my_asprintf (&result, "%050La %d", NaNl (), 33, 44, 55); + ASSERT (result != NULL); + /* "0000000nan 33" is not a valid result; see + <https://lists.gnu.org/r/bug-gnulib/2007-04/msg00107.html> */ + ASSERT (strlen (result) == 50 + 3 + && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + /* Test the support of the %f format directive. */ + + { /* A positive number. */ + char *result; + int retval = + my_asprintf (&result, "%f %d", 12.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "12.750000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* A larger positive number. */ + char *result; + int retval = + my_asprintf (&result, "%f %d", 1234567.0, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1234567.000000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Small and large positive numbers. */ + static struct { double value; const char *string; } data[] = + { + { 1.234321234321234e-37, "0.000000" }, + { 1.234321234321234e-36, "0.000000" }, + { 1.234321234321234e-35, "0.000000" }, + { 1.234321234321234e-34, "0.000000" }, + { 1.234321234321234e-33, "0.000000" }, + { 1.234321234321234e-32, "0.000000" }, + { 1.234321234321234e-31, "0.000000" }, + { 1.234321234321234e-30, "0.000000" }, + { 1.234321234321234e-29, "0.000000" }, + { 1.234321234321234e-28, "0.000000" }, + { 1.234321234321234e-27, "0.000000" }, + { 1.234321234321234e-26, "0.000000" }, + { 1.234321234321234e-25, "0.000000" }, + { 1.234321234321234e-24, "0.000000" }, + { 1.234321234321234e-23, "0.000000" }, + { 1.234321234321234e-22, "0.000000" }, + { 1.234321234321234e-21, "0.000000" }, + { 1.234321234321234e-20, "0.000000" }, + { 1.234321234321234e-19, "0.000000" }, + { 1.234321234321234e-18, "0.000000" }, + { 1.234321234321234e-17, "0.000000" }, + { 1.234321234321234e-16, "0.000000" }, + { 1.234321234321234e-15, "0.000000" }, + { 1.234321234321234e-14, "0.000000" }, + { 1.234321234321234e-13, "0.000000" }, + { 1.234321234321234e-12, "0.000000" }, + { 1.234321234321234e-11, "0.000000" }, + { 1.234321234321234e-10, "0.000000" }, + { 1.234321234321234e-9, "0.000000" }, + { 1.234321234321234e-8, "0.000000" }, + { 1.234321234321234e-7, "0.000000" }, + { 1.234321234321234e-6, "0.000001" }, + { 1.234321234321234e-5, "0.000012" }, + { 1.234321234321234e-4, "0.000123" }, + { 1.234321234321234e-3, "0.001234" }, + { 1.234321234321234e-2, "0.012343" }, + { 1.234321234321234e-1, "0.123432" }, + { 1.234321234321234, "1.234321" }, + { 1.234321234321234e1, "12.343212" }, + { 1.234321234321234e2, "123.432123" }, + { 1.234321234321234e3, "1234.321234" }, + { 1.234321234321234e4, "12343.212343" }, + { 1.234321234321234e5, "123432.123432" }, + { 1.234321234321234e6, "1234321.234321" }, + { 1.234321234321234e7, "12343212.343212" }, + { 1.234321234321234e8, "123432123.432123" }, + { 1.234321234321234e9, "1234321234.321234" }, + { 1.234321234321234e10, "12343212343.2123**" }, + { 1.234321234321234e11, "123432123432.123***" }, + { 1.234321234321234e12, "1234321234321.23****" }, + { 1.234321234321234e13, "12343212343212.3*****" }, + { 1.234321234321234e14, "123432123432123.******" }, + { 1.234321234321234e15, "1234321234321234.000000" }, + { 1.234321234321234e16, "123432123432123**.000000" }, + { 1.234321234321234e17, "123432123432123***.000000" }, + { 1.234321234321234e18, "123432123432123****.000000" }, + { 1.234321234321234e19, "123432123432123*****.000000" }, + { 1.234321234321234e20, "123432123432123******.000000" }, + { 1.234321234321234e21, "123432123432123*******.000000" }, + { 1.234321234321234e22, "123432123432123********.000000" }, + { 1.234321234321234e23, "123432123432123*********.000000" }, + { 1.234321234321234e24, "123432123432123**********.000000" }, + { 1.234321234321234e25, "123432123432123***********.000000" }, + { 1.234321234321234e26, "123432123432123************.000000" }, + { 1.234321234321234e27, "123432123432123*************.000000" }, + { 1.234321234321234e28, "123432123432123**************.000000" }, + { 1.234321234321234e29, "123432123432123***************.000000" }, + { 1.234321234321234e30, "123432123432123****************.000000" }, + { 1.234321234321234e31, "123432123432123*****************.000000" }, + { 1.234321234321234e32, "123432123432123******************.000000" }, + { 1.234321234321234e33, "123432123432123*******************.000000" }, + { 1.234321234321234e34, "123432123432123********************.000000" }, + { 1.234321234321234e35, "123432123432123*********************.000000" }, + { 1.234321234321234e36, "123432123432123**********************.000000" } + }; + size_t k; + for (k = 0; k < SIZEOF (data); k++) + { + char *result; + int retval = + my_asprintf (&result, "%f", data[k].value); + ASSERT (result != NULL); + ASSERT (strmatch (data[k].string, result)); + ASSERT (retval == strlen (result)); + free (result); + } + } + + { /* A negative number. */ + char *result; + int retval = + my_asprintf (&result, "%f %d", -0.03125, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "-0.031250 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Positive zero. */ + char *result; + int retval = + my_asprintf (&result, "%f %d", 0.0, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0.000000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Negative zero. */ + char *result; + int retval = + my_asprintf (&result, "%f %d", minus_zerod, 33, 44, 55); + ASSERT (result != NULL); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Positive infinity. */ + char *result; + int retval = + my_asprintf (&result, "%f %d", Infinityd (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "inf 33") == 0 + || strcmp (result, "infinity 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Negative infinity. */ + char *result; + int retval = + my_asprintf (&result, "%f %d", - Infinityd (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "-inf 33") == 0 + || strcmp (result, "-infinity 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* NaN. */ + char *result; + int retval = + my_asprintf (&result, "%f %d", NaNd (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strlen (result) >= 3 + 3 + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Width. */ + char *result; + int retval = + my_asprintf (&result, "%10f %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, " 1.750000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_LEFT. */ + char *result; + int retval = + my_asprintf (&result, "%-10f %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1.750000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_SHOWSIGN. */ + char *result; + int retval = + my_asprintf (&result, "%+f %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "+1.750000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_SPACE. */ + char *result; + int retval = + my_asprintf (&result, "% f %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, " 1.750000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ALT. */ + char *result; + int retval = + my_asprintf (&result, "%#f %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1.750000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ALT. */ + char *result; + int retval = + my_asprintf (&result, "%#.f %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "2. 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with finite number. */ + char *result; + int retval = + my_asprintf (&result, "%015f %d", 1234.0, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "00001234.000000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with infinite number. */ + char *result; + int retval = + my_asprintf (&result, "%015f %d", - Infinityd (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, " -inf 33") == 0 + || strcmp (result, " -infinity 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with NaN. */ + char *result; + int retval = + my_asprintf (&result, "%050f %d", NaNd (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strlen (result) == 50 + 3 + && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Precision. */ + char *result; + int retval = + my_asprintf (&result, "%.f %d", 1234.0, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1234 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Precision with no rounding. */ + char *result; + int retval = + my_asprintf (&result, "%.2f %d", 999.951, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "999.95 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Precision with rounding. */ + char *result; + int retval = + my_asprintf (&result, "%.2f %d", 999.996, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1000.00 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* A positive number. */ + char *result; + int retval = + my_asprintf (&result, "%Lf %d", 12.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "12.750000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* A larger positive number. */ + char *result; + int retval = + my_asprintf (&result, "%Lf %d", 1234567.0L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1234567.000000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Small and large positive numbers. */ + static struct { long double value; const char *string; } data[] = + { + { 1.234321234321234e-37L, "0.000000" }, + { 1.234321234321234e-36L, "0.000000" }, + { 1.234321234321234e-35L, "0.000000" }, + { 1.234321234321234e-34L, "0.000000" }, + { 1.234321234321234e-33L, "0.000000" }, + { 1.234321234321234e-32L, "0.000000" }, + { 1.234321234321234e-31L, "0.000000" }, + { 1.234321234321234e-30L, "0.000000" }, + { 1.234321234321234e-29L, "0.000000" }, + { 1.234321234321234e-28L, "0.000000" }, + { 1.234321234321234e-27L, "0.000000" }, + { 1.234321234321234e-26L, "0.000000" }, + { 1.234321234321234e-25L, "0.000000" }, + { 1.234321234321234e-24L, "0.000000" }, + { 1.234321234321234e-23L, "0.000000" }, + { 1.234321234321234e-22L, "0.000000" }, + { 1.234321234321234e-21L, "0.000000" }, + { 1.234321234321234e-20L, "0.000000" }, + { 1.234321234321234e-19L, "0.000000" }, + { 1.234321234321234e-18L, "0.000000" }, + { 1.234321234321234e-17L, "0.000000" }, + { 1.234321234321234e-16L, "0.000000" }, + { 1.234321234321234e-15L, "0.000000" }, + { 1.234321234321234e-14L, "0.000000" }, + { 1.234321234321234e-13L, "0.000000" }, + { 1.234321234321234e-12L, "0.000000" }, + { 1.234321234321234e-11L, "0.000000" }, + { 1.234321234321234e-10L, "0.000000" }, + { 1.234321234321234e-9L, "0.000000" }, + { 1.234321234321234e-8L, "0.000000" }, + { 1.234321234321234e-7L, "0.000000" }, + { 1.234321234321234e-6L, "0.000001" }, + { 1.234321234321234e-5L, "0.000012" }, + { 1.234321234321234e-4L, "0.000123" }, + { 1.234321234321234e-3L, "0.001234" }, + { 1.234321234321234e-2L, "0.012343" }, + { 1.234321234321234e-1L, "0.123432" }, + { 1.234321234321234L, "1.234321" }, + { 1.234321234321234e1L, "12.343212" }, + { 1.234321234321234e2L, "123.432123" }, + { 1.234321234321234e3L, "1234.321234" }, + { 1.234321234321234e4L, "12343.212343" }, + { 1.234321234321234e5L, "123432.123432" }, + { 1.234321234321234e6L, "1234321.234321" }, + { 1.234321234321234e7L, "12343212.343212" }, + { 1.234321234321234e8L, "123432123.432123" }, + { 1.234321234321234e9L, "1234321234.321234" }, + { 1.234321234321234e10L, "12343212343.2123**" }, + { 1.234321234321234e11L, "123432123432.123***" }, + { 1.234321234321234e12L, "1234321234321.23****" }, + { 1.234321234321234e13L, "12343212343212.3*****" }, + { 1.234321234321234e14L, "123432123432123.******" }, + { 1.234321234321234e15L, "1234321234321234.000000" }, + { 1.234321234321234e16L, "123432123432123**.000000" }, + { 1.234321234321234e17L, "123432123432123***.000000" }, + { 1.234321234321234e18L, "123432123432123****.000000" }, + { 1.234321234321234e19L, "123432123432123*****.000000" }, + { 1.234321234321234e20L, "123432123432123******.000000" }, + { 1.234321234321234e21L, "123432123432123*******.000000" }, + { 1.234321234321234e22L, "123432123432123********.000000" }, + { 1.234321234321234e23L, "123432123432123*********.000000" }, + { 1.234321234321234e24L, "123432123432123**********.000000" }, + { 1.234321234321234e25L, "123432123432123***********.000000" }, + { 1.234321234321234e26L, "123432123432123************.000000" }, + { 1.234321234321234e27L, "123432123432123*************.000000" }, + { 1.234321234321234e28L, "123432123432123**************.000000" }, + { 1.234321234321234e29L, "123432123432123***************.000000" }, + { 1.234321234321234e30L, "123432123432123****************.000000" }, + { 1.234321234321234e31L, "123432123432123*****************.000000" }, + { 1.234321234321234e32L, "123432123432123******************.000000" }, + { 1.234321234321234e33L, "123432123432123*******************.000000" }, + { 1.234321234321234e34L, "123432123432123********************.000000" }, + { 1.234321234321234e35L, "123432123432123*********************.000000" }, + { 1.234321234321234e36L, "123432123432123**********************.000000" } + }; + size_t k; + for (k = 0; k < SIZEOF (data); k++) + { + char *result; + int retval = + my_asprintf (&result, "%Lf", data[k].value); + ASSERT (result != NULL); + ASSERT (strmatch (data[k].string, result)); + ASSERT (retval == strlen (result)); + free (result); + } + } + + { /* A negative number. */ + char *result; + int retval = + my_asprintf (&result, "%Lf %d", -0.03125L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "-0.031250 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Positive zero. */ + char *result; + int retval = + my_asprintf (&result, "%Lf %d", 0.0L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0.000000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Negative zero. */ + char *result; + int retval = + my_asprintf (&result, "%Lf %d", minus_zerol, 33, 44, 55); + ASSERT (result != NULL); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Positive infinity. */ + char *result; + int retval = + my_asprintf (&result, "%Lf %d", Infinityl (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "inf 33") == 0 + || strcmp (result, "infinity 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Negative infinity. */ + char *result; + int retval = + my_asprintf (&result, "%Lf %d", - Infinityl (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "-inf 33") == 0 + || strcmp (result, "-infinity 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* NaN. */ + char *result; + int retval = + my_asprintf (&result, "%Lf %d", NaNl (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strlen (result) >= 3 + 3 + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } +#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE + { /* Quiet NaN. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%Lf %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strlen (result) >= 3 + 3 + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + { + /* Signalling NaN. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%Lf %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strlen (result) >= 3 + 3 + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + /* asprintf should print something for noncanonical values. */ + { /* Pseudo-NaN. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%Lf %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (retval == strlen (result)); + ASSERT (3 < retval && strcmp (result + retval - 3, " 33") == 0); + free (result); + } + { /* Pseudo-Infinity. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%Lf %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (retval == strlen (result)); + ASSERT (3 < retval && strcmp (result + retval - 3, " 33") == 0); + free (result); + } + { /* Pseudo-Zero. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%Lf %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (retval == strlen (result)); + ASSERT (3 < retval && strcmp (result + retval - 3, " 33") == 0); + free (result); + } + { /* Unnormalized number. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%Lf %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (retval == strlen (result)); + ASSERT (3 < retval && strcmp (result + retval - 3, " 33") == 0); + free (result); + } + { /* Pseudo-Denormal. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%Lf %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (retval == strlen (result)); + ASSERT (3 < retval && strcmp (result + retval - 3, " 33") == 0); + free (result); + } +#endif + + { /* Width. */ + char *result; + int retval = + my_asprintf (&result, "%10Lf %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, " 1.750000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_LEFT. */ + char *result; + int retval = + my_asprintf (&result, "%-10Lf %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1.750000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_SHOWSIGN. */ + char *result; + int retval = + my_asprintf (&result, "%+Lf %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "+1.750000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_SPACE. */ + char *result; + int retval = + my_asprintf (&result, "% Lf %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, " 1.750000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ALT. */ + char *result; + int retval = + my_asprintf (&result, "%#Lf %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1.750000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ALT. */ + char *result; + int retval = + my_asprintf (&result, "%#.Lf %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "2. 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with finite number. */ + char *result; + int retval = + my_asprintf (&result, "%015Lf %d", 1234.0L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "00001234.000000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with infinite number. */ + char *result; + int retval = + my_asprintf (&result, "%015Lf %d", - Infinityl (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, " -inf 33") == 0 + || strcmp (result, " -infinity 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with NaN. */ + char *result; + int retval = + my_asprintf (&result, "%050Lf %d", NaNl (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strlen (result) == 50 + 3 + && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Precision. */ + char *result; + int retval = + my_asprintf (&result, "%.Lf %d", 1234.0L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1234 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Precision with no rounding. */ + char *result; + int retval = + my_asprintf (&result, "%.2Lf %d", 999.951L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "999.95 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Precision with rounding. */ + char *result; + int retval = + my_asprintf (&result, "%.2Lf %d", 999.996L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1000.00 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + /* Test the support of the %F format directive. */ + + { /* A positive number. */ + char *result; + int retval = + my_asprintf (&result, "%F %d", 12.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "12.750000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* A larger positive number. */ + char *result; + int retval = + my_asprintf (&result, "%F %d", 1234567.0, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1234567.000000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* A negative number. */ + char *result; + int retval = + my_asprintf (&result, "%F %d", -0.03125, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "-0.031250 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Positive zero. */ + char *result; + int retval = + my_asprintf (&result, "%F %d", 0.0, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0.000000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Negative zero. */ + char *result; + int retval = + my_asprintf (&result, "%F %d", minus_zerod, 33, 44, 55); + ASSERT (result != NULL); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Positive infinity. */ + char *result; + int retval = + my_asprintf (&result, "%F %d", Infinityd (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "INF 33") == 0 + || strcmp (result, "INFINITY 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Negative infinity. */ + char *result; + int retval = + my_asprintf (&result, "%F %d", - Infinityd (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "-INF 33") == 0 + || strcmp (result, "-INFINITY 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* NaN. */ + char *result; + int retval = + my_asprintf (&result, "%F %d", NaNd (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strlen (result) >= 3 + 3 + && strisnan (result, 0, strlen (result) - 3, 1) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO. */ + char *result; + int retval = + my_asprintf (&result, "%015F %d", 1234.0, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "00001234.000000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with infinite number. */ + char *result; + int retval = + my_asprintf (&result, "%015F %d", - Infinityd (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, " -INF 33") == 0 + || strcmp (result, " -INFINITY 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Precision. */ + char *result; + int retval = + my_asprintf (&result, "%.F %d", 1234.0, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1234 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Precision with no rounding. */ + char *result; + int retval = + my_asprintf (&result, "%.2F %d", 999.951, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "999.95 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Precision with rounding. */ + char *result; + int retval = + my_asprintf (&result, "%.2F %d", 999.996, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1000.00 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* A positive number. */ + char *result; + int retval = + my_asprintf (&result, "%LF %d", 12.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "12.750000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* A larger positive number. */ + char *result; + int retval = + my_asprintf (&result, "%LF %d", 1234567.0L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1234567.000000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* A negative number. */ + char *result; + int retval = + my_asprintf (&result, "%LF %d", -0.03125L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "-0.031250 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Positive zero. */ + char *result; + int retval = + my_asprintf (&result, "%LF %d", 0.0L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0.000000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Negative zero. */ + char *result; + int retval = + my_asprintf (&result, "%LF %d", minus_zerol, 33, 44, 55); + ASSERT (result != NULL); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Positive infinity. */ + char *result; + int retval = + my_asprintf (&result, "%LF %d", Infinityl (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "INF 33") == 0 + || strcmp (result, "INFINITY 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Negative infinity. */ + char *result; + int retval = + my_asprintf (&result, "%LF %d", - Infinityl (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "-INF 33") == 0 + || strcmp (result, "-INFINITY 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* NaN. */ + char *result; + int retval = + my_asprintf (&result, "%LF %d", NaNl (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strlen (result) >= 3 + 3 + && strisnan (result, 0, strlen (result) - 3, 1) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO. */ + char *result; + int retval = + my_asprintf (&result, "%015LF %d", 1234.0L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "00001234.000000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with infinite number. */ + char *result; + int retval = + my_asprintf (&result, "%015LF %d", - Infinityl (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, " -INF 33") == 0 + || strcmp (result, " -INFINITY 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Precision. */ + char *result; + int retval = + my_asprintf (&result, "%.LF %d", 1234.0L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1234 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Precision with no rounding. */ + char *result; + int retval = + my_asprintf (&result, "%.2LF %d", 999.951L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "999.95 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Precision with rounding. */ + char *result; + int retval = + my_asprintf (&result, "%.2LF %d", 999.996L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1000.00 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + /* Test the support of the %e format directive. */ + + { /* A positive number. */ + char *result; + int retval = + my_asprintf (&result, "%e %d", 12.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1.275000e+01 33") == 0 + || strcmp (result, "1.275000e+001 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* A larger positive number. */ + char *result; + int retval = + my_asprintf (&result, "%e %d", 1234567.0, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1.234567e+06 33") == 0 + || strcmp (result, "1.234567e+006 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Small and large positive numbers. */ + static struct { double value; const char *string; } data[] = + { + { 1.234321234321234e-37, "1.234321e-37" }, + { 1.234321234321234e-36, "1.234321e-36" }, + { 1.234321234321234e-35, "1.234321e-35" }, + { 1.234321234321234e-34, "1.234321e-34" }, + { 1.234321234321234e-33, "1.234321e-33" }, + { 1.234321234321234e-32, "1.234321e-32" }, + { 1.234321234321234e-31, "1.234321e-31" }, + { 1.234321234321234e-30, "1.234321e-30" }, + { 1.234321234321234e-29, "1.234321e-29" }, + { 1.234321234321234e-28, "1.234321e-28" }, + { 1.234321234321234e-27, "1.234321e-27" }, + { 1.234321234321234e-26, "1.234321e-26" }, + { 1.234321234321234e-25, "1.234321e-25" }, + { 1.234321234321234e-24, "1.234321e-24" }, + { 1.234321234321234e-23, "1.234321e-23" }, + { 1.234321234321234e-22, "1.234321e-22" }, + { 1.234321234321234e-21, "1.234321e-21" }, + { 1.234321234321234e-20, "1.234321e-20" }, + { 1.234321234321234e-19, "1.234321e-19" }, + { 1.234321234321234e-18, "1.234321e-18" }, + { 1.234321234321234e-17, "1.234321e-17" }, + { 1.234321234321234e-16, "1.234321e-16" }, + { 1.234321234321234e-15, "1.234321e-15" }, + { 1.234321234321234e-14, "1.234321e-14" }, + { 1.234321234321234e-13, "1.234321e-13" }, + { 1.234321234321234e-12, "1.234321e-12" }, + { 1.234321234321234e-11, "1.234321e-11" }, + { 1.234321234321234e-10, "1.234321e-10" }, + { 1.234321234321234e-9, "1.234321e-09" }, + { 1.234321234321234e-8, "1.234321e-08" }, + { 1.234321234321234e-7, "1.234321e-07" }, + { 1.234321234321234e-6, "1.234321e-06" }, + { 1.234321234321234e-5, "1.234321e-05" }, + { 1.234321234321234e-4, "1.234321e-04" }, + { 1.234321234321234e-3, "1.234321e-03" }, + { 1.234321234321234e-2, "1.234321e-02" }, + { 1.234321234321234e-1, "1.234321e-01" }, + { 1.234321234321234, "1.234321e+00" }, + { 1.234321234321234e1, "1.234321e+01" }, + { 1.234321234321234e2, "1.234321e+02" }, + { 1.234321234321234e3, "1.234321e+03" }, + { 1.234321234321234e4, "1.234321e+04" }, + { 1.234321234321234e5, "1.234321e+05" }, + { 1.234321234321234e6, "1.234321e+06" }, + { 1.234321234321234e7, "1.234321e+07" }, + { 1.234321234321234e8, "1.234321e+08" }, + { 1.234321234321234e9, "1.234321e+09" }, + { 1.234321234321234e10, "1.234321e+10" }, + { 1.234321234321234e11, "1.234321e+11" }, + { 1.234321234321234e12, "1.234321e+12" }, + { 1.234321234321234e13, "1.234321e+13" }, + { 1.234321234321234e14, "1.234321e+14" }, + { 1.234321234321234e15, "1.234321e+15" }, + { 1.234321234321234e16, "1.234321e+16" }, + { 1.234321234321234e17, "1.234321e+17" }, + { 1.234321234321234e18, "1.234321e+18" }, + { 1.234321234321234e19, "1.234321e+19" }, + { 1.234321234321234e20, "1.234321e+20" }, + { 1.234321234321234e21, "1.234321e+21" }, + { 1.234321234321234e22, "1.234321e+22" }, + { 1.234321234321234e23, "1.234321e+23" }, + { 1.234321234321234e24, "1.234321e+24" }, + { 1.234321234321234e25, "1.234321e+25" }, + { 1.234321234321234e26, "1.234321e+26" }, + { 1.234321234321234e27, "1.234321e+27" }, + { 1.234321234321234e28, "1.234321e+28" }, + { 1.234321234321234e29, "1.234321e+29" }, + { 1.234321234321234e30, "1.234321e+30" }, + { 1.234321234321234e31, "1.234321e+31" }, + { 1.234321234321234e32, "1.234321e+32" }, + { 1.234321234321234e33, "1.234321e+33" }, + { 1.234321234321234e34, "1.234321e+34" }, + { 1.234321234321234e35, "1.234321e+35" }, + { 1.234321234321234e36, "1.234321e+36" } + }; + size_t k; + for (k = 0; k < SIZEOF (data); k++) + { + char *result; + int retval = + my_asprintf (&result, "%e", data[k].value); + const char *expected = data[k].string; + ASSERT (result != NULL); + ASSERT (strcmp (result, expected) == 0 + /* Some implementations produce exponents with 3 digits. */ + || (strlen (result) == strlen (expected) + 1 + && memcmp (result, expected, strlen (expected) - 2) == 0 + && result[strlen (expected) - 2] == '0' + && strcmp (result + strlen (expected) - 1, + expected + strlen (expected) - 2) + == 0)); + ASSERT (retval == strlen (result)); + free (result); + } + } + + { /* A negative number. */ + char *result; + int retval = + my_asprintf (&result, "%e %d", -0.03125, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "-3.125000e-02 33") == 0 + || strcmp (result, "-3.125000e-002 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Positive zero. */ + char *result; + int retval = + my_asprintf (&result, "%e %d", 0.0, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0.000000e+00 33") == 0 + || strcmp (result, "0.000000e+000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Negative zero. */ + char *result; + int retval = + my_asprintf (&result, "%e %d", minus_zerod, 33, 44, 55); + ASSERT (result != NULL); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000e+00 33") == 0 + || strcmp (result, "-0.000000e+000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Positive infinity. */ + char *result; + int retval = + my_asprintf (&result, "%e %d", Infinityd (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "inf 33") == 0 + || strcmp (result, "infinity 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Negative infinity. */ + char *result; + int retval = + my_asprintf (&result, "%e %d", - Infinityd (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "-inf 33") == 0 + || strcmp (result, "-infinity 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* NaN. */ + char *result; + int retval = + my_asprintf (&result, "%e %d", NaNd (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strlen (result) >= 3 + 3 + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Width. */ + char *result; + int retval = + my_asprintf (&result, "%15e %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, " 1.750000e+00 33") == 0 + || strcmp (result, " 1.750000e+000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_LEFT. */ + char *result; + int retval = + my_asprintf (&result, "%-15e %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1.750000e+00 33") == 0 + || strcmp (result, "1.750000e+000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_SHOWSIGN. */ + char *result; + int retval = + my_asprintf (&result, "%+e %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "+1.750000e+00 33") == 0 + || strcmp (result, "+1.750000e+000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_SPACE. */ + char *result; + int retval = + my_asprintf (&result, "% e %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, " 1.750000e+00 33") == 0 + || strcmp (result, " 1.750000e+000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ALT. */ + char *result; + int retval = + my_asprintf (&result, "%#e %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1.750000e+00 33") == 0 + || strcmp (result, "1.750000e+000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ALT. */ + char *result; + int retval = + my_asprintf (&result, "%#.e %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "2.e+00 33") == 0 + || strcmp (result, "2.e+000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ALT. */ + char *result; + int retval = + my_asprintf (&result, "%#.e %d", 9.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1.e+01 33") == 0 + || strcmp (result, "1.e+001 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with finite number. */ + char *result; + int retval = + my_asprintf (&result, "%015e %d", 1234.0, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0001.234000e+03 33") == 0 + || strcmp (result, "001.234000e+003 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with infinite number. */ + char *result; + int retval = + my_asprintf (&result, "%015e %d", - Infinityd (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, " -inf 33") == 0 + || strcmp (result, " -infinity 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with NaN. */ + char *result; + int retval = + my_asprintf (&result, "%050e %d", NaNd (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strlen (result) == 50 + 3 + && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Precision. */ + char *result; + int retval = + my_asprintf (&result, "%.e %d", 1234.0, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1e+03 33") == 0 + || strcmp (result, "1e+003 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Precision with no rounding. */ + char *result; + int retval = + my_asprintf (&result, "%.4e %d", 999.951, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "9.9995e+02 33") == 0 + || strcmp (result, "9.9995e+002 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Precision with rounding. */ + char *result; + int retval = + my_asprintf (&result, "%.4e %d", 999.996, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1.0000e+03 33") == 0 + || strcmp (result, "1.0000e+003 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* A positive number. */ + char *result; + int retval = + my_asprintf (&result, "%Le %d", 12.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1.275000e+01 33") == 0 + || strcmp (result, "1.275000e+001 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* A larger positive number. */ + char *result; + int retval = + my_asprintf (&result, "%Le %d", 1234567.0L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1.234567e+06 33") == 0 + || strcmp (result, "1.234567e+006 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Small and large positive numbers. */ + static struct { long double value; const char *string; } data[] = + { + { 1.234321234321234e-37L, "1.234321e-37" }, + { 1.234321234321234e-36L, "1.234321e-36" }, + { 1.234321234321234e-35L, "1.234321e-35" }, + { 1.234321234321234e-34L, "1.234321e-34" }, + { 1.234321234321234e-33L, "1.234321e-33" }, + { 1.234321234321234e-32L, "1.234321e-32" }, + { 1.234321234321234e-31L, "1.234321e-31" }, + { 1.234321234321234e-30L, "1.234321e-30" }, + { 1.234321234321234e-29L, "1.234321e-29" }, + { 1.234321234321234e-28L, "1.234321e-28" }, + { 1.234321234321234e-27L, "1.234321e-27" }, + { 1.234321234321234e-26L, "1.234321e-26" }, + { 1.234321234321234e-25L, "1.234321e-25" }, + { 1.234321234321234e-24L, "1.234321e-24" }, + { 1.234321234321234e-23L, "1.234321e-23" }, + { 1.234321234321234e-22L, "1.234321e-22" }, + { 1.234321234321234e-21L, "1.234321e-21" }, + { 1.234321234321234e-20L, "1.234321e-20" }, + { 1.234321234321234e-19L, "1.234321e-19" }, + { 1.234321234321234e-18L, "1.234321e-18" }, + { 1.234321234321234e-17L, "1.234321e-17" }, + { 1.234321234321234e-16L, "1.234321e-16" }, + { 1.234321234321234e-15L, "1.234321e-15" }, + { 1.234321234321234e-14L, "1.234321e-14" }, + { 1.234321234321234e-13L, "1.234321e-13" }, + { 1.234321234321234e-12L, "1.234321e-12" }, + { 1.234321234321234e-11L, "1.234321e-11" }, + { 1.234321234321234e-10L, "1.234321e-10" }, + { 1.234321234321234e-9L, "1.234321e-09" }, + { 1.234321234321234e-8L, "1.234321e-08" }, + { 1.234321234321234e-7L, "1.234321e-07" }, + { 1.234321234321234e-6L, "1.234321e-06" }, + { 1.234321234321234e-5L, "1.234321e-05" }, + { 1.234321234321234e-4L, "1.234321e-04" }, + { 1.234321234321234e-3L, "1.234321e-03" }, + { 1.234321234321234e-2L, "1.234321e-02" }, + { 1.234321234321234e-1L, "1.234321e-01" }, + { 1.234321234321234L, "1.234321e+00" }, + { 1.234321234321234e1L, "1.234321e+01" }, + { 1.234321234321234e2L, "1.234321e+02" }, + { 1.234321234321234e3L, "1.234321e+03" }, + { 1.234321234321234e4L, "1.234321e+04" }, + { 1.234321234321234e5L, "1.234321e+05" }, + { 1.234321234321234e6L, "1.234321e+06" }, + { 1.234321234321234e7L, "1.234321e+07" }, + { 1.234321234321234e8L, "1.234321e+08" }, + { 1.234321234321234e9L, "1.234321e+09" }, + { 1.234321234321234e10L, "1.234321e+10" }, + { 1.234321234321234e11L, "1.234321e+11" }, + { 1.234321234321234e12L, "1.234321e+12" }, + { 1.234321234321234e13L, "1.234321e+13" }, + { 1.234321234321234e14L, "1.234321e+14" }, + { 1.234321234321234e15L, "1.234321e+15" }, + { 1.234321234321234e16L, "1.234321e+16" }, + { 1.234321234321234e17L, "1.234321e+17" }, + { 1.234321234321234e18L, "1.234321e+18" }, + { 1.234321234321234e19L, "1.234321e+19" }, + { 1.234321234321234e20L, "1.234321e+20" }, + { 1.234321234321234e21L, "1.234321e+21" }, + { 1.234321234321234e22L, "1.234321e+22" }, + { 1.234321234321234e23L, "1.234321e+23" }, + { 1.234321234321234e24L, "1.234321e+24" }, + { 1.234321234321234e25L, "1.234321e+25" }, + { 1.234321234321234e26L, "1.234321e+26" }, + { 1.234321234321234e27L, "1.234321e+27" }, + { 1.234321234321234e28L, "1.234321e+28" }, + { 1.234321234321234e29L, "1.234321e+29" }, + { 1.234321234321234e30L, "1.234321e+30" }, + { 1.234321234321234e31L, "1.234321e+31" }, + { 1.234321234321234e32L, "1.234321e+32" }, + { 1.234321234321234e33L, "1.234321e+33" }, + { 1.234321234321234e34L, "1.234321e+34" }, + { 1.234321234321234e35L, "1.234321e+35" }, + { 1.234321234321234e36L, "1.234321e+36" } + }; + size_t k; + for (k = 0; k < SIZEOF (data); k++) + { + char *result; + int retval = + my_asprintf (&result, "%Le", data[k].value); + const char *expected = data[k].string; + ASSERT (result != NULL); + ASSERT (strcmp (result, expected) == 0 + /* Some implementations produce exponents with 3 digits. */ + || (strlen (result) == strlen (expected) + 1 + && memcmp (result, expected, strlen (expected) - 2) == 0 + && result[strlen (expected) - 2] == '0' + && strcmp (result + strlen (expected) - 1, + expected + strlen (expected) - 2) + == 0)); + ASSERT (retval == strlen (result)); + free (result); + } + } + + { /* A negative number. */ + char *result; + int retval = + my_asprintf (&result, "%Le %d", -0.03125L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "-3.125000e-02 33") == 0 + || strcmp (result, "-3.125000e-002 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Positive zero. */ + char *result; + int retval = + my_asprintf (&result, "%Le %d", 0.0L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0.000000e+00 33") == 0 + || strcmp (result, "0.000000e+000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Negative zero. */ + char *result; + int retval = + my_asprintf (&result, "%Le %d", minus_zerol, 33, 44, 55); + ASSERT (result != NULL); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000e+00 33") == 0 + || strcmp (result, "-0.000000e+000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Positive infinity. */ + char *result; + int retval = + my_asprintf (&result, "%Le %d", Infinityl (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "inf 33") == 0 + || strcmp (result, "infinity 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Negative infinity. */ + char *result; + int retval = + my_asprintf (&result, "%Le %d", - Infinityl (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "-inf 33") == 0 + || strcmp (result, "-infinity 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* NaN. */ + char *result; + int retval = + my_asprintf (&result, "%Le %d", NaNl (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strlen (result) >= 3 + 3 + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } +#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE + { /* Quiet NaN. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%Le %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strlen (result) >= 3 + 3 + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + { + /* Signalling NaN. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%Le %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strlen (result) >= 3 + 3 + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + /* asprintf should print something for noncanonical values. */ + { /* Pseudo-NaN. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%Le %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (retval == strlen (result)); + ASSERT (3 < retval && strcmp (result + retval - 3, " 33") == 0); + free (result); + } + { /* Pseudo-Infinity. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%Le %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (retval == strlen (result)); + ASSERT (3 < retval && strcmp (result + retval - 3, " 33") == 0); + free (result); + } + { /* Pseudo-Zero. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%Le %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (retval == strlen (result)); + ASSERT (3 < retval && strcmp (result + retval - 3, " 33") == 0); + free (result); + } + { /* Unnormalized number. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%Le %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (retval == strlen (result)); + ASSERT (3 < retval && strcmp (result + retval - 3, " 33") == 0); + free (result); + } + { /* Pseudo-Denormal. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%Le %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (retval == strlen (result)); + ASSERT (3 < retval && strcmp (result + retval - 3, " 33") == 0); + free (result); + } +#endif + + { /* Width. */ + char *result; + int retval = + my_asprintf (&result, "%15Le %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, " 1.750000e+00 33") == 0 + || strcmp (result, " 1.750000e+000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_LEFT. */ + char *result; + int retval = + my_asprintf (&result, "%-15Le %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1.750000e+00 33") == 0 + || strcmp (result, "1.750000e+000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_SHOWSIGN. */ + char *result; + int retval = + my_asprintf (&result, "%+Le %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "+1.750000e+00 33") == 0 + || strcmp (result, "+1.750000e+000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_SPACE. */ + char *result; + int retval = + my_asprintf (&result, "% Le %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, " 1.750000e+00 33") == 0 + || strcmp (result, " 1.750000e+000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ALT. */ + char *result; + int retval = + my_asprintf (&result, "%#Le %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1.750000e+00 33") == 0 + || strcmp (result, "1.750000e+000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ALT. */ + char *result; + int retval = + my_asprintf (&result, "%#.Le %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "2.e+00 33") == 0 + || strcmp (result, "2.e+000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ALT. */ + char *result; + int retval = + my_asprintf (&result, "%#.Le %d", 9.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1.e+01 33") == 0 + || strcmp (result, "1.e+001 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with finite number. */ + char *result; + int retval = + my_asprintf (&result, "%015Le %d", 1234.0L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0001.234000e+03 33") == 0 + || strcmp (result, "001.234000e+003 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with infinite number. */ + char *result; + int retval = + my_asprintf (&result, "%015Le %d", - Infinityl (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, " -inf 33") == 0 + || strcmp (result, " -infinity 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with NaN. */ + char *result; + int retval = + my_asprintf (&result, "%050Le %d", NaNl (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strlen (result) == 50 + 3 + && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Precision. */ + char *result; + int retval = + my_asprintf (&result, "%.Le %d", 1234.0L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1e+03 33") == 0 + || strcmp (result, "1e+003 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Precision with no rounding. */ + char *result; + int retval = + my_asprintf (&result, "%.4Le %d", 999.951L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "9.9995e+02 33") == 0 + || strcmp (result, "9.9995e+002 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Precision with rounding. */ + char *result; + int retval = + my_asprintf (&result, "%.4Le %d", 999.996L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1.0000e+03 33") == 0 + || strcmp (result, "1.0000e+003 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + /* Test the support of the %g format directive. */ + + { /* A positive number. */ + char *result; + int retval = + my_asprintf (&result, "%g %d", 12.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "12.75 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* A larger positive number. */ + char *result; + int retval = + my_asprintf (&result, "%g %d", 1234567.0, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1.23457e+06 33") == 0 + || strcmp (result, "1.23457e+006 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Small and large positive numbers. */ + static struct { double value; const char *string; } data[] = + { + { 1.234321234321234e-37, "1.23432e-37" }, + { 1.234321234321234e-36, "1.23432e-36" }, + { 1.234321234321234e-35, "1.23432e-35" }, + { 1.234321234321234e-34, "1.23432e-34" }, + { 1.234321234321234e-33, "1.23432e-33" }, + { 1.234321234321234e-32, "1.23432e-32" }, + { 1.234321234321234e-31, "1.23432e-31" }, + { 1.234321234321234e-30, "1.23432e-30" }, + { 1.234321234321234e-29, "1.23432e-29" }, + { 1.234321234321234e-28, "1.23432e-28" }, + { 1.234321234321234e-27, "1.23432e-27" }, + { 1.234321234321234e-26, "1.23432e-26" }, + { 1.234321234321234e-25, "1.23432e-25" }, + { 1.234321234321234e-24, "1.23432e-24" }, + { 1.234321234321234e-23, "1.23432e-23" }, + { 1.234321234321234e-22, "1.23432e-22" }, + { 1.234321234321234e-21, "1.23432e-21" }, + { 1.234321234321234e-20, "1.23432e-20" }, + { 1.234321234321234e-19, "1.23432e-19" }, + { 1.234321234321234e-18, "1.23432e-18" }, + { 1.234321234321234e-17, "1.23432e-17" }, + { 1.234321234321234e-16, "1.23432e-16" }, + { 1.234321234321234e-15, "1.23432e-15" }, + { 1.234321234321234e-14, "1.23432e-14" }, + { 1.234321234321234e-13, "1.23432e-13" }, + { 1.234321234321234e-12, "1.23432e-12" }, + { 1.234321234321234e-11, "1.23432e-11" }, + { 1.234321234321234e-10, "1.23432e-10" }, + { 1.234321234321234e-9, "1.23432e-09" }, + { 1.234321234321234e-8, "1.23432e-08" }, + { 1.234321234321234e-7, "1.23432e-07" }, + { 1.234321234321234e-6, "1.23432e-06" }, + { 1.234321234321234e-5, "1.23432e-05" }, + { 1.234321234321234e-4, "0.000123432" }, + { 1.234321234321234e-3, "0.00123432" }, + { 1.234321234321234e-2, "0.0123432" }, + { 1.234321234321234e-1, "0.123432" }, + { 1.234321234321234, "1.23432" }, + { 1.234321234321234e1, "12.3432" }, + { 1.234321234321234e2, "123.432" }, + { 1.234321234321234e3, "1234.32" }, + { 1.234321234321234e4, "12343.2" }, + { 1.234321234321234e5, "123432" }, + { 1.234321234321234e6, "1.23432e+06" }, + { 1.234321234321234e7, "1.23432e+07" }, + { 1.234321234321234e8, "1.23432e+08" }, + { 1.234321234321234e9, "1.23432e+09" }, + { 1.234321234321234e10, "1.23432e+10" }, + { 1.234321234321234e11, "1.23432e+11" }, + { 1.234321234321234e12, "1.23432e+12" }, + { 1.234321234321234e13, "1.23432e+13" }, + { 1.234321234321234e14, "1.23432e+14" }, + { 1.234321234321234e15, "1.23432e+15" }, + { 1.234321234321234e16, "1.23432e+16" }, + { 1.234321234321234e17, "1.23432e+17" }, + { 1.234321234321234e18, "1.23432e+18" }, + { 1.234321234321234e19, "1.23432e+19" }, + { 1.234321234321234e20, "1.23432e+20" }, + { 1.234321234321234e21, "1.23432e+21" }, + { 1.234321234321234e22, "1.23432e+22" }, + { 1.234321234321234e23, "1.23432e+23" }, + { 1.234321234321234e24, "1.23432e+24" }, + { 1.234321234321234e25, "1.23432e+25" }, + { 1.234321234321234e26, "1.23432e+26" }, + { 1.234321234321234e27, "1.23432e+27" }, + { 1.234321234321234e28, "1.23432e+28" }, + { 1.234321234321234e29, "1.23432e+29" }, + { 1.234321234321234e30, "1.23432e+30" }, + { 1.234321234321234e31, "1.23432e+31" }, + { 1.234321234321234e32, "1.23432e+32" }, + { 1.234321234321234e33, "1.23432e+33" }, + { 1.234321234321234e34, "1.23432e+34" }, + { 1.234321234321234e35, "1.23432e+35" }, + { 1.234321234321234e36, "1.23432e+36" } + }; + size_t k; + for (k = 0; k < SIZEOF (data); k++) + { + char *result; + int retval = + my_asprintf (&result, "%g", data[k].value); + const char *expected = data[k].string; + ASSERT (result != NULL); + ASSERT (strcmp (result, expected) == 0 + /* Some implementations produce exponents with 3 digits. */ + || (expected[strlen (expected) - 4] == 'e' + && strlen (result) == strlen (expected) + 1 + && memcmp (result, expected, strlen (expected) - 2) == 0 + && result[strlen (expected) - 2] == '0' + && strcmp (result + strlen (expected) - 1, + expected + strlen (expected) - 2) + == 0)); + ASSERT (retval == strlen (result)); + free (result); + } + } + + { /* A negative number. */ + char *result; + int retval = + my_asprintf (&result, "%g %d", -0.03125, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "-0.03125 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Positive zero. */ + char *result; + int retval = + my_asprintf (&result, "%g %d", 0.0, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Negative zero. */ + char *result; + int retval = + my_asprintf (&result, "%g %d", minus_zerod, 33, 44, 55); + ASSERT (result != NULL); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Positive infinity. */ + char *result; + int retval = + my_asprintf (&result, "%g %d", Infinityd (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "inf 33") == 0 + || strcmp (result, "infinity 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Negative infinity. */ + char *result; + int retval = + my_asprintf (&result, "%g %d", - Infinityd (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "-inf 33") == 0 + || strcmp (result, "-infinity 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* NaN. */ + char *result; + int retval = + my_asprintf (&result, "%g %d", NaNd (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strlen (result) >= 3 + 3 + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Width. */ + char *result; + int retval = + my_asprintf (&result, "%10g %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, " 1.75 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_LEFT. */ + char *result; + int retval = + my_asprintf (&result, "%-10g %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1.75 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_SHOWSIGN. */ + char *result; + int retval = + my_asprintf (&result, "%+g %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "+1.75 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_SPACE. */ + char *result; + int retval = + my_asprintf (&result, "% g %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, " 1.75 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ALT. */ + char *result; + int retval = + my_asprintf (&result, "%#g %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1.75000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ALT. */ + char *result; + int retval = + my_asprintf (&result, "%#.g %d", 1.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "2. 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ALT. */ + char *result; + int retval = + my_asprintf (&result, "%#.g %d", 9.75, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1.e+01 33") == 0 + || strcmp (result, "1.e+001 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with finite number. */ + char *result; + int retval = + my_asprintf (&result, "%010g %d", 1234.0, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0000001234 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with infinite number. */ + char *result; + int retval = + my_asprintf (&result, "%015g %d", - Infinityd (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, " -inf 33") == 0 + || strcmp (result, " -infinity 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with NaN. */ + char *result; + int retval = + my_asprintf (&result, "%050g %d", NaNd (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strlen (result) == 50 + 3 + && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Precision. */ + char *result; + int retval = + my_asprintf (&result, "%.g %d", 1234.0, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1e+03 33") == 0 + || strcmp (result, "1e+003 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Precision with no rounding. */ + char *result; + int retval = + my_asprintf (&result, "%.5g %d", 999.951, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "999.95 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Precision with rounding. */ + char *result; + int retval = + my_asprintf (&result, "%.5g %d", 999.996, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* A positive number. */ + char *result; + int retval = + my_asprintf (&result, "%Lg %d", 12.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "12.75 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* A larger positive number. */ + char *result; + int retval = + my_asprintf (&result, "%Lg %d", 1234567.0L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1.23457e+06 33") == 0 + || strcmp (result, "1.23457e+006 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Small and large positive numbers. */ + static struct { long double value; const char *string; } data[] = + { + { 1.234321234321234e-37L, "1.23432e-37" }, + { 1.234321234321234e-36L, "1.23432e-36" }, + { 1.234321234321234e-35L, "1.23432e-35" }, + { 1.234321234321234e-34L, "1.23432e-34" }, + { 1.234321234321234e-33L, "1.23432e-33" }, + { 1.234321234321234e-32L, "1.23432e-32" }, + { 1.234321234321234e-31L, "1.23432e-31" }, + { 1.234321234321234e-30L, "1.23432e-30" }, + { 1.234321234321234e-29L, "1.23432e-29" }, + { 1.234321234321234e-28L, "1.23432e-28" }, + { 1.234321234321234e-27L, "1.23432e-27" }, + { 1.234321234321234e-26L, "1.23432e-26" }, + { 1.234321234321234e-25L, "1.23432e-25" }, + { 1.234321234321234e-24L, "1.23432e-24" }, + { 1.234321234321234e-23L, "1.23432e-23" }, + { 1.234321234321234e-22L, "1.23432e-22" }, + { 1.234321234321234e-21L, "1.23432e-21" }, + { 1.234321234321234e-20L, "1.23432e-20" }, + { 1.234321234321234e-19L, "1.23432e-19" }, + { 1.234321234321234e-18L, "1.23432e-18" }, + { 1.234321234321234e-17L, "1.23432e-17" }, + { 1.234321234321234e-16L, "1.23432e-16" }, + { 1.234321234321234e-15L, "1.23432e-15" }, + { 1.234321234321234e-14L, "1.23432e-14" }, + { 1.234321234321234e-13L, "1.23432e-13" }, + { 1.234321234321234e-12L, "1.23432e-12" }, + { 1.234321234321234e-11L, "1.23432e-11" }, + { 1.234321234321234e-10L, "1.23432e-10" }, + { 1.234321234321234e-9L, "1.23432e-09" }, + { 1.234321234321234e-8L, "1.23432e-08" }, + { 1.234321234321234e-7L, "1.23432e-07" }, + { 1.234321234321234e-6L, "1.23432e-06" }, + { 1.234321234321234e-5L, "1.23432e-05" }, + { 1.234321234321234e-4L, "0.000123432" }, + { 1.234321234321234e-3L, "0.00123432" }, + { 1.234321234321234e-2L, "0.0123432" }, + { 1.234321234321234e-1L, "0.123432" }, + { 1.234321234321234L, "1.23432" }, + { 1.234321234321234e1L, "12.3432" }, + { 1.234321234321234e2L, "123.432" }, + { 1.234321234321234e3L, "1234.32" }, + { 1.234321234321234e4L, "12343.2" }, + { 1.234321234321234e5L, "123432" }, + { 1.234321234321234e6L, "1.23432e+06" }, + { 1.234321234321234e7L, "1.23432e+07" }, + { 1.234321234321234e8L, "1.23432e+08" }, + { 1.234321234321234e9L, "1.23432e+09" }, + { 1.234321234321234e10L, "1.23432e+10" }, + { 1.234321234321234e11L, "1.23432e+11" }, + { 1.234321234321234e12L, "1.23432e+12" }, + { 1.234321234321234e13L, "1.23432e+13" }, + { 1.234321234321234e14L, "1.23432e+14" }, + { 1.234321234321234e15L, "1.23432e+15" }, + { 1.234321234321234e16L, "1.23432e+16" }, + { 1.234321234321234e17L, "1.23432e+17" }, + { 1.234321234321234e18L, "1.23432e+18" }, + { 1.234321234321234e19L, "1.23432e+19" }, + { 1.234321234321234e20L, "1.23432e+20" }, + { 1.234321234321234e21L, "1.23432e+21" }, + { 1.234321234321234e22L, "1.23432e+22" }, + { 1.234321234321234e23L, "1.23432e+23" }, + { 1.234321234321234e24L, "1.23432e+24" }, + { 1.234321234321234e25L, "1.23432e+25" }, + { 1.234321234321234e26L, "1.23432e+26" }, + { 1.234321234321234e27L, "1.23432e+27" }, + { 1.234321234321234e28L, "1.23432e+28" }, + { 1.234321234321234e29L, "1.23432e+29" }, + { 1.234321234321234e30L, "1.23432e+30" }, + { 1.234321234321234e31L, "1.23432e+31" }, + { 1.234321234321234e32L, "1.23432e+32" }, + { 1.234321234321234e33L, "1.23432e+33" }, + { 1.234321234321234e34L, "1.23432e+34" }, + { 1.234321234321234e35L, "1.23432e+35" }, + { 1.234321234321234e36L, "1.23432e+36" } + }; + size_t k; + for (k = 0; k < SIZEOF (data); k++) + { + char *result; + int retval = + my_asprintf (&result, "%Lg", data[k].value); + const char *expected = data[k].string; + ASSERT (result != NULL); + ASSERT (strcmp (result, expected) == 0 + /* Some implementations produce exponents with 3 digits. */ + || (expected[strlen (expected) - 4] == 'e' + && strlen (result) == strlen (expected) + 1 + && memcmp (result, expected, strlen (expected) - 2) == 0 + && result[strlen (expected) - 2] == '0' + && strcmp (result + strlen (expected) - 1, + expected + strlen (expected) - 2) + == 0)); + ASSERT (retval == strlen (result)); + free (result); + } + } + + { /* A negative number. */ + char *result; + int retval = + my_asprintf (&result, "%Lg %d", -0.03125L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "-0.03125 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Positive zero. */ + char *result; + int retval = + my_asprintf (&result, "%Lg %d", 0.0L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Negative zero. */ + char *result; + int retval = + my_asprintf (&result, "%Lg %d", minus_zerol, 33, 44, 55); + ASSERT (result != NULL); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Positive infinity. */ + char *result; + int retval = + my_asprintf (&result, "%Lg %d", Infinityl (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "inf 33") == 0 + || strcmp (result, "infinity 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Negative infinity. */ + char *result; + int retval = + my_asprintf (&result, "%Lg %d", - Infinityl (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "-inf 33") == 0 + || strcmp (result, "-infinity 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* NaN. */ + char *result; + int retval = + my_asprintf (&result, "%Lg %d", NaNl (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strlen (result) >= 3 + 3 + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } +#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE + { /* Quiet NaN. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%Lg %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strlen (result) >= 3 + 3 + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + { + /* Signalling NaN. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%Lg %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strlen (result) >= 3 + 3 + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + /* asprintf should print something for noncanonical values. */ + { /* Pseudo-NaN. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%Lg %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (retval == strlen (result)); + ASSERT (3 < retval && strcmp (result + retval - 3, " 33") == 0); + free (result); + } + { /* Pseudo-Infinity. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%Lg %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (retval == strlen (result)); + ASSERT (3 < retval && strcmp (result + retval - 3, " 33") == 0); + free (result); + } + { /* Pseudo-Zero. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%Lg %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (retval == strlen (result)); + ASSERT (3 < retval && strcmp (result + retval - 3, " 33") == 0); + free (result); + } + { /* Unnormalized number. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%Lg %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (retval == strlen (result)); + ASSERT (3 < retval && strcmp (result + retval - 3, " 33") == 0); + free (result); + } + { /* Pseudo-Denormal. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; + char *result; + int retval = + my_asprintf (&result, "%Lg %d", x.value, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (retval == strlen (result)); + ASSERT (3 < retval && strcmp (result + retval - 3, " 33") == 0); + free (result); + } +#endif + + { /* Width. */ + char *result; + int retval = + my_asprintf (&result, "%10Lg %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, " 1.75 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_LEFT. */ + char *result; + int retval = + my_asprintf (&result, "%-10Lg %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1.75 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_SHOWSIGN. */ + char *result; + int retval = + my_asprintf (&result, "%+Lg %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "+1.75 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_SPACE. */ + char *result; + int retval = + my_asprintf (&result, "% Lg %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, " 1.75 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ALT. */ + char *result; + int retval = + my_asprintf (&result, "%#Lg %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1.75000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ALT. */ + char *result; + int retval = + my_asprintf (&result, "%#.Lg %d", 1.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "2. 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ALT. */ + char *result; + int retval = + my_asprintf (&result, "%#.Lg %d", 9.75L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1.e+01 33") == 0 + || strcmp (result, "1.e+001 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with finite number. */ + char *result; + int retval = + my_asprintf (&result, "%010Lg %d", 1234.0L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0000001234 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with infinite number. */ + char *result; + int retval = + my_asprintf (&result, "%015Lg %d", - Infinityl (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, " -inf 33") == 0 + || strcmp (result, " -infinity 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* FLAG_ZERO with NaN. */ + char *result; + int retval = + my_asprintf (&result, "%050Lg %d", NaNl (), 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strlen (result) == 50 + 3 + && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Precision. */ + char *result; + int retval = + my_asprintf (&result, "%.Lg %d", 1234.0L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1e+03 33") == 0 + || strcmp (result, "1e+003 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Precision with no rounding. */ + char *result; + int retval = + my_asprintf (&result, "%.5Lg %d", 999.951L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "999.95 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { /* Precision with rounding. */ + char *result; + int retval = + my_asprintf (&result, "%.5Lg %d", 999.996L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1000 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + /* Test the support of the %n format directive. */ + + { + int count = -1; + char *result; + int retval = + my_asprintf (&result, "%d %n", 123, &count, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "123 ") == 0); + ASSERT (retval == strlen (result)); + ASSERT (count == 4); + free (result); + } + + /* Test the support of the POSIX/XSI format strings with positions. */ + + { + char *result; + int retval = + my_asprintf (&result, "%2$d %1$d", 33, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "55 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + /* Test the support of the grouping flag. */ + + { + char *result; + int retval = + my_asprintf (&result, "%'d %d", 1234567, 99); + ASSERT (result != NULL); + ASSERT (result[strlen (result) - 1] == '9'); + ASSERT (retval == strlen (result)); + free (result); + } + + /* Test the support of the left-adjust flag. */ + + { + char *result; + int retval = + my_asprintf (&result, "a%*sc", -3, "b"); + ASSERT (result != NULL); + ASSERT (strcmp (result, "ab c") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { + char *result; + int retval = + my_asprintf (&result, "a%-*sc", 3, "b"); + ASSERT (result != NULL); + ASSERT (strcmp (result, "ab c") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { + char *result; + int retval = + my_asprintf (&result, "a%-*sc", -3, "b"); + ASSERT (result != NULL); + ASSERT (strcmp (result, "ab c") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + /* Test the support of large precision. */ + + { + char *result; + int retval = + my_asprintf (&result, "%.4000d %d", 1234567, 99); + size_t i; + ASSERT (result != NULL); + for (i = 0; i < 4000 - 7; i++) + ASSERT (result[i] == '0'); + ASSERT (strcmp (result + 4000 - 7, "1234567 99") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { + char *result; + int retval = + my_asprintf (&result, "%.*d %d", 4000, 1234567, 99); + size_t i; + ASSERT (result != NULL); + for (i = 0; i < 4000 - 7; i++) + ASSERT (result[i] == '0'); + ASSERT (strcmp (result + 4000 - 7, "1234567 99") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { + char *result; + int retval = + my_asprintf (&result, "%.4000d %d", -1234567, 99); + size_t i; + ASSERT (result != NULL); + ASSERT (result[0] == '-'); + for (i = 0; i < 4000 - 7; i++) + ASSERT (result[1 + i] == '0'); + ASSERT (strcmp (result + 1 + 4000 - 7, "1234567 99") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { + char *result; + int retval = + my_asprintf (&result, "%.4000u %d", 1234567, 99); + size_t i; + ASSERT (result != NULL); + for (i = 0; i < 4000 - 7; i++) + ASSERT (result[i] == '0'); + ASSERT (strcmp (result + 4000 - 7, "1234567 99") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { + char *result; + int retval = + my_asprintf (&result, "%.4000o %d", 1234567, 99); + size_t i; + ASSERT (result != NULL); + for (i = 0; i < 4000 - 7; i++) + ASSERT (result[i] == '0'); + ASSERT (strcmp (result + 4000 - 7, "4553207 99") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { + char *result; + int retval = + my_asprintf (&result, "%.4000x %d", 1234567, 99); + size_t i; + ASSERT (result != NULL); + for (i = 0; i < 4000 - 6; i++) + ASSERT (result[i] == '0'); + ASSERT (strcmp (result + 4000 - 6, "12d687 99") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { + char *result; + int retval = + my_asprintf (&result, "%#.4000x %d", 1234567, 99); + size_t i; + ASSERT (result != NULL); + ASSERT (result[0] == '0'); + ASSERT (result[1] == 'x'); + for (i = 0; i < 4000 - 6; i++) + ASSERT (result[2 + i] == '0'); + ASSERT (strcmp (result + 2 + 4000 - 6, "12d687 99") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { + char *result; + int retval = + my_asprintf (&result, "%.4000f %d", 1.0, 99); + size_t i; + ASSERT (result != NULL); + ASSERT (result[0] == '1'); + ASSERT (result[1] == '.'); + for (i = 0; i < 4000; i++) + ASSERT (result[2 + i] == '0'); + ASSERT (strcmp (result + 2 + 4000, " 99") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { + char *result; + int retval = + my_asprintf (&result, "%.511f %d", 1.0, 99); + size_t i; + ASSERT (result != NULL); + ASSERT (result[0] == '1'); + ASSERT (result[1] == '.'); + for (i = 0; i < 511; i++) + ASSERT (result[2 + i] == '0'); + ASSERT (strcmp (result + 2 + 511, " 99") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + { + char input[5000]; + char *result; + int retval; + size_t i; + + for (i = 0; i < sizeof (input) - 1; i++) + input[i] = 'a' + ((1000000 / (i + 1)) % 26); + input[i] = '\0'; + retval = my_asprintf (&result, "%.4000s %d", input, 99); + ASSERT (result != NULL); + ASSERT (memcmp (result, input, 4000) == 0); + ASSERT (strcmp (result + 4000, " 99") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + + /* Test the support of the %s format directive. */ + + /* To verify that these tests succeed, it is necessary to run them under + a tool that checks against invalid memory accesses, such as ElectricFence + or "valgrind --tool=memcheck". */ + { + size_t i; + + for (i = 1; i <= 8; i++) + { + char *block; + char *result; + int retval; + + block = (char *) malloc (i); + memcpy (block, "abcdefgh", i); + retval = my_asprintf (&result, "%.*s", (int) i, block); + ASSERT (result != NULL); + ASSERT (memcmp (result, block, i) == 0); + ASSERT (result[i] == '\0'); + ASSERT (retval == strlen (result)); + free (result); + free (block); + } + } +#if HAVE_WCHAR_T + { + size_t i; + + for (i = 1; i <= 8; i++) + { + wchar_t *block; + size_t j; + char *result; + int retval; + + block = (wchar_t *) malloc (i * sizeof (wchar_t)); + for (j = 0; j < i; j++) + block[j] = "abcdefgh"[j]; + retval = my_asprintf (&result, "%.*ls", (int) i, block); + ASSERT (result != NULL); + ASSERT (memcmp (result, "abcdefgh", i) == 0); + ASSERT (result[i] == '\0'); + ASSERT (retval == strlen (result)); + free (result); + free (block); + } + } +#endif +} + +static int +my_asprintf (char **result, const char *format, ...) +{ + va_list args; + int ret; + + va_start (args, format); + ret = vasprintf (result, format, args); + va_end (args); + return ret; +} + +static void +test_vasprintf () +{ + test_function (my_asprintf); +} + +static void +test_asprintf () +{ + test_function (asprintf); +} + +int +main (int argc, char *argv[]) +{ + test_vasprintf (); + test_asprintf (); + return 0; +} diff --git a/gnulib-tests/test-vasprintf.c b/gnulib-tests/test-vasprintf.c new file mode 100644 index 0000000..021cfac --- /dev/null +++ b/gnulib-tests/test-vasprintf.c @@ -0,0 +1,103 @@ +/* Test of vasprintf() and asprintf() functions. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (asprintf, int, (char **, char const *, ...)); +SIGNATURE_CHECK (vasprintf, int, (char **, char const *, va_list)); + +#include <stdarg.h> +#include <stdlib.h> +#include <string.h> + +#include "macros.h" + +static int +my_asprintf (char **result, const char *format, ...) +{ + va_list args; + int ret; + + va_start (args, format); + ret = vasprintf (result, format, args); + va_end (args); + return ret; +} + +static void +test_vasprintf () +{ + int repeat; + + for (repeat = 0; repeat <= 8; repeat++) + { + char *result; + int retval = my_asprintf (&result, "%d", 12345); + ASSERT (retval == 5); + ASSERT (result != NULL); + ASSERT (strcmp (result, "12345") == 0); + free (result); + } + + for (repeat = 0; repeat <= 8; repeat++) + { + char *result; + int retval = my_asprintf (&result, "%08lx", 12345UL); + ASSERT (retval == 8); + ASSERT (result != NULL); + ASSERT (strcmp (result, "00003039") == 0); + free (result); + } +} + +static void +test_asprintf () +{ + int repeat; + + for (repeat = 0; repeat <= 8; repeat++) + { + char *result; + int retval = asprintf (&result, "%d", 12345); + ASSERT (retval == 5); + ASSERT (result != NULL); + ASSERT (strcmp (result, "12345") == 0); + free (result); + } + + for (repeat = 0; repeat <= 8; repeat++) + { + char *result; + int retval = asprintf (&result, "%08lx", 12345UL); + ASSERT (retval == 8); + ASSERT (result != NULL); + ASSERT (strcmp (result, "00003039") == 0); + free (result); + } +} + +int +main (int argc, char *argv[]) +{ + test_vasprintf (); + test_asprintf (); + return 0; +} diff --git a/gnulib-tests/test-vc-list-files-cvs.sh b/gnulib-tests/test-vc-list-files-cvs.sh new file mode 100755 index 0000000..964d1c4 --- /dev/null +++ b/gnulib-tests/test-vc-list-files-cvs.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# Unit tests for vc-list-files +# Copyright (C) 2008-2020 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# 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 <https://www.gnu.org/licenses/>. */ + +: ${srcdir=.} +. "$srcdir/init.sh"; path_prepend_ . + +tmpdir=vc-cvs +repo=`pwd`/$tmpdir/repo + +fail=0 +for i in with-cvsu without; do + # On the first iteration, test using cvsu, if it's in your path. + # On the second iteration, ensure that cvsu fails, so we'll + # exercise the awk-using code. + if test $i = without; then + printf '%s\n' '#!/bin/sh' 'exit 1' > cvsu + chmod a+x cvsu + PATH=`pwd`:$PATH + export PATH + fi + ok=0 + mkdir $tmpdir && cd $tmpdir && + # without cvs, skip the test + { ( cvs -Q -d "$repo" init ) > /dev/null 2>&1 \ + || skip_ "cvs not found in PATH"; } && + mkdir w && cd w && + mkdir d && + touch d/a b c && + cvs -Q -d "$repo" import -m imp m M M0 && + cvs -Q -d "$repo" co m && cd m && + printf '%s\n' b c d/a > expected && + $BOURNE_SHELL "$abs_aux_dir/vc-list-files" | sort > actual && + compare expected actual && + ok=1 + test $ok = 0 && fail=1 +done + +Exit $fail diff --git a/gnulib-tests/test-vc-list-files-git.sh b/gnulib-tests/test-vc-list-files-git.sh new file mode 100755 index 0000000..ef537f8 --- /dev/null +++ b/gnulib-tests/test-vc-list-files-git.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# Unit tests for vc-list-files +# Copyright (C) 2008-2020 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# 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 <https://www.gnu.org/licenses/>. */ + +: ${srcdir=.} +. "$srcdir/init.sh"; path_prepend_ . + +tmpdir=vc-git-$$ +GIT_DIR= GIT_WORK_TREE=; unset GIT_DIR GIT_WORK_TREE + +fail=1 +mkdir $tmpdir && cd $tmpdir && + # without git, skip the test + # The double use of 'exit' is needed for the reference to $? inside the trap. + { ( git init -q ) > /dev/null 2>&1 \ + || skip_ "git not found in PATH"; } && + mkdir d && + touch d/a b c && + git config user.email "you@example.com" && + git config user.name "Your Name" && + git add . > /dev/null && + git commit -q -a -m log && + printf '%s\n' b c d/a > expected && + $BOURNE_SHELL "$abs_aux_dir/vc-list-files" > actual && + compare expected actual && + fail=0 + +Exit $fail diff --git a/gnulib-tests/test-verify-try.c b/gnulib-tests/test-verify-try.c new file mode 100644 index 0000000..c44a065 --- /dev/null +++ b/gnulib-tests/test-verify-try.c @@ -0,0 +1,21 @@ +/* Test the "verify" module. + + Copyright (C) 2017-2020 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 <https://www.gnu.org/licenses/>. */ + +/* This is a separate source file, so that the execution of test-verify.sh + does not interfere with the building of the 'test-verify' program. */ + +#include "test-verify.c" diff --git a/gnulib-tests/test-verify.c b/gnulib-tests/test-verify.c new file mode 100644 index 0000000..498dd2f --- /dev/null +++ b/gnulib-tests/test-verify.c @@ -0,0 +1,69 @@ +/* Test the "verify" module. + + Copyright (C) 2005, 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible. */ + +#include <config.h> + +#include "verify.h" + +#ifndef EXP_FAIL +# define EXP_FAIL 0 +#endif + +int x; +enum { a, b, c }; + +#if EXP_FAIL == 1 +verify (x >= 0); /* should give ERROR: non-constant expression */ +#endif +verify (c == 2); /* should be ok */ +#if EXP_FAIL == 2 +verify (1 + 1 == 3); /* should give ERROR */ +#endif +verify (1 == 1); verify (1 == 1); /* should be ok */ + +enum +{ + item = verify_expr (1 == 1, 10 * 0 + 17) /* should be ok */ +}; + +static int +function (int n) +{ +#if EXP_FAIL == 3 + verify (n >= 0); /* should give ERROR: non-constant expression */ +#endif + verify (c == 2); /* should be ok */ +#if EXP_FAIL == 4 + verify (1 + 1 == 3); /* should give ERROR */ +#endif + verify (1 == 1); verify (1 == 1); /* should be ok */ + + if (n) + return ((void) verify_expr (1 == 1, 1), verify_expr (1 == 1, 8)); /* should be ok */ +#if EXP_FAIL == 5 + return verify_expr (1 == 2, 5); /* should give ERROR */ +#endif + return 0; +} + +int +main (void) +{ + return !(function (0) == 0 && function (1) == 8); +} diff --git a/gnulib-tests/test-verify.sh b/gnulib-tests/test-verify.sh new file mode 100755 index 0000000..1e75d55 --- /dev/null +++ b/gnulib-tests/test-verify.sh @@ -0,0 +1,25 @@ +#!/bin/sh +. "${srcdir=.}/init.sh" + +# We are not interested in triggering bugs in the compilers and tools +# (such as gcc 4.3.1 on openSUSE 11.0). +unset MALLOC_PERTURB_ + +# Rather than figure out how to invoke the compiler with the right +# include path ourselves, we let make do it: +(cd "$initial_cwd_" \ + && rm -f test-verify-try.o \ + && $MAKE test-verify-try.o >/dev/null 2>&1) \ + || skip_ "cannot compile error-free" + +# Now, prove that we encounter all expected compilation failures: +: >out +: >err +for i in 1 2 3 4 5; do + (cd "$initial_cwd_" + rm -f test-verify-try.o + $MAKE CFLAGS=-DEXP_FAIL=$i test-verify-try.o) >>out 2>>err \ + && { warn_ "compiler didn't detect verification failure $i"; fail=1; } +done + +Exit $fail diff --git a/gnulib-tests/test-version-etc.c b/gnulib-tests/test-version-etc.c new file mode 100644 index 0000000..5c66e85 --- /dev/null +++ b/gnulib-tests/test-version-etc.c @@ -0,0 +1,31 @@ +/* Test suite for version-etc. + Copyright (C) 2009-2020 Free Software Foundation, Inc. + This file is part of the GNUlib Library. + + 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include "version-etc.h" + + +#define AUTHORS "Sergey Poznyakoff", "Eric Blake" + +int +main (int argc _GL_UNUSED, char **argv) +{ + version_etc (stdout, "test-version-etc", "dummy", "0", AUTHORS, + (const char *) NULL); + return 0; +} diff --git a/gnulib-tests/test-version-etc.sh b/gnulib-tests/test-version-etc.sh new file mode 100755 index 0000000..6e9e6c4 --- /dev/null +++ b/gnulib-tests/test-version-etc.sh @@ -0,0 +1,45 @@ +#! /bin/sh +# Test suite for version-etc. +# Copyright (C) 2009-2020 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# 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 <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/init.sh"; path_prepend_ . + +TMP=ve-expected.tmp +LC_ALL=C +export LC_ALL +ERR=0 + +cat > $TMP <<EOT +test-version-etc (PROJECT) VERSION +COPYRIGHT Free Software Foundation, Inc. +License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. +This is free software: you are free to change and redistribute it. +There is NO WARRANTY, to the extent permitted by law. + +Written by Sergey Poznyakoff and Eric Blake. +EOT + +${CHECKER} test-version-etc${EXEEXT} --version | + sed '1s/test-version-etc (.*) .*/test-version-etc (PROJECT) VERSION/ + /^Packaged by/d + 2,3 s/Copyright (C) [0-9]\{4,4\}/COPYRIGHT/' | + tr -d '\015' | + compare $TMP - || ERR=1 + +rm $TMP + +exit $ERR diff --git a/gnulib-tests/test-vfprintf-posix.c b/gnulib-tests/test-vfprintf-posix.c new file mode 100644 index 0000000..1dd9480 --- /dev/null +++ b/gnulib-tests/test-vfprintf-posix.c @@ -0,0 +1,52 @@ +/* Test of POSIX compatible vfprintf() function. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (vfprintf, int, (FILE *, char const *, va_list)); + +#include <stdarg.h> +#include <stddef.h> +#include <stdint.h> +#include <string.h> + +#include "macros.h" + +#include "test-fprintf-posix.h" + +static int +my_fprintf (FILE *fp, const char *format, ...) +{ + va_list args; + int ret; + + va_start (args, format); + ret = vfprintf (fp, format, args); + va_end (args); + return ret; +} + +int +main (int argc, char *argv[]) +{ + test_function (my_fprintf); + return 0; +} diff --git a/gnulib-tests/test-vfprintf-posix.sh b/gnulib-tests/test-vfprintf-posix.sh new file mode 100755 index 0000000..d8ced96 --- /dev/null +++ b/gnulib-tests/test-vfprintf-posix.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +tmpfiles="" +trap 'rm -fr $tmpfiles' 1 2 3 15 + +tmpfiles="$tmpfiles t-vfprintf-posix.tmp t-vfprintf-posix.out" +${CHECKER} ./test-vfprintf-posix${EXEEXT} > t-vfprintf-posix.tmp || exit 1 +LC_ALL=C tr -d '\r' < t-vfprintf-posix.tmp > t-vfprintf-posix.out || exit 1 + +: ${DIFF=diff} +${DIFF} "${srcdir}/test-printf-posix.output" t-vfprintf-posix.out +result=$? + +rm -fr $tmpfiles + +exit $result diff --git a/gnulib-tests/test-vprintf-posix.c b/gnulib-tests/test-vprintf-posix.c new file mode 100644 index 0000000..6fa7ef8 --- /dev/null +++ b/gnulib-tests/test-vprintf-posix.c @@ -0,0 +1,52 @@ +/* Test of POSIX compatible vfprintf() function. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (vprintf, int, (char const *, va_list)); + +#include <stdarg.h> +#include <stddef.h> +#include <stdint.h> +#include <string.h> + +#include "macros.h" + +#include "test-printf-posix.h" + +static int +my_printf (const char *format, ...) +{ + va_list args; + int ret; + + va_start (args, format); + ret = vprintf (format, args); + va_end (args); + return ret; +} + +int +main (int argc, char *argv[]) +{ + test_function (my_printf); + return 0; +} diff --git a/gnulib-tests/test-vprintf-posix.sh b/gnulib-tests/test-vprintf-posix.sh new file mode 100755 index 0000000..911c980 --- /dev/null +++ b/gnulib-tests/test-vprintf-posix.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +tmpfiles="" +trap 'rm -fr $tmpfiles' 1 2 3 15 + +tmpfiles="$tmpfiles t-vprintf-posix.tmp t-vprintf-posix.out" +${CHECKER} ./test-vprintf-posix${EXEEXT} > t-vprintf-posix.tmp || exit 1 +LC_ALL=C tr -d '\r' < t-vprintf-posix.tmp > t-vprintf-posix.out || exit 1 + +: ${DIFF=diff} +${DIFF} "${srcdir}/test-printf-posix.output" t-vprintf-posix.out +result=$? + +rm -fr $tmpfiles + +exit $result diff --git a/gnulib-tests/test-wchar.c b/gnulib-tests/test-wchar.c new file mode 100644 index 0000000..7069b60 --- /dev/null +++ b/gnulib-tests/test-wchar.c @@ -0,0 +1,37 @@ +/* Test of <wchar.h> substitute. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#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 (void) +{ + return 0; +} diff --git a/gnulib-tests/test-wcrtomb-w32-1.sh b/gnulib-tests/test-wcrtomb-w32-1.sh new file mode 100755 index 0000000..b01c543 --- /dev/null +++ b/gnulib-tests/test-wcrtomb-w32-1.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP1252 locale. +${CHECKER} ./test-wcrtomb-w32${EXEEXT} French_France 1252 diff --git a/gnulib-tests/test-wcrtomb-w32-2.sh b/gnulib-tests/test-wcrtomb-w32-2.sh new file mode 100755 index 0000000..5481634 --- /dev/null +++ b/gnulib-tests/test-wcrtomb-w32-2.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP1256 locale. +${CHECKER} ./test-wcrtomb-w32${EXEEXT} "Arabic_Saudi Arabia" 1256 diff --git a/gnulib-tests/test-wcrtomb-w32-3.sh b/gnulib-tests/test-wcrtomb-w32-3.sh new file mode 100755 index 0000000..f35879d --- /dev/null +++ b/gnulib-tests/test-wcrtomb-w32-3.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP932 locale. +${CHECKER} ./test-wcrtomb-w32${EXEEXT} Japanese_Japan 932 diff --git a/gnulib-tests/test-wcrtomb-w32-4.sh b/gnulib-tests/test-wcrtomb-w32-4.sh new file mode 100755 index 0000000..8eec6cb --- /dev/null +++ b/gnulib-tests/test-wcrtomb-w32-4.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP950 locale. +${CHECKER} ./test-wcrtomb-w32${EXEEXT} Chinese_Taiwan 950 diff --git a/gnulib-tests/test-wcrtomb-w32-5.sh b/gnulib-tests/test-wcrtomb-w32-5.sh new file mode 100755 index 0000000..fd47d6f --- /dev/null +++ b/gnulib-tests/test-wcrtomb-w32-5.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP936 locale. +${CHECKER} ./test-wcrtomb-w32${EXEEXT} Chinese_China 936 diff --git a/gnulib-tests/test-wcrtomb-w32-6.sh b/gnulib-tests/test-wcrtomb-w32-6.sh new file mode 100755 index 0000000..802237d --- /dev/null +++ b/gnulib-tests/test-wcrtomb-w32-6.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a GB18030 locale. +${CHECKER} ./test-wcrtomb-w32${EXEEXT} Chinese_China 54936 diff --git a/gnulib-tests/test-wcrtomb-w32-7.sh b/gnulib-tests/test-wcrtomb-w32-7.sh new file mode 100755 index 0000000..fb04e58 --- /dev/null +++ b/gnulib-tests/test-wcrtomb-w32-7.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test some UTF-8 locales. +${CHECKER} ./test-wcrtomb-w32${EXEEXT} French_France Japanese_Japan Chinese_Taiwan Chinese_China 65001 diff --git a/gnulib-tests/test-wcrtomb-w32.c b/gnulib-tests/test-wcrtomb-w32.c new file mode 100644 index 0000000..0f02ed2 --- /dev/null +++ b/gnulib-tests/test-wcrtomb-w32.c @@ -0,0 +1,337 @@ +/* Test of conversion of wide character to multibyte character. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <wchar.h> + +#include <locale.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "localcharset.h" +#include "macros.h" + +#if defined _WIN32 && !defined __CYGWIN__ + +static int +test_one_locale (const char *name, int codepage) +{ + char buf[64]; + size_t ret; + +# if 1 + /* Portable code to set the locale. */ + { + char name_with_codepage[1024]; + + sprintf (name_with_codepage, "%s.%d", name, codepage); + + /* Set the locale. */ + if (setlocale (LC_ALL, name_with_codepage) == NULL) + return 77; + } +# else + /* Hacky way to set a locale.codepage combination that setlocale() refuses + to set. */ + { + /* Codepage of the current locale, set with setlocale(). + Not necessarily the same as GetACP(). */ + extern __declspec(dllimport) unsigned int __lc_codepage; + + /* Set the locale. */ + if (setlocale (LC_ALL, name) == NULL) + return 77; + + /* Clobber the codepage and MB_CUR_MAX, both set by setlocale(). */ + __lc_codepage = codepage; + switch (codepage) + { + case 1252: + case 1256: + MB_CUR_MAX = 1; + break; + case 932: + case 950: + case 936: + MB_CUR_MAX = 2; + break; + case 54936: + case 65001: + MB_CUR_MAX = 4; + break; + } + + /* Test whether the codepage is really available. */ + { + mbstate_t state; + wchar_t wc; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, " ", 1, &state) == (size_t)(-1)) + return 77; + } + } +# endif + + /* Test NUL character. */ + { + buf[0] = 'x'; + ret = wcrtomb (buf, 0, NULL); + ASSERT (ret == 1); + ASSERT (buf[0] == '\0'); + } + + /* Test single bytes. */ + { + int c; + + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + ret = wcrtomb (buf, btowc (c), NULL); + ASSERT (ret == 1); + ASSERT (buf[0] == (char) c); + break; + } + } + + /* Test special calling convention, passing a NULL pointer. */ + { + ret = wcrtomb (NULL, '\0', NULL); + ASSERT (ret == 1); + ret = wcrtomb (NULL, btowc ('x'), NULL); + ASSERT (ret == 1); + } + + switch (codepage) + { + case 1252: + /* Locale encoding is CP1252, an extension of ISO-8859-1. */ + { + /* Convert "B\374\337er": "Büßer" */ + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x00FC, NULL); + ASSERT (ret == 1); + ASSERT (memcmp (buf, "\374", 1) == 0); + ASSERT (buf[1] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x00DF, NULL); + ASSERT (ret == 1); + ASSERT (memcmp (buf, "\337", 1) == 0); + ASSERT (buf[1] == 'x'); + } + return 0; + + case 1256: + /* Locale encoding is CP1256, not the same as ISO-8859-6. */ + { + /* Convert "x\302\341\346y": "xآلوy" */ + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x0622, NULL); + ASSERT (ret == 1); + ASSERT (memcmp (buf, "\302", 1) == 0); + ASSERT (buf[1] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x0644, NULL); + ASSERT (ret == 1); + ASSERT (memcmp (buf, "\341", 1) == 0); + ASSERT (buf[1] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x0648, NULL); + ASSERT (ret == 1); + ASSERT (memcmp (buf, "\346", 1) == 0); + ASSERT (buf[1] == 'x'); + } + return 0; + + case 932: + /* Locale encoding is CP932, similar to Shift_JIS. */ + { + /* Convert "<\223\372\226\173\214\352>": "<日本語>" */ + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x65E5, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\223\372", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x672C, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\226\173", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x8A9E, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\214\352", 2) == 0); + ASSERT (buf[2] == 'x'); + } + return 0; + + case 950: + /* Locale encoding is CP950, similar to Big5. */ + { + /* Convert "<\244\351\245\273\273\171>": "<日本語>" */ + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x65E5, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\244\351", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x672C, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\245\273", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x8A9E, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\273\171", 2) == 0); + ASSERT (buf[2] == 'x'); + } + return 0; + + case 936: + /* Locale encoding is CP936 = GBK, an extension of GB2312. */ + { + /* Convert "<\310\325\261\276\325\132>": "<日本語>" */ + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x65E5, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\310\325", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x672C, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\261\276", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x8A9E, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\325\132", 2) == 0); + ASSERT (buf[2] == 'x'); + } + return 0; + + case 54936: + /* Locale encoding is CP54936 = GB18030. */ + if (strcmp (locale_charset (), "GB18030") != 0) + return 77; + { + /* Convert "B\250\271\201\060\211\070er": "Büßer" */ + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x00FC, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\250\271", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x00DF, NULL); + ASSERT (ret == 4); + ASSERT (memcmp (buf, "\201\060\211\070", 4) == 0); + ASSERT (buf[4] == 'x'); + } + return 0; + + case 65001: + /* Locale encoding is CP65001 = UTF-8. */ + if (strcmp (locale_charset (), "UTF-8") != 0) + return 77; + { + /* Convert "B\303\274\303\237er": "Büßer" */ + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x00FC, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\303\274", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x00DF, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\303\237", 2) == 0); + ASSERT (buf[2] == 'x'); + } + return 0; + + default: + return 1; + } +} + +int +main (int argc, char *argv[]) +{ + int codepage = atoi (argv[argc - 1]); + int result; + int i; + + result = 77; + for (i = 1; i < argc - 1; i++) + { + int ret = test_one_locale (argv[i], codepage); + + if (ret != 77) + result = ret; + } + + if (result == 77) + { + fprintf (stderr, "Skipping test: found no locale with codepage %d\n", + codepage); + } + return result; +} + +#else + +int +main (int argc, char *argv[]) +{ + fputs ("Skipping test: not a native Windows system\n", stderr); + return 77; +} + +#endif diff --git a/gnulib-tests/test-wcrtomb.c b/gnulib-tests/test-wcrtomb.c new file mode 100644 index 0000000..3924d59 --- /dev/null +++ b/gnulib-tests/test-wcrtomb.c @@ -0,0 +1,166 @@ +/* Test of conversion of wide character to multibyte character. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2008. */ + +#include <config.h> + +#include <wchar.h> + +#include "signature.h" +SIGNATURE_CHECK (wcrtomb, size_t, (char *, wchar_t, mbstate_t *)); + +#include <locale.h> +#include <stdlib.h> +#include <string.h> + +#include "macros.h" + +/* Check the multibyte character s[0..n-1]. */ +static void +check_character (const char *s, size_t n) +{ + wchar_t wc; + char buf[64]; + int iret; + size_t ret; + + wc = (wchar_t) 0xBADFACE; + iret = mbtowc (&wc, s, n); + ASSERT (iret == n); + + ret = wcrtomb (buf, wc, NULL); + ASSERT (ret == n); + ASSERT (memcmp (buf, s, n) == 0); + + /* Test special calling convention, passing a NULL pointer. */ + ret = wcrtomb (NULL, wc, NULL); + ASSERT (ret == 1); +} + +int +main (int argc, char *argv[]) +{ + char buf[64]; + size_t ret; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test NUL character. */ + { + buf[0] = 'x'; + ret = wcrtomb (buf, 0, NULL); + ASSERT (ret == 1); + ASSERT (buf[0] == '\0'); + } + + /* Test single bytes. */ + { + int c; + + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + ret = wcrtomb (buf, btowc (c), NULL); + ASSERT (ret == 1); + ASSERT (buf[0] == (char) c); + break; + } + } + + /* Test special calling convention, passing a NULL pointer. */ + { + ret = wcrtomb (NULL, '\0', NULL); + ASSERT (ret == 1); + ret = wcrtomb (NULL, btowc ('x'), NULL); + ASSERT (ret == 1); + } + + if (argc > 1) + switch (argv[1][0]) + { + case '1': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + const char input[] = "B\374\337er"; /* "Büßer" */ + + check_character (input + 1, 1); + check_character (input + 2, 1); + } + return 0; + + case '2': + /* Locale encoding is UTF-8. */ + { + const char input[] = "B\303\274\303\237er"; /* "Büßer" */ + + check_character (input + 1, 2); + check_character (input + 3, 2); + } + return 0; + + case '3': + /* Locale encoding is EUC-JP. */ + { + const char input[] = "<\306\374\313\334\270\354>"; /* "<日本語>" */ + + check_character (input + 1, 2); + check_character (input + 3, 2); + check_character (input + 5, 2); + } + return 0; + + case '4': + /* Locale encoding is GB18030. */ + { + const char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */ + + check_character (input + 1, 2); + check_character (input + 3, 4); + } + return 0; + + case '5': + /* C locale; tested above. */ + return 0; + } + + return 1; +} diff --git a/gnulib-tests/test-wcrtomb.sh b/gnulib-tests/test-wcrtomb.sh new file mode 100755 index 0000000..1a31b6e --- /dev/null +++ b/gnulib-tests/test-wcrtomb.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: ${LOCALE_FR=fr_FR} +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR \ + ${CHECKER} ./test-wcrtomb${EXEEXT} 1 \ + || exit 1 +fi + +# Test whether a specific UTF-8 locale is installed. +: ${LOCALE_FR_UTF8=fr_FR.UTF-8} +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 \ + ${CHECKER} ./test-wcrtomb${EXEEXT} 2 \ + || exit 1 +fi + +# Test whether a specific EUC-JP locale is installed. +: ${LOCALE_JA=ja_JP} +if test $LOCALE_JA != none; then + LC_ALL=$LOCALE_JA \ + ${CHECKER} ./test-wcrtomb${EXEEXT} 3 \ + || exit 1 +fi + +# Test whether a specific GB18030 locale is installed. +: ${LOCALE_ZH_CN=zh_CN.GB18030} +if test $LOCALE_ZH_CN != none; then + LC_ALL=$LOCALE_ZH_CN \ + ${CHECKER} ./test-wcrtomb${EXEEXT} 4 \ + || exit 1 +fi + +# Test in the POSIX locale. +LC_ALL=C ${CHECKER} ./test-wcrtomb${EXEEXT} 5 || exit 1 +LC_ALL=POSIX ${CHECKER} ./test-wcrtomb${EXEEXT} 5 || exit 1 + +exit 0 diff --git a/gnulib-tests/test-wctype-h.c b/gnulib-tests/test-wctype-h.c new file mode 100644 index 0000000..e1c4e23 --- /dev/null +++ b/gnulib-tests/test-wctype-h.c @@ -0,0 +1,74 @@ +/* Test of <wctype.h> substitute. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <wctype.h> + +#include "macros.h" + +/* Check that the type wint_t is defined. */ +wint_t a = 'x'; +/* Check that WEOF is defined. */ +wint_t e = WEOF; + +/* Check that the type wctype_t is defined. */ +wctype_t p; + +/* Check that the type wctrans_t is defined. */ +wctrans_t q; + +int +main (void) +{ + /* Check that the isw* functions exist as functions or as macros. */ + (void) iswalnum (0); + (void) iswalpha (0); + (void) iswcntrl (0); + (void) iswdigit (0); + (void) iswgraph (0); + (void) iswlower (0); + (void) iswprint (0); + (void) iswpunct (0); + (void) iswspace (0); + (void) iswupper (0); + (void) iswxdigit (0); + + /* Check that the isw* functions map WEOF to 0. */ + ASSERT (!iswalnum (e)); + ASSERT (!iswalpha (e)); + ASSERT (!iswcntrl (e)); + ASSERT (!iswdigit (e)); + ASSERT (!iswgraph (e)); + ASSERT (!iswlower (e)); + ASSERT (!iswprint (e)); + ASSERT (!iswpunct (e)); + ASSERT (!iswspace (e)); + ASSERT (!iswupper (e)); + ASSERT (!iswxdigit (e)); + + /* Check that the tow* functions exist as functions or as macros. */ + (void) towlower (0); + (void) towupper (0); + + /* Check that the tow* functions map WEOF to WEOF. */ + ASSERT (towlower (e) == e); + ASSERT (towupper (e) == e); + + return 0; +} diff --git a/gnulib-tests/test-wcwidth.c b/gnulib-tests/test-wcwidth.c new file mode 100644 index 0000000..7aaf820 --- /dev/null +++ b/gnulib-tests/test-wcwidth.c @@ -0,0 +1,106 @@ +/* Test of wcwidth() function. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <wchar.h> + +#include "signature.h" +SIGNATURE_CHECK (wcwidth, int, (wchar_t)); + +#include <locale.h> +#include <string.h> + +#include "c-ctype.h" +#include "localcharset.h" +#include "macros.h" + +int +main () +{ + wchar_t wc; + +#if !GNULIB_WCHAR_SINGLE +# ifdef C_CTYPE_ASCII + /* Test width of ASCII characters. */ + for (wc = 0x20; wc < 0x7F; wc++) + ASSERT (wcwidth (wc) == 1); +# endif +#endif + + /* Switch to an UTF-8 locale. */ + if (setlocale (LC_ALL, "fr_FR.UTF-8") != NULL + /* Check whether it's really an UTF-8 locale. + On OpenBSD 4.0, the setlocale call succeeds only for the LC_CTYPE + category and therefore returns "C/fr_FR.UTF-8/C/C/C/C", but the + LC_CTYPE category is effectively set to an ASCII LC_CTYPE category; + in particular, locale_charset() returns "ASCII". */ + && strcmp (locale_charset (), "UTF-8") == 0) + { + /* Test width of ASCII characters. */ + for (wc = 0x20; wc < 0x7F; wc++) + ASSERT (wcwidth (wc) == 1); + + /* Test width of some non-spacing characters. */ + ASSERT (wcwidth (0x0301) == 0); + ASSERT (wcwidth (0x05B0) == 0); + + /* Test width of some format control characters. */ + ASSERT (wcwidth (0x200E) <= 0); + ASSERT (wcwidth (0x2060) <= 0); +#if 0 /* wchar_t may be only 16 bits. */ + ASSERT (wcwidth (0xE0001) <= 0); + ASSERT (wcwidth (0xE0044) <= 0); +#endif + + /* Test width of some zero width characters. */ + /* While it is desirable that U+200B, U+200C, U+200D have width 0, + because this makes wcswidth work better on strings that contain these + characters, it is acceptable if an implementation treats these + characters like control characters. */ + ASSERT (wcwidth (0x200B) <= 0); + ASSERT (wcwidth (0xFEFF) <= 0); + + /* Test width of some math symbols. + U+2202 is marked as having ambiguous width (A) in EastAsianWidth.txt + (see <https://www.unicode.org/Public/12.0.0/ucd/EastAsianWidth.txt>). + The Unicode Standard Annex 11 + <https://www.unicode.org/reports/tr11/tr11-36.html> + says + "Ambiguous characters behave like wide or narrow characters + depending on the context (language tag, script identification, + associated font, source of data, or explicit markup; all can + provide the context). If the context cannot be established + reliably, they should be treated as narrow characters by default." + For wcwidth(), the only available context information is the locale. + "fr_FR.UTF-8" is a Western locale, not an East Asian locale, therefore + U+2202 should be treated like a narrow character. */ + ASSERT (wcwidth (0x2202) == 1); + + /* Test width of some CJK characters. */ + ASSERT (wcwidth (0x3000) == 2); + ASSERT (wcwidth (0xB250) == 2); + ASSERT (wcwidth (0xFF1A) == 2); +#if 0 /* wchar_t may be only 16 bits. */ + ASSERT (wcwidth (0x20369) == 2); + ASSERT (wcwidth (0x2F876) == 2); +#endif + } + + return 0; +} diff --git a/gnulib-tests/test-write.c b/gnulib-tests/test-write.c new file mode 100644 index 0000000..1bff5ed --- /dev/null +++ b/gnulib-tests/test-write.c @@ -0,0 +1,79 @@ +/* Test the write() function. + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (write, ssize_t, (int, const void *, size_t)); + +#include <errno.h> +#include <fcntl.h> +#include <string.h> + +#include "macros.h" + +int +main (void) +{ + const char *filename = "test-write.tmp"; + int fd; + + /* Create a file with a simple contents. */ + fd = open (filename, O_CREAT | O_WRONLY, 0600); + ASSERT (fd >= 0); + ASSERT (write (fd, "Hello World", 11) == 11); + ASSERT (close (fd) == 0); + + /* Write into the middle of the file. */ + fd = open (filename, O_WRONLY); + ASSERT (fd >= 0); + ASSERT (lseek (fd, 6, SEEK_SET) == 6); + ASSERT (write (fd, "fascination", 11) == 11); + + /* Verify the contents of the file. */ + { + char buf[64]; + int rfd = open (filename, O_RDONLY); + ASSERT (rfd >= 0); + ASSERT (read (rfd, buf, sizeof (buf)) == 17); + ASSERT (close (rfd) == 0); + ASSERT (memcmp (buf, "Hello fascination", 17) == 0); + } + + ASSERT (close (fd) == 0); + + /* Test behaviour for invalid file descriptors. */ + { + char byte = 'x'; + errno = 0; + ASSERT (write (-1, &byte, 1) == -1); + ASSERT (errno == EBADF); + } + { + char byte = 'x'; + close (99); + errno = 0; + ASSERT (write (99, &byte, 1) == -1); + ASSERT (errno == EBADF); + } + + /* Clean up. */ + unlink (filename); + + return 0; +} diff --git a/gnulib-tests/test-xalloc-die.c b/gnulib-tests/test-xalloc-die.c new file mode 100644 index 0000000..7f0069e --- /dev/null +++ b/gnulib-tests/test-xalloc-die.c @@ -0,0 +1,28 @@ +/* Test of xalloc_die() function. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Simon Josefsson <simon@josefsson.org>, 2009. */ + +#include <config.h> + +#include "xalloc.h" + +int +main (int argc _GL_UNUSED, char **argv) +{ + xalloc_die (); + return 0; +} diff --git a/gnulib-tests/test-xalloc-die.sh b/gnulib-tests/test-xalloc-die.sh new file mode 100755 index 0000000..033084b --- /dev/null +++ b/gnulib-tests/test-xalloc-die.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# Test suite for xalloc_die. +# Copyright (C) 2009-2020 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# 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 <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/init.sh"; path_prepend_ . + +${CHECKER} test-xalloc-die${EXEEXT} > out 2> err +case $? in + 1) ;; + *) Exit 1;; +esac + +tr -d '\015' < err \ + | sed 's,.*test-xalloc-die[.ex]*:,test-xalloc-die:,' > err2 || Exit 1 + +compare - err2 <<\EOF || Exit 1 +test-xalloc-die: memory exhausted +EOF + +test -s out && Exit 1 + +Exit $fail diff --git a/gnulib-tests/test-xfprintf-posix.c b/gnulib-tests/test-xfprintf-posix.c new file mode 100644 index 0000000..45159b9 --- /dev/null +++ b/gnulib-tests/test-xfprintf-posix.c @@ -0,0 +1,37 @@ +/* Test of error-checking xfprintf() function with POSIX compatible formatting. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include "xprintf.h" + +#include <stdarg.h> +#include <stddef.h> +#include <stdint.h> +#include <string.h> + +#include "macros.h" + +#include "test-fprintf-posix.h" + +int +main (int argc _GL_UNUSED, char *argv[]) +{ + test_function (xfprintf); + return 0; +} diff --git a/gnulib-tests/test-xprintf-posix.c b/gnulib-tests/test-xprintf-posix.c new file mode 100644 index 0000000..e34d75a --- /dev/null +++ b/gnulib-tests/test-xprintf-posix.c @@ -0,0 +1,36 @@ +/* Test of error-checking xprintf() function with POSIX compatible formatting. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include "xprintf.h" + +#include <stddef.h> +#include <stdint.h> +#include <string.h> + +#include "macros.h" + +#include "test-printf-posix.h" + +int +main (int argc _GL_UNUSED, char *argv[]) +{ + test_function (xprintf); + return 0; +} diff --git a/gnulib-tests/test-xprintf-posix.sh b/gnulib-tests/test-xprintf-posix.sh new file mode 100755 index 0000000..2a67197 --- /dev/null +++ b/gnulib-tests/test-xprintf-posix.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +tmpfiles="" +trap 'rm -fr $tmpfiles' 1 2 3 15 + +tmpfiles="$tmpfiles t-xprintf-posix.tmp t-xprintf-posix.out" +${CHECKER} ./test-xprintf-posix${EXEEXT} > t-xprintf-posix.tmp || exit 1 +LC_ALL=C tr -d '\r' < t-xprintf-posix.tmp > t-xprintf-posix.out || exit 1 + +: ${DIFF=diff} +${DIFF} "${srcdir}/test-printf-posix.output" t-xprintf-posix.out +test $? = 0 || { rm -fr $tmpfiles; exit 1; } + +tmpfiles="$tmpfiles t-xfprintf-posix.tmp t-xfprintf-posix.out" +${CHECKER} ./test-xfprintf-posix${EXEEXT} > t-xfprintf-posix.tmp || exit 1 +LC_ALL=C tr -d '\r' < t-xfprintf-posix.tmp > t-xfprintf-posix.out || exit 1 + +: ${DIFF=diff} +${DIFF} "${srcdir}/test-printf-posix.output" t-xfprintf-posix.out +test $? = 0 || { rm -fr $tmpfiles; exit 1; } + +rm -fr $tmpfiles + +exit 0 diff --git a/gnulib-tests/test-xstrtoimax.c b/gnulib-tests/test-xstrtoimax.c new file mode 100644 index 0000000..cc2f6ae --- /dev/null +++ b/gnulib-tests/test-xstrtoimax.c @@ -0,0 +1,4 @@ +#define __xstrtol xstrtoimax +#define __strtol_t intmax_t +#define __spec PRIdMAX +#include "test-xstrtol.c" diff --git a/gnulib-tests/test-xstrtoimax.sh b/gnulib-tests/test-xstrtoimax.sh new file mode 100755 index 0000000..6a48e67 --- /dev/null +++ b/gnulib-tests/test-xstrtoimax.sh @@ -0,0 +1,46 @@ +#!/bin/sh +: ${srcdir=.} +. "$srcdir/init.sh"; path_prepend_ . + +too_big=99999999999999999999999999999999999999999999999999999999999999999999 +result=0 + +# test xstrtoimax +${CHECKER} test-xstrtoimax 1 >> out 2>&1 || result=1 +${CHECKER} test-xstrtoimax -1 >> out 2>&1 || result=1 +${CHECKER} test-xstrtoimax 1k >> out 2>&1 || result=1 +${CHECKER} test-xstrtoimax ${too_big}h >> out 2>&1 && result=1 +${CHECKER} test-xstrtoimax $too_big >> out 2>&1 && result=1 +${CHECKER} test-xstrtoimax x >> out 2>&1 && result=1 +${CHECKER} test-xstrtoimax 9x >> out 2>&1 && result=1 +${CHECKER} test-xstrtoimax 010 >> out 2>&1 || result=1 +${CHECKER} test-xstrtoimax MiB >> out 2>&1 || result=1 + +# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr +# does not understand '\r'. +if echo solaris | tr -d '\r' | grep solais > /dev/null; then + cr='\015' +else + cr='\r' +fi + +# normalize output +LC_ALL=C tr -d "$cr" < out > k +mv k out + +# compare expected output +cat > exp <<EOF +1->1 () +-1->-1 () +1k->1024 () +invalid suffix in X argument '${too_big}h' +X argument '$too_big' too large +invalid X argument 'x' +invalid suffix in X argument '9x' +010->8 () +MiB->1048576 () +EOF + +compare exp out || result=1 + +Exit $result diff --git a/gnulib-tests/test-xstrtol.c b/gnulib-tests/test-xstrtol.c new file mode 100644 index 0000000..8d22098 --- /dev/null +++ b/gnulib-tests/test-xstrtol.c @@ -0,0 +1,62 @@ +/* Test of xstrtol module. + Copyright (C) 1995-1996, 1998-2001, 2003-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <inttypes.h> +#include <stdlib.h> +#include <stdio.h> + +#include "xstrtol-error.h" +#include "error.h" + +#ifndef __xstrtol +# define __xstrtol xstrtol +# define __strtol_t long int +# define __spec "ld" +#endif + +/* Don't show the program name in error messages. */ +static void +print_no_progname (void) +{ +} + +int +main (int argc, char **argv) +{ + strtol_error s_err; + int i; + + error_print_progname = print_no_progname; + + for (i = 1; i < argc; i++) + { + char *p; + __strtol_t val; + + s_err = __xstrtol (argv[i], &p, 0, &val, "bckMw0"); + if (s_err == LONGINT_OK) + { + printf ("%s->%" __spec " (%s)\n", argv[i], val, p); + } + else + { + xstrtol_fatal (s_err, -2, 'X', NULL, argv[i]); + } + } + exit (0); +} diff --git a/gnulib-tests/test-xstrtol.sh b/gnulib-tests/test-xstrtol.sh new file mode 100755 index 0000000..15dd911 --- /dev/null +++ b/gnulib-tests/test-xstrtol.sh @@ -0,0 +1,71 @@ +#!/bin/sh +: ${srcdir=.} +. "$srcdir/init.sh"; path_prepend_ . + +too_big=99999999999999999999999999999999999999999999999999999999999999999999 +result=0 + +# test xstrtol +${CHECKER} test-xstrtol 1 >> out 2>&1 || result=1 +${CHECKER} test-xstrtol -1 >> out 2>&1 || result=1 +${CHECKER} test-xstrtol 1k >> out 2>&1 || result=1 +${CHECKER} test-xstrtol ${too_big}h >> out 2>&1 && result=1 +${CHECKER} test-xstrtol $too_big >> out 2>&1 && result=1 +${CHECKER} test-xstrtol x >> out 2>&1 && result=1 +${CHECKER} test-xstrtol 9x >> out 2>&1 && result=1 +${CHECKER} test-xstrtol 010 >> out 2>&1 || result=1 +# suffix without integer is valid +${CHECKER} test-xstrtol MiB >> out 2>&1 || result=1 +${CHECKER} test-xstrtol 1bB >> out 2>&1 && result=1 + +# test xstrtoul +${CHECKER} test-xstrtoul 1 >> out 2>&1 || result=1 +${CHECKER} test-xstrtoul -1 >> out 2>&1 && result=1 +${CHECKER} test-xstrtoul 1k >> out 2>&1 || result=1 +${CHECKER} test-xstrtoul ${too_big}h >> out 2>&1 && result=1 +${CHECKER} test-xstrtoul $too_big >> out 2>&1 && result=1 +${CHECKER} test-xstrtoul x >> out 2>&1 && result=1 +${CHECKER} test-xstrtoul 9x >> out 2>&1 && result=1 +${CHECKER} test-xstrtoul 010 >> out 2>&1 || result=1 +${CHECKER} test-xstrtoul MiB >> out 2>&1 || result=1 +${CHECKER} test-xstrtoul 1bB >> out 2>&1 && result=1 + +# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr +# does not understand '\r'. +if echo solaris | tr -d '\r' | grep solais > /dev/null; then + cr='\015' +else + cr='\r' +fi + +# normalize output +LC_ALL=C tr -d "$cr" < out > k +mv k out + +# compare expected output +cat > expected <<EOF +1->1 () +-1->-1 () +1k->1024 () +invalid suffix in X argument '${too_big}h' +X argument '$too_big' too large +invalid X argument 'x' +invalid suffix in X argument '9x' +010->8 () +MiB->1048576 () +invalid suffix in X argument '1bB' +1->1 () +invalid X argument '-1' +1k->1024 () +invalid suffix in X argument '${too_big}h' +X argument '$too_big' too large +invalid X argument 'x' +invalid suffix in X argument '9x' +010->8 () +MiB->1048576 () +invalid suffix in X argument '1bB' +EOF + +compare expected out || result=1 + +Exit $result diff --git a/gnulib-tests/test-xstrtoul.c b/gnulib-tests/test-xstrtoul.c new file mode 100644 index 0000000..9dda9ee --- /dev/null +++ b/gnulib-tests/test-xstrtoul.c @@ -0,0 +1,4 @@ +#define __xstrtol xstrtoul +#define __strtol_t unsigned long int +#define __spec "lu" +#include "test-xstrtol.c" diff --git a/gnulib-tests/test-xstrtoumax.c b/gnulib-tests/test-xstrtoumax.c new file mode 100644 index 0000000..2e68c2e --- /dev/null +++ b/gnulib-tests/test-xstrtoumax.c @@ -0,0 +1,4 @@ +#define __xstrtol xstrtoumax +#define __strtol_t uintmax_t +#define __spec PRIuMAX +#include "test-xstrtol.c" diff --git a/gnulib-tests/test-xstrtoumax.sh b/gnulib-tests/test-xstrtoumax.sh new file mode 100755 index 0000000..3ec4cc6 --- /dev/null +++ b/gnulib-tests/test-xstrtoumax.sh @@ -0,0 +1,46 @@ +#!/bin/sh +: ${srcdir=.} +. "$srcdir/init.sh"; path_prepend_ . + +too_big=99999999999999999999999999999999999999999999999999999999999999999999 +result=0 + +# test xstrtoumax +${CHECKER} test-xstrtoumax 1 >> out 2>&1 || result=1 +${CHECKER} test-xstrtoumax -1 >> out 2>&1 && result=1 +${CHECKER} test-xstrtoumax 1k >> out 2>&1 || result=1 +${CHECKER} test-xstrtoumax ${too_big}h >> out 2>&1 && result=1 +${CHECKER} test-xstrtoumax $too_big >> out 2>&1 && result=1 +${CHECKER} test-xstrtoumax x >> out 2>&1 && result=1 +${CHECKER} test-xstrtoumax 9x >> out 2>&1 && result=1 +${CHECKER} test-xstrtoumax 010 >> out 2>&1 || result=1 +${CHECKER} test-xstrtoumax MiB >> out 2>&1 || result=1 + +# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr +# does not understand '\r'. +if echo solaris | tr -d '\r' | grep solais > /dev/null; then + cr='\015' +else + cr='\r' +fi + +# normalize output +LC_ALL=C tr -d "$cr" < out > k +mv k out + +# compare expected output +cat > exp <<EOF +1->1 () +invalid X argument '-1' +1k->1024 () +invalid suffix in X argument '${too_big}h' +X argument '$too_big' too large +invalid X argument 'x' +invalid suffix in X argument '9x' +010->8 () +MiB->1048576 () +EOF + +compare exp out || result=1 + +Exit $result diff --git a/gnulib-tests/test-xvasprintf.c b/gnulib-tests/test-xvasprintf.c new file mode 100644 index 0000000..39bd264 --- /dev/null +++ b/gnulib-tests/test-xvasprintf.c @@ -0,0 +1,135 @@ +/* Test of xvasprintf() and xasprintf() functions. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +/* Tell GCC not to warn about the specific edge cases tested here. */ +#if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__ +# pragma GCC diagnostic ignored "-Wformat-zero-length" +# pragma GCC diagnostic ignored "-Wformat-nonliteral" +# pragma GCC diagnostic ignored "-Wformat-security" +#endif + +#include <config.h> + +#include "xvasprintf.h" + +#include <stdarg.h> +#include <stdlib.h> +#include <string.h> + +#include "macros.h" + +static char * +my_xasprintf (const char *format, ...) +{ + va_list args; + char *ret; + + va_start (args, format); + ret = xvasprintf (format, args); + va_end (args); + return ret; +} + +static void +test_xvasprintf (void) +{ + int repeat; + char *result; + + for (repeat = 0; repeat <= 8; repeat++) + { + result = my_xasprintf ("%d", 12345); + ASSERT (result != NULL); + ASSERT (strcmp (result, "12345") == 0); + free (result); + } + + { + /* Silence gcc warning about zero-length format string. */ + const char *empty = ""; + result = my_xasprintf (empty); + ASSERT (result != NULL); + ASSERT (strcmp (result, "") == 0); + free (result); + } + + result = my_xasprintf ("%s", "foo"); + ASSERT (result != NULL); + ASSERT (strcmp (result, "foo") == 0); + free (result); + + result = my_xasprintf ("%s%s", "foo", "bar"); + ASSERT (result != NULL); + ASSERT (strcmp (result, "foobar") == 0); + free (result); + + result = my_xasprintf ("%s%sbaz", "foo", "bar"); + ASSERT (result != NULL); + ASSERT (strcmp (result, "foobarbaz") == 0); + free (result); +} + +static void +test_xasprintf (void) +{ + int repeat; + char *result; + + for (repeat = 0; repeat <= 8; repeat++) + { + result = xasprintf ("%d", 12345); + ASSERT (result != NULL); + ASSERT (strcmp (result, "12345") == 0); + free (result); + } + + { + /* Silence gcc warning about zero-length format string, + and about "format not a string literal and no format" + (whatever that means) . */ + const char *empty = ""; + result = xasprintf (empty, empty); + ASSERT (result != NULL); + ASSERT (strcmp (result, "") == 0); + free (result); + } + + result = xasprintf ("%s", "foo"); + ASSERT (result != NULL); + ASSERT (strcmp (result, "foo") == 0); + free (result); + + result = xasprintf ("%s%s", "foo", "bar"); + ASSERT (result != NULL); + ASSERT (strcmp (result, "foobar") == 0); + free (result); + + result = my_xasprintf ("%s%sbaz", "foo", "bar"); + ASSERT (result != NULL); + ASSERT (strcmp (result, "foobarbaz") == 0); + free (result); +} + +int +main (int argc _GL_UNUSED, char *argv[]) +{ + test_xvasprintf (); + test_xasprintf (); + + return 0; +} diff --git a/gnulib-tests/test-yesno.c b/gnulib-tests/test-yesno.c new file mode 100644 index 0000000..81d2cd3 --- /dev/null +++ b/gnulib-tests/test-yesno.c @@ -0,0 +1,62 @@ +/* Test of yesno module. + Copyright (C) 2007-2020 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, 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 <https://www.gnu.org/licenses/>. +*/ + +#include <config.h> + +/* Specification. */ +#include "yesno.h" + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "closein.h" +#include "binary-io.h" + +/* Test yesno. Without arguments, read one line. If first argument + is zero, close stdin before attempting to read one line. + Otherwise, read the number of lines specified by first + argument. */ +int +main (int argc, char **argv) +{ + int i = 1; + + /* yesno recommends that all clients use close_stdin in main. */ + atexit (close_stdin); + /* But on mingw, close_stdin leaves stdin's file descriptor at the expected + position (i.e. where this program left off reading) only if its mode has + been set to O_BINARY. If it has been set to O_TEXT, and the file + descriptor is seekable, and stdin is buffered, the MSVCRT runtime ends up + setting the file descriptor's position to the expected position _minus_ + the number of LFs not preceded by CR that were read between the expected + position and the last filled buffer end position. (I.e. the repositioning + from the end-of-buffer to the expected position does not work if the input + file contains end-of-line markers in Unix convention.) */ + set_binary_mode (0, O_BINARY); + + if (1 < argc) + i = atoi (argv[1]); + if (!i) + { + i = 1; + close (0); + } + while (i--) + puts (yesno () ? "Y" : "N"); + return 0; +} diff --git a/gnulib-tests/test-yesno.sh b/gnulib-tests/test-yesno.sh new file mode 100755 index 0000000..67caa77 --- /dev/null +++ b/gnulib-tests/test-yesno.sh @@ -0,0 +1,74 @@ +#!/bin/sh +: ${srcdir=.} +. "$srcdir/init.sh"; path_prepend_ . + +# For now, only test with C locale +LC_ALL=C +export LC_ALL + +# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr +# does not understand '\r'. +if echo solaris | tr -d '\r' | grep solais > /dev/null; then + cr='\015' +else + cr='\r' +fi + +# Test with seekable stdin; the follow-on process must see remaining data. +tr @ '\177' <<EOF > in.tmp +nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn - entire line consumed +y@n - backspace does not change result +y +does not match either yesexpr or noexpr +n +EOF + +cat <<EOF > xout.tmp +N +Y +Y +N +n +EOF + +fail=0 +(${CHECKER} test-yesno; ${CHECKER} test-yesno 3; cat) < in.tmp > out1.tmp || fail=1 +LC_ALL=C tr -d "$cr" < out1.tmp > out.tmp || fail=1 +cmp xout.tmp out.tmp || fail=1 + +(${CHECKER} test-yesno 3; ${CHECKER} test-yesno; cat) < in.tmp > out1.tmp || fail=1 +LC_ALL=C tr -d "$cr" < out1.tmp > out.tmp || fail=1 +cmp xout.tmp out.tmp || fail=1 + +# Test for behavior on pipe +cat <<EOF > xout.tmp +Y +N +EOF +echo yes | ${CHECKER} test-yesno 2 > out1.tmp || fail=1 +LC_ALL=C tr -d "$cr" < out1.tmp > out.tmp || fail=1 +cmp xout.tmp out.tmp || fail=1 + +# Test for behavior with no EOL at EOF +cat <<EOF > xout.tmp +Y +EOF +printf y | ${CHECKER} test-yesno 1 > out1.tmp || fail=1 +LC_ALL=C tr -d "$cr" < out1.tmp > out.tmp || fail=1 +cmp xout.tmp out.tmp || fail=1 + +# Test for behavior on EOF +cat <<EOF > xout.tmp +N +EOF +${CHECKER} test-yesno </dev/null > out1.tmp || fail=1 +LC_ALL=C tr -d "$cr" < out1.tmp > out.tmp || fail=1 +cmp xout.tmp out.tmp || fail=1 + +# Test for behavior when stdin is closed +${CHECKER} test-yesno 0 <&- > out1.tmp 2> err.tmp && fail=1 +LC_ALL=C tr -d "$cr" < out1.tmp > out.tmp || fail=1 +cmp xout.tmp out.tmp || fail=1 +test -s err.tmp || fail=1 + +Exit $fail diff --git a/gnulib-tests/timespec-add.c b/gnulib-tests/timespec-add.c new file mode 100644 index 0000000..259c2e9 --- /dev/null +++ b/gnulib-tests/timespec-add.c @@ -0,0 +1,65 @@ +/* Add two struct timespec values. + + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Paul Eggert. */ + +/* Return the sum of two timespec values A and B. On overflow, return + an extremal value. This assumes 0 <= tv_nsec < TIMESPEC_HZ. */ + +#include <config.h> +#include "timespec.h" + +#include "intprops.h" + +struct timespec +timespec_add (struct timespec a, struct timespec b) +{ + time_t rs = a.tv_sec; + time_t bs = b.tv_sec; + int ns = a.tv_nsec + b.tv_nsec; + int nsd = ns - TIMESPEC_HZ; + int rns = ns; + + if (0 <= nsd) + { + rns = nsd; + time_t bs1; + if (!INT_ADD_WRAPV (bs, 1, &bs1)) + bs = bs1; + else if (rs < 0) + rs++; + else + goto high_overflow; + } + + if (INT_ADD_WRAPV (rs, bs, &rs)) + { + if (bs < 0) + { + rs = TYPE_MINIMUM (time_t); + rns = 0; + } + else + { + high_overflow: + rs = TYPE_MAXIMUM (time_t); + rns = TIMESPEC_HZ - 1; + } + } + + return make_timespec (rs, rns); +} diff --git a/gnulib-tests/timespec-sub.c b/gnulib-tests/timespec-sub.c new file mode 100644 index 0000000..ee827a7 --- /dev/null +++ b/gnulib-tests/timespec-sub.c @@ -0,0 +1,65 @@ +/* Subtract two struct timespec values. + + Copyright (C) 2011-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Paul Eggert. */ + +/* Return the difference between two timespec values A and B. On + overflow, return an extremal value. This assumes 0 <= tv_nsec < + TIMESPEC_HZ. */ + +#include <config.h> +#include "timespec.h" + +#include "intprops.h" + +struct timespec +timespec_sub (struct timespec a, struct timespec b) +{ + time_t rs = a.tv_sec; + time_t bs = b.tv_sec; + int ns = a.tv_nsec - b.tv_nsec; + int rns = ns; + + if (ns < 0) + { + rns = ns + TIMESPEC_HZ; + time_t bs1; + if (!INT_ADD_WRAPV (bs, 1, &bs1)) + bs = bs1; + else if (- TYPE_SIGNED (time_t) < rs) + rs--; + else + goto low_overflow; + } + + if (INT_SUBTRACT_WRAPV (rs, bs, &rs)) + { + if (0 < bs) + { + low_overflow: + rs = TYPE_MINIMUM (time_t); + rns = 0; + } + else + { + rs = TYPE_MAXIMUM (time_t); + rns = TIMESPEC_HZ - 1; + } + } + + return make_timespec (rs, rns); +} diff --git a/gnulib-tests/tmpdir.c b/gnulib-tests/tmpdir.c new file mode 100644 index 0000000..74ae359 --- /dev/null +++ b/gnulib-tests/tmpdir.c @@ -0,0 +1,159 @@ +/* Copyright (C) 1999, 2001-2002, 2006, 2009-2020 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 + 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 <https://www.gnu.org/licenses/>. */ + +/* Extracted from sysdeps/posix/tempname.c. */ + +#include <config.h> + +/* Specification. */ +#include "tmpdir.h" + +#include <stdbool.h> +#include <stdlib.h> +#include <string.h> + +#include <errno.h> +#ifndef __set_errno +# define __set_errno(Val) errno = (Val) +#endif + +#include <stdio.h> +#ifndef P_tmpdir +# ifdef _P_tmpdir /* native Windows */ +# define P_tmpdir _P_tmpdir +# else +# define P_tmpdir "/tmp" +# endif +#endif + +#include <sys/stat.h> + +#if defined _WIN32 && ! defined __CYGWIN__ +# define WIN32_LEAN_AND_MEAN /* avoid including junk */ +# include <windows.h> +#endif + +#include "pathmax.h" + +#if _LIBC +# define struct_stat64 struct stat64 +#else +# define struct_stat64 struct stat +# define __libc_secure_getenv secure_getenv +# define __xstat64(version, path, buf) stat (path, buf) +#endif + +/* Pathname support. + ISSLASH(C) tests whether C is a directory separator character. + */ +#if defined _WIN32 || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ + /* Native Windows, Cygwin, OS/2, DOS */ +# define ISSLASH(C) ((C) == '/' || (C) == '\\') +#else + /* Unix */ +# define ISSLASH(C) ((C) == '/') +#endif + + +/* Return nonzero if DIR is an existent directory. */ +static bool +direxists (const char *dir) +{ + struct_stat64 buf; + return __xstat64 (_STAT_VER, dir, &buf) == 0 && S_ISDIR (buf.st_mode); +} + +/* Path search algorithm, for tmpnam, tmpfile, etc. If DIR is + non-null and exists, uses it; otherwise uses the first of $TMPDIR, + P_tmpdir, /tmp that exists. Copies into TMPL a template suitable + for use with mk[s]temp. Will fail (-1) if DIR is non-null and + doesn't exist, none of the searched dirs exists, or there's not + enough space in TMPL. */ +int +path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx, + bool try_tmpdir) +{ + const char *d; + size_t dlen, plen; + bool add_slash; + + if (!pfx || !pfx[0]) + { + pfx = "file"; + plen = 4; + } + else + { + plen = strlen (pfx); + if (plen > 5) + plen = 5; + } + + if (try_tmpdir) + { + d = __libc_secure_getenv ("TMPDIR"); + if (d != NULL && direxists (d)) + dir = d; + else if (dir != NULL && direxists (dir)) + /* nothing */ ; + else + dir = NULL; + } + if (dir == NULL) + { +#if defined _WIN32 && ! defined __CYGWIN__ + char dirbuf[PATH_MAX]; + DWORD retval; + + /* Find Windows temporary file directory. + We try this before P_tmpdir because Windows defines P_tmpdir to "\\" + and will therefore try to put all temporary files in the root + directory (unless $TMPDIR is set). */ + retval = GetTempPath (PATH_MAX, dirbuf); + if (retval > 0 && retval < PATH_MAX && direxists (dirbuf)) + dir = dirbuf; + else +#endif + if (direxists (P_tmpdir)) + dir = P_tmpdir; + else if (strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp")) + dir = "/tmp"; + else + { + __set_errno (ENOENT); + return -1; + } + } + + dlen = strlen (dir); +#ifdef __VMS + add_slash = 0; +#else + add_slash = dlen != 0 && !ISSLASH (dir[dlen - 1]); +#endif + + /* check we have room for "${dir}/${pfx}XXXXXX\0" */ + if (tmpl_len < dlen + add_slash + plen + 6 + 1) + { + __set_errno (EINVAL); + return -1; + } + + memcpy (tmpl, dir, dlen); + sprintf (tmpl + dlen, &"/%.*sXXXXXX"[!add_slash], (int) plen, pfx); + return 0; +} diff --git a/gnulib-tests/tmpdir.h b/gnulib-tests/tmpdir.h new file mode 100644 index 0000000..4d694a3 --- /dev/null +++ b/gnulib-tests/tmpdir.h @@ -0,0 +1,26 @@ +/* Determine a temporary directory. + Copyright (C) 2001-2002, 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +#include <stdbool.h> +#include <stddef.h> + +/* Path search algorithm, for tmpnam, tmpfile, etc. If DIR is + non-null and exists, uses it; otherwise uses the first of $TMPDIR, + P_tmpdir, /tmp that exists. Copies into TMPL a template suitable + for use with mk[s]temp. Will fail (-1) if DIR is non-null and + doesn't exist, none of the searched dirs exists, or there's not + enough space in TMPL. */ +extern int path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx, bool try_tmpdir); diff --git a/gnulib-tests/tmpfile.c b/gnulib-tests/tmpfile.c new file mode 100644 index 0000000..99d6752 --- /dev/null +++ b/gnulib-tests/tmpfile.c @@ -0,0 +1,179 @@ +/* Create a temporary file. + Copyright (C) 2007, 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Ben Pfaff. */ + +#include <config.h> + +/* Specification. */ +#include <stdio.h> + +#include <errno.h> +#include <stdbool.h> + +#if defined _WIN32 && ! defined __CYGWIN__ +/* A native Windows platforms. */ + +# include <fcntl.h> +# include <string.h> +# include <sys/stat.h> + +# include <io.h> + +# define WIN32_LEAN_AND_MEAN /* avoid including junk */ +# include <windows.h> + +#else + +# include <unistd.h> + +#endif + +#include "pathmax.h" +#include "tempname.h" +#include "tmpdir.h" + +/* PATH_MAX is guaranteed to be defined, because this replacement is only + used on native Windows and Android. */ + +#if defined _WIN32 && ! defined __CYGWIN__ +/* A native Windows platforms. */ + +/* On Windows, opening a file with _O_TEMPORARY has the effect of passing + the FILE_FLAG_DELETE_ON_CLOSE flag to CreateFile(), which has the effect + of deleting the file when it is closed - even when the program crashes. + But (according to the Cygwin sources) it works only on Windows NT or newer. + So we cache the info whether we are running on Windows NT or newer. */ + +static bool +supports_delete_on_close () +{ + static int known; /* 1 = yes, -1 = no, 0 = unknown */ + if (!known) + { + OSVERSIONINFO v; + + /* According to + <https://docs.microsoft.com/en-us/windows/desktop/api/sysinfoapi/nf-sysinfoapi-getversionexa> + this structure must be initialized as follows: */ + v.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); + + if (GetVersionEx (&v)) + known = (v.dwPlatformId == VER_PLATFORM_WIN32_NT ? 1 : -1); + else + known = -1; + } + return (known > 0); +} + +FILE * +tmpfile (void) +{ + char dir[PATH_MAX]; + DWORD retval; + + /* Find Windows temporary file directory. + We provide this as the directory argument to path_search because Windows + defines P_tmpdir to "\\" and will therefore try to put all temporary files + in the root directory (unless $TMPDIR is set). */ + retval = GetTempPath (PATH_MAX, dir); + if (retval > 0 && retval < PATH_MAX) + { + char xtemplate[PATH_MAX]; + + if (path_search (xtemplate, PATH_MAX, dir, NULL, true) >= 0) + { + size_t len = strlen (xtemplate); + int o_temporary = (supports_delete_on_close () ? _O_TEMPORARY : 0); + int fd; + + do + { + memcpy (&xtemplate[len - 6], "XXXXXX", 6); + if (gen_tempname (xtemplate, 0, 0, GT_NOCREATE) < 0) + { + fd = -1; + break; + } + + fd = _open (xtemplate, + _O_CREAT | _O_EXCL | o_temporary + | _O_RDWR | _O_BINARY, + _S_IREAD | _S_IWRITE); + } + while (fd < 0 && errno == EEXIST); + + if (fd >= 0) + { + FILE *fp = _fdopen (fd, "w+b"); + + if (fp != NULL) + return fp; + else + { + int saved_errno = errno; + _close (fd); + errno = saved_errno; + } + } + } + } + else + { + if (retval > 0) + errno = ENAMETOOLONG; + else + /* Ideally this should translate GetLastError () to an errno value. */ + errno = ENOENT; + } + + return NULL; +} + +#else + +FILE * +tmpfile (void) +{ + char buf[PATH_MAX]; + int fd; + FILE *fp; + + /* Try $TMPDIR first, not /tmp nor P_tmpdir, because we need this replacement + on Android, and /tmp does not exist on Android. */ + + if (path_search (buf, sizeof buf, NULL, "tmpf", true)) + return NULL; + + fd = gen_tempname (buf, 0, 0, GT_FILE); + if (fd < 0) + return NULL; + + /* Note that this relies on the Unix semantics that + a file is not really removed until it is closed. */ + (void) unlink (buf); + + if ((fp = fdopen (fd, "w+b")) == NULL) + { + int saved_errno = errno; + close (fd); + errno = saved_errno; + } + + return fp; +} + +#endif diff --git a/gnulib-tests/unistr/test-strncat.h b/gnulib-tests/unistr/test-strncat.h new file mode 100644 index 0000000..1b99ccf --- /dev/null +++ b/gnulib-tests/unistr/test-strncat.h @@ -0,0 +1,90 @@ +/* Test of uN_strncat() functions. + Copyright (C) 2010-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2010. */ + +static void +check_single (const UNIT *input, size_t length, size_t n) +{ + static const UNIT base[] = { 'C', 'h', 'a', 'n', 'g', 'i', 'n', 'g', 0 }; + size_t m; + + for (m = 0; m < SIZEOF (base); m++) + { + UNIT *dest; + UNIT *result; + size_t i; + + dest = (UNIT *) malloc ((1 + m + n + 2) * sizeof (UNIT)); + ASSERT (dest != NULL); + + dest[0] = MAGIC; + for (i = 0; i < m; i++) + dest[1 + i] = base[i]; + dest[1 + m] = 0; + for (i = 1; i < n + 2; i++) + dest[1 + m + i] = MAGIC; + + result = U_STRNCAT (dest + 1, input, n); + ASSERT (result == dest + 1); + + ASSERT (dest[0] == MAGIC); + for (i = 0; i < m; i++) + ASSERT (dest[1 + i] == base[i]); + for (i = 0; i < (n <= length ? n : length); i++) + ASSERT (dest[1 + m + i] == input[i]); + ASSERT (dest[1 + m + i] == 0); + ASSERT (dest[1 + m + i + 1] == MAGIC); + + free (dest); + } +} + +static void +check (const UNIT *input, size_t input_length) +{ + size_t length; + size_t n; + + ASSERT (input_length > 0); + ASSERT (input[input_length - 1] == 0); + length = input_length - 1; /* = U_STRLEN (input) */ + + for (n = 0; n <= 2 * length + 2; n++) + check_single (input, length, n); + + /* Check that U_STRNCAT (D, S, N) does not look at more than + MIN (U_STRLEN (S) + 1, N) units. */ + { + char *page_boundary = (char *) zerosize_ptr (); + + if (page_boundary != NULL) + { + for (n = 0; n <= 2 * length + 2; n++) + { + size_t n_to_copy = (n <= length ? n : length + 1); + UNIT *copy; + size_t i; + + copy = (UNIT *) page_boundary - n_to_copy; + for (i = 0; i < n_to_copy; i++) + copy[i] = input[i]; + + check_single (copy, length, n); + } + } + } +} diff --git a/gnulib-tests/unistr/test-u8-mbtoucr.c b/gnulib-tests/unistr/test-u8-mbtoucr.c new file mode 100644 index 0000000..9c8ead6 --- /dev/null +++ b/gnulib-tests/unistr/test-u8-mbtoucr.c @@ -0,0 +1,187 @@ +/* Test of u8_mbtoucr() function. + Copyright (C) 2010-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2010. */ + +#include <config.h> + +#include "unistr.h" + +#include "macros.h" + +int +main () +{ + ucs4_t uc; + int ret; + + /* Test NUL unit input. */ + { + static const uint8_t input[] = ""; + uc = 0xBADFACE; + ret = u8_mbtoucr (&uc, input, 1); + ASSERT (ret == 1); + ASSERT (uc == 0); + } + + /* Test ISO 646 unit input. */ + { + ucs4_t c; + uint8_t buf[1]; + + for (c = 0; c < 0x80; c++) + { + buf[0] = c; + uc = 0xBADFACE; + ret = u8_mbtoucr (&uc, buf, 1); + ASSERT (ret == 1); + ASSERT (uc == c); + } + } + + /* Test 2-byte character input. */ + { + static const uint8_t input[] = { 0xC3, 0x97 }; + uc = 0xBADFACE; + ret = u8_mbtoucr (&uc, input, 2); + ASSERT (ret == 2); + ASSERT (uc == 0x00D7); + } + + /* Test 3-byte character input. */ + { + static const uint8_t input[] = { 0xE2, 0x82, 0xAC }; + uc = 0xBADFACE; + ret = u8_mbtoucr (&uc, input, 3); + ASSERT (ret == 3); + ASSERT (uc == 0x20AC); + } + + /* Test 4-byte character input. */ + { + static const uint8_t input[] = { 0xF4, 0x8F, 0xBF, 0xBD }; + uc = 0xBADFACE; + ret = u8_mbtoucr (&uc, input, 4); + ASSERT (ret == 4); + ASSERT (uc == 0x10FFFD); + } + + /* Test incomplete/invalid 1-byte input. */ + { + static const uint8_t input[] = { 0xC1 }; + uc = 0xBADFACE; + ret = u8_mbtoucr (&uc, input, 1); + ASSERT (ret == -1); + ASSERT (uc == 0xFFFD); + } + { + static const uint8_t input[] = { 0xC3 }; + uc = 0xBADFACE; + ret = u8_mbtoucr (&uc, input, 1); + ASSERT (ret == -2); + ASSERT (uc == 0xFFFD); + } + { + static const uint8_t input[] = { 0xE2 }; + uc = 0xBADFACE; + ret = u8_mbtoucr (&uc, input, 1); + ASSERT (ret == -2); + ASSERT (uc == 0xFFFD); + } + { + static const uint8_t input[] = { 0xF4 }; + uc = 0xBADFACE; + ret = u8_mbtoucr (&uc, input, 1); + ASSERT (ret == -2); + ASSERT (uc == 0xFFFD); + } + { + static const uint8_t input[] = { 0xFE }; + uc = 0xBADFACE; + ret = u8_mbtoucr (&uc, input, 1); + ASSERT (ret == -1); + ASSERT (uc == 0xFFFD); + } + + /* Test incomplete/invalid 2-byte input. */ + { + static const uint8_t input[] = { 0xE0, 0x9F }; + uc = 0xBADFACE; + ret = u8_mbtoucr (&uc, input, 2); + ASSERT (ret == -1); + ASSERT (uc == 0xFFFD); + } + { + static const uint8_t input[] = { 0xE2, 0x82 }; + uc = 0xBADFACE; + ret = u8_mbtoucr (&uc, input, 2); + ASSERT (ret == -2); + ASSERT (uc == 0xFFFD); + } + { + static const uint8_t input[] = { 0xE2, 0xD0 }; + uc = 0xBADFACE; + ret = u8_mbtoucr (&uc, input, 2); + ASSERT (ret == -1); + ASSERT (uc == 0xFFFD); + } + { + static const uint8_t input[] = { 0xF0, 0x8F }; + uc = 0xBADFACE; + ret = u8_mbtoucr (&uc, input, 2); + ASSERT (ret == -1); + ASSERT (uc == 0xFFFD); + } + { + static const uint8_t input[] = { 0xF3, 0x8F }; + uc = 0xBADFACE; + ret = u8_mbtoucr (&uc, input, 2); + ASSERT (ret == -2); + ASSERT (uc == 0xFFFD); + } + { + static const uint8_t input[] = { 0xF3, 0xD0 }; + uc = 0xBADFACE; + ret = u8_mbtoucr (&uc, input, 2); + ASSERT (ret == -1); + ASSERT (uc == 0xFFFD); + } + + /* Test incomplete/invalid 3-byte input. */ + { + static const uint8_t input[] = { 0xF3, 0x8F, 0xBF }; + uc = 0xBADFACE; + ret = u8_mbtoucr (&uc, input, 3); + ASSERT (ret == -2); + ASSERT (uc == 0xFFFD); + } + { + static const uint8_t input[] = { 0xF3, 0xD0, 0xBF }; + uc = 0xBADFACE; + ret = u8_mbtoucr (&uc, input, 3); + ASSERT (ret == -1); + ASSERT (uc == 0xFFFD); + } + { + static const uint8_t input[] = { 0xF3, 0x8F, 0xD0 }; + uc = 0xBADFACE; + ret = u8_mbtoucr (&uc, input, 3); + ASSERT (ret == -1); + ASSERT (uc == 0xFFFD); + } + + return 0; +} diff --git a/gnulib-tests/unistr/test-u8-uctomb.c b/gnulib-tests/unistr/test-u8-uctomb.c new file mode 100644 index 0000000..a63d10f --- /dev/null +++ b/gnulib-tests/unistr/test-u8-uctomb.c @@ -0,0 +1,157 @@ +/* Test of u8_uctomb() function. + Copyright (C) 2010-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2010. */ + +#include <config.h> + +#include "unistr.h" + +#include "macros.h" + +#define MAGIC 0xBA + +int +main () +{ + /* Test ISO 646 character, in particular the NUL character. */ + { + ucs4_t uc; + + for (uc = 0; uc < 0x80; uc++) + { + uint8_t buf[5] = { MAGIC, MAGIC, MAGIC, MAGIC, MAGIC }; + int ret; + + ret = u8_uctomb (buf, uc, 0); + ASSERT (ret == -2); + ASSERT (buf[0] == MAGIC); + + ret = u8_uctomb (buf, uc, 1); + ASSERT (ret == 1); + ASSERT (buf[0] == uc); + ASSERT (buf[1] == MAGIC); + } + } + + /* Test 2-byte character. */ + { + ucs4_t uc = 0x00D7; + uint8_t buf[5] = { MAGIC, MAGIC, MAGIC, MAGIC, MAGIC }; + int ret; + + ret = u8_uctomb (buf, uc, 0); + ASSERT (ret == -2); + ASSERT (buf[0] == MAGIC); + + ret = u8_uctomb (buf, uc, 1); + ASSERT (ret == -2); + ASSERT (buf[0] == MAGIC); + + ret = u8_uctomb (buf, uc, 2); + ASSERT (ret == 2); + ASSERT (buf[0] == 0xC3); + ASSERT (buf[1] == 0x97); + ASSERT (buf[2] == MAGIC); + } + + /* Test 3-byte character. */ + { + ucs4_t uc = 0x20AC; + uint8_t buf[5] = { MAGIC, MAGIC, MAGIC, MAGIC, MAGIC }; + int ret; + + ret = u8_uctomb (buf, uc, 0); + ASSERT (ret == -2); + ASSERT (buf[0] == MAGIC); + + ret = u8_uctomb (buf, uc, 1); + ASSERT (ret == -2); + ASSERT (buf[0] == MAGIC); + + ret = u8_uctomb (buf, uc, 2); + ASSERT (ret == -2); + ASSERT (buf[0] == MAGIC); + ASSERT (buf[1] == MAGIC); + + ret = u8_uctomb (buf, uc, 3); + ASSERT (ret == 3); + ASSERT (buf[0] == 0xE2); + ASSERT (buf[1] == 0x82); + ASSERT (buf[2] == 0xAC); + ASSERT (buf[3] == MAGIC); + } + + /* Test 4-byte character. */ + { + ucs4_t uc = 0x10FFFD; + uint8_t buf[5] = { MAGIC, MAGIC, MAGIC, MAGIC, MAGIC }; + int ret; + + ret = u8_uctomb (buf, uc, 0); + ASSERT (ret == -2); + ASSERT (buf[0] == MAGIC); + + ret = u8_uctomb (buf, uc, 1); + ASSERT (ret == -2); + ASSERT (buf[0] == MAGIC); + + ret = u8_uctomb (buf, uc, 2); + ASSERT (ret == -2); + ASSERT (buf[0] == MAGIC); + ASSERT (buf[1] == MAGIC); + + ret = u8_uctomb (buf, uc, 3); + ASSERT (ret == -2); + ASSERT (buf[0] == MAGIC); + ASSERT (buf[1] == MAGIC); + ASSERT (buf[2] == MAGIC); + + ret = u8_uctomb (buf, uc, 4); + ASSERT (ret == 4); + ASSERT (buf[0] == 0xF4); + ASSERT (buf[1] == 0x8F); + ASSERT (buf[2] == 0xBF); + ASSERT (buf[3] == 0xBD); + ASSERT (buf[4] == MAGIC); + } + + /* Test invalid characters. */ + { + ucs4_t invalid[] = { 0x110000, 0xD800, 0xDBFF, 0xDC00, 0xDFFF }; + uint8_t buf[5] = { MAGIC, MAGIC, MAGIC, MAGIC, MAGIC }; + size_t i; + + for (i = 0; i < SIZEOF (invalid); i++) + { + ucs4_t uc = invalid[i]; + int n; + + for (n = 0; n <= 4; n++) + { + int ret = u8_uctomb (buf, uc, n); + ASSERT (ret == -1); + ASSERT (buf[0] == MAGIC); + ASSERT (buf[1] == MAGIC); + ASSERT (buf[2] == MAGIC); + ASSERT (buf[3] == MAGIC); + ASSERT (buf[4] == MAGIC); + } + } + } + + return 0; +} diff --git a/gnulib-tests/uniwidth/test-uc_width.c b/gnulib-tests/uniwidth/test-uc_width.c new file mode 100644 index 0000000..6f06343 --- /dev/null +++ b/gnulib-tests/uniwidth/test-uc_width.c @@ -0,0 +1,56 @@ +/* Test of uc_width() function. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include "uniwidth.h" + +#include "macros.h" + +int +main () +{ + ucs4_t uc; + + /* Test width of ASCII characters. */ + for (uc = 0x0020; uc < 0x007F; uc++) + ASSERT (uc_width (uc, "ISO-8859-2") == 1); + + /* Test width of some non-spacing characters. */ + ASSERT (uc_width (0x0301, "UTF-8") == 0); + ASSERT (uc_width (0x05B0, "UTF-8") == 0); + + /* Test width of some format control characters. */ + ASSERT (uc_width (0x200E, "UTF-8") == 0); + ASSERT (uc_width (0x2060, "UTF-8") == 0); + ASSERT (uc_width (0xE0001, "UTF-8") == 0); + ASSERT (uc_width (0xE0044, "UTF-8") == 0); + + /* Test width of some zero width characters. */ + ASSERT (uc_width (0x200B, "UTF-8") == 0); + ASSERT (uc_width (0xFEFF, "UTF-8") == 0); + + /* Test width of some CJK characters. */ + ASSERT (uc_width (0x3000, "UTF-8") == 2); + ASSERT (uc_width (0xB250, "UTF-8") == 2); + ASSERT (uc_width (0xFF1A, "UTF-8") == 2); + ASSERT (uc_width (0x20369, "UTF-8") == 2); + ASSERT (uc_width (0x2F876, "UTF-8") == 2); + + return 0; +} diff --git a/gnulib-tests/uniwidth/test-uc_width2.c b/gnulib-tests/uniwidth/test-uc_width2.c new file mode 100644 index 0000000..b86011b --- /dev/null +++ b/gnulib-tests/uniwidth/test-uc_width2.c @@ -0,0 +1,86 @@ +/* Test of uc_width() function. + Copyright (C) 2007-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2008. */ + +#include <config.h> + +#include "uniwidth.h" + +#include <stdio.h> + +#include "macros.h" + +/* One of 0, '0', '1', 'A', '2'. */ +static char current_width; +/* The interval for which the current_width holds. */ +static ucs4_t current_start; +static ucs4_t current_end; + +static void +finish_interval (void) +{ + if (current_width != 0) + { + if (current_start == current_end) + printf ("%04X\t\t%c\n", (unsigned) current_start, current_width); + else + printf ("%04X..%04X\t%c\n", (unsigned) current_start, + (unsigned) current_end, current_width); + current_width = 0; + } +} + +static void +add_to_interval (ucs4_t uc, char width) +{ + if (current_width == width && uc == current_end + 1) + current_end = uc; + else + { + finish_interval (); + current_width = width; + current_start = current_end = uc; + } +} + +int +main () +{ + ucs4_t uc; + + for (uc = 0; uc < 0x110000; uc++) + { + int w1 = uc_width (uc, "UTF-8"); + int w2 = uc_width (uc, "GBK"); + char width = + (w1 == 0 && w2 == 0 ? '0' : + w1 == 1 && w2 == 1 ? '1' : + w1 == 1 && w2 == 2 ? 'A' : + w1 == 2 && w2 == 2 ? '2' : + 0); + if (width == 0) + { + /* uc must be a control character. */ + ASSERT (w1 < 0 && w2 < 0); + } + else + add_to_interval (uc, width); + } + finish_interval (); + + return 0; +} diff --git a/gnulib-tests/uniwidth/test-uc_width2.sh b/gnulib-tests/uniwidth/test-uc_width2.sh new file mode 100755 index 0000000..23866c9 --- /dev/null +++ b/gnulib-tests/uniwidth/test-uc_width2.sh @@ -0,0 +1,631 @@ +#!/bin/sh + +tmpfiles="" +trap 'rm -fr $tmpfiles' 1 2 3 15 + +tmpfiles="$tmpfiles uc_width.out" +${CHECKER} ./test-uc_width2${EXEEXT} | LC_ALL=C tr -d '\r' > uc_width.out + +tmpfiles="$tmpfiles uc_width.ok" +cat > uc_width.ok <<\EOF +0000 0 +0020..007E 1 +00A0 1 +00A1..00AC A +00AD 0 +00AE..02FF A +0300..036F 0 +0370..0482 A +0483..0489 0 +048A..0590 A +0591..05BD 0 +05BE A +05BF 0 +05C0 A +05C1..05C2 0 +05C3 A +05C4..05C5 0 +05C6 A +05C7 0 +05C8..05FF A +0600..0605 0 +0606..060F A +0610..061A 0 +061B A +061C 0 +061D..064A A +064B..065F 0 +0660..066F A +0670 0 +0671..06D5 A +06D6..06DD 0 +06DE A +06DF..06E4 0 +06E5..06E6 A +06E7..06E8 0 +06E9 A +06EA..06ED 0 +06EE..070E A +070F 0 +0710 A +0711 0 +0712..072F A +0730..074A 0 +074B..07A5 A +07A6..07B0 0 +07B1..07EA A +07EB..07F3 0 +07F4..0815 A +0816..0819 0 +081A A +081B..0823 0 +0824 A +0825..0827 0 +0828 A +0829..082D 0 +082E..0858 A +0859..085B 0 +085C..08D3 A +08D4..0902 0 +0903..0939 A +093A 0 +093B A +093C 0 +093D..0940 A +0941..0948 0 +0949..094C A +094D 0 +094E..0950 A +0951..0957 0 +0958..0961 A +0962..0963 0 +0964..0980 A +0981 0 +0982..09BB A +09BC 0 +09BD..09C0 A +09C1..09C4 0 +09C5..09CC A +09CD 0 +09CE..09E1 A +09E2..09E3 0 +09E4..0A00 A +0A01..0A02 0 +0A03..0A3B A +0A3C 0 +0A3D..0A40 A +0A41..0A42 0 +0A43..0A46 A +0A47..0A48 0 +0A49..0A4A A +0A4B..0A4D 0 +0A4E..0A50 A +0A51 0 +0A52..0A6F A +0A70..0A71 0 +0A72..0A74 A +0A75 0 +0A76..0A80 A +0A81..0A82 0 +0A83..0ABB A +0ABC 0 +0ABD..0AC0 A +0AC1..0AC5 0 +0AC6 A +0AC7..0AC8 0 +0AC9..0ACC A +0ACD 0 +0ACE..0AE1 A +0AE2..0AE3 0 +0AE4..0B00 A +0B01 0 +0B02..0B3B A +0B3C 0 +0B3D..0B3E A +0B3F 0 +0B40 A +0B41..0B44 0 +0B45..0B4C A +0B4D 0 +0B4E..0B55 A +0B56 0 +0B57..0B61 A +0B62..0B63 0 +0B64..0B81 A +0B82 0 +0B83..0BBF A +0BC0 0 +0BC1..0BCC A +0BCD 0 +0BCE..0BFF A +0C00 0 +0C01..0C3D A +0C3E..0C40 0 +0C41..0C45 A +0C46..0C48 0 +0C49 A +0C4A..0C4D 0 +0C4E..0C54 A +0C55..0C56 0 +0C57..0C61 A +0C62..0C63 0 +0C64..0C80 A +0C81 0 +0C82..0CBB A +0CBC 0 +0CBD..0CCB A +0CCC..0CCD 0 +0CCE..0CE1 A +0CE2..0CE3 0 +0CE4..0D00 A +0D01 0 +0D02..0D40 A +0D41..0D44 0 +0D45..0D4C A +0D4D 0 +0D4E..0D61 A +0D62..0D63 0 +0D64..0DC9 A +0DCA 0 +0DCB..0DD1 A +0DD2..0DD4 0 +0DD5 A +0DD6 0 +0DD7..0E30 A +0E31 0 +0E32..0E33 A +0E34..0E3A 0 +0E3B..0E46 A +0E47..0E4E 0 +0E4F..0EB0 A +0EB1 0 +0EB2..0EB3 A +0EB4..0EB9 0 +0EBA A +0EBB..0EBC 0 +0EBD..0EC7 A +0EC8..0ECD 0 +0ECE..0F17 A +0F18..0F19 0 +0F1A..0F34 A +0F35 0 +0F36 A +0F37 0 +0F38 A +0F39 0 +0F3A..0F70 A +0F71..0F7E 0 +0F7F A +0F80..0F84 0 +0F85 A +0F86..0F87 0 +0F88..0F8C A +0F8D..0F97 0 +0F98 A +0F99..0FBC 0 +0FBD..0FC5 A +0FC6 0 +0FC7..102C A +102D..1030 0 +1031 A +1032..1037 0 +1038 A +1039..103A 0 +103B..103C A +103D..103E 0 +103F..1057 A +1058..1059 0 +105A..105D A +105E..1060 0 +1061..1070 A +1071..1074 0 +1075..1081 A +1082 0 +1083..1084 A +1085..1086 0 +1087..108C A +108D 0 +108E..109C A +109D 0 +109E..10FF A +1100..115F 2 +1160..135C A +135D..135F 0 +1360..1711 A +1712..1714 0 +1715..1731 A +1732..1734 0 +1735..1751 A +1752..1753 0 +1754..1771 A +1772..1773 0 +1774..17B3 A +17B4..17B5 0 +17B6 A +17B7..17BD 0 +17BE..17C5 A +17C6 0 +17C7..17C8 A +17C9..17D3 0 +17D4..17DC A +17DD 0 +17DE..180A A +180B..180E 0 +180F..1884 A +1885..1886 0 +1887..18A8 A +18A9 0 +18AA..191F A +1920..1922 0 +1923..1926 A +1927..1928 0 +1929..1931 A +1932 0 +1933..1938 A +1939..193B 0 +193C..1A16 A +1A17..1A18 0 +1A19..1A1A A +1A1B 0 +1A1C..1A55 A +1A56 0 +1A57 A +1A58..1A5E 0 +1A5F A +1A60 0 +1A61 A +1A62 0 +1A63..1A64 A +1A65..1A6C 0 +1A6D..1A72 A +1A73..1A7C 0 +1A7D..1A7E A +1A7F 0 +1A80..1AAF A +1AB0..1ABE 0 +1ABF..1AFF A +1B00..1B03 0 +1B04..1B33 A +1B34 0 +1B35 A +1B36..1B3A 0 +1B3B A +1B3C 0 +1B3D..1B41 A +1B42 0 +1B43..1B6A A +1B6B..1B73 0 +1B74..1B7F A +1B80..1B81 0 +1B82..1BA1 A +1BA2..1BA5 0 +1BA6..1BA7 A +1BA8..1BA9 0 +1BAA A +1BAB..1BAD 0 +1BAE..1BE5 A +1BE6 0 +1BE7 A +1BE8..1BE9 0 +1BEA..1BEC A +1BED 0 +1BEE A +1BEF..1BF1 0 +1BF2..1C2B A +1C2C..1C33 0 +1C34..1C35 A +1C36..1C37 0 +1C38..1CCF A +1CD0..1CD2 0 +1CD3 A +1CD4..1CE0 0 +1CE1 A +1CE2..1CE8 0 +1CE9..1CEC A +1CED 0 +1CEE..1CF3 A +1CF4 0 +1CF5..1CF7 A +1CF8..1CF9 0 +1CFA..1DBF A +1DC0..1DF5 0 +1DF6..1DFA A +1DFB..1DFF 0 +1E00..200A A +200B..200F 0 +2010..2029 A +202A..202E 0 +202F..205F A +2060..2064 0 +2065 A +2066..206F 0 +2070..20A8 A +20A9 1 +20AA..20CF A +20D0..20F0 0 +20F1..2328 A +2329..232A 2 +232B..2CEE A +2CEF..2CF1 0 +2CF2..2D7E A +2D7F 0 +2D80..2DDF A +2DE0..2DFF 0 +2E00..2E7F A +2E80..3029 2 +302A..302D 0 +302E..303E 2 +303F A +3040..3098 2 +3099..309A 0 +309B..4DBF 2 +4DC0..4DFF A +4E00..A4CF 2 +A4D0..A66E A +A66F..A672 0 +A673 A +A674..A67D 0 +A67E..A69D A +A69E..A69F 0 +A6A0..A6EF A +A6F0..A6F1 0 +A6F2..A801 A +A802 0 +A803..A805 A +A806 0 +A807..A80A A +A80B 0 +A80C..A824 A +A825..A826 0 +A827..A8C3 A +A8C4..A8C5 0 +A8C6..A8DF A +A8E0..A8F1 0 +A8F2..A925 A +A926..A92D 0 +A92E..A946 A +A947..A951 0 +A952..A97F A +A980..A982 0 +A983..A9B2 A +A9B3 0 +A9B4..A9B5 A +A9B6..A9B9 0 +A9BA..A9BB A +A9BC 0 +A9BD..A9E4 A +A9E5 0 +A9E6..AA28 A +AA29..AA2E 0 +AA2F..AA30 A +AA31..AA32 0 +AA33..AA34 A +AA35..AA36 0 +AA37..AA42 A +AA43 0 +AA44..AA4B A +AA4C 0 +AA4D..AA7B A +AA7C 0 +AA7D..AAAF A +AAB0 0 +AAB1 A +AAB2..AAB4 0 +AAB5..AAB6 A +AAB7..AAB8 0 +AAB9..AABD A +AABE..AABF 0 +AAC0 A +AAC1 0 +AAC2..AAEB A +AAEC..AAED 0 +AAEE..AAF5 A +AAF6 0 +AAF7..ABE4 A +ABE5 0 +ABE6..ABE7 A +ABE8 0 +ABE9..ABEC A +ABED 0 +ABEE..ABFF A +AC00..D7A3 2 +D7A4..F8FF A +F900..FAFF 2 +FB00..FB1D A +FB1E 0 +FB1F..FDFF A +FE00..FE0F 0 +FE10..FE1F 2 +FE20..FE2F 0 +FE30..FE6F 2 +FE70..FEFE A +FEFF 0 +FF00..FF60 2 +FF61..FFDF 1 +FFE0..FFE6 2 +FFE7..FFF8 1 +FFF9..FFFB 0 +FFFC..101FC 1 +101FD 0 +101FE..102DF 1 +102E0 0 +102E1..10375 1 +10376..1037A 0 +1037B..10A00 1 +10A01..10A03 0 +10A04 1 +10A05..10A06 0 +10A07..10A0B 1 +10A0C..10A0F 0 +10A10..10A37 1 +10A38..10A3A 0 +10A3B..10A3E 1 +10A3F 0 +10A40..10AE4 1 +10AE5..10AE6 0 +10AE7..11000 1 +11001 0 +11002..11037 1 +11038..11046 0 +11047..1107E 1 +1107F..11081 0 +11082..110B2 1 +110B3..110B6 0 +110B7..110B8 1 +110B9..110BA 0 +110BB..110BC 1 +110BD 0 +110BE..110FF 1 +11100..11102 0 +11103..11126 1 +11127..1112B 0 +1112C 1 +1112D..11134 0 +11135..11172 1 +11173 0 +11174..1117F 1 +11180..11181 0 +11182..111B5 1 +111B6..111BE 0 +111BF..111C9 1 +111CA..111CC 0 +111CD..1122E 1 +1122F..11231 0 +11232..11233 1 +11234 0 +11235 1 +11236..11237 0 +11238..1123D 1 +1123E 0 +1123F..112DE 1 +112DF 0 +112E0..112E2 1 +112E3..112EA 0 +112EB..112FF 1 +11300..11301 0 +11302..1133B 1 +1133C 0 +1133D..1133F 1 +11340 0 +11341..11365 1 +11366..1136C 0 +1136D..1136F 1 +11370..11374 0 +11375..11437 1 +11438..1143F 0 +11440..11441 1 +11442..11444 0 +11445 1 +11446 0 +11447..114B2 1 +114B3..114B8 0 +114B9 1 +114BA 0 +114BB..114BE 1 +114BF..114C0 0 +114C1 1 +114C2..114C3 0 +114C4..115B1 1 +115B2..115B5 0 +115B6..115BB 1 +115BC..115BD 0 +115BE 1 +115BF..115C0 0 +115C1..115DB 1 +115DC..115DD 0 +115DE..11632 1 +11633..1163A 0 +1163B..1163C 1 +1163D 0 +1163E 1 +1163F..11640 0 +11641..116AA 1 +116AB 0 +116AC 1 +116AD 0 +116AE..116AF 1 +116B0..116B5 0 +116B6 1 +116B7 0 +116B8..1171C 1 +1171D..1171F 0 +11720..11721 1 +11722..11725 0 +11726 1 +11727..1172B 0 +1172C..11C2F 1 +11C30..11C36 0 +11C37 1 +11C38..11C3D 0 +11C3E..11C91 1 +11C92..11CA7 0 +11CA8..11CA9 1 +11CAA..11CB0 0 +11CB1 1 +11CB2..11CB3 0 +11CB4 1 +11CB5..11CB6 0 +11CB7..16AEF 1 +16AF0..16AF4 0 +16AF5..16B2F 1 +16B30..16B36 0 +16B37..16F8E 1 +16F8F..16F92 0 +16F93..1BC9C 1 +1BC9D..1BC9E 0 +1BC9F 1 +1BCA0..1BCA3 0 +1BCA4..1D166 1 +1D167..1D169 0 +1D16A..1D172 1 +1D173..1D182 0 +1D183..1D184 1 +1D185..1D18B 0 +1D18C..1D1A9 1 +1D1AA..1D1AD 0 +1D1AE..1D241 1 +1D242..1D244 0 +1D245..1D9FF 1 +1DA00..1DA36 0 +1DA37..1DA3A 1 +1DA3B..1DA6C 0 +1DA6D..1DA74 1 +1DA75 0 +1DA76..1DA83 1 +1DA84 0 +1DA85..1DA9A 1 +1DA9B..1DA9F 0 +1DAA0 1 +1DAA1..1DAAF 0 +1DAB0..1DFFF 1 +1E000..1E006 0 +1E007 1 +1E008..1E018 0 +1E019..1E01A 1 +1E01B..1E021 0 +1E022 1 +1E023..1E024 0 +1E025 1 +1E026..1E02A 0 +1E02B..1E8CF 1 +1E8D0..1E8D6 0 +1E8D7..1E943 1 +1E944..1E94A 0 +1E94B..1FFFF 1 +20000..3FFFF 2 +40000..E0000 1 +E0001 0 +E0002..E001F 1 +E0020..E007F 0 +E0080..E00FF 1 +E0100..E01EF 0 +E01F0..10FFFF 1 +EOF + +: ${DIFF=diff} +${DIFF} uc_width.ok uc_width.out +result=$? + +rm -fr $tmpfiles + +exit $result diff --git a/gnulib-tests/unused-parameter.h b/gnulib-tests/unused-parameter.h new file mode 100644 index 0000000..f5cf21e --- /dev/null +++ b/gnulib-tests/unused-parameter.h @@ -0,0 +1,36 @@ +/* A C macro for declaring that specific function parameters are not used. + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* _GL_UNUSED_PARAMETER is a marker that can be appended to function parameter + declarations for parameters that are not used. This helps to reduce + warnings, such as from GCC -Wunused-parameter. The syntax is as follows: + type param _GL_UNUSED_PARAMETER + or more generally + param_decl _GL_UNUSED_PARAMETER + For example: + int param _GL_UNUSED_PARAMETER + int *(*param)(void) _GL_UNUSED_PARAMETER + Other possible, but obscure and discouraged syntaxes: + int _GL_UNUSED_PARAMETER *(*param)(void) + _GL_UNUSED_PARAMETER int *(*param)(void) + */ +#ifndef _GL_UNUSED_PARAMETER +# if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) +# define _GL_UNUSED_PARAMETER __attribute__ ((__unused__)) +# else +# define _GL_UNUSED_PARAMETER +# endif +#endif diff --git a/gnulib-tests/usleep.c b/gnulib-tests/usleep.c new file mode 100644 index 0000000..f735302 --- /dev/null +++ b/gnulib-tests/usleep.c @@ -0,0 +1,76 @@ +/* Pausing execution of the current thread. + Copyright (C) 2009-2020 Free Software Foundation, Inc. + Written by Eric Blake <ebb9@byu.net>, 2009. + + 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 <https://www.gnu.org/licenses/>. */ + +/* This file is _intentionally_ light-weight. Rather than using + select or nanosleep, both of which drag in external libraries on + some platforms, this merely rounds up to the nearest second if + usleep() does not exist. If sub-second resolution is important, + then use a more powerful interface to begin with. */ + +#include <config.h> + +/* Specification. */ +#include <unistd.h> + +#include <errno.h> + +#if defined _WIN32 && ! defined __CYGWIN__ +# define WIN32_LEAN_AND_MEAN /* avoid including junk */ +# include <windows.h> +#endif + +#ifndef HAVE_USLEEP +# define HAVE_USLEEP 0 +#endif + +/* Sleep for MICRO microseconds, which can be greater than 1 second. + Return -1 and set errno to EINVAL on range error (about 4295 + seconds), or 0 on success. Interaction with SIGALARM is + unspecified. */ + +int +usleep (useconds_t micro) +#undef usleep +{ +#if defined _WIN32 && ! defined __CYGWIN__ + unsigned int milliseconds = micro / 1000; + if (sizeof milliseconds < sizeof micro && micro / 1000 != milliseconds) + { + errno = EINVAL; + return -1; + } + if (micro % 1000) + milliseconds++; + Sleep (milliseconds); + return 0; +#else + unsigned int seconds = micro / 1000000; + if (sizeof seconds < sizeof micro && micro / 1000000 != seconds) + { + errno = EINVAL; + return -1; + } + if (!HAVE_USLEEP && micro % 1000000) + seconds++; + while ((seconds = sleep (seconds)) != 0); + +# if !HAVE_USLEEP +# define usleep(x) 0 +# endif + return usleep (micro % 1000000); +#endif +} diff --git a/gnulib-tests/w32sock.h b/gnulib-tests/w32sock.h new file mode 100644 index 0000000..9c23c9d --- /dev/null +++ b/gnulib-tests/w32sock.h @@ -0,0 +1,140 @@ +/* w32sock.h --- internal auxiliary functions for Windows socket functions + + Copyright (C) 2008-2020 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 <https://www.gnu.org/licenses/>. */ + +/* Written by Paolo Bonzini */ + +#include <errno.h> + +/* Get O_RDWR and O_BINARY. */ +#include <fcntl.h> + +/* Get _open_osfhandle(). */ +#include <io.h> + +/* Get _get_osfhandle(). */ +#if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +#else +# include <io.h> +#endif + +#define FD_TO_SOCKET(fd) ((SOCKET) _get_osfhandle ((fd))) +#define SOCKET_TO_FD(fh) (_open_osfhandle ((intptr_t) (fh), O_RDWR | O_BINARY)) + +static inline void +set_winsock_errno (void) +{ + int err = WSAGetLastError (); + + /* Map some WSAE* errors to the runtime library's error codes. */ + switch (err) + { + case WSA_INVALID_HANDLE: + errno = EBADF; + break; + case WSA_NOT_ENOUGH_MEMORY: + errno = ENOMEM; + break; + case WSA_INVALID_PARAMETER: + errno = EINVAL; + break; + case WSAENAMETOOLONG: + errno = ENAMETOOLONG; + break; + case WSAENOTEMPTY: + errno = ENOTEMPTY; + break; + case WSAEWOULDBLOCK: + errno = EWOULDBLOCK; + break; + case WSAEINPROGRESS: + errno = EINPROGRESS; + break; + case WSAEALREADY: + errno = EALREADY; + break; + case WSAENOTSOCK: + errno = ENOTSOCK; + break; + case WSAEDESTADDRREQ: + errno = EDESTADDRREQ; + break; + case WSAEMSGSIZE: + errno = EMSGSIZE; + break; + case WSAEPROTOTYPE: + errno = EPROTOTYPE; + break; + case WSAENOPROTOOPT: + errno = ENOPROTOOPT; + break; + case WSAEPROTONOSUPPORT: + errno = EPROTONOSUPPORT; + break; + case WSAEOPNOTSUPP: + errno = EOPNOTSUPP; + break; + case WSAEAFNOSUPPORT: + errno = EAFNOSUPPORT; + break; + case WSAEADDRINUSE: + errno = EADDRINUSE; + break; + case WSAEADDRNOTAVAIL: + errno = EADDRNOTAVAIL; + break; + case WSAENETDOWN: + errno = ENETDOWN; + break; + case WSAENETUNREACH: + errno = ENETUNREACH; + break; + case WSAENETRESET: + errno = ENETRESET; + break; + case WSAECONNABORTED: + errno = ECONNABORTED; + break; + case WSAECONNRESET: + errno = ECONNRESET; + break; + case WSAENOBUFS: + errno = ENOBUFS; + break; + case WSAEISCONN: + errno = EISCONN; + break; + case WSAENOTCONN: + errno = ENOTCONN; + break; + case WSAETIMEDOUT: + errno = ETIMEDOUT; + break; + case WSAECONNREFUSED: + errno = ECONNREFUSED; + break; + case WSAELOOP: + errno = ELOOP; + break; + case WSAEHOSTUNREACH: + errno = EHOSTUNREACH; + break; + default: + errno = (err > 10000 && err < 10025) ? err - 10000 : err; + break; + } +} diff --git a/gnulib-tests/warn-on-use.h b/gnulib-tests/warn-on-use.h new file mode 100644 index 0000000..1be2cbb --- /dev/null +++ b/gnulib-tests/warn-on-use.h @@ -0,0 +1,131 @@ +/* A C macro for emitting warnings if a function is used. + Copyright (C) 2010-2020 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 <https://www.gnu.org/licenses/>. */ + +/* _GL_WARN_ON_USE (function, "literal string") issues a declaration + for FUNCTION which will then trigger a compiler warning containing + the text of "literal string" anywhere that function is called, if + supported by the compiler. If the compiler does not support this + feature, the macro expands to an unused extern declaration. + + _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the + attribute used in _GL_WARN_ON_USE. If the compiler does not support + this feature, it expands to empty. + + These macros are useful for marking a function as a potential + portability trap, with the intent that "literal string" include + instructions on the replacement function that should be used + instead. + _GL_WARN_ON_USE is for functions with 'extern' linkage. + _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline' + linkage. + + However, one of the reasons that a function is a portability trap is + if it has the wrong signature. Declaring FUNCTION with a different + signature in C is a compilation error, so this macro must use the + same type as any existing declaration so that programs that avoid + the problematic FUNCTION do not fail to compile merely because they + included a header that poisoned the function. But this implies that + _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already + have a declaration. Use of this macro implies that there must not + be any other macro hiding the declaration of FUNCTION; but + undefining FUNCTION first is part of the poisoning process anyway + (although for symbols that are provided only via a macro, the result + is a compilation error rather than a warning containing + "literal string"). Also note that in C++, it is only safe to use if + FUNCTION has no overloads. + + For an example, it is possible to poison 'getline' by: + - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]], + [getline]) in configure.ac, which potentially defines + HAVE_RAW_DECL_GETLINE + - adding this code to a header that wraps the system <stdio.h>: + #undef getline + #if HAVE_RAW_DECL_GETLINE + _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" + "not universally present; use the gnulib module getline"); + #endif + + It is not possible to directly poison global variables. But it is + possible to write a wrapper accessor function, and poison that + (less common usage, like &environ, will cause a compilation error + rather than issue the nice warning, but the end result of informing + the developer about their portability problem is still achieved): + #if HAVE_RAW_DECL_ENVIRON + static char *** + rpl_environ (void) { return &environ; } + _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); + # undef environ + # define environ (*rpl_environ ()) + #endif + or better (avoiding contradictory use of 'static' and 'extern'): + #if HAVE_RAW_DECL_ENVIRON + static char *** + _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared") + rpl_environ (void) { return &environ; } + # undef environ + # define environ (*rpl_environ ()) + #endif + */ +#ifndef _GL_WARN_ON_USE + +# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) +/* A compiler attribute is available in gcc versions 4.3.0 and later. */ +# define _GL_WARN_ON_USE(function, message) \ +extern __typeof__ (function) function __attribute__ ((__warning__ (message))) +# define _GL_WARN_ON_USE_ATTRIBUTE(message) \ + __attribute__ ((__warning__ (message))) +# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING +/* Verify the existence of the function. */ +# define _GL_WARN_ON_USE(function, message) \ +extern __typeof__ (function) function +# define _GL_WARN_ON_USE_ATTRIBUTE(message) +# else /* Unsupported. */ +# define _GL_WARN_ON_USE(function, message) \ +_GL_WARN_EXTERN_C int _gl_warn_on_use +# define _GL_WARN_ON_USE_ATTRIBUTE(message) +# endif +#endif + +/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string") + is like _GL_WARN_ON_USE (function, "string"), except that the function is + declared with the given prototype, consisting of return type, parameters, + and attributes. + This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does + not work in this case. */ +#ifndef _GL_WARN_ON_USE_CXX +# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) +# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ +extern rettype function parameters_and_attributes \ + __attribute__ ((__warning__ (msg))) +# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING +/* Verify the existence of the function. */ +# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ +extern rettype function parameters_and_attributes +# else /* Unsupported. */ +# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ +_GL_WARN_EXTERN_C int _gl_warn_on_use +# endif +#endif + +/* _GL_WARN_EXTERN_C declaration; + performs the declaration with C linkage. */ +#ifndef _GL_WARN_EXTERN_C +# if defined __cplusplus +# define _GL_WARN_EXTERN_C extern "C" +# else +# define _GL_WARN_EXTERN_C extern +# endif +#endif diff --git a/gnulib-tests/wctob.c b/gnulib-tests/wctob.c new file mode 100644 index 0000000..7d08863 --- /dev/null +++ b/gnulib-tests/wctob.c @@ -0,0 +1,38 @@ +/* Convert wide character to unibyte character. + Copyright (C) 2008, 2010-2020 Free Software Foundation, Inc. + Written by Bruno Haible <bruno@clisp.org>, 2008. + + 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +/* Specification. */ +#include <wchar.h> + +#include <stdio.h> +#include <stdlib.h> + +int +wctob (wint_t wc) +{ + char buf[64]; + + if (!(MB_CUR_MAX <= sizeof (buf))) + abort (); + /* Handle the case where WEOF is a value that does not fit in a wchar_t. */ + if (wc == (wchar_t)wc) + if (wctomb (buf, (wchar_t)wc) == 1) + return (unsigned char) buf[0]; + return EOF; +} diff --git a/gnulib-tests/wctomb-impl.h b/gnulib-tests/wctomb-impl.h new file mode 100644 index 0000000..cca56bb --- /dev/null +++ b/gnulib-tests/wctomb-impl.h @@ -0,0 +1,34 @@ +/* Convert wide character to multibyte character. + Copyright (C) 2011-2020 Free Software Foundation, Inc. + Written by Bruno Haible <bruno@clisp.org>, 2011. + + 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 <https://www.gnu.org/licenses/>. */ + +int +wctomb (char *s, wchar_t wc) +{ + if (s == NULL) + return 0; + else + { + mbstate_t state; + size_t result; + + memset (&state, 0, sizeof (mbstate_t)); + result = wcrtomb (s, wc, &state); + if (result == (size_t)-1) + return -1; + return result; + } +} diff --git a/gnulib-tests/wctomb.c b/gnulib-tests/wctomb.c new file mode 100644 index 0000000..55ec077 --- /dev/null +++ b/gnulib-tests/wctomb.c @@ -0,0 +1,25 @@ +/* Convert wide character to multibyte character. + Copyright (C) 2011-2020 Free Software Foundation, Inc. + Written by Bruno Haible <bruno@clisp.org>, 2011. + + 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 <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdlib.h> + +#include <string.h> +#include <wchar.h> + +#include "wctomb-impl.h" diff --git a/gnulib-tests/zerosize-ptr.h b/gnulib-tests/zerosize-ptr.h new file mode 100644 index 0000000..4a5d267 --- /dev/null +++ b/gnulib-tests/zerosize-ptr.h @@ -0,0 +1,81 @@ +/* Return a pointer to a zero-size object in memory. + Copyright (C) 2009-2020 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 <https://www.gnu.org/licenses/>. */ + +/* ISO C 99 does not allow memcmp(), memchr() etc. to be invoked with a NULL + argument. Therefore this file produces a non-NULL pointer which cannot + be dereferenced, if possible. */ + +/* On Android, when targeting Android 4.4 or older with a GCC toolchain, + prevent a compilation error + "error: call to 'mmap' declared with attribute error: mmap is not + available with _FILE_OFFSET_BITS=64 when using GCC until android-21. + Either raise your minSdkVersion, disable _FILE_OFFSET_BITS=64, or + switch to Clang." + The files that we access in this compilation unit are less than 2 GB + large. */ +#if defined __ANDROID__ +# undef _FILE_OFFSET_BITS +# undef __USE_FILE_OFFSET64 +#endif + +#include <stdlib.h> + +/* Test whether mmap() and mprotect() are available. + We don't use HAVE_MMAP, because AC_FUNC_MMAP would not define it on HP-UX. + HAVE_MPROTECT is not enough, because mingw does not have mmap() but has an + mprotect() function in libgcc.a. */ +#if HAVE_SYS_MMAN_H && HAVE_MPROTECT +# include <fcntl.h> +# include <unistd.h> +# include <sys/types.h> +# include <sys/mman.h> +/* Define MAP_FILE when it isn't otherwise. */ +# ifndef MAP_FILE +# define MAP_FILE 0 +# endif +#endif + +/* Return a pointer to a zero-size object in memory (that is, actually, a + pointer to a page boundary where the previous page is readable and writable + and the next page is neither readable not writable), if possible. + Return NULL otherwise. */ + +static void * +zerosize_ptr (void) +{ +/* Use mmap and mprotect when they exist. Don't test HAVE_MMAP, because it is + not defined on HP-UX 11 (since it does not support MAP_FIXED). */ +#if HAVE_SYS_MMAN_H && HAVE_MPROTECT +# if HAVE_MAP_ANONYMOUS + const int flags = MAP_ANONYMOUS | MAP_PRIVATE; + const int fd = -1; +# else /* !HAVE_MAP_ANONYMOUS */ + const int flags = MAP_FILE | MAP_PRIVATE; + int fd = open ("/dev/zero", O_RDONLY, 0666); + if (fd >= 0) +# endif + { + int pagesize = getpagesize (); + char *two_pages = + (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE, + flags, fd, 0); + if (two_pages != (char *)(-1) + && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0) + return two_pages + pagesize; + } +#endif + return NULL; +} |