[Midnightbsd-cvs] src [11327] trunk/usr.bin/tests: add tests

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Wed Jul 4 20:54:35 EDT 2018


Revision: 11327
          http://svnweb.midnightbsd.org/src/?rev=11327
Author:   laffer1
Date:     2018-07-04 20:54:34 -0400 (Wed, 04 Jul 2018)
Log Message:
-----------
add tests

Added Paths:
-----------
    trunk/usr.bin/tests/
    trunk/usr.bin/tests/Makefile
    trunk/usr.bin/tests/regress.m4

Added: trunk/usr.bin/tests/Makefile
===================================================================
--- trunk/usr.bin/tests/Makefile	                        (rev 0)
+++ trunk/usr.bin/tests/Makefile	2018-07-05 00:54:34 UTC (rev 11327)
@@ -0,0 +1,12 @@
+# $MidnightBSD$
+# $FreeBSD: stable/10/usr.bin/tests/Makefile 313488 2017-02-09 22:49:48Z ngie $
+
+.include <bsd.own.mk>
+
+.PATH:		${SRCTOP}/tests
+KYUAFILE=	yes
+
+FILESDIR=	${TESTSDIR}
+FILES=		regress.m4
+
+.include <bsd.test.mk>


Property changes on: trunk/usr.bin/tests/Makefile
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/usr.bin/tests/regress.m4
===================================================================
--- trunk/usr.bin/tests/regress.m4	                        (rev 0)
+++ trunk/usr.bin/tests/regress.m4	2018-07-05 00:54:34 UTC (rev 11327)
@@ -0,0 +1,60 @@
+# $MidnightBSD$
+# $FreeBSD: stable/10/usr.bin/tests/regress.m4 264996 2014-04-27 01:15:10Z jmmv $
+
+dnl A library of routines for doing regression tests for userland utilities.
+
+dnl Start up.  We initialise the exit status to 0 (no failure) and change
+dnl into the directory specified by our first argument, which is the
+dnl directory to run the tests inside.
+define(`REGRESSION_START',
+TESTDIR=$1
+if [ -z "$TESTDIR" ]; then
+  TESTDIR=.
+fi
+cd $TESTDIR
+
+STATUS=0)
+
+dnl Check $? to see if we passed or failed.  The first parameter is the test
+dnl which passed or failed.  It may be nil.
+define(`REGRESSION_PASSFAIL',
+if [ $? -eq 0 ]; then
+  echo "ok - $1 # Test detected no regression. (in $TESTDIR)"
+else
+  STATUS=$?
+  echo "not ok - $1 # Test failed: regression detected.  See above. (in $TESTDIR)"
+fi)
+
+dnl An actual test.  The first parameter is the test name.  The second is the
+dnl command/commands to execute for the actual test.  Their exit status is
+dnl checked.  It is assumed that the test will output to stdout, and that the
+dnl output to be used to check for regression will be in regress.TESTNAME.out.
+define(`REGRESSION_TEST',
+$2 | diff -u ${SRCDIR:-.}/regress.$1.out -
+REGRESSION_PASSFAIL($1))
+
+dnl A freeform regression test.  Only exit status is checked.
+define(`REGRESSION_TEST_FREEFORM',
+$2
+REGRESSION_PASSFAIL($1))
+
+dnl A regression test like REGRESSION_TEST, except only regress.out is used
+dnl for checking output differences.  The first argument is the command, the
+dnl second argument (which may be empty) is the test name.
+define(`REGRESSION_TEST_ONE',
+$1 | diff -u ${SRCDIR:-.}/regress.out -
+REGRESSION_PASSFAIL($2))
+
+dnl A fatal error.  This will exit with the given status (first argument) and
+dnl print the message (second argument) prefixed with the string "FATAL :" to
+dnl the error stream.
+define(`REGRESSION_FATAL',
+echo "Bail out! $2 (in $TESTDIR)" > /dev/stderr
+exit $1)
+
+dnl Cleanup.  Exit with the status code of the last failure.  Should probably
+dnl be the number of failed tests, but hey presto, this is what it does.  This
+dnl could also clean up potential droppings, if some forms of regression tests
+dnl end up using mktemp(1) or such.
+define(`REGRESSION_END',
+exit $STATUS)


Property changes on: trunk/usr.bin/tests/regress.m4
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property


More information about the Midnightbsd-cvs mailing list