diff --git a/tests/portcheck/Makefile b/tests/portcheck/Makefile new file mode 100644 index 00000000000..989ca803594 --- /dev/null +++ b/tests/portcheck/Makefile @@ -0,0 +1,99 @@ +# $OpenBSD: Makefile,v 1.1.1.1 2014/02/03 22:28:41 zhuk Exp $ + +# To add a test named ${testname}: +# 1) If test should catch errors, add sample portcheck output to the +# ${testname}.sample file in this directory. Otherwise, this file should +# absent. +# 2) Create test port directory with ${testname} name. +# 3) Add the test to REGRESS_TARGETS. +# 4) If the test doesn't need running plist checks, add the -P to the +# TEST_${testname}_ARGS variable. Do this in the "test-specific parameters" +# section below. + +# user-customizeable +REGRESS_TARGETS ?= t1 t2 t3 t4 t5 +PORTCHECK ?= ${PORTSDIR}/infrastructure/bin/portcheck +PORTCHECK_ARGS ?= +SUBST_CMD ?= ${PORTSDIR}/infrastructure/bin/pkg_subst + +# internal stuff, non-customizable +PORTCHECK_ROOT_DIR = ${.CURDIR:C,/[^/]+/*$,,} +CATEGORY = ${.CURDIR:C,^${PORTSDIR}/,,} +SUBST_ARGS = -c -DCATEGORY=${CATEGORY} +SCANNING_MSG = "scanning ports under the ${PORTSDIR}" + +# test-specific parameters +TEST_t3_ARGS = -A ${CATEGORY}/t3 +TEST_t4_ARGS = -A -P ${CATEGORY}/t4 + +# define tests +.for _t in ${REGRESS_TARGETS} +TEST_${_t}_ARGS ?= +TEST_${_t}_DIR = ${.CURDIR}/${_t} +TEST_${_t}_DIFF_OPTS = +. if ${TEST_${_t}_ARGS:M-A} +TEST_${_t}_DIFF_OPTS += -I ${SCANNING_MSG} +. endif + +# will exist if and only if portcheck returned non-zero +TEST_${_t}_FAIL = ${_t}.failed + +# output of portcheck's stdout and stderr +TEST_${_t}_OUT = ${_t}.pkgpath +TEST_${_t}_ERR = ${_t}.errors + +CLEANFILES += ${TEST_${_t}_FAIL} ${TEST_${_t}_ERR} ${TEST_${_t}_OUT} + +# sample error list, to compare with actual portcheck output +TEST_${_t}_SAMPLE_SRC = ${.CURDIR}/${_t}.sample + +# same as above but after substitution, needed for path independancy +TEST_${_t}_SAMPLE = ${_t}.sample.subst +CLEANFILES += ${TEST_${_t}_SAMPLE} + +. if exists(${TEST_${_t}_SAMPLE_SRC}) +${TEST_${_t}_SAMPLE}: ${TEST_${_t}_SAMPLE_SRC} + @${SUBST_CMD} ${SUBST_ARGS} -DTEST=${_t} $> $@ +${_t}: ${TEST_${_t}_SAMPLE} +. endif + +${_t}: .PHONY + @echo '=> ${_t}' + @rm -f ${TEST_${_t}_FAIL} + @(cd ${TEST_${_t}_DIR}; ${PORTCHECK} ${TEST_${_t}_ARGS}) \ + >${TEST_${_t}_OUT} 2>${TEST_${_t}_ERR} || touch ${TEST_${_t}_FAIL} + +. if exists(${TEST_${_t}_SAMPLE_SRC}) +# there should be errors printed and portcheck should exit with non-zero code + @test -e ${TEST_${_t}_FAIL} || echo "${_t}: portcheck did not fail" + @diff -u ${TEST_${_t}_DIFF_OPTS} ${TEST_${_t}_SAMPLE} ${TEST_${_t}_ERR} +. else +# there should be NO errors printed and portcheck should exit with zero code + @test ! -e ${TEST_${_t}_FAIL} || echo "${_t}: portcheck did not succeed" + +# in -A mode, portcheck still prints to stderr ${SCANNING_MSG} +. if ${TEST_${_t}_ARGS:M-A} + @echo ${SCANNING_MSG} | \ + diff -u ${TEST_${_t}_DIFF_OPTS} - ${TEST_${_t}_ERR} +. else + @test ! -s ${TEST_${_t}_ERR} || { \ + echo "${_t}: portcheck printed errors:"; \ + cat ${TEST_${_t}_ERR}; \ + } +. endif +. endif + +. if ${TEST_${_t}_ARGS:M-A} + @test ! -s ${TEST_${_t}_OUT} || { \ + echo "${_t}: portcheck printed on stdout:"; \ + cat ${TEST_${_t}_OUT}; \ + } +. else + @echo ${CATEGORY}/${_t} | \ + diff -u ${TEST_${_t}_DIFF_OPTS} - ${TEST_${_t}_OUT} +. endif + +.PHONY: ${_t} +.endfor + +.include diff --git a/tests/portcheck/Makefile.inc b/tests/portcheck/Makefile.inc new file mode 100644 index 00000000000..6728dd0ea59 --- /dev/null +++ b/tests/portcheck/Makefile.inc @@ -0,0 +1,3 @@ +# $OpenBSD: Makefile.inc,v 1.1.1.1 2014/02/03 22:28:41 zhuk Exp $ +CATEGORIES += ${PKGPATH:C,/[^/]+$,,} +PERMIT_PACKAGE_CDROM ?= Yes diff --git a/tests/portcheck/t1.sample b/tests/portcheck/t1.sample new file mode 100644 index 00000000000..6ebbe694949 --- /dev/null +++ b/tests/portcheck/t1.sample @@ -0,0 +1,2 @@ +no distinfo in . +missing RDEP on devel/desktop-file-utils diff --git a/tests/portcheck/t1/Makefile b/tests/portcheck/t1/Makefile new file mode 100644 index 00000000000..ee637b2df4e --- /dev/null +++ b/tests/portcheck/t1/Makefile @@ -0,0 +1,6 @@ +# $OpenBSD: Makefile,v 1.1.1.1 2014/02/03 22:28:41 zhuk Exp $ + +COMMENT = test 1 +DISTNAME = test-1 + +.include diff --git a/tests/portcheck/t1/pkg/DESCR b/tests/portcheck/t1/pkg/DESCR new file mode 100644 index 00000000000..f4702ea9cc1 --- /dev/null +++ b/tests/portcheck/t1/pkg/DESCR @@ -0,0 +1 @@ +KCalc is a calculator which offers many mathematical functions. diff --git a/tests/portcheck/t1/pkg/PLIST b/tests/portcheck/t1/pkg/PLIST new file mode 100644 index 00000000000..c236118636a --- /dev/null +++ b/tests/portcheck/t1/pkg/PLIST @@ -0,0 +1,17 @@ +@comment $OpenBSD: PLIST,v 1.1.1.1 2014/02/03 22:28:41 zhuk Exp $ +@conflict kdeutils-<4 +@bin bin/kcalc +lib/libkdeinit4_kcalc.so +share/applications/kde4/kcalc.desktop +share/apps/kcalc/ +share/apps/kcalc/kcalcui.rc +share/apps/kcalc/scienceconstants.xml +share/apps/kconf_update/kcalcrc.upd +share/config.kcfg/kcalc.kcfg +share/doc/HTML/en/kcalc/ +share/doc/HTML/en/kcalc/commands.docbook +share/doc/HTML/en/kcalc/common +share/doc/HTML/en/kcalc/index.cache.bz2 +share/doc/HTML/en/kcalc/index.docbook +@exec %D/bin/update-desktop-database +@unexec-delete %D/bin/update-desktop-database diff --git a/tests/portcheck/t2/Makefile b/tests/portcheck/t2/Makefile new file mode 100644 index 00000000000..fef39d9e10d --- /dev/null +++ b/tests/portcheck/t2/Makefile @@ -0,0 +1,9 @@ +# $OpenBSD: Makefile,v 1.1.1.1 2014/02/03 22:28:41 zhuk Exp $ +# "fixed" version of t1 + +COMMENT = test 1 +DISTNAME = test-1 + +RUN_DEPENDS = devel/desktop-file-utils + +.include diff --git a/tests/portcheck/t2/distinfo b/tests/portcheck/t2/distinfo new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/portcheck/t2/pkg/DESCR b/tests/portcheck/t2/pkg/DESCR new file mode 100644 index 00000000000..f4702ea9cc1 --- /dev/null +++ b/tests/portcheck/t2/pkg/DESCR @@ -0,0 +1 @@ +KCalc is a calculator which offers many mathematical functions. diff --git a/tests/portcheck/t2/pkg/PLIST b/tests/portcheck/t2/pkg/PLIST new file mode 100644 index 00000000000..c236118636a --- /dev/null +++ b/tests/portcheck/t2/pkg/PLIST @@ -0,0 +1,17 @@ +@comment $OpenBSD: PLIST,v 1.1.1.1 2014/02/03 22:28:41 zhuk Exp $ +@conflict kdeutils-<4 +@bin bin/kcalc +lib/libkdeinit4_kcalc.so +share/applications/kde4/kcalc.desktop +share/apps/kcalc/ +share/apps/kcalc/kcalcui.rc +share/apps/kcalc/scienceconstants.xml +share/apps/kconf_update/kcalcrc.upd +share/config.kcfg/kcalc.kcfg +share/doc/HTML/en/kcalc/ +share/doc/HTML/en/kcalc/commands.docbook +share/doc/HTML/en/kcalc/common +share/doc/HTML/en/kcalc/index.cache.bz2 +share/doc/HTML/en/kcalc/index.docbook +@exec %D/bin/update-desktop-database +@unexec-delete %D/bin/update-desktop-database diff --git a/tests/portcheck/t3.sample b/tests/portcheck/t3.sample new file mode 100644 index 00000000000..355cea42c3b --- /dev/null +++ b/tests/portcheck/t3.sample @@ -0,0 +1 @@ +in ${CATEGORY}/${TEST}: missing RDEP on devel/desktop-file-utils diff --git a/tests/portcheck/t3/Makefile b/tests/portcheck/t3/Makefile new file mode 100644 index 00000000000..5af35f1cf0e --- /dev/null +++ b/tests/portcheck/t3/Makefile @@ -0,0 +1,8 @@ +# $OpenBSD: Makefile,v 1.1.1.1 2014/02/03 22:28:41 zhuk Exp $ +# +# Check there are no distinfo checks in -A mode + +COMMENT = test 1 +DISTNAME = test-1 + +.include diff --git a/tests/portcheck/t3/pkg/DESCR b/tests/portcheck/t3/pkg/DESCR new file mode 100644 index 00000000000..f4702ea9cc1 --- /dev/null +++ b/tests/portcheck/t3/pkg/DESCR @@ -0,0 +1 @@ +KCalc is a calculator which offers many mathematical functions. diff --git a/tests/portcheck/t3/pkg/PLIST b/tests/portcheck/t3/pkg/PLIST new file mode 100644 index 00000000000..c236118636a --- /dev/null +++ b/tests/portcheck/t3/pkg/PLIST @@ -0,0 +1,17 @@ +@comment $OpenBSD: PLIST,v 1.1.1.1 2014/02/03 22:28:41 zhuk Exp $ +@conflict kdeutils-<4 +@bin bin/kcalc +lib/libkdeinit4_kcalc.so +share/applications/kde4/kcalc.desktop +share/apps/kcalc/ +share/apps/kcalc/kcalcui.rc +share/apps/kcalc/scienceconstants.xml +share/apps/kconf_update/kcalcrc.upd +share/config.kcfg/kcalc.kcfg +share/doc/HTML/en/kcalc/ +share/doc/HTML/en/kcalc/commands.docbook +share/doc/HTML/en/kcalc/common +share/doc/HTML/en/kcalc/index.cache.bz2 +share/doc/HTML/en/kcalc/index.docbook +@exec %D/bin/update-desktop-database +@unexec-delete %D/bin/update-desktop-database diff --git a/tests/portcheck/t4/Makefile b/tests/portcheck/t4/Makefile new file mode 100644 index 00000000000..9912e271f6b --- /dev/null +++ b/tests/portcheck/t4/Makefile @@ -0,0 +1,9 @@ +# $OpenBSD: Makefile,v 1.1.1.1 2014/02/03 22:28:41 zhuk Exp $ +# +# Won't fail because distinfo checks don't happen for checking +# "existing" ports, and -P is used to skip PLIST checks. + +COMMENT = test 1 +DISTNAME = test-1 + +.include diff --git a/tests/portcheck/t4/pkg/PLIST b/tests/portcheck/t4/pkg/PLIST new file mode 100644 index 00000000000..c236118636a --- /dev/null +++ b/tests/portcheck/t4/pkg/PLIST @@ -0,0 +1,17 @@ +@comment $OpenBSD: PLIST,v 1.1.1.1 2014/02/03 22:28:41 zhuk Exp $ +@conflict kdeutils-<4 +@bin bin/kcalc +lib/libkdeinit4_kcalc.so +share/applications/kde4/kcalc.desktop +share/apps/kcalc/ +share/apps/kcalc/kcalcui.rc +share/apps/kcalc/scienceconstants.xml +share/apps/kconf_update/kcalcrc.upd +share/config.kcfg/kcalc.kcfg +share/doc/HTML/en/kcalc/ +share/doc/HTML/en/kcalc/commands.docbook +share/doc/HTML/en/kcalc/common +share/doc/HTML/en/kcalc/index.cache.bz2 +share/doc/HTML/en/kcalc/index.docbook +@exec %D/bin/update-desktop-database +@unexec-delete %D/bin/update-desktop-database diff --git a/tests/portcheck/t5.sample b/tests/portcheck/t5.sample new file mode 100644 index 00000000000..9a8ad6068d9 --- /dev/null +++ b/tests/portcheck/t5.sample @@ -0,0 +1,13 @@ +duplicated assignment of COMMENT at Makefile:7 +patches/patch-xyz does not have $OpenBSD$ RCS tag at the top +extra file: patches/patch-xyz.orig +extra file: patches/qwerty +core dump file found: some.core +no distinfo in . +extra file: ./pkg/qwerty +non-empty WANTLIB- for arch-independent package +kdeui WANTLIB without x11/kde* in MODULES (check other libs, too!) +missing RDEP on devel/desktop-file-utils +missing @exec of update-desktop-database +missing @unexec-delete of update-desktop-database +translation file(s) found without devel/gettext dependency diff --git a/tests/portcheck/t5/Makefile b/tests/portcheck/t5/Makefile new file mode 100644 index 00000000000..2f33d28895b --- /dev/null +++ b/tests/portcheck/t5/Makefile @@ -0,0 +1,13 @@ +# $OpenBSD: Makefile,v 1.1.1.1 2014/02/03 22:28:41 zhuk Exp $ +# +# Check catching most obvious things + +COMMENT = test 1 +COMMENT += 222 + COMMENT = test 1 +DISTNAME = test-1 +PKG_ARCH= * + +WANTLIB = c kdeui + +.include diff --git a/tests/portcheck/t5/patches/patch-xyz b/tests/portcheck/t5/patches/patch-xyz new file mode 100644 index 00000000000..39802f64280 --- /dev/null +++ b/tests/portcheck/t5/patches/patch-xyz @@ -0,0 +1 @@ +stub diff --git a/tests/portcheck/t5/patches/qwerty b/tests/portcheck/t5/patches/qwerty new file mode 100644 index 00000000000..39802f64280 --- /dev/null +++ b/tests/portcheck/t5/patches/qwerty @@ -0,0 +1 @@ +stub diff --git a/tests/portcheck/t5/pkg/PLIST b/tests/portcheck/t5/pkg/PLIST new file mode 100644 index 00000000000..c2c2d18314b --- /dev/null +++ b/tests/portcheck/t5/pkg/PLIST @@ -0,0 +1,5 @@ +@comment $OpenBSD: PLIST,v 1.1.1.1 2014/02/03 22:28:41 zhuk Exp $ +share/applications/kde4/kcalc.desktop +share/doc/HTML/en/kcalc/index.cache.bz2 +share/doc/HTML/en/kcalc/index.docbook +share/locale/zh_CN/LC_MESSAGES/gwenview.mo diff --git a/tests/portcheck/t5/pkg/qwerty b/tests/portcheck/t5/pkg/qwerty new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/tests/portcheck/t5/pkg/qwerty @@ -0,0 +1 @@ +