xref: /freebsd/bin/pkill/tests/pgrep-t_test.sh (revision e6bfd18d21b225af6a0ed67ceeaf1293b7b9eba5)
1#!/bin/sh
2# $FreeBSD$
3
4base=`basename $0`
5
6echo "1..2"
7
8name="pgrep -t <tty>"
9tty=`ps -x -o tty -p $$ | tail -1`
10if [ "$tty" = "??" -o "$tty" = "-" ]; then
11	tty="-"
12	ttyshort="-"
13else
14	case $tty in
15	pts/*)	ttyshort=`echo $tty | cut -c 5-` ;;
16	*)	ttyshort=`echo $tty | cut -c 4-` ;;
17	esac
18fi
19sleep=$(pwd)/sleep.txt
20ln -sf /bin/sleep $sleep
21$sleep 5 &
22sleep 0.3
23chpid=$!
24pid=`pgrep -f -t $tty $sleep`
25if [ "$pid" = "$chpid" ]; then
26	echo "ok 1 - $name"
27else
28	echo "not ok 1 - $name"
29fi
30pid=`pgrep -f -t $ttyshort $sleep`
31if [ "$pid" = "$chpid" ]; then
32	echo "ok 2 - $name"
33else
34	echo "not ok 2 - $name"
35fi
36kill $chpid
37rm -f $sleep
38