From patchwork Tue Nov 27 19:57:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruslan Trofymenko X-Patchwork-Id: 152168 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp220996ljp; Tue, 27 Nov 2018 12:15:29 -0800 (PST) X-Google-Smtp-Source: AJdET5exko6NVUc+c0Md12huDmhCzz0GtcyjLmcqIifZZ9825Mr5y6hcb9WdUjN2JzQZQJVpn++i X-Received: by 2002:a17:906:6011:: with SMTP id o17-v6mr24732653ejj.237.1543349729689; Tue, 27 Nov 2018 12:15:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543349729; cv=none; d=google.com; s=arc-20160816; b=pOjfngk0NHcCJI62pJMHQTCirCZgw6ug9E4PGFVFwNVG1pOyOoAiBhZ0e58KHcT5yv /eqPeMVd5AnHhzAmR2OhNzY6OuDJb/iih2wpTlWQSYhdtUNQUmZ7MW9WeNGzjz7/lah6 mrFo0gauXLwklaq0wkQfTU0eYdy8tHGraIUzAGm4K49uV7AOigRo02BEAG1bBz/9wN0+ vs4fgU8H+SKLjaAxAdc512Zz+qusj186/1NsWOBe6UqJkKYychmTuRhN+akvNQTQi9a+ ZlubZSk0GxURY2hro2OxAxMFaU8vRSJ0Wj0pZHCw8NtcSafKTHvoLifOl9Rp3AQcbDzR 75jw== 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; bh=gvJq0oUXy++aLFXsBx5fz1GnBfdDQa5hgpQZxvNaS9k=; b=D0PYKOPm0sE5e9I4eCYY16aMaXDMPoegprTUmbqiYKcFkdS1wSGx1kkinwYSl7viSa rkBISr6EC/8/VEAe2rUmCpGPMGHefGrpKRUcaUGZBSVBtvIQDJvuPlNUxd/V31ow9/oe 1MjFollGLhMYwbe5XRr5QOSEEvcDqQ0m/6Xo3FMjfiLUK2iHoPEKanlawSKRNFFNo/ba K+uWsPlIB8GUN/yoRyGbP9qRAVBdG+Ny3A+UAt8mQWVNmYcuw9KZVRtkJ1ysaIlwmUI7 rePw1LP/m4WnmQlign2MkC4a1giN6SRr+PxYCcoMHhtmpn1KbAwyej7/IyUIlsAb3r9d LnUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=eTfuwRq9; 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 m17si2325646edf.177.2018.11.27.12.15.29; Tue, 27 Nov 2018 12:15:29 -0800 (PST) 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=eTfuwRq9; 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 4D40CC22271; Tue, 27 Nov 2018 20:12:36 +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_H2, 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 04452C222F3; Tue, 27 Nov 2018 20:10:36 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7731BC2213D; Tue, 27 Nov 2018 19:57:32 +0000 (UTC) Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by lists.denx.de (Postfix) with ESMTPS id D5320C2212B for ; Tue, 27 Nov 2018 19:57:31 +0000 (UTC) Received: by mail-lf1-f68.google.com with SMTP id l10so17524968lfh.9 for ; Tue, 27 Nov 2018 11:57:31 -0800 (PST) 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=OpzblhBULa92Trq+cRJm/VnawupM9RxyuctNtApvjy4=; b=eTfuwRq9L6rtIv+xWxVWODnsTMxOroty+4dAPZJ4uMPLKDXUVc1toVFb5yvi0vyL7D hu9p2046VBAEeFJ2P93jk2abu4OHYdc50nnIfmudgc0WY5C+Mq3puDr+lhat3HxhDvlc j3Yn8yWCpmJSLEGecQ2Mqu1KsR6YIdMuClU8I= 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=OpzblhBULa92Trq+cRJm/VnawupM9RxyuctNtApvjy4=; b=bzvZC/Wh+tPRERrxNcHgwMVUzYXZIlp/D3j2XxphMpRZZAeRlgZ/yPDR0yDjJt28Og q+wiAtR/oqTzfXk6TUy5k8UT3f/IlrHchYE2DpRbA8ZyaXZOZrbCAak25BQN7S2+2fKe mqcQfgEGd21J/bZ3CB+9uOtngudjEtk4ocNcFEHWJAIT+v3GtcZzSRuOVN8/AqG3XwMW kSkGu4D5YlnAmnkesada6T+Bw/A89QNwvcoB99fN62WdIfI6gJYCrrtoT/k7xvhittHZ 7RQZH1Qds/CNoCY3wZqUaZXhl6tGaUGSfObSlCOI5PHSSW69/HDKmDxb5X6l8QDXvul2 2XRA== X-Gm-Message-State: AGRZ1gKOYMwywh6Hi3905Pw4u4owbeIgzdT5m/v6Opn6CA8X7GfiOqJu rp0Qopk9GzEekzhtnKFRA6OiiVK8ZcY= X-Received: by 2002:a19:5402:: with SMTP id i2mr19163488lfb.128.1543348651010; Tue, 27 Nov 2018 11:57:31 -0800 (PST) Received: from kbp1-dhp-f54913.synapse.com ([195.238.92.132]) by smtp.gmail.com with ESMTPSA id g12-v6sm738725lja.74.2018.11.27.11.57.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Nov 2018 11:57:30 -0800 (PST) From: Ruslan Trofymenko To: u-boot@lists.denx.de Date: Tue, 27 Nov 2018 21:57:20 +0200 Message-Id: <1543348642-31045-6-git-send-email-ruslan.trofymenko@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543348642-31045-1-git-send-email-ruslan.trofymenko@linaro.org> References: <1543348642-31045-1-git-send-email-ruslan.trofymenko@linaro.org> X-Mailman-Approved-At: Tue, 27 Nov 2018 20:10:30 +0000 Cc: Tom Rini , Praneeth Bajjuri , Alistair Strachan Subject: [U-Boot] [PATCH 5/7] test/py: Add base test case for A/B updates 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" Add sandbox test for 'android_ab_select' command. Test: ./test/py/test.py --bd sandbox --build -k test_ab Signed-off-by: Ruslan Trofymenko Reviewed-by: Simon Glass --- configs/sandbox_defconfig | 2 ++ test/py/tests/test_ab.py | 74 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 test/py/tests/test_ab.py diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 5a744f4..f246f89 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -20,6 +20,7 @@ CONFIG_PRE_CON_BUF_ADDR=0x100000 CONFIG_LOG_MAX_LEVEL=6 CONFIG_LOG_ERROR_RETURN=y CONFIG_DISPLAY_BOARDINFO_LATE=y +CONFIG_ANDROID_AB=y CONFIG_CMD_CPU=y CONFIG_CMD_LICENSE=y CONFIG_CMD_BOOTZ=y @@ -61,6 +62,7 @@ CONFIG_CMD_TIME=y CONFIG_CMD_TIMER=y CONFIG_CMD_SOUND=y CONFIG_CMD_QFW=y +CONFIG_CMD_ANDROID_AB_SELECT=y CONFIG_CMD_BOOTSTAGE=y CONFIG_CMD_PMIC=y CONFIG_CMD_REGULATOR=y diff --git a/test/py/tests/test_ab.py b/test/py/tests/test_ab.py new file mode 100644 index 0000000..f27538e --- /dev/null +++ b/test/py/tests/test_ab.py @@ -0,0 +1,74 @@ +# SPDX-License-Identifier: GPL-2.0 +# (C) Copyright 2018 Texas Instruments, + +# Test A/B update commands. + +import os +import pytest +import u_boot_utils + +class ABTestDiskImage(object): + """Disk Image used by the A/B tests.""" + + def __init__(self, u_boot_console): + """Initialize a new ABTestDiskImage object. + + Args: + u_boot_console: A U-Boot console. + + Returns: + Nothing. + """ + + filename = 'test_ab_disk_image.bin' + + persistent = u_boot_console.config.persistent_data_dir + '/' + filename + self.path = u_boot_console.config.result_dir + '/' + filename + + with u_boot_utils.persistent_file_helper(u_boot_console.log, persistent): + if os.path.exists(persistent): + u_boot_console.log.action('Disk image file ' + persistent + + ' already exists') + else: + u_boot_console.log.action('Generating ' + persistent) + fd = os.open(persistent, os.O_RDWR | os.O_CREAT) + os.ftruncate(fd, 524288) + os.close(fd) + cmd = ('sgdisk', persistent) + u_boot_utils.run_and_log(u_boot_console, cmd) + + cmd = ('sgdisk', '--new=1:64:512', '-c 1:misc', persistent) + u_boot_utils.run_and_log(u_boot_console, cmd) + cmd = ('sgdisk', '-l', persistent) + u_boot_utils.run_and_log(u_boot_console, cmd) + + cmd = ('cp', persistent, self.path) + u_boot_utils.run_and_log(u_boot_console, cmd) + +di = None +@pytest.fixture(scope='function') +def ab_disk_image(u_boot_console): + global di + if not di: + di = ABTestDiskImage(u_boot_console) + return di + +@pytest.mark.boardspec('sandbox') +@pytest.mark.buildconfigspec('android_ab') +@pytest.mark.buildconfigspec('cmd_android_ab_select') +@pytest.mark.requiredtool('sgdisk') +def test_ab(ab_disk_image, u_boot_console): + """Test the 'android_ab_select' command.""" + + u_boot_console.run_command('host bind 0 ' + ab_disk_image.path) + + output = u_boot_console.run_command('android_ab_select slot_name host 0#misc') + assert 're-initializing A/B metadata' in output + assert 'Attempting slot a, tries remaining 7' in output + output = u_boot_console.run_command('printenv slot_name') + assert 'a' in output + + output = u_boot_console.run_command('android_ab_select slot_name host 0:1') + assert 'Attempting slot b, tries remaining 7' in output + output = u_boot_console.run_command('printenv slot_name') + assert 'b' in output