mirror of
https://github.com/opnsense/plugins.git
synced 2026-04-15 22:20:31 -04:00
devel/debug: meet 'qyua', the quick-kyua command ;)
With the tool we can run tests from the source tree given the tests (or a respective prebuilt set) have been installed in the system. It creates "_" prefixed files in order to not taint the otherwise installed tests and set up the few things that the build would for source tree based test files. Underneath eventually it runs kyua-test or kyua-debug depending on the debug command line flag -d. -a runs all the tests in the source tree and -l lists them. For now only supports .sh files and both /usr/src and /usr/tests have to be manually managed, but more to come.
This commit is contained in:
parent
000dcc9bda
commit
45bc2f35af
2 changed files with 145 additions and 1 deletions
|
|
@ -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 \
|
||||
|
|
|
|||
144
devel/debug/src/sbin/qyua
Executable file
144
devel/debug/src/sbin/qyua
Executable file
|
|
@ -0,0 +1,144 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Copyright (c) 2014-2024 Franco Fichtner <franco@opnsense.org>
|
||||
#
|
||||
# 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
|
||||
Loading…
Reference in a new issue