From patchwork Fri Dec 31 16:13:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francis Laniel X-Patchwork-Id: 1574406 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.a=rsa-sha256 header.s=google header.b=HPHOjT2h; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JQVg81087z9s0r for ; Sat, 1 Jan 2022 03:18:12 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 91A8E8371B; Fri, 31 Dec 2021 17:16:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="HPHOjT2h"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D12728304A; Fri, 31 Dec 2021 17:14:18 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9D5FD82FB5 for ; Fri, 31 Dec 2021 17:14:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=francis.laniel@amarulasolutions.com Received: by mail-wr1-x42e.google.com with SMTP id k18so19942933wrg.11 for ; Fri, 31 Dec 2021 08:14:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=98e0mbLXRnLI8IlxnjpcWBf+gA05Y3lwmyEV3pT8pX0=; b=HPHOjT2h2Iwcl7l2N4MywC2GCVJk8wnMDyTDnxrCgMQ3WajJ61/FlfqK7O+iOCtcwz 4j8HVcX3mkk2IGm0q8OLR4dBp5EhN1KL2B6gjikmDVEa+V1MztU3z+oEM0b1xopUfr7d 0zVwdK8PU3FGmmFzjrzdxiCvCOKMupVGjUURM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=98e0mbLXRnLI8IlxnjpcWBf+gA05Y3lwmyEV3pT8pX0=; b=fVgELI6ddR2DOWrC8ezLyPM05/KtJMnYNmMb1YDtfFGlZxi7T89ApMd3gUPUduTRs6 +LFs9cizRhDI30ihMJfpfDztNQoEENww7Jub2gli0bwY9agA0ul4bb8+t99Cu1oSzg5g CFPGKzdnW91sf45gqTJHJ/e2anDw6nuxWNj0XO8HveaiG0VKTN7J84supnXoh2M0sxu3 E8fPnmTzVZ4Xgds4VJo0POqwn3RcmQjf4utz5xjteoOJzz1jB9+BpEOzLuErjkI9w8jj 51EnCqy6yexHcnIy4XzRbDanDJUaaSEq7AALEhlENNxaGMzL82fZU0qpKJYC8Rrc7w7o Q3og== X-Gm-Message-State: AOAM530DJ2dn7xHaqd5o+/1zzvaClF6xqBrZvRpV3gvMwOdGDrzdp3lE 1xBnul96HgW5ZLq5FD3zs3gvH2XiRfOW4Q== X-Google-Smtp-Source: ABdhPJxVvs0WJAI2oyMFWmKkWf6qi6/2ZgkMUlD3gXHAEdD1CSj3fdmtigp7X7REbv5WrDMOEXNHvQ== X-Received: by 2002:a05:6000:2a6:: with SMTP id l6mr29621172wry.76.1640967243219; Fri, 31 Dec 2021 08:14:03 -0800 (PST) Received: from pwmachine.home ([2a01:cb14:983:1f00:eef7:8bf8:8ee0:cb1a]) by smtp.gmail.com with ESMTPSA id f6sm31855522wmq.6.2021.12.31.08.14.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Dec 2021 08:14:02 -0800 (PST) From: Francis Laniel To: u-boot@lists.denx.de Cc: Marek Behun , Michael Nazzareno Trimarchi , Simon Glass , Wolfgang Denk , Harald Seiler , Francis Laniel Subject: [RFC PATCH v1 03/21] test/py: hush_if_test: Remove the test file. Date: Fri, 31 Dec 2021 17:13:09 +0100 Message-Id: <20211231161327.24918-4-francis.laniel@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211231161327.24918-1-francis.laniel@amarulasolutions.com> References: <20211231161327.24918-1-francis.laniel@amarulasolutions.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Commit 9087ab2cc4 ("test/py: hush_if_test: Remove the test file.") translated this test to a C test, so this python file is no more needed. Signed-off-by: Francis Laniel Reviewed-by: Simon Glass --- test/py/tests/test_hush_if_test.py | 184 ----------------------------- 1 file changed, 184 deletions(-) delete mode 100644 test/py/tests/test_hush_if_test.py diff --git a/test/py/tests/test_hush_if_test.py b/test/py/tests/test_hush_if_test.py deleted file mode 100644 index 37c1608bb2..0000000000 --- a/test/py/tests/test_hush_if_test.py +++ /dev/null @@ -1,184 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved. - -# Test operation of the "if" shell command. - -import os -import os.path -import pytest - -# TODO: These tests should be converted to a C test. -# For more information please take a look at the thread -# https://lists.denx.de/pipermail/u-boot/2019-October/388732.html - -pytestmark = pytest.mark.buildconfigspec('hush_parser') - -# The list of "if test" conditions to test. -subtests = ( - # Base if functionality. - - ('true', True), - ('false', False), - - # Basic operators. - - ('test aaa = aaa', True), - ('test aaa = bbb', False), - - ('test aaa != bbb', True), - ('test aaa != aaa', False), - - ('test aaa < bbb', True), - ('test bbb < aaa', False), - - ('test bbb > aaa', True), - ('test aaa > bbb', False), - - ('test 123 -eq 123', True), - ('test 123 -eq 456', False), - - ('test 123 -ne 456', True), - ('test 123 -ne 123', False), - - ('test 123 -lt 456', True), - ('test 123 -lt 123', False), - ('test 456 -lt 123', False), - - ('test 123 -le 456', True), - ('test 123 -le 123', True), - ('test 456 -le 123', False), - - ('test 456 -gt 123', True), - ('test 123 -gt 123', False), - ('test 123 -gt 456', False), - - ('test 456 -ge 123', True), - ('test 123 -ge 123', True), - ('test 123 -ge 456', False), - - # Octal tests - - ('test 010 -eq 010', True), - ('test 010 -eq 011', False), - - ('test 010 -ne 011', True), - ('test 010 -ne 010', False), - - # Hexadecimal tests - - ('test 0x2000000 -gt 0x2000001', False), - ('test 0x2000000 -gt 0x2000000', False), - ('test 0x2000000 -gt 0x1ffffff', True), - - # Mixed tests - - ('test 010 -eq 10', False), - ('test 010 -ne 10', True), - ('test 0xa -eq 10', True), - ('test 0xa -eq 012', True), - - ('test 2000000 -gt 0x1ffffff', False), - ('test 0x2000000 -gt 1ffffff', True), - ('test 0x2000000 -lt 1ffffff', False), - ('test 0x2000000 -eq 2000000', False), - ('test 0x2000000 -ne 2000000', True), - - ('test -z ""', True), - ('test -z "aaa"', False), - - ('test -n "aaa"', True), - ('test -n ""', False), - - # Inversion of simple tests. - - ('test ! aaa = aaa', False), - ('test ! aaa = bbb', True), - ('test ! ! aaa = aaa', True), - ('test ! ! aaa = bbb', False), - - # Binary operators. - - ('test aaa != aaa -o bbb != bbb', False), - ('test aaa != aaa -o bbb = bbb', True), - ('test aaa = aaa -o bbb != bbb', True), - ('test aaa = aaa -o bbb = bbb', True), - - ('test aaa != aaa -a bbb != bbb', False), - ('test aaa != aaa -a bbb = bbb', False), - ('test aaa = aaa -a bbb != bbb', False), - ('test aaa = aaa -a bbb = bbb', True), - - # Inversion within binary operators. - - ('test ! aaa != aaa -o ! bbb != bbb', True), - ('test ! aaa != aaa -o ! bbb = bbb', True), - ('test ! aaa = aaa -o ! bbb != bbb', True), - ('test ! aaa = aaa -o ! bbb = bbb', False), - - ('test ! ! aaa != aaa -o ! ! bbb != bbb', False), - ('test ! ! aaa != aaa -o ! ! bbb = bbb', True), - ('test ! ! aaa = aaa -o ! ! bbb != bbb', True), - ('test ! ! aaa = aaa -o ! ! bbb = bbb', True), -) - -def exec_hush_if(u_boot_console, expr, result): - """Execute a shell "if" command, and validate its result.""" - - config = u_boot_console.config.buildconfig - maxargs = int(config.get('config_sys_maxargs', '0')) - args = len(expr.split(' ')) - 1 - if args > maxargs: - u_boot_console.log.warning('CONFIG_SYS_MAXARGS too low; need ' + - str(args)) - pytest.skip() - - cmd = 'if ' + expr + '; then echo true; else echo false; fi' - response = u_boot_console.run_command(cmd) - assert response.strip() == str(result).lower() - -@pytest.mark.buildconfigspec('cmd_echo') -@pytest.mark.parametrize('expr,result', subtests) -def test_hush_if_test(u_boot_console, expr, result): - """Test a single "if test" condition.""" - - exec_hush_if(u_boot_console, expr, result) - -def test_hush_z(u_boot_console): - """Test the -z operator""" - u_boot_console.run_command('setenv ut_var_nonexistent') - u_boot_console.run_command('setenv ut_var_exists 1') - exec_hush_if(u_boot_console, 'test -z "$ut_var_nonexistent"', True) - exec_hush_if(u_boot_console, 'test -z "$ut_var_exists"', False) - u_boot_console.run_command('setenv ut_var_exists') - -# We might test this on real filesystems via UMS, DFU, 'save', etc. -# Of those, only UMS currently allows file removal though. -@pytest.mark.buildconfigspec('cmd_echo') -@pytest.mark.boardspec('sandbox') -def test_hush_if_test_host_file_exists(u_boot_console): - """Test the "if test -e" shell command.""" - - test_file = u_boot_console.config.result_dir + \ - '/creating_this_file_breaks_u_boot_tests' - - try: - os.unlink(test_file) - except: - pass - assert not os.path.exists(test_file) - - expr = 'test -e hostfs - ' + test_file - exec_hush_if(u_boot_console, expr, False) - - try: - with open(test_file, 'wb'): - pass - assert os.path.exists(test_file) - - expr = 'test -e hostfs - ' + test_file - exec_hush_if(u_boot_console, expr, True) - finally: - os.unlink(test_file) - - expr = 'test -e hostfs - ' + test_file - exec_hush_if(u_boot_console, expr, False)