Initial commit for coreutils 8.25 ... still need to fix two failing tests before build (likely i18n stuff)

This commit is contained in:
Ondřej Vašík 2016-01-20 16:43:39 +01:00
parent 11e5aa1d55
commit 7d9c9afa38
11 changed files with 56 additions and 355 deletions

1
.gitignore vendored
View File

@ -15,3 +15,4 @@
/coreutils-8.23.tar.xz.sig
/coreutils-8.24.tar.xz
/coreutils-8.24.tar.xz.sig
/coreutils-8.25.tar.xz

View File

@ -10,4 +10,4 @@ diff -urNp coreutils-6.12-orig/src/md5sum.c coreutils-6.12/src/md5sum.c
+"), stdout);
fputs (_("\
\n\
The following four options are useful only when verifying checksums:\n\
The following five options are useful only when verifying checksums:\n\

View File

@ -1,12 +0,0 @@
diff -urNp coreutils-8.13-orig/src/stty.c coreutils-8.13/src/stty.c
--- coreutils-8.13-orig/src/stty.c 2011-07-28 12:38:27.000000000 +0200
+++ coreutils-8.13/src/stty.c 2011-09-09 10:18:57.526687209 +0200
@@ -1005,7 +1005,7 @@ main (int argc, char **argv)
spurious difference in an uninitialized portion of the structure. */
static struct termios new_mode;
- if (tcsetattr (STDIN_FILENO, TCSADRAIN, &mode))
+ if (tcsetattr (STDIN_FILENO, TCSANOW, &mode))
error (EXIT_FAILURE, errno, "%s", device_name);
/* POSIX (according to Zlotnick's book) tcsetattr returns zero if

View File

@ -1,119 +0,0 @@
@@ -, +, @@
destination
mv dir dir dir
---
src/copy.c | 12 +++++++----
tests/local.mk | 1 -
tests/mv/dup-source.sh | 46 +++++++++++++++++++++++++++++++++----------
3 files changed, 44 insertions(+), 15 deletions(-)
--- a/src/copy.c
+++ a/src/copy.c
@@ -2278,10 +2278,14 @@ copy_internal (char const *src_name, char const *dst_name,
error (0, 0, _("warning: source directory %s "
"specified more than once"),
quote (top_level_src_name));
- /* We only do backups in move mode and for non dirs,
- and in move mode this won't be the issue as the source will
- be missing for subsequent attempts.
- There we just warn and return here. */
+ /* In move mode, if a previous rename succeeded, then
+ we won't be in this path as the source is missing. If the
+ rename previously failed, then that has been handled.
+ Pretend this instance succeeded so the source isn't removed. */
+ if (x->move_mode && rename_succeeded)
+ *rename_succeeded = true;
+ /* We only do backups in move mode, and for non directories.
+ So just ignore this repeated entry. */
return true;
}
else if (x->dereference == DEREF_ALWAYS
--- a/tests/local.mk
+++ a/tests/local.mk
@@ -443,7 +443,6 @@ all_tests = \
tests/cp/dir-rm-dest.sh \
tests/cp/dir-slash.sh \
tests/cp/dir-vs-file.sh \
- tests/cp/duplicate-sources.sh \
tests/cp/existing-perm-dir.sh \
tests/cp/existing-perm-race.sh \
tests/cp/fail-perm.sh \
--- a/tests/mv/dup-source.sh
+++ a/tests/mv/dup-source.sh
@@ -24,25 +24,37 @@ print_ver_ cp mv
skip_if_root_
+reset_files() { rm -fr a b d; touch a; mkdir b d; }
+
for i in cp; do
# cp may not fail in this case.
-
- rm -fr a d; touch a; mkdir d
+ reset_files
$i a a d/ 2> out || fail=1
- rm -fr a d; touch a; mkdir d
+ reset_files
$i ./a a d/ 2>> out || fail=1
+ # Similarly for directories, but handle
+ # source == dest appropriately.
+ reset_files
+ $i -a ./b b d/ 2>> out || fail=1
+ reset_files
+ returns_ 1 $i -a ./b b b/ 2>> out || fail=1
+
# cp succeeds with --backup=numbered.
- rm -fr a d; touch a; mkdir d
+ reset_files
$i --backup=numbered a a d/ 2>> out || fail=1
# But not with plain '--backup'
- rm -fr a d; touch a; mkdir d
- $i --backup a a d/ 2>> out && fail=1
+ reset_files
+ returns_ 1 $i --backup a a d/ 2>> out || fail=1
+
cat <<EOF > exp
$i: warning: source file 'a' specified more than once
$i: warning: source file 'a' specified more than once
+$i: warning: source directory 'b' specified more than once
+$i: cannot copy a directory, './b', into itself, 'b/b'
+$i: warning: source directory 'b' specified more than once
$i: will not overwrite just-created 'd/a' with 'a'
EOF
compare exp out || fail=1
@@ -50,14 +62,28 @@ done
for i in mv; do
# But mv *does* fail in this case (it has to).
+ reset_files
+ returns_ 1 $i a a d/ 2> out || fail=1
+ returns_ 1 test -e a || fail=1
+ reset_files
+ returns_ 1 $i ./a a d/ 2>> out || fail=1
+ returns_ 1 test -e a || fail=1
+
+ # Similarly for directories, also handling
+ # source == dest appropriately.
+ reset_files
+ returns_ 1 $i ./b b d/ 2>> out || fail=1
+ returns_ 1 test -e b || fail=1
+ reset_files
+ returns_ 1 $i --verbose ./b b b/ 2>> out || fail=1
+ test -d b || fail=1
- rm -fr a d; touch a; mkdir d
- $i a a d/ 2> out && fail=1
- rm -fr a d; touch a; mkdir d
- $i ./a a d/ 2>> out && fail=1
cat <<EOF > exp
$i: cannot stat 'a': No such file or directory
$i: cannot stat 'a': No such file or directory
+$i: cannot stat 'b': No such file or directory
+$i: cannot move './b' to a subdirectory of itself, 'b/b'
+$i: warning: source directory 'b' specified more than once
EOF
compare exp out || fail=1
done
--

View File

@ -13,8 +13,8 @@
#include "error.h"
@@ -90,25 +95,16 @@ add_range_pair (size_t lo, size_t hi)
++n_rp;
}
CURRENT_RP.HI then we make CURRENT_RP to point to the next range pair. */
static struct field_range_pair *current_rp;
-/* This buffer is used to support the semantics of the -s option
- (or lack of same) when the specified field list includes (does
@ -58,8 +58,8 @@
-static unsigned char delim;
+static mbf_char_t delim;
/* True if the --output-delimiter=STRING option was specified. */
static bool output_delimiter_specified;
/* The delimiter for each line/record. */
static unsigned char line_delim = '\n';
@@ -135,7 +135,7 @@ static size_t output_delimiter_length;
/* The output field separator string. Defaults to the 1-character
@ -240,24 +240,24 @@
+
+ print_delimiter = false;
+ char_idx = 0;
+ current_rp = rp;
+ current_rp = frp;
+
+ mbf_init (mbf, stream);
+ while (true)
+ {
+ mbf_getc (c, mbf);
+
+ if (mb_iseq (c, '\n'))
+ if (mb_iseq (c, line_delim))
+ {
+ putc ('\n', stdout);
+ putc (line_delim, stdout);
+ char_idx = 0;
+ print_delimiter = false;
+ current_rp = rp;
+ current_rp = frp;
+ }
+ else if (mb_iseof (c))
+ {
+ if (char_idx > 0)
+ putc ('\n', stdout);
+ putc (line_delim, stdout);
+ break;
+ }
+ else
@ -312,7 +312,7 @@
bool found_any_selected_field = false;
bool buffer_first_field;
current_rp = rp;
current_rp = frp;
- c = getc (stream);
- if (c == EOF)
@ -336,14 +336,14 @@
- size_t n_bytes;
+ size_t n_chars;
+ mbf_char_t nl;
+ mb_setascii (&nl, '\n');
+ mb_setascii (&nl, line_delim);
+
+ len = mb_getndelim2 (&field_1_buffer, &field_1_bufsize,
+ GETNLINE_NO_LIMIT, d, nl, &mbf);
+
- len = getndelim2 (&field_1_buffer, &field_1_bufsize, 0,
- GETNLINE_NO_LIMIT, delim, '\n', stream);
- GETNLINE_NO_LIMIT, delim, line_delim, stream);
if (len < 0)
{
free (field_1_buffer);
@ -376,11 +376,11 @@
+ mb_putc (field_1_buffer[i], stdout);
+
/* Make sure the output line is newline terminated. */
- if (field_1_buffer[n_bytes - 1] != '\n')
+ if (!mb_iseq (field_1_buffer[n_chars - 1], '\n'))
putchar ('\n');
- c = '\n';
+ mb_setascii (&c,'\n');
- if (field_1_buffer[n_bytes - 1] != line_delim)
+ if (!mb_iseq (field_1_buffer[n_chars - 1], line_delim))
putchar (line_delim);
- c = line_delim;
+ mb_setascii (&c, line_delim);
}
continue;
}
@ -392,8 +392,8 @@
+ mb_putc (field_1_buffer[i], stdout);
/* With -d$'\n' don't treat the last '\n' as a delimiter. */
- if (delim == '\n')
+ if (mb_iseq (d, '\n'))
- if (delim == line_delim)
+ if (mb_iseq (d, line_delim))
{
- int last_c = getc (stream);
- if (last_c != EOF)
@ -416,13 +416,13 @@
if (print_kth (field_idx))
{
@@ -605,41 +822,46 @@ cut_fields (FILE *stream)
@@ -605,42 +822,46 @@ cut_fields (FILE *stream)
}
found_any_selected_field = true;
- while ((c = getc (stream)) != delim && c != '\n' && c != EOF)
- while ((c = getc (stream)) != delim && c != line_delim && c != EOF)
+ mbf_getc (c, mbf);
+ while (!mb_equal (c, d) && !mb_iseq (c, '\n') && !mb_iseof (c))
+ while (!mb_equal (c, d) && !mb_iseq (c, line_delim) && !mb_iseof (c))
{
- putchar (c);
- prev_c = c;
@ -433,9 +433,9 @@
}
else
{
- while ((c = getc (stream)) != delim && c != '\n' && c != EOF)
- while ((c = getc (stream)) != delim && c != line_delim && c != EOF)
+ mbf_getc (c, mbf);
+ while (!mb_equal (c, d) && !mb_iseq (c, '\n') && !mb_iseof (c))
+ while (!mb_equal (c, d) && !mb_iseq (c, line_delim) && !mb_iseof (c))
{
- prev_c = c;
+ mb_copy (&prev_c, &c);
@ -444,8 +444,8 @@
}
/* With -d$'\n' don't treat the last '\n' as a delimiter. */
- if (delim == '\n' && c == delim)
+ if (mb_iseq (d, '\n') && mb_equal (c, d))
- if (delim == line_delim && c == delim)
+ if (mb_iseq (d, line_delim) && mb_equal (c, d))
{
- int last_c = getc (stream);
- if (last_c != EOF)
@ -462,21 +462,22 @@
- if (c == delim)
+ if (mb_equal (c, d))
next_item (&field_idx);
- else if (c == '\n' || c == EOF)
+ else if (mb_iseq (c, '\n') || mb_iseof (c))
- else if (c == line_delim || c == EOF)
+ else if (mb_iseq (c, line_delim) || mb_iseof (c))
{
if (found_any_selected_field
|| !(suppress_non_delimited && field_idx == 1))
{
- if (c == '\n' || prev_c != '\n' || delim == '\n')
+ if (mb_iseq (c, '\n') || !mb_iseq (prev_c, '\n') || mb_iseq (d, '\n'))
putchar ('\n');
- if (c == line_delim || prev_c != line_delim
- || delim == line_delim)
+ if (mb_iseq (c, line_delim) || !mb_iseq (prev_c, line_delim) || mb_iseq (d, line_delim))
putchar (line_delim);
}
- if (c == EOF)
+ if (mb_iseof (c))
break;
field_idx = 1;
current_rp = rp;
current_rp = frp;
@@ -652,7 +874,14 @@ static void
cut_stream (FILE *stream)
{
@ -512,7 +513,7 @@
+ mb_setascii (&delim, '\0');
have_read_stdin = false;
while ((optc = getopt_long (argc, argv, "b:c:d:f:ns", longopts, NULL)) != -1)
while ((optc = getopt_long (argc, argv, "b:c:d:f:nsz", longopts, NULL)) != -1)
@@ -728,7 +960,6 @@ main (int argc, char **argv)
switch (optc)
{
@ -565,7 +566,7 @@
case 's':
@@ -802,15 +1048,12 @@ main (int argc, char **argv)
}
| (complement ? SETFLD_COMPLEMENT : 0) );
if (!delim_specified)
- delim = '\t';

View File

@ -433,14 +433,14 @@ index 0a40a1a..ed97fd4 100644
- {
- if (ferror (fp))
- {
- error (0, errno, "%s", prev_file);
- error (0, errno, "%s", quotef (prev_file));
- exit_status = EXIT_FAILURE;
- }
- if (STREQ (prev_file, "-"))
- clearerr (fp); /* Also clear EOF. */
- else if (fclose (fp) != 0)
- {
- error (0, errno, "%s", prev_file);
- error (0, errno, "%s", quotef (prev_file));
- exit_status = EXIT_FAILURE;
- }
- }
@ -460,7 +460,7 @@ index 0a40a1a..ed97fd4 100644
- fadvise (fp, FADVISE_SEQUENTIAL);
- return fp;
- }
- error (0, errno, "%s", file);
- error (0, errno, "%s", quotef (file));
- exit_status = EXIT_FAILURE;
- }
- return NULL;
@ -748,14 +748,14 @@ index e0f7c22..48fbb32 100644
- {
- if (ferror (fp))
- {
- error (0, errno, "%s", prev_file);
- error (0, errno, "%s", quotef (prev_file));
- exit_status = EXIT_FAILURE;
- }
- if (STREQ (prev_file, "-"))
- clearerr (fp); /* Also clear EOF. */
- else if (fclose (fp) != 0)
- {
- error (0, errno, "%s", prev_file);
- error (0, errno, "%s", quotef (prev_file));
- exit_status = EXIT_FAILURE;
- }
- }
@ -775,7 +775,7 @@ index e0f7c22..48fbb32 100644
- fadvise (fp, FADVISE_SEQUENTIAL);
- return fp;
- }
- error (0, errno, "%s", file);
- error (0, errno, "%s", quotef (file));
- exit_status = EXIT_FAILURE;
- }
- return NULL;

View File

@ -150,7 +150,7 @@ diff -urNp coreutils-8.24-orig/src/fold.c coreutils-8.24/src/fold.c
-
- if (istream == NULL)
- {
- error (0, errno, "%s", filename);
- error (0, errno, "%s", quotef (filename));
- return false;
- }
@ -394,7 +394,7 @@ diff -urNp coreutils-8.24-orig/src/fold.c coreutils-8.24/src/fold.c
+
if (ferror (istream))
{
error (0, saved_errno, "%s", filename);
error (0, saved_errno, "%s", quotef (filename));
@@ -251,7 +498,8 @@ main (int argc, char **argv)
atexit (close_stdout);
@ -493,7 +493,7 @@ diff -urNp coreutils-8.24-orig/src/join.c coreutils-8.24/src/join.c
+ else
{
/* Skip leading blanks before the first field. */
while (isblank (to_uchar (*ptr)))
while (field_sep (*ptr))
@@ -305,6 +322,147 @@ xfields (struct line *line)
extract_field (line, ptr, lim - ptr);
}
@ -1240,7 +1240,7 @@ diff -urNp coreutils-8.24-orig/src/pr.c coreutils-8.24/src/pr.c
- clump_buff = xmalloc (MAX (8, chars_per_input_tab));
+ clump_buff = xmalloc (mb_len * MAX (8, chars_per_input_tab));
}
/* Open the necessary files,
@@ -1383,7 +1506,7 @@ init_funcs (void)
@ -2685,33 +2685,6 @@ diff -urNp coreutils-8.24-orig/src/sort.c coreutils-8.24/src/sort.c
}
break;
@@ -4681,10 +5374,10 @@ main (int argc, char **argv)
if (nfiles == 0)
{
- static char *minus = (char *) "-";
nfiles = 1;
free (files);
- files = &minus;
+ files = xmalloc (sizeof *files);
+ *files = (char *) "-";
}
/* Need to re-check that we meet the minimum requirement for memory
@@ -4742,6 +5435,13 @@ main (int argc, char **argv)
sort (files, nfiles, outfile, nthreads);
}
+#ifdef lint
+ if (files_from)
+ readtokens0_free (&tok);
+ else
+ free (files);
+#endif
+
if (have_read_stdin && fclose (stdin) == EOF)
die (_("close failed"), "-");
diff -urNp coreutils-8.24-orig/src/uniq.c coreutils-8.24/src/uniq.c
--- coreutils-8.24-orig/src/uniq.c 2015-06-26 19:04:19.000000000 +0200
+++ coreutils-8.24/src/uniq.c 2015-07-05 09:04:33.032546980 +0200
@ -2733,12 +2706,13 @@ diff -urNp coreutils-8.24-orig/src/uniq.c coreutils-8.24/src/uniq.c
#include "system.h"
#include "argmatch.h"
#include "linebuffer.h"
@@ -32,7 +43,19 @@
@@ -32,8 +43,20 @@
#include "stdio--.h"
#include "xmemcoll.h"
#include "xstrtol.h"
-#include "memcasecmp.h"
+#include "xmemcoll.h"
#include "quote.h"
+
+/* MB_LEN_MAX is incorrectly defined to be 1 in at least one GCC
+ installation; work around this configuration error. */

View File

@ -1,50 +0,0 @@
--- coreutils-8.23/gnulib-tests/gnulib.mk.orig 2015-07-04 11:11:09.438579284 +0100
+++ coreutils-8.23/gnulib-tests/gnulib.mk 2015-07-04 11:12:12.113643496 +0100
@@ -2312,14 +2312,6 @@
## end gnulib module unsetenv-tests
-## begin gnulib module update-copyright-tests
-
-TESTS += test-update-copyright.sh
-TESTS_ENVIRONMENT += abs_aux_dir='$(abs_aux_dir)'
-EXTRA_DIST += test-update-copyright.sh
-
-## end gnulib module update-copyright-tests
-
## begin gnulib module userspec-tests
TESTS += test-userspec
--- coreutils-8.23/gnulib-tests/Makefile.in.orig 2015-07-04 11:10:54.353323089 +0100
+++ coreutils-8.23/gnulib-tests/Makefile.in 2015-07-04 11:12:45.542210970 +0100
@@ -220,7 +220,6 @@
test-u8-mbtoucr$(EXEEXT) test-u8-uctomb$(EXEEXT) \
test-uc_width$(EXEEXT) uniwidth/test-uc_width2.sh \
test-unlink$(EXEEXT) test-unlinkat$(EXEEXT) \
- test-unsetenv$(EXEEXT) test-update-copyright.sh \
test-userspec$(EXEEXT) test-utimens$(EXEEXT) \
test-utimensat$(EXEEXT) test-vasnprintf$(EXEEXT) \
test-vasprintf-posix$(EXEEXT) test-vasprintf$(EXEEXT) \
@@ -3766,7 +3765,7 @@
uniwidth/test-uc_width2.sh macros.h test-unlink.h \
test-unlink.c signature.h macros.h test-unlinkat.c \
test-rmdir.h test-unlink.h signature.h macros.h unlinkdir.h \
- test-unsetenv.c signature.h macros.h test-update-copyright.sh \
+ test-unsetenv.c signature.h macros.h \
test-userspec.c nap.h test-futimens.h test-lutimens.h \
test-utimens.h test-utimens-common.h test-utimens.c macros.h \
nap.h test-lutimens.h test-utimens.h test-utimens-common.h \
@@ -7787,13 +7786,6 @@
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
- "$$tst" $(AM_TESTS_FD_REDIRECT)
-test-update-copyright.sh.log: test-update-copyright.sh
- @p='test-update-copyright.sh'; \
- b='test-update-copyright.sh'; \
- $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
- --log-file $$b.log --trs-file $$b.trs \
- $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
test-userspec.log: test-userspec$(EXEEXT)
@p='test-userspec$(EXEEXT)'; \

View File

@ -1,7 +1,7 @@
Summary: A set of basic GNU tools commonly used in shell scripts
Name: coreutils
Version: 8.24
Release: 108%{?dist}
Version: 8.25
Release: 1%{?dist}
License: GPLv3+
Group: System Environment/Base
Url: http://www.gnu.org/software/coreutils/
@ -21,27 +21,18 @@ Source10: coreutils-find-requires.sh
%global __find_requires %{SOURCE10} %{_rpmconfigdir}/find-requires
# From upstream
#mv: prevent dataloss when source directory is specified multiple t imes
Patch1: coreutils-8.24-mv-duplicate-sources.patch
# Our patches
#general patch to workaround koji build system issues
Patch100: coreutils-6.10-configuration.patch
#add note about no difference between binary/text mode on Linux - md5sum manpage
Patch101: coreutils-6.10-manpages.patch
#temporarily workaround probable kernel issue with TCSADRAIN(#504798)
Patch102: coreutils-7.4-sttytcsadrain.patch
#do display processor type for uname -p/-i based on uname(2) syscall
Patch103: coreutils-8.2-uname-processortype.patch
#df --direct
Patch104: coreutils-df-direct.patch
#add note about mkdir --mode behaviour into info documentation(#610559)
Patch107: coreutils-8.4-mkdir-modenote.patch
# Don't run the currently failing test-update-copyright.sh test
Patch108: coreutils-remove-test-update-copyright.patch
#avoid false failure due to extra stat() calls done by opendir() in glibc 2.22
Patch109: glibc-2.22-test-fix.patch
# sh-utils
#add info about TZ envvar to date manpage
@ -172,12 +163,9 @@ including documentation and translations.
# Our patches
%patch100 -p1 -b .configure
%patch101 -p1 -b .manpages
%patch102 -p1 -b .tcsadrain
%patch103 -p1 -b .sysinfo
%patch104 -p1 -b .dfdirect
%patch107 -p1 -b .mkdirmode
%patch108 -p1 -b .crtest
%patch109 -p1 -b .opendir_stat
# sh-utils
%patch703 -p1 -b .dateman
@ -192,13 +180,12 @@ including documentation and translations.
%patch908 -p1 -b .getgrouplist
%patch912 -p1 -b .overflow
%patch913 -p1 -b .testoff
%patch1 -p1 -b .dupl
#SELinux
%patch950 -p1 -b .selinux
%patch951 -p1 -b .selinuxman
chmod a+x tests/misc/sort-mb-tests.sh tests/df/direct.sh tests/mv-dup-source.sh || :
chmod a+x tests/misc/sort-mb-tests.sh tests/df/direct.sh || :
#fix typos/mistakes in localized documentation(#439410, #440056)
find ./po/ -name "*.p*" | xargs \
@ -359,6 +346,9 @@ fi
%license COPYING
%changelog
* Wed Jan 20 2016 Ondrej Vasik <ovasik@redhat.com> - 8.25-1
- new upstream release(#1300282)
* Fri Jan 15 2016 Ondrej Oprala <ooprala@redhat.com> - 8.24-108
- cut: be MB for ALL archs

View File

@ -1,83 +0,0 @@
From fd5f2b1569e2e0b31be755e14e236a7a02478fc0 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <mail@bernhard-voelker.de>
Date: Sun, 30 Aug 2015 22:49:35 +0200
Subject: [PATCH] tests: avoid FP of ls/stat-free-color.sh with newer glibc
Since glibc-2.22, specifically commit [0], the opendir() implementation
implicitly makes an additional stat call thus leading to a FP.
Seen on openSUSE:Tumbleweed since snapshot 20150821.
[0]
https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=46f894d8c60a
* tests/ls/stat-free-color.sh: Change the test to verify that ls(1)
needs the same number of stat-like calls for a single, empty directory
argument as for one with a few directory entries (sub-directory,
regular file, symlink, etc.).
---
tests/ls/stat-free-color.sh | 39 ++++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/tests/ls/stat-free-color.sh b/tests/ls/stat-free-color.sh
index fb2ee8b..35816a3 100755
--- a/tests/ls/stat-free-color.sh
+++ b/tests/ls/stat-free-color.sh
@@ -27,8 +27,6 @@ stats='stat,lstat,stat64,lstat64,newfstatat'
require_strace_ $stats
require_dirent_d_type_
-ln -s nowhere dangle || framework_failure_
-
# Disable enough features via LS_COLORS so that ls --color
# can do its job without calling stat (other than the obligatory
# one-call-per-command-line argument).
@@ -54,22 +52,33 @@ EOF
eval $(dircolors -b color-without-stat)
# The system may perform additional stat-like calls before main.
-# To avoid counting those, first get a baseline count by running
-# ls with only the --help option. Then, compare that with the
+# Furthermore, underlying library functions may also implicitly
+# add an extra stat call, e.g. opendir since glibc-2.21-360-g46f894d.
+# To avoid counting those, first get a baseline count for running
+# ls with one empty directory argument. Then, compare that with the
# invocation under test.
-strace -o log-help -e $stats ls --help >/dev/null || fail=1
-n_lines_help=$(wc -l < log-help)
+mkdir d || framework_failure_
+
+strace -o log1 -e $stats ls --color=always d || fail=1
+n_stat1=$(wc -l < log1) || framework_failure_
+
+test $n_stat1 = 0 \
+ && skip_ 'No stat calls recognized on this platform'
-strace -o log -e $stats ls --color=always . || fail=1
-n_lines=$(wc -l < log)
+# Populate the test directory.
+mkdir d/subdir \
+ && touch d/regf \
+ && ln d/regf d/hlink \
+ && ln -s regf d/slink \
+ && ln -s nowhere d/dangle \
+ || framework_failure_
-n_stat=$(expr $n_lines - $n_lines_help)
+# Invocation under test.
+strace -o log2 -e $stats ls --color=always d || fail=1
+n_stat2=$(wc -l < log2) || framework_failure_
-# Expect one stat call.
-case $n_stat in
- 0) skip_ 'No stat calls recognized on this platform' ;;
- 1) ;; # Corresponding to stat(".")
- *) fail=1; head -n30 log* ;;
-esac
+# Expect the same number of stat calls.
+test $n_stat1 = $n_stat2 \
+ || { fail=1; head -n30 log*; }
Exit $fail
--
2.4.1

View File

@ -1,2 +1 @@
40efdbce865d2458d8da0a9dcee7c16c coreutils-8.24.tar.xz
01b4406a1de25aa4af49b9c4b0057c19 coreutils-8.24.tar.xz.sig
070e43ba7f618d747414ef56ab248a48 coreutils-8.25.tar.xz