On 23:36 Wed 13 Dec , Alexander Bluhm wrote:
> On Wed, Dec 06, 2017 at 11:19:18PM +0300, Sergey Bronnikov wrote:
> > Patch below adds similar scripts for ed, perl, gdb, libkeynote, ctags,
> > m4 and sed. Patch looks huge but it is actually simple. Anyway if you
> > want splitted patch I will resend.
> 
> It is not the patch that is too big but the task.  Try to start
> with one test, get it integrated, learn, and then do the next.
> 
> I have only looked at ed as it is the first in your list.
> 
> It generates a lot of errors:
> *** The script =.red exited abnormally  ***
> *** The script a1.red exited abnormally  ***
> *** The script i1.red exited abnormally  ***
> *** The script i3.red exited abnormally  ***
> *** The script k1.red exited abnormally  ***
> *** The script nl.red exited abnormally  ***
> *** The script r1.red exited abnormally  ***
> *** The script s2.red exited abnormally  ***
> *** The script =.red exited abnormally  ***
> *** The script a1.red exited abnormally  ***
> *** The script i1.red exited abnormally  ***
> *** The script i3.red exited abnormally  ***
> *** The script k1.red exited abnormally  ***
> *** The script nl.red exited abnormally  ***
> *** The script r1.red exited abnormally  ***
> *** The script s2.red exited abnormally  ***
> 
> I think they have to be fixed, before I will run them.  Importing
> failing tests is not a good idea.
> 
> Although the tests fail, the regress framework does not recognize
> it.  Running tests and not caring about the result is pointless.
> 
> Then it creates temparary files in /usr/src/bin/ed/test.  Ideally
> they should be in /usr/src/regress/bin/ed/obj and removed by make
> clean.  If this is too complicated, we could leave it as it is.
> But we should at least try it.
> 
> So please select one regress to start with, make it nicely pass and
> fail, fix the bugs and get your work commited.  I will help you
> there.
> 
> bluhm

I have updated patch for bin/ed and now the most part of tests are
works.

Tests =-err.ed, a1-err.ed, i1-err.ed, k1-err.ed and r1-err.ed
marked as skipped targets because README describe them as known failed.
Tests i3.red, nl.red and s2.red still fails and require some attention.

Patch requires some actions:
- rename =.err to something else, for example eq.err,
 otherwise make will fail
- create regress/bin/ed/obj directory for a temporary files

I hardcoded an absolute path to the test dir in a makescripts target.
I don't know why but this doesn't work with $TESTDIR.

Sergey


diff --git a/bin/ed/test/=.err b/bin/ed/test/eq.err
similarity index 100%
rename from bin/ed/test/=.err
rename to bin/ed/test/eq.err
diff --git a/bin/ed/test/mkscripts.sh b/bin/ed/test/mkscripts.sh
index 2bf9b213235..ef8299770c7 100644
--- a/bin/ed/test/mkscripts.sh
+++ b/bin/ed/test/mkscripts.sh
@@ -6,6 +6,8 @@
 
 PATH="/bin:/usr/bin:/usr/local/bin/:."
 ED=$1
+OBJ=$2
+TESTS=$3
 [ ! -x $ED ] && { echo "$ED: cannot execute"; exit 1; }
 
 for i in *.t; do
@@ -31,13 +33,13 @@ for i in *.t; do
                #!/bin/sh -
                $ED - <<\EOT
                H
-               r $base.d
+               r $TESTS/$base.d
                w $base.o
                EOT
                .
                -2r $i
-               w $base.ed
-               !chmod +x $base.ed
+               w $OBJ/$base.ed
+               !chmod +x $OBJ/$base.ed
        EOF
 done
 
@@ -65,12 +67,12 @@ for i in *.err; do
                #!/bin/sh -
                $ED - <<\EOT
                H
-               r $base.err
+               r $TESTS/$base.err
                w $base.o
                EOT
                .
                -2r $i
-               w ${base}.red
-               !chmod +x ${base}.red
+               w $OBJ/${base}.red
+               !chmod +x $OBJ/${base}.red
        EOF
 done
diff --git a/regress/bin/ed/Makefile b/regress/bin/ed/Makefile
new file mode 100644
index 00000000000..f54039e6065
--- /dev/null
+++ b/regress/bin/ed/Makefile
@@ -0,0 +1,31 @@
+# $OpenBSD $
+
+TESTDIR= ${.CURDIR}/../../../bin/ed/test/
+OBJDIR= ${.CURDIR}/obj
+ED= /bin/ed
+SHELL= /bin/sh
+CLEANFILES+= ${OBJDIR}/*.red ${OBJDIR}/*.ed ${OBJDIR}/*.o
+
+ARGS!= cd ${OBJDIR} && ls *.{ed,red}
+TARGETS?= ${ARGS}
+REGRESS_TARGETS= ${TARGETS:S/^/run-regress-/}
+REGRESS_SKIP_TARGETS+= run-regress-eq.ed \
+                               run-regress-a1.ed \
+                               run-regress-i1.ed \
+                               run-regress-k1.ed \
+                               run-regress-r1.ed
+
+regress: makescripts
+.for a in ${ARGS}
+run-regress-$a: $a
+               @echo '\n======== $a ========'
+               @${SHELL} ${.CURDIR}/ckscripts.sh ${ED} ${OBJDIR} ${TESTDIR} $a
+.endfor
+
+makescripts:
+               @cd ${TESTDIR} && $(SHELL) mkscripts.sh ${ED} ${OBJDIR} 
"/usr/src/bin/ed/test"
+               @cp ${TESTDIR}/e1.t ${TESTDIR}/u.t ${TESTDIR}/r3.t ${OBJDIR}
+
+.PHONY: ${REGRESS_TARGETS}
+
+.include <bsd.regress.mk>
diff --git a/regress/bin/ed/ckscripts.sh b/regress/bin/ed/ckscripts.sh
new file mode 100644
index 00000000000..c78fb7fef15
--- /dev/null
+++ b/regress/bin/ed/ckscripts.sh
@@ -0,0 +1,35 @@
+#!/bin/sh -
+
+PATH="/bin:/usr/bin:/usr/local/bin/:."
+ED=$1
+OBJDIR=$2
+TESTDIR=$3
+TEST=$4
+
+[ ! -x $ED ] && { echo "$ED: cannot execute"; exit 1; }
+[ ! -e $OBJDIR/$TEST ] && { echo "$TEST: does not exist"; exit 1; }
+
+# *.red scripts must exit with non-zero status
+# *.ed scripts must exit with zero status
+ext=$(echo $TEST | cut -d'.' -f2)
+if [[ "$ext" == "ed" ]]; then
+  base=`$ED - \!"echo $TEST" <<-EOF
+       s/\..*
+               EOF`
+  if $OBJDIR/$base.ed; then
+       if cmp -s $TESTDIR/$base.o $TESTDIR/$base.r; then :; else
+               echo "*** Output $TESTDIR/$base.o of script $TEST is incorrect 
***"
+               exit 1
+       fi
+  else
+    echo "*** The script $TEST exited abnormally ***"
+    exit 1
+  fi
+else
+  if $OBJDIR/$TEST; then
+    echo "*** The script $TEST exited abnormally  ***"
+    exit 1
+  else
+    exit 0
+  fi
+fi

Reply via email to