From f04e6d5f68851a660d03aeb831f44bc3f43d9a19 Mon Sep 17 00:00:00 2001 From: sdk Date: Wed, 29 Dec 2021 19:31:01 +0000 Subject: [PATCH] Add regress tests for grep -A, -B and -C flags ok otto@ --- regress/usr.bin/grep/Makefile | 11 ++++++++--- regress/usr.bin/grep/t27.in | 12 ++++++++++++ regress/usr.bin/grep/t27a.out | 8 ++++++++ regress/usr.bin/grep/t27b.out | 8 ++++++++ regress/usr.bin/grep/t27c.out | 11 +++++++++++ 5 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 regress/usr.bin/grep/t27.in create mode 100644 regress/usr.bin/grep/t27a.out create mode 100644 regress/usr.bin/grep/t27b.out create mode 100644 regress/usr.bin/grep/t27c.out diff --git a/regress/usr.bin/grep/Makefile b/regress/usr.bin/grep/Makefile index 6fd13d0b9f3..edb5a524817 100644 --- a/regress/usr.bin/grep/Makefile +++ b/regress/usr.bin/grep/Makefile @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile,v 1.17 2012/12/12 15:11:25 weerd Exp $ +# $OpenBSD: Makefile,v 1.18 2021/12/29 19:31:01 sdk Exp $ REGRESS_TARGETS=t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 \ - t18 t19 t20 t21 t22 t23 t24 t25 t26 + t18 t19 t20 t21 t22 t23 t24 t25 t26 t27 t1: grep t.s ${.CURDIR}/in | diff - ${.CURDIR}/t1.out @@ -102,8 +102,13 @@ t25: t26: echo 'aaab' | grep -o 'a*' | head -n 10 | diff - ${.CURDIR}/t26.out +t27: + grep -A1 'C' ${.CURDIR}/t27.in | diff - ${.CURDIR}/t27a.out + grep -B1 'C' ${.CURDIR}/t27.in | diff - ${.CURDIR}/t27b.out + grep -C1 'C' ${.CURDIR}/t27.in | diff - ${.CURDIR}/t27c.out + .PHONY: t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 -.PHONY: t21 t22 t23 t24 t25 t26 +.PHONY: t21 t22 t23 t24 t25 t26 t27 .include diff --git a/regress/usr.bin/grep/t27.in b/regress/usr.bin/grep/t27.in new file mode 100644 index 00000000000..1967dea5320 --- /dev/null +++ b/regress/usr.bin/grep/t27.in @@ -0,0 +1,12 @@ +A +B +C +D +A +B +C +D +A +B +C +D diff --git a/regress/usr.bin/grep/t27a.out b/regress/usr.bin/grep/t27a.out new file mode 100644 index 00000000000..9320af96aab --- /dev/null +++ b/regress/usr.bin/grep/t27a.out @@ -0,0 +1,8 @@ +C +D +-- +C +D +-- +C +D diff --git a/regress/usr.bin/grep/t27b.out b/regress/usr.bin/grep/t27b.out new file mode 100644 index 00000000000..b8e0f3383d6 --- /dev/null +++ b/regress/usr.bin/grep/t27b.out @@ -0,0 +1,8 @@ +B +C +-- +B +C +-- +B +C diff --git a/regress/usr.bin/grep/t27c.out b/regress/usr.bin/grep/t27c.out new file mode 100644 index 00000000000..becae857c51 --- /dev/null +++ b/regress/usr.bin/grep/t27c.out @@ -0,0 +1,11 @@ +B +C +D +-- +B +C +D +-- +B +C +D -- 2.20.1