From 2b6787043d1f6b7519bbc71449b4b6ef1cf99e1a Mon Sep 17 00:00:00 2001 From: anton Date: Wed, 21 Jun 2017 19:03:30 +0000 Subject: [PATCH] Add regression tests for the filec feature in csh. --- regress/bin/Makefile | 4 +- regress/bin/csh/Makefile | 15 ++++++ regress/bin/csh/filec.sh | 103 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 regress/bin/csh/Makefile create mode 100644 regress/bin/csh/filec.sh diff --git a/regress/bin/Makefile b/regress/bin/Makefile index d809b60b448..d6ec45cced7 100644 --- a/regress/bin/Makefile +++ b/regress/bin/Makefile @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile,v 1.11 2016/07/05 20:01:47 schwarze Exp $ +# $OpenBSD: Makefile,v 1.12 2017/06/21 19:03:30 anton Exp $ -SUBDIR+= cat chmod ksh ln md5 pax ps test +SUBDIR+= cat chmod csh ksh ln md5 pax ps test install: diff --git a/regress/bin/csh/Makefile b/regress/bin/csh/Makefile new file mode 100644 index 00000000000..71b6d33919f --- /dev/null +++ b/regress/bin/csh/Makefile @@ -0,0 +1,15 @@ +REGRESS_TARGETS= filec + +PROG= edit +SRCS= edit.c +CFLAGS+= -Wall +LDADD+= -lutil +CLEANFILES+= edit.c + +edit.c: ${.CURDIR}/../ksh/edit/edit.c + @cp ${.CURDIR}/../ksh/edit/edit.c . + +filec: edit + @sh ${.CURDIR}/filec.sh + +.include diff --git a/regress/bin/csh/filec.sh b/regress/bin/csh/filec.sh new file mode 100644 index 00000000000..3b7dc5bd58a --- /dev/null +++ b/regress/bin/csh/filec.sh @@ -0,0 +1,103 @@ +#!/bin/sh +# +# Copyright (c) 2017 Anton Lindqvist +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +set -e + +testseq() { + stdin=$1 + exp=$(echo "$2") + act=$(echo -n "$stdin" | ./edit csh) + [ "$exp" = "$act" ] && return 0 + + echo input: + echo ">>>${stdin}<<<" + echo -n "$stdin" | hexdump -C + echo expected: + echo ">>>${exp}<<<" + echo -n "$exp" | hexdump -C + echo actual: + echo ">>>${act}<<<" + echo -n "$act" | hexdump -C + + return 1 +} + +# Create a fake HOME with a minimal .cshrc and a few files used for completion. +tmp=$(mktemp -d) +trap 'rm -r $tmp' 0 +touch "${tmp}/complete" "${tmp}/incomplete.1" "${tmp}/incomplete.2" +cat >"${tmp}/.cshrc" <