1#!/bin/sh 2# $FreeBSD$ 3 4base=`basename $0` 5 6echo "1..3" 7 8name="pgrep -j <jid>" 9if [ `id -u` -eq 0 ]; then 10 sleep=$(pwd)/sleep.txt 11 ln -sf /bin/sleep $sleep 12 jail / $base-1 127.0.0.1 $sleep 5 & 13 chpid=$! 14 jail / $base-2 127.0.0.1 $sleep 5 & 15 chpid2=$! 16 $sleep 5 & 17 chpid3=$! 18 sleep 0.5 19 jid=`jls | awk "/127\\.0\\.0\\.1.*${base}-1/ {print \$1}"` 20 pid=`pgrep -f -j $jid $sleep` 21 if [ "$pid" = "$chpid" ]; then 22 echo "ok 1 - $name" 23 else 24 echo "not ok 1 - $name" 25 fi 26 kill $chpid $chpid2 $chpid3 27 rm -f $sleep 28else 29 echo "ok 1 - $name # skip Test needs uid 0." 30fi 31 32name="pgrep -j any" 33if [ `id -u` -eq 0 ]; then 34 sleep=$(pwd)/sleep.txt 35 ln -sf /bin/sleep $sleep 36 jail / $base-1 127.0.0.1 $sleep 5 & 37 chpid=$! 38 jail / $base-2 127.0.0.1 $sleep 5 & 39 chpid2=$! 40 $sleep 5 & 41 chpid3=$! 42 sleep 0.5 43 pids=`pgrep -f -j any $sleep | sort` 44 refpids=`{ echo $chpid; echo $chpid2; } | sort` 45 if [ "$pids" = "$refpids" ]; then 46 echo "ok 2 - $name" 47 else 48 echo "not ok 2 - $name" 49 fi 50 kill $chpid $chpid2 $chpid3 51 rm -f $sleep 52else 53 echo "ok 2 - $name # skip Test needs uid 0." 54fi 55 56name="pgrep -j none" 57if [ `id -u` -eq 0 ]; then 58 sleep=$(pwd)/sleep.txt 59 ln -sf /bin/sleep $sleep 60 $sleep 5 & 61 chpid=$! 62 jail / $base 127.0.0.1 $sleep 5 & 63 chpid2=$! 64 sleep 0.5 65 pid=`pgrep -f -j none $sleep` 66 if [ "$pid" = "$chpid" ]; then 67 echo "ok 3 - $name" 68 else 69 echo "not ok 3 - $name" 70 fi 71 kill $chpid $chpid2 72 rm -f $sleep 73else 74 echo "ok 3 - $name # skip Test needs uid 0." 75fi 76