diff options
author | Ryan S. Arnold <ryan.arnold@linaro.org> | 2013-11-12 14:37:11 -0600 |
---|---|---|
committer | Ryan S. Arnold <ryan.arnold@linaro.org> | 2013-11-12 14:37:11 -0600 |
commit | 81e05253f2cb9926758a557791579ad9cc616376 (patch) | |
tree | 4aef8b60c60fa0553260d9843183a098089039c6 /test.sh | |
parent | f2482325ae6553a82532b27af411c087dd5ade86 (diff) |
Add some error checking to --target and --build. Add top level cbuild.sh test.
Diffstat (limited to 'test.sh')
-rwxr-xr-x | test.sh | 154 |
1 files changed, 116 insertions, 38 deletions
@@ -1,65 +1,143 @@ #!/bin/sh +testcbuild2="`basename $0`" + +# The directory where the script lives. +topdir="`dirname $0`" + +# Source common.sh for some common utilities. +. ${topdir}/lib/common.sh || exit 1 + +# Override $local_snapshots so that the local_snapshots directory +# of an existing build is not moved or damaged. This affects all +# called instances of cbuild2.sh below. +export local_snapshots="`mktemp -d /tmp/cbuild2.$$.XXX`/snapshots" +export sources_conf=${topdir}testsuite/test_sources.conf +export remote_snapshots=http://cbuild.validation.linaro.org/snapshots +export wget_bin=/usr/bin/wget +export wget_quiet=yes + +# Create the snapshots/ subdir before it is used. +# It's possible that /tmp is out of space and this will fail. +out="`mkdir -p ${local_snapshots}`" +if test "$?" -gt 0; then + exit 1 +fi + +usage() +{ + echo " ${testcbuild2} [--snapshots <path/to/snapshots/md5sums>]" + echo "" + echo " ${testcbuild2} is the cbuild2 frontend command conformance test." + echo "" + echo " ${testcbuild2} should be run from the source directory." +} + pass() { - echo "PASS: $1" + echo "PASS: '$1'" } fail() { - echo "FAIL: $1" + echo "FAIL: '$1'" } -test() +cbtest() { case "$1" in *$2*) - pass $2 + pass "$3" ;; *) - fail $2 + fail "$3" ;; esac } -out="`./cbuild2.sh --build XXX`" -test "${out}" "build" - -out="`./cbuild2.sh --target XXX`" -test "${out}" "target" - -out="`./cbuild2.sh --snapshots XXX`" -test "${out}" "snapshot" - -out="`./cbuild2.sh --libc XXX`" -test "${out}" "libc" - -out="`./cbuild2.sh --list XXX`" -test "${out}" "list" - -#out="`./cbuild2.sh --set {gcc,binutils,libc,latest}=XXX`" -#test "${out}" "set" +m5sums= +while test $# -gt 0; do + case "$1" in + --h*|-h) + usage + exit 1 + ;; + --snap*|-snap*) + if test `echo $1 | grep -c "\-snap.*="` -gt 0; then + error "A '=' is invalid after --snapshots. A space is expected." + exit 1; + fi + if test -z $2; then + error "--snapshots requires a path to an md5sums file." + exit 1; + fi + md5sums=$2 + if test ! -e "$md5sums"; then + error "Path to snapshots/md5sums is invalid." + exit 1; + fi + echo "Copying ${md5sums} to ${local_snapshots} for snapshots file." + cp ${md5sums} ${local_snapshots} + ;; + *) + ;; + esac + + if test $# -gt 0; then + shift + fi +done + +if test ! -e "${local_snapshots}/md5sums"; then + out="`fetch md5sums 2>/dev/null`" + if test $? -gt 0; then + echo "Failed to fetch md5sums. Use --snapshots for offline mode." 1>&2 + exit 1; + fi + echo "Using ${local_snapshots}/md5sums for snapshots file." +fi + +test_xfailure() +{ + local cb_commands=$1 + local match=$2 + local out + out="`./cbuild2.sh ${cb_commands} 2>&1 | grep "${match}" | sed -e 's:\(^ERROR\).*\('"${match}"'\).*:\1 \2:'`" + cbtest "${out}" "ERROR ${match}" "ERROR ${cb_commands}" +} -out="`./cbuild2.sh --binutils XXX`" -test "${out}" "binutils" +test_xpass() +{ + local cb_commands=$1 + local match=$2 + local out + # Continue to search for error so we don't get false positives. + out="`./cbuild2.sh ${cb_commands} 2>&1 | grep "${match}" | sed -e 's:\(^ERROR\).*\('"${match}"'\).*:\1 \2:'`" + cbtest "${out}" "${match}" "VALID ${cb_commands}" +} -out="`./cbuild2.sh --gcc XXX`" -test "${out}" "gcc" +cb_commands="--dry-run" +match="Complete build process took" +test_xpass "${cb_commands}" "${match}" -out="`./cbuild2.sh --config XXX`" -test "${out}" "config" +cb_commands="--dryrun" +match="Complete build process took" +test_xpass "${cb_commands}" "${match}" -out="`./cbuild2.sh --clean`" -test "${out}" "Cleaning" +cb_commands="--dryrunas" +match="Command not recognized" +test_xfailure "${cb_commands}" "${match}" -out="`./cbuild2.sh --dispatch XXX`" -test "${out}" "Dispatch" +cb_commands="--target=foo" +match="A space is expected" +test_xfailure "${cb_commands}" "${match}" -out="`./cbuild2.sh --sysroot XXX`" -test "${out}" "sysroot" +cb_commands="--target foo" +match="Complete build process took" +test_xpass "${cb_commands}" "${match}" -out="`./cbuild2.sh --db-user XXX`" -test "${out}" "user" +cb_commands="--build=all" +match="A space is expected" +test_xfailure "${cb_commands}" "${match}" -out="`./cbuild2.sh --db-passwd XXX`" -test "${out}" "password" +exit 0 |