mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
devel/debug: add opnsense-atf and related glue
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
PLUGIN_NAME= debug
|
||||
PLUGIN_VERSION= 1.5
|
||||
PLUGIN_VERSION= 1.6.d
|
||||
PLUGIN_COMMENT= Debugging Tools
|
||||
PLUGIN_DEPENDS= php${PLUGIN_PHP}-pear-PHP_CodeSniffer \
|
||||
php${PLUGIN_PHP}-pecl-xdebug \
|
||||
phpunit9-php${PLUGIN_PHP} \
|
||||
py${PLUGIN_PYTHON}-pycodestyle \
|
||||
p5-File-Slurp git
|
||||
p5-File-Slurp git jq scapy
|
||||
PLUGIN_MAINTAINER= franco@opnsense.org
|
||||
PLUGIN_TIER= 2
|
||||
|
||||
|
||||
Executable
+132
@@ -0,0 +1,132 @@
|
||||
#!/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.
|
||||
|
||||
PATTERNS="-e ^passed -e ^skipped -e ^failed"
|
||||
TESTDIR=/usr/src/tests/sys/netpfil/pf
|
||||
__RUNNING_INSIDE_ATF_RUN=internal-yes-value
|
||||
|
||||
export __RUNNING_INSIDE_ATF_RUN
|
||||
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo "Must be root."
|
||||
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"
|
||||
PATTERNS="-e ."
|
||||
;;
|
||||
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 TESTFILE in $(find -s ${TESTDIR} -name "*.sh"); do
|
||||
TESTFILE=$(basename ${TESTFILE})
|
||||
echo ${TESTFILE%.sh}
|
||||
done
|
||||
}
|
||||
|
||||
run()
|
||||
{
|
||||
TESTFILE=${1%%:*}
|
||||
TESTCASE=${1#*:}
|
||||
|
||||
TEST=${TESTDIR}/${TESTFILE}.sh
|
||||
|
||||
if [ "${TESTCASE}" = "${1}" ]; then
|
||||
TESTCASE=
|
||||
fi
|
||||
|
||||
if [ ! -f "${TEST}" ]; then
|
||||
echo "Unsupported test case: ${TESTFILE}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
grep ^atf_test_case ${TEST} | tr -d '"' | awk '{ print $2 " " $3}' | while read CASE CLEANUP; do
|
||||
if [ -n "${TESTCASE}" -a "${TESTCASE}" != "${CASE}" ]; then
|
||||
continue
|
||||
fi
|
||||
RESULT=$( (/usr/libexec/atf-sh ${TEST} ${CASE} 2>&1) | grep ${PATTERNS})
|
||||
if [ -n "${CLEANUP}" ]; then
|
||||
/usr/libexec/atf-sh ${TEST} ${CASE}:cleanup > /dev/null 2>&1
|
||||
fi
|
||||
if [ -z "${DO_DEBUG}" ]; then
|
||||
echo ">>> $(basename ${TESTDIR})(${TESTFILE}:${CASE}): ${RESULT}"
|
||||
else
|
||||
echo "${RESULT}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
if [ -n "${DO_LIST}" ]; then
|
||||
list
|
||||
exit 0
|
||||
fi
|
||||
|
||||
TESTS=${@}
|
||||
if [ -n "${DO_ALL}" ]; then
|
||||
TESTS=$(list)
|
||||
fi
|
||||
|
||||
# We could consider copying the whole test setup
|
||||
# somewhere else # but the whole thing needs to
|
||||
# be redesigned anyway. Fudge this locally.
|
||||
chmod 555 ${TESTDIR}/../common/*.sh ${TESTDIR}/../common/*.py ${TESTDIR}/*.py
|
||||
|
||||
for TEST in ${TESTS}; do
|
||||
run ${TEST}
|
||||
done
|
||||
|
||||
if [ -z "${TESTS}" ]; then
|
||||
echo "Nothing to do."
|
||||
fi
|
||||
|
||||
chmod 644 ${TESTDIR}/../common/*.sh ${TESTDIR}/../common/*.py ${TESTDIR}/*.py
|
||||
Reference in New Issue
Block a user