mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 08:09:41 +00:00
test: move opnsense-atf to debug plugin
This commit is contained in:
parent
1ff4c95f11
commit
536166095c
1
plist
1
plist
@ -2160,7 +2160,6 @@
|
||||
/usr/local/sbin/carp_service_status
|
||||
/usr/local/sbin/configctl
|
||||
/usr/local/sbin/ifctl
|
||||
/usr/local/sbin/opnsense-atf
|
||||
/usr/local/sbin/opnsense-beep
|
||||
/usr/local/sbin/opnsense-crypt
|
||||
/usr/local/sbin/opnsense-importer
|
||||
|
||||
@ -1,135 +0,0 @@
|
||||
#!/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
|
||||
|
||||
# More loose madness here, best to wrap a package
|
||||
pkg install -Ay py311-scapy jq > /dev/null
|
||||
|
||||
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
|
||||
Loading…
x
Reference in New Issue
Block a user