Makefile 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. # $OpenBSD: Makefile,v 1.18 2016/03/28 15:37:12 zhuk Exp $
  2. # To add a test named ${testname}:
  3. # 1) If test should catch errors, add sample portcheck output to the
  4. # ${testname}.sample file in this directory. Otherwise, this file should
  5. # absent.
  6. # 2) Create test port directory with ${testname} name.
  7. # 3) Add the test to REGRESS_TARGETS.
  8. # 4) If the test doesn't need running plist checks, add the -P to the
  9. # TEST_${testname}_ARGS variable. Do this in the "test-specific parameters"
  10. # section below.
  11. # user-customizeable
  12. REGRESS_TARGETS ?= t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18
  13. PORTCHECK ?= ${PORTSDIR}/infrastructure/bin/portcheck
  14. PORTCHECK_ARGS ?=
  15. SUBST_CMD ?= ${PORTSDIR}/infrastructure/bin/pkg_subst
  16. # internal stuff, non-customizable
  17. PORTCHECK_ROOT_DIR = ${.CURDIR:C,/[^/]+/*$,,}
  18. CATEGORY = ${.CURDIR:C,^${PORTSDIR}/,,}
  19. SUBST_ARGS = -c -DCATEGORY=${CATEGORY}
  20. SCANNING_MSG = "scanning ports under the ${PORTSDIR}"
  21. # test-specific parameters
  22. TEST_t1_ARGS = -N
  23. TEST_t3_ARGS = -A ${CATEGORY}/t3
  24. TEST_t4_ARGS = -A -P ${CATEGORY}/t4
  25. TEST_t5_ARGS = -N
  26. TEST_t7_ARGS = -P
  27. TEST_t8_ARGS = -P
  28. TEST_t9_ARGS = -P
  29. TEST_t13_ARGS = -P
  30. TEST_t14_ARGS = -P
  31. TEST_t15_ARGS = -P
  32. TEST_t16_ARGS = -P
  33. TEST_t17_ARGS = -P
  34. # define tests
  35. .for _t in ${REGRESS_TARGETS}
  36. TEST_${_t}_ARGS ?=
  37. TEST_${_t}_DIR = ${.CURDIR}/${_t}
  38. TEST_${_t}_DIFF_OPTS =
  39. . if ${TEST_${_t}_ARGS:M-A}
  40. TEST_${_t}_DIFF_OPTS += -I ${SCANNING_MSG}
  41. . endif
  42. # will exist if and only if portcheck returned non-zero
  43. TEST_${_t}_FAIL = ${_t}.failed
  44. # output of portcheck's stdout and stderr
  45. TEST_${_t}_OUT = ${_t}.pkgpath
  46. TEST_${_t}_ERR = ${_t}.errors
  47. CLEANFILES += ${TEST_${_t}_FAIL} ${TEST_${_t}_ERR} ${TEST_${_t}_OUT}
  48. # sample error list, to compare with actual portcheck output
  49. TEST_${_t}_SAMPLE_SRC = ${.CURDIR}/${_t}.sample
  50. # same as above but after substitution, needed for path independancy
  51. TEST_${_t}_SAMPLE = ${_t}.sample.subst
  52. CLEANFILES += ${TEST_${_t}_SAMPLE}
  53. . if exists(${TEST_${_t}_SAMPLE_SRC})
  54. ${TEST_${_t}_SAMPLE}: ${TEST_${_t}_SAMPLE_SRC}
  55. @${SUBST_CMD} ${SUBST_ARGS} -DTEST=${_t} $> $@
  56. ${_t}: ${TEST_${_t}_SAMPLE}
  57. . endif
  58. ${_t}:
  59. @echo '=> ${_t}'
  60. @rm -f ${TEST_${_t}_FAIL}
  61. @(cd ${TEST_${_t}_DIR}; ${PORTCHECK} ${TEST_${_t}_ARGS}) \
  62. >${TEST_${_t}_OUT} 2>${TEST_${_t}_ERR} || touch ${TEST_${_t}_FAIL}
  63. . if exists(${TEST_${_t}_SAMPLE_SRC})
  64. # there should be errors printed and portcheck should exit with non-zero code
  65. @test -e ${TEST_${_t}_FAIL} || echo "${_t}: portcheck did not fail"
  66. @sort <${TEST_${_t}_ERR} | \
  67. diff -u ${TEST_${_t}_DIFF_OPTS} ${TEST_${_t}_SAMPLE} -
  68. . else
  69. # there should be NO errors printed and portcheck should exit with zero code
  70. @test ! -e ${TEST_${_t}_FAIL} || echo "${_t}: portcheck did not succeed"
  71. # in -A mode, portcheck still prints to stderr ${SCANNING_MSG}
  72. . if ${TEST_${_t}_ARGS:M-A}
  73. @echo ${SCANNING_MSG} | \
  74. diff -u ${TEST_${_t}_DIFF_OPTS} - ${TEST_${_t}_ERR}
  75. . else
  76. @test ! -s ${TEST_${_t}_ERR} || { \
  77. echo "${_t}: portcheck printed errors:"; \
  78. cat ${TEST_${_t}_ERR}; \
  79. }
  80. . endif
  81. . endif
  82. . if ${TEST_${_t}_ARGS:M-A}
  83. @test ! -s ${TEST_${_t}_OUT} || { \
  84. echo "${_t}: portcheck printed on stdout:"; \
  85. cat ${TEST_${_t}_OUT}; \
  86. }
  87. . else
  88. @echo ${CATEGORY}/${_t} | \
  89. diff -u ${TEST_${_t}_DIFF_OPTS} - ${TEST_${_t}_OUT}
  90. . endif
  91. .PHONY: ${_t}
  92. .endfor
  93. .include <bsd.regress.mk>