summaryrefslogtreecommitdiff
path: root/tests/misc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/misc')
-rwxr-xr-xtests/misc/sort2
-rwxr-xr-xtests/misc/sort-exit-early36
-rwxr-xr-xtests/misc/sort-merge-fdlimit2
3 files changed, 38 insertions, 2 deletions
diff --git a/tests/misc/sort b/tests/misc/sort
index 5be00a017..5d15d7572 100755
--- a/tests/misc/sort
+++ b/tests/misc/sort
@@ -33,7 +33,7 @@ my $mb_locale = $ENV{LOCALE_FR_UTF8};
# Normalize each diagnostic to use '-'.
my $normalize_filename = {ERR_SUBST => 's/^$prog: .*?:/$prog: -:/'};
-my $no_file = "$prog: open failed: no-file: No such file or directory\n";
+my $no_file = "$prog: cannot read: no-file: No such file or directory\n";
my @Tests =
(
diff --git a/tests/misc/sort-exit-early b/tests/misc/sort-exit-early
new file mode 100755
index 000000000..7470aad52
--- /dev/null
+++ b/tests/misc/sort-exit-early
@@ -0,0 +1,36 @@
+#!/bin/sh
+# Test 'sort' exits early on inaccessible inputs or output
+
+# Copyright (C) 2012 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+print_ver_ sort
+
+# Check output is writable before starting to sort
+touch input
+chmod a-w input
+timeout 10 sort -o input && fail=1
+test $? = 124 && fail=1
+
+# Check all inputs are readable before starting to sort
+# Also ensure the output isn't created in this case
+touch output
+chmod a-r output
+timeout 10 sort -o typo - output && fail=1
+test $? = 124 && fail=1
+test -e typo && fail=1
+
+Exit $fail
diff --git a/tests/misc/sort-merge-fdlimit b/tests/misc/sort-merge-fdlimit
index 7ce109c1a..ee1575aed 100755
--- a/tests/misc/sort-merge-fdlimit
+++ b/tests/misc/sort-merge-fdlimit
@@ -65,7 +65,7 @@ done
(seq 6 && echo 6) >exp || fail=1
echo 6 >out || fail=1
(exec 3<&- 4<&- 5<&- 6</dev/null 7<&6 8<&6 9<&6 &&
- ulimit -n 10 &&
+ ulimit -n 11 &&
sort -n -m --batch-size=7 -o out out in/1 in/2 in/3 in/4 in/5 out
) &&
compare exp out || fail=1