From c36efc2ffd4f4cca283b70147d232cc8b01ba4ad Mon Sep 17 00:00:00 2001 From: Max Okumoto Date: Tue, 1 Mar 2005 22:42:28 +0000 Subject: [PATCH] Changed regression tests to write to /tmp instead of in the src dir. --- usr.bin/make/tests/basic/t0/test.sh | 9 ++--- usr.bin/make/tests/basic/t1/test.sh | 9 ++--- usr.bin/make/tests/basic/t2/test.sh | 8 ++-- usr.bin/make/tests/basic/t3/test.sh | 9 ++--- usr.bin/make/tests/common.sh | 50 ++++++++++++++++++------- usr.bin/make/tests/variables/t0/test.sh | 9 ++--- usr.bin/make/tests/variables/t1/test.sh | 8 ++-- 7 files changed, 54 insertions(+), 48 deletions(-) diff --git a/usr.bin/make/tests/basic/t0/test.sh b/usr.bin/make/tests/basic/t0/test.sh index f9b7bcbca7..d24a45cc74 100644 --- a/usr.bin/make/tests/basic/t0/test.sh +++ b/usr.bin/make/tests/basic/t0/test.sh @@ -1,15 +1,12 @@ #!/bin/sh -# $DragonFly: src/usr.bin/make/tests/basic/t0/test.sh,v 1.5 2005/02/26 10:43:29 okumoto Exp $ +# $DragonFly: src/usr.bin/make/tests/basic/t0/test.sh,v 1.6 2005/03/01 22:42:28 okumoto Exp $ . ../../common.sh -run_test() +setup_test() { - cp /dev/null Makefile - - $MAKE 1> stdout 2> stderr - echo $? > status + cp /dev/null $WORK_BASE/Makefile } desc_test() diff --git a/usr.bin/make/tests/basic/t1/test.sh b/usr.bin/make/tests/basic/t1/test.sh index ce6cb6f81d..d00f11e9c8 100644 --- a/usr.bin/make/tests/basic/t1/test.sh +++ b/usr.bin/make/tests/basic/t1/test.sh @@ -1,17 +1,14 @@ #!/bin/sh -# $DragonFly: src/usr.bin/make/tests/basic/t1/test.sh,v 1.5 2005/02/26 10:43:29 okumoto Exp $ +# $DragonFly: src/usr.bin/make/tests/basic/t1/test.sh,v 1.6 2005/03/01 22:42:28 okumoto Exp $ . ../../common.sh -run_test() +setup_test() { - cat > Makefile << _EOF_ + cat > $WORK_BASE/Makefile << _EOF_ all: _EOF_ - - $MAKE 1> stdout 2> stderr - echo $? > status } desc_test() diff --git a/usr.bin/make/tests/basic/t2/test.sh b/usr.bin/make/tests/basic/t2/test.sh index 34cffc7313..8c282d20ea 100644 --- a/usr.bin/make/tests/basic/t2/test.sh +++ b/usr.bin/make/tests/basic/t2/test.sh @@ -1,17 +1,15 @@ #!/bin/sh -# $DragonFly: src/usr.bin/make/tests/basic/t2/test.sh,v 1.5 2005/02/26 10:43:29 okumoto Exp $ +# $DragonFly: src/usr.bin/make/tests/basic/t2/test.sh,v 1.6 2005/03/01 22:42:28 okumoto Exp $ . ../../common.sh -run_test() +setup_test() { - cat > Makefile << _EOF_ + cat > $WORK_BASE/Makefile << _EOF_ all: echo hello _EOF_ - $MAKE 1> stdout 2> stderr - echo $? > status } desc_test() diff --git a/usr.bin/make/tests/basic/t3/test.sh b/usr.bin/make/tests/basic/t3/test.sh index 3237c69223..a238d4d803 100644 --- a/usr.bin/make/tests/basic/t3/test.sh +++ b/usr.bin/make/tests/basic/t3/test.sh @@ -1,15 +1,12 @@ #!/bin/sh -# $DragonFly: src/usr.bin/make/tests/basic/t3/test.sh,v 1.1 2005/02/26 10:43:09 okumoto Exp $ +# $DragonFly: src/usr.bin/make/tests/basic/t3/test.sh,v 1.2 2005/03/01 22:42:28 okumoto Exp $ . ../../common.sh -run_test() +setup_test() { - rm -f Makefile - - $MAKE 1> stdout 2> stderr - echo $? > status + rm -f $WORK_BASE/Makefile } desc_test() diff --git a/usr.bin/make/tests/common.sh b/usr.bin/make/tests/common.sh index 1991eca8e1..3ba100443a 100644 --- a/usr.bin/make/tests/common.sh +++ b/usr.bin/make/tests/common.sh @@ -2,7 +2,7 @@ # # Common code used run regression tests for usr.bin/make. # -# $DragonFly: src/usr.bin/make/tests/common.sh,v 1.5 2005/03/01 22:01:16 okumoto Exp $ +# $DragonFly: src/usr.bin/make/tests/common.sh,v 1.6 2005/03/01 22:42:28 okumoto Exp $ IDTAG='$'DragonFly'$' @@ -33,7 +33,7 @@ hack_cmp() { local EXPECTED RESULT EXPECTED="expected.$1" - RESULT=$1 + RESULT=$WORK_BASE/$1 if [ -f $EXPECTED ]; then cat $EXPECTED |\ @@ -54,7 +54,7 @@ hack_diff() { local EXPECTED RESULT EXPECTED="expected.$1" - RESULT=$1 + RESULT=$WORK_BASE/$1 echo diff $EXPECTED $RESULT if [ -f $EXPECTED ]; then @@ -71,29 +71,47 @@ hack_diff() # Default run_test() function. It should be replace by the # user specified regression test. # -run_test() +# Both the variables SRC_BASE WORK_BASE are available. +# +setup_test() { - echo "Missing run_test() function in $START_BASE/test.sh" + echo "Missing setup_test() function in $SRC_BASE/test.sh" } +# +# Default run_test() function. It can be replace by the +# user specified regression test. +# +# Both the variables SRC_BASE WORK_BASE are available. +# +# Note: this function executes from a subshell. +# +run_test() +( + cd $WORK_BASE; + $MAKE 1> stdout 2> stderr + echo $? > status +) + # # Execute cmd in subdirectory. # eval_subdir_cmd() { - local START_BASE + local SRC_BASE WORK_BASE if [ ! -d $1 ]; then - echo "Test directory '$1' missing in directory '$START_BASE'" + echo "Test directory '$1' missing in directory '$SRC_BASE'" return fi if [ ! -f $1/test.sh ]; then - echo "Test script missing in directory '$START_BASE/$1'" + echo "Test script missing in directory '$SRC_BASE/$1'" return fi - START_BASE=${START_BASE}/$1 + SRC_BASE=${SRC_BASE}/$1 + WORK_BASE=${WORK_BASE}/$1 (cd $1; sh ./test.sh $2) } @@ -136,17 +154,17 @@ eval_cmd() if [ ! -z "$FAIL" ]; then FAIL=`echo $FAIL` - echo "$START_BASE: Test failed {$FAIL}" + echo "$SRC_BASE: Test failed {$FAIL}" fi ;; desc) - echo -n "$START_BASE: " + echo -n "$SRC_BASE: " desc_test ;; diff) sh $0 test echo "------------------------" - echo "- $START_BASE" + echo "- $SRC_BASE" echo "------------------------" hack_diff stdout hack_diff stderr @@ -158,6 +176,8 @@ eval_cmd() sh $0 clean ;; test) + [ -d $WORK_BASE ] || mkdir -p $WORK_BASE + setup_test run_test ;; update) @@ -213,10 +233,12 @@ for i; do esac done -START_BASE=${START_BASE:-.} +SRC_BASE=${SRC_BASE:-""} +WORK_BASE=${WORK_BASE:-"/tmp/$USER.make.test"} MAKE=${MAKE:-/usr/bin/make} SCRATCH=${SCRATCH:-/tmp} export MAKE export VERBOSE -export START_BASE +export SRC_BASE +export WORK_BASE diff --git a/usr.bin/make/tests/variables/t0/test.sh b/usr.bin/make/tests/variables/t0/test.sh index c5a4e719cf..ef757a5985 100644 --- a/usr.bin/make/tests/variables/t0/test.sh +++ b/usr.bin/make/tests/variables/t0/test.sh @@ -1,12 +1,12 @@ #!/bin/sh -# $DragonFly: src/usr.bin/make/tests/variables/t0/test.sh,v 1.5 2005/02/26 10:48:24 okumoto Exp $ +# $DragonFly: src/usr.bin/make/tests/variables/t0/test.sh,v 1.6 2005/03/01 22:42:28 okumoto Exp $ . ../../common.sh -run_test() +setup_test() { - cat > Makefile << "_EOF_" + cat > $WORK_BASE/Makefile << "_EOF_" A = 0 AV = 1 all: @@ -27,9 +27,6 @@ all: echo ${A{ echo $} _EOF_ - - $MAKE 1> stdout 2> stderr - echo $? > status } desc_test() diff --git a/usr.bin/make/tests/variables/t1/test.sh b/usr.bin/make/tests/variables/t1/test.sh index 4f604f6664..4c99ac275c 100644 --- a/usr.bin/make/tests/variables/t1/test.sh +++ b/usr.bin/make/tests/variables/t1/test.sh @@ -1,12 +1,12 @@ #!/bin/sh -# $DragonFly: src/usr.bin/make/tests/variables/t1/test.sh,v 1.6 2005/02/26 11:25:02 okumoto Exp $ +# $DragonFly: src/usr.bin/make/tests/variables/t1/test.sh,v 1.7 2005/03/01 22:42:28 okumoto Exp $ . ../../common.sh -run_test() +setup_test() { - cat > Makefile << "_EOF_" + cat > $WORK_BASE/Makefile << "_EOF_" FILES = \ main.c globals.h \ util.c util.h \ @@ -22,8 +22,6 @@ all: @echo "utility files: ${FILES:Mutil.?}" @echo "m files: ${FILES:Mm*}" _EOF_ - $MAKE 1> stdout 2> stderr - echo $? > status } desc_test() -- 2.41.0