Working on a new test harness.  Moved the sort tests into it.
diff --git a/Makefile b/Makefile
index c96c737..d14aaf7 100644
--- a/Makefile
+++ b/Makefile
@@ -158,6 +158,7 @@
 	$(MAKE) top_srcdir=$(top_srcdir) top_builddir=$(top_builddir) \
 		-f $(top_srcdir)/Makefile STRIPCMD=/bin/true
 	nm --size-sort busybox
+
 # Documentation Targets
 doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
 
@@ -283,7 +284,7 @@
 	    docs/busybox pod2htm* *.gdb *.elf *~ core .*config.log \
 	    docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
 	    docs/busybox.net/BusyBox.html busybox.links libbb/loop.h \
-	    .config.old .hdepend busybox
+	    .config.old .hdepend busybox testsuite/links/*
 	- rm -rf _install
 	- find . -name .\*.flags -exec rm -f {} \;
 	- find . -name \*.o -exec rm -f {} \;
diff --git a/testsuite/runtest b/testsuite/runtest
index 6ba334b..91b7943 100755
--- a/testsuite/runtest
+++ b/testsuite/runtest
@@ -97,6 +97,16 @@
 			status=1
 		fi
 	fi
+
+	if [ -f "$applet".tests ]
+	then
+		rm -f links/"$applet"
+		ln -s ../../busybox links/"$applet"
+		PATH=links:$PATH ./"$applet".tests
+		if [ $? -ne 0 ]; then status=1; fi
+	fi
+
+
 done
 
 exit $status
diff --git a/testsuite/sort.tests b/testsuite/sort.tests
new file mode 100755
index 0000000..b23cf43
--- /dev/null
+++ b/testsuite/sort.tests
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+# SUSv3 compliant sort tests.
+# Copyright 2005 by Rob Landley <rob@landley.net>
+# Licensed under GPL v2, see file LICENSE for details.
+
+if [ ${#COMMAND} -eq 0 ]; then COMMAND=sort; fi
+. testing.sh
+
+# The basic tests.  These should work even with the small busybox.
+
+testing "sort" "input" "a\nb\nc\n" "c\na\nb\n" ""
+testing "sort #2" "input" "010\n1\n3\n" "3\n1\n010\n" ""
+testing "sort stdin" "" "a\nb\nc\n" "" "b\na\nc\n"
+testing "sort numeric" "-n input" "1\n3\n010\n" "3\n1\n010\n" ""
+testing "sort reverse" "-r input" "wook\nwalrus\npoint\npabst\naargh\n" \
+	"point\nwook\npabst\naargh\nwalrus\n" ""
+
+# These tests require the full option set.
+
+# Longish chunk of data re-used by the next few tests
+
+data="42	1	3	woot
+42	1	010	zoology
+egg	1	2	papyrus
+7	3	42	soup
+999	3	0	algebra
+"
+
+# Sorting with keys
+
+testing "sort one key" "-k4,4 input" \
+"999	3	0	algebra
+egg	1	2	papyrus
+7	3	42	soup
+42	1	3	woot
+42	1	010	zoology
+" "$data" ""
+
+testing "sort key range with numeric option" "-k2,3n input" \
+"42	1	010	zoology
+42	1	3	woot
+egg	1	2	papyrus
+7	3	42	soup
+999	3	0	algebra
+" "$data" ""
+
+# Busybox is definitely doing this one wrong just now...
+
+testing "sort key range with numeric option and global reverse" \
+"-k2,3n -r input" \
+"egg	1	2	papyrus
+42	1	3	woot
+42	1	010	zoology
+999	3	0	algebra
+7	3	42	soup
+" "$data" ""
+
+# 
+
+testing "sort key range with multiple options" "-k2,3rn input" \
+"7	3	42	soup
+999	3	0	algebra
+42	1	010	zoology
+42	1	3	woot
+egg	1	2	papyrus
+" "$data" ""
+
+exit $FAILCOUNT
diff --git a/testsuite/testing.sh b/testsuite/testing.sh
new file mode 100755
index 0000000..d516f72
--- /dev/null
+++ b/testsuite/testing.sh
@@ -0,0 +1,62 @@
+# Simple test harness infrastructurei for BusyBox
+#
+# Copyright 2005 by Rob Landley
+#
+# License is GPLv2, see LICENSE in the busybox tarball for full license text.
+
+# The "testing" function uses one environment variable:
+#	COMMAND = command to execute
+#
+# The function takes five arguments:
+#	$1) Description to display when running command
+#	$2) Command line arguments to command"
+#	$3) Expected result (on stdout)"
+#	$4) Data written to file "input"
+#	$5) Data written to stdin
+#
+# The exit value of testing is the exit value of the command it ran.
+#
+# The environment variable "FAILCOUNT" contains a cumulative total of the
+# 
+
+# The command line parsing is ugly and should be improved.
+
+if [ "$1" == "-v" ]
+then
+  verbose=1
+fi
+
+export FAILCOUNT=0
+
+# The testing function
+
+function testing()
+{
+  if [ $# -ne 5 ]
+  then
+    echo "Test $1 has the wrong number of arguments" >&2
+    exit
+  fi
+
+  f=$FAILCOUNT
+  echo -ne "$3" > expected
+  echo -ne "$4" > input
+  echo -n -e "$5" | eval "$COMMAND $2" > actual
+  RETVAL=$?
+
+  cmp expected actual > /dev/null
+  if [ $? -ne 0 ]
+  then
+	FAILCOUNT=$[$FAILCOUNT+1]
+	echo FAIL:"$1"
+	if [ $verbose ]
+	then
+		diff -u expected actual
+	fi
+  else
+	echo PASS:"$1"
+  fi
+  rm -f input expected actual
+
+  return $RETVAL
+}