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 CF0D8C4332F for ; Fri, 9 Dec 2022 12:10:43 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B452C851E7; Fri, 9 Dec 2022 13:10:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="aKNafkM2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A597C851E7; Fri, 9 Dec 2022 13:10:40 +0100 (CET) Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) (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 D2B30851C1 for ; Fri, 9 Dec 2022 13:10:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=max.oss.09@gmail.com Received: by mail-ed1-x533.google.com with SMTP id i15so2835341edf.2 for ; Fri, 09 Dec 2022 04:10:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=eUXVjHWCtPsXWS8Yl6PUmUWOKk93K5ObnoB40suNMZA=; b=aKNafkM2urAUHrD3UnU9OpBG9yFBkXEZVA9fp8x98Gi41Y1bkIfkBJw3dOdeGxmi2K fOqxGt06NQEYNLwrObVYuahGWa1sjvlkrIjJpDsSCrNONTUQvPJvbGT3EzFbzkljir96 F/FW7V05YkfzlNvxJpVx15guueANdD2D21pjkZu80g10AThpSj+euoA+WbxZiKH7bMCs QCHrVrG7zaNShBZxXU88Jcahnn4ZMm/V6pqM0TMnKnTBUPKFmJKCN/4820lC4o5s1JfN r7J8NiA7CtsVlNyTAMg1XiAxyy9C/5NXb9VnwuqdqJhybcZXIQvZlEYxx2mqp+nCiEWG wvzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=eUXVjHWCtPsXWS8Yl6PUmUWOKk93K5ObnoB40suNMZA=; b=zIxTCSPOzTlJoDLIxiHRJFPOnotIYr5Lb4bXaTTIzZCV7pu3+UE2KAhAtQxtFTp93X PKkVSEJENUT+ePPCkOpegIZTU16pDc2gFgdTzl1juadJIpdfNODos50zOVR6uk/ZGetY gJS8HHMBCww1zTJHZKhmjBwyJik6idLDvbpRjPMvXaFqIVtYjGzZ6x9I4JWYc08wB81Q 2UM1hmuiXWBrDVu+GejprH3mn+VvOcHMD18WBzLFAsmdwD1xOOGK9419eWsq87G8TrGC I1A0tP9aBOATLsVtyQs3q+O0xqIUf/BqN8Y/Ps/nMoD+qoBF5c6sKqz9Gah9vZy0EoRj fIww== X-Gm-Message-State: ANoB5plKbUEW7viE41vJZztjoIq4KsYd9jBG7Ho8x5owyBcc0IcKhw0Q ne/rXe5M434e55JrwWVh4EanUAKNn9k= X-Google-Smtp-Source: AA0mqf6pSv4aDQD6eQTZwctrRiPR20W+A6ZOfuZqtRmMXatBQF/hfEKO8hel+s8KOwVKyOIZvvdiaw== X-Received: by 2002:a05:6402:288f:b0:46b:b750:3d2e with SMTP id eg15-20020a056402288f00b0046bb7503d2emr4546514edb.26.1670587836959; Fri, 09 Dec 2022 04:10:36 -0800 (PST) Received: from linuxdev2.toradex.int (31-10-206-125.static.upc.ch. [31.10.206.125]) by smtp.gmail.com with ESMTPSA id er18-20020a056402449200b004588ef795easm566316edb.34.2022.12.09.04.10.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Dec 2022 04:10:36 -0800 (PST) From: Max Krummenacher To: u-boot@lists.denx.de Cc: Max Krummenacher , Heinrich Schuchardt , Simon Glass Subject: [PATCH v1] test: env: add test for u-boot-initial-env creation Date: Fri, 9 Dec 2022 13:09:56 +0100 Message-Id: <20221209120956.2286619-1-max.oss.09@gmail.com> X-Mailer: git-send-email 2.35.3 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.6 at phobos.denx.de X-Virus-Status: Clean From: Max Krummenacher Checks that `make u-boot-initial-env` creates the text file u-boot-initial-env and checks that it at least contains `board=`. Signed-off-by: Max Krummenacher --- Changes in v1: I assume every board has a board environment variable but I don't test its value. I.e. the test succseeds even if a board sets it to some arbitrary string at build time. - Tested only with 'sandbox'. - As proposed by Simon, see https://lore.kernel.org/all/CAPnjgZ0V_Fdj9EvzD1hOYa7VqeptsueAuPj5ktYa7owO1qr_CQ@mail.gmail.com/ Thanks for the pointers tn where to add and where to look for a host test example. This was very helpful. test/py/tests/test_env.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py index 6d08565f0b5..ea1e4c76e09 100644 --- a/test/py/tests/test_env.py +++ b/test/py/tests/test_env.py @@ -8,6 +8,7 @@ Test operation of shell commands relating to environment variables. import os import os.path +import re from subprocess import call, CalledProcessError import tempfile @@ -173,6 +174,28 @@ def validate_set(state_test_env, var, value): response = state_test_env.u_boot_console.run_command('printenv %s' % var) assert response == ('%s=%s' % (var, value)) +def test_env_initial_env_file(u_boot_console): + """Test that the u-boot-initial-env make target works""" + cons = u_boot_console + builddir = 'O=' + cons.config.build_dir + envfile = cons.config.build_dir + '/u-boot-initial-env' + + # remove if already exists from an older run + try: + os.remove(envfile) + except: + pass + + u_boot_utils.run_and_log(cons, ['make', builddir, 'u-boot-initial-env']) + + assert os.path.exists(envfile) + + # assume that every environment has a board variable, e.g. board=sandbox + with open(envfile, 'r') as file: + env = file.read() + regex = re.compile('board=.+\\n') + assert re.search(regex, env) + def test_env_echo_exists(state_test_env): """Test echoing a variable that exists.""" -- 2.35.3