shithub: mc

Download patch

ref: 2b398fd1053b03888f400011dda46d4e36986876
parent: bdf0ed62196f1e67d65b3346ae45d1a0e322bd00
author: S. Gilles <sgilles@umd.edu>
date: Sat Jun 20 17:55:43 EDT 2020

Allow runtest.{rc,sh} to handle subdirectories.

This allows tests consisting of multiple files, including .glue.c files,
so we can check calling convention compliance.

--- a/test/runtest.rc
+++ b/test/runtest.rc
@@ -1,11 +1,22 @@
 #!/bin/rc
 
 rfork e
-MYR_MC=../6/6.out
-MYR_MUSE=../muse/6.out
+MYR_MC=`{cd .. ; pwd}^/6/6.out
+MYR_MUSE=`{cd .. ; pwd}^/muse/6.out
 fn build {
-	rm -f $1 $1^.6 $1^.use
-	../obj/mbld/mbld -Bnone -o 'out' -b $1 -I../obj/lib/std -I../obj/lib/sys -I../obj/lib/regex -r../rt/_myrrt.6 $1^.myr
+	dir=`{echo $1 | grep '.*/'}
+	if(~ $dir '') {
+		rm -f $1 $1^.6 $1^.use
+		../obj/mbld/mbld -Bnone -o 'out' -b $1 -I../obj/lib/std -I../obj/lib/sys -I../obj/lib/regex -r../rt/_myrrt.6 $1^.myr
+	}
+	if not {
+		target=`{echo $1 | grep -o '[^/]*$'}
+		top=`{pwd}
+		mkdir -p out/$dir
+		cd $dir
+		$top/../obj/mbld/mbld -Bnone -o $top/out/$dir -I$top/../obj/lib/std -I$top/../obj/lib/sys -I$top/../obj/lib/regex -r$top/../rt/_myrrt.o clean
+		$top/../obj/mbld/mbld -Bnone -o $top/out/$dir -I$top/../obj/lib/std -I$top/../obj/lib/sys -I$top/../obj/lib/regex -r$top/../rt/_myrrt.o :$target
+	}
 }
 
 fn pass {
@@ -62,7 +73,9 @@
 	res=$1; shift
 
 	echo 'test' $test '<<{!'
+	here=`{pwd}
 	build $test
+	cd $here
 	switch($type) {
 	case E
 		expectstatus $test $res
@@ -77,11 +90,13 @@
 
 fn F {
 	echo 'test ' ^ $1 '<<{!'
+	here=`{pwd}
 	@{ build $1 } >[2=1]
 	if (~ $status '')
 		fail $1
 	if not
 		pass $1
+	cd $here
 }
 
 echo 'MTEST ' `{grep '^[BF]' tests | wc -l}
--- a/test/runtest.sh
+++ b/test/runtest.sh
@@ -1,15 +1,25 @@
 #!/bin/sh
-export PATH=.:$PATH
-export MYR_MC=../6/6m
-export MYR_MUSE=../muse/muse
+export PATH=$(pwd):$PATH
+export MYR_MC=$(cd ..; pwd)/6/6m
+export MYR_MUSE=$(cd ..; pwd)/muse/muse
 ARGS=$*
 NFAILURES=0
 NPASSES=0
 
 build() {
-	rm -f out/$1 out/$1.o out/$1.s out/$1.use
-	mkdir -p out
-	../obj/mbld/mbld -Bnone -o 'out' -b $1 -I../obj/lib/std -I../obj/lib/sys -I../obj/lib/regex -r../rt/_myrrt.o $1.myr
+	dir=$(echo $1 | egrep -o '.*/')
+	if [ -z $dir ]; then
+		rm -f out/$1 out/$1.o out/$1.s out/$1.use
+		mkdir -p out
+		../obj/mbld/mbld -Bnone -o 'out' -b $1 -I../obj/lib/std -I../obj/lib/sys -I../obj/lib/regex -r../rt/_myrrt.o $1.myr
+	else
+		target=$(echo $1 | egrep -o '[^/]*$')
+		top=$(pwd)
+		mkdir -p out/$dir
+		cd $dir
+		$top/../obj/mbld/mbld -Bnone -o $top/out/$dir -I$top/../obj/lib/std -I$top/../obj/lib/sys -I$top/../obj/lib/regex -r$top/../rt/_myrrt.o clean
+		$top/../obj/mbld/mbld -Bnone -o $top/out/$dir -I$top/../obj/lib/std -I$top/../obj/lib/sys -I$top/../obj/lib/regex -r$top/../rt/_myrrt.o :$target
+	fi
 }
 
 pass() {
@@ -95,7 +105,9 @@
 		args="$1"; shift
 	fi
 	echo "test $test <<{!"
+	here=$(pwd)
 	build $test
+	cd $here
 	case $type in
 	"E")  expectstatus "$test" "$res";;
 	"P")  expectprint "$test" "$res";;
@@ -111,12 +123,14 @@
 	fi
 
 	echo "test $1 <<{!"
-	(build $1) > /dev/null 2>1
+	here=$(pwd)
+	(build $1) > /dev/null 2>&1
 	if [ $? -eq '1' ]; then
 		pass $1
 	else
 		fail $1
 	fi
+	cd $here
 }
 
 echo "MTEST $(egrep '^[BF]' tests | wc -l)"
--- a/test/tests
+++ b/test/tests
@@ -4,9 +4,12 @@
 #	B: Expect that this test will build.
 #	F: Expect that this test will not build.
 #    testname: Test case
-#	The test that will run. We will try to
-#	compile 'testname.myr' to 'testname',
-#	and then execute it, verifying the result
+#	The test that will run. If testname contains
+#	no '/', we will try to compile 'testname.myr'
+#	to 'testname', and then execute it, verifying the
+#	result. If the testname is of form a/b/c/.../y/z,
+#	we will try to mbld target z located in subdir
+#	a/b/c/.../y and execute, again verifying.
 #    [E|P|C]: Result type
 #	E tells us that the result is an exit status
 #	P tells us that the result is on stdout,