Blame SOURCES/coreutils-8.22-non-defaulttests.patch

fc4c3c
diff -urNp coreutils-8.22-orig/tests/cp/cp-a-selinux.sh coreutils-8.22/tests/cp/cp-a-selinux.sh
fc4c3c
--- coreutils-8.22-orig/tests/cp/cp-a-selinux.sh	2013-12-04 15:48:30.000000000 +0100
fc4c3c
+++ coreutils-8.22/tests/cp/cp-a-selinux.sh	2015-08-17 13:59:27.837012142 +0200
fc4c3c
@@ -4,7 +4,7 @@
fc4c3c
 # Check also locally if --preserve=context, -a and --preserve=all
fc4c3c
 # does work
fc4c3c
 
fc4c3c
-# Copyright (C) 2007-2013 Free Software Foundation, Inc.
fc4c3c
+# Copyright (C) 2007-2015 Free Software Foundation, Inc.
fc4c3c
 
fc4c3c
 # This program is free software: you can redistribute it and/or modify
fc4c3c
 # it under the terms of the GNU General Public License as published by
fc4c3c
@@ -37,16 +37,36 @@ cp -a c d 2>err || framework_failure_
fc4c3c
 cp --preserve=context c e || framework_failure_
fc4c3c
 cp --preserve=all c f || framework_failure_
fc4c3c
 ls -Z d | grep $ctx || fail=1
fc4c3c
-test -s err && fail=1   #there must be no stderr output for -a
fc4c3c
+# there must be no stderr output for -a
fc4c3c
+compare /dev/null err || fail=1
fc4c3c
 ls -Z e | grep $ctx || fail=1
fc4c3c
 ls -Z f | grep $ctx || fail=1
fc4c3c
+rm -f f
fc4c3c
+
fc4c3c
+# Check handling of existing dirs which requires specific handling
fc4c3c
+# due to recursion, and was handled incorrectly in coreutils-8.22
fc4c3c
+# Note standard permissions are updated for existing directories
fc4c3c
+# in the destination, so SELinux contexts should be updated too.
fc4c3c
+chmod o+rw restore/existing_dir
fc4c3c
+mkdir -p backup/existing_dir/ || framework_failure_
fc4c3c
+ls -Zd backup/existing_dir > ed_ctx || fail=1
fc4c3c
+grep $ctx ed_ctx && framework_failure_
fc4c3c
+touch backup/existing_dir/file || framework_failure_
fc4c3c
+chcon $ctx backup/existing_dir/file || framework_failure_
fc4c3c
+# Set the dir context to ensure it is reset
fc4c3c
+mkdir -p --context="$ctx" restore/existing_dir || framework_failure_
fc4c3c
+# Copy and ensure existing directories updated
fc4c3c
+cp -a backup/. restore/
fc4c3c
+ls -Zd restore/existing_dir > ed_ctx || fail=1
fc4c3c
+grep $ctx ed_ctx &&
fc4c3c
+  { ls -lZd restore/existing_dir; fail=1; }
fc4c3c
 
fc4c3c
 # Check restorecon (-Z) functionality for file and directory
fc4c3c
 get_selinux_type() { ls -Zd "$1" | sed -n 's/.*:\(.*_t\):.*/\1/p'; }
fc4c3c
 # Also make a dir with our known context
fc4c3c
 mkdir c_d || framework_failure_
fc4c3c
 chcon $ctx c_d || framework_failure_
fc4c3c
-# Get the type of this known context for file and dir
fc4c3c
+# Get the type of this known context for file and dir for tracing
fc4c3c
 old_type_f=$(get_selinux_type c)
fc4c3c
 old_type_d=$(get_selinux_type c_d)
fc4c3c
 # Setup copies for manipulation with restorecon
fc4c3c
@@ -62,7 +82,7 @@ if restorecon Z1 Z1_d 2>/dev/null; then
fc4c3c
   cpZ_type_f=$(get_selinux_type Z2)
fc4c3c
   test "$cpZ_type_f" = "$new_type_f" || fail=1
fc4c3c
 
fc4c3c
-  # Ensuze -Z overrides -a and that dirs are handled too
fc4c3c
+  # Ensure -Z overrides -a and that dirs are handled too
fc4c3c
   cp -aZ c Z3 || fail=1
fc4c3c
   cp -aZ c_d Z3_d || fail=1
fc4c3c
   cpaZ_type_f=$(get_selinux_type Z3)
fc4c3c
@@ -93,27 +113,30 @@ test $skip = 1 \
fc4c3c
 
fc4c3c
 cd mnt                                       || framework_failure_
fc4c3c
 
fc4c3c
-echo > f                                     || framework_failure_
fc4c3c
-
fc4c3c
+# Create files with hopefully different contexts
fc4c3c
+echo > ../f                                  || framework_failure_
fc4c3c
 echo > g                                     || framework_failure_
fc4c3c
+test "$(stat -c%C ../f)" = "$(stat -c%C g)" &&
fc4c3c
+  skip_ "files on separate file systems have the same security context"
fc4c3c
+
fc4c3c
 # /bin/cp from coreutils-6.7-3.fc7 would fail this test by letting cp
fc4c3c
 # succeed (giving no diagnostics), yet leaving the destination file empty.
fc4c3c
-cp -a f g 2>err || fail=1
fc4c3c
+cp -a ../f g 2>err || fail=1
fc4c3c
 test -s g       || fail=1     # The destination file must not be empty.
fc4c3c
-test -s err     && fail=1     # There must be no stderr output.
fc4c3c
+compare /dev/null err || fail=1
fc4c3c
 
fc4c3c
 # =====================================================
fc4c3c
 # Here, we expect cp to succeed and not warn with "Operation not supported"
fc4c3c
 rm -f g
fc4c3c
 echo > g
fc4c3c
-cp --preserve=all f g 2>err || fail=1
fc4c3c
+cp --preserve=all ../f g 2>err || fail=1
fc4c3c
 test -s g || fail=1
fc4c3c
 grep "Operation not supported" err && fail=1
fc4c3c
 
fc4c3c
 # =====================================================
fc4c3c
 # The same as above except destination does not exist
fc4c3c
 rm -f g
fc4c3c
-cp --preserve=all f g 2>err || fail=1
fc4c3c
+cp --preserve=all ../f g 2>err || fail=1
fc4c3c
 test -s g || fail=1
fc4c3c
 grep "Operation not supported" err && fail=1
fc4c3c
 
fc4c3c
@@ -133,9 +156,9 @@ echo > g
fc4c3c
 # =====================================================
fc4c3c
 # Here, we expect cp to fail, because it cannot set the SELinux
fc4c3c
 # security context through NFS or a mount with fixed context.
fc4c3c
-cp --preserve=context f g 2> out && fail=1
fc4c3c
+cp --preserve=context ../f g 2> out && fail=1
fc4c3c
 # Here, we *do* expect the destination to be empty.
fc4c3c
-test -s g && fail=1
fc4c3c
+compare /dev/null g || fail=1
fc4c3c
 sed "s/ .g'.*//" out > k
fc4c3c
 mv k out
fc4c3c
 compare exp out || fail=1
fc4c3c
@@ -143,9 +166,9 @@ compare exp out || fail=1
fc4c3c
 rm -f g
fc4c3c
 echo > g
fc4c3c
 # Check if -a option doesn't silence --preserve=context option diagnostics
fc4c3c
-cp -a --preserve=context f g 2> out2 && fail=1
fc4c3c
+cp -a --preserve=context ../f g 2> out2 && fail=1
fc4c3c
 # Here, we *do* expect the destination to be empty.
fc4c3c
-test -s g && fail=1
fc4c3c
+compare /dev/null g || fail=1
fc4c3c
 sed "s/ .g'.*//" out2 > k
fc4c3c
 mv k out2
fc4c3c
 compare exp out2 || fail=1
fc4c3c
@@ -154,31 +177,33 @@ for no_g_cmd in '' 'rm -f g'; do
fc4c3c
   # restorecon equivalent.  Note even though the context
fc4c3c
   # returned from matchpathcon() will not match $ctx
fc4c3c
   # the resulting ENOTSUP warning will be suppressed.
fc4c3c
+
fc4c3c
    # With absolute path
fc4c3c
   $no_g_cmd
fc4c3c
-  cp -Z f $(realpath g) || fail=1
fc4c3c
+  cp -Z ../f $(realpath g) || fail=1
fc4c3c
    # With relative path
fc4c3c
   $no_g_cmd
fc4c3c
-  cp -Z f g || fail=1
fc4c3c
+  cp -Z ../f g || fail=1
fc4c3c
    # -Z overrides -a
fc4c3c
   $no_g_cmd
fc4c3c
-  cp -Z -a f g || fail=1
fc4c3c
+  cp -Z -a ../f g || fail=1
fc4c3c
    # -Z doesn't take an arg
fc4c3c
   $no_g_cmd
fc4c3c
-  cp -Z "$ctx" f g && fail=1
fc4c3c
+  returns_ 1 cp -Z "$ctx" ../f g || fail=1
fc4c3c
 
fc4c3c
   # Explicit context
fc4c3c
   $no_g_cmd
fc4c3c
    # Explicitly defaulting to the global $ctx should work
fc4c3c
-  cp --context="$ctx" f g || fail=1
fc4c3c
+  cp --context="$ctx" ../f g || fail=1
fc4c3c
    # --context overrides -a
fc4c3c
   $no_g_cmd
fc4c3c
-  cp -a --context="$ctx" f g || fail=1
fc4c3c
+  cp -a --context="$ctx" ../f g || fail=1
fc4c3c
 done
fc4c3c
 
fc4c3c
-# Mutually exlusive options
fc4c3c
-cp -Z --preserve=context f g && fail=1
fc4c3c
-cp --preserve=context -Z f g && fail=1
fc4c3c
-cp --preserve=context --context="$ctx" f g && fail=1
fc4c3c
+# Mutually exclusive options
fc4c3c
+returns_ 1 cp -Z --preserve=context ../f g || fail=1
fc4c3c
+returns_ 1 cp --preserve=context -Z ../f g || fail=1
fc4c3c
+returns_ 1 cp --preserve=context --context="$ctx" ../f g || fail=1
fc4c3c
 
fc4c3c
 Exit $fail
fc4c3c
+
fc4c3c
diff -urNp coreutils-8.22-orig/tests/du/2g.sh coreutils-8.22/tests/du/2g.sh
fc4c3c
--- coreutils-8.22-orig/tests/du/2g.sh	2013-12-04 15:48:30.000000000 +0100
fc4c3c
+++ coreutils-8.22/tests/du/2g.sh	2015-08-17 13:59:37.349088611 +0200
fc4c3c
@@ -3,7 +3,7 @@
fc4c3c
 # Before coreutils-5.93, on systems with a signed, 32-bit stat.st_blocks
fc4c3c
 # one of du's computations would overflow.
fc4c3c
 
fc4c3c
-# Copyright (C) 2005-2013 Free Software Foundation, Inc.
fc4c3c
+# Copyright (C) 2005-2015 Free Software Foundation, Inc.
fc4c3c
 
fc4c3c
 # This program is free software: you can redistribute it and/or modify
fc4c3c
 # it under the terms of the GNU General Public License as published by
fc4c3c
@@ -24,13 +24,9 @@ print_ver_ du
fc4c3c
 # Creating a 2GB file counts as 'very expensive'.
fc4c3c
 very_expensive_
fc4c3c
 
fc4c3c
-
fc4c3c
 # Get number of free kilobytes on current partition, so we can
fc4c3c
 # skip this test if there is insufficient free space.
fc4c3c
-
fc4c3c
-# This technique relies on the fact that the 'Available' kilobyte
fc4c3c
-# count is the number just before the one with a trailing '%'.
fc4c3c
-free_kb=$(df -kP .|tail -1|sed 's/ [0-9][0-9]*%.*//;s/ *$//;s/.* //')
fc4c3c
+free_kb=$(df -k --output=avail . | tail -n1)
fc4c3c
 case "$free_kb" in
fc4c3c
   [0-9]*) ;;
fc4c3c
   *) skip_ "invalid size from df: $free_kb";;
fc4c3c
@@ -45,16 +41,22 @@ test $min_kb -lt $free_kb ||
fc4c3c
 }
fc4c3c
 
fc4c3c
 big=big
fc4c3c
-rm -f $big
fc4c3c
-test -t 1 || printf 'creating a 2GB file...\n'
fc4c3c
-for i in $(seq 100); do
fc4c3c
-  # Note: 2147483648 == 2^31. Print floor(2^31/100) per iteration.
fc4c3c
-  printf %21474836s x >> $big || fail=1
fc4c3c
-  # On the final iteration, append the remaining 48 bytes.
fc4c3c
-  test $i = 100 && { printf %48s x >> $big || fail=1; }
fc4c3c
-  test -t 1 && printf 'creating a 2GB file: %d%% complete\r' $i
fc4c3c
-done
fc4c3c
-echo
fc4c3c
+
fc4c3c
+if ! fallocate -l2G $big; then
fc4c3c
+  rm -f $big
fc4c3c
+  {
fc4c3c
+    is_local_dir_ . || skip 'Not writing 2GB data to remote'
fc4c3c
+    for i in $(seq 100); do
fc4c3c
+      # Note: 2147483648 == 2^31. Print floor(2^31/100) per iteration.
fc4c3c
+      printf %21474836s x || fail=1
fc4c3c
+    done
fc4c3c
+    # After the final iteration, append the remaining 48 bytes.
fc4c3c
+    printf %48s x || fail=1
fc4c3c
+  } > $big || fail=1
fc4c3c
+fi
fc4c3c
+
fc4c3c
+# The allocation may be done asynchronously (BTRFS for example)
fc4c3c
+sync $big || framework_failure_
fc4c3c
 
fc4c3c
 du -k $big > out1 || fail=1
fc4c3c
 rm -f $big
fc4c3c
diff -urNp coreutils-8.22-orig/tests/init.sh coreutils-8.22/tests/init.sh
fc4c3c
--- coreutils-8.22-orig/tests/init.sh	2013-12-04 15:48:30.000000000 +0100
fc4c3c
+++ coreutils-8.22/tests/init.sh	2015-08-17 13:59:19.900948318 +0200
fc4c3c
@@ -93,6 +93,27 @@ skip_ () { warn_ "$ME_: skipped test: $@
fc4c3c
 fatal_ () { warn_ "$ME_: hard error: $@"; Exit 99; }
fc4c3c
 framework_failure_ () { warn_ "$ME_: set-up failure: $@"; Exit 99; }
fc4c3c
 
fc4c3c
+# This is used to simplify checking of the return value
fc4c3c
+# which is useful when ensuring a command fails as desired.
fc4c3c
+# I.e., just doing `command ... &&fail=1` will not catch
fc4c3c
+# a segfault in command for example.  With this helper you
fc4c3c
+# instead check an explicit exit code like
fc4c3c
+#   returns_ 1 command ... || fail
fc4c3c
+returns_ () {
fc4c3c
+  # Disable tracing so it doesn't interfere with stderr of the wrapped command
fc4c3c
+  { set +x; } 2>/dev/null
fc4c3c
+
fc4c3c
+  local exp_exit="$1"
fc4c3c
+  shift
fc4c3c
+  "$@"
fc4c3c
+  test $? -eq $exp_exit && ret_=0 || ret_=1
fc4c3c
+
fc4c3c
+  if test "$VERBOSE" = yes && test "$gl_set_x_corrupts_stderr_" = false; then
fc4c3c
+    set -x
fc4c3c
+  fi
fc4c3c
+  { return $ret_; } 2>/dev/null
fc4c3c
+}
fc4c3c
+
fc4c3c
 # Sanitize this shell to POSIX mode, if possible.
fc4c3c
 DUALCASE=1; export DUALCASE
fc4c3c
 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
fc4c3c
diff -urNp coreutils-8.22-orig/tests/local.mk coreutils-8.22/tests/local.mk
fc4c3c
--- coreutils-8.22-orig/tests/local.mk	2015-08-17 12:44:49.343344148 +0200
fc4c3c
+++ coreutils-8.22/tests/local.mk	2015-08-17 13:59:12.124885835 +0200
fc4c3c
@@ -121,7 +121,6 @@ all_root_tests =				\
fc4c3c
   tests/install/install-C-root.sh		\
fc4c3c
   tests/ls/capability.sh			\
fc4c3c
   tests/ls/nameless-uid.sh			\
fc4c3c
-  tests/misc/chcon.sh				\
fc4c3c
   tests/misc/chroot-credentials.sh		\
fc4c3c
   tests/misc/selinux.sh				\
fc4c3c
   tests/misc/truncate-owned-by-other.sh		\