summaryrefslogtreecommitdiffstats
path: root/bin/pkill/tests
diff options
context:
space:
mode:
authorjamie <jamie@FreeBSD.org>2015-08-29 02:41:59 +0000
committerjamie <jamie@FreeBSD.org>2015-08-29 02:41:59 +0000
commit9e4b124ba9f2b548c4360e61b1b979fee54875b4 (patch)
treee38abb8a227df077065d2d687582878be10cc65e /bin/pkill/tests
parentb90ab2596fccb7f1eb0655e5a0f8450c61b7f331 (diff)
downloadFreeBSD-src-9e4b124ba9f2b548c4360e61b1b979fee54875b4.zip
FreeBSD-src-9e4b124ba9f2b548c4360e61b1b979fee54875b4.tar.gz
MFC r287012:
Make pkill/pgrep -j ARG take jname, not just jid. PR: 201588 Submitted by: Daniel Shahaf <danielsh at apache.org>
Diffstat (limited to 'bin/pkill/tests')
-rw-r--r--bin/pkill/tests/pgrep-j_test.sh27
-rw-r--r--bin/pkill/tests/pkill-j_test.sh28
2 files changed, 53 insertions, 2 deletions
diff --git a/bin/pkill/tests/pgrep-j_test.sh b/bin/pkill/tests/pgrep-j_test.sh
index e24e5c2..1d62813 100644
--- a/bin/pkill/tests/pgrep-j_test.sh
+++ b/bin/pkill/tests/pgrep-j_test.sh
@@ -14,7 +14,7 @@ if [ `id -u` -ne 0 ]; then
exit 0
fi
-echo "1..3"
+echo "1..4"
sleep=$(pwd)/sleep.txt
ln -sf /bin/sleep $sleep
@@ -87,5 +87,30 @@ else
fi
[ -f ${PWD}/${base}_3_1.pid ] && kill $(cat $PWD/${base}_3_1.pid)
[ -f ${PWD}/${base}_3_2.pid ] && kill $(cat $PWD/${base}_3_2.pid)
+wait
+
+# test 4 is like test 1 except with jname instead of jid.
+name="pgrep -j <jname>"
+sleep_amount=8
+jail -c path=/ name=${base}_4_1 ip4.addr=127.0.0.1 \
+ command=daemon -p ${PWD}/${base}_4_1.pid $sleep $sleep_amount &
+
+jail -c path=/ name=${base}_4_2 ip4.addr=127.0.0.1 \
+ command=daemon -p ${PWD}/${base}_4_2.pid $sleep $sleep_amount &
+
+sleep 0.5
+
+jname="${base}_4_1,${base}_4_2"
+pid1="$(pgrep -f -x -j "$jname" "$sleep $sleep_amount" | sort)"
+pid2=$(printf "%s\n%s" "$(cat ${PWD}/${base}_4_1.pid)" \
+ $(cat ${PWD}/${base}_4_2.pid) | sort)
+if [ "$pid1" = "$pid2" ]; then
+ echo "ok 4 - $name"
+else
+ echo "not ok 4 - $name # pgrep output: '$(echo $pid1)', pidfile output: '$(echo $pid2)'"
+fi
+[ -f ${PWD}/${base}_4_1.pid ] && kill $(cat ${PWD}/${base}_4_1.pid)
+[ -f ${PWD}/${base}_4_2.pid ] && kill $(cat ${PWD}/${base}_4_2.pid)
+wait
rm -f $sleep
diff --git a/bin/pkill/tests/pkill-j_test.sh b/bin/pkill/tests/pkill-j_test.sh
index 26e185f..0af24cf 100644
--- a/bin/pkill/tests/pkill-j_test.sh
+++ b/bin/pkill/tests/pkill-j_test.sh
@@ -14,7 +14,7 @@ if [ `id -u` -ne 0 ]; then
exit 0
fi
-echo "1..3"
+echo "1..4"
sleep=$(pwd)/sleep.txt
ln -sf /bin/sleep $sleep
@@ -90,5 +90,31 @@ else
fi 2>/dev/null
[ -f ${PWD}/${base}_3_1.pid ] && kill $(cat ${base}_3_1.pid)
[ -f ${PWD}/${base}_3_2.pid ] && kill $(cat ${base}_3_2.pid)
+wait
+
+# test 4 is like test 1 except with jname instead of jid.
+name="pkill -j <jname>"
+sleep_amount=8
+jail -c path=/ name=${base}_4_1 ip4.addr=127.0.0.1 \
+ command=daemon -p ${PWD}/${base}_4_1.pid $sleep $sleep_amount &
+
+jail -c path=/ name=${base}_4_2 ip4.addr=127.0.0.1 \
+ command=daemon -p ${PWD}/${base}_4_2.pid $sleep $sleep_amount &
+
+$sleep $sleep_amount &
+
+sleep 0.5
+
+jname="${base}_4_1,${base}_4_2"
+if pkill -f -j "$jname" $sleep && sleep 0.5 &&
+ ! -f ${PWD}/${base}_4_1.pid &&
+ ! -f ${PWD}/${base}_4_2.pid ; then
+ echo "ok 4 - $name"
+else
+ echo "not ok 4 - $name"
+fi 2>/dev/null
+[ -f ${PWD}/${base}_4_1.pid ] && kill $(cat ${PWD}/${base}_4_1.pid)
+[ -f ${PWD}/${base}_4_2.pid ] && kill $(cat ${PWD}/${base}_4_2.pid)
+wait
rm -f $sleep
OpenPOWER on IntegriCloud