Deleted Added
full compact
pgrep-LF_test.sh (149474) pgrep-LF_test.sh (263351)
1#!/bin/sh
1#!/bin/sh
2# $FreeBSD: head/tools/regression/usr.bin/pkill/pgrep-LF.t 149474 2005-08-25 20:13:58Z pjd $
2# $FreeBSD: head/bin/pkill/tests/pgrep-LF_test.sh 263351 2014-03-19 12:46:04Z jmmv $
3
4base=`basename $0`
5
6echo "1..2"
7
8name="pgrep -LF <pidfile>"
3
4base=`basename $0`
5
6echo "1..2"
7
8name="pgrep -LF <pidfile>"
9pidfile=`mktemp /tmp/$base.XXXXXX` || exit 1
10sleep=`mktemp /tmp/$base.XXXXXX` || exit 1
9pidfile=$(pwd)/pidfile.txt
10sleep=$(pwd)/sleep.txt
11ln -sf /bin/sleep $sleep
12daemon -p $pidfile $sleep 5
13sleep 0.3
14chpid=`cat $pidfile`
15pid=`pgrep -f -L -F $pidfile $sleep`
16if [ "$pid" = "$chpid" ]; then
17 echo "ok 1 - $name"
18else
19 echo "not ok 1 - $name"
20fi
21kill "$chpid"
22
23# Be sure we cannot find process which pidfile is not locked.
24$sleep 5 &
25sleep 0.3
26chpid=$!
27echo $chpid > $pidfile
28pgrep -f -L -F $pidfile $sleep 2>/dev/null
29ec=$?
30case $ec in
310)
32 echo "not ok 2 - $name"
33 ;;
34*)
35 echo "ok 2 - $name"
36 ;;
37esac
38
39kill "$chpid"
40rm -f $pidfile
41rm -f $sleep
11ln -sf /bin/sleep $sleep
12daemon -p $pidfile $sleep 5
13sleep 0.3
14chpid=`cat $pidfile`
15pid=`pgrep -f -L -F $pidfile $sleep`
16if [ "$pid" = "$chpid" ]; then
17 echo "ok 1 - $name"
18else
19 echo "not ok 1 - $name"
20fi
21kill "$chpid"
22
23# Be sure we cannot find process which pidfile is not locked.
24$sleep 5 &
25sleep 0.3
26chpid=$!
27echo $chpid > $pidfile
28pgrep -f -L -F $pidfile $sleep 2>/dev/null
29ec=$?
30case $ec in
310)
32 echo "not ok 2 - $name"
33 ;;
34*)
35 echo "ok 2 - $name"
36 ;;
37esac
38
39kill "$chpid"
40rm -f $pidfile
41rm -f $sleep