xref: /netbsd-src/bin/ed/test/ckscripts.sh (revision d7290b768779f8854936afae9bf690197e4de897)
19b082a69Scgd#!/bin/sh -
2*d7290b76Scgd#	$NetBSD: ckscripts.sh,v 1.9 1995/04/23 10:07:34 cgd Exp $
3*d7290b76Scgd#
49b082a69Scgd# This script runs the .ed scripts generated by mkscripts.sh
59b082a69Scgd# and compares their output against the .r files, which contain
69b082a69Scgd# the correct output
79b082a69Scgd
89b082a69ScgdPATH="/bin:/usr/bin:/usr/local/bin/:."
92621a68cSalmED=$1
102621a68cSalm[ ! -x $ED ] && { echo "$ED: cannot execute"; exit 1; }
119b082a69Scgd
1259ddb06dSalm# Run the *.red scripts first, since these don't generate output;
1359ddb06dSalm# they exit with non-zero status
1459ddb06dSalmfor i in *.red; do
1559ddb06dSalm	echo $i
16336e165cScgd	if $i; then
1759ddb06dSalm		echo "*** The script $i exited abnormally  ***"
18336e165cScgd	fi
19336e165cScgddone >errs.o 2>&1
20336e165cScgd
21336e165cScgd# Run the remainding scripts; they exit with zero status
229b082a69Scgdfor i in *.ed; do
2359ddb06dSalm#	base=`expr $i : '\([^.]*\)'`
2483ab6f7fSalm#	base=`echo $i | sed 's/\..*//'`
2559ddb06dSalm	base=`$ED - \!"echo $i" <<-EOF
2659ddb06dSalm		s/\..*
2759ddb06dSalm	EOF`
28336e165cScgd	if $base.ed; then
299b082a69Scgd		if cmp -s $base.o $base.r; then :; else
309b082a69Scgd			echo "*** Output $base.o of script $i is incorrect ***"
319b082a69Scgd		fi
329b082a69Scgd	else
339b082a69Scgd		echo "*** The script $i exited abnormally ***"
349b082a69Scgd	fi
35336e165cScgddone >scripts.o 2>&1
36336e165cScgd
37336e165cScgdgrep -h '\*\*\*' errs.o scripts.o
38