From patchwork Wed Dec 12 17:12:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ruslan Trofymenko X-Patchwork-Id: 153582 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2054792ljp; Wed, 12 Dec 2018 09:16:01 -0800 (PST) X-Google-Smtp-Source: AFSGD/UE69ykPhS+t7ni5oo/vXuSiV/2+bqdqxLgYZi5TgplVYOTx3BKAyd0CAukFmgoP7PjqADE X-Received: by 2002:a17:906:790b:: with SMTP id b11-v6mr15961334ejo.228.1544634961230; Wed, 12 Dec 2018 09:16:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544634961; cv=none; d=google.com; s=arc-20160816; b=Q5bH/0Qg5qQS3e+MgUX2d3l13InaUIH1uE00s2REejQr6ar/4DMNuavhi1RTTBzPRj uWnGdIOEbaIXGXfXsesJ1PdjmKwUE1d4a8zhadtRiT8A1x3uK01y17jgsZdRbeBEyB1l 7P+atbbGfG/c0/qSfVkYh0iSPivYDlE9/i7guaBYUeHTKEJoE5uVO/ugPp3L8F1v8cs3 S2iTsDeXvb0X6/W6PG1nahb3Pj8Ur/IvPijD2LNtFhvAHMiRzwZeMtzPUFFp2QgmgBZ5 91oE53YHI7007mD7wkZkQ4tSxPdJ5P4jSncCopwNZdumSIflndydKAdnnEmii6LY6ONC pfUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature; bh=+UIra8PaPwtnj8rmquQ4V02SZhiKxFsJKlR5IhHlRYc=; b=kIto3WqZsdp5UASBp4q/sQef81gXqDxfhN/ivjzc63WRqXq45SePs2b7lLeyC9+v6z jmfc+A7rvJm5mxpeKJ/l4xqRJJ6sJA6CKZFSBsOVfHBU69Q13yF2mssaqHyzbvHZfWRZ sJIor/ElmX6DtIQcaiZA5R/MDbya7jt9fZ0rthn0OWn1N1TSIk0a7xWc6jGOwhZttDHb FWqvClgNONy6gub0tY2Zk/rTBeSX/3pDby3n01FW0Uq81CB8uc1zA+wgCGDyNIYFKYxE TWU7Zg3WNvG8WNmjwW/IXBsRSDg3DedINvP4XOiIVgPN8lN28OMwQlltv69KsOwdST75 UMaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=X8M+ggWU; 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 y49si827349edd.80.2018.12.12.09.16.00; Wed, 12 Dec 2018 09:16:01 -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=X8M+ggWU; 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 C6FE1C2293E; Wed, 12 Dec 2018 17:13:42 +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 CC223C21FF8; Wed, 12 Dec 2018 17:12:52 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C3F9EC22782; Wed, 12 Dec 2018 17:12:49 +0000 (UTC) Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) by lists.denx.de (Postfix) with ESMTPS id 055DEC22775 for ; Wed, 12 Dec 2018 17:12:44 +0000 (UTC) Received: by mail-lj1-f169.google.com with SMTP id x85-v6so16982008ljb.2 for ; Wed, 12 Dec 2018 09:12:43 -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 :mime-version:content-transfer-encoding; bh=UKBCx6drYikbJNWrDKSg3ERr1i62RZmFh/Iz7ecHmOE=; b=X8M+ggWUua1OWv8n89kcSSR4sUTFxstvcdT/1HZL019jKT9O2YioOFXiR8aXBfr3b4 jVWpFj22r87HZi4ae9jchI7SpP1xGUVLzzRXiHDau/FCrxvk1dXSA46bCPjy7UnTuLjJ 1ZYuvO56s/HMLxiTuuuEpV4hvnzalyPwiYHf8= 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:mime-version:content-transfer-encoding; bh=UKBCx6drYikbJNWrDKSg3ERr1i62RZmFh/Iz7ecHmOE=; b=mswdvJXn2l9FMwdEz0D+ZuER7ezxoBJuSnqmP/0yj/p4Tr1OLa9Tn3aG1ESlr7QzeA ogn2BGxfLKnIfNJ8v/P368MLK6xNUq9u4te6NZ9FdQwXm0hzl0LfeNq2BgkEpEEAEhlQ Q8IdRQu6wzzLVK90r2yO32JPr8d/wOQvH8VneLjOs0XZrzqOXsFshZMmQl3qfRT1rT0R fXvqG8lrOTHGYcCEJuU/xlN/vrE1Imko0w3mQKjtWUqJ1hOjy6C9KPx1Wobsfne9khzJ GltRB4M/VbxBNvMcunFwdR1jKAsdVMu6H+W7L+Wpm6dOc5aaHElyj1pcwlUrzhNeO1kz 3i9Q== X-Gm-Message-State: AA+aEWYuHpPD0PRFg8F73H2n1m0Rih/wqN588gGQDCevoEr0SknlkmWn 4PkvkErLqD/Y34FJrO4dRhB2lRDYJfQ= X-Received: by 2002:a2e:8546:: with SMTP id u6-v6mr3330393ljj.95.1544634763202; Wed, 12 Dec 2018 09:12:43 -0800 (PST) Received: from kbp1-dhp-f54913.synapse.com ([195.238.92.132]) by smtp.gmail.com with ESMTPSA id t81sm3358020lfe.84.2018.12.12.09.12.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Dec 2018 09:12:42 -0800 (PST) From: Ruslan Trofymenko To: u-boot@lists.denx.de Date: Wed, 12 Dec 2018 19:12:32 +0200 Message-Id: <1544634754-3435-6-git-send-email-ruslan.trofymenko@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544634754-3435-1-git-send-email-ruslan.trofymenko@linaro.org> References: <1544634754-3435-1-git-send-email-ruslan.trofymenko@linaro.org> MIME-Version: 1.0 Cc: Tom Rini , Praneeth Bajjuri , Alistair Strachan Subject: [U-Boot] [PATCH v2 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add sandbox test for 'ab_select' command. Test: ./test/py/test.py --bd sandbox --build -k test_ab Signed-off-by: Ruslan Trofymenko Reviewed-by: Alistair Strachan Reviewed-by: Sam Protsenko Reviewed-by: Simon Glass --- Changes in v2: * Сhanges related to command renaming * Assertion condition was clarified. Full command output is controlled. 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 5b65c61..b6a642e 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -21,6 +21,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 @@ -49,6 +50,7 @@ CONFIG_CMD_SF=y CONFIG_CMD_SPI=y CONFIG_CMD_USB=y CONFIG_CMD_AXI=y +CONFIG_CMD_AB_SELECT=y CONFIG_CMD_TFTPPUT=y CONFIG_CMD_TFTPSRV=y CONFIG_CMD_RARP=y diff --git a/test/py/tests/test_ab.py b/test/py/tests/test_ab.py new file mode 100644 index 0000000..b90ca87 --- /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_ab_select') +@pytest.mark.requiredtool('sgdisk') +def test_ab(ab_disk_image, u_boot_console): + """Test the 'ab_select' command.""" + + u_boot_console.run_command('host bind 0 ' + ab_disk_image.path) + + output = u_boot_console.run_command('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 'slot_name=a' in output + + output = u_boot_console.run_command('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 'slot_name=b' in output