From patchwork Tue Oct 4 02:14:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 2799 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director15.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id GIGRNMsxPGM8IgAAIUCqbw (envelope-from ) for ; Tue, 04 Oct 2022 09:14:51 -0400 Received: from proxy9.mail.iad3b.rsapps.net ([172.31.255.6]) by director15.mail.ord1d.rsapps.net with LMTP id SOhANMsxPGNpaQAAIcMcQg (envelope-from ) for ; Tue, 04 Oct 2022 09:14:51 -0400 Received: from smtp33.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy9.mail.iad3b.rsapps.net with LMTPS id 4ANFDssxPGPNcwAAC4PSzw (envelope-from ) for ; Tue, 04 Oct 2022 09:14:51 -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: smtp33.gate.iad3b.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: 86f2becc-43e6-11ed-a05b-525400fb5834-1-1 Received: from [216.105.38.7] ([216.105.38.7:35040] helo=lists.sourceforge.net) by smtp33.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id B1/E2-03466-AC13C336; Tue, 04 Oct 2022 09:14:51 -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 1ofhkX-0000rx-M5; Tue, 04 Oct 2022 13:14:17 +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 1ofhkV-0000rq-Rb for openvpn-devel@lists.sourceforge.net; Tue, 04 Oct 2022 13:14:15 +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:References: In-Reply-To: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:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=NhQ42HH8XbNR07mSJeC8r1kb3ABHF57tmIwDMI3tJJA=; b=cGxIY1qcJO+BBw2HKi49Yeh89Q 1SJh9ObojNqgbULg4Tpn6y2VffL0aH+5s8N3TtKKaxjiuIm7BX/lDi3YKuERZ0lmjdQ/ES6oxh2wf hpUnac4Ek08j6rAXQ7ox/OsC2MRzd6k2nlGOP+iQ9S5EPofK1n/hhwJQmm4scHQN8zvo=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: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:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=NhQ42HH8XbNR07mSJeC8r1kb3ABHF57tmIwDMI3tJJA=; b=Lzu+yF/on68pihYEreRHD8nLWP 0LekwaCLN4k6eapq1Iq2P/n4Nre5CF5wizVLUI1XftrkmQgtRwV7KLCJk+EaPxLQJvYvNbgLQ0Q85 9vzCEfbdDs3syIbjCIIlYmjl9lp499f+Vf5BpDB561znjf3+HWdyrpTq3riqVKwIIGMk=; Received: from chekov.greenie.muc.de ([193.149.48.178]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1ofhkT-00027B-O3 for openvpn-devel@lists.sourceforge.net; Tue, 04 Oct 2022 13:14:15 +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 294DE3TF095606 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO) for ; Tue, 4 Oct 2022 15:14:03 +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 294DE3Kw095605 for openvpn-devel@lists.sourceforge.net; Tue, 4 Oct 2022 15:14:03 +0200 (CEST) (envelope-from gert) From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Tue, 4 Oct 2022 15:14:03 +0200 Message-Id: <20221004131403.95597-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221004082532.84741-1-gert@greenie.muc.de> References: <20221004082532.84741-1-gert@greenie.muc.de> 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: 1ofhkT-00027B-O3 Subject: [Openvpn-devel] [PATCH v2] 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. v2: replace indent tabs with spaces change [ $V == 1 ] expression to [ $V = 1 ] (POSIXly correct) Signed-off-by: Gert Doering Acked-By: Frank Lichtenheld --- 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..5aabbd5e 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.$$