Mercurial > hg > aboriginal
changeset 778:e373d2b6d0b8
Add killtree and make stuff use it. Update smoketest-all.sh to use doforklog, allowing FORK=1 to run stuff in parallel.
author | Rob Landley <rob@landley.net> |
---|---|
date | Fri, 03 Jul 2009 05:29:11 -0500 |
parents | 879353d1cfba |
children | 6caf372a8b12 |
files | buildall.sh run-from-build.sh smoketest-all.sh smoketest.sh sources/functions.sh |
diffstat | 5 files changed, 50 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/buildall.sh Thu Jul 02 16:23:39 2009 -0500 +++ b/buildall.sh Fri Jul 03 05:29:11 2009 -0500 @@ -14,6 +14,10 @@ DO_SKIP_STAGE_TARBALLS="$SKIP_STAGE_TARBALLS" [ ! -z "$CROSS_COMPILERS_EH" ] && DO_SKIP_STAGE_TARBALLS=1 +[ ! -z "$FORK" ] && QUIET='| grep "^==="' + +trap "killtree $$" EXIT + # Perform initial setup that doesn't parallelize well: Download source, # build host tools, extract source.
--- a/run-from-build.sh Thu Jul 02 16:23:39 2009 -0500 +++ b/run-from-build.sh Fri Jul 03 05:29:11 2009 -0500 @@ -19,7 +19,7 @@ # And run it, using the distccd we built (if necessary) and the cross-compiler. -trap "pkill -P$$" EXIT +trap "killtree $$" EXIT ./run-emulator.sh --make-hdb 2048 --memory 256 --with-distcc \ "${BUILD}/cross-compiler-${ARCH}"
--- a/smoketest-all.sh Thu Jul 02 16:23:39 2009 -0500 +++ b/smoketest-all.sh Fri Jul 03 05:29:11 2009 -0500 @@ -1,10 +1,12 @@ #!/bin/bash +. sources/functions.sh || exit 1 + if [ "$1" == "--logs" ] then - for i in build/smoketest-*.txt + for i in build/logs/smoketest-*.txt do - NAME="$(echo $i | sed 's/smoketest-\(.*\)\.txt/\1/')" + NAME="$(echo $i | sed 's/.*smoketest-\(.*\)\.txt/\1/')" echo -n "Testing $NAME:" RESULT="$(grep 'Hello world!' "$i")" [ -z "$RESULT" ] && echo "FAIL" || echo "PASS" @@ -13,12 +15,22 @@ exit fi -# Test all targets to see whether or not they can compile and run "hello world" +function dotest() +{ + [ -z "$FORK" ] && echo -n "Testing $1:" + [ ! -z "$VERBOSE" ] && VERBOSITY="tee >(cat >&2) |" + RESULT="$(./smoketest.sh "$1" 2>&1 | eval "$VERBOSITY grep 'Hello world!'")" + [ -z "$RESULT" ] && RESULT="FAIL" || RESULT="PASS" + [ -z "$FORK" ] && echo "$RESULT" || echo "Testing $1:$RESULT" + rm -f build/system-image-"$1"/hdb.img 2>/dev/null +} -ls -pd build/system-image-* | sed -n 's@.*/system-image-\(.*\)/@\1@p' | while read i +# Test all non-hw targets to see whether or not they can compile and run +# the included "hello world" program. + +for i in $(ls -pd build/system-image-* | sed -n 's@.*/system-image-\(.*\)/@\1@p' | grep -v "^hw-") do - echo -n "Testing $i:" - RESULT="$(./smoketest.sh "$i" 2>&1 | grep 'Hello world!')" - [ -z "$RESULT" ] && echo "FAIL" || echo "PASS" - rm -f build/system-image-"$i"/hdb.img 2>/dev/null + doforklog dotest $i done + +wait
--- a/smoketest.sh Thu Jul 02 16:23:39 2009 -0500 +++ b/smoketest.sh Fri Jul 03 05:29:11 2009 -0500 @@ -1,5 +1,7 @@ #!/bin/bash +. sources/functions.sh || exit 1 + # This script compiles stuff under the final system, using distcc to call out # to the cross compiler. @@ -12,7 +14,7 @@ } timeout $$ & -trap "pkill -P$$" EXIT +trap "killtree $$" EXIT # Call run-from-build with a here document to do stuff.
--- a/sources/functions.sh Thu Jul 02 16:23:39 2009 -0500 +++ b/sources/functions.sh Fri Jul 03 05:29:11 2009 -0500 @@ -563,9 +563,29 @@ if [ ! -z "$FORK" ] then - $* 2>&1 | tee "$LOG" | grep '^===' & + $* 2>&1 | eval "tee \"$LOG\" $QUIET" & else - $* 2>&1 | tee "$LOG" + $* 2>&1 | eval "tee \"$LOG\" $QUIET" fi } +# Kill a process and all its decendants + +function killtree() +{ + local KIDS="" + + while [ $# -ne 0 ] + do + KIDS="$KIDS $(pgrep -P$1)" + shift + done + + KIDS="$(echo -n $KIDS)" + if [ ! -z "$KIDS" ] + then + # Depth first kill avoids reparent_to_init hiding stuff. + killtree $KIDS + kill $KIDS 2>/dev/null + fi +}