Bump to version 1.22.1
[platform/upstream/busybox.git] / testsuite / sort.tests
index 1db7870..91b282e 100755 (executable)
@@ -1,10 +1,10 @@
-#!/bin/bash
+#!/bin/sh
 
 # SUSv3 compliant sort tests.
 # Copyright 2005 by Rob Landley <rob@landley.net>
-# Licensed under GPL v2, see file LICENSE for details.
+# Licensed under GPLv2, see file LICENSE in this source tree.
 
-. testing.sh
+. ./testing.sh
 
 # The basic tests.  These should work even with the small busybox.
 
@@ -27,6 +27,8 @@ egg   1       2       papyrus
 999    3       0       algebra
 "
 
+# testing "description" "command(s)" "result" "infile" "stdin"
+
 # Sorting with keys
 
 testing "sort one key" "sort -k4,4 input" \
@@ -45,8 +47,8 @@ egg   1       2       papyrus
 999    3       0       algebra
 " "$data" ""
 
-# Busybox is definitely doing this one wrong just now.  FIXME
-
+test x"$SKIP_KNOWN_BUGS" = x"" && {
+# Busybox is definitely doing these wrong.  FIXME
 testing "sort key range with numeric option and global reverse" \
 "sort -k2,3n -r input" \
 "egg   1       2       papyrus
@@ -56,8 +58,6 @@ testing "sort key range with numeric option and global reverse" \
 7      3       42      soup
 " "$data" ""
 
-#
-
 testing "sort key range with multiple options" "sort -k2,3rn input" \
 "7     3       42      soup
 999    3       0       algebra
@@ -65,6 +65,7 @@ testing "sort key range with multiple options" "sort -k2,3rn input" \
 42     1       3       woot
 egg    1       2       papyrus
 " "$data" ""
+}
 
 testing "sort key range with two -k options" "sort -k 2,2n -k 1,1r input" "\
 d 2
@@ -107,7 +108,24 @@ a c
 b c
 " ""
 
+testing "sort -z outputs NUL terminated lines" "sort -z input" "\
+one\0three\0two\0\
+" "\
+one\0two\0three\0\
+" ""
+
 testing "sort key doesn't strip leading blanks, disables fallback global sort" \
 "sort -n -k2 -t ' '" " a \n 1 \n 2 \n" "" " 2 \n 1 \n a \n"
 
+testing "sort file in place" \
+"sort -o input input && cat input" "\
+111
+222
+" "\
+222
+111
+" ""
+
+# testing "description" "command(s)" "result" "infile" "stdin"
+
 exit $FAILCOUNT