From 536166095cb0d252a8dce6cc2c8bd5e410bb6ecb Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Wed, 13 Nov 2024 08:12:01 +0100 Subject: [PATCH] test: move opnsense-atf to debug plugin --- plist | 1 - src/sbin/opnsense-atf | 135 ------------------------------------------ 2 files changed, 136 deletions(-) delete mode 100755 src/sbin/opnsense-atf diff --git a/plist b/plist index b327566d8..73bddef9d 100644 --- a/plist +++ b/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 diff --git a/src/sbin/opnsense-atf b/src/sbin/opnsense-atf deleted file mode 100755 index 355373e8d..000000000 --- a/src/sbin/opnsense-atf +++ /dev/null @@ -1,135 +0,0 @@ -#!/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. - -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