git: 34478b73bf18 - main - pf tests: Only do post-test logging when specifically enabled

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Sat, 05 Feb 2022 10:07:22 UTC
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=34478b73bf18e4f13b6053f6f338c78f782a1df8

commit 34478b73bf18e4f13b6053f6f338c78f782a1df8
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2022-02-01 17:33:42 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2022-02-05 09:31:51 +0000

    pf tests: Only do post-test logging when specifically enabled
    
    The pf tests have the ability to log state information (pf rules, pf
    states, interfaces, ...) on exit (i.e. on success or on error).
    This is useful, but only in specific cases. When it's not needed it may
    get in the way of clear output.
    
    Test scripts can add 'debug' to the pft_init call to enable this for the
    specified test.
    
    Reviewed by:    brd
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D34133
---
 tests/sys/netpfil/pf/utils.subr | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/sys/netpfil/pf/utils.subr b/tests/sys/netpfil/pf/utils.subr
index 9afd6280707e..a010374993ff 100644
--- a/tests/sys/netpfil/pf/utils.subr
+++ b/tests/sys/netpfil/pf/utils.subr
@@ -59,7 +59,10 @@ pft_onerror()
 
 pft_init()
 {
-	trap pft_onerror EXIT
+	if [ "$1" == "debug" ]
+	then
+		trap pft_onerror EXIT
+	fi
 
 	vnet_init