From patchwork Sun Jun 3 18:56:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Opaniuk X-Patchwork-Id: 137608 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp659846lji; Sun, 3 Jun 2018 12:00:47 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLTUkFSC5xxgAMLNAYR3y40fbupUNU9i8a4Fgxdk7cA7qjFHvpEf1SUs59m8k9xkKToLK5L X-Received: by 2002:a50:9f6b:: with SMTP id b98-v6mr21752235edf.219.1528052447847; Sun, 03 Jun 2018 12:00:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528052447; cv=none; d=google.com; s=arc-20160816; b=oA5dsApEjurnHtffKkTKSHHS3AbBOKFoQ4v1ZTV6jSNm2wNIDd5bGT86O8UYS9As1N joeKYdRC8yFvJ9pWm5AhzDa30+dhHB1cxvUbqqj1Qy5rK6kcn9yN1EEuL9LuhH0MdJz5 c1bcGD+TQ66tLTD43WUyxh8qHkMhUtoMEr05aqk3JKJhnHi4vtvxtZ+uqnq9dRsCw3o6 T7myZMkufUZ+WW7ly5QYte3PK31JLCR/snYX2CkwZepozAtTsw7A4VNiJHqSrb9lXLq0 vUzmlACzwbZ/jcZJIlWZw6ELE/vRrirakrNPImdHHi86fT6rGbw5q+1oijDM1ueABe+O 9eEA== 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=nl0hcsJccCbV0GQ2Tuwv2IEdyAUsRoJVXWUOyOJx19LT7SE4sQoli1P+E4ns/E+NJm qHr896gSu/T1r5nutCP7AfCIK6/HFoDOZWkdkEXizcGzOMY5+ZrMwJaEs8hkS5/dQ57R vr9e1B/DrsFSA+XP8yWJDqr1U+om3EJJPoZJQdx+OXFxNVCO2H9dUf9vJAG4VraMhfC4 +e7upWnislxM7KR0gTqH/TOmM9YRPvePLCp2uJF+OSPLN1dimamX0pfFoDSD22DtwDEQ LiaawguWGsXwNDtjnAjWpi6GVT7XPShUGCqDAMYv1DUSktMJwUqCN1qal0W8NvVaTfrD aweQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=F8cTD6GK; 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 t23-v6si5041956edd.288.2018.06.03.12.00.47; Sun, 03 Jun 2018 12:00:47 -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=F8cTD6GK; 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 5B8F5C21D4A; Sun, 3 Jun 2018 18:59:38 +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=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 D845DC21DFF; Sun, 3 Jun 2018 18:57:25 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7796CC21E1B; Sun, 3 Jun 2018 18:57:08 +0000 (UTC) Received: from mail-lf0-f48.google.com (mail-lf0-f48.google.com [209.85.215.48]) by lists.denx.de (Postfix) with ESMTPS id 9660BC21E31 for ; Sun, 3 Jun 2018 18:57:03 +0000 (UTC) Received: by mail-lf0-f48.google.com with SMTP id y20-v6so21857589lfy.0 for ; Sun, 03 Jun 2018 11:57:03 -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=F8cTD6GKZCYIMBc6lxQx88KWDaeamot+RnFt+7BSH6Aw3NOo5QavffKPI+iDZJGJ0U 8XKMZQpVyj+L72dgbQfkntw7/TxWYA8FEIHAU2stotZrtfy+rdHuMhYPlLwvsjAxi71/ rvr5B0zOIdltOQxxRCP1rHYBFBegoBgmBpyl8= 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=E+lpiXKSQQTiVjKivha1fA7oKv9cfDYfyqHx2Tfhd0tJWdTGox8mrn/qmULnIIZRgY 2DgW9lK9FgEFWw7xLiTIxC8vvA9980cU36fWfV++yFbu877HKUdKXUDIflV4DqEgtKSC wgUinkI/muwGAGdFYRAPuLSt+0mPeeEoamFXgocM4ysPuSSlb2veLiQWNF4CljImZ1FS RYoPGNXr5OjJOOOirLecC4Yjfx3b9crrh+7EwBu1xEb0qlHkhQaTI7vSirpybxyhX5HF D4ulCQEHZRDX+p0RnbRNq0Ua0pfnpAeWe9ukr930irYnVY+ISFsTykHJ9woPAtQQEGZM FBqQ== X-Gm-Message-State: ALKqPwed1qW0C/UfeBjQpRSWr+6P4oNHm+IzjSeMSda1aGV+SpuDcmfW Q2XGpCNI2kcqFcroEpvywoWhBz5tSrBeFw== X-Received: by 2002:a19:c203:: with SMTP id l3-v6mr11490256lfc.55.1528052222634; Sun, 03 Jun 2018 11:57:02 -0700 (PDT) Received: from localhost (host-176-36-145-117.la.net.ua. [176.36.145.117]) by smtp.gmail.com with ESMTPSA id u3-v6sm2177703ljk.83.2018.06.03.11.57.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Jun 2018 11:57:02 -0700 (PDT) From: Igor Opaniuk To: u-boot@lists.denx.de Date: Sun, 3 Jun 2018 21:56:42 +0300 Message-Id: <1528052203-29689-8-git-send-email-igor.opaniuk@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528052203-29689-1-git-send-email-igor.opaniuk@linaro.org> References: <1528052203-29689-1-git-send-email-igor.opaniuk@linaro.org> Cc: trini@konsulko.com, praneeth@ti.com, misael.lopez@ti.com, erosca@de.adit-jv.com, joakim.bech@linaro.org Subject: [U-Boot] [PATCH v2 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')