From patchwork Mon Oct 3 21:25:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 2798 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director11.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id IFYcCTTuO2OSWgAAIUCqbw (envelope-from ) for ; Tue, 04 Oct 2022 04:26:28 -0400 Received: from proxy3.mail.ord1d.rsapps.net ([172.30.191.6]) by director11.mail.ord1d.rsapps.net with LMTP id WH0NCTTuO2PDLwAAvGGmqA (envelope-from ) for ; Tue, 04 Oct 2022 04:26:28 -0400 Received: from smtp24.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy3.mail.ord1d.rsapps.net with LMTPS id P6+/CDTuO2MaLwAA7WKfLA (envelope-from ) for ; Tue, 04 Oct 2022 04:26:28 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp24.gate.ord1d.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=none (p=nil; dis=none) header.from=greenie.muc.de X-Suspicious-Flag: YES X-Classification-ID: 3d4cc6fa-43be-11ed-ac3f-52540091a1c4-1-1 Received: from [216.105.38.7] ([216.105.38.7:34578] helo=lists.sourceforge.net) by smtp24.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 6A/62-32074-33EEB336; Tue, 04 Oct 2022 04:26:27 -0400 Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1ofdFN-0003ev-PG; Tue, 04 Oct 2022 08:25:49 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1ofdFM-0003eo-5L for openvpn-devel@lists.sourceforge.net; Tue, 04 Oct 2022 08:25:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=EpbGKi+4HOvGbzxm4qXh22g29U/BU1IpCUG/ugJ+ZZs=; b=ePR3WOTuveylB3qjETFbK1qQmX Pdn2A4gP3kdNE7Dy84wvyyuyIgID5oX7Nt5XM0S25Ika8ighXbI1xQ25x98MpPd8w6J72RsPum4QM RnbIcxyhibI6VCVR0pzylDC5ywSWrUJlwQ/uLKhj0yU8LvS5SSUAtSgC3IQIsyDTUfnY=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:To:From: Sender:Reply-To:Cc:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=EpbGKi+4HOvGbzxm4qXh22g29U/BU1IpCUG/ugJ+ZZs=; b=L AEb1ls1slIU4G6hRnGfnCvsq7BEKg+X9XE6XYVwbvqUq+BW2RWEVD0L6OKfqZhKRjefW5dpSGLGnP n+9SpzEZbsFBFRGcoh3OhsqMlfH/mPilFrfnh2vU2whWhKf73+XDmu8nc8gOjmu9+D3/RptOpP62B GU34zN3PMuLYJKyw=; Received: from chekov.greenie.muc.de ([193.149.48.178]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1ofdFG-00C4QW-TT for openvpn-devel@lists.sourceforge.net; Tue, 04 Oct 2022 08:25:47 +0000 Received: from chekov.greenie.muc.de (localhost [127.0.0.1]) by chekov.greenie.muc.de (8.16.1/8.16.1) with ESMTPS id 2948PWqf084750 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO) for ; Tue, 4 Oct 2022 10:25:32 +0200 (CEST) (envelope-from gert@chekov.greenie.muc.de) Received: (from gert@localhost) by chekov.greenie.muc.de (8.16.1/8.16.1/Submit) id 2948PWjX084749 for openvpn-devel@lists.sourceforge.net; Tue, 4 Oct 2022 10:25:32 +0200 (CEST) (envelope-from gert) From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Tue, 4 Oct 2022 10:25:32 +0200 Message-Id: <20221004082532.84741-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Introduce V= levels to t_lpback.sh self test V=0 - do not print any output at all V=1 - print intro line, summary at end, and "FAIL"+Log for failing tests V=99 - print everything + summary code-wise, introduce test_start() / test_end() functions which do the $? check as well, so the actual testing code is streamlined. Content analysis details: (0.0 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-Headers-End: 1ofdFG-00C4QW-TT Subject: [Openvpn-devel] [PATCH] denoise tests/t_lpback.sh X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox Introduce V= levels to t_lpback.sh self test V=0 - do not print any output at all V=1 - print intro line, summary at end, and "FAIL"+Log for failing tests V=99 - print everything + summary code-wise, introduce test_start() / test_end() functions which do the $? check as well, so the actual testing code is streamlined. Signed-off-by: Gert Doering --- tests/t_lpback.sh | 88 ++++++++++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 31 deletions(-) diff --git a/tests/t_lpback.sh b/tests/t_lpback.sh index 67952994..4cf29d26 100755 --- a/tests/t_lpback.sh +++ b/tests/t_lpback.sh @@ -24,6 +24,52 @@ top_builddir="${top_builddir:-..}" trap "rm -f key.$$ tc-server-key.$$ tc-client-key.$$ log.$$ ; trap 0 ; exit 77" 1 2 15 trap "rm -f key.$$ tc-server-key.$$ tc-client-key.$$ log.$$ ; exit 1" 0 3 +# verbosity, defaults to "1" +V="${V:-1}" +tests_passed=0 +tests_failed=0 + +# ---------------------------------------------------------- +# helper functions +# ---------------------------------------------------------- + +# output progress information +# depending on verbosity level, collect & print only on failure +test_start() +{ + case $V in + 0) outbuf="" ;; # no per-test output at all + 1) outbuf="$@" ;; # compact, details only on failure + *) printf "$@" ;; # print all + esac +} +test_end() +{ + RC=$1 ; LOG=$2 + if [ $RC != 0 ] + then + case $V in + 0) ;; # no per-test output + 1) echo "$outbuf" "FAIL (RC=$RC)"; cat $LOG ;; + *) echo "FAIL (RC=$RC)"; cat $LOG ;; + esac + e=1 + tests_failed=$(( $tests_failed + 1 )) + else + case $V in + 0|1) ;; # no per-test output for 'OK' + *) echo "OK" ;; # print all + esac + tests_passed=$(( $tests_passed + 1 )) + fi +} + +# if running with V=1, give an indication what test runs now +if [ "$V" == 1 ] ; then + echo "$0: running with V=$V, only printing test fails" +fi + + # Get list of supported ciphers from openvpn --show-ciphers output CIPHERS=$(${top_builddir}/src/openvpn/openvpn --show-ciphers | \ sed -e '/The following/,/^$/d' -e s'/ .*//' -e '/^[[:space:]]*$/d') @@ -49,38 +95,20 @@ set +e for cipher in ${CIPHERS} do - printf "Testing cipher ${cipher}... " + test_start "Testing cipher ${cipher}... " ( "${top_builddir}/src/openvpn/openvpn" --test-crypto --secret key.$$ --cipher ${cipher} ) >log.$$ 2>&1 - if [ $? != 0 ] ; then - echo "FAILED" - cat log.$$ - e=1 - else - echo "OK" - fi + test_end $? log.$$ done -printf "Testing tls-crypt-v2 server key generation... " +test_start "Testing tls-crypt-v2 server key generation... " "${top_builddir}/src/openvpn/openvpn" \ --genkey tls-crypt-v2-server tc-server-key.$$ >log.$$ 2>&1 -if [ $? != 0 ] ; then - echo "FAILED" - cat log.$$ - e=1 -else - echo "OK" -fi +test_end $? log.$$ -printf "Testing tls-crypt-v2 key generation (no metadata)... " +test_start "Testing tls-crypt-v2 key generation (no metadata)... " "${top_builddir}/src/openvpn/openvpn" --tls-crypt-v2 tc-server-key.$$ \ --genkey tls-crypt-v2-client tc-client-key.$$ >log.$$ 2>&1 -if [ $? != 0 ] ; then - echo "FAILED" - cat log.$$ - e=1 -else - echo "OK" -fi +test_end $? log.$$ # Generate max-length base64 metadata ('A' is 0b000000 in base64) METADATA="" @@ -89,16 +117,14 @@ while [ $i -lt 732 ]; do METADATA="${METADATA}A" i=$(expr $i + 1) done -printf "Testing tls-crypt-v2 key generation (max length metadata)... " +test_start "Testing tls-crypt-v2 key generation (max length metadata)... " "${top_builddir}/src/openvpn/openvpn" --tls-crypt-v2 tc-server-key.$$ \ --genkey tls-crypt-v2-client tc-client-key.$$ "${METADATA}" \ >log.$$ 2>&1 -if [ $? != 0 ] ; then - echo "FAILED" - cat log.$$ - e=1 -else - echo "OK" +test_end $? log.$$ + +if [ "$V" -ge 1 ] ; then + echo "$0: tests passed: $tests_passed failed: $tests_failed" fi rm key.$$ tc-server-key.$$ tc-client-key.$$ log.$$