From 611e7e02bff8898e622d6ad582a92f2de746b614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?=
Date: Thu, 14 Jan 2016 01:17:57 +0000 Subject: [PATCH 1/3] sort: with --debug, flag setlocale() failures on OpenBSD Locale categories are not equivalent on OpenBSD, and LC_COLLATE only supports "C" for example. Now LC_ALL is supported to set multiple other categories on OpenBSD, so setlocale(LC_ALL, "") returns a string indicating which categories were updated and which ignored. Therefore... * src/sort.c (main): ...Call setlocale(LC_COLLATE, "") to explicitly check whether a specified LC_ALL or LC_COLLATE environment variable value is supported for the LC_COLLATE category. Also use !! to explicitly convert to bool to support c89 systems where bool is an int, and thus would get values > 1. Reported by Assaf Gordon. --- src/sort.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sort.c b/src/sort.c index 575877d..62acb62 100644 --- a/src/sort.c +++ b/src/sort.c @@ -4192,7 +4192,7 @@ main (int argc, char **argv) initialize_main (&argc, &argv); set_program_name (argv[0]); - locale_ok = setlocale (LC_ALL, ""); + locale_ok = !! setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); @@ -4667,6 +4667,10 @@ main (int argc, char **argv) quote (setlocale (LC_COLLATE, NULL))); else { + /* OpenBSD can only set some categories with LC_ALL above, + so set LC_COLLATE explicitly to flag errors. */ + if (locale_ok) + locale_ok = !! setlocale (LC_COLLATE, ""); error (0, 0, "%s%s", locale_ok ? "" : _("failed to set locale; "), _("using simple byte comparison")); } -- 2.5.0 From b4c768c42d955cf86eab25e2c613c16a9001655f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Thu, 14 Jan 2016 01:52:34 +0000 Subject: [PATCH 2/3] tests: avoid coredumps when determining memory limits * init.cfg (get_min_ulimit_v_): Refactor ulimit call to... (ulimit_supported_): ...here, and add calls to avoid coredumps. --- init.cfg | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/init.cfg b/init.cfg index e0ee1bc..630b49f 100644 --- a/init.cfg +++ b/init.cfg @@ -153,6 +153,23 @@ require_openat_support_() fi } +# Return true if command runs with the +# ulimit specified in the first argument +ulimit_supported_() +{ + local v + v="$1" + shift + + ( + # Try to disable core dumps which may + # occur with memory constraints + trap '' SEGV; ulimit -c 0; + + ulimit -v $v && "$@" + ) >/dev/null 2>&1 +} + # Determine the minimum required VM limit to run the given command. # Output that value to stdout ... to be used by the caller. # Return 0 in case of success, and a non-Zero value otherwise. @@ -166,11 +183,11 @@ get_min_ulimit_v_() page_size=$(($page_size / 1024)) for v in $( seq 5000 5000 50000 ); do - if ( ulimit -v $v && "$@" ) >/dev/null; then + if ulimit_supported_ $v "$@"; then local prev_v prev_v=$v for v in $( seq $(($prev_v-1000)) -1000 1000 ); do - ( ulimit -v $v && "$@" ) >/dev/null || \ + ulimit_supported $v "$@" || { ret_v=$((prev_v + $page_size)) echo $ret_v -- 2.5.0 From 1f40f6a34ef91c618f2c6ffd427696398f10a49f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Thu, 14 Jan 2016 02:18:58 +0000 Subject: [PATCH 3/3] tests: support older fallocate number formats * tests/cp/fiemap-extents.sh: Support RHEL6 fallocate which doesn't support IEC suffixes like "MiB" on numbers. Also add some extra framework_failure_ protections. Reported by Assaf Gordon. --- tests/cp/fiemap-extents.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/cp/fiemap-extents.sh b/tests/cp/fiemap-extents.sh index d44a741..672070e 100755 --- a/tests/cp/fiemap-extents.sh +++ b/tests/cp/fiemap-extents.sh @@ -21,14 +21,14 @@ print_ver_ cp require_sparse_support_ -touch fiemap_chk +touch fiemap_chk || framework_failure_ fiemap_capable_ fiemap_chk || skip_ 'this file system lacks FIEMAP support' rm fiemap_chk fallocate --help >/dev/null || skip_ 'The fallocate utility is required' touch falloc.test || framework_failure_ -fallocate -l 1 -o 0 -n falloc.test || +fallocate -l 1 -o 1 -n falloc.test || skip_ 'this file system lacks FALLOCATE support' rm falloc.test @@ -41,6 +41,9 @@ if false; then # which would cause failure of unrelated tests run in parallel. require_file_system_bytes_free_ 800000000 +fallocate -l 1MiB num.test || + skip_ "this fallocate doesn't support numbers with IEX suffixes" + fallocate -l 600MiB space.test || skip_ 'this test needs at least 600MiB free space' @@ -67,14 +70,14 @@ fi # Note the '-l 1' case is an effective noop, and just checks # a file with a trailing hole is copied correctly. for sparse_mode in always auto never; do - for alloc in '-l 4MiB ' '-l 1MiB -o 4MiB' '-l 1'; do + for alloc in '-l 4194304' '-l 1048576 -o 4194304' '-l 1'; do dd count=10 if=/dev/urandom iflag=fullblock of=unwritten.withdata truncate -s 2MiB unwritten.withdata || framework_failure_ fallocate $alloc -n unwritten.withdata || framework_failure_ cp --sparse=$sparse_mode unwritten.withdata cp.test || fail=1 test $(stat -c %s unwritten.withdata) = $(stat -c %s cp.test) || fail=1 cmp unwritten.withdata cp.test || fail=1 - rm unwritten.withdata cp.test + rm unwritten.withdata cp.test || framework_failure_ done done -- 2.5.0