From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 13:29:56 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 68FC35E674F; Sat, 10 Apr 2021 13:29:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHbTJ29Tjz3Jjs; Sat, 10 Apr 2021 13:29:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1C8C91223A; Sat, 10 Apr 2021 13:29:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13ADTtDa001898; Sat, 10 Apr 2021 13:29:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13ADTtOa001897; Sat, 10 Apr 2021 13:29:55 GMT (envelope-from git) Date: Sat, 10 Apr 2021 13:29:55 GMT Message-Id: <202104101329.13ADTtOa001897@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: 502d647d75c8 - stable/13 - tests/sys/netgraph: Further CI fixes MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 502d647d75c81ea63735b898b94ebad0de13c58d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 13:29:56 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=502d647d75c81ea63735b898b94ebad0de13c58d commit 502d647d75c81ea63735b898b94ebad0de13c58d Author: Alex Richardson AuthorDate: 2021-03-19 18:34:29 +0000 Commit: Alex Richardson CommitDate: 2021-04-10 12:53:36 +0000 tests/sys/netgraph: Further CI fixes I was trying to debug why this test is working locally but failing in CI. While doing so I made some small changes to allow running it with set -e. It turns out the problem is that find_iface does not return anything in Jenkins, so all following tests fail with obscure error messages. To handle this case exit early if $eth is empty. Reviewed By: lwhsu Differential Revision: https://reviews.freebsd.org/D29340 (cherry picked from commit 7dd1f932c1f51bfe10da7bc8875879cdcdd40821) --- tests/sys/netgraph/ng_macfilter_test.sh | 57 +++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/tests/sys/netgraph/ng_macfilter_test.sh b/tests/sys/netgraph/ng_macfilter_test.sh index 269de3e130aa..482f32e5d335 100755 --- a/tests/sys/netgraph/ng_macfilter_test.sh +++ b/tests/sys/netgraph/ng_macfilter_test.sh @@ -29,6 +29,8 @@ # # $FreeBSD$ +set -e + progname="$(basename $0 .sh)" entries_lst="/tmp/$progname.entries.lst" entries2_lst="/tmp/$progname.entries2.lst" @@ -124,7 +126,7 @@ test_not_ok () { local msg="$1" _test_next - _test_fails + _test_fail echo "not ok $TSTNR - $msg" return 1 @@ -183,9 +185,24 @@ test_ge () { test_not_ok "$v1 <= $v2 $msg" fi } -test_rc () { test_eq $? $1 "$2"; } -test_failure () { test_ne $? 0 "$1"; } -test_success () { test_eq $? 0 "$1"; } +test_failure () { + msg=$1 + shift + if ! "$@"; then + test_ok "$msg - \"$@\" failed as expected" + else + test_not_ok "$msg - expected \"$@\" to fail but succeeded" + fi +} +test_success () { + msg=$1 + shift + if ! "$@"; then + test_not_ok "$msg - \"$@\" failed unexpectedly" + else + test_ok "$msg - \"$@\" succeeded" + fi +} gethooks () { ngctl msg MF: 'gethooks' \ @@ -217,6 +234,13 @@ genmac () { test_title "Setting up system..." load_modules netgraph ng_socket ng_ether ng_macfilter ng_one2many eth=$(find_iface) +if [ -z "$eth" ]; then + echo "1..1" + echo "not ok 1 - Could not find a valid interface" + echo "Available interfaces:" + ifconfig + exit 1 +fi test_comment "Using $eth..." @@ -239,31 +263,23 @@ test_cnt 46 ################################################################################ test_title "Test: Duplicate default hook" -ngctl connect MF: O2M: default many99 2>/dev/null -test_failure "duplicate connect of default hook" - +test_failure "duplicate connect of default hook" ngctl connect MF: O2M: default many99 ################################################################################ test_title "Test: Add and remove hooks" -ngctl connect MF: O2M: xxx1 many$((HOOKS + 1)) -test_success "connect MF:xxx1 to O2M:many$((HOOKS + 1))" -ngctl connect MF: O2M: xxx2 many$((HOOKS + 2)) -test_success "connect MF:xxx2 to O2M:many$((HOOKS + 2))" -ngctl connect MF: O2M: xxx3 many$((HOOKS + 3)) -test_success "connect MF:xxx3 to O2M:many$((HOOKS + 3))" +test_success "connect MF:xxx1 to O2M:many$((HOOKS + 1))" ngctl connect MF: O2M: xxx1 many$((HOOKS + 1)) +test_success "connect MF:xxx2 to O2M:many$((HOOKS + 2))" ngctl connect MF: O2M: xxx2 many$((HOOKS + 2)) +test_success "connect MF:xxx3 to O2M:many$((HOOKS + 3))" ngctl connect MF: O2M: xxx3 many$((HOOKS + 3)) hooks=$(gethooks) test_eq $created_hooks:xxx1:xxx2:xxx3 $hooks 'hooks after adding xxx1-3' -ngctl rmhook MF: xxx1 -test_success "rmhook MF:xxx$i" +test_success "rmhook MF:xxx$i" ngctl rmhook MF: xxx1 hooks=$(gethooks) test_eq $created_hooks:xxx2:xxx3 $hooks 'hooks after removing xxx1' -ngctl rmhook MF: xxx2 -test_success "rmhook MF:xxx$i" +test_success "rmhook MF:xxx$i" ngctl rmhook MF: xxx2 hooks=$(gethooks) test_eq $created_hooks:xxx3 $hooks 'hooks after removing xxx2' -ngctl rmhook MF: xxx3 -test_success "rmhook MF:xxx$i" +test_success "rmhook MF:xxx$i" ngctl rmhook MF: xxx3 hooks=$(gethooks) test_eq $created_hooks $hooks 'hooks after removing xxx3' @@ -418,8 +434,7 @@ done ################################################################################ test_title "Test: Resetting macfilter..." -ngctl msg MF: reset -test_success "**** reset failed" +test_success "**** reset failed" ngctl msg MF: reset test_eq $(countmacs) 0 'MACs in table' test_bail_on_fail