From patchwork Thu Oct 25 02:39:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 10655375 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4D56B17F3 for ; Thu, 25 Oct 2018 02:40:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B9AB2B658 for ; Thu, 25 Oct 2018 02:40:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 303072B691; Thu, 25 Oct 2018 02:40:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC7AA2B658 for ; Thu, 25 Oct 2018 02:40:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727356AbeJYLLB (ORCPT ); Thu, 25 Oct 2018 07:11:01 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:52360 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727333AbeJYLLB (ORCPT ); Thu, 25 Oct 2018 07:11:01 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:e0bc:761d:9be1:27bc]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id BBAB761B78; Thu, 25 Oct 2018 02:40:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1540435219; bh=y4s23+nnagPVnwJ5P3KUEOqIoIY0Tfmf5ieeyCqPR+Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=yZiQY7XSdJN/0PwWnnoxcKm92MHpI+8tfUFskMFGZX7mn4hjSN6jwzEZ52cgeRPP/ bB1H++xB1II/np58QvhmmV8FmrSdBrp7OA9vyyhyydIFqW4F3bo660DH5Ao/Ihj83K pbf+BFh30Tqwbuht3CQ1fDX67e0VuvHQXPJQUQ6ij5H17ljDPN9tCECw7/ugDJC2iz 7jjGpBgHs7+udU3haYYJq1Pjak9iBYjEUqB8enxvmujVfLpmbsvbXIy8EaSfxhxdjI HBreQZEJG4ZPOLxKf3Oukc42WjWQh6bnhuuVa/yflnDVwqFdRa8ZvWyGfLRGA1Mh5P 1KlzDXCsDtI+8MvYj1h6wqV/BBzLW407CTcYRJtYNY+Vrwim45OP9MBX7ELyQEPx59 /DC7geniH3F8dBs30aaCoIVBcAa75MSN2mOpus2oERttjMg/zcr0DUflI09O2i3lww 6ic4B8ofiVDsMerhr+wCUvFz0F3tkc5SgZZzmVrNTYRN+pp90uP From: "brian m. carlson" To: git@vger.kernel.org Cc: Derrick Stolee , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= , Duy Nguyen , =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v4 05/12] t: add basic tests for our SHA-1 implementation Date: Thu, 25 Oct 2018 02:39:58 +0000 Message-Id: <20181025024005.154208-6-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.19.1.759.g500967bb5e In-Reply-To: <20181025024005.154208-1-sandals@crustytoothpaste.net> References: <20181025024005.154208-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 127.0.1.1 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We have in the past had some unfortunate endianness issues with some SHA-1 implementations we ship, especially on big-endian machines. Add an explicit test using the test helper to catch these issues and point them out prominently. This test can also be used as a staging ground for people testing additional algorithms to verify that their implementations are working as expected. Signed-off-by: brian m. carlson --- t/t0015-hash.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 t/t0015-hash.sh diff --git a/t/t0015-hash.sh b/t/t0015-hash.sh new file mode 100755 index 0000000000..8e763c2c3d --- /dev/null +++ b/t/t0015-hash.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +test_description='test basic hash implementation' +. ./test-lib.sh + + +test_expect_success 'test basic SHA-1 hash values' ' + test-tool sha1 actual && + grep da39a3ee5e6b4b0d3255bfef95601890afd80709 actual && + printf "a" | test-tool sha1 >actual && + grep 86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 actual && + printf "abc" | test-tool sha1 >actual && + grep a9993e364706816aba3e25717850c26c9cd0d89d actual && + printf "message digest" | test-tool sha1 >actual && + grep c12252ceda8be8994d5fa0290a47231c1d16aae3 actual && + printf "abcdefghijklmnopqrstuvwxyz" | test-tool sha1 >actual && + grep 32d10c7b8cf96570ca04ce37f2a19d84240d3a89 actual && + perl -E "for (1..100000) { print q{aaaaaaaaaa}; }" | \ + test-tool sha1 >actual && + grep 34aa973cd4c4daa4f61eeb2bdbad27316534016f actual && + printf "blob 0\0" | test-tool sha1 >actual && + grep e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 actual && + printf "blob 3\0abc" | test-tool sha1 >actual && + grep f2ba8f84ab5c1bce84a7b441cb1959cfc7093b7f actual && + printf "tree 0\0" | test-tool sha1 >actual && + grep 4b825dc642cb6eb9a060e54bf8d69288fbee4904 actual +' + +test_done