diff options
author | Enji Cooper <ngie@FreeBSD.org> | 2015-02-14 06:19:24 +0000 |
---|---|---|
committer | Enji Cooper <ngie@FreeBSD.org> | 2015-02-14 06:19:24 +0000 |
commit | 8edd0e30402f3c4952b038cde163c3f31e36c818 (patch) | |
tree | 9cabdc7b1b08cc62d4127415f0995cf32b328832 /bin/pkill/tests | |
parent | 899d1cacacfe2372aa56de9471c05638d8be3b42 (diff) | |
download | src-8edd0e30402f3c4952b038cde163c3f31e36c818.tar.gz src-8edd0e30402f3c4952b038cde163c3f31e36c818.zip |
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
Notes
Notes:
svn path=/head/; revision=278742
Diffstat (limited to 'bin/pkill/tests')
-rw-r--r-- | bin/pkill/tests/pgrep-j_test.sh | 29 |
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 23e586a4ca17..4830ace39aa9 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 |