chown: add a test

Add a test for the chown utility. This sets up chown(8) to be capable of being
tested.  As such, only add one test for now as an example.
This commit is contained in:
Eitan Adler 2014-06-30 05:33:52 +00:00
parent 7063e348ab
commit 4bfdbb0b56
4 changed files with 38 additions and 0 deletions

View file

@ -21,6 +21,8 @@
..
tests
bin
chown
..
date
..
mv

View file

@ -1,8 +1,14 @@
# @(#)Makefile 8.1 (Berkeley) 6/6/93
# $FreeBSD$
.include <src.opts.mk>
PROG= chown
LINKS= ${BINDIR}/chown /usr/bin/chgrp
MAN= chgrp.1 chown.8
.if ${MK_TESTS} != "no"
SUBDIR+= tests
.endif
.include <bsd.prog.mk>

View file

@ -0,0 +1,9 @@
# $FreeBSD$
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/bin/chown
TAP_TESTS_SH= chown-f_test
.include <bsd.test.mk>

View file

@ -0,0 +1,21 @@
#!/bin/sh
# $FreeBSD$
base=`basename $0`
echo "1..1"
name="chown -f root:wheel file"
if [ `id -u` -eq 0 ]; then
echo "ok 3 - $name # skip Test must not be uid 0."
else
touch file
output=$(chown -f root:wheel file 2>&1)
if [ $? -eq 0 -a -z "$output" ]
then
echo "ok 1 - $name"
else
echo "not ok 1 - $name"
fi
rm file
fi