From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 3CCBFC433F5 for ; Sun, 13 Mar 2022 05:48:14 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 84E0381433; Sun, 13 Mar 2022 06:48:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="PMU5mFyU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7DCC58141D; Sun, 13 Mar 2022 06:48:09 +0100 (CET) Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) (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 1F4E981433 for ; Sun, 13 Mar 2022 06:48:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-pl1-x636.google.com with SMTP id q11so10992237pln.11 for ; Sat, 12 Mar 2022 21:48:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+rHuSuEb0eMNy5ZEHRF/UtriUavGVqx2LDv6zVnaikM=; b=PMU5mFyUQQeWSQ1BHbwpRDbOGct7sphncvBG8PcL0Zpy9QVP80BJlWjfxgfZ2BL0w4 ZjFFZbYfvbIPA6nhhAbXceQ4BB/K0gz0LrEsKAinN3m5PtgKZ2krs1eopO3tgJwIAqh4 QO2muYfui3FK/nxE0/JA67uYn1kgxrfzlICOA= 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=+rHuSuEb0eMNy5ZEHRF/UtriUavGVqx2LDv6zVnaikM=; b=OePjLzzKBnTpUEW7PIJ2sQsK9ev7/pYuNpFedvlgVRsc2T6HWvjTuoCgQaog3eGxPn E6FOzHFwCnIP+gPxaWpKdwH8iXkhJuLsFtF5Cg8ZobWlXlLEwjp2rYA0J/z3wqZtjsTU 9sg0oyPZ4XBVSewIZz0IVKqumoM+g1d6wuY/X9E3AhBLfyGjGVgSOziV31GEYVge7UXH TmA5HW1FAYDJk7TPUPrgyCxaYhBe9Ef4mccUzC7rtrQoH0Win5ZuDp95qRmfM52fXKo8 6oi2uTXFw5YZbatEefLdQe+SqmyAMTCDoaPixgcKglwFXHuGNjTftgmNsNVWm3mAeMwp +cBQ== X-Gm-Message-State: AOAM531hy42ynadsQNWmxr7r15i+n5/EVQq+cjdz3PRYkxQPv0kKr5yB ag36AvNSOFWLMAIuRPbQnZaBWvKi8ogQtcdh X-Google-Smtp-Source: ABdhPJwxIDJV+dwYYMPZemOsbstg55d7Sb8IAeNPONzyoH1iujML5y+f5DneGcJCdV87UxhAGTAFJA== X-Received: by 2002:a17:902:ced0:b0:151:a5fa:6b44 with SMTP id d16-20020a170902ced000b00151a5fa6b44mr17955562plg.31.1647150481880; Sat, 12 Mar 2022 21:48:01 -0800 (PST) Received: from sjg1.roam.corp.google.com ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id s8-20020a056a0008c800b004f664655937sm16956647pfu.157.2022.03.12.21.47.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Mar 2022 21:48:01 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Patrick Delaunay , Andy Shevchenko , Heinrich Schuchardt , Joe Hershberger , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Wolfgang Denk Subject: [PATCH] env: Allow text-env tests to run with awk Date: Sat, 12 Mar 2022 22:47:49 -0700 Message-Id: <20220313054749.599896-1-sjg@chromium.org> X-Mailer: git-send-email 2.35.1.723.g4982287a31-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 At present the tests assume that gawk is being used. Adjust the tests so that the names are inserted in alphabetical order, so that awk is happy. Also use PROCINFO to make gawk output in alphabetical order. This is not ideal, since it changes the env-car ordering from what the user provided, but it may be acceptable. Signed-off-by: Simon Glass Reported-by: Patrick Delaunay Fixes: https://source.denx.de/u-boot/u-boot/-/issues/10 --- scripts/env2string.awk | 5 ++++- test/py/tests/test_env.py | 28 ++++++++++++++-------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/scripts/env2string.awk b/scripts/env2string.awk index 1bfe9ed07a4..de470a49941 100644 --- a/scripts/env2string.awk +++ b/scripts/env2string.awk @@ -81,7 +81,10 @@ END { if (do_output) { printf("%s", "#define CONFIG_EXTRA_ENV_TEXT \"") - # Print out all the variables + # Print out all the variables by alphabetic order, if using + # gawk. This allows test_env_test.py to work on both awk (where + # this next line does nothing) + PROCINFO["sorted_in"] = "@ind_str_asc" for (var in vars) { env = vars[var] print var "=" vars[var] "\\0" diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py index b2f3470de94..6d08565f0b5 100644 --- a/test/py/tests/test_env.py +++ b/test/py/tests/test_env.py @@ -554,42 +554,42 @@ def test_env_text(u_boot_console): # two vars check_script('''fred=123 -ernie=456''', 'fred=123\\0ernie=456\\0') +mary=456''', 'fred=123\\0mary=456\\0') # blank lines check_script('''fred=123 -ernie=456 +mary=456 -''', 'fred=123\\0ernie=456\\0') +''', 'fred=123\\0mary=456\\0') # append check_script('''fred=123 -ernie=456 -fred+= 456''', 'fred=123 456\\0ernie=456\\0') +mary=456 +fred+= 456''', 'fred=123 456\\0mary=456\\0') # append from empty check_script('''fred= -ernie=456 -fred+= 456''', 'fred= 456\\0ernie=456\\0') +mary=456 +fred+= 456''', 'fred= 456\\0mary=456\\0') # variable with + in it - check_script('fred+ernie=123', 'fred+ernie=123\\0') + check_script('fred+mary=123', 'fred+mary=123\\0') # ignores variables that are empty check_script('''fred= fred+= -ernie=456''', 'ernie=456\\0') +mary=456''', 'mary=456\\0') # single-character env name - check_script('''f=123 + check_script('''m=123 e=456 -f+= 456''', 'e=456\\0f=123 456\\0') +m+= 456''', 'e=456\\0m=123 456\\0') # contains quotes check_script('''fred="my var" -ernie=another"''', 'fred=\\"my var\\"\\0ernie=another\\"\\0') +mary=another"''', 'fred=\\"my var\\"\\0mary=another\\"\\0') # variable name ending in + check_script('''fred\\+=my var @@ -598,7 +598,7 @@ fred++= again''', 'fred+=my var again\\0') # variable name containing + check_script('''fred+jane=both fred+jane+=again -ernie=456''', 'fred+jane=bothagain\\0ernie=456\\0') +mary=456''', 'fred+jane=bothagain\\0mary=456\\0') # multi-line vars - new vars always start at column 1 check_script('''fred=first @@ -607,7 +607,7 @@ ernie=456''', 'fred+jane=bothagain\\0ernie=456\\0') after blank confusing=oops -ernie=another"''', 'fred=first second third with tab after blank confusing=oops\\0ernie=another\\"\\0') +mary=another"''', 'fred=first second third with tab after blank confusing=oops\\0mary=another\\"\\0') # real-world example check_script('''ubifs_boot= -- 2.35.1.723.g4982287a31-goog