diff --git a/devel/debug/Makefile b/devel/debug/Makefile index a3cfa16c9..08952f769 100644 --- a/devel/debug/Makefile +++ b/devel/debug/Makefile @@ -1,5 +1,5 @@ PLUGIN_NAME= debug -PLUGIN_VERSION= 1.6 +PLUGIN_VERSION= 1.7.d PLUGIN_COMMENT= Debugging Tools PLUGIN_DEPENDS= php${PLUGIN_PHP}-pear-PHP_CodeSniffer \ php${PLUGIN_PHP}-pecl-xdebug \ diff --git a/devel/debug/src/sbin/qyua b/devel/debug/src/sbin/qyua new file mode 100755 index 000000000..6ed0ec999 --- /dev/null +++ b/devel/debug/src/sbin/qyua @@ -0,0 +1,144 @@ +#!/bin/sh + +# Copyright (c) 2014-2024 Franco Fichtner +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +COMPONENT=sys/netpfil/pf + +TESTDIR=/usr/src/tests/${COMPONENT} +DESTDIR=/usr/tests/${COMPONENT} + +if [ "$(id -u)" != "0" ]; then + echo "Must be root." >&2 + exit 1 +fi + +DO_ALL= +DO_DEBUG= +DO_LIST= + +while getopts adlV OPT; do + case ${OPT} in + a) + DO_ALL="-a" + ;; + d) + DO_DEBUG="-d" + ;; + l) + DO_LIST="-l" + ;; + V) + DO_VERBOSE="-V" + ;; + *) + echo "Usage: man ${0##*/}" >&2 + exit 1 + ;; + esac +done + +shift $((OPTIND - 1)) + +if [ -n "${DO_VERBOSE}" ]; then + set -x +fi + +list() +{ + for TEST in $(find -s ${TESTDIR} -name "*.sh"); do + TEST=$(basename ${TEST}) + echo ${TEST%.sh} + done +} + +if [ ! -d "${TESTDIR}" ]; then + echo "Source directory not found: ${TESTDIR}" >&2 + exit 1 +fi + +if [ ! -d "${DESTDIR}" ]; then + echo "Target directory not found: ${DESTDIR}" >&2 + exit 1 +fi + +if [ -n "${DO_LIST}" ]; then + list + exit 0 +fi + +TESTS=${@} +if [ -n "${DO_ALL}" ]; then + TESTS=$(list) +fi + +if [ -z "${TESTS}" ]; then + echo "Nothing to do." + exit 0 +fi + + +# clear from previous run +rm -rf ${DESTDIR}/_* + +# set up a shadow config +cat > ${DESTDIR}/_Kyuafile << EOF +-- Automatically generated by bsd.test.mk. + +syntax(2) + +test_suite("FreeBSD") + +EOF + +for TEST in ${TESTS}; do + if [ -n "${DO_DEBUG}" ]; then + TEST=${TEST%%:*} + fi + + if [ ! -f ${TESTDIR}/${TEST}.sh ]; then + echo "Source file not found: ${TESTDIR}/${TEST}.sh" >&2 + exit 1 + fi + + cat >> ${DESTDIR}/_Kyuafile << EOF +atf_test_program{name="_${TEST}", is_exclusive=true} +EOF + + cat > ${DESTDIR}/_${TEST} << EOF +#! /usr/libexec/atf-sh + +$(cat ${TESTDIR}/${TEST}.sh) +EOF + + chmod 555 ${DESTDIR}/_${TEST} +done + +if [ -z "${DO_DEBUG}" ]; then + exec kyua test -k ${DESTDIR}/_Kyuafile +else + for TEST in ${TESTS}; do + # only support first one + exec kyua debug -k ${DESTDIR}/_Kyuafile _${TEST} + done +fi