From: DongHun Kwak Date: Wed, 16 Dec 2015 04:46:35 +0000 (+0900) Subject: Bump to Coreutils 6.9 X-Git-Tag: submit/tizen/20151223.035611^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a436aad18667e14fd496ab08b728ab148b05bf2b;p=product%2Fupstream%2Fcoreutils.git Bump to Coreutils 6.9 Sync with tizen 2.4 Run unit test Change-Id: I37949360a56432aefc96bf27c16196bdba752956 Signed-off-by: DongHun Kwak --- diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 4567b1b..0000000 --- a/.gitignore +++ /dev/null @@ -1,39 +0,0 @@ -*.1 -*.I[12] -*.[EIOX] -*.gmo -*.o -*/.deps -*~ -.kludge-stamp -ABOUT-NLS -INSTALL -Makefile -Makefile.in -THANKS-to-translators -aclocal.m4 -autom4te.cache -config.cache -config.h -config.hin -config.log -config.status -configure -coreutils-*.tar.bz2 -coreutils-*.tar.bz2.sig -coreutils-*.tar.gz -coreutils-*.tar.gz.sig -coreutils-*.xdelta -coreutils-*.xdelta.sig -stamp-h1 -tests/cut/cut-tests -tests/head/head-tests -tests/join/join-tests -tests/pr/pr-tests -tests/sort/sort-tests -tests/tac/tac-tests -tests/tail/tail-tests -tests/test/test-tests -tests/tr/tr-tests -tests/uniq/uniq-tests -tests/wc/wc-tests diff --git a/.hgignore b/.hgignore deleted file mode 100644 index efbf44f..0000000 --- a/.hgignore +++ /dev/null @@ -1,147 +0,0 @@ -.*/Makefile$ -.*/Makefile\.in$ -.*/\.deps/ -.*\.1$ -.*\.o$ -.*~$ -^Makefile$ -^Makefile\.in$ -^THANKS-to-translators$ -^aclocal\.m4$ -^autom4te\.cache/ -^config\.h$ -^config\.hin$ -^config\.log$ -^config\.status$ -^configure$ -^doc/constants\.texi$ -^doc/coreutils\.info$ -^doc/stamp-vti$ -^doc/version\.texi$ -^lib/alloca\.h$ -^lib/charset\.alias$ -^lib/getdate\.c$ -^lib/libcoreutils\.a$ -^lib/ref-add\.sed$ -^lib/ref-del\.sed$ -^lib/t-fpending$ -^po/.*\.gmo$ -^po/.*\.po$ -^po/POTFILES$ -^po/stamp-po$ -^po/remove-potcdate.sed$ -^src/\[$ -^src/base64$ -^src/basename$ -^src/cat$ -^src/chgrp$ -^src/chmod$ -^src/chown$ -^src/chroot$ -^src/cksum$ -^src/comm$ -^src/cp$ -^src/csplit$ -^src/cut$ -^src/date$ -^src/dd$ -^src/df$ -^src/dir$ -^src/dircolors$ -^src/dircolors\.h$ -^src/dirname$ -^src/du$ -^src/echo$ -^src/env$ -^src/expand$ -^src/expr$ -^src/factor$ -^src/false$ -^src/fmt$ -^src/fold$ -^src/fs\.h$ -^src/ginstall$ -^src/groups$ -^src/head$ -^src/hostid$ -^src/hostname$ -^src/id$ -^src/join$ -^src/kill$ -^src/link$ -^src/ln$ -^src/localedir\.h$ -^src/logname$ -^src/ls$ -^src/md5sum$ -^src/mkdir$ -^src/mkfifo$ -^src/mknod$ -^src/mv$ -^src/nice$ -^src/nl$ -^src/nohup$ -^src/od$ -^src/paste$ -^src/pathchk$ -^src/pinky$ -^src/pr$ -^src/printenv$ -^src/printf$ -^src/ptx$ -^src/pwd$ -^src/readlink$ -^src/rm$ -^src/rmdir$ -^src/seq$ -^src/setuidgid$ -^src/sha1sum$ -^src/sha224sum$ -^src/sha256sum$ -^src/sha384sum$ -^src/sha512sum$ -^src/shred$ -^src/sleep$ -^src/sort$ -^src/split$ -^src/stat$ -^src/stty$ -^src/su$ -^src/sum$ -^src/sync$ -^src/tac$ -^src/tail$ -^src/tee$ -^src/test$ -^src/touch$ -^src/tr$ -^src/true$ -^src/tsort$ -^src/tty$ -^src/uname$ -^src/unexpand$ -^src/uniq$ -^src/unlink$ -^src/uptime$ -^src/users$ -^src/vdir$ -^src/wc$ -^src/wheel-size\.h$ -^src/wheel\.h$ -^src/who$ -^src/whoami$ -^src/yes$ -^stamp-h1$ -^tests/.*\.I[12]$ -^tests/.*\.[EIOX]$ -^tests/cut/cut-tests$ -^tests/head/head-tests$ -^tests/join/join-tests$ -^tests/pr/pr-tests$ -^tests/sort/sort-tests$ -^tests/tac/tac-tests$ -^tests/tail/tail-tests$ -^tests/test/test-tests$ -^tests/tr/tr-tests$ -^tests/uniq/uniq-tests$ -^tests/wc/wc-tests$ diff --git a/.kludge-stamp b/.kludge-stamp deleted file mode 100644 index e69de29..0000000 diff --git a/.prev-version b/.prev-version deleted file mode 100644 index 341291e..0000000 --- a/.prev-version +++ /dev/null @@ -1 +0,0 @@ -6.7 diff --git a/.vg-suppressions b/.vg-suppressions deleted file mode 100644 index a6cb2fe..0000000 --- a/.vg-suppressions +++ /dev/null @@ -1,79 +0,0 @@ -# Suppress valgrind diagnostics we don't care about. - -# 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. - -{ - libc_dl_open - Memcheck:Cond - fun:_dl_relocate_object - obj:/lib/libc-2.3.2.so - fun:_dl_catch_error - fun:_dl_open -} - -{ - libc_dl_catch_error__map_object - Memcheck:Addr1 - obj:/lib/ld-2.3.2.so - fun:_dl_map_object - obj:/lib/libc-2.3.2.so - fun:_dl_catch_error -} -{ - libc_dl_catch_error__map_versions - Memcheck:Addr1 - obj:/lib/ld-2.3.2.so - fun:_dl_check_map_versions - obj:/lib/libc-2.3.2.so - fun:_dl_catch_error -} - -{ - jm_libc_sigaction - Memcheck:Param - sigaction(act) - fun:__libc_sigaction -} - -{ - libc_expand_dynamic_string_token - Memcheck:Cond - fun:strlen - fun:expand_dynamic_string_token - obj:* - obj:* - obj:* - obj:* - obj:* -} -{ - libc__dl_new_object - Memcheck:Cond - fun:strlen - fun:_dl_new_object - obj:* - obj:* - obj:* - obj:* -} -{ - libc_fillin_rpath - Memcheck:Cond - fun:strlen - fun:fillin_rpath -} diff --git a/.x-po-check b/.x-po-check deleted file mode 100644 index 202ec8e..0000000 --- a/.x-po-check +++ /dev/null @@ -1,4 +0,0 @@ -ChangeLog(-[0-9]+)?$ -^old/ -^src/c99-to-c98\.diff$ -^gl/.* diff --git a/.x-sc_file_system b/.x-sc_file_system deleted file mode 100644 index a2e3887..0000000 --- a/.x-sc_file_system +++ /dev/null @@ -1,8 +0,0 @@ -ChangeLog -Makefile.maint -NEWS -config-log -po/ -src/df.c -src/stat.c -tests/misc/df-P diff --git a/.x-sc_obsolete_symbols b/.x-sc_obsolete_symbols deleted file mode 100644 index a2fe831..0000000 --- a/.x-sc_obsolete_symbols +++ /dev/null @@ -1,6 +0,0 @@ -ChangeLog* -Makefile.maint -config.hin -configure -m4/jm-macros.m4 -src/system.h diff --git a/.x-sc_prohibit_atoi_atof b/.x-sc_prohibit_atoi_atof deleted file mode 100644 index d995223..0000000 --- a/.x-sc_prohibit_atoi_atof +++ /dev/null @@ -1,11 +0,0 @@ -^configure$ -ChangeLog -^TODO$ -^lib/mktime\.c$ -^lib/getloadavg\.c$ -^lib/euidaccess\.c$ -^lib/euidaccess-stat\.c$ -^lib/group-member\.c$ -^Makefile\.maint$ -^doc/coreutils.texi$ -^src/stty.c$ diff --git a/.x-sc_require_config_h b/.x-sc_require_config_h deleted file mode 100644 index 415a113..0000000 --- a/.x-sc_require_config_h +++ /dev/null @@ -1,28 +0,0 @@ -^lib/at-func\.c$ -^lib/bcopy\.c$ -^lib/buffer-lcm\.c$ -^lib/c-strtold\.c$ -^lib/fnmatch_loop\.c$ -^lib/full-read\.c$ -^lib/imaxtostr\.c$ -^lib/mempcpy\.c$ -^lib/memset\.c$ -^lib/offtostr\.c$ -^lib/regcomp\.c$ -^lib/regex_internal\.c$ -^lib/regexec\.c$ -^lib/safe-write\.c$ -^lib/strtoll\.c$ -^lib/strtoul\.c$ -^lib/strtoull\.c$ -^lib/strtoumax\.c$ -^lib/umaxtostr\.c$ -^lib/xstrtold\.c$ -^lib/xstrtoul\.c$ -^src/false\.c$ -^src/lbracket\.c$ -^src/ls-dir\.c$ -^src/ls-ls\.c$ -^src/ls-vdir\.c$ -^src/rand-isaac\.c$ -^src/tac-pipe\.c$ diff --git a/.x-sc_space_tab b/.x-sc_space_tab deleted file mode 100644 index f52ebd0..0000000 --- a/.x-sc_space_tab +++ /dev/null @@ -1,11 +0,0 @@ -config(ure|\.(guess|sub)) -tests/pr -lib/regex.c -config-log -tests/misc/nl -po/de.po -m4/lib-ld.m4 -m4/lib-prefix.m4 -m4/po.m4 -aclocal.m4 -src/c99-to-c89.diff diff --git a/.x-sc_sun_os_names b/.x-sc_sun_os_names deleted file mode 100644 index 3ffc52c..0000000 --- a/.x-sc_sun_os_names +++ /dev/null @@ -1,2 +0,0 @@ -config-log -build-aux/config.guess diff --git a/.x-sc_trailing_blank b/.x-sc_trailing_blank deleted file mode 100644 index 92571d6..0000000 --- a/.x-sc_trailing_blank +++ /dev/null @@ -1 +0,0 @@ -^tests/pr/ diff --git a/.x-sc_unmarked_diagnostics b/.x-sc_unmarked_diagnostics deleted file mode 100644 index aac8984..0000000 --- a/.x-sc_unmarked_diagnostics +++ /dev/null @@ -1,2 +0,0 @@ -^lib/xstrtol\.h$ -^build-aux/cvsu$ diff --git a/.x-sc_useless_cpp_parens b/.x-sc_useless_cpp_parens deleted file mode 100644 index 01eb4b4..0000000 --- a/.x-sc_useless_cpp_parens +++ /dev/null @@ -1,13 +0,0 @@ -^build-aux/config.guess -^configure -^lib/alloca.c -^lib/fts.c -^lib/getdate.c -^lib/getloadavg.c -^lib/gettext.h -^lib/getusershell.c -^lib/mbswidth.c -^lib/strtod.c -^lib/xstrtol.c -^m4/ -^tests/misc/pwd-unreadable-parent diff --git a/lib/utimens.c b/lib/utimens.c index 71bc510..49a2eae 100644 --- a/lib/utimens.c +++ b/lib/utimens.c @@ -75,7 +75,7 @@ struct utimbuf Return 0 on success, -1 (setting errno) on failure. */ int -futimens (int fd ATTRIBUTE_UNUSED, +gl_futimens (int fd ATTRIBUTE_UNUSED, char const *file, struct timespec const timespec[2]) { /* Some Linux-based NFS clients are buggy, and mishandle time stamps @@ -185,5 +185,5 @@ futimens (int fd ATTRIBUTE_UNUSED, int utimens (char const *file, struct timespec const timespec[2]) { - return futimens (-1, file, timespec); + return gl_futimens (-1, file, timespec); } diff --git a/lib/utimens.h b/lib/utimens.h index 0097aaa..169521d 100644 --- a/lib/utimens.h +++ b/lib/utimens.h @@ -1,3 +1,3 @@ #include -int futimens (int, char const *, struct timespec const [2]); +int gl_futimens (int, char const *, struct timespec const [2]); int utimens (char const *, struct timespec const [2]); diff --git a/packaging/baselibs.conf b/packaging/baselibs.conf new file mode 100644 index 0000000..34d4a2b --- /dev/null +++ b/packaging/baselibs.conf @@ -0,0 +1,3 @@ +targettype x86 package coreutils + +^/bin/uname$ + prereq -glibc-x86 diff --git a/packaging/coreutils.manifest b/packaging/coreutils.manifest new file mode 100644 index 0000000..67da90f --- /dev/null +++ b/packaging/coreutils.manifest @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/packaging/coreutils.spec b/packaging/coreutils.spec new file mode 100644 index 0000000..1fa1379 --- /dev/null +++ b/packaging/coreutils.spec @@ -0,0 +1,151 @@ +%define _unpackaged_files_terminate_build 0 + +%define run_tests 0 +%if %{run_tests} + # check is defined off at .rpmmacros file. + %undefine check +%endif + +Summary: The GNU core utilities: a set of tools commonly used in shell scripts + +Name: coreutils +Version: 6.9 +Release: 14 +License: GPL-2.0+ +Group: System Environment/Base +Url: http://www.gnu.org/software/coreutils/ +Source0: coreutils-%{version}.tar.bz2 +Source1: mktemp-1.5.tar.gz +Source1001: %{name}.manifest + +BuildRequires: autoconf >= 2.58 +BuildRequires: automake >= 1.10 +BuildRequires: gettext findutils + +Provides: fileutils sh-utils stat textutils mktemp +Provides: coreutils +Obsoletes: coreutils + +%description +These are the GNU core utilities. This package is the combination of +the old GNU fileutils, sh-utils, and textutils packages. + +%prep +%setup -q -b 1 -n coreutils-%{version} + +%build +cp %{SOURCE1001} . + +export CFLAGS=" -fpie" +export LDFLAGS=" -pie" + +pushd ../mktemp-1.5 +%configure +make +popd + +%configure +make + +%check +%if %{run_tests} + %__make check || exit 0 + chmod 755 ./run_test.sh + ./run_test.sh %{name} %{version} +%endif + +%install + +pushd ../mktemp-1.5 +make bindir=%{buildroot}/bin mandir=%{buildroot}%{_mandir} install +popd + +%make_install + +# man pages are not installed with make install +make mandir=%{buildroot}%{_mandir} install-man + +# let be compatible with old fileutils, sh-utils and textutils packages : +mkdir -p %{buildroot}{/bin,%{_bindir},%{_sbindir},/sbin} +for f in cat chgrp chmod chown cp date dd df echo link ln ls mkdir mknod mv pwd rm rmdir sleep sync touch true uname unlink +do + mv %{buildroot}{%{_bindir},/bin}/$f +done + +# chroot was in /usr/sbin : +mv %{buildroot}{%{_bindir},%{_sbindir}}/chroot + +# These come from util-linux and/or procps. +for i in hostname uptime kill ; do + rm %{buildroot}{%{_bindir}/$i,%{_mandir}/man1/$i.1} +done + +# Use hard links instead of symbolic links for LC_TIME files (bug #246729). +find %{buildroot}%{_datadir}/locale -type l | \ +(while read link + do + target=$(readlink "$link") + rm -f "$link" + ln "$(dirname "$link")/$target" "$link" + done) + +%clean +rm -rf $RPM_BUILD_ROOT + +%docs_package + +%files +%manifest %{name}.manifest +%license COPYING +/bin/cat +/bin/chgrp +/bin/chmod +/bin/chown +/bin/cp +/bin/date +/bin/dd +/bin/df +/bin/echo +/bin/ln +/bin/ls +/bin/mkdir +/bin/mknod +/bin/mktemp +/bin/mv +/bin/pwd +/bin/rm +/bin/rmdir +/bin/sleep +/bin/sync +/bin/touch +/bin/true +/bin/uname +%{_bindir}/basename +%{_bindir}/cksum +%{_bindir}/cut +%{_bindir}/dirname +%{_bindir}/du +%{_bindir}/env +%{_bindir}/expr +%{_bindir}/head +%{_bindir}/id +%{_bindir}/install +%{_bindir}/md5sum +%{_bindir}/nice +%{_bindir}/od +%{_bindir}/printenv +%{_bindir}/printf +%{_bindir}/readlink +%{_bindir}/seq +%{_bindir}/sort +%{_bindir}/stat +%{_bindir}/tac +%{_bindir}/tail +%{_bindir}/tee +%{_bindir}/test +%{_bindir}/tr +%{_bindir}/uniq +%{_bindir}/wc +%{_bindir}/who +%{_bindir}/whoami +%{_sbindir}/chroot diff --git a/packaging/mktemp-1.5.tar.gz b/packaging/mktemp-1.5.tar.gz new file mode 100644 index 0000000..0e1249f Binary files /dev/null and b/packaging/mktemp-1.5.tar.gz differ diff --git a/run_test.sh b/run_test.sh new file mode 100755 index 0000000..c781b04 --- /dev/null +++ b/run_test.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +PACKAGE_NAME=$1 +PACKAGE_VERSION=$2 + +TEST_LOG="/tmp/${PACKAGE_NAME}_test" +export TEST_LOG + +# Color +Color_Off='\e[0m' # Text Reset + +# Regular Colors +Red='\e[0;31m' # Red +Green='\e[0;32m' # Green +Cyan='\e[0;36m' # Cyank + +# Bold +BWhite='\e[1;37m' # White + +result_check() { + test_case=$1 + if [ $? -eq 0 ] + then + echo -e "${Green}PASS${Color_Off}: $test_case" + echo "TEST: PASS: $test_case" >> ${TEST_LOG} + else + echo -e "${Red}FAIL${Color_Off}: $test_case" + echo -e "TEST: FAIL: $test_case" >> ${TEST_LOG} + fi +} + +skip_test() { + test_case=$1 + echo -e "${Cyan}SKIP${Color_Off}: $test_case" + echo "TEST: SKIP: $test_case" >> ${TEST_LOG} +} + +TOTAL_CNT=`grep "TEST:" ${TEST_LOG} | wc -l` +PASS_CNT=`grep "PASS:" ${TEST_LOG} | wc -l` +FAIL_CNT=`grep "FAIL:" ${TEST_LOG} | wc -l` +SKIP_CNT=`grep "SKIP:" ${TEST_LOG} | wc -l` + + +br='==================='; br=$br$br$br$br; + +echo -e "${Green}$br ${Color_Off}" +echo -e "${Green}Test sheet summary for ${PACKAGE_NAME} ${PACKAGE_VERSION}${Color_Off}" +echo -e "${Green}$br ${Color_Off}" +echo -e "#${BWhite} TOTAL: $TOTAL_CNT ${Color_Off}" +echo -e "#${Green} PASS${Color_Off} : $PASS_CNT" +echo -e "#${Red} FAIL${Color_Off} : $FAIL_CNT" +echo -e "#${Cyan} SKIP${Color_Off} : $SKIP_CNT" +echo -e "${Green}$br ${Color_Off}" + +rm -f ${TEST_LOG} +exit 0 + diff --git a/src/copy.c b/src/copy.c index 4bdb75c..b42924b 100644 --- a/src/copy.c +++ b/src/copy.c @@ -53,6 +53,7 @@ #include "utimens.h" #include "xreadlink.h" #include "yesno.h" +#include "smack.h" #ifndef HAVE_FCHOWN # define HAVE_FCHOWN false @@ -518,7 +519,7 @@ copy_reg (char const *src_name, char const *dst_name, timespec[0] = get_stat_atime (src_sb); timespec[1] = get_stat_mtime (src_sb); - if (futimens (dest_desc, dst_name, timespec) != 0) + if (gl_futimens (dest_desc, dst_name, timespec) != 0) { error (0, errno, _("preserving times for %s"), quote (dst_name)); if (x->require_preserve) @@ -570,6 +571,30 @@ copy_reg (char const *src_name, char const *dst_name, } } + if (x->preserve_context) + { + struct smack_attrs src_context; + struct smack_attrs dst_context; + memset (&src_context, 0, sizeof(src_context)); + memset (&dst_context, 0, sizeof(dst_context)); + + if (smack_of_fd (source_desc, &src_context) < 0) + { + if (x->require_preserve) + ; //fail silently now // return_val = false; + } + else if (smack_of_fd (dest_desc, &dst_context) < 0) + { + if (x->require_preserve) + ; //fail silently now // return_val = false; + } + else if (smack_differs (&src_context, &dst_context)) + { + if (smack_to_fd (dest_desc, &src_context) < 0 && x->require_preserve) + ; //fail silently now // return_val = false; + } + } + close_src_and_dst_desc: if (close (dest_desc) < 0) { @@ -1891,6 +1916,30 @@ copy_internal (char const *src_name, char const *dst_name, } } + if (x->preserve_context) + { + struct smack_attrs src_context; + struct smack_attrs dst_context; + memset (&src_context, 0, sizeof(src_context)); + memset (&dst_context, 0, sizeof(dst_context)); + + if (smack_of_file (src_name, &src_context) < 0) + { + if (x->require_preserve) + ; //fail silently now // return false; + } + else if (smack_of_file (dst_name, &dst_context) < 0) + { + if (x->require_preserve) + ; //fail silently now // return false; + } + else if (smack_differs (&src_context, &dst_context)) + { + if (smack_to_file (dst_name, &src_context) < 0 && x->require_preserve) + ; //fail silently now // return false; + } + } + return delayed_ok; un_backup: diff --git a/src/copy.h b/src/copy.h index c815baf..0d0e69e 100644 --- a/src/copy.h +++ b/src/copy.h @@ -128,6 +128,10 @@ struct cp_options bool preserve_mode; bool preserve_timestamps; + /* If true, attempt to give the copies the original files' + security context. */ + bool preserve_context; + /* Enabled for mv, and for cp by the --preserve=links option. If true, attempt to preserve in the destination files any logical hard links between the source files. If used with cp's diff --git a/src/cp.c b/src/cp.c index 5759e0d..3f5d30f 100644 --- a/src/cp.c +++ b/src/cp.c @@ -35,6 +35,7 @@ #include "stat-time.h" #include "utimens.h" #include "acl.h" +#include "smack.h" #define ASSIGN_BASENAME_STRDUPA(Dest, File_name) \ do \ @@ -191,7 +192,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ -p same as --preserve=mode,ownership,timestamps\n\ --preserve[=ATTR_LIST] preserve the specified attributes (default:\n\ mode,ownership,timestamps), if possible\n\ - additional attributes: links, all\n\ + additional attributes: links, context, all\n\ "), stdout); fputs (_("\ --no-preserve=ATTR_LIST don't preserve the specified attributes\n\ @@ -317,6 +318,29 @@ re_protect (char const *const_dst_name, size_t src_offset, } } + if (x->preserve_context) + { + struct smack_attrs src_context; + struct smack_attrs dst_context; + memset (&src_context, 0, sizeof(src_context)); + memset (&dst_context, 0, sizeof(dst_context)); + + if (smack_of_file (src_name, &src_context) < 0 || + smack_of_file (dst_name, &dst_context) < 0) + { + ; //error (0, errno, _("failed to preserve context for %s"), + // quote (dst_name)); + //return false; + } + if (smack_differs (&src_context, &dst_context) && + smack_to_file (dst_name, &src_context) < 0) + { + ; //error (0, errno, _("failed to preserve context for %s"), + // quote (dst_name)); + //return false; + } + } + if (x->preserve_ownership) { if (chown (dst_name, src_sb.st_uid, src_sb.st_gid) != 0 @@ -749,6 +773,7 @@ cp_option_init (struct cp_options *x) x->preserve_links = false; x->preserve_mode = false; x->preserve_timestamps = false; + x->preserve_context = false; x->require_preserve = false; x->recursive = false; @@ -777,18 +802,19 @@ decode_preserve_arg (char const *arg, struct cp_options *x, bool on_off) PRESERVE_TIMESTAMPS, PRESERVE_OWNERSHIP, PRESERVE_LINK, + PRESERVE_CONTEXT, PRESERVE_ALL }; static enum File_attribute const preserve_vals[] = { PRESERVE_MODE, PRESERVE_TIMESTAMPS, - PRESERVE_OWNERSHIP, PRESERVE_LINK, PRESERVE_ALL + PRESERVE_OWNERSHIP, PRESERVE_LINK, PRESERVE_CONTEXT, PRESERVE_ALL }; /* Valid arguments to the `--preserve' option. */ static char const* const preserve_args[] = { "mode", "timestamps", - "ownership", "links", "all", NULL + "ownership", "links", "context", "all", NULL }; ARGMATCH_VERIFY (preserve_args, preserve_vals); @@ -824,11 +850,16 @@ decode_preserve_arg (char const *arg, struct cp_options *x, bool on_off) x->preserve_links = on_off; break; + case PRESERVE_CONTEXT: + x->preserve_context = on_off; + break; + case PRESERVE_ALL: x->preserve_mode = on_off; x->preserve_timestamps = on_off; x->preserve_ownership = on_off; x->preserve_links = on_off; + x->preserve_context = on_off; break; default: @@ -885,6 +916,8 @@ main (int argc, char **argv) x.preserve_ownership = true; x.preserve_mode = true; x.preserve_timestamps = true; + /* Context preservation may be draconian */ + x.preserve_context = true; x.require_preserve = true; x.recursive = true; break; diff --git a/src/id.c b/src/id.c index 7abb3e5..f775341 100644 --- a/src/id.c +++ b/src/id.c @@ -29,6 +29,7 @@ #include "system.h" #include "error.h" #include "quote.h" +#include "smack.h" /* The official name of this program (e.g., no `g' prefix). */ #define PROGRAM_NAME "id" @@ -40,6 +41,7 @@ int getugroups (); static void print_user (uid_t uid); static void print_group (gid_t gid); static void print_group_list (const char *username); +static void print_context (void); static void print_full_info (const char *username); /* The name this program was run with. */ @@ -52,11 +54,15 @@ static bool use_name = false; static uid_t ruid, euid; static gid_t rgid, egid; +/* The security "context" to print. */ +static char context[SMACK_LABELLEN]; + /* True unless errors have been encountered. */ static bool ok = true; static struct option const longopts[] = { + {"context", no_argument, NULL, 'Z'}, {"group", no_argument, NULL, 'g'}, {"groups", no_argument, NULL, 'G'}, {"name", no_argument, NULL, 'n'}, @@ -80,6 +86,7 @@ usage (int status) Print information for USERNAME, or the current user.\n\ \n\ -a ignore, for compatibility with other versions\n\ + -Z, --context print only the security context\n\ -g, --group print only the effective group ID\n\ -G, --groups print all group IDs\n\ -n, --name print a name instead of a number, for -ugG\n\ @@ -102,6 +109,8 @@ main (int argc, char **argv) { int optc; + /* If true, output only the security context. -Z */ + bool just_context = false; /* If true, output the list of all group IDs. -G */ bool just_group_list = false; /* If true, output only the group ID(s). -g */ @@ -119,13 +128,16 @@ main (int argc, char **argv) atexit (close_stdout); - while ((optc = getopt_long (argc, argv, "agnruG", longopts, NULL)) != -1) + while ((optc = getopt_long (argc, argv, "agnruGZ", longopts, NULL)) != -1) { switch (optc) { case 'a': /* Ignore -a, for compatibility with SVR4. */ break; + case 'Z': + just_context = true; + break; case 'g': just_group = true; break; @@ -148,8 +160,8 @@ main (int argc, char **argv) } } - if (just_user + just_group + just_group_list > 1) - error (EXIT_FAILURE, 0, _("cannot print only user and only group")); + if (just_user + just_group + just_group_list + just_context > 1) + error (EXIT_FAILURE, 0, _("cannot print multiple exclusive fields")); if (just_user + just_group + just_group_list == 0 && (use_real | use_name)) error (EXIT_FAILURE, 0, @@ -183,6 +195,8 @@ main (int argc, char **argv) print_group (use_real ? rgid : egid); else if (just_group_list) print_group_list (argv[optind]); + else if (just_context) + print_context (); else print_full_info (argv[optind]); putchar ('\n'); @@ -324,6 +338,18 @@ print_group_list (const char *username) #endif /* HAVE_GETGROUPS */ } +/* Print the security context. */ + +static void +print_context (void) +{ + + if (smack_of_proc(-1, context, sizeof (context)) < 1 || strlen(context) < 1) + printf (""); + else + printf ("%s", context); +} + /* Print all of the info about the user's user and group IDs. */ static void @@ -385,4 +411,7 @@ print_full_info (const char *username) free (groups); } #endif /* HAVE_GETGROUPS */ + + if (smack_of_proc(-1, context, sizeof (context)) > 0 && strlen(context) > 0) + printf (" context=\"%s\"", context); } diff --git a/src/install.c b/src/install.c index 0457751..40165d8 100644 --- a/src/install.c +++ b/src/install.c @@ -39,6 +39,7 @@ #include "stat-time.h" #include "utimens.h" #include "xstrtol.h" +#include "smack.h" /* The official name of this program (e.g., no `g' prefix). */ #define PROGRAM_NAME "install" @@ -115,6 +116,9 @@ static mode_t dir_mode = DEFAULT_MODE; or S_ISGID bits. */ static mode_t dir_mode_bits = CHMOD_MODE_BITS; +/* The security context to give all files. */ +static struct smack_attrs context; + /* If true, strip executable files after copying them. */ static bool strip_files; @@ -124,6 +128,7 @@ static bool dir_arg; static struct option const long_options[] = { {"backup", optional_argument, NULL, 'b'}, + {"context", required_argument, NULL, 'Z'}, {"directory", no_argument, NULL, 'd'}, {"group", required_argument, NULL, 'g'}, {"mode", required_argument, NULL, 'm'}, @@ -155,6 +160,7 @@ cp_option_init (struct cp_options *x) x->preserve_links = false; x->preserve_mode = false; x->preserve_timestamps = false; + x->preserve_context = false; x->require_preserve = false; x->recursive = false; x->sparse_mode = SPARSE_AUTO; @@ -243,7 +249,7 @@ main (int argc, char **argv) we'll actually use backup_suffix_string. */ backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX"); - while ((optc = getopt_long (argc, argv, "bcsDdg:m:o:pt:TvS:", long_options, + while ((optc = getopt_long (argc, argv, "bcsDdg:m:o:pt:TvS:Z:", long_options, NULL)) != -1) { switch (optc) @@ -305,6 +311,10 @@ main (int argc, char **argv) case 'T': no_target_directory = true; break; + case 'Z': + if (optarg) + strncpy(context.attr, optarg, SMACK_LABELLEN); + break; case_GETOPT_HELP_CHAR; case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); default: @@ -520,6 +530,8 @@ change_attributes (char const *name) error (0, errno, _("cannot change ownership of %s"), quote (name)); else if (chmod (name, mode) != 0) error (0, errno, _("cannot change permissions of %s"), quote (name)); + else if (context.attr[0] && smack_to_file (name, &context) < 0) + ; // error (0, errno, _("cannot change security context of %s"), quote (name)); else return true; @@ -686,6 +698,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ -t, --target-directory=DIRECTORY copy all SOURCE arguments into DIRECTORY\n\ -T, --no-target-directory treat DEST as a normal file\n\ -v, --verbose print the name of each directory as it is created\n\ + -Z, --context=CONTEXT set the security context on all destination files\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); diff --git a/src/ls.c b/src/ls.c index 3d48900..8517b41 100644 --- a/src/ls.c +++ b/src/ls.c @@ -104,6 +104,7 @@ #include "wcwidth.h" #include "xstrtol.h" #include "xreadlink.h" +#include "smack.h" #define PROGRAM_NAME (ls_mode == LS_LS ? "ls" \ : (ls_mode == LS_MULTI_COL \ @@ -177,6 +178,9 @@ struct fileinfo /* For long listings, true if the file has an access control list. */ bool have_acl; #endif + + /* Security context */ + struct smack_attrs context; }; #if USE_ACL @@ -339,6 +343,7 @@ static int nlink_width; static int owner_width; static int group_width; static int author_width; +static int context_width; static int major_device_number_width; static int minor_device_number_width; static int file_size_width; @@ -434,6 +439,10 @@ static bool print_owner = true; static bool print_author; +/* True means to display the security context. */ + +static bool print_context; + /* True means to display group information. -G and -o turn this off. */ static bool print_group = true; @@ -1514,7 +1523,7 @@ decode_switches (int argc, char **argv) } while ((c = getopt_long (argc, argv, - "abcdfghiklmnopqrstuvw:xABCDFGHI:LNQRST:UX1", + "abcdfghiklmnopqrstuvw:xABCDFGHI:LNQRST:UXZ1", long_options, NULL)) != -1) { switch (c) @@ -1717,6 +1726,10 @@ decode_switches (int argc, char **argv) sort_type_specified = true; break; + case 'Z': + print_context = true; + break; + case '1': /* -1 has no effect after -l. */ if (format != long_format) @@ -2574,6 +2587,7 @@ gobble_file (char const *name, enum filetype type, ino_t inode, /* Command line dereferences are already taken care of by the above assertion that the inode number is not yet known. */ || (print_inode && inode == NOT_AN_INODE_NUMBER) + || print_context || (format_needs_type && (type == unknown || command_line_arg /* --indicator-style=classify (aka -F) @@ -2605,6 +2619,7 @@ gobble_file (char const *name, enum filetype type, ino_t inode, switch (dereference) { case DEREF_ALWAYS: + err = smack_of_file_follow(absolute_name, &f->context); err = stat (absolute_name, &f->stat); break; @@ -2613,6 +2628,7 @@ gobble_file (char const *name, enum filetype type, ino_t inode, if (command_line_arg) { bool need_lstat; + err = smack_of_file_follow(absolute_name, &f->context); err = stat (absolute_name, &f->stat); if (dereference == DEREF_COMMAND_LINE_ARGUMENTS) @@ -2631,6 +2647,7 @@ gobble_file (char const *name, enum filetype type, ino_t inode, } default: /* DEREF_NEVER */ + err = smack_of_file(absolute_name, &f->context); err = lstat (absolute_name, &f->stat); break; } @@ -2738,6 +2755,13 @@ gobble_file (char const *name, enum filetype type, ino_t inode, author_width = len; } + if (print_context) + { + int len = strlen (f->context.attr); + if (context_width < len) + context_width = len; + } + { char buf[INT_BUFSIZE_BOUND (uintmax_t)]; int len = strlen (umaxtostr (f->stat.st_nlink, buf)); @@ -3463,7 +3487,7 @@ print_long_format (const struct fileinfo *f) DIRED_INDENT (); - if (print_owner | print_group | print_author) + if (print_owner | print_group | print_author | print_context) { DIRED_FPUTS (buf, stdout, p - buf); @@ -3476,6 +3500,9 @@ print_long_format (const struct fileinfo *f) if (print_author) format_user (f->stat.st_author, author_width, f->stat_ok); + if (print_context) + format_user_or_group(f->context.attr, 0, context_width); + p = buf; } @@ -3812,6 +3839,9 @@ print_file_name_and_frills (const struct fileinfo *f) human_readable (ST_NBLOCKS (f->stat), buf, human_output_opts, ST_NBLOCKSIZE, output_block_size)); + if (print_context) + printf ("%*s ", format == with_commas ? 0 : context_width, f->context); + print_name_with_quoting (f->name, FILE_OR_LINK_MODE (f), f->linkok, f->stat_ok, f->filetype, NULL); @@ -3975,6 +4005,9 @@ length_of_file_name_and_frills (const struct fileinfo *f) output_block_size)) : block_size_width); + if (print_context) + len += 1 + (format == with_commas ? strlen (f->context.attr) : context_width); + quote_name (NULL, f->name, filename_quoting_options, &name_width); len += name_width; @@ -4403,6 +4436,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ -w, --width=COLS assume screen width instead of current value\n\ -x list entries by lines instead of by columns\n\ -X sort alphabetically by entry extension\n\ + -Z print the security context\n\ -1 list one file per line\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); diff --git a/src/mkdir.c b/src/mkdir.c index 6fa0ac2..61ba5dc 100644 --- a/src/mkdir.c +++ b/src/mkdir.c @@ -29,6 +29,7 @@ #include "modechange.h" #include "quote.h" #include "savewd.h" +#include "smack.h" /* The official name of this program (e.g., no `g' prefix). */ #define PROGRAM_NAME "mkdir" @@ -40,6 +41,7 @@ char *program_name; static struct option const longopts[] = { + {"context", required_argument, NULL, 'Z'}, {"mode", required_argument, NULL, 'm'}, {"parents", no_argument, NULL, 'p'}, {"verbose", no_argument, NULL, 'v'}, @@ -65,9 +67,10 @@ Create the DIRECTORY(ies), if they do not already exist.\n\ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (_("\ - -m, --mode=MODE set file mode (as in chmod), not a=rwx - umask\n\ - -p, --parents no error if existing, make parent directories as needed\n\ - -v, --verbose print a message for each created directory\n\ + -Z, --context=CONTEXT set security context\n\ + -m, --mode=MODE set file mode (as in chmod), not a=rwx - umask\n\ + -p, --parents no error if existing, make parent directories as needed\n\ + -v, --verbose print a message for each created directory\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); @@ -92,6 +95,9 @@ struct mkdir_options /* File mode bits affected by MODE. */ mode_t mode_bits; + /* Security context. */ + struct smack_attrs context; + /* If not null, format to use when reporting newly made directories. */ char const *created_directory_format; }; @@ -101,6 +107,17 @@ static void announce_mkdir (char const *dir, void *options) { struct mkdir_options const *o = options; + + if (o->context.attr[0]) { + char *sep = strrchr(dir, '/'); + int res = 0; + if ((sep != NULL) && (strlen(sep) != strlen(dir))) + res = smack_to_file (sep + 1, &o->context); + else + res = smack_to_file (dir, &o->context); + if (res < 0) + ; // error (0, errno, _("setting directory context failed")); + } if (o->created_directory_format) error (0, 0, o->created_directory_format, quote (dir)); } @@ -144,6 +161,7 @@ main (int argc, char **argv) options.make_ancestor_function = NULL; options.mode = S_IRWXUGO; options.mode_bits = 0; + memset(&options.context, 0, sizeof(options.context)); options.created_directory_format = NULL; initialize_main (&argc, &argv); @@ -154,10 +172,14 @@ main (int argc, char **argv) atexit (close_stdout); - while ((optc = getopt_long (argc, argv, "pm:v", longopts, NULL)) != -1) + while ((optc = getopt_long (argc, argv, "Z:pm:v", longopts, NULL)) != -1) { switch (optc) { + case 'Z': + if (optarg) + strncpy(options.context.attr, optarg, SMACK_LABELLEN); + break; case 'p': options.make_ancestor_function = make_ancestor; break; diff --git a/src/mkfifo.c b/src/mkfifo.c index d329b79..e1d9283 100644 --- a/src/mkfifo.c +++ b/src/mkfifo.c @@ -26,6 +26,7 @@ #include "error.h" #include "modechange.h" #include "quote.h" +#include "smack.h" /* The official name of this program (e.g., no `g' prefix). */ #define PROGRAM_NAME "mkfifo" @@ -37,6 +38,7 @@ char *program_name; static struct option const longopts[] = { + {"context", required_argument, NULL, 'Z'}, {"mode", required_argument, NULL, 'm'}, {GETOPT_HELP_OPTION_DECL}, {GETOPT_VERSION_OPTION_DECL}, @@ -60,7 +62,10 @@ Create named pipes (FIFOs) with the given NAMEs.\n\ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (_("\ - -m, --mode=MODE set file permission bits to MODE, not a=rw - umask\n\ + -Z, --context=CONTEXT set security context to CONTEXT\n\ +"), stdout); + fputs (_("\ + -m, --mode=MODE set file permission bits to MODE, not a=rw - umask\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); @@ -73,6 +78,8 @@ int main (int argc, char **argv) { mode_t newmode; + struct smack_attrs specified_context; + memset(&specified_context, 0, sizeof(specified_context)); char const *specified_mode = NULL; int exit_status = EXIT_SUCCESS; int optc; @@ -85,10 +92,14 @@ main (int argc, char **argv) atexit (close_stdout); - while ((optc = getopt_long (argc, argv, "m:", longopts, NULL)) != -1) + while ((optc = getopt_long (argc, argv, "Z:m:", longopts, NULL)) != -1) { switch (optc) { + case 'Z': + if (optarg) + strncpy(specified_context.attr, optarg, SMACK_LABELLEN); + break; case 'm': specified_mode = optarg; break; @@ -119,11 +130,17 @@ main (int argc, char **argv) } for (; optind < argc; ++optind) - if (mkfifo (argv[optind], newmode) != 0) - { - error (0, errno, _("cannot create fifo %s"), quote (argv[optind])); - exit_status = EXIT_FAILURE; - } + { + if (mkfifo (argv[optind], newmode) != 0) + { + error (0, errno, _("cannot create fifo %s"), quote (argv[optind])); + exit_status = EXIT_FAILURE; + } + if (specified_context.attr[0] && + smack_to_file(argv[optind], &specified_context) < 0) + ;// error (0, errno, _("context assignment of %s to %s failed"), + // argv[optind], quote (specified_context)); + } exit (exit_status); } diff --git a/src/mknod.c b/src/mknod.c index 43a1b9d..ff9b0af 100644 --- a/src/mknod.c +++ b/src/mknod.c @@ -27,6 +27,7 @@ #include "modechange.h" #include "quote.h" #include "xstrtol.h" +#include "smack.h" /* The official name of this program (e.g., no `g' prefix). */ #define PROGRAM_NAME "mknod" @@ -38,6 +39,7 @@ char *program_name; static struct option const longopts[] = { + {"context", required_argument, NULL, 'Z'}, {"mode", required_argument, NULL, 'm'}, {GETOPT_HELP_OPTION_DECL}, {GETOPT_VERSION_OPTION_DECL}, @@ -62,7 +64,10 @@ Create the special file NAME of the given TYPE.\n\ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (_("\ - -m, --mode=MODE set file permission bits to MODE, not a=rw - umask\n\ + -Z, --context=CONTEXT set file security context to CONTEXT\n\ +"), stdout); + fputs (_("\ + -m, --mode=MODE set file permission bits to MODE, not a=rw - umask\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); @@ -88,6 +93,8 @@ int main (int argc, char **argv) { mode_t newmode; + struct smack_attrs specified_context; + memset(&specified_context, 0, sizeof(specified_context)); char const *specified_mode = NULL; int optc; int expected_operands; @@ -101,10 +108,14 @@ main (int argc, char **argv) atexit (close_stdout); - while ((optc = getopt_long (argc, argv, "m:", longopts, NULL)) != -1) + while ((optc = getopt_long (argc, argv, "Z:m:", longopts, NULL)) != -1) { switch (optc) { + case 'Z': + if (optarg) + strncpy(specified_context.attr, optarg, SMACK_LABELLEN); + break; case 'm': specified_mode = optarg; break; @@ -217,5 +228,9 @@ main (int argc, char **argv) usage (EXIT_FAILURE); } + if (specified_context.attr[0] && smack_to_file (argv[optind], &specified_context) < 0) + ; //error (0, errno, _("context assignment to %s failed"), + // quote (specified_context)); + exit (EXIT_SUCCESS); } diff --git a/src/mv.c b/src/mv.c index 1d1ddda..aca3ebd 100644 --- a/src/mv.c +++ b/src/mv.c @@ -32,6 +32,7 @@ #include "filenamecat.h" #include "quote.h" #include "remove.h" +#include "smack.h" /* The official name of this program (e.g., no `g' prefix). */ #define PROGRAM_NAME "mv" @@ -126,6 +127,7 @@ cp_option_init (struct cp_options *x) x->preserve_links = true; x->preserve_mode = true; x->preserve_timestamps = true; + x->preserve_context = true; x->require_preserve = false; /* FIXME: maybe make this an option */ x->recursive = true; x->sparse_mode = SPARSE_AUTO; /* FIXME: maybe make this an option */ diff --git a/src/smack.h b/src/smack.h new file mode 100644 index 0000000..731ce70 --- /dev/null +++ b/src/smack.h @@ -0,0 +1,276 @@ +/* smack.h - Simplified Mandatory Access Control Kernel + + Copyright (C) 2010 Free Software Foundation, Inc. + + This program is free software; you can 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, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU 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. + + Written by Casey Schaufler. */ + +#include +#include +#include +#include + +#define SMACK_PATHTEXTSIZE 80 +#define SMACK_LABELLEN 256 +#define SMACK_PROC_FMT "/proc/%s/attr/current" +#define SMACK_CHECK_PATH "/smack/load" +#define SMACK_ATTRNAME "security.SMACK64" +#define SMACK_EXECNAME "security.SMACK64EXEC" +#define SMACK_MMAPNAME "security.SMACK64MMAP" +#define SMACK_TRANSMUTENAME "security.SMACK64TRANSMUTE" +#define SMACK_TRANSMUTETRUE "TRUE" + +struct smack_attrs +{ + char attr[SMACK_LABELLEN]; + char exec[SMACK_LABELLEN]; + char mmap[SMACK_LABELLEN]; + int transmute; +}; + +static inline int +smack_enabled(void) +{ + int i; + struct stat buf; + + i = stat(SMACK_CHECK_PATH, &buf); + + if (i < 0) + return 0; + + return 1; +} + +static inline bool +smack_differs(const struct smack_attrs *smack1, + const struct smack_attrs *smack2) +{ + if (strcmp(smack1->attr, smack2->attr)) + return 1; + + if (strcmp(smack1->exec, smack2->exec)) + return 1; + + if (strcmp(smack1->mmap, smack2->mmap)) + return 1; + + if (smack1->transmute != smack2->transmute) + return 1; + + return 0; +} + +static inline int +smack_of_file(const char *path, struct smack_attrs *result) +{ + int ret, i; + int rlen = SMACK_LABELLEN; + char buffer[rlen]; + + i = lgetxattr(path, SMACK_ATTRNAME, result->attr, rlen); + if (i < 0) + return i; + + if (i < rlen) + result->attr[i] = '\0'; + + ret = i; + + i = lgetxattr(path, SMACK_EXECNAME, result->exec, rlen); + if (i >= 0 && i < rlen) + result->exec[i] = '\0'; + + i = lgetxattr(path, SMACK_MMAPNAME, result->mmap, rlen); + if (i >= 0 && i < rlen) + result->mmap[i] = '\0'; + + i = getxattr(path, SMACK_TRANSMUTENAME, buffer, rlen); + if (i >= 0 && i < rlen && strncmp(buffer, SMACK_TRANSMUTETRUE, i) == 0) + result->transmute = 1; + + return ret; +} + +static inline int +smack_of_file_follow(const char *path, struct smack_attrs *result) +{ + int ret, i; + int rlen = SMACK_LABELLEN; + char buffer[rlen]; + + i = getxattr(path, SMACK_ATTRNAME, result->attr, rlen); + if (i < 0) + return i; + + if (i < rlen) + result->attr[i] = '\0'; + + ret = i; + + i = getxattr(path, SMACK_EXECNAME, result->exec, rlen); + if (i >= 0 && i < rlen) + result->exec[i] = '\0'; + + i = getxattr(path, SMACK_MMAPNAME, result->mmap, rlen); + if (i >= 0 && i < rlen) + result->mmap[i] = '\0'; + + i = getxattr(path, SMACK_TRANSMUTENAME, buffer, rlen); + if (i >= 0 && i < rlen && strncmp(buffer, SMACK_TRANSMUTETRUE, i) == 0) + result->transmute = 1; + + return ret; +} + +static inline int +smack_of_fd(int fd, struct smack_attrs *result) +{ + int ret, i; + int rlen = SMACK_LABELLEN; + char buffer[rlen]; + + i = fgetxattr(fd, SMACK_ATTRNAME, result->attr, rlen); + if (i < 0) + return i; + + if (i < rlen) + result->attr[i] = '\0'; + + ret = i; + + i = fgetxattr(fd, SMACK_EXECNAME, result->exec, rlen); + if (i >= 0 && i < rlen) + result->exec[i] = '\0'; + + i = fgetxattr(fd, SMACK_MMAPNAME, result->mmap, rlen); + if (i >= 0 && i < rlen) + result->mmap[i] = '\0'; + + i = fgetxattr(fd, SMACK_TRANSMUTENAME, buffer, rlen); + if (i >= 0 && i < rlen && strncmp(buffer, SMACK_TRANSMUTETRUE, i) == 0) + result->transmute = 1; + + return ret; +} + +static inline int +smack_to_fd(int fd, const struct smack_attrs *smack) +{ + int ret; + + if (smack->attr[0]) + { + ret = fsetxattr(fd, SMACK_ATTRNAME, smack->attr, strlen(smack->attr), 0); + if (ret < 0) + return ret; + } + + if (smack->exec[0]) + { + ret = fsetxattr(fd, SMACK_EXECNAME, smack->exec, strlen(smack->exec), 0); + if (ret < 0) + return ret; + } + + if (smack->mmap[0]) + { + ret = fsetxattr(fd, SMACK_MMAPNAME, smack->mmap, strlen(smack->mmap), 0); + if (ret < 0) + return ret; + } + + if (smack->transmute) + { + ret = fsetxattr(fd, SMACK_TRANSMUTENAME, SMACK_TRANSMUTETRUE, + strlen(SMACK_TRANSMUTETRUE), 0); + if (ret < 0) + return ret; + } + + return 0; +} + +static inline int +smack_to_file(const char *path, const struct smack_attrs *smack) +{ + int ret; + + if (smack->attr[0]) + { + ret = lsetxattr(path, SMACK_ATTRNAME, smack->attr, strlen(smack->attr), 0); + if (ret < 0) + return ret; + } + + if (smack->exec[0]) + { + ret = lsetxattr(path, SMACK_EXECNAME, smack->exec, strlen(smack->exec), 0); + if (ret < 0) + return ret; + } + + if (smack->mmap[0]) + { + ret = lsetxattr(path, SMACK_MMAPNAME, smack->mmap, strlen(smack->mmap), 0); + if (ret < 0) + return ret; + } + + if (smack->transmute) + { + ret = lsetxattr(path, SMACK_TRANSMUTENAME, SMACK_TRANSMUTETRUE, + strlen(SMACK_TRANSMUTETRUE), 0); + if (ret < 0) + return ret; + } + + return 0; +} + +static inline int +smack_of_proc(pid_t pid, char *result, int rlen) +{ + int fd; + int red; + char *cp = "self"; + char pidtext[SMACK_PATHTEXTSIZE]; + char path[SMACK_PATHTEXTSIZE]; + + if (pid > 0) + { + sprintf(pidtext, "%d", pid); + cp = pidtext; + } + + if (strlen(cp) + strlen(SMACK_PROC_FMT) >= SMACK_PATHTEXTSIZE) + return -1; + + sprintf(path, SMACK_PROC_FMT, cp); + fd = open(path, O_RDONLY); + if (fd < 0) + return fd; + + red = read(fd, result, rlen); + close(fd); + + if (red >= 0 && red < rlen) + result[red] = '\0'; + if ((cp = index (result, '\n')) != NULL) + *cp = '\0'; + + return strlen (result); +} diff --git a/src/stat.c b/src/stat.c index ca84236..c7769b4 100644 --- a/src/stat.c +++ b/src/stat.c @@ -68,6 +68,7 @@ #include "stat-time.h" #include "strftime.h" #include "xreadlink.h" +#include "smack.h" #define alignof(type) offsetof (struct { char c; type x; }, x) @@ -270,6 +271,8 @@ human_fstype (STRUCT_STATVFS const *statfsbuf) return "squashfs"; case S_MAGIC_SYSFS: /* 0x62656572 */ return "sysfs"; + case S_MAGIC_SMACK: /* 0x43415D53 */ + return "smack"; # elif __GNU__ case FSTYPE_UFS: return "ufs"; @@ -595,6 +598,15 @@ print_stat (char *pformat, size_t prefix_len, char m, else out_uint (pformat, prefix_len, statbuf->st_ctime); break; + case 'C': + { + struct smack_attrs context; + memset(&context, 0, sizeof(context)); + + if (smack_of_file(filename, &context) > 0) + out_string(pformat, prefix_len, context.attr); + } + break; default: fputc ('?', stdout); break; @@ -855,6 +867,7 @@ The valid format sequences for files (without --file-system):\n\ %B The size in bytes of each block reported by %b\n\ "), stdout); fputs (_("\ + %C Security context\n\ %d Device number in decimal\n\ %D Device number in hex\n\ %f Raw mode in hex\n\ diff --git a/src/touch.c b/src/touch.c index a79c26d..91e754b 100644 --- a/src/touch.c +++ b/src/touch.c @@ -182,7 +182,7 @@ touch (const char *file) t = timespec; } - ok = (futimens (fd, (fd == STDOUT_FILENO ? NULL : file), t) == 0); + ok = (gl_futimens (fd, (fd == STDOUT_FILENO ? NULL : file), t) == 0); if (fd == STDIN_FILENO) { diff --git a/tests/Makefile.in b/tests/Makefile.in index 9628757..026701e 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -550,6 +550,7 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps) # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): + @TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; rm -f $$TEST_LOG; @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ @@ -567,14 +568,15 @@ $(RECURSIVE_TARGETS): else \ local_target="$$target"; \ fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target); \ done; \ if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" + $(MAKE) $(AM_MAKEFLAGS) "$$target-am"; \ + fi; \ + test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): + @TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; rm -f $$TEST_LOG; @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ @@ -601,9 +603,9 @@ $(RECURSIVE_CLEAN_TARGETS): else \ local_target="$$target"; \ fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done && test -z "$$fail" + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target); \ + done; \ + test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ @@ -676,6 +678,7 @@ distclean-tags: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -693,6 +696,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -705,11 +709,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/chgrp/Makefile.in b/tests/chgrp/Makefile.in index 7afc0a0..26e4f16 100644 --- a/tests/chgrp/Makefile.in +++ b/tests/chgrp/Makefile.in @@ -526,6 +526,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -543,6 +544,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -555,11 +557,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/chmod/Makefile.in b/tests/chmod/Makefile.in index a3bea9d..0fda197 100644 --- a/tests/chmod/Makefile.in +++ b/tests/chmod/Makefile.in @@ -528,6 +528,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -545,6 +546,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -557,11 +559,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/chmod/no-x b/tests/chmod/no-x index 34b3952..9ed5854 100755 --- a/tests/chmod/no-x +++ b/tests/chmod/no-x @@ -46,7 +46,8 @@ fi fail=0 # This must exit nonzero. -chmod -R o=r d >/dev/null 2>out && fail=1 +chmod -R o=r d >/dev/null 2>out1 && fail=1 +sed -r 's/^(\/.*\/)*(chmod:.*)/\2/' out1 > out cat <<\EOF > exp chmod: `d/no-x': Permission denied diff --git a/tests/chown/Makefile.in b/tests/chown/Makefile.in index fb774f7..1275d16 100644 --- a/tests/chown/Makefile.in +++ b/tests/chown/Makefile.in @@ -523,6 +523,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -540,6 +541,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -552,11 +554,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/chown/deref b/tests/chown/deref index e3da3eb..9dab74e 100755 --- a/tests/chown/deref +++ b/tests/chown/deref @@ -48,7 +48,8 @@ set _ `ls -ldo dangle`; shift; user=$3 # With 5.2.1 and earlier, this command would mistakenly succeed. chown --dereference $user dangle 2> out1 && fail=1 -sed 's/: [^:]*$//' out1 > out +sed 's/: [^:]*$//' out1 > out2 +sed -r 's/^(\/.*\/)*(.*)/\2/' out2 > out cat <<\EOF > exp || fail=1 chown: cannot dereference `dangle' diff --git a/tests/chown/preserve-root b/tests/chown/preserve-root index 4f8fe4f..6a7a72b 100755 --- a/tests/chown/preserve-root +++ b/tests/chown/preserve-root @@ -67,6 +67,10 @@ echo '==== test -RLh' >> out chown -RLh --preserve-root `id -u` d >> out 2>&1 && fail=1 chgrp -RLh --preserve-root `id -g` d >> out 2>&1 && fail=1 +sed -r 's/^(\/.*\/)*(chown:.*)/\2/' out > out1 +sed -r 's/^(\/.*\/)*(chgrp:.*)/\2/' out1 > out2 +sed -r 's/^(\/.*\/)*(chmod:.*)/\2/' out2 > out + cat <<\EOF > exp || fail=1 chown: it is dangerous to operate recursively on `/' chown: use --no-preserve-root to override this failsafe diff --git a/tests/cp/Makefile.in b/tests/cp/Makefile.in index f87e056..5f56738 100644 --- a/tests/cp/Makefile.in +++ b/tests/cp/Makefile.in @@ -553,6 +553,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -570,6 +571,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -582,11 +584,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/cp/backup-is-src b/tests/cp/backup-is-src index b4f90c8..92f1cf8 100755 --- a/tests/cp/backup-is-src +++ b/tests/cp/backup-is-src @@ -45,14 +45,15 @@ if test $framework_failure = 1; then fi # This cp command should exit nonzero. -cp --b=simple a~ a > out 2>&1 && fail=1 +cp --b=simple a~ a > out1 2>&1 && fail=1 -sed "s,cp:,XXX:," out > out2 +sed -r 's/^(\/.*\/)*(.*)/\2/' out1 > out2 +sed "s,cp:,XXX:," out2 > out cat > exp <<\EOF XXX: backing up `a' would destroy source; `a~' not copied EOF -cmp out2 exp || fail=1 +cmp out exp || fail=1 (exit $fail); exit $fail diff --git a/tests/cp/fail-perm b/tests/cp/fail-perm index 5fff090..21f6a35 100755 --- a/tests/cp/fail-perm +++ b/tests/cp/fail-perm @@ -69,10 +69,14 @@ cp F symlink 2> out && fail=1 # ...: The file access permissions do not allow the specified action. # to the expected one: sed 's/: The file access permissions.*/: Permission denied/'o1;mv o1 out +sed -r 's/^(\/.*\/)*(cp:.*)/\2/' out > out1;mv out1 out + cmp out exp || { (diff -c out exp) 2> /dev/null; fail=1; } cp --target-directory=symlink F 2> out && fail=1 sed 's/: The file access permissions.*/: Permission denied/'o1;mv o1 out +sed -r 's/^(\/.*\/)*(cp:.*)/\2/' out > out1;mv out1 out + cmp out exp || { (diff -c out exp) 2> /dev/null; fail=1; } chmod 700 D diff --git a/tests/cp/into-self b/tests/cp/into-self index 79c727a..d47645c 100755 --- a/tests/cp/into-self +++ b/tests/cp/into-self @@ -50,7 +50,8 @@ fi fail=0 # This command should exit nonzero. -cp -R dir dir 2> out && fail=1 +cp -R dir dir 2> out1 && fail=1 +sed -r 's/^(\/.*\/)*(cp: .*)/\2/' out1 > out cat > exp <<\EOF cp: cannot copy a directory, `dir', into itself, `dir/dir' diff --git a/tests/cut/Makefile.in b/tests/cut/Makefile.in index 33f6404..988d0f5 100644 --- a/tests/cut/Makefile.in +++ b/tests/cut/Makefile.in @@ -575,6 +575,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -592,6 +593,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -604,11 +606,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/dd/Makefile.in b/tests/dd/Makefile.in index f76aae6..ad529b2 100644 --- a/tests/dd/Makefile.in +++ b/tests/dd/Makefile.in @@ -522,6 +522,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -539,6 +540,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -551,11 +553,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/dircolors/Makefile.in b/tests/dircolors/Makefile.in index 9908cbf..71182e7 100644 --- a/tests/dircolors/Makefile.in +++ b/tests/dircolors/Makefile.in @@ -522,6 +522,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -539,6 +540,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -551,11 +553,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/dircolors/simple b/tests/dircolors/simple index 2e5f110..53d9b19 100755 --- a/tests/dircolors/simple +++ b/tests/dircolors/simple @@ -39,7 +39,7 @@ use strict; my @Tests = ( ['a', '-b', {IN => {k => "exec\n"}}, - {ERR => "dircolors: k:1: invalid line; missing second token\n"}, + {ERR => "$ENV{PWD}/../../src/dircolors: k:1: invalid line; missing second token\n"}, {EXIT => 1}], ['quote', '-b', {IN => "exec 'echo Hello;:'\n"}, {OUT => "LS_COLORS='ex='\\''echo Hello;\\:'\\'':';\n" diff --git a/tests/du/Makefile.in b/tests/du/Makefile.in index b68e6b4..95c094b 100644 --- a/tests/du/Makefile.in +++ b/tests/du/Makefile.in @@ -551,6 +551,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -568,6 +569,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -580,11 +582,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/du/files0-from b/tests/du/files0-from index fdcb595..4558071 100755 --- a/tests/du/files0-from +++ b/tests/du/files0-from @@ -46,14 +46,14 @@ my @Tests = ( # invalid extra command line argument ['f-extra-arg', '--files0-from=- no-such', {IN=>"a"}, {EXIT=>1}, - {ERR => "du: extra operand `no-such'\n" + {ERR => "$ENV{PWD}/../../src/du: extra operand `no-such'\n" . "File operands cannot be combined with --files0-from.\n" - . "Try `du --help' for more information.\n"} + . "Try `$ENV{PWD}/../../src/du --help' for more information.\n"} ], # missing input file ['missing', '--files0-from=missing', {EXIT=>1}, - {ERR => "du: cannot open `missing' for reading: " + {ERR => "$ENV{PWD}/../../src/du: cannot open `missing' for reading: " . "No such file or directory\n"}], # empty input @@ -64,12 +64,12 @@ my @Tests = # one NUL ['nul-1', '--files0-from=-', '<', {IN=>"\0"}, {EXIT=>1}, - {ERR => "du: -:1: invalid zero-length file name\n"}], + {ERR => "$ENV{PWD}/../../src/du: -:1: invalid zero-length file name\n"}], # two NULs ['nul-2', '--files0-from=-', '<', {IN=>"\0\0"}, {EXIT=>1}, - {ERR => "du: -:1: invalid zero-length file name\n" - . "du: -:2: invalid zero-length file name\n"}], + {ERR => "$ENV{PWD}/../../src/du: -:1: invalid zero-length file name\n" + . "$ENV{PWD}/../../src/du: -:2: invalid zero-length file name\n"}], # one file name, no NUL ['1', '--files0-from=-', '<', @@ -95,7 +95,7 @@ my @Tests = ['zero-len', '--files0-from=-', '<', {IN=>{f=>"\0g\0"}}, {AUX=>{g=>''}}, {OUT=>"0\tg\n"}, {OUT_SUBST=>'s/^\d+/0/'}, - {ERR => "du: -:1: invalid zero-length file name\n"}, {EXIT=>1} ], + {ERR => "$ENV{PWD}/../../src/du: -:1: invalid zero-length file name\n"}, {EXIT=>1} ], ); my $save_temps = $ENV{DEBUG}; diff --git a/tests/du/inacc-dest b/tests/du/inacc-dest index 0ff6b96..8efcf70 100755 --- a/tests/du/inacc-dest +++ b/tests/du/inacc-dest @@ -56,6 +56,8 @@ du > ../t 2>&1 && fail=1 # /proc support, nor native openat support. sed 's/^[0-9][0-9]* //' ../t | sort -u > out +sed -r 's/^(\/.*\/)*(du:.*)/\2/' out > out1;mv out1 out + cat <<\EOF > exp || fail=1 . ./a diff --git a/tests/du/long-sloop b/tests/du/long-sloop index f5f9423..262961c 100755 --- a/tests/du/long-sloop +++ b/tests/du/long-sloop @@ -90,6 +90,7 @@ fail=0 # du: cannot access `1/s/s/s/.../s': Too many levels of symbolic links du -L 1 > /dev/null 2> out1 && fail=1 sed "s, .1/s/s/s/[/s]*',," out1 > out || fail=1 +sed -r 's/^(\/.*\/)*(du:.*)/\2/' out > out1;mv out1 out echo "du: cannot access: $too_many" > exp || fail=1 diff --git a/tests/du/no-x b/tests/du/no-x index fa93e97..c938b4f 100755 --- a/tests/du/no-x +++ b/tests/du/no-x @@ -47,6 +47,7 @@ fail=0 # This must exit nonzero. du d >/dev/null 2>out && fail=1 +sed -r 's/^(\/.*\/)*(du:.*)/\2/' out > out1;mv out1 out cat <<\EOF > exp du: `d/no-x': Permission denied diff --git a/tests/expr/Makefile.in b/tests/expr/Makefile.in index e853c76..bc40e46 100644 --- a/tests/expr/Makefile.in +++ b/tests/expr/Makefile.in @@ -522,6 +522,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -539,6 +540,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -551,11 +553,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/expr/basic b/tests/expr/basic index ee264d9..ea3f473 100755 --- a/tests/expr/basic +++ b/tests/expr/basic @@ -41,6 +41,8 @@ use strict; my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $src_path = "$ENV{PWD}/../../src"; + my @Tests = ( ['a', '5 + 6', {OUT => '11'}], @@ -75,7 +77,7 @@ my @Tests = ['minus2', '-- 2 + 2', {OUT => '4'}], # This erroneously succeeded and output `3' before 2.0.12. - ['fail-a', '3 + -', {ERR => "$prog: non-numeric argument\n"}, + ['fail-a', '3 + -', {ERR => "$src_path/$prog: non-numeric argument\n"}, {EXIT => 2}], # This erroneously succeeded before 5.3.1. @@ -89,15 +91,15 @@ my @Tests = ['bre1', '"abc" : "a\\(b\\)c"', {OUT => 'b'}], ['bre2', '"a(" : "a("', {OUT => '2'}], ['bre3', '_ : "a\\("', - {ERR => "$prog: Unmatched ( or \\(\n"}, {EXIT => 2}], + {ERR => "$src_path/$prog: Unmatched ( or \\(\n"}, {EXIT => 2}], ['bre4', '_ : "a\\(b"', - {ERR => "$prog: Unmatched ( or \\(\n"}, {EXIT => 2}], + {ERR => "$src_path/$prog: Unmatched ( or \\(\n"}, {EXIT => 2}], ['bre5', '"a(b" : "a(b"', {OUT => '3'}], ['bre6', '"a)" : "a)"', {OUT => '2'}], ['bre7', '_ : "a\\)"', - {ERR => "$prog: Unmatched ) or \\)\n"}, {EXIT => 2}], + {ERR => "$src_path/$prog: Unmatched ) or \\)\n"}, {EXIT => 2}], ['bre8', '_ : "\\)"', - {ERR => "$prog: Unmatched ) or \\)\n"}, {EXIT => 2}], + {ERR => "$src_path/$prog: Unmatched ) or \\)\n"}, {EXIT => 2}], ['bre9', '"ab" : "a\\(\\)b"', {OUT => ''}, {EXIT => 1}], ['bre10', '"a^b" : "a^b"', {OUT => '3'}], ['bre11', '"a\$b" : "a\$b"', {OUT => '3'}], @@ -133,21 +135,21 @@ my @Tests = ['bre40', '"ab" : "a\\{1,\\}b"', {OUT => '2'}], ['bre41', '"aab" : "a\\{1,2\\}b"', {OUT => '3'}], ['bre42', '_ : "a\\{1"', - {ERR => "$prog: Unmatched \\{\n"}, {EXIT => 2}], + {ERR => "$src_path/$prog: Unmatched \\{\n"}, {EXIT => 2}], ['bre43', '_ : "a\\{1a"', - {ERR => "$prog: Unmatched \\{\n"}, {EXIT => 2}], + {ERR => "$src_path/$prog: Unmatched \\{\n"}, {EXIT => 2}], ['bre44', '_ : "a\\{1a\\}"', - {ERR => "$prog: Invalid content of \\{\\}\n"}, {EXIT => 2}], + {ERR => "$src_path/$prog: Invalid content of \\{\\}\n"}, {EXIT => 2}], ['bre45', '"a" : "a\\{,2\\}"', {OUT => '1'}], ['bre46', '"a" : "a\\{,\\}"', {OUT => '1'}], ['bre47', '_ : "a\\{1,x\\}"', - {ERR => "$prog: Invalid content of \\{\\}\n"}, {EXIT => 2}], + {ERR => "$src_path/$prog: Invalid content of \\{\\}\n"}, {EXIT => 2}], ['bre48', '_ : "a\\{1,x"', - {ERR => "$prog: Unmatched \\{\n"}, {EXIT => 2}], + {ERR => "$src_path/$prog: Unmatched \\{\n"}, {EXIT => 2}], ['bre49', '_ : "a\\{32768\\}"', - {ERR => "$prog: Invalid content of \\{\\}\n"}, {EXIT => 2}], + {ERR => "$src_path/$prog: Invalid content of \\{\\}\n"}, {EXIT => 2}], ['bre50', '_ : "a\\{1,0\\}"', - {ERR => "$prog: Invalid content of \\{\\}\n"}, {EXIT => 2}], + {ERR => "$src_path/$prog: Invalid content of \\{\\}\n"}, {EXIT => 2}], ['bre51', '"acabc" : ".*ab\\{0,0\\}c"', {OUT => '2'}], ['bre52', '"abcac" : "ab\\{0,1\\}c"', {OUT => '3'}], ['bre53', '"abbcac" : "ab\\{0,3\\}c"', {OUT => '4'}], @@ -161,10 +163,10 @@ my @Tests = ['bre61', '"acd" : "a\\(b\\)?c\\1d"', {OUT => ''}, {EXIT => 1}], ['bre62', '-- "-5" : "-\\{0,1\\}[0-9]*\$"', {OUT => '2'}], - ['fail-b', '9 9', {ERR => "$prog: syntax error\n"}, + ['fail-b', '9 9', {ERR => "$src_path/$prog: syntax error\n"}, {EXIT => 2}], - ['fail-c', {ERR => "$prog: missing operand\n" - . "Try `$prog --help' for more information.\n"}, + ['fail-c', {ERR => "$src_path/$prog: missing operand\n" + . "Try `$src_path/$prog --help' for more information.\n"}, {EXIT => 2}], ); diff --git a/tests/factor/Makefile.in b/tests/factor/Makefile.in index dead356..f62af41 100644 --- a/tests/factor/Makefile.in +++ b/tests/factor/Makefile.in @@ -522,6 +522,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -539,6 +540,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -551,11 +553,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/factor/basic b/tests/factor/basic index 8b91cce..ca44c16 100755 --- a/tests/factor/basic +++ b/tests/factor/basic @@ -41,6 +41,8 @@ use strict; my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $src_path = "$ENV{PWD}/../../src"; + my @Tests = ( ['1', '9', {OUT => '3 3'}], @@ -74,12 +76,12 @@ my @Tests = ['x', '4294966896', {OUT => '2 2 2 2 3 3 3 11 607 1489'}], ['y', '4294966998', {OUT => '2 3 7 3917 26107'}], ['z', '-1', - {ERR => "$prog: invalid option -- 1\n" - . "Try `$prog --help' for more information.\n"}, + {ERR => "$src_path/$prog: invalid option -- '1'\n" + . "Try `$src_path/$prog --help' for more information.\n"}, {EXIT => 1}], ['cont', 'a 4', {OUT => "4: 2 2\n"}, - {ERR => "$prog: `a' is not a valid positive integer\n"}, + {ERR => "$src_path/$prog: `a' is not a valid positive integer\n"}, {EXIT => 1}], ); diff --git a/tests/fmt/Makefile.in b/tests/fmt/Makefile.in index cef5c9a..0a41dfd 100644 --- a/tests/fmt/Makefile.in +++ b/tests/fmt/Makefile.in @@ -522,6 +522,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -539,6 +540,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -551,11 +553,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/fmt/basic b/tests/fmt/basic index 66abe13..86b7c32 100755 --- a/tests/fmt/basic +++ b/tests/fmt/basic @@ -41,24 +41,26 @@ use strict; (my $program_name = $0) =~ s|.*/||; +my $src_path = "$ENV{PWD}/../../src"; + my @Tests = ( ['8-bit-pfx', qw (-p 'ç'), {IN=> "ça\nçb\n"}, {OUT=>"ça b\n"}], ['wide-1', '-w 32768', - {ERR => "fmt: invalid width: `32768'\n"}, {EXIT => 1}], + {ERR => "$src_path/fmt: invalid width: `32768'\n"}, {EXIT => 1}], ['wide-2', '-w 2147483647', - {ERR => "fmt: invalid width: `2147483647'\n"}, {EXIT => 1}], + {ERR => "$src_path/fmt: invalid width: `2147483647'\n"}, {EXIT => 1}], ['bad-suffix', '-72x', {IN=> ''}, - {ERR => "fmt: invalid width: `72x'\n"}, {EXIT => 1}], + {ERR => "$src_path/fmt: invalid width: `72x'\n"}, {EXIT => 1}], ['no-file', 'no-such-file', - {ERR => "fmt: cannot open `no-such-file' for reading:" + {ERR => "$src_path/fmt: cannot open `no-such-file' for reading:" . " No such file or directory\n"}, {EXIT => 1}], ['obs-1', '-c -72', - {ERR => "fmt: invalid option -- 7; -WIDTH is recognized only when it" + {ERR => "$src_path/fmt: invalid option -- 7; -WIDTH is recognized only when it" . " is the first\noption; use -w N instead\n" - . "Try `fmt --help' for more information.\n" }, {EXIT => 1}], + . "Try `$src_path/fmt --help' for more information.\n" }, {EXIT => 1}], # With --prefix=P, do not remove leading space on lines without the prefix. ['pfx-1', qw (-p '>'), diff --git a/tests/head/Makefile.in b/tests/head/Makefile.in index a5d6e56..515cade 100644 --- a/tests/head/Makefile.in +++ b/tests/head/Makefile.in @@ -562,6 +562,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -579,6 +580,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -591,11 +593,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/install/Makefile.in b/tests/install/Makefile.in index 4828378..56a0059 100644 --- a/tests/install/Makefile.in +++ b/tests/install/Makefile.in @@ -519,6 +519,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -536,6 +537,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -548,11 +550,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/install/basic-1 b/tests/install/basic-1 index 3270604..9a0de8f 100755 --- a/tests/install/basic-1 +++ b/tests/install/basic-1 @@ -143,6 +143,8 @@ fi touch file || fail=1 ginstall -Dv file sub3/a/b/c/file >out 2>&1 || fail=1 +sed -r 's/^(\/.*\/)*(ginstall:.*)/\2/' out > out1; mv out1 out + diff - out <<\EOF || fail=1 ginstall: creating directory `sub3' ginstall: creating directory `sub3/a' diff --git a/tests/join/Makefile.in b/tests/join/Makefile.in index b114a9b..34d7336 100644 --- a/tests/join/Makefile.in +++ b/tests/join/Makefile.in @@ -567,6 +567,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -584,6 +585,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -596,11 +598,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/ln/Makefile.in b/tests/ln/Makefile.in index d59ce9a..9ad7daf 100644 --- a/tests/ln/Makefile.in +++ b/tests/ln/Makefile.in @@ -518,6 +518,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -535,6 +536,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -547,11 +549,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/ln/hard-backup b/tests/ln/hard-backup index e37938d..9a110a6 100755 --- a/tests/ln/hard-backup +++ b/tests/ln/hard-backup @@ -44,6 +44,8 @@ fi fail=0 ln --backup f f 2> out && fail=1 +sed -r 's/^(\/.*\/)*(ln:.*)/\2/' out > out1; mv out1 out + cat <<\EOF > exp || fail=1 ln: `f' and `f' are the same file EOF diff --git a/tests/ls-2/Makefile.in b/tests/ls-2/Makefile.in index 98146a7..c024f42 100644 --- a/tests/ls-2/Makefile.in +++ b/tests/ls-2/Makefile.in @@ -522,6 +522,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -539,6 +540,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -551,11 +553,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/ls-2/tests b/tests/ls-2/tests index d0257a6..1d766d2 100755 --- a/tests/ls-2/tests +++ b/tests/ls-2/tests @@ -79,6 +79,8 @@ my $exe_in_subdir = {PRE => sub { make_j_d (); $ENV{LS_COLORS}='ex=01;32' }}; my $remove_j = {POST => sub {unlink 'j/d' or die "j/d: $!\n"; rmdir 'j' or die "j: $!\n" }}; +my $src_path = "$ENV{PWD}/../../src"; + my $q_bell = {IN => {"q\a" => ''}}; my @Tests = ( @@ -130,7 +132,7 @@ my @Tests = # From Stéphane Chazelas. ['no-a-isdir-b', 'no-dir d', {OUT => "d:\n"}, - {ERR => "ls: cannot access no-dir: No such file or directory\n"}, + {ERR => "$src_path/ls: cannot access no-dir: No such file or directory\n"}, $mkdir, $rmdir, {EXIT => 2}], ['recursive-2', '-R d', {OUT => "d:\ne\n\nd/e:\n"}, $mkdir2, $rmdir2], diff --git a/tests/ls/Makefile.in b/tests/ls/Makefile.in index a77a08a..70c814a 100644 --- a/tests/ls/Makefile.in +++ b/tests/ls/Makefile.in @@ -549,6 +549,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -566,6 +567,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -578,11 +580,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/md5sum/Makefile.in b/tests/md5sum/Makefile.in index bfb9447..a82983c 100644 --- a/tests/md5sum/Makefile.in +++ b/tests/md5sum/Makefile.in @@ -522,6 +522,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -539,6 +540,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -551,11 +553,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/md5sum/basic-1 b/tests/md5sum/basic-1 index 5f02af2..52120a7 100755 --- a/tests/md5sum/basic-1 +++ b/tests/md5sum/basic-1 @@ -33,6 +33,8 @@ use strict; (my $program_name = $0) =~ s|.*/||; +my $src_path = "$ENV{PWD}/../../src"; + # Turn off localisation of executable's ouput. @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; @@ -63,7 +65,7 @@ my @Tests = # sha1sum accept BSD format. ['check-bsd', '--check', {IN=> {'f.sha1' => "SHA1 (f) = $degenerate\n"}}, {AUX=> {f=> ''}}, - {ERR=>"md5sum: f.sha1: no properly formatted " + {ERR=>"$src_path/md5sum: f.sha1: no properly formatted " . "MD5 checksum lines found\n"}, {EXIT=> 1}], ['check-bsd2', '--check', {IN=> {'f.md5' => "MD5 (f) = $degenerate\n"}}, diff --git a/tests/misc/Makefile.in b/tests/misc/Makefile.in index 357d695..40974d7 100644 --- a/tests/misc/Makefile.in +++ b/tests/misc/Makefile.in @@ -600,6 +600,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -617,6 +618,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -629,11 +631,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/misc/basename b/tests/misc/basename index 89d96ff..58ab954 100755 --- a/tests/misc/basename +++ b/tests/misc/basename @@ -45,12 +45,14 @@ my $double_slash = ($stat_single->dev == $stat_double->dev my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $src_path = "$ENV{PWD}/../../src"; + 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'}], + ['fail-1', {ERR => "$src_path/$prog: missing operand\n" + . "Try `$src_path/$prog --help' for more information.\n"}, {EXIT => '1'}], + ['fail-2', qw(a b c), {ERR => "$src_path/$prog: extra operand `c'\n" + . "Try `$src_path/$prog --help' for more information.\n"}, {EXIT => '1'}], ['a', qw(d/f), {OUT => 'f'}], ['b', qw(/d/f), {OUT => 'f'}], diff --git a/tests/misc/csplit b/tests/misc/csplit index 885d692..adc216a 100755 --- a/tests/misc/csplit +++ b/tests/misc/csplit @@ -76,6 +76,7 @@ rm -f in out exp # `echo |csplit - 1 1' used to abort. echo > in csplit in 1 1 > out 2> err || fail=1 +sed -r 's/^(\/.*\/)*(csplit:.*)/\2/' err > err1; mv err1 err cat < exp 0 0 @@ -83,6 +84,7 @@ cat < exp 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 @@ -95,6 +97,10 @@ 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 + +sed -r 's/^(\/.*\/)*(csplit:.*)/\2/' out > out1; mv out1 out +sed -r 's/^(\/.*\/)*(csplit:.*)/\2/' err > err1; mv err1 err + cat <<\EOF > experr csplit: 0: line number must be greater than zero csplit: line number `1' is smaller than preceding line number, 2 diff --git a/tests/misc/dirname b/tests/misc/dirname index c217d9a..24f5866 100755 --- a/tests/misc/dirname +++ b/tests/misc/dirname @@ -46,12 +46,14 @@ my $double_slash = ($stat_single->dev == $stat_double->dev my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $src_path = "$ENV{PWD}/../../src"; + 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'}], + ['fail-1', {ERR => "$src_path/$prog: missing operand\n" + . "Try `$src_path/$prog --help' for more information.\n"}, {EXIT => '1'}], + ['fail-2', qw(a b), {ERR => "$src_path/$prog: extra operand `b'\n" + . "Try `$src_path/$prog --help' for more information.\n"}, {EXIT => '1'}], ['a', qw(d/f), {OUT => 'd'}], ['b', qw(/d/f), {OUT => '/d'}], diff --git a/tests/misc/split-fail b/tests/misc/split-fail index 70435b4..b76a124 100755 --- a/tests/misc/split-fail +++ b/tests/misc/split-fail @@ -77,6 +77,7 @@ split -99999999999999999991 2> out && fail=1 # so map them both to -99*. sed 's/99[19]*/99*/' out > out-t mv -f out-t out +sed -r 's/^(\/.*\/)*(split:.*)/\2/' out > out1; mv out1 out cat <<\EOF > exp split: line count option -99*... is too large diff --git a/tests/misc/stat-printf b/tests/misc/stat-printf index ecd4940..a5d35c6 100755 --- a/tests/misc/stat-printf +++ b/tests/misc/stat-printf @@ -34,6 +34,8 @@ use strict; (my $ME = $0) =~ s|.*/||; my $prog = 'stat'; +my $src_path = "$ENV{PWD}/../../src"; + # Turn off localisation of executable's ouput. @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; @@ -53,7 +55,7 @@ my @Tests = ['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"}], + {ERR=>"$src_path/$prog: warning: unrecognized escape `\\x'\n"}], # With --format, there *is* a trailing newline. ['f-nl', "--format=%n .", {OUT=>".\n"}], @@ -62,12 +64,12 @@ my @Tests = ['end-pct', "--printf=% .", {OUT=>"%"}], ['pct-pct', "--printf=%% .", {OUT=>"%"}], ['end-bs', "--printf='\\' .", {OUT=>'\\'}, - {ERR=>"$prog: warning: backslash at end of format\n"}], + {ERR=>"$src_path/$prog: warning: backslash at end of format\n"}], ['err-1', "--printf=%9% .", {EXIT => 1}, - {ERR=>"$prog: %9%: invalid directive\n"}], + {ERR=>"$src_path/$prog: %9%: invalid directive\n"}], ['err-2', "--printf=%9 .", {EXIT => 1}, - {ERR=>"$prog: %9: invalid directive\n"}], + {ERR=>"$src_path/$prog: %9: invalid directive\n"}], ); my $save_temps = $ENV{DEBUG}; diff --git a/tests/misc/wc-files0-from b/tests/misc/wc-files0-from index 72f1bdf..265191d 100755 --- a/tests/misc/wc-files0-from +++ b/tests/misc/wc-files0-from @@ -41,6 +41,8 @@ use strict; $ENV{PROG} = 'wc'; my $ME = $ENV{PROG}; +my $src_path = "$ENV{PWD}/../../src"; + # Turn off localization of executable's ouput. @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; @@ -48,14 +50,14 @@ 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" + {ERR => "$src_path/$ME: extra operand `no-such'\n" . "File operands cannot be combined with --files0-from.\n" - . "Try `$ME --help' for more information.\n"} + . "Try `$src_path/$ME --help' for more information.\n"} ], # missing input file ['missing', '--files0-from=missing', {EXIT=>1}, - {ERR => "$ME: cannot open `missing' for reading: " + {ERR => "$src_path/$ME: cannot open `missing' for reading: " . "No such file or directory\n"}], # empty input @@ -66,13 +68,13 @@ my @Tests = # one NUL ['nul-1', '--files0-from=-', '<', {IN=>"\0"}, {EXIT=>1}, - {ERR => "$ME: : No such file or directory\n"}], + {ERR => "$src_path/$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"}], + {ERR => "$src_path/$ME: : No such file or directory\n" + . "$src_path/$ME: : No such file or directory\n"}], # one file name, no NUL ['1', '--files0-from=-', '<', @@ -96,7 +98,7 @@ my @Tests = ['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} ], + {ERR => "$src_path/$ME: : No such file or directory\n"}, {EXIT=>1} ], ); my $save_temps = $ENV{DEBUG}; diff --git a/tests/mkdir/Makefile.in b/tests/mkdir/Makefile.in index 78efc69..772e13f 100644 --- a/tests/mkdir/Makefile.in +++ b/tests/mkdir/Makefile.in @@ -522,6 +522,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -539,6 +540,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -551,11 +553,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/mkdir/p-v b/tests/mkdir/p-v index 2675423..052744b 100755 --- a/tests/mkdir/p-v +++ b/tests/mkdir/p-v @@ -46,6 +46,7 @@ if test $framework_failure = 1; then fi mkdir -pv foo/a/b/c/d 2>out || exit +sed -r 's/^(\/.*\/)*(mkdir:.*)/\2/' out > out1; mv out1 out diff - out <<\EOF mkdir: created directory `foo' diff --git a/tests/mv/Makefile.in b/tests/mv/Makefile.in index b86230a..475b42b 100644 --- a/tests/mv/Makefile.in +++ b/tests/mv/Makefile.in @@ -563,6 +563,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -580,6 +581,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -592,11 +594,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/mv/dir2dir b/tests/mv/dir2dir index 11ae26e..710390f 100755 --- a/tests/mv/dir2dir +++ b/tests/mv/dir2dir @@ -56,6 +56,8 @@ mv b/t a 2> out && fail=1 sed 's/: File exists/: Directory not empty/'o1;mv o1 out sed 's/: Device or resource busy/: Directory not empty/'o1;mv o1 out +sed -r 's/^(\/.*\/)*(mv:.*)/\2/' out > out1; mv out1 out + cat <<\EOF > exp || fail=1 mv: cannot move `b/t' to `a/t': Directory not empty EOF diff --git a/tests/mv/dup-source b/tests/mv/dup-source index 7965c91..2582f99 100755 --- a/tests/mv/dup-source +++ b/tests/mv/dup-source @@ -63,6 +63,7 @@ for i in cp; do # But not with plain `--backup' rm -fr a d; touch a; mkdir d $i --backup a a d/ 2>> out && fail=1 + sed -r 's/^(\/.*\/)*(cp:.*)/\2/' out > out1; mv out1 out cat < exp $i: warning: source file \`a' specified more than once $i: warning: source file \`a' specified more than once @@ -79,6 +80,7 @@ for i in mv; do $i a a d/ 2> out && fail=1 rm -fr a d; touch a; mkdir d $i ./a a d/ 2>> out && fail=1 + sed -r 's/^(\/.*\/)*(mv:.*)/\2/' out > out1; mv out1 out cat < exp $i: cannot stat \`a': No such file or directory $i: cannot stat \`a': No such file or directory diff --git a/tests/mv/i-1 b/tests/mv/i-1 index 3ab73c0..5e741e4 100755 --- a/tests/mv/i-1 +++ b/tests/mv/i-1 @@ -38,12 +38,14 @@ use strict; my $test_a = 'a'; +my $src_path = "$ENV{PWD}/../../src"; + my @Tests = ( # Make sure a `n' reply to `mv -i...' aborts the move operation. [$test_a, '-i', {IN => {src => "a\n"}}, {IN => {dst => "b\n"}}, '<', {IN => "n\n"}, - {ERR => "mv: overwrite `dst'? "}, + {ERR => "$src_path/mv: overwrite `dst'? "}, {POST => sub { -r 'src' or die "test $test_a failed\n"}}, {EXIT => 0}, ], diff --git a/tests/mv/i-link-no b/tests/mv/i-link-no index 2931af6..1612b3a 100755 --- a/tests/mv/i-link-no +++ b/tests/mv/i-link-no @@ -49,6 +49,8 @@ fi fail=0 mv --reply=no a/bar a/foo b > out 2> err || fail=1 +sed -r 's/^(\/.*\/)*(mv:.*)/\2/' err > err1; mv err1 err + cat < exp EOF diff --git a/tests/mv/perm-1 b/tests/mv/perm-1 index 1b9ab28..171eb6e 100755 --- a/tests/mv/perm-1 +++ b/tests/mv/perm-1 @@ -47,6 +47,9 @@ fi fail=0 mv no-write/dir . > out 2>&1 && fail=1 + +sed -r 's/^(\/.*\/)*(mv:.*)/\2/' out > out1; mv out1 out + cat <<\EOF > exp mv: cannot move `no-write/dir' to `./dir': Permission denied EOF diff --git a/tests/mv/reply-no b/tests/mv/reply-no index ae0a3cd..7aed9ef 100755 --- a/tests/mv/reply-no +++ b/tests/mv/reply-no @@ -48,6 +48,8 @@ mv --interactive --reply=no a b > out 2>&1 || fail=1 test -f a || fail=1 test -f b || fail=1 +sed -r 's/^(\/.*\/)*(mv:.*)/\2/' out > out1; mv out1 out + cat < exp_err mv: the --reply option is deprecated; use -i or -f instead EOF diff --git a/tests/od/Makefile.in b/tests/od/Makefile.in index 90f34eb..395486b 100644 --- a/tests/od/Makefile.in +++ b/tests/od/Makefile.in @@ -521,6 +521,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -538,6 +539,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -550,11 +552,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/pr/Makefile.in b/tests/pr/Makefile.in index da0078a..b1de47b 100644 --- a/tests/pr/Makefile.in +++ b/tests/pr/Makefile.in @@ -651,6 +651,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -668,6 +669,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -680,11 +682,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/readlink/Makefile.in b/tests/readlink/Makefile.in index e2d7264..5a883fb 100644 --- a/tests/readlink/Makefile.in +++ b/tests/readlink/Makefile.in @@ -518,6 +518,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -535,6 +536,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -547,11 +549,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/rm/Makefile.in b/tests/rm/Makefile.in index 391f4e1..aca610d 100644 --- a/tests/rm/Makefile.in +++ b/tests/rm/Makefile.in @@ -565,6 +565,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -582,6 +583,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -594,11 +596,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/rm/cycle b/tests/rm/cycle index 22936ee..17580a3 100755 --- a/tests/rm/cycle +++ b/tests/rm/cycle @@ -46,6 +46,9 @@ fi fail=0 rm -rf a a 2>&1 | sed 's/:[^:]*$//' > out || fail=1 + +sed -r 's/^(\/.*\/)*(rm:.*)/\2/' out > out1; mv out1 out + cat <<\EOF > exp rm: cannot remove `a/b/file' rm: cannot remove `a/b/file' diff --git a/tests/rm/dir-no-w b/tests/rm/dir-no-w index 27aba6a..adb80d3 100755 --- a/tests/rm/dir-no-w +++ b/tests/rm/dir-no-w @@ -46,6 +46,9 @@ fail=0 # For rm from coreutils-5.0.1, this would prompt. rm ---presume-input-tty unwritable-dir < /dev/null > out-t 2>&1 && fail=1 + +sed -r 's/^(\/.*\/)*(rm:.*)/\2/' out-t > out1; mv out1 out-t + cat <<\EOF > exp || fail=1 rm: cannot remove `unwritable-dir': Is a directory EOF diff --git a/tests/rm/dir-nonrecur b/tests/rm/dir-nonrecur index 5b09821..d7775f1 100755 --- a/tests/rm/dir-nonrecur +++ b/tests/rm/dir-nonrecur @@ -44,6 +44,9 @@ fi fail=0 rm d 2> out && fail=1 + +sed -r 's/^(\/.*\/)*(rm:.*)/\2/' out > out1; mv out1 out + cat <<\EOF > exp || fail=1 rm: cannot remove `d': Is a directory EOF diff --git a/tests/rm/fail-eacces b/tests/rm/fail-eacces index b322848..82ecc47 100755 --- a/tests/rm/fail-eacces +++ b/tests/rm/fail-eacces @@ -44,6 +44,8 @@ fi fail=0 rm -rf d/f 2> out && fail=1 +sed -r 's/^(\/.*\/)*(rm:.*)/\2/' out > out1; mv out1 out + cat <<\EOF > exp rm: cannot remove `d/f': Permission denied EOF diff --git a/tests/rm/inaccessible b/tests/rm/inaccessible index 02128d7..0253973 100755 --- a/tests/rm/inaccessible +++ b/tests/rm/inaccessible @@ -60,6 +60,8 @@ set +x test -d "$p/abs1" && fail=1 test -d "$p/abs2" && fail=1 +sed -r 's/^(\/.*\/)*(rm:.*)/\2/' out > out1; mv out1 out + cat <<\EOF > exp || fail=1 rm: cannot remove `rel': Permission denied EOF diff --git a/tests/rm/interactive-always b/tests/rm/interactive-always index 7b81664..79ebb79 100755 --- a/tests/rm/interactive-always +++ b/tests/rm/interactive-always @@ -87,17 +87,20 @@ rm -R -f --interactive=once file4-* < $test.I >> out 2>> err || fail=1 echo . >> err || fail=1 test -f file4-1 || fail=1 +sed -r 's/^(\/.*\/)*(rm:.*)/\2/' out > out1; mv out1 out +sed -r 's/^(\/.*\/)*(rm:.*)/\2/' err > err1; mv err1 err + cat <<\EOF > expout || fail=1 EOF cat <<\EOF > experr || fail=1 no WHEN -rm: remove regular empty file `file1-1'? rm: remove regular empty file `file1-2'? . +rm: remove regular empty file `file1-2'? . WHEN=never . WHEN=once rm: remove all arguments recursively? . WHEN=always -rm: remove regular empty file `file4-1'? rm: remove regular empty file `file4-2'? . +rm: remove regular empty file `file4-2'? . -f overrides --interactive . --interactive overrides -f diff --git a/tests/rm/interactive-once b/tests/rm/interactive-once index 9325e8e..ea2c95f 100755 --- a/tests/rm/interactive-once +++ b/tests/rm/interactive-once @@ -103,6 +103,9 @@ echo . >> err || fail=1 test -d dir2-1 && fail=1 test -d dir2-2 && fail=1 +sed -r 's/^(\/.*\/)*(rm:.*)/\2/' out > out1; mv out1 out +sed -r 's/^(\/.*\/)*(rm:.*)/\2/' err > err1; mv err1 err + cat <<\EOF > expout || fail=1 EOF cat <<\EOF > experr || fail=1 diff --git a/tests/rm/isatty b/tests/rm/isatty index 202dc01..389e34e 100755 --- a/tests/rm/isatty +++ b/tests/rm/isatty @@ -61,6 +61,8 @@ test -f f || fail=1 kill $pid > /dev/null 2>&1 +sed -r 's/^(\/.*\/)*(rm:.*)/\2/' out > out1; mv out1 out + # Note the trailing `x' -- so I don't have to have a trailing # blank in this file :-) cat > exp <<\EOF diff --git a/tests/rm/rm1 b/tests/rm/rm1 index 8987cd2..9223e8d 100755 --- a/tests/rm/rm1 +++ b/tests/rm/rm1 @@ -47,6 +47,9 @@ fail=0 # This should fail. rm -rf b > out 2>&1 && fail=1 + +sed -r 's/^(\/.*\/)*(rm:.*)/\2/' out > out1; mv out1 out + cat <<\EOF > exp rm: cannot remove directory `b/a/p': Permission denied EOF diff --git a/tests/rm/rm2 b/tests/rm/rm2 index c64a9f3..44fcd0e 100755 --- a/tests/rm/rm2 +++ b/tests/rm/rm2 @@ -52,6 +52,9 @@ fail=0 # in the same sort of diagnostic. # Both of these should fail. rm -rf a b > out 2>&1 && fail=1 + +sed -r 's/^(\/.*\/)*(rm:.*)/\2/' out > out1; mv out1 out + cat <<\EOF > exp rm: cannot remove `a/1': Permission denied rm: cannot remove `b': Permission denied diff --git a/tests/rm/rm3 b/tests/rm/rm3 index b3caf49..b7e7b6e 100755 --- a/tests/rm/rm3 +++ b/tests/rm/rm3 @@ -66,6 +66,7 @@ EOF # Both of these should fail. rm -ir z < in > out 2>&1 || fail=1 +sed -r 's/^(\/.*\/)*(rm:.*)/\2/' out > out1; mv out1 out # Given input like `rm: ...? rm: ...? ' (no trailing newline), # the `head...' part of the pipeline below removes the trailing space, so @@ -75,6 +76,7 @@ rm -ir z < in > out 2>&1 || fail=1 tr '?' '\n' < out | head --bytes=-1 | sed 's/^ //' |sort > o2 mv o2 out + sort < exp || fail=1 rm: descend into directory \`z' rm: remove regular empty file \`z/empty' diff --git a/tests/rm/rm5 b/tests/rm/rm5 index 297d02a..f66df9c 100755 --- a/tests/rm/rm5 +++ b/tests/rm/rm5 @@ -57,6 +57,8 @@ fail=0 rm -ir d < in > out 2>&1 || fail=1 +sed -r 's/^(\/.*\/)*(rm:.*)/\2/' out > out1; mv out1 out + # Given input like `rm: ...? rm: ...? ' (no trailing newline), # the `head...' part of the pipeline below removes the trailing space, so # that sed doesn't have to deal with a line lacking a terminating newline. diff --git a/tests/rm/unread2 b/tests/rm/unread2 index e67c9ae..e57bd33 100755 --- a/tests/rm/unread2 +++ b/tests/rm/unread2 @@ -47,6 +47,9 @@ fail=0 # This should fail. rm -rf a > out 2>&1 && fail=1 + +sed -r 's/^(\/.*\/)*(rm:.*)/\2/' out > out1; mv out1 out + cat <<\EOF > exp rm: cannot remove `a': Permission denied EOF diff --git a/tests/rmdir/Makefile.in b/tests/rmdir/Makefile.in index 7104588..e21ee95 100644 --- a/tests/rmdir/Makefile.in +++ b/tests/rmdir/Makefile.in @@ -522,6 +522,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -539,6 +540,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -551,11 +553,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/seq/Makefile.in b/tests/seq/Makefile.in index 056150e..4c29ba8 100644 --- a/tests/seq/Makefile.in +++ b/tests/seq/Makefile.in @@ -522,6 +522,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -539,6 +540,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -551,11 +553,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/sha1sum/Makefile.in b/tests/sha1sum/Makefile.in index a016355..0574993 100644 --- a/tests/sha1sum/Makefile.in +++ b/tests/sha1sum/Makefile.in @@ -522,6 +522,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -539,6 +540,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -551,11 +553,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/sha1sum/basic-1 b/tests/sha1sum/basic-1 index 35562bd..e6f802f 100755 --- a/tests/sha1sum/basic-1 +++ b/tests/sha1sum/basic-1 @@ -38,6 +38,8 @@ use strict; my $sha_degenerate = "da39a3ee5e6b4b0d3255bfef95601890afd80709"; +my $src_path = "$ENV{PWD}/../../src"; + my @Tests = ( ['s1', {IN=> {f=> ''}}, @@ -64,7 +66,7 @@ my @Tests = # md5sum accept BSD format. ['check-bsd', '--check', {IN=> {'f.md5' => "MD5 (f) = $sha_degenerate\n"}}, {AUX=> {f=> ''}}, - {ERR=>"sha1sum: f.md5: no properly formatted " + {ERR=>"$src_path/sha1sum: f.md5: no properly formatted " . "SHA1 checksum lines found\n"}, {EXIT=> 1}], ['check-bsd2', '--check', diff --git a/tests/shred/Makefile.in b/tests/shred/Makefile.in index 66c79dd..17d5d16 100644 --- a/tests/shred/Makefile.in +++ b/tests/shred/Makefile.in @@ -521,6 +521,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -538,6 +539,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -550,11 +552,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/sort/Makefile.in b/tests/sort/Makefile.in index cab283b..7f4b106 100644 --- a/tests/sort/Makefile.in +++ b/tests/sort/Makefile.in @@ -592,6 +592,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -609,6 +610,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -621,11 +623,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/stty/Makefile.in b/tests/stty/Makefile.in index f6b75a9..eca4ba0 100644 --- a/tests/stty/Makefile.in +++ b/tests/stty/Makefile.in @@ -518,6 +518,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -535,6 +536,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -547,11 +549,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/sum/Makefile.in b/tests/sum/Makefile.in index 4501982..44ee0da 100644 --- a/tests/sum/Makefile.in +++ b/tests/sum/Makefile.in @@ -522,6 +522,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -539,6 +540,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -551,11 +553,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/tac/Makefile.in b/tests/tac/Makefile.in index 68b4045..c71f4f4 100644 --- a/tests/tac/Makefile.in +++ b/tests/tac/Makefile.in @@ -563,6 +563,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -580,6 +581,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -592,11 +594,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/tail-2/Makefile.in b/tests/tail-2/Makefile.in index 4a3818a..9393494 100644 --- a/tests/tail-2/Makefile.in +++ b/tests/tail-2/Makefile.in @@ -546,6 +546,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -563,6 +564,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -575,11 +577,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/tail/Makefile.in b/tests/tail/Makefile.in index 2ac0eae..3d4174a 100644 --- a/tests/tail/Makefile.in +++ b/tests/tail/Makefile.in @@ -571,6 +571,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -588,6 +589,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -600,11 +602,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/tee/Makefile.in b/tests/tee/Makefile.in index 050793d..7b84bfb 100644 --- a/tests/tee/Makefile.in +++ b/tests/tee/Makefile.in @@ -518,6 +518,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -535,6 +536,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -547,11 +549,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/test/Makefile.in b/tests/test/Makefile.in index 60472b0..0b9bb01 100644 --- a/tests/test/Makefile.in +++ b/tests/test/Makefile.in @@ -647,6 +647,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -664,6 +665,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -676,11 +678,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/touch/Makefile.in b/tests/touch/Makefile.in index 442fa3f..00990df 100644 --- a/tests/touch/Makefile.in +++ b/tests/touch/Makefile.in @@ -544,6 +544,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -561,6 +562,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -573,11 +575,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/touch/fail-diag b/tests/touch/fail-diag index 082f754..2487958 100755 --- a/tests/touch/fail-diag +++ b/tests/touch/fail-diag @@ -49,6 +49,9 @@ fi fail=0 touch $dir > out 2>&1 && fail=1 + +sed -r 's/^(\/.*\/)*(touch:.*)/\2/' out > out1; mv out1 out + cat < exp touch: cannot touch \`$dir': No such file or directory EOF diff --git a/tests/touch/not-owner b/tests/touch/not-owner index 4d63ad7..5681852 100755 --- a/tests/touch/not-owner +++ b/tests/touch/not-owner @@ -60,6 +60,8 @@ fail=0 # touch: creating `/': Is a directory touch / > out 2>&1 && fail=1 +sed -r 's/^(\/.*\/)*(touch:.*)/\2/' out > out1; mv out1 out + # On SunOS4, EPERM is `Not owner'. # On some *BSD systems it's `Operation not permitted'. for msg in 'Not owner' 'Operation not permitted' 'Permission denied'; do diff --git a/tests/tr/Makefile.in b/tests/tr/Makefile.in index 6ae4ba3..42e01ae 100644 --- a/tests/tr/Makefile.in +++ b/tests/tr/Makefile.in @@ -575,6 +575,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -592,6 +593,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -604,11 +606,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/tsort/Makefile.in b/tests/tsort/Makefile.in index 3f3be5b..ab41198 100644 --- a/tests/tsort/Makefile.in +++ b/tests/tsort/Makefile.in @@ -522,6 +522,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -539,6 +540,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -551,11 +553,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/tsort/basic-1 b/tests/tsort/basic-1 index 4fe24f3..3455017 100755 --- a/tests/tsort/basic-1 +++ b/tests/tsort/basic-1 @@ -39,14 +39,16 @@ use strict; # Turn off localisation of executable's ouput. @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; +my $src_path = "$ENV{PWD}/../../src"; + my @Tests = ( ['cycle-1', {IN => {f => "t b\nt s\ns t\n"}}, {OUT => "s\nt\nb\n"}, {EXIT => 1}, - {ERR => "tsort: f: input contains a loop:\ntsort: s\ntsort: t\n"} ], + {ERR => "$src_path/tsort: f: input contains a loop:\n$src_path/tsort: s\n$src_path/tsort: t\n"} ], ['cycle-2', {IN => {f => "t x\nt s\ns t\n"}}, {OUT => "s\nt\nx\n"}, {EXIT => 1}, - {ERR => "tsort: f: input contains a loop:\ntsort: s\ntsort: t\n"} ], + {ERR => "$src_path/tsort: f: input contains a loop:\n$src_path/tsort: s\n$src_path/tsort: t\n"} ], ['posix-1', {IN => "a b c c d e\ng g\nf g e f\nh h\n"}, {OUT => "a\nc\nd\nh\nb\ne\nf\ng\n"}], @@ -66,12 +68,12 @@ my @Tests = # copy of the final token were appended. ['odd', {IN => "a\n"}, {EXIT => 1}, - {ERR => "tsort: odd.1: input contains an odd number of tokens\n"}], + {ERR => "$src_path/tsort: odd.1: input contains an odd number of tokens\n"}], ['only-one', {IN => {f => ""}}, {IN => {g => ""}}, {EXIT => 1}, - {ERR => "tsort: extra operand `g'\n" - . "Try `tsort --help' for more information.\n"}], + {ERR => "$src_path/tsort: extra operand `g'\n" + . "Try `$src_path/tsort --help' for more information.\n"}], ); my $save_temps = $ENV{DEBUG}; diff --git a/tests/unexpand/Makefile.in b/tests/unexpand/Makefile.in index 48393aa..2ae25f8 100644 --- a/tests/unexpand/Makefile.in +++ b/tests/unexpand/Makefile.in @@ -522,6 +522,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -539,6 +540,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -551,11 +553,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/unexpand/basic-1 b/tests/unexpand/basic-1 index 3824d7c..9d28f8f 100755 --- a/tests/unexpand/basic-1 +++ b/tests/unexpand/basic-1 @@ -39,6 +39,8 @@ use strict; my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $src_path = "$ENV{PWD}/../../src"; + my @Tests = ( ['a1', {IN=> ' 'x 1 ."y\n"}, {OUT=> ' 'x 1 ."y\n"}], @@ -91,7 +93,7 @@ my @Tests = # It is debatable whether this test should require an environment # setting of e.g., _POSIX2_VERSION=1. ['obs-ovflo', '-18446744073709551617', {IN=>''}, {OUT=>''}, - {EXIT => 1}, {ERR => "$prog: tab stop value is too large\n"}], + {EXIT => 1}, {ERR => "$src_path/$prog: tab stop value is too large\n"}], ); my $save_temps = $ENV{DEBUG}; diff --git a/tests/uniq/Makefile.in b/tests/uniq/Makefile.in index bd99059..321400a 100644 --- a/tests/uniq/Makefile.in +++ b/tests/uniq/Makefile.in @@ -569,6 +569,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -586,6 +587,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -598,11 +600,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \ diff --git a/tests/wc/Makefile.in b/tests/wc/Makefile.in index 5a46cac..d6e3b4c 100644 --- a/tests/wc/Makefile.in +++ b/tests/wc/Makefile.in @@ -555,6 +555,7 @@ CTAGS: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + TEST_LOG="/tmp/coreutils_test"; export TEST_LOG; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ if test -n "$$list"; then \ @@ -572,6 +573,7 @@ check-TESTS: $(TESTS) ;; \ *) \ echo "PASS: $$tst"; \ + echo "TEST: PASS: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ elif test $$? -ne 77; then \ @@ -584,11 +586,13 @@ check-TESTS: $(TESTS) *) \ failed=`expr $$failed + 1`; \ echo "FAIL: $$tst"; \ + echo "TEST: FAIL: $$tst" >> $$TEST_LOG; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ echo "SKIP: $$tst"; \ + echo "TEST: SKIP: $$tst" >> $$TEST_LOG; \ fi; \ done; \ if test "$$failed" -eq 0; then \