summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2015-02-14 06:19:24 +0000
committerngie <ngie@FreeBSD.org>2015-02-14 06:19:24 +0000
commitf1a09d8d1a273b665f276516202ef2293f4ff6c7 (patch)
tree9cabdc7b1b08cc62d4127415f0995cf32b328832 /bin
parent2c667816e63fe3cfa93cac7d5514bd42a182b406 (diff)
downloadFreeBSD-src-f1a09d8d1a273b665f276516202ef2293f4ff6c7.zip
FreeBSD-src-f1a09d8d1a273b665f276516202ef2293f4ff6c7.tar.gz
Simplify jail_name_to_jid and try to be more fault tolerant when scanning for
the jail ID (poll up to 10 times for the jail IDs to become available) If the scan fails, the code will fall through and fail as it does with Jenkins today
Diffstat (limited to 'bin')
-rw-r--r--bin/pkill/tests/pgrep-j_test.sh29
1 files changed, 14 insertions, 15 deletions
diff --git a/bin/pkill/tests/pgrep-j_test.sh b/bin/pkill/tests/pgrep-j_test.sh
index 23e586a..4830ace 100644
--- a/bin/pkill/tests/pgrep-j_test.sh
+++ b/bin/pkill/tests/pgrep-j_test.sh
@@ -4,17 +4,7 @@
jail_name_to_jid()
{
local check_name="$1"
- (
- line="$(jls -n 2> /dev/null | grep name=$check_name )"
- for nv in $line; do
- local name="${nv%=*}"
- if [ "${name}" = "jid" ]; then
- eval $nv
- echo $jid
- break
- fi
- done
- )
+ jls -j "$check_name" -s 2>/dev/null | tr ' ' '\n' | grep jid= | sed -e 's/.*=//g'
}
base=pgrep_j_test
@@ -37,10 +27,19 @@ jail -c path=/ name=${base}_1_1 ip4.addr=127.0.0.1 \
jail -c path=/ name=${base}_1_2 ip4.addr=127.0.0.1 \
command=daemon -p ${PWD}/${base}_1_2.pid $sleep $sleep_amount &
-jid1=$(jail_name_to_jid ${base}_1_1)
-jid2=$(jail_name_to_jid ${base}_1_2)
-jid="${jid1},${jid2}"
-pid1="$(pgrep -f -x -j $jid "$sleep $sleep_amount" | sort)"
+for i in `seq 1 10`; do
+ jid1=$(jail_name_to_jid ${base}_1_1)
+ jid2=$(jail_name_to_jid ${base}_1_2)
+ jid="${jid1},${jid2}"
+ case "$jid" in
+ [0-9]+,[0-9]+)
+ break
+ ;;
+ esac
+ sleep 0.1
+done
+
+pid1="$(pgrep -f -x -j "$jid" "$sleep $sleep_amount" | sort)"
pid2=$(printf "%s\n%s" "$(cat ${PWD}/${base}_1_1.pid)" \
$(cat ${PWD}/${base}_1_2.pid) | sort)
if [ "$pid1" = "$pid2" ]; then
OpenPOWER on IntegriCloud