From patchwork Wed Apr 25 13:18:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Opaniuk X-Patchwork-Id: 134314 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp865691lji; Wed, 25 Apr 2018 06:26:29 -0700 (PDT) X-Google-Smtp-Source: AIpwx49SmlxezDHeQcxJA3lQFWkKCr2iVOEiVQI3GXgXWtos0wOuqDkLuz4oTf+vkSUyoqhggA+E X-Received: by 10.80.216.196 with SMTP id y4mr39052626edj.260.1524662789299; Wed, 25 Apr 2018 06:26:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524662789; cv=none; d=google.com; s=arc-20160816; b=tSKP0WJf8zkHPQLfGGSWZlXeyGH9QAYuf9I9bPIHtPQ9HSOhWSN7s9bl155DloqkxL TBYogSa1TViClWby7zLd4D1DoYMth499b8QKrvfl91OqSDzbINxuLiHSscGpZle3aYlS AJ1rlPDY1SuR3Dke3E922Zk14jFUYUItKHIVa8Au0TbtxmUhNS7bWq/zhDW1f/X18qzU VmthXLvq7ZvX0zPqLMFzcT7lmw2jCRzWpevPuexdDn+7aDU9aB4iyvGmkghoknPTtQPJ XKdDx+IbhEuvh9O2K3CAz/UnSV05tZlDYNWn/E6rvbLx8YM5nINbn+qGCz7zVqWO6ZcY 8Msw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:arc-authentication-results; bh=DJ8tx1eDDFdo3cufV5OhRdJ9Ed/XlCG+Cy5oIdjVeHA=; b=ytG4+9m68l1xoKI80Xf6cRA82ZqVE5lNg/MKXR2Ly3JJT9/HYa6EF+Oej5pIRr9x3L GIdWjnOTdHFCV07yqkldKAUP0Yy8Jgo763FzmuTMHnVf4odKav7S9hVF9FSRhXNOmomX mNjI8JLPaCirfma38WzzzL1CyOGLZd5CJGhIqIxf3Ovla2RLBvyr3YnM8bZ5PmZJICkj 2JMMPW1YEGwJ6rS7wvn9EA7moUsB6/Nksm6BfS+xxlziuwi00rs7QsMl2zR4uDEbGo4f V6J9U/3pV0YctADSkAy7C9d3om9/ANnffzX3lCMlv3JAKEU17m9Duq6Le9y9N9tMMaiW v/Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=XezRTZn+; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id i16si7284147edj.340.2018.04.25.06.26.28; Wed, 25 Apr 2018 06:26:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=XezRTZn+; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id C96E4C21F9F; Wed, 25 Apr 2018 13:24:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 6D2B8C21FF8; Wed, 25 Apr 2018 13:21:06 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B13EFC21F21; Wed, 25 Apr 2018 13:18:22 +0000 (UTC) Received: from mail-lf0-f67.google.com (mail-lf0-f67.google.com [209.85.215.67]) by lists.denx.de (Postfix) with ESMTPS id 5C830C21F9A for ; Wed, 25 Apr 2018 13:18:22 +0000 (UTC) Received: by mail-lf0-f67.google.com with SMTP id j16-v6so8185969lfb.7 for ; Wed, 25 Apr 2018 06:18:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zAPF1FoEIpgNjbluIuRozLo5OAd+ieHFmH6THfuDFXE=; b=XezRTZn+dKOJFwP1ze9bPKG4hmGxcwwUvNv5jI8saNHpkty22FLdFCgfmsrgYgTtLn j01wQrKswA/wPp4ImOBJDpWzbbkoKRtcgQSDlTGapnFWI+47fnJ3qfvdRwcQGytNMggr x9/LWmGPX3L1qI4RbJhudRIcIQtNM2dzoQrOQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zAPF1FoEIpgNjbluIuRozLo5OAd+ieHFmH6THfuDFXE=; b=HBEX67Z6lmH46v6EUzpHELDHYKpCADP98IH5d2bbqLQ60l0eJ4BTIKuf9cNJqpMveA dQc6hXtneTLPtnrbW6CI1aRgvAW38K4h1yQfBr9rxVk+Nvk1d2dEiB9EYGeXRh9YPW+s 5Oul89aAem7UWMxgfWsYyyWUNN1PvnzXYHjAHgxicRTPbQ85BRQ9S8CEAZCQZNGdeWlP bpJ9hShYwDwCaqMYVx7DLCrJX3Xa9gRauiFvZNfXoMu8uiHsorz022wNK1XwIfwFuUCI B9JDPX3J+xP/uauQVAJaMXafR/xOTzpTPl/Krlg6bUgIw4yZBA45aWMziCTKr2IW4r8F fWOA== X-Gm-Message-State: ALQs6tCDjdpPRvF9wEZEE+3WocWPEFs0zfls4HaBM5CbZfJ9abBlnLz4 tnrD0W8OH0bnRvc9TJK+dZQR7rUeqzHP5w== X-Received: by 2002:a19:aacd:: with SMTP id t196-v6mr14746044lfe.60.1524662301300; Wed, 25 Apr 2018 06:18:21 -0700 (PDT) Received: from localhost ([195.238.93.36]) by smtp.gmail.com with ESMTPSA id h11-v6sm2725767lfd.76.2018.04.25.06.18.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Apr 2018 06:18:20 -0700 (PDT) From: Igor Opaniuk To: u-boot@lists.denx.de Date: Wed, 25 Apr 2018 16:18:04 +0300 Message-Id: <1524662285-19617-8-git-send-email-igor.opaniuk@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524662285-19617-1-git-send-email-igor.opaniuk@linaro.org> References: <1524662285-19617-1-git-send-email-igor.opaniuk@linaro.org> X-Mailman-Approved-At: Wed, 25 Apr 2018 13:20:58 +0000 Cc: trini@konsulko.com, praneeth@ti.com, misael.lopez@ti.com, joakim.bech@linaro.org Subject: [U-Boot] [PATCH 7/8] test/py: avb2.0: add tests for avb commands X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 1. Run AVB 2.0 full verification chain, avb verify 2. Check if 'avb get_uuid' works, compare results with 'part list mmc 1' output 3. Test `avb read` commands, which reads N bytes from a partition identified by a name Signed-off-by: Igor Opaniuk --- test/py/tests/test_avb.py | 111 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 test/py/tests/test_avb.py diff --git a/test/py/tests/test_avb.py b/test/py/tests/test_avb.py new file mode 100644 index 0000000..770bdde --- /dev/null +++ b/test/py/tests/test_avb.py @@ -0,0 +1,111 @@ +# Copyright (c) 2018, Linaro Limited +# +# SPDX-License-Identifier: GPL-2.0+ +# +# Android Verified Boot 2.0 Test + +""" +This tests Android Verified Boot 2.0 support in U-boot: + +For additional details about how to build proper vbmeta partition +check doc/README.avb2 + +For configuration verification: +- Corrupt boot partition and check for failure +- Corrupt vbmeta partition and check for failure +""" + +import pytest +import u_boot_utils as util + +# defauld mmc id +mmc_dev = 1 +temp_addr = 0x90000000 +temp_addr2 = 0x90002000 + +def test_avb_verify(u_boot_console): + """Run AVB 2.0 boot verification chain with avb subset of commands + """ + + success_str = "Verification passed successfully" + + response = u_boot_console.run_command('avb init %s' %str(mmc_dev)) + assert response == '' + response = u_boot_console.run_command('avb verify') + assert response.find(success_str) + + +def test_avb_mmc_uuid(u_boot_console): + """Check if 'avb get_uuid' works, compare results with + 'part list mmc 1' output + """ + + response = u_boot_console.run_command('avb init %s' % str(mmc_dev)) + assert response == '' + + response = u_boot_console.run_command('mmc rescan; mmc dev %s' % + str(mmc_dev)) + assert response.find('is current device') + + part_lines = u_boot_console.run_command('mmc part').splitlines() + part_list = {} + cur_partname = "" + + for line in part_lines: + if "\"" in line: + start_pt = line.find("\"") + end_pt = line.find("\"", start_pt + 1) + cur_partname = line[start_pt + 1: end_pt] + + if "guid:" in line: + guid_to_check = line.split("guid:\t") + part_list[cur_partname] = guid_to_check[1] + + # lets check all guids with avb get_guid + for part, guid in part_list.iteritems(): + avb_guid_resp = u_boot_console.run_command('avb get_uuid %s' % part) + assert guid == avb_guid_resp.split("UUID: ")[1] + + +def test_avb_read_rb(u_boot_console): + """Test reading rollback indexes + """ + + response = u_boot_console.run_command('avb init %s' % str(mmc_dev)) + assert response == '' + + response = u_boot_console.run_command('avb read_rb 1') + + +def test_avb_is_unlocked(u_boot_console): + """Test if device is in the unlocked state + """ + + response = u_boot_console.run_command('avb init %s' % str(mmc_dev)) + assert response == '' + + response = u_boot_console.run_command('avb is_unlocked') + + +def test_avb_mmc_read(u_boot_console): + """Test mmc read operation + """ + + response = u_boot_console.run_command('mmc rescan; mmc dev %s 0' % + str(mmc_dev)) + assert response.find('is current device') + + response = u_boot_console.run_command('mmc read 0x%x 0x100 0x1' % temp_addr) + assert response.find('read: OK') + + response = u_boot_console.run_command('avb init %s' % str(mmc_dev)) + assert response == '' + + response = u_boot_console.run_command('avb read_part xloader 0 100 0x%x' % + temp_addr2) + assert response.find('Read 512 bytes') + + # Now lets compare two buffers + response = u_boot_console.run_command('cmp 0x%x 0x%x 40' % + (temp_addr, temp_addr2)) + assert response.find('64 word')