On 09/21/2015 02:56 AM, Pádraig Brady wrote:
> On 21/09/15 00:47, Bernhard Voelker wrote:
>> >From 1335ab2713aab020564275c49fdb3e92bb9a207b Mon Sep 17 00:00:00 2001
>> From: Bernhard Voelker <[email protected]>
>> Date: Mon, 21 Sep 2015 01:40:33 +0200
>> Subject: [PATCH] maint: use adaptive approach for `ulimit -v` based tests
>>
>> When configured with either 'symlinks' or 'shebangs' as value for
>> the --enable-single-binary option, tests based on `ulimit -v` are
>> skipped.  The reason is that the multicall 'coreutils' binary requires
>> much more memory due to shared libraries being loaded, and the size of
>> the 'date' binary (~290KiB) compared to the multicall binary (~5MiB),
>> of course.  Finally, in the case of 'shebangs', the starting shell
>> requires more memory, too
>>
>> Instead of using hard-coded values for the memory limit, use an
>> adaptive approach: first determine the amount of memory for a similar,
>> yet more trivial command, and then do the real test run using that
> 
> s/command/invocation of the command/
> 
> I can't find any significant issues with the patch at all.

Thanks, I'll push with that change tomorrow.

> In future for i18n significant `ulimit -v`, we might have gen_min_ulimit_v_()
> do additional checking of setlocale() output with non "C" locales
> (I notice locale(1) doesn't set the exit value appropriately upon failure :/),
> and use that as additional space to add on top of the current adaptive method?

Using the above adaptive gen_min_ulimit_v_(), isn't the attached sufficient
for tests/i18n/sort-month.sh (both patches on top of your I18N branch)?

BTW: I've found another strange issue with "sort -Mu" swallowing one output line
(therefore I had to use the extra uniq(1) in the attached patch for now):

  $ printf ".\nɑ\n" | /var/tmp/build-root/openSUSE_Factory-x86_64/usr/bin/sort 
-M
  .
  ɑ
  $ printf "ɑ\n.\n" | /var/tmp/build-root/openSUSE_Factory-x86_64/usr/bin/sort 
-M
  .
  ɑ
  $ printf ".\nɑ\n" | /var/tmp/build-root/openSUSE_Factory-x86_64/usr/bin/sort 
-Mu
  .
  $ printf "ɑ\n.\n" | /var/tmp/build-root/openSUSE_Factory-x86_64/usr/bin/sort 
-Mu
  ɑ

Interestingly, the effect is not limited to I18N but also happens with git 
master;
'sort -Mu' seems to discard all but one of the non-month input lines:

  $ printf "b\na\n" | LC_ALL=C ~/coreutils/src/sort -Mu
  b
  $ printf "a\nb\n" | LC_ALL=C ~/coreutils/src/sort -Mu
  a
  $ printf "Nov\nDec\na\nb\n" | LC_ALL=C ~/coreutils/src/sort -Mu
  a
  Nov
  Dec

I don't think this is intended, is it?
It's getting quite late, so I'll stop now.

Thanks & have a nice day,
Berny
>From d2bbe6ec30e6f7e0546b2dbf42a22b35f54b1649 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <[email protected]>
Date: Tue, 22 Sep 2015 02:45:28 +0200
Subject: [PATCH] tests: change i18n/sort-month.sh to use adaptive 'ulimit -v'

* tests/i18n/sort-month.sh: Use the new adaptive get_min_ulimit_v_
rather than using valgrind; the latter way to verify that 'sort -M'
does not leak a huge amount of memory anymore only works when compiled
with -Dlint.
---
 tests/i18n/sort-month.sh | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/tests/i18n/sort-month.sh b/tests/i18n/sort-month.sh
index 9ff0fd4..2dac1e3 100644
--- a/tests/i18n/sort-month.sh
+++ b/tests/i18n/sort-month.sh
@@ -3,12 +3,6 @@
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ sort
-require_valgrind_
-
-# Skip this test if some deallocations are
-# avoided at process end.
-grep '^#define lint 1' $CONFIG_HEADER > /dev/null ||
-  skip_ 'Allocation checks only work reliably in "lint" mode'
 
 export LC_ALL=en_US.UTF-8
 locale -k LC_CTYPE | grep -q "charmap.*UTF-8" \
@@ -17,18 +11,19 @@ locale -k LC_CTYPE | grep -q "charmap.*UTF-8" \
 # Note the use of ɑ here which expands to
 # a wider representation upon case conversion
 # which triggered an assertion in sort -M
-cat <<EOF > exp
-.
-ɑ
-EOF
+s=$(printf ".\nɑ") || framework_failure_
+echo "$s" > exp || framework_failure_
 
+# Detemine required amount of memory for small input.
+vm=$(get_min_ulimit_v_ sort -M -o out exp)\
+  || skip_ "this shell lacks ulimit support"
+compare exp out || fail=1
 
 # check large mem leak with --month-sort
 # https://bugzilla.redhat.com/show_bug.cgi?id=1259942
-valgrind --leak-check=full \
-         --error-exitcode=1 --errors-for-leak-kinds=definite \
-         sort -M < exp > out || fail=1
-compare exp out || { fail=1; cat out; }
-
+yes "$s" | head -n200000 \
+  | (ulimit -v $(($vm+10000)) && sort -M -o out2) || fail=1
+uniq < out2 > out3 || framework_failure_
+compare exp out3 || fail=1
 
 Exit $fail
-- 
2.1.4

Reply via email to