]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: avoid intermittent ulimit -v failures
authorPádraig Brady <P@draigBrady.com>
Wed, 16 Dec 2015 02:07:56 +0000 (02:07 +0000)
committerPádraig Brady <P@draigBrady.com>
Thu, 17 Dec 2015 00:25:49 +0000 (00:25 +0000)
* init.cfg (get_min_ulimit_v_): Increase the determined
virtual memory limit for the command by a page size
to avoid alignment issues causing false failures for
subsequent runs.
* tests/misc/cut-huge-range.sh: Be defensive and match
the cut invocations under test, more closely with the
form used to determine the VM memory limit.

This was noticed on i686 linux at:
http://hydra.nixos.org/build/28990456

init.cfg
tests/misc/cut-huge-range.sh

index e4309ae5397a28dff7c64ab11b2a58ede90c8fcc..d5ac23bc913f42ad05d7a98fab229545056a4bc0 100644 (file)
--- a/init.cfg
+++ b/init.cfg
@@ -158,14 +158,24 @@ require_openat_support_()
 # Return 0 in case of success, and a non-Zero value otherwise.
 get_min_ulimit_v_()
 {
-  local vm
+  local v
+  local page_size
+
+  # Increase result by this amount to avoid alignment issues
+  page_size=$(getconf PAGESIZE || echo 4096)
+  page_size=$(($page_size / 1024))
+
   for v in $( seq 5000 5000 50000 ); do
     if ( ulimit -v $v && "$@" ) >/dev/null; then
-      local vm_prev
+      local prev_v
       prev_v=$v
       for v in $( seq $(($prev_v-1000)) -1000 1000 ); do
-        ( ulimit -v $v && "$@" ) >/dev/null \
-          || { echo $prev_v; return 0; }
+        ( ulimit -v $v && "$@" ) >/dev/null || \
+          {
+            ret_v=$((prev_v + $page_size))
+            echo $ret_v
+            return 0
+          }
         prev_v=$v
       done
     fi
index 633ca8572451b3fcff00b30aef4940369add13df..001bcde3028f0a327894555a345e7ad6d31f8d42 100755 (executable)
@@ -51,15 +51,15 @@ CUT_MAX=$(echo $SIZE_MAX | sed "$subtract_one")
 
 # From coreutils-8.10 through 8.20, this would make cut try to allocate
 # a 256MiB bit vector.
-(ulimit -v $vm && : | cut -b$CUT_MAX- > err 2>&1) || fail=1
+(ulimit -v $vm && cut -b$CUT_MAX- /dev/null > err 2>&1) || fail=1
 
 # Up to and including coreutils-8.21, cut would allocate possibly needed
 # memory upfront.  Subsequently extra memory is no longer needed.
-(ulimit -v $vm && : | cut -b1-$CUT_MAX >> err 2>&1) || fail=1
+(ulimit -v $vm && cut -b1-$CUT_MAX /dev/null >> err 2>&1) || fail=1
 
 # Explicitly disallow values above CUT_MAX
-(ulimit -v $vm && : | returns_ 1 cut -b$SIZE_MAX 2>/dev/null) || fail=1
-(ulimit -v $vm && : | returns_ 1 cut -b$SIZE_OFLOW 2>/dev/null) || fail=1
+(ulimit -v $vm && returns_ 1 cut -b$SIZE_MAX /dev/null 2>/dev/null) || fail=1
+(ulimit -v $vm && returns_ 1 cut -b$SIZE_OFLOW /dev/null 2>/dev/null) || fail=1
 
 compare /dev/null err || fail=1