summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreadler <eadler@FreeBSD.org>2014-07-17 07:12:12 +0000
committereadler <eadler@FreeBSD.org>2014-07-17 07:12:12 +0000
commit3c336ca4fd74679f5f9e087024a2fca34d4ce63b (patch)
tree41ddc5f3b600b892e28e2760693f35501b6f77f4
parente3ad0e803199c167a2d9d9857a8113a51a463ee4 (diff)
downloadFreeBSD-src-3c336ca4fd74679f5f9e087024a2fca34d4ce63b.zip
FreeBSD-src-3c336ca4fd74679f5f9e087024a2fca34d4ce63b.tar.gz
units(1): Add basic tests
Add some tests to help avoid breaking units
-rw-r--r--etc/mtree/BSD.tests.dist2
-rw-r--r--usr.bin/units/Makefile6
-rw-r--r--usr.bin/units/tests/Makefile9
-rwxr-xr-xusr.bin/units/tests/units_basics.sh22
4 files changed, 39 insertions, 0 deletions
diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist
index 5c54598..614a684 100644
--- a/etc/mtree/BSD.tests.dist
+++ b/etc/mtree/BSD.tests.dist
@@ -256,6 +256,8 @@
tr
..
truncate
+ ..
+ units
..
uudecode
..
diff --git a/usr.bin/units/Makefile b/usr.bin/units/Makefile
index ebd1e07..3abbd3f 100644
--- a/usr.bin/units/Makefile
+++ b/usr.bin/units/Makefile
@@ -1,5 +1,7 @@
# $FreeBSD$
+.include <src.opts.mk>
+
PROG= units
FILES= units.lib
FILESDIR= ${SHAREDIR}/misc
@@ -7,4 +9,8 @@ FILESDIR= ${SHAREDIR}/misc
LDADD+=-ledit -ltermcap
DPADD+=${LIBEDIT} ${LIBTERMCAP}
+.if ${MK_TESTS} != "no"
+SUBDIR+= tests
+.endif
+
.include <bsd.prog.mk>
diff --git a/usr.bin/units/tests/Makefile b/usr.bin/units/tests/Makefile
new file mode 100644
index 0000000..887af6c
--- /dev/null
+++ b/usr.bin/units/tests/Makefile
@@ -0,0 +1,9 @@
+# $FreeBSD$
+
+.include <bsd.own.mk>
+
+TESTSDIR= ${TESTSBASE}/bin/chown
+
+TAP_TESTS_SH= units_basics
+
+.include <bsd.test.mk>
diff --git a/usr.bin/units/tests/units_basics.sh b/usr.bin/units/tests/units_basics.sh
new file mode 100755
index 0000000..adc28e0
--- /dev/null
+++ b/usr.bin/units/tests/units_basics.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+# $FreeBSD$
+
+base=`basename $0`
+
+echo "1..3"
+
+assert_equals() {
+ testnum="$1"
+ expected="$2"
+ fn="$3"
+ if [ "$expected" = "$($fn)" ]
+ then
+ echo "ok $testnum - $fn"
+ else
+ echo "not ok $testnum - $fn"
+ fi
+}
+
+assert_equals 1 1 "units -t ft ft"
+assert_equals 2 12 "units -t ft in"
+assert_equals 3 0.083333333 "units -t in ft"
OpenPOWER on IntegriCloud