summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2014-10-27 15:05:46 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2014-10-27 15:05:46 +0000
commit09ab5367a008599789224b93c997c9974fc446de (patch)
treeab470d8163df2ac04697638e9e394335473cdab4 /regress
parent430b59d5bb20e538af23032066ead7946bcb20b9 (diff)
Infrastructure for testing HTML output;
this is relevant because we use the HTML output module for man.cgi(8), where broken output can cause security issues.
Diffstat (limited to 'regress')
-rw-r--r--regress/usr.bin/mandoc/Makefile.inc54
-rw-r--r--regress/usr.bin/mandoc/Makefile.sub9
2 files changed, 54 insertions, 9 deletions
diff --git a/regress/usr.bin/mandoc/Makefile.inc b/regress/usr.bin/mandoc/Makefile.inc
index a104d338b17..9baf6bba59c 100644
--- a/regress/usr.bin/mandoc/Makefile.inc
+++ b/regress/usr.bin/mandoc/Makefile.inc
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile.inc,v 1.14 2014/08/14 00:07:55 schwarze Exp $
+# $OpenBSD: Makefile.inc,v 1.15 2014/10/27 15:05:45 schwarze Exp $
.include "Makefile.sub"
@@ -30,6 +30,9 @@ _MANDIFFS += ${t}.diff_man
_UTF8FILES = ${UTF8_TARGETS:C/$/.mandoc_utf8/}
_UTF8DIFFS = ${UTF8_TARGETS:C/$/.diff_utf8/}
+_HTMLFILES = ${HTML_TARGETS:C/$/.mandoc_html/}
+_HTMLDIFFS = ${HTML_TARGETS:C/$/.diff_html/}
+
_LINTFILES =
_LINTDIFFS =
.for t in ${LINT_TARGETS}
@@ -48,16 +51,20 @@ ascii: ascii-clean ${_ASCIIDIFFS}
utf8: utf8-clean ${_UTF8DIFFS}
+html: html-clean ${_HTMLDIFFS}
+
tman: tman-clean ${_MANDIFFS}
lint: lint-clean ${_LINTDIFFS}
-html: ${_HTMLVALS}
+htmlval: ${_HTMLVALS}
# --- suffix rules ---
-.SUFFIXES: .diff_ascii .diff_lint .diff_man .diff_utf8 .in .in_man \
- .mandoc_ascii .mandoc_lint .mandoc_man .mandoc_utf8 \
+.SUFFIXES: .diff_ascii .diff_html .diff_lint .diff_man .diff_utf8 \
+ .in .in_man \
+ .mandoc_ascii .mandoc_html .mandoc_lint \
+ .mandoc_man .mandoc_utf8 \
.out_ascii .out_lint .out_utf8
.in.mandoc_ascii:
@@ -76,6 +83,15 @@ html: ${_HTMLVALS}
@echo "${DIFF} ${.IMPSRC:S/mandoc_utf8$/out_utf8/} ${.IMPSRC}"
@${DIFF} ${.CURDIR}/${.IMPSRC:S/mandoc_utf8$/out_utf8/} ${.IMPSRC}
+.in.mandoc_html:
+ @echo "${MANDOC} ${MOPTS} -Thtml ${.IMPSRC:T} > ${.TARGET}"
+ @${MANDOC} ${MOPTS} -Thtml ${.IMPSRC} | \
+ sed -n '/^BEGINTEST/,/^ENDTEST/p' > ${.TARGET}
+
+.mandoc_html.diff_html:
+ @echo "${DIFF} ${.IMPSRC:S/mandoc_html$/out_html/} ${.IMPSRC}"
+ @${DIFF} ${.CURDIR}/${.IMPSRC:S/mandoc_html$/out_html/} ${.IMPSRC}
+
.in.in_man:
@echo "${MANDOC} ${MOPTS} -Tman ${.IMPSRC:T} > ${.TARGET}"
@${MANDOC} ${MOPTS} -Tman ${.IMPSRC} > ${.TARGET}
@@ -120,6 +136,10 @@ ${t}.validate_html: ${t}.in
${t}: ${t}.diff_utf8
.endfor
+.for t in ${HTML_TARGETS}
+${t}: ${t}.diff_html
+.endfor
+
.for t in ${LINT_TARGETS}
${t}: ${t}.diff_lint
.endfor
@@ -138,6 +158,11 @@ utf8-clean:
rm -f ${_UTF8FILES}
.endif
+html-clean:
+.if !empty(_HTMLFILES)
+ rm -f ${_HTMLFILES}
+.endif
+
tman-clean:
.if !empty(_MANFILES)
rm -f ${_MANFILES}
@@ -148,7 +173,8 @@ lint-clean:
rm -f ${_LINTFILES}
.endif
-.PHONY: ${_ASCIIDIFFS} ${_HTMLVALS} ${_LINTDIFFS} ${_MANDIFFS} ${_UTF8DIFFS}
+.PHONY: ${_ASCIIDIFFS} ${_UTF8DIFFS} ${_HTMLDIFFS} ${_MANDIFFS} \
+ ${_LINTDIFFS} ${_HTMLVALS}
# ----------------------------------------------------------------------
@@ -170,6 +196,7 @@ NOPTS ?= -mandoc
SKIP_GROFF ?=
_OUTFILES =
+_HTMLOUTFILES =
_LINTOUTFILES =
.for t in ${REGRESS_TARGETS}
. if empty(SKIP_GROFF:M${t}) && \
@@ -184,6 +211,10 @@ _OUTFILES += ${t}.out_utf8
. endif
.endfor
+.for t in ${HTML_TARGETS}
+_HTMLOUTFILES += ${t}.out_html
+.endfor
+
.for t in ${LINT_TARGETS}
_LINTOUTFILES += ${t}.out_lint
.endfor
@@ -192,6 +223,8 @@ _LINTOUTFILES += ${t}.out_lint
groff: obj-check ${_OUTFILES}
+html-out: obj-check ${_HTMLOUTFILES}
+
lint-out: obj-check ${_LINTOUTFILES}
# --- single-file targets ---
@@ -220,6 +253,12 @@ ${t}.out_utf8:
. endif
.endfor
+.for t in ${HTML_TARGETS}
+${t}.out_html: ${t}.in
+ ${MANDOC} ${MOPTS} -Thtml ${.ALLSRC} | \
+ sed -n '/^BEGINTEST/,/^ENDTEST/p' > ${.TARGET}
+.endfor
+
.for t in ${LINT_TARGETS}
${t}.out_lint: ${t}.in
-${MANDOC} ${MOPTS} -Tlint ${.ALLSRC} > ${.TARGET} 2>&1
@@ -232,6 +271,11 @@ groff-clean: obj-check
rm -f ${_OUTFILES}
.endif
+html-out-clean: obj-check
+.if !empty(_HTMLOUTFILES)
+ rm -f ${_HTMLOUTFILES}
+.endif
+
lint-out-clean: obj-check
.if !empty(_LINTOUTFILES)
rm -f ${_LINTOUTFILES}
diff --git a/regress/usr.bin/mandoc/Makefile.sub b/regress/usr.bin/mandoc/Makefile.sub
index dc98ec81e73..0e21bbb81ea 100644
--- a/regress/usr.bin/mandoc/Makefile.sub
+++ b/regress/usr.bin/mandoc/Makefile.sub
@@ -1,8 +1,9 @@
-# $OpenBSD: Makefile.sub,v 1.2 2014/08/14 00:07:55 schwarze Exp $
+# $OpenBSD: Makefile.sub,v 1.3 2014/10/27 15:05:45 schwarze Exp $
-_MAIN_TARGETS = ascii utf8 tman lint html
-_CLEAN_TARGETS = ascii-clean utf8-clean tman-clean lint-clean
-_OUT_TARGETS = groff groff-clean lint-out lint-out-clean obj-clean
+_MAIN_TARGETS = ascii utf8 html tman lint htmlval
+_CLEAN_TARGETS = ascii-clean utf8-clean html-clean tman-clean lint-clean
+_OUT_TARGETS = groff groff-clean html-out html-out-clean \
+ lint-out lint-out-clean obj-clean
${_MAIN_TARGETS} ${_CLEAN_TARGETS} ${_OUT_TARGETS}: _SUBDIRUSE