svn commit: trunk/busybox: testsuite

landley at busybox.net landley at busybox.net
Fri Sep 2 00:41:55 UTC 2005


Author: landley
Date: 2005-09-01 17:41:53 -0700 (Thu, 01 Sep 2005)
New Revision: 11313

Log:
Working on a new test harness.  Moved the sort tests into it.


Added:
   trunk/busybox/testsuite/sort.tests
   trunk/busybox/testsuite/testing.sh

Modified:
   trunk/busybox/Makefile
   trunk/busybox/testsuite/runtest


Changeset:
Modified: trunk/busybox/Makefile
===================================================================
--- trunk/busybox/Makefile	2005-09-02 00:10:06 UTC (rev 11312)
+++ trunk/busybox/Makefile	2005-09-02 00:41:53 UTC (rev 11313)
@@ -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 {} \;

Modified: trunk/busybox/testsuite/runtest
===================================================================
--- trunk/busybox/testsuite/runtest	2005-09-02 00:10:06 UTC (rev 11312)
+++ trunk/busybox/testsuite/runtest	2005-09-02 00:41:53 UTC (rev 11313)
@@ -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

Added: trunk/busybox/testsuite/sort.tests
===================================================================
--- trunk/busybox/testsuite/sort.tests	2005-09-02 00:10:06 UTC (rev 11312)
+++ trunk/busybox/testsuite/sort.tests	2005-09-02 00:41:53 UTC (rev 11313)
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+# SUSv3 compliant sort tests.
+# Copyright 2005 by Rob Landley <rob at 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


Property changes on: trunk/busybox/testsuite/sort.tests
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/busybox/testsuite/testing.sh
===================================================================
--- trunk/busybox/testsuite/testing.sh	2005-09-02 00:10:06 UTC (rev 11312)
+++ trunk/busybox/testsuite/testing.sh	2005-09-02 00:41:53 UTC (rev 11313)
@@ -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
+}


Property changes on: trunk/busybox/testsuite/testing.sh
___________________________________________________________________
Name: svn:executable
   + *




More information about the busybox-cvs mailing list