diff options
author | jmmv <jmmv@FreeBSD.org> | 2014-04-27 01:15:10 +0000 |
---|---|---|
committer | jmmv <jmmv@FreeBSD.org> | 2014-04-27 01:15:10 +0000 |
commit | 1e4589b921fdaa1b1d2fc6b6ed016f1e0a01cb8f (patch) | |
tree | 94c86cf13dedabad5bdc68f6f227b843a5161343 /bin | |
parent | 5b12da65bf9d40526ac9ca480d639bad3cd39cf6 (diff) | |
download | FreeBSD-src-1e4589b921fdaa1b1d2fc6b6ed016f1e0a01cb8f.zip FreeBSD-src-1e4589b921fdaa1b1d2fc6b6ed016f1e0a01cb8f.tar.gz |
MFC various moves of tools/regressions/ tests to the new infrastructure.
- r263220 Migrate tools/regression/sbin/ to the new tests layout.
- r263222 Add Makefile missed in r263220.
- r263226 Migrate tools/regression/{usr.bin/lastcomm,usr.sbin}/ to the new tests layout.
- r263227 Migrate most of tools/regression/usr.bin/ to the new tests layout.
- r263345 Expand tabs that sneaked in into spaces.
- r263346 Migrate tools/regression/usr.bin/make/ to the new tests layout.
- r263348 Add Makefiles missed in r263346.
- r263351 Migrate tools/regression/usr.bin/pkill/ to the new tests layout.
- r263388 Mark multi_test as requiring /usr/share/dict/words.
- r263814 Fix path to the run.pl script to let these tests run.
- r264742 Prevent building tests when bootstrapping make.
This is 'make tinderbox' clean.
Diffstat (limited to 'bin')
30 files changed, 1053 insertions, 0 deletions
diff --git a/bin/pkill/Makefile b/bin/pkill/Makefile index e98ed2c..bb4d865 100644 --- a/bin/pkill/Makefile +++ b/bin/pkill/Makefile @@ -1,6 +1,8 @@ # $NetBSD: Makefile,v 1.1 2002/03/01 11:21:58 ad Exp $ # $FreeBSD$ +.include <bsd.own.mk> + PROG= pkill DPADD= ${LIBKVM} @@ -17,4 +19,8 @@ MLINKS= pkill.1 pgrep.1 SYMLINKS= ${BINDIR}/pkill /usr/bin/pkill SYMLINKS+= ${BINDIR}/pgrep /usr/bin/pgrep +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif + .include <bsd.prog.mk> diff --git a/bin/pkill/tests/Makefile b/bin/pkill/tests/Makefile new file mode 100644 index 0000000..b131d59 --- /dev/null +++ b/bin/pkill/tests/Makefile @@ -0,0 +1,38 @@ +# $FreeBSD$ + +.include <bsd.own.mk> + +TESTSDIR= ${TESTSBASE}/bin/pkill + +TAP_TESTS_SH= pgrep-F_test +TAP_TESTS_SH+= pgrep-LF_test +TAP_TESTS_SH+= pgrep-P_test +TAP_TESTS_SH+= pgrep-U_test +TAP_TESTS_SH+= pgrep-_g_test +TAP_TESTS_SH+= pgrep-_s_test +TAP_TESTS_SH+= pgrep-g_test +TAP_TESTS_SH+= pgrep-i_test +TAP_TESTS_SH+= pgrep-j_test +TEST_METADATA.pgrep-j_test+= required_user="root" +TAP_TESTS_SH+= pgrep-l_test +TAP_TESTS_SH+= pgrep-n_test +TAP_TESTS_SH+= pgrep-o_test +TAP_TESTS_SH+= pgrep-q_test +TAP_TESTS_SH+= pgrep-s_test +TAP_TESTS_SH+= pgrep-t_test +TAP_TESTS_SH+= pgrep-v_test +TAP_TESTS_SH+= pgrep-x_test +TAP_TESTS_SH+= pkill-F_test +TAP_TESTS_SH+= pkill-LF_test +TAP_TESTS_SH+= pkill-P_test +TAP_TESTS_SH+= pkill-U_test +TAP_TESTS_SH+= pkill-_g_test +TAP_TESTS_SH+= pkill-g_test +TAP_TESTS_SH+= pkill-i_test +TAP_TESTS_SH+= pkill-j_test +TEST_METADATA.pkill-j_test+= required_user="root" +TAP_TESTS_SH+= pkill-s_test +TAP_TESTS_SH+= pkill-t_test +TAP_TESTS_SH+= pkill-x_test + +.include <bsd.test.mk> diff --git a/bin/pkill/tests/pgrep-F_test.sh b/bin/pkill/tests/pgrep-F_test.sh new file mode 100644 index 0000000..4d8feaa --- /dev/null +++ b/bin/pkill/tests/pgrep-F_test.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..1" + +name="pgrep -F <pidfile>" +pidfile=$(pwd)/pidfile.txt +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +chpid=$! +echo $chpid > $pidfile +pid=`pgrep -f -F $pidfile $sleep` +if [ "$pid" = "$chpid" ]; then + echo "ok - $name" +else + echo "not ok - $name" +fi +kill "$chpid" +rm -f $pidfile +rm -f $sleep diff --git a/bin/pkill/tests/pgrep-LF_test.sh b/bin/pkill/tests/pgrep-LF_test.sh new file mode 100644 index 0000000..4818869 --- /dev/null +++ b/bin/pkill/tests/pgrep-LF_test.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..2" + +name="pgrep -LF <pidfile>" +pidfile=$(pwd)/pidfile.txt +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +daemon -p $pidfile $sleep 5 +sleep 0.3 +chpid=`cat $pidfile` +pid=`pgrep -f -L -F $pidfile $sleep` +if [ "$pid" = "$chpid" ]; then + echo "ok 1 - $name" +else + echo "not ok 1 - $name" +fi +kill "$chpid" + +# Be sure we cannot find process which pidfile is not locked. +$sleep 5 & +sleep 0.3 +chpid=$! +echo $chpid > $pidfile +pgrep -f -L -F $pidfile $sleep 2>/dev/null +ec=$? +case $ec in +0) + echo "not ok 2 - $name" + ;; +*) + echo "ok 2 - $name" + ;; +esac + +kill "$chpid" +rm -f $pidfile +rm -f $sleep diff --git a/bin/pkill/tests/pgrep-P_test.sh b/bin/pkill/tests/pgrep-P_test.sh new file mode 100644 index 0000000..5a5cdcf --- /dev/null +++ b/bin/pkill/tests/pgrep-P_test.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..1" + +name="pgrep -P <ppid>" +ppid=$$ +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +chpid=$! +pid=`pgrep -f -P $ppid $sleep` +if [ "$pid" = "$chpid" ]; then + echo "ok - $name" +else + echo "not ok - $name" +fi +kill $chpid +rm -f $sleep diff --git a/bin/pkill/tests/pgrep-U_test.sh b/bin/pkill/tests/pgrep-U_test.sh new file mode 100644 index 0000000..2e7f24d --- /dev/null +++ b/bin/pkill/tests/pgrep-U_test.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..2" + +name="pgrep -U <uid>" +ruid=`id -ur` +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +chpid=$! +pid=`pgrep -f -U $ruid $sleep` +if [ "$pid" = "$chpid" ]; then + echo "ok 1 - $name" +else + echo "not ok 1 - $name" +fi +kill $chpid +rm -f $sleep + +name="pgrep -U <user>" +ruid=`id -urn` +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +chpid=$! +pid=`pgrep -f -U $ruid $sleep` +if [ "$pid" = "$chpid" ]; then + echo "ok 2 - $name" +else + echo "not ok 2 - $name" +fi +kill $chpid +rm -f $sleep diff --git a/bin/pkill/tests/pgrep-_g_test.sh b/bin/pkill/tests/pgrep-_g_test.sh new file mode 100644 index 0000000..fbe7b08 --- /dev/null +++ b/bin/pkill/tests/pgrep-_g_test.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..2" + +name="pgrep -G <gid>" +rgid=`id -gr` +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +chpid=$! +pid=`pgrep -f -G $rgid $sleep` +if [ "$pid" = "$chpid" ]; then + echo "ok 1 - $name" +else + echo "not ok 1 - $name" +fi +kill $chpid +rm -f $sleep + +name="pgrep -G <group>" +rgid=`id -grn` +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +chpid=$! +pid=`pgrep -f -G $rgid $sleep` +if [ "$pid" = "$chpid" ]; then + echo "ok 2 - $name" +else + echo "not ok 2 - $name" +fi +kill $chpid +rm -f $sleep diff --git a/bin/pkill/tests/pgrep-_s_test.sh b/bin/pkill/tests/pgrep-_s_test.sh new file mode 100644 index 0000000..ce0bde3 --- /dev/null +++ b/bin/pkill/tests/pgrep-_s_test.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..2" + +exp_pid="$(ps ax | grep '\[idle\]' | awk '{print $1}')" + +name="pgrep -S" +pid=`pgrep -Sx idle` +if [ "$pid" = "$exp_pid" ]; then + echo "ok 1 - $name" +else + echo "not ok 1 - $name" +fi +pid=`pgrep -x idle` +if [ "$pid" != "$exp_pid" ]; then + echo "ok 2 - $name" +else + echo "not ok 2 - $name" +fi diff --git a/bin/pkill/tests/pgrep-g_test.sh b/bin/pkill/tests/pgrep-g_test.sh new file mode 100644 index 0000000..1414908 --- /dev/null +++ b/bin/pkill/tests/pgrep-g_test.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..2" + +name="pgrep -g <pgrp>" +pgrp=`ps -o tpgid -p $$ | tail -1` +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +chpid=$! +pid=`pgrep -f -g $pgrp $sleep` +if [ "$pid" = "$chpid" ]; then + echo "ok 1 - $name" +else + echo "not ok 1 - $name" +fi +kill $chpid +rm -f $sleep + +name="pgrep -g 0" +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +chpid=$! +pid=`pgrep -f -g 0 $sleep` +if [ "$pid" = "$chpid" ]; then + echo "ok 2 - $name" +else + echo "not ok 2 - $name" +fi +kill $chpid +rm -f $sleep diff --git a/bin/pkill/tests/pgrep-i_test.sh b/bin/pkill/tests/pgrep-i_test.sh new file mode 100644 index 0000000..b9ecfbc --- /dev/null +++ b/bin/pkill/tests/pgrep-i_test.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..1" + +name="pgrep -i" +sleep=$(pwd)/sleep.txt +usleep="${sleep}XXX" +touch $usleep +lsleep="${sleep}xxx" +ln -sf /bin/sleep $usleep +$usleep 5 & +sleep 0.3 +chpid=$! +pid=`pgrep -f -i $lsleep` +if [ "$pid" = "$chpid" ]; then + echo "ok - $name" +else + echo "not ok - $name" +fi +kill $chpid +rm -f $sleep $usleep diff --git a/bin/pkill/tests/pgrep-j_test.sh b/bin/pkill/tests/pgrep-j_test.sh new file mode 100644 index 0000000..6656a9b --- /dev/null +++ b/bin/pkill/tests/pgrep-j_test.sh @@ -0,0 +1,75 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..3" + +name="pgrep -j <jid>" +if [ `id -u` -eq 0 ]; then + sleep=$(pwd)/sleep.txt + ln -sf /bin/sleep $sleep + jail / $base-1 127.0.0.1 $sleep 5 & + chpid=$! + jail / $base-2 127.0.0.1 $sleep 5 & + chpid2=$! + $sleep 5 & + chpid3=$! + sleep 0.5 + jid=`jls | awk "/127\\.0\\.0\\.1.*${base}-1/ {print \$1}"` + pid=`pgrep -f -j $jid $sleep` + if [ "$pid" = "$chpid" ]; then + echo "ok 1 - $name" + else + echo "not ok 1 - $name" + fi + kill $chpid $chpid2 $chpid3 + rm -f $sleep +else + echo "ok 1 - $name # skip Test needs uid 0." +fi + +name="pgrep -j any" +if [ `id -u` -eq 0 ]; then + sleep=$(pwd)/sleep.txt + ln -sf /bin/sleep $sleep + jail / $base-1 127.0.0.1 $sleep 5 & + chpid=$! + jail / $base-2 127.0.0.1 $sleep 5 & + chpid2=$! + $sleep 5 & + chpid3=$! + sleep 0.5 + pids=`pgrep -f -j any $sleep | sort` + refpids=`{ echo $chpid; echo $chpid2; } | sort` + if [ "$pids" = "$refpids" ]; then + echo "ok 2 - $name" + else + echo "not ok 2 - $name" + fi + kill $chpid $chpid2 $chpid3 + rm -f $sleep +else + echo "ok 2 - $name # skip Test needs uid 0." +fi + +name="pgrep -j none" +if [ `id -u` -eq 0 ]; then + sleep=$(pwd)/sleep.txt + ln -sf /bin/sleep $sleep + $sleep 5 & + chpid=$! + jail / $base 127.0.0.1 $sleep 5 & + chpid2=$! + sleep 0.5 + pid=`pgrep -f -j none $sleep` + if [ "$pid" = "$chpid" ]; then + echo "ok 3 - $name" + else + echo "not ok 3 - $name" + fi + kill $chpid $chpid2 + rm -f $sleep +else + echo "ok 3 - $name # skip Test needs uid 0." +fi diff --git a/bin/pkill/tests/pgrep-l_test.sh b/bin/pkill/tests/pgrep-l_test.sh new file mode 100644 index 0000000..49273b3 --- /dev/null +++ b/bin/pkill/tests/pgrep-l_test.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..1" + +name="pgrep -l" +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +pid=$! +if [ "$pid $sleep 5" = "`pgrep -f -l $sleep`" ]; then + echo "ok - $name" +else + echo "not ok - $name" +fi +kill $pid +rm -f $sleep diff --git a/bin/pkill/tests/pgrep-n_test.sh b/bin/pkill/tests/pgrep-n_test.sh new file mode 100644 index 0000000..1b6fe83 --- /dev/null +++ b/bin/pkill/tests/pgrep-n_test.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..1" + +name="pgrep -n" +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +oldpid=$! +$sleep 5 & +sleep 0.3 +newpid=$! +pid=`pgrep -f -n $sleep` +if [ "$pid" = "$newpid" ]; then + echo "ok - $name" +else + echo "not ok - $name" +fi +kill $oldpid +kill $newpid +rm -f $sleep diff --git a/bin/pkill/tests/pgrep-o_test.sh b/bin/pkill/tests/pgrep-o_test.sh new file mode 100644 index 0000000..250f230 --- /dev/null +++ b/bin/pkill/tests/pgrep-o_test.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..1" + +name="pgrep -o" +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +oldpid=$! +$sleep 5 & +sleep 0.3 +newpid=$! +pid=`pgrep -f -o $sleep` +if [ "$pid" = "$oldpid" ]; then + echo "ok - $name" +else + echo "not ok - $name" +fi +kill $oldpid +kill $newpid +rm -f $sleep diff --git a/bin/pkill/tests/pgrep-q_test.sh b/bin/pkill/tests/pgrep-q_test.sh new file mode 100644 index 0000000..2626a5e --- /dev/null +++ b/bin/pkill/tests/pgrep-q_test.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..4" + +name="pgrep -q" +sleep0=$(pwd)/sleep0.txt +sleep1=$(pwd)/sleep1.txt +ln -sf /bin/sleep $sleep0 +$sleep0 5 & +sleep 0.3 +pid=$! +out="`pgrep -q -f $sleep0 2>&1`" +if [ $? -eq 0 ]; then + echo "ok 1 - $name" +else + echo "not ok 1 - $name" +fi +if [ -z "${out}" ]; then + echo "ok 2 - $name" +else + echo "not ok 2 - $name" +fi +out="`pgrep -q -f $sleep1 2>&1`" +if [ $? -ne 0 ]; then + echo "ok 3 - $name" +else + echo "not ok 3 - $name" +fi +if [ -z "${out}" ]; then + echo "ok 4 - $name" +else + echo "not ok 4 - $name" +fi +kill $pid +rm -f $sleep0 $sleep1 diff --git a/bin/pkill/tests/pgrep-s_test.sh b/bin/pkill/tests/pgrep-s_test.sh new file mode 100644 index 0000000..82c1ef9 --- /dev/null +++ b/bin/pkill/tests/pgrep-s_test.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..2" + +name="pgrep -s <sid>" +sid=`ps -o tsid -p $$ | tail -1` +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +chpid=$! +pid=`pgrep -f -s $sid $sleep` +if [ "$pid" = "$chpid" ]; then + echo "ok 1 - $name" +else + echo "not ok 1 - $name" +fi +kill $chpid +rm -f $sleep + +name="pgrep -s 0" +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +chpid=$! +pid=`pgrep -f -s 0 $sleep` +if [ "$pid" = "$chpid" ]; then + echo "ok 2 - $name" +else + echo "not ok 2 - $name" +fi +kill $chpid +rm -f $sleep diff --git a/bin/pkill/tests/pgrep-t_test.sh b/bin/pkill/tests/pgrep-t_test.sh new file mode 100644 index 0000000..a8527d5 --- /dev/null +++ b/bin/pkill/tests/pgrep-t_test.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..2" + +name="pgrep -t <tty>" +tty=`ps -x -o tty -p $$ | tail -1` +if [ "$tty" = "??" -o "$tty" = "-" ]; then + tty="-" + ttyshort="-" +else + case $tty in + pts/*) ttyshort=`echo $tty | cut -c 5-` ;; + *) ttyshort=`echo $tty | cut -c 4-` ;; + esac +fi +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +chpid=$! +pid=`pgrep -f -t $tty $sleep` +if [ "$pid" = "$chpid" ]; then + echo "ok 1 - $name" +else + echo "not ok 1 - $name" +fi +pid=`pgrep -f -t $ttyshort $sleep` +if [ "$pid" = "$chpid" ]; then + echo "ok 2 - $name" +else + echo "not ok 2 - $name" +fi +kill $chpid +rm -f $sleep diff --git a/bin/pkill/tests/pgrep-v_test.sh b/bin/pkill/tests/pgrep-v_test.sh new file mode 100644 index 0000000..b9835bc --- /dev/null +++ b/bin/pkill/tests/pgrep-v_test.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..2" + +name="pgrep -v" +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +pid=$! +if [ -z "`pgrep -f -v $sleep | egrep '^'"$pid"'$'`" ]; then + echo "ok 1 - $name" +else + echo "not ok 1 - $name" +fi +if [ ! -z "`pgrep -f -v -x x | egrep '^'"$pid"'$'`" ]; then + echo "ok 2 - $name" +else + echo "not ok 2 - $name" +fi +kill $pid +rm -f $sleep diff --git a/bin/pkill/tests/pgrep-x_test.sh b/bin/pkill/tests/pgrep-x_test.sh new file mode 100644 index 0000000..1defde2 --- /dev/null +++ b/bin/pkill/tests/pgrep-x_test.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..4" + +name="pgrep -x" +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +pid=$! +if [ ! -z "`pgrep -x sleep | egrep '^'"$pid"'$'`" ]; then + echo "ok 1 - $name" +else + echo "not ok 1 - $name" +fi +if [ -z "`pgrep -x slee | egrep '^'"$pid"'$'`" ]; then + echo "ok 2 - $name" +else + echo "not ok 2 - $name" +fi +name="pgrep -x -f" +if [ ! -z "`pgrep -x -f ''"$sleep"' 5' | egrep '^'"$pid"'$'`" ]; then + echo "ok 3 - $name" +else + echo "not ok 3 - $name" +fi +if [ -z "`pgrep -x -f ''"$sleep"' ' | egrep '^'"$pid"'$'`" ]; then + echo "ok 4 - $name" +else + echo "not ok 4 - $name" +fi +kill $pid +rm -f $sleep diff --git a/bin/pkill/tests/pkill-F_test.sh b/bin/pkill/tests/pkill-F_test.sh new file mode 100644 index 0000000..48ad474 --- /dev/null +++ b/bin/pkill/tests/pkill-F_test.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..1" + +name="pkill -F <pidfile>" +pidfile=$(pwd)/pidfile.txt +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +echo $! > $pidfile +pkill -f -F $pidfile $sleep +ec=$? +case $ec in +0) + echo "ok - $name" + ;; +*) + echo "not ok - $name" + ;; +esac + +rm -f $pidfile +rm -f $sleep diff --git a/bin/pkill/tests/pkill-LF_test.sh b/bin/pkill/tests/pkill-LF_test.sh new file mode 100644 index 0000000..fcafd0a --- /dev/null +++ b/bin/pkill/tests/pkill-LF_test.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..2" + +name="pkill -LF <pidfile>" +pidfile=$(pwd)/pidfile.txt +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +daemon -p $pidfile $sleep 5 +sleep 0.3 +pkill -f -L -F $pidfile $sleep +ec=$? +case $ec in +0) + echo "ok 1 - $name" + ;; +*) + echo "not ok 1 - $name" + ;; +esac + +# Be sure we cannot kill process which pidfile is not locked. +$sleep 5 & +sleep 0.3 +chpid=$! +echo $chpid > $pidfile +pkill -f -L -F $pidfile $sleep 2>/dev/null +ec=$? +case $ec in +0) + echo "not ok 2 - $name" + ;; +*) + echo "ok 2 - $name" + ;; +esac + +kill "$chpid" +rm -f $pidfile +rm -f $sleep diff --git a/bin/pkill/tests/pkill-P_test.sh b/bin/pkill/tests/pkill-P_test.sh new file mode 100644 index 0000000..2030710 --- /dev/null +++ b/bin/pkill/tests/pkill-P_test.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..1" + +name="pkill -P <ppid>" +ppid=$$ +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +pkill -f -P $ppid $sleep +ec=$? +case $ec in +0) + echo "ok - $name" + ;; +*) + echo "not ok - $name" + ;; +esac + +rm -f $sleep diff --git a/bin/pkill/tests/pkill-U_test.sh b/bin/pkill/tests/pkill-U_test.sh new file mode 100644 index 0000000..04395e5 --- /dev/null +++ b/bin/pkill/tests/pkill-U_test.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..2" + +name="pkill -U <uid>" +ruid=`id -ur` +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +pkill -f -U $ruid $sleep +ec=$? +case $ec in +0) + echo "ok 1 - $name" + ;; +*) + echo "not ok 1 - $name" + ;; +esac +rm -f $sleep + +name="pkill -U <user>" +ruid=`id -urn` +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +pkill -f -U $ruid $sleep +ec=$? +case $ec in +0) + echo "ok 2 - $name" + ;; +*) + echo "not ok 2 - $name" + ;; +esac +rm -f $sleep diff --git a/bin/pkill/tests/pkill-_g_test.sh b/bin/pkill/tests/pkill-_g_test.sh new file mode 100644 index 0000000..1739ac8 --- /dev/null +++ b/bin/pkill/tests/pkill-_g_test.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..2" + +name="pkill -G <gid>" +rgid=`id -gr` +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +pkill -f -G $rgid $sleep +ec=$? +case $ec in +0) + echo "ok 1 - $name" + ;; +*) + echo "not ok 1 - $name" + ;; +esac +rm -f $sleep + +name="pkill -G <group>" +rgid=`id -grn` +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +pkill -f -G $rgid $sleep +ec=$? +case $ec in +0) + echo "ok 2 - $name" + ;; +*) + echo "not ok 2 - $name" + ;; +esac +rm -f $sleep diff --git a/bin/pkill/tests/pkill-g_test.sh b/bin/pkill/tests/pkill-g_test.sh new file mode 100644 index 0000000..29d6ab7 --- /dev/null +++ b/bin/pkill/tests/pkill-g_test.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..2" + +name="pkill -g <pgrp>" +pgrp=`ps -o tpgid -p $$ | tail -1` +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +pkill -f -g $pgrp $sleep +ec=$? +case $ec in +0) + echo "ok 1 - $name" + ;; +*) + echo "not ok 1 - $name" + ;; +esac +rm -f $sleep + +name="pkill -g 0" +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +pkill -f -g 0 $sleep +ec=$? +case $ec in +0) + echo "ok 2 - $name" + ;; +*) + echo "not ok 2 - $name" + ;; +esac +rm -f $sleep diff --git a/bin/pkill/tests/pkill-i_test.sh b/bin/pkill/tests/pkill-i_test.sh new file mode 100644 index 0000000..b9b8df8 --- /dev/null +++ b/bin/pkill/tests/pkill-i_test.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..1" + +name="pkill -i" +sleep=$(pwd)/sleep.txt +usleep="${sleep}XXX" +touch $usleep +lsleep="${sleep}xxx" +ln -sf /bin/sleep $usleep +$usleep 5 & +sleep 0.3 +pkill -f -i $lsleep +ec=$? +case $ec in +0) + echo "ok - $name" + ;; +*) + echo "not ok - $name" + ;; +esac +rm -f $sleep $usleep diff --git a/bin/pkill/tests/pkill-j_test.sh b/bin/pkill/tests/pkill-j_test.sh new file mode 100644 index 0000000..48e7c72 --- /dev/null +++ b/bin/pkill/tests/pkill-j_test.sh @@ -0,0 +1,71 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..3" + +name="pkill -j <jid>" +if [ `id -u` -eq 0 ]; then + sleep=$(pwd)/sleep.txt + ln -sf /bin/sleep $sleep + jail / $base-1 127.0.0.1 $sleep 5 & + chpid=$! + jail / $base-2 127.0.0.1 $sleep 5 & + chpid2=$! + $sleep 5 & + chpid3=$! + sleep 0.5 + jid=`jls | awk "/127\\.0\\.0\\.1.*${base}-1/ {print \$1}"` + if pkill -f -j $jid $sleep && sleep 0.5 && + ! kill $chpid && kill $chpid2 $chpid3; then + echo "ok 1 - $name" + else + echo "not ok 1 - $name" + fi 2>/dev/null + rm -f $sleep +else + echo "ok 1 - $name # skip Test needs uid 0." +fi + +name="pkill -j any" +if [ `id -u` -eq 0 ]; then + sleep=$(pwd)/sleep.txt + ln -sf /bin/sleep $sleep + jail / $base-1 127.0.0.1 $sleep 5 & + chpid=$! + jail / $base-2 127.0.0.1 $sleep 5 & + chpid2=$! + $sleep 5 & + chpid3=$! + sleep 0.5 + if pkill -f -j any $sleep && sleep 0.5 && + ! kill $chpid && ! kill $chpid2 && kill $chpid3; then + echo "ok 2 - $name" + else + echo "not ok 2 - $name" + fi 2>/dev/null + rm -f $sleep +else + echo "ok 2 - $name # skip Test needs uid 0." +fi + +name="pkill -j none" +if [ `id -u` -eq 0 ]; then + sleep=$(pwd)/sleep.txt + ln -sf /bin/sleep $sleep + $sleep 5 & + chpid=$! + jail / $base 127.0.0.1 $sleep 5 & + chpid2=$! + sleep 0.5 + if pkill -f -j none $sleep && sleep 0.5 && + ! kill $chpid && kill $chpid2; then + echo "ok 3 - $name" + else + echo "not ok 3 - $name" + fi 2>/dev/null + rm -f $sleep +else + echo "ok 3 - $name # skip Test needs uid 0." +fi diff --git a/bin/pkill/tests/pkill-s_test.sh b/bin/pkill/tests/pkill-s_test.sh new file mode 100644 index 0000000..0a9587b --- /dev/null +++ b/bin/pkill/tests/pkill-s_test.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..2" + +name="pkill -s <sid>" +sid=`ps -o tsid -p $$ | tail -1` +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +pkill -f -s $sid $sleep +ec=$? +case $ec in +0) + echo "ok 1 - $name" + ;; +*) + echo "not ok 1 - $name" + ;; +esac +rm -f $sleep + +name="pkill -s 0" +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +pkill -f -s 0 $sleep +ec=$? +case $ec in +0) + echo "ok 2 - $name" + ;; +*) + echo "not ok 2 - $name" + ;; +esac +rm -f $sleep diff --git a/bin/pkill/tests/pkill-t_test.sh b/bin/pkill/tests/pkill-t_test.sh new file mode 100644 index 0000000..07f511b --- /dev/null +++ b/bin/pkill/tests/pkill-t_test.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..2" + +name="pkill -t <tty>" +tty=`ps -x -o tty -p $$ | tail -1` +if [ "$tty" = "??" -o "$tty" = "-" ]; then + tty="-" + ttyshort="-" +else + case $tty in + pts/*) ttyshort=`echo $tty | cut -c 5-` ;; + *) ttyshort=`echo $tty | cut -c 4-` ;; + esac +fi +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +pkill -f -t $tty $sleep +ec=$? +case $ec in +0) + echo "ok 1 - $name" + ;; +*) + echo "not ok 1 - $name" + ;; +esac +$sleep 5 & +sleep 0.3 +pkill -f -t $ttyshort $sleep +ec=$? +case $ec in +0) + echo "ok 2 - $name" + ;; +*) + echo "not ok 2 - $name" + ;; +esac +rm -f $sleep diff --git a/bin/pkill/tests/pkill-x_test.sh b/bin/pkill/tests/pkill-x_test.sh new file mode 100644 index 0000000..5ff0d68 --- /dev/null +++ b/bin/pkill/tests/pkill-x_test.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# $FreeBSD$ + +base=`basename $0` + +echo "1..4" + +name="pkill -x" +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +pkill -x slee -P $$ +if [ $? -ne 0 ]; then + echo "ok 1 - $name" +else + echo "not ok 1 - $name" +fi +pkill -x sleep -P $$ +if [ $? -eq 0 ]; then + echo "ok 2 - $name" +else + echo "not ok 2 - $name" +fi +rm -f $sleep + +name="pkill -x -f" +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep +$sleep 5 & +sleep 0.3 +pkill -x -f "$sleep " -P $$ +if [ $? -ne 0 ]; then + echo "ok 3 - $name" +else + echo "not ok 3 - $name" +fi +pkill -x -f "$sleep 5" -P $$ +if [ $? -eq 0 ]; then + echo "ok 4 - $name" +else + echo "not ok 4 - $name" +fi +rm -f $sleep |