Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95F10C43214 for ; Fri, 20 Aug 2021 15:49:14 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5281D610FF for ; Fri, 20 Aug 2021 15:49:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5281D610FF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DE53B82BFA; Fri, 20 Aug 2021 17:49:09 +0200 (CEST) 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="Sq3O0IYY"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3055E82BFA; Fri, 20 Aug 2021 17:49:07 +0200 (CEST) Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) (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 5FD7881BDA for ; Fri, 20 Aug 2021 17:49:02 +0200 (CEST) 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-x435.google.com with SMTP id h13so14957284wrp.1 for ; Fri, 20 Aug 2021 08:49:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=fYfjXb2U5VgWmqAxnkcicW4omfWY343nyxGjf7/EGe8=; b=Sq3O0IYY3A0xQ+lHcSWe7V0DCh0XKtIf/0Zrz6AzxBVMONpAHqcwrw3gwt2zAPcKK6 F6IYnQb2T5cyzgXPLZn8R+45GbugY2pqN4xHHAjr0YEwKtJyn+iyFVClI3kgcxyncJIh +t/heVT8c7DhvmSm7W7+noyVsgfE7hqINztUk= 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:mime-version :content-transfer-encoding; bh=fYfjXb2U5VgWmqAxnkcicW4omfWY343nyxGjf7/EGe8=; b=sfpHbJlsaMVHE8i5Ysecd1mXdY+rvyhSry9OYj1bWV19HkDsPXbBkwuJY4rZMOs2Gh yt9jHGmf8tfcxgJrJxYgmCsInq9KWzrumDlU86x9Odr05s6FJ3aUECylklgGmaYhIAtm bM5dnDM4hNZaM6nbvSJ6v4kdfI/K5XtZ+nsvWxEzl6EChsuu45Z99n7E1u2M63Xa+MXO w7WFiApQmtD4A2MJPZiyi9ZN9aojh27uvrLXhB82gXDByqMf+Ok1cs5m45bCncJpljAq JcFWj/3s4ZEi4j/T9EslyZxGbVbkpHHdfLVUNBKu6d5YORiWzj1L8lsppHP2geS2XnuE bEtQ== X-Gm-Message-State: AOAM5338Q5hCbLbBGQkg81GWZWpd+svXiwqLWCzNMytvhqpPPneYRWmF 8poq9iZK5gg8Mx6uu3XcSSu6N55Wj6G2Ng== X-Google-Smtp-Source: ABdhPJzvCSF0QUl5n8eUN6SQ9WdxBFNvYQ18YLcrlvGuarLBHN5rOIG4MWT6VfjHTSR02yxk5Bre4g== X-Received: by 2002:adf:f141:: with SMTP id y1mr11022558wro.173.1629474541913; Fri, 20 Aug 2021 08:49:01 -0700 (PDT) Received: from pwmachine.home ([2a01:cb14:983:1f00:4e0c:e96d:5c36:fa68]) by smtp.gmail.com with ESMTPSA id c13sm2108846wru.73.2021.08.20.08.49.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Aug 2021 08:49:00 -0700 (PDT) From: Francis Laniel To: u-boot@lists.denx.de Cc: michael@amarulasolutions.com, Francis Laniel Subject: [RFC PATCH 0/6] Add C tests for hush Date: Fri, 20 Aug 2021 17:48:33 +0200 Message-Id: <20210820154839.101107-1-francis.laniel@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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 Hi everyone. First, I hope you are fine and the same for your relatives. This series introduces C tests for hush. The main goal of these tests is to act as regression tests in case of hush being modified. During their writings some bugs were found, unfortunately I did not write patches to fix them. First, I think these bugs were present in Busybox when hush was taken from. Also, as the whole U-Boot board scripts seem to work with these bugs maybe correcting them can lead to breaking things somewhere... This is why I marked this series as RFC as I would like the hear the opinion of the community on this problem. Regarding the series, first commit introduces a new subcommand to ut: ut hush. Then, others add tests for the following: * if test condition: All these tests were taken from test_hush_if_test.py which was then removed. * variable expansion: These tests ensures variable expansion is correct. While writing them a bug was found in hush where the following: foo='bar "quux' echo $foo prints: bar quux instead of: bar "quux * commands lists: These tests test several command separated by ';', "&&" and "||". Here also, some bugs were found, indeed the following: false && false || true returns 0 in actual (2021) hush's Busybox, while it returns 1 in U-Boot. * loops: This test is quite simple as we do not have math support in U-Boot, this can be tricky to heavily test while and until loops. To conclude, here is this series diffstat: Francis Laniel (6): test: Add framework to test hush behavior. test: hush: Test hush if/else. test/py: hush_if_test: Remove the test file. test: hush: Test hush variable expansion. test: hush: Test hush commands list. test: hush: Test hush loops. include/test/hush.h | 15 ++ include/test/suites.h | 1 + test/Makefile | 3 + test/cmd_ut.c | 6 + test/hush/Makefile | 10 + test/hush/cmd_ut_hush.c | 20 ++ test/hush/dollar.c | 188 ++++++++++++++++++ test/hush/if.c | 308 +++++++++++++++++++++++++++++ test/hush/list.c | 79 ++++++++ test/hush/loop.c | 64 ++++++ test/py/tests/test_hush_if_test.py | 192 ------------------ 11 files changed, 694 insertions(+), 192 deletions(-) create mode 100644 include/test/hush.h create mode 100644 test/hush/Makefile create mode 100644 test/hush/cmd_ut_hush.c create mode 100644 test/hush/dollar.c create mode 100644 test/hush/if.c create mode 100644 test/hush/list.c create mode 100644 test/hush/loop.c delete mode 100644 test/py/tests/test_hush_if_test.py Best regards. -- 2.25.1