diff options
Diffstat (limited to 'tests/misc')
48 files changed, 4655 insertions, 0 deletions
diff --git a/tests/misc/Makefile.am b/tests/misc/Makefile.am new file mode 100644 index 0000000..4d6a754 --- /dev/null +++ b/tests/misc/Makefile.am @@ -0,0 +1,88 @@ +# Make miscellaneous coreutils tests. -*-Makefile-*- + +# Copyright (C) 200-2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +EXTRA_DIST = $(TESTS) + +TESTS_ENVIRONMENT = \ + top_srcdir=$(top_srcdir) \ + abs_top_builddir=$(abs_top_builddir) \ + srcdir=$(srcdir) \ + PACKAGE_VERSION=$(PACKAGE_VERSION) \ + PERL="$(PERL)" \ + BUILD_SRC_DIR="`pwd`/../../src" \ + CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \ + PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH" \ + CONFIG_HEADER=$(CONFIG_HEADER) \ + REPLACE_GETCWD=$(REPLACE_GETCWD) \ + host_os=$(host_os) \ + PROG=`../../src/basename -- "$$tst"` + +# Do not choose a name that is a shell keyword like 'if', or a +# commonly-used utility like 'cat' or 'test', as the name of a test. +# Otherwise, VPATH builds will fail on hosts like Solaris, since they +# will expand 'if test ...' to 'if .../test ...', and the '.../test' +# will execute the test script rather than the standard utility. + +TESTS = \ + pr \ + df-P \ + pwd-unreadable-parent \ + cut \ + wc-files0-from \ + wc-files0 \ + cat-proc \ + base64 \ + basename \ + close-stdout \ + csplit \ + date \ + date-sec \ + df \ + dirname \ + expand \ + false-status \ + fold \ + head-c \ + head-elide-tail \ + head-pos \ + mknod \ + nice \ + nl \ + nohup \ + paste-no-nl \ + pathchk1 \ + printf \ + printf-hex \ + pwd-long \ + sha224sum \ + sha256sum \ + sha384sum \ + sha512sum \ + shuf \ + sort-compress \ + sort-merge \ + sort-rand \ + split-a \ + split-fail \ + split-l \ + stat-fmt \ + stat-printf \ + tac-continue \ + test-diag \ + tty-eof diff --git a/tests/misc/Makefile.in b/tests/misc/Makefile.in new file mode 100644 index 0000000..357d695 --- /dev/null +++ b/tests/misc/Makefile.in @@ -0,0 +1,798 @@ +# Makefile.in generated by automake 1.10 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006 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@ + +# Make miscellaneous coreutils tests. -*-Makefile-*- + +# Copyright (C) 200-2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@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@ +subdir = tests/misc +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/absolute-header.m4 \ + $(top_srcdir)/m4/acl.m4 $(top_srcdir)/m4/alloca.m4 \ + $(top_srcdir)/m4/allocsa.m4 $(top_srcdir)/m4/argmatch.m4 \ + $(top_srcdir)/m4/arpa_inet_h.m4 $(top_srcdir)/m4/assert.m4 \ + $(top_srcdir)/m4/atexit.m4 $(top_srcdir)/m4/autobuild.m4 \ + $(top_srcdir)/m4/backupfile.m4 $(top_srcdir)/m4/base64.m4 \ + $(top_srcdir)/m4/bison.m4 $(top_srcdir)/m4/boottime.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/cloexec.m4 $(top_srcdir)/m4/close-stream.m4 \ + $(top_srcdir)/m4/closeout.m4 $(top_srcdir)/m4/codeset.m4 \ + $(top_srcdir)/m4/config-h.m4 $(top_srcdir)/m4/cycle-check.m4 \ + $(top_srcdir)/m4/d-ino.m4 $(top_srcdir)/m4/d-type.m4 \ + $(top_srcdir)/m4/dirfd.m4 $(top_srcdir)/m4/dirname.m4 \ + $(top_srcdir)/m4/dos.m4 $(top_srcdir)/m4/double-slash-root.m4 \ + $(top_srcdir)/m4/dup2.m4 $(top_srcdir)/m4/eealloc.m4 \ + $(top_srcdir)/m4/eoverflow.m4 $(top_srcdir)/m4/error.m4 \ + $(top_srcdir)/m4/euidaccess-stat.m4 \ + $(top_srcdir)/m4/euidaccess.m4 $(top_srcdir)/m4/exclude.m4 \ + $(top_srcdir)/m4/exitfail.m4 $(top_srcdir)/m4/extensions.m4 \ + $(top_srcdir)/m4/fchdir.m4 $(top_srcdir)/m4/fcntl-safer.m4 \ + $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/fd-reopen.m4 \ + $(top_srcdir)/m4/file-type.m4 $(top_srcdir)/m4/fileblocks.m4 \ + $(top_srcdir)/m4/filemode.m4 $(top_srcdir)/m4/filenamecat.m4 \ + $(top_srcdir)/m4/flexmember.m4 $(top_srcdir)/m4/fnmatch.m4 \ + $(top_srcdir)/m4/fpending.m4 $(top_srcdir)/m4/fprintftime.m4 \ + $(top_srcdir)/m4/free.m4 $(top_srcdir)/m4/fstypename.m4 \ + $(top_srcdir)/m4/fsusage.m4 $(top_srcdir)/m4/ftruncate.m4 \ + $(top_srcdir)/m4/fts.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/getdate.m4 $(top_srcdir)/m4/getdelim.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/getndelim2.m4 \ + $(top_srcdir)/m4/getopt.m4 $(top_srcdir)/m4/getpagesize.m4 \ + $(top_srcdir)/m4/getpass.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/glibc21.m4 \ + $(top_srcdir)/m4/gnulib-common.m4 \ + $(top_srcdir)/m4/gnulib-comp.m4 \ + $(top_srcdir)/m4/group-member.m4 \ + $(top_srcdir)/m4/hard-locale.m4 $(top_srcdir)/m4/hash.m4 \ + $(top_srcdir)/m4/host-os.m4 $(top_srcdir)/m4/human.m4 \ + $(top_srcdir)/m4/i-ring.m4 $(top_srcdir)/m4/iconv.m4 \ + $(top_srcdir)/m4/idcache.m4 $(top_srcdir)/m4/inet_ntop.m4 \ + $(top_srcdir)/m4/inline.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/isapipe.m4 $(top_srcdir)/m4/jm-macros.m4 \ + $(top_srcdir)/m4/jm-winsz1.m4 $(top_srcdir)/m4/jm-winsz2.m4 \ + $(top_srcdir)/m4/lchmod.m4 $(top_srcdir)/m4/lchown.m4 \ + $(top_srcdir)/m4/lib-check.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/link-follow.m4 \ + $(top_srcdir)/m4/localcharset.m4 \ + $(top_srcdir)/m4/long-options.m4 \ + $(top_srcdir)/m4/longdouble.m4 $(top_srcdir)/m4/longlong.m4 \ + $(top_srcdir)/m4/ls-mntd-fs.m4 $(top_srcdir)/m4/lstat.m4 \ + $(top_srcdir)/m4/mbchar.m4 $(top_srcdir)/m4/mbiter.m4 \ + $(top_srcdir)/m4/mbrtowc.m4 $(top_srcdir)/m4/mbscasecmp.m4 \ + $(top_srcdir)/m4/mbstate_t.m4 $(top_srcdir)/m4/mbswidth.m4 \ + $(top_srcdir)/m4/md5.m4 $(top_srcdir)/m4/memcasecmp.m4 \ + $(top_srcdir)/m4/memchr.m4 $(top_srcdir)/m4/memcmp.m4 \ + $(top_srcdir)/m4/memcoll.m4 $(top_srcdir)/m4/memcpy.m4 \ + $(top_srcdir)/m4/memmove.m4 $(top_srcdir)/m4/mempcpy.m4 \ + $(top_srcdir)/m4/memrchr.m4 $(top_srcdir)/m4/memset.m4 \ + $(top_srcdir)/m4/memxfrm.m4 $(top_srcdir)/m4/mkancesdirs.m4 \ + $(top_srcdir)/m4/mkdir-p.m4 $(top_srcdir)/m4/mkdir-slash.m4 \ + $(top_srcdir)/m4/mkstemp.m4 $(top_srcdir)/m4/mktime.m4 \ + $(top_srcdir)/m4/modechange.m4 $(top_srcdir)/m4/mountlist.m4 \ + $(top_srcdir)/m4/mpsort.m4 $(top_srcdir)/m4/nanosleep.m4 \ + $(top_srcdir)/m4/netinet_in_h.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/openat.m4 $(top_srcdir)/m4/pathmax.m4 \ + $(top_srcdir)/m4/perl.m4 $(top_srcdir)/m4/physmem.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/posixtm.m4 \ + $(top_srcdir)/m4/posixver.m4 $(top_srcdir)/m4/prereq.m4 \ + $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/putenv.m4 \ + $(top_srcdir)/m4/quote.m4 $(top_srcdir)/m4/quotearg.m4 \ + $(top_srcdir)/m4/randint.m4 $(top_srcdir)/m4/randperm.m4 \ + $(top_srcdir)/m4/randread.m4 $(top_srcdir)/m4/readlink.m4 \ + $(top_srcdir)/m4/readtokens.m4 $(top_srcdir)/m4/readutmp.m4 \ + $(top_srcdir)/m4/regex.m4 \ + $(top_srcdir)/m4/rename-dest-slash.m4 \ + $(top_srcdir)/m4/rename.m4 $(top_srcdir)/m4/rmdir-errno.m4 \ + $(top_srcdir)/m4/rmdir.m4 $(top_srcdir)/m4/root-dev-ino.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/setenv.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/snprintf.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-time.m4 \ + $(top_srcdir)/m4/stdarg.m4 $(top_srcdir)/m4/stdbool.m4 \ + $(top_srcdir)/m4/stdint.m4 $(top_srcdir)/m4/stdint_h.m4 \ + $(top_srcdir)/m4/stdio-safer.m4 $(top_srcdir)/m4/stdio_h.m4 \ + $(top_srcdir)/m4/stdlib-safer.m4 $(top_srcdir)/m4/stdlib_h.m4 \ + $(top_srcdir)/m4/stpcpy.m4 $(top_srcdir)/m4/strcspn.m4 \ + $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strftime.m4 \ + $(top_srcdir)/m4/string_h.m4 $(top_srcdir)/m4/strndup.m4 \ + $(top_srcdir)/m4/strnlen.m4 $(top_srcdir)/m4/strnumcmp.m4 \ + $(top_srcdir)/m4/strpbrk.m4 $(top_srcdir)/m4/strtod.m4 \ + $(top_srcdir)/m4/strtoimax.m4 $(top_srcdir)/m4/strtol.m4 \ + $(top_srcdir)/m4/strtoll.m4 $(top_srcdir)/m4/strtoul.m4 \ + $(top_srcdir)/m4/strtoull.m4 $(top_srcdir)/m4/strtoumax.m4 \ + $(top_srcdir)/m4/strverscmp.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/tempname.m4 $(top_srcdir)/m4/time_h.m4 \ + $(top_srcdir)/m4/time_r.m4 $(top_srcdir)/m4/timespec.m4 \ + $(top_srcdir)/m4/tm_gmtoff.m4 $(top_srcdir)/m4/tzset.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/unlinkdir.m4 $(top_srcdir)/m4/unlocked-io.m4 \ + $(top_srcdir)/m4/uptime.m4 $(top_srcdir)/m4/userspec.m4 \ + $(top_srcdir)/m4/utimbuf.m4 $(top_srcdir)/m4/utime.m4 \ + $(top_srcdir)/m4/utimecmp.m4 $(top_srcdir)/m4/utimens.m4 \ + $(top_srcdir)/m4/utimes-null.m4 $(top_srcdir)/m4/utimes.m4 \ + $(top_srcdir)/m4/vasnprintf.m4 $(top_srcdir)/m4/vasprintf.m4 \ + $(top_srcdir)/m4/wchar.m4 $(top_srcdir)/m4/wchar_t.m4 \ + $(top_srcdir)/m4/wctype.m4 $(top_srcdir)/m4/wcwidth.m4 \ + $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xalloc.m4 \ + $(top_srcdir)/m4/xfts.m4 $(top_srcdir)/m4/xgetcwd.m4 \ + $(top_srcdir)/m4/xnanosleep.m4 $(top_srcdir)/m4/xstrndup.m4 \ + $(top_srcdir)/m4/xstrtod.m4 $(top_srcdir)/m4/xstrtol.m4 \ + $(top_srcdir)/m4/yesno.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/lib/config.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ABSOLUTE_DIRENT_H = @ABSOLUTE_DIRENT_H@ +ABSOLUTE_FCNTL_H = @ABSOLUTE_FCNTL_H@ +ABSOLUTE_INTTYPES_H = @ABSOLUTE_INTTYPES_H@ +ABSOLUTE_NETINET_IN_H = @ABSOLUTE_NETINET_IN_H@ +ABSOLUTE_STDINT_H = @ABSOLUTE_STDINT_H@ +ABSOLUTE_STDIO_H = @ABSOLUTE_STDIO_H@ +ABSOLUTE_STDLIB_H = @ABSOLUTE_STDLIB_H@ +ABSOLUTE_STRING_H = @ABSOLUTE_STRING_H@ +ABSOLUTE_SYS_SOCKET_H = @ABSOLUTE_SYS_SOCKET_H@ +ABSOLUTE_SYS_STAT_H = @ABSOLUTE_SYS_STAT_H@ +ABSOLUTE_SYS_TIME_H = @ABSOLUTE_SYS_TIME_H@ +ABSOLUTE_TIME_H = @ABSOLUTE_TIME_H@ +ABSOLUTE_UNISTD_H = @ABSOLUTE_UNISTD_H@ +ABSOLUTE_WCHAR_H = @ABSOLUTE_WCHAR_H@ +ABSOLUTE_WCTYPE_H = @ABSOLUTE_WCTYPE_H@ +ACLOCAL = @ACLOCAL@ +ALLOCA = @ALLOCA@ +ALLOCA_H = @ALLOCA_H@ +AMTAR = @AMTAR@ +ARPA_INET_H = @ARPA_INET_H@ +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@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFAULT_POSIX2_VERSION = @DEFAULT_POSIX2_VERSION@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DF_PROG = @DF_PROG@ +DIRENT_H = @DIRENT_H@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EOVERFLOW = @EOVERFLOW@ +EXEEXT = @EXEEXT@ +FCNTL_H = @FCNTL_H@ +FNMATCH_H = @FNMATCH_H@ +GETLOADAVG_LIBS = @GETLOADAVG_LIBS@ +GETOPT_H = @GETOPT_H@ +GLIBC21 = @GLIBC21@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GNULIB_CHOWN = @GNULIB_CHOWN@ +GNULIB_DUP2 = @GNULIB_DUP2@ +GNULIB_FCHDIR = @GNULIB_FCHDIR@ +GNULIB_FPRINTF_POSIX = @GNULIB_FPRINTF_POSIX@ +GNULIB_FTRUNCATE = @GNULIB_FTRUNCATE@ +GNULIB_GETCWD = @GNULIB_GETCWD@ +GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@ +GNULIB_GETSUBOPT = @GNULIB_GETSUBOPT@ +GNULIB_IMAXABS = @GNULIB_IMAXABS@ +GNULIB_IMAXDIV = @GNULIB_IMAXDIV@ +GNULIB_MBSCASECMP = @GNULIB_MBSCASECMP@ +GNULIB_MBSCASESTR = @GNULIB_MBSCASESTR@ +GNULIB_MBSCHR = @GNULIB_MBSCHR@ +GNULIB_MBSCSPN = @GNULIB_MBSCSPN@ +GNULIB_MBSLEN = @GNULIB_MBSLEN@ +GNULIB_MBSNCASECMP = @GNULIB_MBSNCASECMP@ +GNULIB_MBSPBRK = @GNULIB_MBSPBRK@ +GNULIB_MBSPCASECMP = @GNULIB_MBSPCASECMP@ +GNULIB_MBSRCHR = @GNULIB_MBSRCHR@ +GNULIB_MBSSEP = @GNULIB_MBSSEP@ +GNULIB_MBSSPN = @GNULIB_MBSSPN@ +GNULIB_MBSSTR = @GNULIB_MBSSTR@ +GNULIB_MBSTOK_R = @GNULIB_MBSTOK_R@ +GNULIB_MEMMEM = @GNULIB_MEMMEM@ +GNULIB_MEMPCPY = @GNULIB_MEMPCPY@ +GNULIB_MEMRCHR = @GNULIB_MEMRCHR@ +GNULIB_MKDTEMP = @GNULIB_MKDTEMP@ +GNULIB_MKSTEMP = @GNULIB_MKSTEMP@ +GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@ +GNULIB_READLINK = @GNULIB_READLINK@ +GNULIB_SNPRINTF = @GNULIB_SNPRINTF@ +GNULIB_SPRINTF_POSIX = @GNULIB_SPRINTF_POSIX@ +GNULIB_STPCPY = @GNULIB_STPCPY@ +GNULIB_STPNCPY = @GNULIB_STPNCPY@ +GNULIB_STRCASESTR = @GNULIB_STRCASESTR@ +GNULIB_STRCHRNUL = @GNULIB_STRCHRNUL@ +GNULIB_STRDUP = @GNULIB_STRDUP@ +GNULIB_STRNDUP = @GNULIB_STRNDUP@ +GNULIB_STRNLEN = @GNULIB_STRNLEN@ +GNULIB_STRPBRK = @GNULIB_STRPBRK@ +GNULIB_STRSEP = @GNULIB_STRSEP@ +GNULIB_STRTOIMAX = @GNULIB_STRTOIMAX@ +GNULIB_STRTOK_R = @GNULIB_STRTOK_R@ +GNULIB_STRTOUMAX = @GNULIB_STRTOUMAX@ +GNULIB_VFPRINTF_POSIX = @GNULIB_VFPRINTF_POSIX@ +GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@ +GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@ +GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@ +GNU_PACKAGE = @GNU_PACKAGE@ +GREP = @GREP@ +HAVE_DECL_GETLOGIN_R = @HAVE_DECL_GETLOGIN_R@ +HAVE_DECL_IMAXABS = @HAVE_DECL_IMAXABS@ +HAVE_DECL_IMAXDIV = @HAVE_DECL_IMAXDIV@ +HAVE_DECL_MEMMEM = @HAVE_DECL_MEMMEM@ +HAVE_DECL_MEMRCHR = @HAVE_DECL_MEMRCHR@ +HAVE_DECL_SNPRINTF = @HAVE_DECL_SNPRINTF@ +HAVE_DECL_STRDUP = @HAVE_DECL_STRDUP@ +HAVE_DECL_STRNCASECMP = @HAVE_DECL_STRNCASECMP@ +HAVE_DECL_STRNDUP = @HAVE_DECL_STRNDUP@ +HAVE_DECL_STRNLEN = @HAVE_DECL_STRNLEN@ +HAVE_DECL_STRTOIMAX = @HAVE_DECL_STRTOIMAX@ +HAVE_DECL_STRTOK_R = @HAVE_DECL_STRTOK_R@ +HAVE_DECL_STRTOUMAX = @HAVE_DECL_STRTOUMAX@ +HAVE_DECL_VSNPRINTF = @HAVE_DECL_VSNPRINTF@ +HAVE_DUP2 = @HAVE_DUP2@ +HAVE_FTRUNCATE = @HAVE_FTRUNCATE@ +HAVE_GETSUBOPT = @HAVE_GETSUBOPT@ +HAVE_INTTYPES_H = @HAVE_INTTYPES_H@ +HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@ +HAVE_MEMPCPY = @HAVE_MEMPCPY@ +HAVE_MKDTEMP = @HAVE_MKDTEMP@ +HAVE_NETINET_IN_H = @HAVE_NETINET_IN_H@ +HAVE_READLINK = @HAVE_READLINK@ +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_STDINT_H = @HAVE_STDINT_H@ +HAVE_STPCPY = @HAVE_STPCPY@ +HAVE_STPNCPY = @HAVE_STPNCPY@ +HAVE_STRCASECMP = @HAVE_STRCASECMP@ +HAVE_STRCASESTR = @HAVE_STRCASESTR@ +HAVE_STRCHRNUL = @HAVE_STRCHRNUL@ +HAVE_STRNDUP = @HAVE_STRNDUP@ +HAVE_STRPBRK = @HAVE_STRPBRK@ +HAVE_STRSEP = @HAVE_STRSEP@ +HAVE_STRUCT_TIMEVAL = @HAVE_STRUCT_TIMEVAL@ +HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@ +HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_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_UNISTD_H = @HAVE_UNISTD_H@ +HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@ +HAVE_WCTYPE_H = @HAVE_WCTYPE_H@ +HAVE_WINSOCK2_H = @HAVE_WINSOCK2_H@ +HAVE_WINT_T = @HAVE_WINT_T@ +HAVE_WS2TCPIP_H = @HAVE_WS2TCPIP_H@ +HAVE__BOOL = @HAVE__BOOL@ +HELP2MAN = @HELP2MAN@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +INTTYPES_H = @INTTYPES_H@ +KMEM_GROUP = @KMEM_GROUP@ +LDFLAGS = @LDFLAGS@ +LIBCOREUTILS_LIBDEPS = @LIBCOREUTILS_LIBDEPS@ +LIBCOREUTILS_LTLIBDEPS = @LIBCOREUTILS_LTLIBDEPS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIB_ACL = @LIB_ACL@ +LIB_ACL_TRIVIAL = @LIB_ACL_TRIVIAL@ +LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@ +LIB_CRYPT = @LIB_CRYPT@ +LIB_EACCESS = @LIB_EACCESS@ +LIB_FDATASYNC = @LIB_FDATASYNC@ +LIB_GETHRXTIME = @LIB_GETHRXTIME@ +LIB_NANOSLEEP = @LIB_NANOSLEEP@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MAN = @MAN@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGMERGE = @MSGMERGE@ +NEED_SETGID = @NEED_SETGID@ +NETINET_IN_H = @NETINET_IN_H@ +OBJEXT = @OBJEXT@ +OPTIONAL_BIN_PROGS = @OPTIONAL_BIN_PROGS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +POSUB = @POSUB@ +POW_LIB = @POW_LIB@ +PRIPTR_PREFIX = @PRIPTR_PREFIX@ +PRI_MACROS_BROKEN = @PRI_MACROS_BROKEN@ +PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@ +RANLIB = @RANLIB@ +REPLACE_CHOWN = @REPLACE_CHOWN@ +REPLACE_FCHDIR = @REPLACE_FCHDIR@ +REPLACE_FPRINTF = @REPLACE_FPRINTF@ +REPLACE_GETCWD = @REPLACE_GETCWD@ +REPLACE_GETTIMEOFDAY = @REPLACE_GETTIMEOFDAY@ +REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@ +REPLACE_MKSTEMP = @REPLACE_MKSTEMP@ +REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@ +REPLACE_PRINTF = @REPLACE_PRINTF@ +REPLACE_SNPRINTF = @REPLACE_SNPRINTF@ +REPLACE_SPRINTF = @REPLACE_SPRINTF@ +REPLACE_STRPTIME = @REPLACE_STRPTIME@ +REPLACE_TIMEGM = @REPLACE_TIMEGM@ +REPLACE_VFPRINTF = @REPLACE_VFPRINTF@ +REPLACE_VPRINTF = @REPLACE_VPRINTF@ +REPLACE_VSNPRINTF = @REPLACE_VSNPRINTF@ +REPLACE_VSPRINTF = @REPLACE_VSPRINTF@ +SEQ_LIBM = @SEQ_LIBM@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@ +SIZE_T_SUFFIX = @SIZE_T_SUFFIX@ +STDBOOL_H = @STDBOOL_H@ +STDINT_H = @STDINT_H@ +STRIP = @STRIP@ +SYS_SOCKET_H = @SYS_SOCKET_H@ +SYS_STAT_H = @SYS_STAT_H@ +SYS_TIME_H = @SYS_TIME_H@ +SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ +TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@ +U = @U@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +WCHAR_H = @WCHAR_H@ +WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@ +WCTYPE_H = @WCTYPE_H@ +WINT_T_SUFFIX = @WINT_T_SUFFIX@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +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@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +gl_LIBOBJS = @gl_LIBOBJS@ +gl_LTLIBOBJS = @gl_LTLIBOBJS@ +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@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +EXTRA_DIST = $(TESTS) +TESTS_ENVIRONMENT = \ + top_srcdir=$(top_srcdir) \ + abs_top_builddir=$(abs_top_builddir) \ + srcdir=$(srcdir) \ + PACKAGE_VERSION=$(PACKAGE_VERSION) \ + PERL="$(PERL)" \ + BUILD_SRC_DIR="`pwd`/../../src" \ + CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \ + PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH" \ + CONFIG_HEADER=$(CONFIG_HEADER) \ + REPLACE_GETCWD=$(REPLACE_GETCWD) \ + host_os=$(host_os) \ + PROG=`../../src/basename -- "$$tst"` + + +# Do not choose a name that is a shell keyword like 'if', or a +# commonly-used utility like 'cat' or 'test', as the name of a test. +# Otherwise, VPATH builds will fail on hosts like Solaris, since they +# will expand 'if test ...' to 'if .../test ...', and the '.../test' +# will execute the test script rather than the standard utility. +TESTS = \ + pr \ + df-P \ + pwd-unreadable-parent \ + cut \ + wc-files0-from \ + wc-files0 \ + cat-proc \ + base64 \ + basename \ + close-stdout \ + csplit \ + date \ + date-sec \ + df \ + dirname \ + expand \ + false-status \ + fold \ + head-c \ + head-elide-tail \ + head-pos \ + mknod \ + nice \ + nl \ + nohup \ + paste-no-nl \ + pathchk1 \ + printf \ + printf-hex \ + pwd-long \ + sha224sum \ + sha256sum \ + sha384sum \ + sha512sum \ + shuf \ + sort-compress \ + sort-merge \ + sort-rand \ + split-a \ + split-fail \ + split-l \ + stat-fmt \ + stat-printf \ + tac-continue \ + test-diag \ + tty-eof + +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/misc/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu tests/misc/Makefile +.PRECIOUS: 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__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(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 +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + srcdir=$(srcdir); export srcdir; \ + list=' $(TESTS) '; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *$$ws$$tst$$ws*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *$$ws$$tst$$ws*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + echo "SKIP: $$tst"; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + skipped="($$skip tests were not run)"; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + test -z "$$skipped" || echo "$$skipped"; \ + test -z "$$report" || echo "$$report"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + else :; fi + +distdir: $(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 $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-TESTS check-am clean clean-generic \ + distclean distclean-generic distdir dvi dvi-am html html-am \ + info info-am install install-am 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-pdf install-pdf-am install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-generic pdf pdf-am ps ps-am uninstall \ + uninstall-am + +# 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/tests/misc/base64 b/tests/misc/base64 new file mode 100755 index 0000000..70295fb --- /dev/null +++ b/tests/misc/base64 @@ -0,0 +1,169 @@ +#!/bin/sh +# -*- perl -*- +# Exercise base64. + +# Copyright (C) 2006, 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +: ${PERL=perl} +: ${srcdir=.} + +$PERL -e 1 > /dev/null 2>&1 || { + echo 1>&2 "$0: configure didn't find a usable version of Perl," \ + "so can't run this test" + exit 77 +} + +exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF +require 5.003; +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localisation of executable's ouput. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +# Return the encoding of a string of N 'a's. +sub enc($) +{ + my ($n) = @_; + my %remainder = ( 0 => '', 1 => 'YQ==', 2 => 'YWE=' ); + return 'YWFh' x ($n / 3) . $remainder{$n % 3}; +} + +# Construct an encoded string of length 4KB, using 3K "a"s. +my $a3k = enc 3072; +my @a3k_nl; +# A few copies, each with different number of newlines at the start. +for my $k (0..3) + { + (my $t = $a3k) =~ s/^/"\n"x $k/e; + push @a3k_nl, $t; + } + +# Return a copy of S, with newlines inserted every WIDTH bytes. +# Ensure that the result (if not the empty string) is newline-terminated. +sub wrap($$) +{ + my ($s, $width) = @_; + $s =~ s/(.{$width})/$1\n/g; + substr ($s, -1, 1) ne "\n" + and $s .= "\n"; + return $s; +} + +my @Tests = + ( + ['empty', {IN=>''}, {OUT=>""}], + ['inout', {IN=>'a'}, {OUT=>"YQ==\n"}], + ['wrap', '--wrap 0', {IN=>'foo'}, {OUT=>'Zm9v'}], + ['wrap5-39', '--wrap=5', {IN=>'a' x 39}, {OUT=>wrap enc(39),5}], + ['wrap5-40', '--wrap=5', {IN=>'a' x 40}, {OUT=>wrap enc(40),5}], + ['wrap5-41', '--wrap=5', {IN=>'a' x 41}, {OUT=>wrap enc(41),5}], + ['wrap5-42', '--wrap=5', {IN=>'a' x 42}, {OUT=>wrap enc(42),5}], + ['wrap5-43', '--wrap=5', {IN=>'a' x 43}, {OUT=>wrap enc(43),5}], + ['wrap5-44', '--wrap=5', {IN=>'a' x 44}, {OUT=>wrap enc(44),5}], + ['wrap5-45', '--wrap=5', {IN=>'a' x 45}, {OUT=>wrap enc(45),5}], + ['wrap5-46', '--wrap=5', {IN=>'a' x 46}, {OUT=>wrap enc(46),5}], + + ['buf-1', '--decode', {IN=>enc 1}, {OUT=>'a' x 1}], + ['buf-2', '--decode', {IN=>enc 2}, {OUT=>'a' x 2}], + ['buf-3', '--decode', {IN=>enc 3}, {OUT=>'a' x 3}], + ['buf-4', '--decode', {IN=>enc 4}, {OUT=>'a' x 4}], + # 4KB worth of input. + ['buf-4k0', '--decode', {IN=>enc 3072+0}, {OUT=>'a' x (3072+0)}], + ['buf-4k1', '--decode', {IN=>enc 3072+1}, {OUT=>'a' x (3072+1)}], + ['buf-4k2', '--decode', {IN=>enc 3072+2}, {OUT=>'a' x (3072+2)}], + ['buf-4k3', '--decode', {IN=>enc 3072+3}, {OUT=>'a' x (3072+3)}], + ['buf-4km1','--decode', {IN=>enc 3072-1}, {OUT=>'a' x (3072-1)}], + ['buf-4km2','--decode', {IN=>enc 3072-2}, {OUT=>'a' x (3072-2)}], + ['buf-4km3','--decode', {IN=>enc 3072-3}, {OUT=>'a' x (3072-3)}], + ['buf-4km4','--decode', {IN=>enc 3072-4}, {OUT=>'a' x (3072-4)}], + + # Exercise the case in which the final base-64 byte is + # in a buffer all by itself. + ['b4k-1', '--decode', {IN=>$a3k_nl[1]}, {OUT=>'a' x (3072+0)}], + ['b4k-2', '--decode', {IN=>$a3k_nl[2]}, {OUT=>'a' x (3072+0)}], + ['b4k-3', '--decode', {IN=>$a3k_nl[3]}, {OUT=>'a' x (3072+0)}], + + ['baddecode', '--decode', {IN=>'a'}, {OUT=>""}, + {ERR_SUBST => 's/.*: invalid input//'}, {ERR => "\n"}, {EXIT => 1}], + ['baddecode2', '--decode', {IN=>'ab'}, {OUT=>"i"}, + {ERR_SUBST => 's/.*: invalid input//'}, {ERR => "\n"}, {EXIT => 1}], + ['baddecode3', '--decode', {IN=>'Zzz'}, {OUT=>"g<"}, + {ERR_SUBST => 's/.*: invalid input//'}, {ERR => "\n"}, {EXIT => 1}], + ['baddecode4', '--decode', {IN=>'Zz='}, {OUT=>"g"}, + {ERR_SUBST => 's/.*: invalid input//'}, {ERR => "\n"}, {EXIT => 1}], + ['baddecode5', '--decode', {IN=>'Z==='}, {OUT=>""}, + {ERR_SUBST => 's/.*: invalid input//'}, {ERR => "\n"}, {EXIT => 1}] + ); + +# For each non-failing test, create a --decode test using the +# expected output as input. Also, add tests inserting newlines. +my @new; +foreach my $t (@Tests) + { + my $exit_val; + my $in; + my @out; + + # If the test has a single option of "--decode", then skip it. + !ref $t->[1] && $t->[1] eq '--decode' + and next; + + foreach my $e (@$t) + { + ref $e && ref $e eq 'HASH' + or next; + defined $e->{EXIT} + and $exit_val = $e->{EXIT}; + defined $e->{IN} + and $in = $e->{IN}; + if (defined $e->{OUT}) + { + my $t = $e->{OUT}; + push @out, $t; + my $len = length $t; + foreach my $i (0..$len) + { + my $u = $t; + substr ($u, $i, 0) = "\n"; + push @out, $u; + 10 <= $i + and last; + } + } + } + $exit_val + and next; + + my $i = 0; + foreach my $o (@out) + { + push @new, ["d$i-$t->[0]", '--decode', {IN => $o}, {OUT => $in}]; + ++$i; + } + } +push @Tests, @new; + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; +EOF diff --git a/tests/misc/basename b/tests/misc/basename new file mode 100755 index 0000000..89d96ff --- /dev/null +++ b/tests/misc/basename @@ -0,0 +1,95 @@ +#!/bin/sh +# -*-perl-*- + +# Copyright (C) 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +: ${PERL=perl} +: ${srcdir=.} + +$PERL -e 1 > /dev/null 2>&1 || { + echo 1>&2 "$0: configure didn't find a usable version of Perl," \ + "so can't run this test" + exit 77 +} + +d=$srcdir/.. +exec $PERL -w -I$d -MCoreutils -- - << \EOF +require 5.003; +use strict; +use File::stat; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localisation of executable's ouput. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $stat_single = stat('/'); +my $stat_double = stat('//'); +my $double_slash = ($stat_single->dev == $stat_double->dev + && $stat_single->ino == $stat_double->ino) ? '/' : '//'; + +my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; + +my @Tests = + ( + ['fail-1', {ERR => "$prog: missing operand\n" + . "Try `$prog --help' for more information.\n"}, {EXIT => '1'}], + ['fail-2', qw(a b c), {ERR => "$prog: extra operand `c'\n" + . "Try `$prog --help' for more information.\n"}, {EXIT => '1'}], + + ['a', qw(d/f), {OUT => 'f'}], + ['b', qw(/d/f), {OUT => 'f'}], + ['c', qw(d/f/), {OUT => 'f'}], + ['d', qw(d/f//), {OUT => 'f'}], + ['e', qw(f), {OUT => 'f'}], + ['f', qw(/), {OUT => '/'}], + ['g', qw(//), {OUT => "$double_slash"}], + ['h', qw(///), {OUT => '/'}], + ['i', qw(///a///), {OUT => 'a'}], + ['j', qw(''), {OUT => ''}], + ['1', qw(f.s .s), {OUT => 'f'}], + ['2', qw(fs s), {OUT => 'f'}], + ['3', qw(fs fs), {OUT => 'fs'}], + ['4', qw(fs/ s), {OUT => 'f'}], + ['5', qw(dir/file.suf .suf), {OUT => 'file'}], + ['6', qw(// /), {OUT => "$double_slash"}], + ['7', qw(// //), {OUT => "$double_slash"}], + ['8', qw(fs x), {OUT => 'fs'}], + ['9', qw(fs ''), {OUT => 'fs'}], + ['10', qw(fs/ s/), {OUT => 'fs'}], + ); + +# Append a newline to end of each expected `OUT' string. +my $t; +foreach $t (@Tests) + { + my $arg1 = $t->[1]; + my $e; + foreach $e (@$t) + { + $e->{OUT} = "$e->{OUT}\n" + if ref $e eq 'HASH' and exists $e->{OUT}; + } + } + +my $save_temps = $ENV{SAVE_TEMPS}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; +EOF diff --git a/tests/misc/cat-proc b/tests/misc/cat-proc new file mode 100755 index 0000000..22f3847 --- /dev/null +++ b/tests/misc/cat-proc @@ -0,0 +1,60 @@ +#!/bin/sh +# Ensure that cat -E produces same output as cat, module `$'s, +# even when applied to a file in /proc. + +# Copyright (C) 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + cat --version +fi + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +f=/proc/cpuinfo +test -f $f \ + || { + echo "$0: no $f skipping this test" 1>&2 + (exit 77); exit 77 + } + +fail=0 + +# Yes, parts of /proc/cpuinfo might change between cat runs. +# If that happens, consider choosing a file that's less likely to change, +# or just filter out the changing lines. The sed filter should help +# to avoid any spurious numeric differences. +cat -E $f | sed 's/[0-9][0-9]*/D/g' | tr -d '$' > out || fail=1 +cat $f | sed 's/[0-9][0-9]*/D/g' | tr -d '$' > exp || fail=1 + +cmp out exp || fail=1 +test $fail = 1 && diff out exp 2> /dev/null + +(exit $fail); exit $fail diff --git a/tests/misc/close-stdout b/tests/misc/close-stdout new file mode 100755 index 0000000..dd8bbc5 --- /dev/null +++ b/tests/misc/close-stdout @@ -0,0 +1,77 @@ +#!/bin/sh +# Ensure that several programs work fine, even with stdout initially closed. +# This is effectively a test of closeout.c's close_stdout function. + +# Copyright (C) 2004, 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + rm --version +fi + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +PATH="$pwd/../..:$PATH" +export PATH + +fail=0 + +# Ensure these exit successfully, even though stdout is closed, +# because they generate no output. +touch a +cp a b >&- || fail=1 +test -f b || fail=1 +chmod o-w . >&- || fail=1 +ln a c >&- || fail=1 +rm c >&- || fail=1 +mkdir d >&- || fail=1 +mv d e >&- || fail=1 +rmdir e >&- || fail=1 +touch e >&- || fail=1 +sleep 0 >&- || fail=1 +"$pwd/../../src/true" >&- || fail=1 +"$pwd/../../src/printf" '' >&- || fail=1 + +# If >&- works, ensure these fail, because stdout is closed and they +# *do* generate output. >&- apparently does not work in HP-UX 11.23. +# This test is ineffective unless /dev/stdout also works. +if "$pwd/../../src/test" -w /dev/stdout >/dev/null && + "$pwd/../../src/test" ! -w /dev/stdout >&-; then + "$pwd/../../src/printf" 'foo' >&- 2>/dev/null && fail=1 + cp --verbose a b >&- 2>/dev/null && fail=1 +fi + +# Likewise for /dev/full, if /dev/full works. +if test -w /dev/full && test -c /dev/full; then + "$pwd/../../src/printf" 'foo' >/dev/full 2>/dev/null && fail=1 + cp --verbose a b >/dev/full 2>/dev/null && fail=1 +fi + +(exit $fail); exit $fail diff --git a/tests/misc/csplit b/tests/misc/csplit new file mode 100755 index 0000000..885d692 --- /dev/null +++ b/tests/misc/csplit @@ -0,0 +1,116 @@ +#!/bin/sh +# various csplit tests + +# Copyright (C) 2001, 2002, 2003, 2004, 2005 2006 Free Software +# Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + csplit --version +fi + +. $srcdir/../lang-default + +pwd=`pwd` +tmp=csplit.$$ +trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0 +trap '(exit $?); exit' 1 2 13 15 + +framework_failure=0 +mkdir $tmp || framework_failure=1 +cd $tmp || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +fail=0 + +# csplit could get a failed assertion to 2.0.17 +(echo a; echo; echo) > in +csplit in '/^$/' 2 > out || fail=1 +cat <<EOF > exp +2 +0 +2 +EOF +cmp out exp || fail=1 +test $fail = 1 && diff out exp 2> /dev/null +rm -f in out exp + +# Ensure that xx02 contains just two newlines. +# This would fail due to reading from freed buffer with coreutils-5.0.91. +printf '\n\n' > exp +cp xx02 out || fail=1 +cmp out exp || fail=1 +test $fail = 1 && diff out exp 2> /dev/null +rm -f in out exp + +# csplit would infloop +(echo; echo a) > in +csplit in '/a/-1' '{*}' > out || fail=1 +cat <<EOF > exp +0 +3 +EOF +cmp out exp || fail=1 +test $fail = 1 && diff out exp 2> /dev/null +rm -f in out exp + +# `echo |csplit - 1 1' used to abort. +echo > in +csplit in 1 1 > out 2> err || fail=1 +cat <<EOF > exp +0 +0 +1 +EOF +cmp out exp || fail=1 +test $fail = 1 && diff out exp 2> /dev/null +cat <<\EOF > experr +csplit: warning: line number `1' is the same as preceding line number +EOF +cmp err experr || fail=1 +test $fail = 1 && diff err experr 2> /dev/null +rm -f in out exp err experr + +# make sure `csplit FILE 0' fails. +echo > in +csplit in 0 > out 2> err && fail=1 +csplit in 2 1 > out 2>> err && fail=1 +csplit in 3 3 > out 2>> err && fail=1 +cat <<\EOF > experr +csplit: 0: line number must be greater than zero +csplit: line number `1' is smaller than preceding line number, 2 +csplit: warning: line number `3' is the same as preceding line number +csplit: `3': line number out of range +EOF +cmp err experr || fail=1 +test $fail = 1 && diff err experr 2> /dev/null + +# Ensure that lines longer than the initial buffer length don't cause +# trouble (e.g. reading from freed memory, resulting in corrupt output). +# This test failed at least in coreutils-5.2.1 and 5.3.0, and was fixed +# in 5.3.1. +rm -f in out exp err experr xx?? +printf 'x%8199s\nx\n%8199s\nx\n' x x > in +csplit in '/x\{1\}/' '{*}' > /dev/null || fail=1 +cat xx?? | cmp - in || fail=1 + +(exit $fail); exit $fail diff --git a/tests/misc/cut b/tests/misc/cut new file mode 100755 index 0000000..3db4c9b --- /dev/null +++ b/tests/misc/cut @@ -0,0 +1,51 @@ +#!/bin/sh +# Test "cut". -*- perl -*- + +# Copyright (C) 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +: ${PERL=perl} +: ${srcdir=.} + +$PERL -e 1 > /dev/null 2>&1 || { + echo 1>&2 "$0: configure didn't find a usable version of Perl," \ + "so can't run this test" + exit 77 +} + +exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF +require 5.003; +use strict; + +(my $ME = $0) =~ s|.*/||; + +# Turn off localisation of executable's ouput. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my @Tests = + ( + # Provoke a double-free in cut from coreutils-6.7. + ['dbl-free', '-f2-', {IN=>{f=>'x'}}, {IN=>{g=>'y'}}, {OUT=>"x\ny\n"}], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = 'cut'; +my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose); +exit $fail; +EOF diff --git a/tests/misc/date b/tests/misc/date new file mode 100755 index 0000000..0ff8345 --- /dev/null +++ b/tests/misc/date @@ -0,0 +1,323 @@ +#!/bin/sh +# Test "date". + +# Copyright (C) 2005-2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +: ${PERL=perl} +: ${srcdir=.} + +$PERL -e 1 > /dev/null 2>&1 || { + echo 1>&2 "$0: configure didn't find a usable version of Perl," \ + "so can't run this test" + exit 77 +} + +exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF +require 5.003; +use strict; + +(my $ME = $0) =~ s|.*/||; + +# Turn off localisation of executable's ouput. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +# Export TZ=UTC0 so that zone-dependent strings match. +$ENV{TZ} = 'UTC0'; + +my $t0 = '08:17:48'; +my $d0 = '1997-01-19'; +my $d1 = "$d0 $t0 +0"; + +my $ts = '08:17:49'; # next second +my $tm = '08:18:48'; # next minute +my $th = '09:17:48'; # next hour + +my $dd = '1997-01-20'; # next day +my $dw = '1997-01-26'; # next week +my $dm = '1997-02-19'; # next month +my $dy = '1998-01-19'; # next month + +my $fmt = "'+%Y-%m-%d %T'"; + +# Determine a number of seconds that will provoke an invalid +# time diagnostic from date. If possible, use a number that +# is less than 2^64, yet so large that it would cause the resulting +# tm_year value to be too large for a 32-bit int. But some systems +# (Solaris 8) have a buggy localtime that mistakenly accepts such +# invalid times and give garbage in tm_year. Other systems might +# have an int type that is wider than 32. So if this localtime +# call succeeds, use 2^64 as the number of seconds. +my $n_seconds = 72057594037927935; +my @d = localtime ($n_seconds); +my $year = $d[5]; +defined $year + and $n_seconds = '18446744073709551616'; + +my @Tests = + ( + # test-name, [option, option, ...] {OUT=>"expected-output"} + # + ['1', "-d '$d1' +'%% %a %A %b %B'", {OUT=>"% Sun Sunday Jan January"}], + + # [Actually, skip it on *all* systems. -- this Perl code is run at + # distribution-build-time, not at configure/test time. ] + + # Skip the test of %c on SunOS4 systems. Such systems would fail this + # test because their underlying strftime doesn't handle the %c format + # properly. GNU strftime must rely on the underlying host library + # function to get locale-dependent behavior, as strftime is the only + # portable interface to that behavior. + # ['2', "-d '$d1' +'%c'", {OUT=>"Sun Jan 19 $t0 1997"}], + + ['3', "-d '$d1' +'%d_%D_%e_%h_%H'", {OUT=>"19_01/19/97_19_Jan_08"}], + ['4', "-d '$d1' +'%I_%j_%k_%l_%m'", {OUT=>"08_019_ 8_ 8_01"}], + ['5', "-d '$d1' +'%M_%n_%p_%r'", {OUT=>"17_\n_AM_$t0 AM"}], + ['6', "-d '$d1' +'%s_%S_%t_%T'", {OUT=>"853661868_48_\t_$t0"}], + ['7', "-d '$d1' +'%U_%V_%w_%W'", {OUT=>"03_03_0_02"}], + ['8', "-d '$d1' +'%x_%X_%y_%Y'", {OUT=>"01/19/97_${t0}_97_1997"}], + ['9', "-d '$d1' +'%z'", {OUT=>"+0000"}], + + ['leap-1', "--date '02/29/1996 1 year' +%Y-%m-%d", {OUT=>"1997-03-01"}], + + ['U95-1', "--date '1995-1-1' +%U", {OUT=>"01"}], + ['U95-2', "--date '1995-1-7' +%U", {OUT=>"01"}], + ['U95-3', "--date '1995-1-8' +%U", {OUT=>"02"}], + + ['U92-1', "--date '1992-1-1' +%U", {OUT=>"00"}], + ['U92-2', "--date '1992-1-4' +%U", {OUT=>"00"}], + ['U92-3', "--date '1992-1-5' +%U", {OUT=>"01"}], + + ['V92-1', "--date '1992-1-1' +%V", {OUT=>"01"}], + ['V92-2', "--date '1992-1-5' +%V", {OUT=>"01"}], + ['V92-3', "--date '1992-1-6' +%V", {OUT=>"02"}], + + ['W92-1', "--date '1992-1-1' +%W", {OUT=>"00"}], + ['W92-2', "--date '1992-1-5' +%W", {OUT=>"00"}], + ['W92-3', "--date '1992-1-6' +%W", {OUT=>"01"}], + + ['millen-1', "--date '1998-1-1 3 years' +%Y", {OUT=>"2001"}], + + ['rel-0', "-d '$d1 now' '+%Y-%m-%d %T'", {OUT=>"$d0 $t0"}], + + ['rel-1a', "-d '$d1 yesterday' $fmt", {OUT=>"1997-01-18 $t0"}], + ['rel-1b', "-d '$d1 tomorrow' $fmt", {OUT=>"1997-01-20 $t0"}], + + ['rel-2a', "-d '$d1 6 years ago' $fmt", {OUT=>"1991-01-19 $t0"}], + ['rel-2b', "-d '$d1 7 months ago' $fmt", {OUT=>"1996-06-19 $t0"}], + ['rel-2c', "-d '$d1 8 weeks ago' $fmt", {OUT=>"1996-11-24 $t0"}], + ['rel-2d', "-d '$d1 1 day ago' $fmt", {OUT=>"1997-01-18 $t0"}], + ['rel-2e', "-d '$d1 2 hours ago' $fmt", {OUT=>"$d0 06:17:48"}], + ['rel-2f', "-d '$d1 3 minutes ago' $fmt", {OUT=>"$d0 08:14:48"}], + ['rel-2g', "-d '$d1 4 seconds ago' $fmt", {OUT=>"$d0 08:17:44"}], + + ['rel-3a', "-d '$d1 4 seconds ago' $fmt", {OUT=>"$d0 08:17:44"}], + + ['next-s', "-d '$d1 next second' '+%Y-%m-%d %T'", {OUT=>"$d0 $ts"}], + ['next-m', "-d '$d1 next minute' '+%Y-%m-%d %T'", {OUT=>"$d0 $tm"}], + ['next-h', "-d '$d1 next hour' '+%Y-%m-%d %T'", {OUT=>"$d0 $th"}], + ['next-d', "-d '$d1 next day' '+%Y-%m-%d %T'", {OUT=>"$dd $t0"}], + ['next-w', "-d '$d1 next week' '+%Y-%m-%d %T'", {OUT=>"$dw $t0"}], + ['next-mo', "-d '$d1 next month' '+%Y-%m-%d %T'", {OUT=>"$dm $t0"}], + ['next-y', "-d '$d1 next year' '+%Y-%m-%d %T'", {OUT=>"$dy $t0"}], + + ['utc-0', "-u -d '08/01/97 6:00' '+%D,%H:%M'", {OUT=>"08/01/97,06:00"}, + {ENV => 'TZ=UTC+4'}], + + ['utc-0a', "-u -d '08/01/97 6:00 UTC +4 hours' '+%D,%H:%M'", + {OUT=>"08/01/97,10:00"}], + # Make sure --file=FILE works with -u. + ['utc-1', "-u --file=f '+%Y-%m-%d %T'", + {AUX=>{f=>"$d0 $t0\n$d0 $t0"}}, + {OUT=>"$d0 $t0\n$d0 $t0"}, + {ENV => 'TZ=UTC+1'}], + + ['utc-1a', "-u --file=f '+%Y-%m-%d %T'", + {AUX=>{f=>"$d0 $t0 UTC +1 hour\n$d0 $t0 UTC +1 hour"}}, + {OUT=>"$d0 $th\n$d0 $th"}], + + # From the examples in the documentation. + ['date2sec-0', "-d '1970-01-01 00:00:01' +%s", {OUT=>"7201"}, + {ENV => 'TZ=UTC+2'}], + + # Same as above, but don't rely on TZ in environment. + ['date2sec-0a', "-d '1970-01-01 00:00:01 UTC +2 hours' +%s", + {OUT=>"7201"}], + + ['date2sec-1', "-d 2000-01-01 +%s", {OUT=>"946684800"}], + ['sec2date-0', "-d '1970-01-01 UTC 946684800 sec' +'%Y-%m-%d %T %z'", + {OUT=>"2000-01-01 00:00:00 +0000"}], + + ['this-m', "-d '$d0 $t0 this minute' $fmt", {OUT=>"$d0 $t0"}], + ['this-h', "-d '$d0 $t0 this hour' $fmt", {OUT=>"$d0 $t0"}], + ['this-w', "-d '$d0 $t0 this week' $fmt", {OUT=>"$d0 $t0"}], + ['this-mo', "-d '$d0 $t0 this month' $fmt", {OUT=>"$d0 $t0"}], + ['this-y', "-d '$d0 $t0 this year' $fmt", {OUT=>"$d0 $t0"}], + + ['risks-1', "-d 'Nov 10 1996' $fmt", {OUT=>"1996-11-10 00:00:00"}], + + # This one would pass if TZ (with any, or even no, value) were in + # the environment. + ['regress-1', "-u -d '1996-11-10 0:00:00 +0' $fmt", + {OUT=>"1996-11-10 00:00:00"}, + {ENV =>'LANG=C'}], + + + ['datevtime-1', "-d 000909 $fmt", {OUT=>"2000-09-09 00:00:00"}], + + # test for RFC-822 conformance + ['rfc822-1', "-R -d '$d1'", {OUT=>"Sun, 19 Jan 1997 08:17:48 +0000"}, + # Solaris 5.9's /bin/sh emits this diagnostic to stderr + # if you don't have support for the named locale. + {ERR_SUBST => q!s/^couldn't set locale correctly\n//!}, + {ENV => 'LC_ALL=de_DE TZ=UTC0'}], + + # Relative seconds, with time. fixed in 2.0j + ['relative-1', "--utc -d '1970-01-01 00:00:00 UTC +961062237 sec' $fmt", + {OUT=>"2000-06-15 09:43:57"}], + + # Relative seconds, no time. + ['relative-2', "--utc -d '1970-01-01 UTC +961062237 sec' $fmt", + {OUT=>"2000-06-15 09:43:57"}, + {ENV => 'TZ=UTC+1'}], + + # Relative days, no time, across time zones. + ['relative-3', "-I -d '2006-04-23 21 days ago'", {OUT=>"2006-04-02"}, + {ENV=>'TZ=PST8PDT,M4.1.0,M10.5.0'}], + + # This would infloop (or appear to) prior to coreutils-4.5.5, + # due to a bug in strftime.c. + ['wide-fmt', "-d '1999-06-01'", '+%3004Y', {OUT=>'0' x 3000 . "1999"}], + + # Ensure that we can parse MONTHNAME-DAY-YEAR. + ['moname-d-y', '--iso -d May-23-2003', {OUT=>"2003-05-23"}], + ['moname-d-y-r', '--rfc-3339=date -d May-23-2003', {OUT=>"2003-05-23"}], + + ['epoch', '--iso=sec -d @31536000', + {OUT=>"1971-01-01T00:00:00+0000"}], + ['epoch-r', '--rfc-3339=sec -d @31536000', + {OUT=>"1971-01-01 00:00:00+00:00"}], + + ['ns-10', '--iso=ns', '-d "1969-12-31 13:00:00.00000001-1100"', + {OUT=>"1970-01-01T00:00:00,000000010+0000"}], + ['ns-10-r', '--rfc-3339=ns', '-d "1969-12-31 13:00:00.00000001-1100"', + {OUT=>"1970-01-01 00:00:00.000000010+00:00"}], + + ['ns-max32', '--iso=ns', '-d "2038-01-19 03:14:07.999999999"', + {OUT=>"2038-01-19T03:14:07,999999999+0000"}], + ['ns-max32-r', '--rfc-3339=ns', '-d "2038-01-19 03:14:07.999999999"', + {OUT=>"2038-01-19 03:14:07.999999999+00:00"}], + + ['tz-1', '+%:::z', {OUT=>"-12:34:56"}, {ENV=>'TZ=XXX12:34:56'}], + + ['tz-2', '+%:::z', {OUT=>"+12:34:56"}, {ENV=>'TZ=XXX-12:34:56'}], + + ['tz-3', '+%::z', {OUT=>"+01:02:03"}, {ENV=>'TZ=XXX-1:02:03'}], + + ['tz-4', '+%:::z', {OUT=>"+12"}, {ENV=>'TZ=XXX-12'}], + + ['tz-5', '+%:z', {OUT=>"-00:01"}, {ENV=>'TZ=XXX0:01'}], + + # Accept %:z with a field width before the `:'. + ['tz-5w','+%8:z', {OUT=>"-0000:01"}, {ENV=>'TZ=XXX0:01'}], + # Don't recognize %:z with a field width between the `:' and the `z'. + ['tz-5wf', '+%:8z', {OUT=>"%:8z"}, {ENV=>'TZ=XXX0:01'}], + + ['ns-relative', + '--iso=ns', "-d'1970-01-01 00:00:00.1234567 UTC +961062237.987654321 sec'", + {OUT=>"2000-06-15T09:43:58,111111021+0000"}], + ['ns-relativer', '--rfc-3339=ns', + "-d'1970-01-01 00:00:00.1234567 UTC +961062237.987654321 sec'", + {OUT=>"2000-06-15 09:43:58.111111021+00:00"}], + + # Since coreutils/lib/getdate.y revision 1.96 (post-coreutils-5.3.0), + # a command like the following would mistakenly exit nonzero with an + # `invalid date ...' diagnostic, but when run in a time zone for + # which daylight savings time is in effect for the starting date. + # Unfortunately (for ease of testing), if you set TZ at all, this + # failure is not triggered, hence the removal of TZ from the environment. + ['cross-dst', "-d'2005-03-27 +1 day'", '+%Y', {OUT=>"2005"}, + {ENV_DEL => 'TZ'}, + ], + + ['empty-fmt', '+', {OUT=>""}], + + ['neg-secs', '-d @-22 +%05s', {OUT=>"-0022"}], + ['neg-secs2', '-d @-22 +%_5s', {OUT=>" -22"}], + + # Before today's fix, date would print uninitialized data + # to standard output for an out-of-range date: + # $ date -d @$(echo 2^56-1|bc) 2> /dev/null | od -a -N3 + # 0000000 p 4 6 + # 0000003 + ['uninit-64', "-d \@$n_seconds", + {OUT=>''}, + # Use ERR_SUBST to get around fact that the diagnostic + # you get on a system with 32-bit time_t is not the same as + # the one you get for a system where it's 64 bits wide: + # - date: time 72057594037927935 is out of range + # + date: invalid date `@72057594037927935' + {ERR_SUBST => 's/.*//'}, + {ERR => "\n"}, + {EXIT => 1}, + ], + + ['fill-1', '-d 1999-12-08 +%_3d', {OUT=>' 8'}], + ['fill-2', '-d 1999-12-08 +%03d', {OUT=>'008'}], + + # Test the combination of the to-upper-case modifier (^) and a conversion + # specifier that expands to a string containing lower case characters. + ['subfmt-up1', '-d "1999-12-08 7:30" "+%^c"', + # Solaris 5.9 prints 'WED DEC 08 07:30:00 1999', while + # most others print 'WED DEC 8 07:30:00 1999'. + {OUT_SUBST => 's/ [ 0]8.*//'}, + {OUT=>'WED DEC'}], + ); + +# Repeat the cross-dst test, using Jan 1, 2005 and every interval from 1..364. +foreach my $i (1..364) + { + push @Tests, ["cross-dst$i", + "-d'2005-01-01 +$i day'", '+%Y', {OUT=>"2005"}, + {ENV_DEL => 'TZ'}, + ]; + } + +# Append "\n" to each OUT=> RHS if the expected exit value is either +# zero or not specified (defaults to zero). +foreach my $t (@Tests) + { + my $exit_val; + foreach my $e (@$t) + { + ref $e && ref $e eq 'HASH' && defined $e->{EXIT} + and $exit_val = $e->{EXIT}; + } + foreach my $e (@$t) + { + ref $e && ref $e eq 'HASH' && defined $e->{OUT} && ! $exit_val + and $e->{OUT} .= "\n"; + } + } + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = 'date'; +my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose); +exit $fail; +EOF diff --git a/tests/misc/date-sec b/tests/misc/date-sec new file mode 100755 index 0000000..6852c87 --- /dev/null +++ b/tests/misc/date-sec @@ -0,0 +1,67 @@ +#!/bin/sh +# Ensure that a command like +# `date --date="21:04 +0100" +%S' always prints `00'. +# Before coreutils-5.2.1, it would print the seconds from the current time. + +# Copyright (C) 2004, 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + date --version +fi + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +fail=0 + +# It would be easier simply to sleep for two seconds between two runs +# of `date --date="21:04 +0100" +%S` and ensure that both outputs +# are `00', but I prefer not to sleep unconditionally. `make check' +# takes long enough as it is. + +n=0 +# See if the current number of seconds is `00' or just before. +s=`date +%S` +case "$s" in + 58) n=3;; + 59) n=2;; + 00) n=1;; +esac + +# If necessary, wait for the system clock to pass the minute mark. +test $n = 0 || sleep $n + +s=`date --date="21:04 +0100" +%S` +case "$s" in + 00) ;; + *) fail=1;; +esac + +(exit $fail); exit $fail diff --git a/tests/misc/df b/tests/misc/df new file mode 100755 index 0000000..31040ca --- /dev/null +++ b/tests/misc/df @@ -0,0 +1,34 @@ +#!/bin/sh +# Ensure that "df ." outputs a header. + +# Copyright (C) 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + df --version +fi + +case `df .` in +*' +'*) + fail=0;; +*) + fail=1;; +esac + +(exit $fail); exit $fail diff --git a/tests/misc/df-P b/tests/misc/df-P new file mode 100755 index 0000000..3a5ec9b --- /dev/null +++ b/tests/misc/df-P @@ -0,0 +1,60 @@ +#!/bin/sh +# Ensure that df -P is not affected by BLOCK_SIZE settings + +# Copyright (C) 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + df --version +fi + +. $srcdir/../envvar-check +. $srcdir/../lang-default + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +fail=0 + + df -P . > t1 || fail=1 +BLOCK_SIZE=1M df -P . > t2 || fail=1 + +# Since disk utilization may be changing, compare only df's header line. +# That records the block size. E.g., for "1M", it would be: +# Filesystem 1048576-blocks Used Available Capacity Mounted on +# while for 1K, it would be +# Filesystem 1024-blocks Used Available Capacity Mounted on + +head -n1 t1 > exp || fail=1 +head -n1 t2 > out || fail=1 + +cmp out exp || fail=1 +test $fail = 1 && diff out exp 2> /dev/null + +(exit $fail); exit $fail diff --git a/tests/misc/dirname b/tests/misc/dirname new file mode 100755 index 0000000..c217d9a --- /dev/null +++ b/tests/misc/dirname @@ -0,0 +1,89 @@ +#!/bin/sh +# -*-perl-*- +# Test "dirname". + +# Copyright (C) 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +: ${PERL=perl} +: ${srcdir=.} + +$PERL -e 1 > /dev/null 2>&1 || { + echo 1>&2 "$0: configure didn't find a usable version of Perl," \ + "so can't run this test" + exit 77 +} + +d=$srcdir/.. +exec $PERL -w -I$d -MCoreutils -- - << \EOF +require 5.003; +use strict; +use File::stat; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localisation of executable's ouput. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $stat_single = stat('/'); +my $stat_double = stat('//'); +my $double_slash = ($stat_single->dev == $stat_double->dev + && $stat_single->ino == $stat_double->ino) ? '/' : '//'; + +my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; + +my @Tests = + ( + ['fail-1', {ERR => "$prog: missing operand\n" + . "Try `$prog --help' for more information.\n"}, {EXIT => '1'}], + ['fail-2', qw(a b), {ERR => "$prog: extra operand `b'\n" + . "Try `$prog --help' for more information.\n"}, {EXIT => '1'}], + + ['a', qw(d/f), {OUT => 'd'}], + ['b', qw(/d/f), {OUT => '/d'}], + ['c', qw(d/f/), {OUT => 'd'}], + ['d', qw(d/f//), {OUT => 'd'}], + ['e', qw(f), {OUT => '.'}], + ['f', qw(/), {OUT => '/'}], + ['g', qw(//), {OUT => "$double_slash"}], + ['h', qw(///), {OUT => '/'}], + ['i', qw(//a//), {OUT => "$double_slash"}], + ['j', qw(///a///), {OUT => '/'}], + ['k', qw(///a///b), {OUT => '///a'}], + ['l', qw(///a//b/), {OUT => '///a'}], + ['m', qw(''), {OUT => '.'}], + ); + +# Append a newline to end of each expected `OUT' string. +my $t; +foreach $t (@Tests) + { + my $arg1 = $t->[1]; + my $e; + foreach $e (@$t) + { + $e->{OUT} = "$e->{OUT}\n" + if ref $e eq 'HASH' and exists $e->{OUT}; + } + } + +my $save_temps = $ENV{SAVE_TEMPS}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; +EOF diff --git a/tests/misc/expand b/tests/misc/expand new file mode 100755 index 0000000..dcf0681 --- /dev/null +++ b/tests/misc/expand @@ -0,0 +1,54 @@ +#!/bin/sh +# -*- perl -*- +# Exercise expand. + +# Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +: ${PERL=perl} +: ${srcdir=.} + +$PERL -e 1 > /dev/null 2>&1 || { + echo 1>&2 "$0: configure didn't find a usable version of Perl," \ + "so can't run this test" + exit 77 +} + +exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF +#/ +require 5.003; +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localization of executable's ouput. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my @Tests = + ( + ['t1', '--tabs=3', {IN=>"a\tb"}, {OUT=>"a b"}], + ['t2', '--tabs=3,6,9', {IN=>"a\tb\tc\td\te"}, {OUT=>"a b c d e"}], + ['i1', '--tabs=3 -i', {IN=>"\ta\tb"}, {OUT=>" a\tb"}], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; +EOF diff --git a/tests/misc/false-status b/tests/misc/false-status new file mode 100755 index 0000000..612b5f9 --- /dev/null +++ b/tests/misc/false-status @@ -0,0 +1,45 @@ +#!/bin/sh +# ensure that false exits nonzero even with --help or --version + +# Copyright (C) 2003, 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + false --version +fi + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +fail=0 + +false --version > /dev/null && fail=1 +false --help > /dev/null && fail=1 + +(exit $fail); exit $fail diff --git a/tests/misc/fold b/tests/misc/fold new file mode 100755 index 0000000..ceab2e9 --- /dev/null +++ b/tests/misc/fold @@ -0,0 +1,68 @@ +#!/bin/sh +# -*- perl -*- +# Exercise fold. + +# Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +: ${PERL=perl} +: ${srcdir=.} + +$PERL -e 1 > /dev/null 2>&1 || { + echo 1>&2 "$0: configure didn't find a usable version of Perl," \ + "so can't run this test" + exit 77 +} + +# Ensure that we don't run an older version of fold. +# Prior to 5.0.91, some of the tests below would cause fold to infloop, +# and since `make check' might be run even after a build failure, it'd +# expose just such an older version. +ver=`fold --version|sed 1q` +case $ver in + *" $PACKAGE_VERSION") ;; + *) echo 1>&2 \ + "$0: found unexpected version of fold, \`$ver'" + "(expected $PACKAGE_VERSION)" + exit 1;; +esac + +exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF +#/ +require 5.003; +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localization of executable's ouput. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my @Tests = + ( + ['s1', '-w2 -s', {IN=>"a\t"}, {OUT=>"a\n\t"}], + ['s2', '-w4 -s', {IN=>"abcdef d\n"}, {OUT=>"abcd\nef d\n"}], + ['s3', '-w4 -s', {IN=>"a cd fgh\n"}, {OUT=>"a \ncd \nfgh\n"}], + ['s4', '-w4 -s', {IN=>"abc ef\n"}, {OUT=>"abc \nef\n"}], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; +EOF diff --git a/tests/misc/head-c b/tests/misc/head-c new file mode 100755 index 0000000..ba13c32 --- /dev/null +++ b/tests/misc/head-c @@ -0,0 +1,49 @@ +#!/bin/sh +# exercise the fix of 2001-08-18, based on test case from Ian Bruce + +# Copyright (C) 2001, 2004, 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + head --version +fi + +pwd=`pwd` +tmp=head-c.$$ +trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0 +trap '(exit $?); exit' 1 2 13 15 + +framework_failure=0 +mkdir $tmp || framework_failure=1 +cd $tmp || framework_failure=1 +echo abc > in || framework_failure=1 + +if test $framework_failure = 1; then + echo 'failure in testing framework' 1>&2 + (exit 1); exit 1 +fi + +fail=0 + +(head -c1; head -c1) < in > out || fail=1 +case "`cat out`" in + ab) ;; + *) fail=1 ;; +esac + +(exit $fail); exit $fail diff --git a/tests/misc/head-elide-tail b/tests/misc/head-elide-tail new file mode 100755 index 0000000..911ca61 --- /dev/null +++ b/tests/misc/head-elide-tail @@ -0,0 +1,123 @@ +#!/bin/sh +# -*- perl -*- +# Exercise head's --bytes=-N option. + +# Copyright (C) 2003, 2005 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +: ${PERL=perl} +: ${srcdir=.} + +$PERL -e 1 > /dev/null 2>&1 || { + echo 1>&2 "$0: configure didn't find a usable version of Perl," \ + "so can't run this test" + exit 77 +} + +exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF +#/ +require 5.003; +use strict; + +(my $program_name = $0) =~ s|.*/||; + +$ENV{PROG} = 'head'; + +# Turn off localization of executable's ouput. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +# This should match the definition in head.c. +my $READ_BUFSIZE = 4096; + +my @Tests = + ( + # Elide the exact size of the file. + ['elide-b1', "--bytes=-2", {IN=>"a\n"}, {OUT=>''}], + # Elide more than the size of the file. + ['elide-b2', "--bytes=-2", {IN=>"a"}, {OUT=>''}], + # Leave just one byte. + ['elide-b3', "--bytes=-2", {IN=>"abc"}, {OUT=>'a'}], + # Make it so the elided bytes straddle the end of the first + # $READ_BUFSIZE block. + ['elide-b4', "--bytes=-2", + {IN=> 'a' x ($READ_BUFSIZE-3) . "\nbcd"}, + {OUT=>'a' x ($READ_BUFSIZE-3) . "\nb"}], + # Make it so the elided bytes straddle the end of the 2nd + # $READ_BUFSIZE block. + ['elide-b5', "--bytes=-2", + {IN=> 'a' x (2 * $READ_BUFSIZE - 2) . 'bcd'}, + {OUT=>'a' x (2 * $READ_BUFSIZE - 2) . 'b'}], + + ['elide-l0', "--lines=-1", {IN=>''}, {OUT=>''}], + ['elide-l1', "--lines=-1", {IN=>"a\n"}, {OUT=>''}], + ['elide-l2', "--lines=-1", {IN=>"a"}, {OUT=>''}], + ['elide-l3', "--lines=-1", {IN=>"a\nb"}, {OUT=>"a\n"}], + ['elide-l4', "--lines=-1", {IN=>"a\nb\n"}, {OUT=>"a\n"}], + ); + +if ($ENV{RUN_EXPENSIVE_TESTS}) + { + # Brute force: use all combinations of file sizes [0..20] and + # number of bytes to elide [0..20]. For better coverage, recompile + # head with -DHEAD_TAIL_PIPE_READ_BUFSIZE=4 and + # -DHEAD_TAIL_PIPE_BYTECOUNT_THRESHOLD=8 + my $s = "abcdefghijklmnopqrst"; + for my $file_size (0..20) + { + for my $n_elide (0..20) + { + my $input = substr $s, 0, $file_size; + my $out_len = $n_elide < $file_size ? $file_size - $n_elide : 0; + my $output = substr $input, 0, $out_len; + my $t = ["elideb$file_size-$n_elide", "--bytes=-$n_elide", + {IN=>$input}, {OUT=>$output}]; + push @Tests, $t; + my @u = @$t; + # Insert the ---presume-input-pipe option. + $u[0] .= 'p'; + $u[1] .= ' ---presume-input-pipe'; + push @Tests, \@u; + } + } + + $s =~ s/(.)/$1\n/g; + for my $file_size (0..20) + { + for my $n_elide (0..20) + { + my $input = substr $s, 0, 2 * $file_size; + my $out_len = $n_elide < $file_size ? $file_size - $n_elide : 0; + my $output = substr $input, 0, 2 * $out_len; + my $t = ["elidel$file_size-$n_elide", "--lines=-$n_elide", + {IN=>$input}, {OUT=>$output}]; + push @Tests, $t; + my @u = @$t; + # Insert the ---presume-input-pipe option. + $u[0] .= 'p'; + $u[1] .= ' ---presume-input-pipe'; + push @Tests, \@u; + } + } + } + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; +EOF diff --git a/tests/misc/head-pos b/tests/misc/head-pos new file mode 100755 index 0000000..9069feb --- /dev/null +++ b/tests/misc/head-pos @@ -0,0 +1,51 @@ +#!/bin/sh +# When reading a specified number of lines, ensure that the output +# file pointer is positioned just after those lines. + +# Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + head --version +fi + +pwd=`pwd` +tmp=head-pos.$$ +trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0 +trap '(exit $?); exit' 1 2 13 15 + +framework_failure=0 +mkdir $tmp || framework_failure=1 +cd $tmp || framework_failure=1 +(echo a; echo b) > in || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +fail=0 +(head -n 1 >/dev/null; cat) < in > out || fail=1 +cat <<EOF > exp +b +EOF + +cmp out exp || fail=1 +test $fail = 1 && diff out exp 2> /dev/null + +(exit $fail); exit $fail diff --git a/tests/misc/mknod b/tests/misc/mknod new file mode 100755 index 0000000..12cb0a6 --- /dev/null +++ b/tests/misc/mknod @@ -0,0 +1,56 @@ +#!/bin/sh +# Ensure that mknod, mkfifo, mkdir -m MODE work with a restrictive umask + +# Copyright (C) 2004, 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + mknod --version +fi + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +fail=0 + +umask 777 + +mknod -m 734 f1 p || fail=1 +set _ `ls -dgo f1`; shift; mode=$1 +test $mode = prwx-wxr-- || fail=1 + +mkfifo -m 734 f2 || fail=1 +set _ `ls -dgo f2`; shift; mode=$1 +test $mode = prwx-wxr-- || fail=1 + +mkdir -m 734 f3 || fail=1 +set _ `ls -dgo f3`; shift; mode=$1 +test $mode = drwx-wxr-- || test $mode = drwx-wsr-- || fail=1 + +(exit $fail); exit $fail diff --git a/tests/misc/nice b/tests/misc/nice new file mode 100755 index 0000000..02c10b5 --- /dev/null +++ b/tests/misc/nice @@ -0,0 +1,86 @@ +#! /bin/sh +# Test "nice". + +# Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +# This script takes no arguments. + +if test -n "$DJDIR"; then + echo "$0: cannot test nice on DJGPP" >&2 + exit 77 +fi + +tests=' +0 empty 10 +1 -1 1 +2 -12 12 +3 -1:-2 2 +4 -n:1 1 +5 -n:1:-2 2 +6 -n:1:-+12 12 +7 -2:-n:1 1 +8 -2:-n:12 12 +9 -+1 1 +10 -+12 12 +11 -+1:-+12 12 +12 -n:+1 1 +13 --1:-2 2 +14 --1:-2:-13 13 +15 --1:-n:2 2 +16 --1:-n:2:-3 3 +17 --1:-n:2:-13 13 +18 -n:-1:-12 12 +19 --1:-12 12 +NA LAST NA +' +set $tests + +if test "$VERBOSE" = yes; then + nice --version + set -x +fi + +# Require that this test be run at `nice' level 0. +niceness=`nice` +if test "$niceness" = 0; then + : ok +else + echo "$0: this test must be run at nice level 0" 1>&2 + exit 77 +fi + +fail=0 +while :; do + test_name=$1 + args=$2 + expected_result=$3 + test $args = empty && args='' + test x$args = xLAST && break + args=`echo x$args|tr : ' '|sed 's/^x//'` + if test "$VERBOSE" = yes; then + #echo "testing \`nice $args nice\` = $expected_result ..." + echo "test $test_name... " | tr -d '\n' + fi + test x`nice $args nice 2> /dev/null` = x$expected_result \ + && ok=ok || ok=FAIL fail=1 + test "$VERBOSE" = yes && echo $ok + test x`nice $args nice 2> /dev/null` = x$expected_result || fail=1 + shift; shift; shift +done + +exit $fail diff --git a/tests/misc/nl b/tests/misc/nl new file mode 100755 index 0000000..72d2c21 --- /dev/null +++ b/tests/misc/nl @@ -0,0 +1,63 @@ +#!/bin/sh +# exercise nl functionality + +# Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + nl --version +fi + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +fail=0 + +echo a | nl > out || fail=1 +echo b | nl -s%n >> out || fail=1 +echo c | nl -n ln >> out || fail=1 +echo d | nl -n rn >> out || fail=1 +echo e | nl -n rz >> out || fail=1 +echo === >> out +printf 'a\n\n' | nl > t || fail=1; cat -A t >> out +cat <<\EOF > exp + 1 a + 1%nb +1 c + 1 d +000001 e +=== + 1^Ia$ + $ +EOF + +cmp out exp || fail=1 +test $fail = 1 && diff out exp 2> /dev/null + +(exit $fail); exit $fail diff --git a/tests/misc/nohup b/tests/misc/nohup new file mode 100755 index 0000000..6166473 --- /dev/null +++ b/tests/misc/nohup @@ -0,0 +1,128 @@ +#!/bin/sh +# test nohup + +# Copyright (C) 2003, 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + nohup --version +fi + +. $srcdir/../envvar-check +. $srcdir/../lang-default + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +fail=0 + +nohup sh -c 'echo stdout; echo stderr 1>&2' 2>err || fail=1 + +# Be careful. The results of the above nohup command +# change depending on whether stdin and stdout are redirected. +if test -t 1; then + test "`cat nohup.out`" = stdout || fail=1 + if test -t 0; then + echo 'nohup: ignoring input and appending output to `nohup.out'\' + else + echo 'nohup: appending output to `nohup.out'\' + fi >exp || fail=1 +else + # Here it should not even exist. + test -f nohup.out && fail=1 + if test -t 0; then + echo 'nohup: ignoring input' >exp + else + rm -f exp + fi || fail=1 +fi +echo 'stderr' >> exp || fail=1 + +cmp exp err || fail=1 +test $fail = 1 && diff exp err 2> /dev/null +rm -f nohup.out err exp +# ---------------------- + +# Be careful. The results of the following nohup command +# change depending on whether stderr is redirected. +nohup sh -c 'echo stdout; echo stderr 1>&2' >out || fail=1 +if test -t 2; then + test "`cat out|tr '\n' -`" = stdout-stderr- || fail=1 +else + test "`cat out|tr '\n' -`" = stdout- || fail=1 +fi +# It must *not* exist. +test -f nohup.out && fail=1 +rm -f nohup.out err +# ---------------------- + +nohup no-such-command 2> err +errno=$? +if test -t 1; then + test $errno = 127 || fail=1 + # It must exist. + test -f nohup.out || fail=1 + # It must be empty. + test -s nohup.out && fail=1 +fi + +cat <<\EOF > exp || fail=1 +nohup: appending output to `nohup.out' +nohup: cannot run command `no-such-command': No such file or directory +EOF +# Disable these comparisons. Too much variation in 2nd line. +# cmp exp err || fail=1 +# test $fail = 1 && diff exp err 2> /dev/null +rm -f nohup.out err exp +# ---------------------- + +touch k; chmod 0 k +nohup ./k 2> err +errno=$? +test $errno = 126 || fail=1 +if test -t 1; then + # It must exist. + test -f nohup.out || fail=1 + # It must be empty. + test -s nohup.out && fail=1 +fi + +cat <<\EOF > exp || fail=1 +nohup: appending output to `nohup.out' +nohup: cannot run command `./k': Permission denied +EOF +# Disable these comparisons. Too much variation in 2nd line. +# cmp exp err || fail=1 +# test $fail = 1 && diff exp err 2> /dev/null + +# Make sure it fails with exit status of 127 when given too few arguments. +nohup >/dev/null 2>&1 +test $? = 127 || fail=1 + +(exit $fail); exit $fail diff --git a/tests/misc/paste-no-nl b/tests/misc/paste-no-nl new file mode 100755 index 0000000..6fafb08 --- /dev/null +++ b/tests/misc/paste-no-nl @@ -0,0 +1,64 @@ +#!/bin/sh +# -*- perl -*- +# Ensure that paste properly handles files lacking a final newline. + +# Copyright (C) 2003, 2005 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +: ${PERL=perl} +: ${srcdir=.} + +$PERL -e 1 > /dev/null 2>&1 || { + echo 1>&2 "$0: configure didn't find a usable version of Perl," \ + "so can't run this test" + exit 77 +} + +exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF +#/ +require 5.003; +use strict; + +(my $program_name = $0) =~ s|.*/||; + +$ENV{PROG} = 'paste'; + +# Turn off localization of executable's ouput. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my @Tests = + ( + ['no-nl-1', {IN=>"a"}, {IN=>"b"}, {OUT=>"a\tb\n"}], + ['no-nl-2', {IN=>"a\n"}, {IN=>"b"}, {OUT=>"a\tb\n"}], + ['no-nl-3', {IN=>"a"}, {IN=>"b\n"}, {OUT=>"a\tb\n"}], + ['no-nl-4', {IN=>"a\n"}, {IN=>"b\n"}, {OUT=>"a\tb\n"}], + + # Same as above, but with a two lines in each input file and + # the addition of the -d option to make SPACE be the output delimiter. + ['no-nla1', '-d" "', {IN=>"1\na"}, {IN=>"2\nb"}, {OUT=>"1 2\na b\n"}], + ['no-nla2', '-d" "', {IN=>"1\na\n"}, {IN=>"2\nb"}, {OUT=>"1 2\na b\n"}], + ['no-nla3', '-d" "', {IN=>"1\na"}, {IN=>"2\nb\n"}, {OUT=>"1 2\na b\n"}], + ['no-nla4', '-d" "', {IN=>"1\na\n"}, {IN=>"2\nb\n"}, {OUT=>"1 2\na b\n"}], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; +EOF diff --git a/tests/misc/pathchk1 b/tests/misc/pathchk1 new file mode 100755 index 0000000..9305f0c --- /dev/null +++ b/tests/misc/pathchk1 @@ -0,0 +1,57 @@ +#!/bin/sh +# pathchk tests + +# Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + pathchk --version +fi + +PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd "$pwd" && rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 +touch file || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +fail=0 + +# This should exit nonzero. Before 2.0.13, it gave a diagnostic, +# but exited successfully. +pathchk file/x > /dev/null 2>&1 && fail=1 + +# This should exit nonzero. Through 5.3.0 it exited with status zero. +pathchk -p '' > /dev/null 2>&1 && fail=1 + +# This tests the new -P option. +pathchk -P '' > /dev/null 2>&1 && fail=1 +pathchk -P -- - > /dev/null 2>&1 && fail=1 +pathchk -p -P x/- > /dev/null 2>&1 && fail=1 + +(exit $fail); exit $fail diff --git a/tests/misc/pr b/tests/misc/pr new file mode 100755 index 0000000..a40ea31 --- /dev/null +++ b/tests/misc/pr @@ -0,0 +1,61 @@ +#!/bin/sh +# -*- perl -*- +# Exercise a bug with pr -m -s + +# Copyright (C) 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +: ${PERL=perl} +: ${srcdir=.} + +. $srcdir/../envvar-check + +$PERL -e 1 > /dev/null 2>&1 || { + echo 1>&2 "$0: configure didn't find a usable version of Perl," \ + "so can't run this test" + exit 77 +} + +exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF +#/ +require 5.003; +use strict; + +(my $program_name = $0) =~ s|.*/||; + +$ENV{PROG} = 'pr'; +my $ME = $ENV{PROG}; + +# Turn off localization of executable's ouput. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my @Tests = + ( + ['merge-w-tabs', '-m -s -t', + {IN=>{1=>"a\tb\tc\n"}}, + {IN=>{2=>"m\tn\to\n"}}, + {IN=>{3=>"x\ty\tz\n"}}, + {OUT=>join("\t", qw(a b c m n o x y z)) . "\n"} ], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; +EOF diff --git a/tests/misc/printf b/tests/misc/printf new file mode 100755 index 0000000..481cb37 --- /dev/null +++ b/tests/misc/printf @@ -0,0 +1,114 @@ +#!/bin/sh +# basic tests for printf + +# Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +prog=`pwd`/../../src/printf + +if test "$VERBOSE" = yes; then + set -x + "$prog" --version +fi + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +fail=0 + +# This would fail (by printing the `--') for printf in sh-utils +# and in coreutils 4.5.1. +"$prog" -- 'foo\n' > out || fail=1 +cat <<\EOF > exp +foo +EOF + +cmp out exp || fail=1 +test $fail = 1 && diff out exp 2> /dev/null + +rm -f out exp +# Until coreutils-4.5.10, this would elicit a segfault. +"$prog" '1 %*sy\n' -3 x > out || fail=1 + +# Until coreutils 5.2.2, this would succeed. +if POSIXLY_CORRECT=1 "$prog" '2 \x' >/dev/null 2>&1; then + fail=1 +else + echo '2 failed, as expected' >> out +fi + +# Until coreutils-4.5.12, these would fail. +"$prog" '3 \x40\n' >> out || fail=1 +POSIXLY_CORRECT=1 \ +"$prog" '4 \x40\n' >> out || fail=1 +"$prog" '5 % +d\n' 234 >> out || fail=1 + +# This should print "6 !\n", but don't rely on `!' being the +# one-byte representation of octal 041. With printf prior to +# coreutils-5.0.1, it would print six bytes: "6 \41\n". +"$prog" '6 \41\n' | tr '\41' '!' >> out + +# Note that as of coreutils-5.0.1, printf with a format of '\0002x' +# prints a NUL byte followed by the digit `2' and an `x'. +# By contrast bash's printf outputs the same thing as $(printf '\2x') does. +"$prog" '7 \2y \02y \002y \0002y\n' |tr '\0\2' '*=' >> out + +"$prog" '8 %b %b %b %b\n' '\1y' '\01y' '\001y' '\0001y'|tr '\1' = >> out + +"$prog" '9 %*dx\n' -2 0 >>out || fail=1 + +"$prog" '10 %.*dx\n' -2147483648 0 >>out || fail=1 + +"$prog" '11 %*c\n' 2 x >>out || fail=1 + +"$prog" '%#d\n' 0 >>out 2> /dev/null && fail=1 + +"$prog" '%0s\n' 0 >>out 2> /dev/null && fail=1 + +"$prog" '%.9c\n' 0 >>out 2> /dev/null && fail=1 + +"$prog" '%'\''s\n' 0 >>out 2> /dev/null && fail=1 + +cat <<\EOF > exp +1 x y +2 failed, as expected +3 @ +4 @ +5 +234 +6 ! +7 =y =y =y *2y +8 =y =y =y =y +9 0 x +10 0x +11 x +EOF + +cmp out exp || fail=1 +test $fail = 1 && diff -au out exp 2> /dev/null + +(exit $fail); exit $fail diff --git a/tests/misc/printf-hex b/tests/misc/printf-hex new file mode 100755 index 0000000..d3d5d04 --- /dev/null +++ b/tests/misc/printf-hex @@ -0,0 +1,52 @@ +#!/bin/sh +# make sure that only two hex. digits are consumed in a \xHHH sequence + +# Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +prog=`pwd`/../../src/printf + +if test "$VERBOSE" = yes; then + set -x + "$prog" --version +fi + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +fail=0 + +"$prog" '\x7e3\n' > out || fail=1 +cat <<\EOF > exp +~3 +EOF + +cmp out exp || fail=1 +test $fail = 1 && diff out exp 2> /dev/null + +(exit $fail); exit $fail diff --git a/tests/misc/pwd-long b/tests/misc/pwd-long new file mode 100755 index 0000000..6fc83e2 --- /dev/null +++ b/tests/misc/pwd-long @@ -0,0 +1,132 @@ +#!/bin/sh +# Ensure that pwd works even when run from a very deep directory. + +# Copyright (C) 2006-2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +: ${PERL=perl} + +$PERL -e 1 > /dev/null 2>&1 || { + echo 1>&2 "$0: configure didn't find a usable version of Perl," \ + "so can't run this test" + exit 77 +} + +framework_failure=0 +pwd=`"${BUILD_SRC_DIR?}"/pwd` || framework_failure=1 +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +ARGV_0=$0 +export ARGV_0 + +CWD=$pwd/$tmp +export CWD + +$PERL -Tw -- - <<\EOF + +# Show that pwd works even when the length of the resulting +# directory name is longer than PATH_MAX. +use strict; + +(my $ME = $ENV{ARGV_0}) =~ s|.*/||; + +sub normalize_to_cwd_relative ($$$) +{ + my ($dir, $dev, $ino) = @_; + my $slash = -1; + my $next_slash; + while (1) + { + $slash = index $dir, '/', $slash + 1; + $slash <= -1 + and die "$ME: $dir does not contain old CWD\n"; + my $dir_prefix = $slash ? substr ($dir, 0, $slash) : '/'; + my ($d, $i) = (stat $dir_prefix)[0, 1]; + $d == $dev && $i == $ino + and return substr $dir, $slash + 1; + } +} + +# Set up a safe, well-known environment +delete @ENV{qw(BASH_ENV CDPATH ENV PATH)}; +$ENV{IFS} = ''; + +# Save CWD's device and inode numbers. +my ($dev, $ino) = (stat '.')[0, 1]; + +# Construct the expected "."-relative part of pwd's output. +my $z = 'z' x 31; +my $n = 256; +my $expected = "/$z" x $n; +# Remove the leading "/". +substr ($expected, 0, 1) = ''; + +my $i = 0; +do + { + mkdir $z, 0700 + or die "$ME: at depth $i: $!\n"; + chdir $z; + } +until (++$i == $n); + +my $build_src_dir = $ENV{BUILD_SRC_DIR}; +$build_src_dir + or die "$ME: envvar BUILD_SRC_DIR not defined\n"; +if ($build_src_dir !~ m!^([-+.:/\w]+)$!) + { + warn "$0: skipping this test; odd build source directory name:\n" + . "$build_src_dir\n"; + exit 77; + } +$build_src_dir = $1; + +my $pwd_binary = "$build_src_dir/pwd"; + +-x $pwd_binary + or die "$ME: $pwd_binary is not an executable file\n"; +chomp (my $actual = `$pwd_binary`); + +# Convert the absolute name from pwd into a $CWD-relative name. +# This is necessary in order to avoid a spurious failure when run +# from a directory in a bind-mounted partition. What happens is +# pwd reads a ".." that contains two or more entries with identical +# dev,ino that match the ones we're looking for, and it chooses a +# name that does not correspond to the one already recorded in $CWD. +$actual = normalize_to_cwd_relative $actual, $dev, $ino; + +if ($expected ne $actual) + { + my $e_len = length $expected; + my $a_len = length $actual; + warn "expected len: $e_len\n"; + warn "actual len: $a_len\n"; + warn "expected: $expected\n"; + warn "actual: $actual\n"; + exit 1; + } +EOF diff --git a/tests/misc/pwd-unreadable-parent b/tests/misc/pwd-unreadable-parent new file mode 100755 index 0000000..72c666e --- /dev/null +++ b/tests/misc/pwd-unreadable-parent @@ -0,0 +1,70 @@ +#!/bin/sh +# Ensure that pwd and "readlink -e ." work even when a parent directory +# is unreadable. Perform this test only on systems with a usable getcwd +# function that has this capability. + +# Copyright (C) 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + pwd --version + readlink --version +fi + +test $host_os != linux-gnu && + { + echo 1>&2 "$0: vendor getcwd may be inadequate; skipping this test" + (exit 77); exit 77 + } + +# Linux ia64 has the gl_FUNC_GETCWD_ABORT_BUG, so we can't use +# the system getcwd. +test $REPLACE_GETCWD = 1 && + { + echo 1>&2 "$0: can't use buggy system getcwd; skipping this test" + (exit 77); exit 77 + } + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 + +mkdir -p a/b || framework_failure=1 +cd a/b || framework_failure=1 +chmod a=x .. || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +pwd_exe=$pwd/../../src/pwd + +fail=0 +$pwd_exe > exp || fail=1 +readlink -ev . > out || fail=1 + +cmp out exp || fail=1 +test $fail = 1 && diff out exp 2> /dev/null + +(exit $fail); exit $fail diff --git a/tests/misc/sha224sum b/tests/misc/sha224sum new file mode 100755 index 0000000..2b3c402 --- /dev/null +++ b/tests/misc/sha224sum @@ -0,0 +1,63 @@ +#!/bin/sh +# Test "sha224sum". + +# Copyright (C) 2005 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +: ${PERL=perl} +: ${srcdir=.} + +$PERL -e 1 > /dev/null 2>&1 || { + echo 1>&2 "$0: configure didn't find a usable version of Perl," \ + "so can't run this test" + exit 77 +} + +exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF +require 5.003; +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localisation of executable's ouput. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my @Tests = + ( + ['s3', {IN=> {f=> 'abc'}}, + {OUT=>"23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7 f\n"}], + ['s4', + {IN=> {f=> 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'}}, + {OUT=>"75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525 f\n"}], + ['s8', {IN=> {f=> 'a' x 1000000}}, + {OUT=>"20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67 f\n"}], + ); + +# Insert the `--text' argument for each test. +my $t; +foreach $t (@Tests) + { + splice @$t, 1, 0, '--text' unless @$t[1] =~ /--check/; + } + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; +EOF diff --git a/tests/misc/sha256sum b/tests/misc/sha256sum new file mode 100755 index 0000000..59ee072 --- /dev/null +++ b/tests/misc/sha256sum @@ -0,0 +1,69 @@ +#!/bin/sh +# Test "sha256sum". + +# Copyright (C) 2005 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +: ${PERL=perl} +: ${srcdir=.} + +$PERL -e 1 > /dev/null 2>&1 || { + echo 1>&2 "$0: configure didn't find a usable version of Perl," \ + "so can't run this test" + exit 77 +} + +exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF +require 5.003; +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localisation of executable's ouput. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $sha_degenerate = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"; + +my @Tests = + ( + ['s1', {IN=> {f=> ''}}, + {OUT=>"$sha_degenerate f\n"}], + ['s2', {IN=> {f=> 'a'}}, + {OUT=>"ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb f\n"}], + ['s3', {IN=> {f=> 'abc'}}, + {OUT=>"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad f\n"}], + ['s4', + {IN=> {f=> 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'}}, + {OUT=>"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1 f\n"}], + ['s8', {IN=> {f=> 'a' x 1000000}}, + {OUT=>"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0 f\n"}], + ); + +# Insert the `--text' argument for each test. +my $t; +foreach $t (@Tests) + { + splice @$t, 1, 0, '--text' unless @$t[1] =~ /--check/; + } + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; +EOF diff --git a/tests/misc/sha384sum b/tests/misc/sha384sum new file mode 100755 index 0000000..8236104 --- /dev/null +++ b/tests/misc/sha384sum @@ -0,0 +1,69 @@ +#!/bin/sh +# Test "sha384sum". + +# Copyright (C) 2005 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +: ${PERL=perl} +: ${srcdir=.} + +$PERL -e 1 > /dev/null 2>&1 || { + echo 1>&2 "$0: configure didn't find a usable version of Perl," \ + "so can't run this test" + exit 77 +} + +exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF +require 5.003; +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localisation of executable's ouput. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $sha_degenerate = "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b"; + +my @Tests = + ( + ['s1', {IN=> {f=> ''}}, + {OUT=>"$sha_degenerate f\n"}], + ['s2', {IN=> {f=> 'a'}}, + {OUT=>"54a59b9f22b0b80880d8427e548b7c23abd873486e1f035dce9cd697e85175033caa88e6d57bc35efae0b5afd3145f31 f\n"}], + ['s3', {IN=> {f=> 'abc'}}, + {OUT=>"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7 f\n"}], + ['s4', + {IN=> {f=> 'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu'}}, + {OUT=>"09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039 f\n"}], + ['s8', {IN=> {f=> 'a' x 1000000}}, + {OUT=>"9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985 f\n"}], + ); + +# Insert the `--text' argument for each test. +my $t; +foreach $t (@Tests) + { + splice @$t, 1, 0, '--text' unless @$t[1] =~ /--check/; + } + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; +EOF diff --git a/tests/misc/sha512sum b/tests/misc/sha512sum new file mode 100755 index 0000000..84f4cfb --- /dev/null +++ b/tests/misc/sha512sum @@ -0,0 +1,69 @@ +#!/bin/sh +# Test "sha512sum". + +# Copyright (C) 2005 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +: ${PERL=perl} +: ${srcdir=.} + +$PERL -e 1 > /dev/null 2>&1 || { + echo 1>&2 "$0: configure didn't find a usable version of Perl," \ + "so can't run this test" + exit 77 +} + +exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF +require 5.003; +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localisation of executable's ouput. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $sha_degenerate = "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"; + +my @Tests = + ( + ['s1', {IN=> {f=> ''}}, + {OUT=>"$sha_degenerate f\n"}], + ['s2', {IN=> {f=> 'a'}}, + {OUT=>"1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f5302860c652bf08d560252aa5e74210546f369fbbbce8c12cfc7957b2652fe9a75 f\n"}], + ['s3', {IN=> {f=> 'abc'}}, + {OUT=>"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f f\n"}], + ['s4', + {IN=> {f=> 'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu'}}, + {OUT=>"8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909 f\n"}], + ['s8', {IN=> {f=> 'a' x 1000000}}, + {OUT=>"e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b f\n"}], + ); + +# Insert the `--text' argument for each test. +my $t; +foreach $t (@Tests) + { + splice @$t, 1, 0, '--text' unless @$t[1] =~ /--check/; + } + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; +EOF diff --git a/tests/misc/shuf b/tests/misc/shuf new file mode 100755 index 0000000..a2d5891 --- /dev/null +++ b/tests/misc/shuf @@ -0,0 +1,68 @@ +#!/bin/sh +# Ensure that shuf randomizes its input. + +# Copyright (C) 2006, 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + shuf --version +fi + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 +seq 100 > in || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +fail=0 + +shuf in >out || fail=1 + +# Fail if the input is the same as the output. +# This is a probabilistic test :-) +# However, the odds of failure are very low: 1 in 100! (~ 1 in 10^158) +cmp in out > /dev/null && { fail=1; echo "not random?" 1>&2; } + +# Fail if the sorted output is not the same as the input. +sort -n out > out1 +cmp in out1 || { fail=1; echo "not a permutation" 1>&2; } + +# Exercise shuf's -i option. +shuf -i 1-100 > out || fail=1 +cmp in out > /dev/null && { fail=1; echo "not random?" 1>&2; } +sort -n out > out1 +cmp in out1 || { fail=1; echo "not a permutation" 1>&2; } + +# Exercise shuf's -e option. +t=`shuf -e a b c d e | sort | fmt` +test "$t" = 'a b c d e' || { fail=1; echo "not a permutation" 1>&2; } + +# Before coreutils-6.3, this would infloop. +# "seq 1860" produces 8193 (8K + 1) bytes of output. +seq 1860 | shuf > /dev/null || fail=1 + +(exit $fail); exit $fail diff --git a/tests/misc/sort-compress b/tests/misc/sort-compress new file mode 100755 index 0000000..0cafb2e --- /dev/null +++ b/tests/misc/sort-compress @@ -0,0 +1,92 @@ +#!/bin/sh +# Test use of compression by sort + +# Copyright (C) 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + sort --version +fi + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 +seq -w 2000 > exp || framework_failure=1 +tac exp > in || framework_failure=1 +SORT=$abs_top_builddir/src/sort + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +fail=0 + +# This should force the use of temp files compressed with the default gzip +sort -S 1k in > out || fail=1 +cmp exp out || fail=1 +test $fail = 1 && diff out exp 2> /dev/null + +# Create our own gzip program that will be used as the default +cat <<\EOF > gzip || fail=1 +#!/bin/sh +tr 41 14 +touch ok +EOF + +chmod +x gzip + +# This will find our new gzip in PATH +PATH=.:$PATH sort -S 1k --compress-program=gzip in > out || fail=1 +cmp exp out || fail=1 +test $fail = 1 && diff out exp 2> /dev/null +test -f ok || fail=1 +rm -f ok + +# This is to make sure it works with no compression. +PATH=.:$PATH sort -S 1k in > out || fail=1 +cmp exp out || fail=1 +test $fail = 1 && diff out exp 2> /dev/null +test -f ok && fail=1 + +# This is to make sure we can use something other than gzip +mv gzip dzip || fail=1 +sort --compress-program=./dzip -S 1k in > out || fail=1 +cmp exp out || fail=1 +test $fail = 1 && diff out exp 2> /dev/null +test -f ok || fail=1 +rm -f ok + +# Make sure it can find other programs in PATH correctly +PATH=.:$PATH sort --compress-program=dzip -S 1k in > out || fail=1 +cmp exp out || fail=1 +test $fail = 1 && diff out exp 2> /dev/null +test -f ok || fail=1 +rm -f dzip ok + +# This is to make sure sort functions if it can't find the default gzip +PATH=. "$SORT" -S 1k in > out || fail=1 +cmp exp out || fail=1 +test $fail = 1 && diff out exp 2> /dev/null + +(exit $fail); exit $fail diff --git a/tests/misc/sort-merge b/tests/misc/sort-merge new file mode 100755 index 0000000..a737e4d --- /dev/null +++ b/tests/misc/sort-merge @@ -0,0 +1,50 @@ +#!/bin/sh +# Test "sort -m". + +# Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +: ${PERL=perl} +: ${srcdir=.} + +$PERL -e 1 > /dev/null 2>&1 || { + echo 1>&2 "$0: configure didn't find a usable version of Perl," \ + "so can't run this test" + exit 77 +} + +exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF +require 5.003; +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localisation of executable's ouput. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my @Tests = + ( + ['m1', '-m', {IN=> {empty=> ''}}, {IN=> {f=> "foo\n"}}, {OUT=>"foo\n"}], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = 'sort'; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; +EOF diff --git a/tests/misc/sort-rand b/tests/misc/sort-rand new file mode 100755 index 0000000..f997318 --- /dev/null +++ b/tests/misc/sort-rand @@ -0,0 +1,54 @@ +#!/bin/sh +# Ensure that sort --sort-random doesn't sort. + +# Copyright (C) 2005, 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + sort --version +fi + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 +seq 100 > in || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +fail=0 + +sort --random-sort in > out || fail=1 + +# Fail if the input is the same as the output. +# This is a probabilistic test :-) +# However, the odds of failure are very low: 1 in 100! (~ 1 in 10^158) +cmp in out > /dev/null && { fail=1; echo "not random?" 1>&2; } + +# Fail if the sorted output is not the same as the input. +sort -n out > out1 +cmp in out1 || { fail=1; echo "not a permutation" 1>&2; } + +(exit $fail); exit $fail diff --git a/tests/misc/split-a b/tests/misc/split-a new file mode 100755 index 0000000..3026aac --- /dev/null +++ b/tests/misc/split-a @@ -0,0 +1,96 @@ +#!/bin/sh +# Show that split -a works. + +# Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + split --version +fi + +. $srcdir/../lang-default + +pwd=`pwd` +tmp=split-a.$$ +trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0 +trap '(exit $?); exit' 1 2 13 15 + +framework_failure=0 +mkdir $tmp || framework_failure=1 +cd $tmp || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +fail=0 + +# Generate a 27-byte file +# yes|tr -d y|head -n27 > in +echo abcdefghijklmnopqrstuvwxyz > in + +# This should fail. +split -b 1 -a 1 in 2> err && fail=1 +test -f xa || fail=1 +test -f xz || fail=1 +test -f xaa && fail=1 +test -f xaz && fail=1 +rm -f x* + +# With a longer suffix, it must succeed. +split --verbose -b 1 -a 2 in 2> err || fail=1 +test -f xaa || fail=1 +test -f xaz || fail=1 +test -f xba || fail=1 +test -f xbb && fail=1 + +cat <<\EOF > exp +creating file `xaa' +creating file `xab' +creating file `xac' +creating file `xad' +creating file `xae' +creating file `xaf' +creating file `xag' +creating file `xah' +creating file `xai' +creating file `xaj' +creating file `xak' +creating file `xal' +creating file `xam' +creating file `xan' +creating file `xao' +creating file `xap' +creating file `xaq' +creating file `xar' +creating file `xas' +creating file `xat' +creating file `xau' +creating file `xav' +creating file `xaw' +creating file `xax' +creating file `xay' +creating file `xaz' +creating file `xba' +EOF + +cmp err exp || fail=1 +test $fail = 1 && diff err exp 2> /dev/null + +(exit $fail); exit $fail diff --git a/tests/misc/split-fail b/tests/misc/split-fail new file mode 100755 index 0000000..70435b4 --- /dev/null +++ b/tests/misc/split-fail @@ -0,0 +1,88 @@ +#!/bin/sh +# split must fail when given length/count of zero. + +# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + split --version +fi + +. $srcdir/../lang-default + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 +touch in || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +fail=0 + +split -a 0 in 2> /dev/null || fail=1 +split -b 0 in 2> /dev/null && fail=1 +split -C 0 in 2> /dev/null && fail=1 +split -l 0 in 2> /dev/null && fail=1 + +# Make sure that the obsolete -N notation still works +split -1 in 2> /dev/null || fail=1 + +# Then make sure that -0 evokes a failure. +split -0 in 2> /dev/null && fail=1 + +# Ensure that split --lines=N and --bytes=N work for N=2^32, +# assuming our host supports integers that wide. +if _4gb=`expr 4294967296 + 0 2>/dev/null`; then + split --lines=$_4gb in || fail=1 + split --bytes=$_4gb in || fail=1 +fi + +# Currently (coreutils-5.0.1) split --line-bytes=M fails +# with `invalid number of bytes' for M=2^32 or larger. Actually, +# the limit is SIZE_MAX, which is 2^32 on 32-bit systems. +# On 64-bit systems, there's no problem with a count of 2^32, +# So disable this test in order to avoid the `failure' on 64-bit systems. +#split --line-bytes=$_4gb 2> /dev/null in && fail=1 + +# Make sure that a huge obsolete option evokes the right failure. +split -99999999999999999991 2> out && fail=1 + +# On losing systems (x86 Solaris 5.9 c89), we get a message like this: +# split: line count option -9999999999... is too large +# while on most, we get this: +# split: line count option -99999999999999999991... is too large +# so map them both to -99*. +sed 's/99[19]*/99*/' out > out-t +mv -f out-t out + +cat <<\EOF > exp +split: line count option -99*... is too large +EOF +cmp out exp || fail=1 +test $fail = 1 && diff out exp 2> /dev/null + + +(exit $fail); exit $fail diff --git a/tests/misc/split-l b/tests/misc/split-l new file mode 100755 index 0000000..4491683 --- /dev/null +++ b/tests/misc/split-l @@ -0,0 +1,64 @@ +#!/bin/sh +# show that `split --lines=2' works. + +# Copyright (C) 2002, 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + ln --version +fi + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 +printf '1\n2\n3\n4\n5\n' > in || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +fail=0 + +split --lines=2 in > out || fail=1 +cat <<\EOF > exp-1 +1 +2 +EOF +cat <<\EOF > exp-2 +3 +4 +EOF +cat <<\EOF > exp-3 +5 +EOF + +cmp xaa exp-1 || fail=1 +test $fail = 1 && diff xaa exp 2> /dev/null +cmp xab exp-2 || fail=1 +test $fail = 2 && diff xab exp 2> /dev/null +cmp xac exp-3 || fail=1 +test $fail = 3 && diff xac exp 2> /dev/null +test -f xad && fail=1 + +(exit $fail); exit $fail diff --git a/tests/misc/stat-fmt b/tests/misc/stat-fmt new file mode 100755 index 0000000..435fbbb --- /dev/null +++ b/tests/misc/stat-fmt @@ -0,0 +1,48 @@ +#!/bin/sh +# ensure that stat properly handles a format string ending with % + +# Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + stat --version +fi + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +fail=0 + +for i in `seq 50`; do + fmt=`printf "%${i}s" %` + out=`stat --form="$fmt" .` + test "$out" = "$fmt" || fail=1 +done + +(exit $fail); exit $fail diff --git a/tests/misc/stat-printf b/tests/misc/stat-printf new file mode 100755 index 0000000..ecd4940 --- /dev/null +++ b/tests/misc/stat-printf @@ -0,0 +1,78 @@ +#!/bin/sh +# Test "stat --printf". + +# Copyright (C) 2005, 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +: ${PERL=perl} +: ${srcdir=.} + +$PERL -e 1 > /dev/null 2>&1 || { + echo 1>&2 "$0: configure didn't find a usable version of Perl," \ + "so can't run this test" + exit 77 +} + +exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF +require 5.003; +use strict; + +(my $ME = $0) =~ s|.*/||; +my $prog = 'stat'; + +# Turn off localisation of executable's ouput. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my @Tests = + ( + # test-name, [option, option, ...] {OUT=>"expected-output"} + # + ['nl', q!--printf='\n' .!, {OUT=>"\n"}], + ['no-nl', "--printf=%n .", {OUT=>"."}], + ['pct-and-esc', q!--printf='\0%n\0' .!, {OUT=>"\0.\0"}], + ['backslash', q!--printf='\\\\' .!, {OUT=>"\\"}], + ['nul', q!--printf='\0' .!, {OUT=>"\0"}], + # Don't bother testing \v, since Perl doesn't handle it. + ['bel-etc', q!--printf='\a\b\f\n\r\t' .!, {OUT=>"\a\b\f\n\r\t"}], + ['octal-1', q!--printf='\012\377' .!, {OUT=>"\012\377"}], + ['octal-2', q!--printf='.\012a\377b' .!, {OUT=>".\012a\377b"}], + ['hex-1', q!--printf='\x34\xf' .!, {OUT=>"\x34\xf"}], + ['hex-2', q!--printf='.\x18p\xfq' .!, {OUT=>".\x18p\x0fq"}], + ['hex-3', q!--printf='\x' .!, {OUT=>'x'}, + {ERR=>"$prog: warning: unrecognized escape `\\x'\n"}], + + # With --format, there *is* a trailing newline. + ['f-nl', "--format=%n .", {OUT=>".\n"}], + ['f-nl2', "--format=%n . .", {OUT=>".\n.\n"}], + + ['end-pct', "--printf=% .", {OUT=>"%"}], + ['pct-pct', "--printf=%% .", {OUT=>"%"}], + ['end-bs', "--printf='\\' .", {OUT=>'\\'}, + {ERR=>"$prog: warning: backslash at end of format\n"}], + + ['err-1', "--printf=%9% .", {EXIT => 1}, + {ERR=>"$prog: %9%: invalid directive\n"}], + ['err-2', "--printf=%9 .", {EXIT => 1}, + {ERR=>"$prog: %9: invalid directive\n"}], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose); +exit $fail; +EOF diff --git a/tests/misc/tac-continue b/tests/misc/tac-continue new file mode 100755 index 0000000..d8f50ff --- /dev/null +++ b/tests/misc/tac-continue @@ -0,0 +1,92 @@ +#!/bin/sh +# Ensure that tac processes all command line arguments, even +# when it encounters an error with say the first one. +# With coreutils-5.2.1 and earlier, this test would fail. + +# Copyright (C) 2004, 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + tac --version +fi + +. $srcdir/../lang-default + +# See if the envvar is defined. +if test x = "x$FULL_PARTITION_TMPDIR"; then + echo "$0: FULL_PARTITION_TMPDIR not defined; skipping this test" 1>&2 + (exit 77); exit 77 +fi + +if ! test -d "$FULL_PARTITION_TMPDIR"; then + echo "$0: $FULL_PARTITION_TMPDIR:" \ + "\$FULL_PARTITION_TMPDIR does not specify a directory" 1>&2 + (exit 1); exit 1 +fi + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 + +fp_tmp="$FULL_PARTITION_TMPDIR/tac-cont-$$" +t0="$t0 $fp_tmp" +# Make sure we can create an empty file there (i.e. no shortage of inodes). +if ! touch $fp_tmp; then + echo "$0: $fp_tmp: cannot create empty file" 1>&2 + (exit 1); exit 1 +fi + +# Make sure that we fail when trying to create a file large enough +# to consume a non-inode block. +if seq 1000 > $fp_tmp 2>/dev/null; then + echo "$0: $FULL_PARTITION_TMPDIR: not a full partition" 1>&2 + (exit 1); exit 1 +fi + +seq 5 > in + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +fail=0 + +# Give tac a fifo command line argument. +# This makes it try to create a temporary file in $TMPDIR. +mkfifo fifo +seq 1000 > fifo & +TMPDIR=$FULL_PARTITION_TMPDIR tac fifo in >out 2>err && fail=1 + +cat <<\EOF > exp || fail=1 +5 +4 +3 +2 +1 +EOF + +cmp out exp || fail=1 +test $fail = 1 && diff out exp 2> /dev/null + +(exit $fail); exit $fail diff --git a/tests/misc/test-diag b/tests/misc/test-diag new file mode 100755 index 0000000..d2a40fa --- /dev/null +++ b/tests/misc/test-diag @@ -0,0 +1,53 @@ +#!/bin/sh +# Test the diagnostics of "test". + +# Copyright (C) 2006, 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +: ${PERL=perl} +: ${srcdir=.} + +$PERL -e 1 > /dev/null 2>&1 || { + echo 1>&2 "$0: configure didn't find a usable version of Perl," \ + "so can't run this test" + exit 77 +} + +exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF +require 5.003; +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localisation of executable's ouput. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $prog = '../../src/test'; +my @Tests = + ( + # In coreutils-5.93, this diagnostic lacked the newline. + ['o', '-o arg', {ERR => "test: extra argument `-o'\n"}, + {ERR_SUBST => 's!^$prog:!test:!'}, + {EXIT => 2}], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; +EOF diff --git a/tests/misc/tty-eof b/tests/misc/tty-eof new file mode 100755 index 0000000..dca154e --- /dev/null +++ b/tests/misc/tty-eof @@ -0,0 +1,128 @@ +#!/bin/sh +# -*- perl -*- +# Test whether programs exit upon a single EOF from a tty. + +# Copyright (C) 2003, 2006, 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +: ${PERL=perl} + +$PERL -e 1 > /dev/null 2>&1 || { + echo 1>&2 "$0: configure didn't find a usable version of Perl," \ + "so can't run this test" + exit 77 +} + +ARGV_0=$0 +export ARGV_0 + +exec $PERL -w -- - <<\EOF + +# Ensure that cat exits upon a single EOF (^D) from a tty. +# Do the same for all programs that can read stdin, +# require no arguments and that write to standard output. +use strict; + +(my $ME = $ENV{ARGV_0}) =~ s|.*/||; + +# Some older versions of Expect.pm (e.g. 1.07) lack the log_user method, +# so check for that, too. +eval { require Expect; Expect->require_version('1.11') }; +$@ and (warn "$ME: this script requires Perl's Expect package >=1.11\n"), + exit 77; + +{ + my $fail = 0; + my @stdin_reading_commands = qw( + base64 + cat + cksum + dd + expand + fmt + fold + head + md5sum + nl + od + paste + pr + ptx + sha1sum + sha224sum + sha256sum + sha384sum + sha512sum + shuf + sort + sum + tac + tail + tee + tsort + unexpand + uniq + wc + ); + my $stderr = 'tty-eof.err'; + foreach my $cmd ((@stdin_reading_commands), 'cut -f2') + { + my $exp = new Expect; + $exp->log_user(0); + $exp->spawn("$cmd 2> $stderr") + or (warn "$ME: cannot run `$cmd': $!\n"), $fail=1, next; + # No input for cut -f2. + $cmd =~ /^cut/ + or $exp->send("a b\n"); + $exp->send("\cD"); # This is Control-D. FIXME: what if that's not EOF? + $exp->expect (0, '-re', "^a b\\r?\$"); + my $found = $exp->expect (1, '-re', "^.+\$"); + # $found and warn "F: $found: " . $exp->exp_match () . "\n"; + $exp->expect(1, 'eof'); + # Expect no output from cut, since we gave it no input. + defined $found || $cmd =~ /^cut/ + or (warn "$ME: $cmd didn't produce expected output\n"), + $fail=1, next; + defined $exp->exitstatus + or (warn "$ME: $cmd didn't exit after ^D from standard input\n"), + $fail=1, next; + my $s = $exp->exitstatus; + $s == 0 + or (warn "$ME: $cmd exited with status $s (expected 0)\n"), + $fail=1; + $exp->hard_close(); + + # dd normally writes to stderr. If it exits successfully, we're done. + $cmd eq 'dd' && $s == 0 + and next; + + if (-s $stderr) + { + warn "$ME: $cmd wrote to stderr:\n"; + system "cat $stderr"; + $fail = 1; + } + } + continue + { + unlink $stderr + or warn "$ME: failed to remove stderr file from $cmd, $stderr: $!\n"; + } + + exit $fail +} +EOF diff --git a/tests/misc/wc-files0 b/tests/misc/wc-files0 new file mode 100755 index 0000000..8991e7e --- /dev/null +++ b/tests/misc/wc-files0 @@ -0,0 +1,66 @@ +#!/bin/sh +# Show that wc's new --files0-from option works. + +# Copyright (C) 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + wc --version +fi + +. $srcdir/../lang-default + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 + +echo 2 > 2b || framework_failure=1 +echo 2 words > 2w || framework_failure=1 +printf '2b\n2w\n' |tr '\n' '\0' > names || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +fail=0 + +wc --files0-from=names > out || fail=1 +cat <<\EOF > exp || fail=1 + 1 1 2 2b + 1 2 8 2w + 2 3 10 total +EOF + +cmp out exp || fail=1 +test $fail = 1 && diff out exp 2> /dev/null + +if test "$fail" = ''; then + # Repeat the above test, but read the file name list from stdin. + rm -f out + wc --files0-from=- < names > out || fail=1 + cmp out exp || fail=1 + test $fail = 1 && diff out exp 2> /dev/null +fi + +(exit $fail); exit $fail diff --git a/tests/misc/wc-files0-from b/tests/misc/wc-files0-from new file mode 100755 index 0000000..72f1bdf --- /dev/null +++ b/tests/misc/wc-files0-from @@ -0,0 +1,108 @@ +#!/bin/sh +# -*- perl -*- +# Exercise wc's --files0-from option. +# This file bears a striking resemblance to tests/du/files0-from. + +# Copyright (C) 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +: ${PERL=perl} +: ${srcdir=.} + +. $srcdir/../envvar-check + +$PERL -e 1 > /dev/null 2>&1 || { + echo 1>&2 "$0: configure didn't find a usable version of Perl," \ + "so can't run this test" + exit 77 +} + +exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF +#/ +require 5.003; +use strict; + +(my $program_name = $0) =~ s|.*/||; + +$ENV{PROG} = 'wc'; +my $ME = $ENV{PROG}; + +# Turn off localization of executable's ouput. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my @Tests = + ( + # invalid extra command line argument + ['f-extra-arg', '--files0-from=- no-such', {IN=>"a"}, {EXIT=>1}, + {ERR => "$ME: extra operand `no-such'\n" + . "File operands cannot be combined with --files0-from.\n" + . "Try `$ME --help' for more information.\n"} + ], + + # missing input file + ['missing', '--files0-from=missing', {EXIT=>1}, + {ERR => "$ME: cannot open `missing' for reading: " + . "No such file or directory\n"}], + + # empty input + ['empty', '--files0-from=-'], + + # empty input, from non-regular file + ['empty-nonreg', '--files0-from=/dev/null'], + + # one NUL + ['nul-1', '--files0-from=-', '<', {IN=>"\0"}, {EXIT=>1}, + {ERR => "$ME: : No such file or directory\n"}], + + # two NULs + ['nul-2', '--files0-from=-', '<', {IN=>"\0\0"}, {EXIT=>1}, + {OUT=>"0 0 0 total\n"}, + {ERR => "$ME: : No such file or directory\n" + . "$ME: : No such file or directory\n"}], + + # one file name, no NUL + ['1', '--files0-from=-', '<', + {IN=>{f=>"g"}}, {AUX=>{g=>''}}, {OUT=>"0 0 0 g\n"} ], + + # one file name, with NUL + ['1a', '--files0-from=-', '<', + {IN=>{f=>"g\0"}}, {AUX=>{g=>''}}, {OUT=>"0 0 0 g\n"} ], + + # two file names, no final NUL + ['2', '--files0-from=-', '<', + {IN=>{f=>"g\0g"}}, {AUX=>{g=>''}}, + {OUT=>"0 0 0 g\n0 0 0 g\n0 0 0 total\n"} ], + + # two file names, with final NUL + ['2a', '--files0-from=-', '<', + {IN=>{f=>"g\0g\0"}}, {AUX=>{g=>''}}, + {OUT=>"0 0 0 g\n0 0 0 g\n0 0 0 total\n"} ], + + # Ensure that wc processes FILEs following a zero-length name. + ['zero-len', '--files0-from=-', '<', + {IN=>{f=>"\0g\0"}}, {AUX=>{g=>''}}, + {OUT=>"0 0 0 g\n0 0 0 total\n"}, + {ERR => "$ME: : No such file or directory\n"}, {EXIT=>1} ], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; +EOF |