Date: Sat, 14 Feb 2015 06:19:25 +0000 (UTC) From: Garrett Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r278742 - head/bin/pkill/tests Message-ID: <201502140619.t1E6JPVV054197@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ngie Date: Sat Feb 14 06:19:24 2015 New Revision: 278742 URL: https://svnweb.freebsd.org/changeset/base/278742 Log: 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 Modified: head/bin/pkill/tests/pgrep-j_test.sh Modified: head/bin/pkill/tests/pgrep-j_test.sh ============================================================================== --- head/bin/pkill/tests/pgrep-j_test.sh Sat Feb 14 04:28:51 2015 (r278741) +++ head/bin/pkill/tests/pgrep-j_test.sh Sat Feb 14 06:19:24 2015 (r278742) @@ -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 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201502140619.t1E6JPVV054197>