From patchwork Sun Feb 6 18:36:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francis Laniel X-Patchwork-Id: 1589013 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=U4gf46Ev; 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) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JsJ194vMNz9s1l for ; Mon, 7 Feb 2022 05:37:49 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2247E83BBD; Sun, 6 Feb 2022 19:37:41 +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="U4gf46Ev"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E6FEF83BCC; Sun, 6 Feb 2022 19:37:39 +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, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) (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 0766383881 for ; Sun, 6 Feb 2022 19:37:33 +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-x430.google.com with SMTP id w11so21171849wra.4 for ; Sun, 06 Feb 2022 10:37:32 -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:mime-version :content-transfer-encoding; bh=VNqiAUNiz64YXxrdRcmfxQkagfdNWWbCu4n4c+JHvTg=; b=U4gf46Ev65UFPEIKYuRzc2WWwDzGBSGj1tx4vFgvNMFoyuhSKx2/OKZprXY7DebslM 4iIcZHxae9PndMNdXFdREnug1Wvqv+YI3tKUP+2DEafeU2r/Na1wjQtuXPE5RhycGkDe 70qFvmOdSBRytdRwSQtr8QR1BFLoBBrKDm/IM= 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:mime-version :content-transfer-encoding; bh=VNqiAUNiz64YXxrdRcmfxQkagfdNWWbCu4n4c+JHvTg=; b=s5T5bN9ubEVfRnc0jOXXwwfZlAyhJVQ87ckgXuiXFbtO918MKs8gqqUnegK2E1i/Yl hsRONbZLog6T1WyywKTxPvUPO6CVi/QenWnZMNXxl2pmi6u8zuJLF5S9lTfiijhWdnCv Hl8G7imQR1fEqkiHx1pFrlqZiuVZNobhjl8T/0OIUu/p/8oW5IZXkVm3Sw9T/U/IXFtn /5cx+o8Gh1GigNAx+cTttrZB3ECvxWTSkPMIeybqin+DP5Enym0cZiGf1vHEjSwQMuT0 X0n7HWHqLcfFzT5jOJrSv9nahIt8Nd2OLUwuUINBFN11k6akD71hS74oyh0HPXb+3tXV i32Q== X-Gm-Message-State: AOAM533pC6Vq329FORLXprVXL5WhSwYP5rI632DR3W96epMGlKnJmZR5 5es6PvOqzdPtRKRPN4+4Tlxxc7lo3gWskQ== X-Google-Smtp-Source: ABdhPJxrFSOmj4gN6jnVm3CqvF4cp3WJyF+kJOOG47R5ExzoV+GT667WqGRSyvJ8a8LZ1DWIFs3vOw== X-Received: by 2002:a5d:59ac:: with SMTP id p12mr7159681wrr.286.1644172652412; Sun, 06 Feb 2022 10:37:32 -0800 (PST) Received: from pwmachine.home ([2a01:cb14:983:1f00:e5b3:218b:cb92:2549]) by smtp.gmail.com with ESMTPSA id ay29sm7095011wmb.38.2022.02.06.10.37.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Feb 2022 10:37:31 -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 v2 00/21] Modernize U-Boot shell Date: Sun, 6 Feb 2022 19:36:56 +0100 Message-Id: <20220206183717.57446-1-francis.laniel@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.5 at phobos.denx.de X-Virus-Status: Clean Hi. First I hope you are fine and the same for your relatives. During 2021 summer, Sean Anderson wrote a contribution to add a new shell, based on LIL, to U-Boot [1][2]. While one of the goals of this contribution was to address the fact actual U-Boot shell, which is based on Busybox hush, is old there was a discussion about adding a new shell versus updating the actual one [3][4]. So, in this series, with Harald Seiler, we updated the actual U-Boot shell to reflect what is currently in Busybox source code. Basically, this contribution is about taking a snapshot of Busybox shell/hush.c file (as it exists in commit 37460f5da) and adapt it to suit U-Boot needs. This contribution was written to be as backward-compatible as possible to avoid breaking the existing. So, the 2021 hush flavor offers the same as the actual, that is to say: 1. Variable expansion. 2. Instruction lists (;, && and ||). 3. If, then and else. 4. Loops (for, while and until). No new features offered by Busybox hush were implemented (e.g. functions). In terms of testing, new unit tests were added to ut to ensure the new behavior is the same as the old one and it does not add regression. Nonetheless, if old behavior was buggy and fixed upstream, the fix is then added to U-Boot [5]. In sandbox, all of these tests pass smoothly: 2021> printenv board board=sandbox 2021> ut hush Running 20 hush tests ... Failures: 0 Thanks to the effort of Harald Seiler, I was successful booting a board: 2021> printenv board_rev board_rev=iMX8MP 2021> boot ... root@iMX8MPboard:~# fw_printenv board_rev board_rev=iMX8MP I marked this contribution as RFC to indeed collect your opinion. My goal is not to change suddenly actual shell to this one, we clearly need a transition period to think about it. I think it is better to see this contribution as a proof of concept which shows it is possible to update the actual shell. If you want to review it - your review will really be appreciated - here are some information regarding the commits: * commits marked as "test:" deal with unit tests. * commit "cli: Add Busybox upstream hush.c file." copies Busybox shell/hush.c into U-Boot tree, this explain why this commit contains around 12000 additions. * commit "cli: Port Busybox 2021 hush to U-Boot." modifies previously added file to permit us to use this as new shell. The really good idea of #include'ing Busybox code into a wrapper file to define some particular functions while minimizing modifications to upstream code comes from Harald Seiler. * Other commits focus on enabling features we need (e.g. if). Changes since v1: * Renamed cli_hush_2021_upstream.c to cli_hush_upstream.c. * Addressed reviews regarding variable expansion unit test. Francis Laniel (21): 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. cli: Add Busybox upstream hush.c file cli: Port Busybox 2021 hush to U-Boot cli: Add choice for hush parser cli: Add HUSH_2021_PARSER to hush parser choice cli: Enables using hush 2021 parser as command line parser cli: hush_2021: Enable variables expansion for hush 2021 cli: hush_2021: Add functions to be called from run_command() cli: Modify run_command() to add hush 2021 as parser test: hush: Fix instructions list tests for hush 2021 test: hush: Fix variable expansion tests for hush 2021 cli: hush_2021: Enable using \< and \> as string compare operators cli: hush_2021: Enable if keyword test: hush: Fix if tests for hush 2021 cli: hush_2021: Enable loops test: hush: Fix loop tests for hush 2021 cmd/Kconfig | 22 + common/Makefile | 3 +- common/cli.c | 27 +- common/cli_hush_2021.c | 309 + common/cli_hush_upstream.c | 12791 +++++++++++++++++++++++++++ include/cli_hush.h | 8 + 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 | 226 + test/hush/if.c | 351 + test/hush/list.c | 127 + test/hush/loop.c | 84 + test/py/tests/test_hush_if_test.py | 184 - 17 files changed, 13999 insertions(+), 188 deletions(-) create mode 100644 common/cli_hush_2021.c create mode 100644 common/cli_hush_upstream.c 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 and thank you in advance for your reviews. --- [1] https://lists.denx.de/pipermail/u-boot/2021-July/453347.html [2] https://runtimeterror.com/tech/lil/ [3] https://lists.denx.de/pipermail/u-boot/2021-July/453790.html [4] https://lists.denx.de/pipermail/u-boot/2021-July/453848.html [5] https://lists.denx.de/pipermail/u-boot/2021-August/458569.html -- 2.25.1