From patchwork Thu Mar 4 13:50:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447319 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=aWJEbtkS; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4Drsk42mwpz9sSC for ; Fri, 5 Mar 2021 00:52:12 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 530AC8276E; Thu, 4 Mar 2021 14:51:57 +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="aWJEbtkS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CBD19826C7; Thu, 4 Mar 2021 14:51:49 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x330.google.com (mail-ot1-x330.google.com [IPv6:2607:f8b0:4864:20::330]) (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 3B75882082 for ; Thu, 4 Mar 2021 14:51:46 +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-ot1-x330.google.com with SMTP id w3so7540030oti.8 for ; Thu, 04 Mar 2021 05:51:46 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=xr73UmxRM7VcE6E69G1s3P+H121I3NPQYcuiK+qumi4=; b=aWJEbtkSmUEy19z7DbYS0SnQfinFrRzUYgHDfnXDsYB7+/XDSEOPCQmBiPcOniAxR3 Nabuo4nqgP94VYK1IF6PGMrJmhEyxfyoOCr3KPTW4j8irvmk4QSNV1hInZuKd5L79sfe rdhq5gc8+BswaUMIG2VpgS06j3PGggsy4S20w= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=xr73UmxRM7VcE6E69G1s3P+H121I3NPQYcuiK+qumi4=; b=YysUS8fqEAZ7QmScfwpzpiJqF3LvpxZCEyjfBYI9QxO41tRjaKFpxH22TgO23A3mre Oy9BaJi6gJvE2UI/RVSGJKx/G65RBupkXAQPmjqLWIMuL4nzD2/6xdIkCTSiqaKxnvDU 7XmwUtoIlPUuOteDJ9peLbBh0MCmUv2v4d2cTybBu5/spQDSX16q/BFO8MJ2JU8GamFY XwfeNetPjyWQEWzq2QNc/2njU5i9NWSdpbZF70c6FpFIUl+TfiCzcKkaT/1bL64+T4sJ Th46Ewh2zeFo8k+hbrS/oRgcpX/HHmu9LSVh1+n81N06pnEhXYuwF+xIcsFgVEgvrz34 zLrA== X-Gm-Message-State: AOAM531udoK4cds9A+qKX5gSLbbrSlkIuq5mhRkusRgLrgeF1dFAaW2X SQNccavdYoC7QwoBwkHpqkK98ajxdL2TgRg3 X-Google-Smtp-Source: ABdhPJz7v7f1vQbOKrhamncGymikDRn7grWC/9qIyThyeX4SqFxmZWpoyQ4FF+ztGPNj7Zv5RT8EOg== X-Received: by 2002:a9d:63d1:: with SMTP id e17mr3515250otl.183.1614865903646; Thu, 04 Mar 2021 05:51:43 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.51.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:51:43 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass , Marek Vasut , Pavel Herrmann Subject: [PATCH v4 01/42] dm: core: Fix allocation of empty of-platdata Date: Thu, 4 Mar 2021 06:50:37 -0700 Message-Id: <20210304135118.643277-2-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean With of-platdata we always have a dtv struct that holds the platform data provided by the driver_info record. However, this struct can be empty if there are no actual devicetree properties provided. The upshot of empty platform data is that it will end up as a zero-size member in the BSS section, which is fine. But if the driver specifies plat_auto then it expects the correct amount of space to be allocated. At present this does not happen, since device_bind() assumes that the platform-data size will always be >0. As a result we end up not allocating the space and just use the BSS region, overwriting whatever other contents are present. Fix this by removing the condition that platform data be non-empty, always allocating space if requested. This fixes a strange bug that has been lurking since of-platdata was implemented. It has likely never been noticed since devices normally have at least some devicetree properties, BSS is seldom used on SPL, the dtv structs are normally at the end of bss and the overwriting only happens if a driver changes its platform data. It was discovered using sandbox_spl, which exercises more features than a normal board might, and the critical global_data variable 'gd' happened to be at the end of BSS. Fixes: 9fa28190091 ("dm: core: Expand platdata for of-platdata devices") Signed-off-by: Simon Glass --- (no changes since v1) drivers/core/device.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/core/device.c b/drivers/core/device.c index 625134921d6..d1098a3861a 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -92,15 +92,19 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv, if (auto_seq && !(uc->uc_drv->flags & DM_UC_FLAG_NO_AUTO_SEQ)) dev->seq_ = uclass_find_next_free_seq(uc); + /* Check if we need to allocate plat */ if (drv->plat_auto) { bool alloc = !plat; + /* + * For of-platdata, we try use the existing data, but if + * plat_auto is larger, we must allocate a new space + */ if (CONFIG_IS_ENABLED(OF_PLATDATA)) { - if (of_plat_size) { + if (of_plat_size) dev_or_flags(dev, DM_FLAG_OF_PLATDATA); - if (of_plat_size < drv->plat_auto) - alloc = true; - } + if (of_plat_size < drv->plat_auto) + alloc = true; } if (alloc) { dev_or_flags(dev, DM_FLAG_ALLOC_PDATA); @@ -109,6 +113,11 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv, ret = -ENOMEM; goto fail_alloc1; } + + /* + * For of-platdata, copy the old plat into the new + * space + */ if (CONFIG_IS_ENABLED(OF_PLATDATA) && plat) memcpy(ptr, plat, of_plat_size); dev_set_plat(dev, ptr); From patchwork Thu Mar 4 13:50:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447321 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=dnEU6H0e; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4DrskZ3xHPz9sWc for ; Fri, 5 Mar 2021 00:52:38 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 14759827A5; Thu, 4 Mar 2021 14:52:07 +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="dnEU6H0e"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DB167826C7; Thu, 4 Mar 2021 14:51:54 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) (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 C2AC38268F for ; Thu, 4 Mar 2021 14:51:48 +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-ot1-x32a.google.com with SMTP id g8so23627164otk.4 for ; Thu, 04 Mar 2021 05:51:48 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=Wd8xQ1Z6xnD4IyChHiPvt0lzHPDWXL3VD86jc6yWwPg=; b=dnEU6H0evyR2E1aByUeHrfCrExJrwf2SP3WA4B4S3piFV/RhojOArMrJ3AjjiR+e0m /ggzDiBFVhFfhfo+jX4qnxS0t6nxRIy/DwoRhYCtfbqaTlICW+o9l1+4yHPUbFUYP0ID voSjdi5F5wIIeed52jUvKr72EmrSjr30Rnh2U= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Wd8xQ1Z6xnD4IyChHiPvt0lzHPDWXL3VD86jc6yWwPg=; b=WrRGA5kGq3kcJKhzQYBNGqy1H9Y86ZVjcZxvh+mFfxRfDScdAv5grl10QyY6Qndvc+ MNofNScgNlyL8J68alib75mOm9d9uKLykX5nj/pGOD+N/XS4jwbCqpoT3euUpLeMy3cj rhFcNRwDmCmc73IGk7ZFoYIyH4RHk3WmmDouzklzLftwrQBpKTGU7lL6h4A5j7HAslBO tmrbochsrG9kXjOwMl6PwrRhN3ed7Fi/LV7FJlh0cYA+JkP/Z1v5005ljWhF6+v/Vm7Y L+ZPb8bTkX797+yU/X/MRcOvccGwVe0NHWeKcREJ0jWOUJbNHCayNxduoyr9xphzU3v3 451w== X-Gm-Message-State: AOAM5324it4OzBKKVf72v+7adt6s4Fdc17pnhGszdxdPlKWqEAuYfdnK brMulb15CJmjxhlV1CxzFp0ivpxLxbHsXdfa X-Google-Smtp-Source: ABdhPJynZbxjI+r+IBijS2+5hDD0CFei/zyItReJQiLzb9ZTr0w9C7Rge0DxtkotRwMoW2OrisaS1A== X-Received: by 2002:a9d:6251:: with SMTP id i17mr3473429otk.162.1614865904551; Thu, 04 Mar 2021 05:51:44 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.51.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:51:44 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 02/42] doc: Tidy up testing section Date: Thu, 4 Mar 2021 06:50:38 -0700 Message-Id: <20210304135118.643277-3-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean Tweak this so the output looks a little better. Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt --- (no changes since v2) Changes in v2: - Use correct rst format for 'Ad-hoc tests' section doc/develop/testing.rst | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/doc/develop/testing.rst b/doc/develop/testing.rst index 4bc9ca3a6ae..bc74eb53e35 100644 --- a/doc/develop/testing.rst +++ b/doc/develop/testing.rst @@ -8,14 +8,14 @@ tested and what tests you should write when adding a new feature. Running tests ------------- -To run most tests on sandbox, type this: +To run most tests on sandbox, type this:: make check in the U-Boot directory. Note that only the pytest suite is run using this command. -Some tests take ages to run. To run just the quick ones, type this: +Some tests take ages to run. To run just the quick ones, type this:: make qcheck @@ -35,9 +35,9 @@ either on sandbox or on real hardware. It relies on the U-Boot console to inject test commands and check the result. It is slower to run than C code, but provides the ability to unify lots of tests and summarise their results. -You can run the tests on sandbox with: +You can run the tests on sandbox with:: - ./test/py/test.py --bd sandbox --build + ./test/py/test.py --bd sandbox --build This will produce HTML output in build-sandbox/test-log.html @@ -58,10 +58,14 @@ Ad-hoc tests There are several ad-hoc tests which run outside the pytest environment: - test/fs - File system test (shell script) - test/image - FIT and legacy image tests (shell script and Python) - test/stdint - A test that stdint.h can be used in U-Boot (shell script) - trace - Test for the tracing feature (shell script) +test/fs + File system test (shell script) +test/image + FIT and legacy image tests (shell script and Python) +test/stdint + A test that stdint.h can be used in U-Boot (shell script) +trace + Test for the tracing feature (shell script) TODO: Move these into pytest. From patchwork Thu Mar 4 13:50:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447318 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=aOcNJopm; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4Drsjs322jz9sSC for ; Fri, 5 Mar 2021 00:52:01 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0745F82700; Thu, 4 Mar 2021 14:51:52 +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="aOcNJopm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 79FE1826FB; Thu, 4 Mar 2021 14:51:50 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) (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 0692B825C6 for ; Thu, 4 Mar 2021 14:51:46 +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-oi1-x236.google.com with SMTP id s73so4356368oie.1 for ; Thu, 04 Mar 2021 05:51:46 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=QJRRm58nRd/NoSIlTCbiSRqHLj1qoKm4tvZ4RjGkfF0=; b=aOcNJopmbPGExGmuTtN7SNUg+zhZbTTwZe7UwGpJuh2Rqn8vHNs2gGF7k/HG6cwowJ fTfqZHc4PA9K9nPFlunCVODkgXD+ocsaQIeymBp7V+Ecl76hEvh9NlO7+7hP/Mw5G3v5 rNMhz/85MLl09aDQ4mHw+mRQhBYTzZBZh81ZA= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=QJRRm58nRd/NoSIlTCbiSRqHLj1qoKm4tvZ4RjGkfF0=; b=WXKrLzZF79BpL0b+TSAi1VjCo4MGbFaf0kpktBI8ZE/1VSloslQSPWysgqnzxZSMO+ zfAindn3yciEt+6Ix3usJWPtLQy132sx9xFvJ42kfTQrH8lMBqOitO0s0MfaL8LdEP3l v5OFv/c+t0unq9grmD0C15f+eExcn1kWgbgTZW/SxM48+GGkmppLfzj7laTp8DoAqfhT QDFSICYdKH73+xV34C2fNzk5fMHPZYbfdAJ8Zi58074XeTeuL6LifonA0Yjkp32fvlDY Byxo54nEqL4+iDIZWnYwJ5Asnp0tJVzyDZbB7NXfzCJC4d7HdkVdCNVd0mL+EEr8jbmn KHIA== X-Gm-Message-State: AOAM531bA8Xmu0DQmli9iMa+IsV3NctZlDwcCmwbW9LycLtRkQ4YugxB +gU/LxGZrKy8uliEhr2eu2uAUz6Z7ECxJpBx X-Google-Smtp-Source: ABdhPJwS+AD7nH432Pou/V0QyPS/2tTUrvGCZETmzsF/2M7uXhnAlLT3KZqUZzRzRU6G9n8dUp9uGw== X-Received: by 2002:a05:6808:da:: with SMTP id t26mr2920916oic.77.1614865905540; Thu, 04 Mar 2021 05:51:45 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.51.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:51:45 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 03/42] doc: Document make tcheck Date: Thu, 4 Mar 2021 06:50:39 -0700 Message-Id: <20210304135118.643277-4-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean Add a comment about this option in the documentation. Also mention the script that runs these combinations. Signed-off-by: Simon Glass --- (no changes since v2) Changes in v2: - Expand docs on how each type of test is marked doc/develop/testing.rst | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/develop/testing.rst b/doc/develop/testing.rst index bc74eb53e35..f01ca4dc408 100644 --- a/doc/develop/testing.rst +++ b/doc/develop/testing.rst @@ -15,10 +15,20 @@ To run most tests on sandbox, type this:: in the U-Boot directory. Note that only the pytest suite is run using this command. -Some tests take ages to run. To run just the quick ones, type this:: +Some tests take ages to run and are marked with @pytest.mark.slow. To run just +the quick ones, type this:: make qcheck +It is also possible to run just the tests for tools (patman, binman, etc.). +Such tests are included with those tools, i.e. no actual U-Boot unit tests are +run. Type this:: + + make tcheck + +All of the above use the test/run script with a paremeter to select which tests +are run. + Sandbox ------- From patchwork Thu Mar 4 13:50:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447325 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=ULxmXytu; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4DrslY1w8Pz9sSC for ; Fri, 5 Mar 2021 00:53:29 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 152DB82817; Thu, 4 Mar 2021 14:52:21 +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="ULxmXytu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B8BB182790; Thu, 4 Mar 2021 14:51:58 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) (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 F1085826FB for ; Thu, 4 Mar 2021 14:51:52 +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-oi1-x22e.google.com with SMTP id z126so30146693oiz.6 for ; Thu, 04 Mar 2021 05:51:52 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=jzdSlokF6/yI65DwNywu+TbSLU+HjlnWt3jJ0h0HW+A=; b=ULxmXytu6onB0eZLf6pHoGfPijfNG8m5KEzNzM8BA7GnkKTnmvD/xJAE3dmg3Ylc9+ 1rcdnzawcMeJCVufWUPUR4DIBQiYl8Jl0jHBQcFZbOhVN4P8ncJf62E1Z28gtjoUdykF r8Kx0f4qxyLzffStA/HszCfSu8bpxiNQlaC88= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=jzdSlokF6/yI65DwNywu+TbSLU+HjlnWt3jJ0h0HW+A=; b=nyrpFT9+eYHnOZ7bQcKeZVXThXieoJcSgdlG90rxA3zuc3+zc2H12UcZ6AnzjUotDd VoJZlu5Wc7xI+q1oeVhnAFWxD5zLRak0iuNw8vfJDRLLFEFNVU3oiwy4oQG65eZlxlXh DyZsGMm/6cGXwg0JjTQvS2lD81nNjKLiVwmo7NfvIanMj9n03SjZt8ts082mko9Bv+3T duBPMj+o+AvEq4/X0XK9Zt+F6DWvJeHCUT2YIQmMeJxr9NrtVTnp/JYHJ+GHBUbjHAJe pPtGOEsaJR2qnFygzZ0mKO2sEyfpv8DburJUvsxeAbAJBMcfV7Y6EGTnhqfie+6mD9Fh hJbw== X-Gm-Message-State: AOAM531jb1jEChPD8c8o/HHBx1VPzjTy3dh4pvUG+q1KWLLit2Y+CXIs UFxjTGB/i4DK/0ymzTfeaQ1MiZp+0MQ+a8Wd X-Google-Smtp-Source: ABdhPJzH83wI5/NfdqQqBtORTgc22ibdwADK7Jimc+Vz+3qk0Je0BXvLKLUxUymf0u84XS78pdKTrw== X-Received: by 2002:aca:7516:: with SMTP id q22mr1436921oic.158.1614865906669; Thu, 04 Mar 2021 05:51:46 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.51.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:51:46 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 04/42] sandbox: Drop the 'starting...' message unless testing Date: Thu, 4 Mar 2021 06:50:40 -0700 Message-Id: <20210304135118.643277-5-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean This message is annoying since it is only useful for testing. Add a flag to control whether it is emitted or not, so it can be supressed by default. Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/cpu/start.c | 15 +++++++++++++-- arch/sandbox/include/asm/state.h | 1 + test/py/tests/test_log.py | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index c4c4128d465..3dcab6a0cc8 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -389,6 +389,15 @@ static int sandbox_cmdline_cb_select_unittests(struct sandbox_state *state, } SANDBOX_CMDLINE_OPT_SHORT(select_unittests, 'k', 1, "Select unit tests to run"); +static int sandbox_cmdline_cb_log_test(struct sandbox_state *state, + const char *arg) +{ + state->log_test = true; + + return 0; +} +SANDBOX_CMDLINE_OPT(log_test, 0, "Show logging info on startup (for testing)"); + static void setup_ram_buf(struct sandbox_state *state) { /* Zero the RAM buffer if we didn't read it, to keep valgrind happy */ @@ -491,8 +500,10 @@ int main(int argc, char *argv[]) gd->reloc_off = (ulong)gd->arch.text_base; /* sandbox test: log functions called before log_init in board_init_f */ - log_info("sandbox: starting...\n"); - log_debug("debug: %s\n", __func__); + if (state->log_test) { + log_info("sandbox: starting...\n"); + log_debug("debug: %s\n", __func__); + } /* Do pre- and post-relocation init */ board_init_f(0); diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h index bca13069824..d0e7fdbd5b0 100644 --- a/arch/sandbox/include/asm/state.h +++ b/arch/sandbox/include/asm/state.h @@ -105,6 +105,7 @@ struct sandbox_state { struct list_head mapmem_head; /* struct sandbox_mapmem_entry */ bool hwspinlock; /* Hardware Spinlock status */ bool allow_memio; /* Allow readl() etc. to work */ + bool log_test; /* Output some log info for testing */ /* * This struct is getting large. diff --git a/test/py/tests/test_log.py b/test/py/tests/test_log.py index f889120f2b3..e2955ab0770 100644 --- a/test/py/tests/test_log.py +++ b/test/py/tests/test_log.py @@ -43,7 +43,7 @@ def test_log_dropped(u_boot_console): """Test dropped 'log' message when debug_uart is activated""" cons = u_boot_console - cons.restart_uboot() + cons.restart_uboot_with_flags(['--log_test']) output = cons.get_spawn_output().replace('\r', '') assert 'sandbox: starting...' in output assert (not 'debug: main' in output) From patchwork Thu Mar 4 13:50:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447320 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Vre7/5Te; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4DrskK1DTxz9sSC for ; Fri, 5 Mar 2021 00:52:25 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C856882789; Thu, 4 Mar 2021 14:52:00 +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="Vre7/5Te"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BE21082774; Thu, 4 Mar 2021 14:51:54 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x332.google.com (mail-ot1-x332.google.com [IPv6:2607:f8b0:4864:20::332]) (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 14736826B9 for ; Thu, 4 Mar 2021 14:51:49 +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-ot1-x332.google.com with SMTP id v12so26170543ott.10 for ; Thu, 04 Mar 2021 05:51:48 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=tjBDcVyJGYQGE0FxmwfTiin+p6cO2r5UwGcBVE9WtPQ=; b=Vre7/5TeIsKgc43gTrQ0TLbgKOmJwOWQwS7RCQct4vc1I98zVB1I5WjEbumlNu6/K1 SuiwOZzqopKoDowPYPYE04K3WrZbY2KOLviN5r15jT/RT+MqSHGVjib+EfzUKKWeYmXi KwBfAzEYbAsVhDzr2p+ZhXwyrioPttHX/wuIs= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=tjBDcVyJGYQGE0FxmwfTiin+p6cO2r5UwGcBVE9WtPQ=; b=VdmPmjnXUW1CwwsAzTSGZDQD7jx5YlqMj8Zil9aDm1C8+KvFY90sEWvyRcxTOMdSKs g3itGqTXsaHINMcmTj2Q08JJeunyFgH6EZw6n90LN0y0e2GSPdrB9ge8b/9damFTfEc2 XExZrsz9TLxS1+QeqeOVWtg/odGtQF/gt5KicvCopHgb7ifa1gJWE8MGilsD+MchO0+u MhkyG4jw7kQTPb8aVzduK/cCRMr0o326rlFsxPQUKYiHJJy7ObuegPhqafJuLaIJB5SK zINtaxG9dWjCFFubIqFT1nuT+7S6yeG+gTwR6D1cPJspSIHXv8m3SCMeXr3aMUoFhDES w4pg== X-Gm-Message-State: AOAM533HuxbHUfwkSe8BrLzo4hEjTZKESUYuoZIHvGcsG0NMJ0hQN9IC KG9BYX07HngwSVEYpZQUHxISaDl1NyjdGnYj X-Google-Smtp-Source: ABdhPJxnV78lKGWf8b3axpz1lu65iPn5yIznoQUdOtytLQCh8uUD18kbL6pjxdlRxE2FPPTJ1FJ4bw== X-Received: by 2002:a05:6830:1192:: with SMTP id u18mr3655444otq.146.1614865907607; Thu, 04 Mar 2021 05:51:47 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.51.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:51:47 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 05/42] test: Re-enable test_ofplatdata Date: Thu, 4 Mar 2021 06:50:41 -0700 Message-Id: <20210304065106.v4.5.Ic3c67628cdef6cb65fa39abe6681f23b5e471d86@changeid> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean This was inadvertently disabled after a recent change. Re-enable it. Signed-off-by: Simon Glass --- (no changes since v3) Changes in v3: - Add new patch to re-enable test_ofplatdata test/py/tests/test_ofplatdata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/py/tests/test_ofplatdata.py b/test/py/tests/test_ofplatdata.py index 92d09b7aa19..e9cce4daf48 100644 --- a/test/py/tests/test_ofplatdata.py +++ b/test/py/tests/test_ofplatdata.py @@ -4,7 +4,7 @@ import pytest import u_boot_utils as util -@pytest.mark.boardspec('sandbox') +@pytest.mark.boardspec('sandbox_spl') @pytest.mark.buildconfigspec('spl_of_platdata') def test_spl_devicetree(u_boot_console): """Test content of spl device-tree""" From patchwork Thu Mar 4 13:50:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447322 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=amZLuh0n; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4Drskp3hfgz9sVt for ; Fri, 5 Mar 2021 00:52:50 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 80DDE827BE; Thu, 4 Mar 2021 14:52:10 +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="amZLuh0n"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0913E8276E; Thu, 4 Mar 2021 14:51:56 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) (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 2171C82082 for ; Thu, 4 Mar 2021 14:51:50 +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-oi1-x234.google.com with SMTP id i21so27872048oii.2 for ; Thu, 04 Mar 2021 05:51:50 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=lAtevWhzR7E6hlqEEmv61vC8dqfiewyuOipE5/+J4Ug=; b=amZLuh0nWDLbzQ6DfvBxf+wjg8UMEBQVJtxsxMmcX+4mQulaMErQTFJtRD96ySVxXK 61QruCGAMU6n/8pa2DSTaC9eaAvobAlQ8SC6AG6guMl/RV0+yValpNX0EqOBkKDFQpqb JOKD9h1r648MaRr+EX9Y1CUJWCWiHa/nFz0NY= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=lAtevWhzR7E6hlqEEmv61vC8dqfiewyuOipE5/+J4Ug=; b=V8ijrSSfLnav6l1UvZC/wDnMb+rUUGG9cjJknON73kHD+TZpHDbCtVknxCKXI+JZkP yOL3fYg4B+aiFA3FNaMzZeRzqSqtwFSwrLb3qVFYOWeOGck9HUiDFKB2GelJzxw8JL/a DycU4L5LftemtiRf0wc0ePAGZpyrNKu7y7j8U+mJqVu5KxMRuV3Z/JfZK6BlYfQC+ALY k051WzGcVv+XuX9a8fwPT3T3McWxoyZ2hz6K329REArifGFSDWrlUgHDKq7nSbKW4jUx 3IvkHMnc251sBV1gCWpLmxAMV0Z3FLLtlBazkTZw5xBdfxrcj6e1phZhUVHDzZdrOEZK 3b+A== X-Gm-Message-State: AOAM531bmVjoLHJyNl8nc0FunNaag6Y1hiRImORm/+wbm0U80TZ2pr6u m27U4za9UacFTwR8Fkz5WOiebZlxXh5k02E7 X-Google-Smtp-Source: ABdhPJzyrG9T2zXa0DhtuYwO1yhGDF6jx3Sl2K9+Ovi19U4RbC1sd1WQPZWmuSwc5lttzuTM9mB4PQ== X-Received: by 2002:aca:ab09:: with SMTP id u9mr2947399oie.153.1614865908629; Thu, 04 Mar 2021 05:51:48 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.51.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:51:48 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 06/42] doc: Explain how to run tests without pytest Date: Thu, 4 Mar 2021 06:50:42 -0700 Message-Id: <20210304135118.643277-6-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean Add details about how to run a sandbox test directly, without using pytest. This is more convenient for rapid development, since it is faster and allows easier use of a debugger. Also mention sandbox_flattree as an example of the different sandbox builds available. Signed-off-by: Simon Glass --- (no changes since v2) Changes in v2: - Put the docs in tests_sandbox since it is more related to sandbox - Put in a mention of tests_sandbox in the main testing docs doc/develop/index.rst | 1 + doc/develop/testing.rst | 9 ++++ doc/develop/tests_sandbox.rst | 79 +++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 doc/develop/tests_sandbox.rst diff --git a/doc/develop/index.rst b/doc/develop/index.rst index ac57fdb8f30..50b1de3bdff 100644 --- a/doc/develop/index.rst +++ b/doc/develop/index.rst @@ -33,3 +33,4 @@ Testing coccinelle testing py_testing + tests_sandbox diff --git a/doc/develop/testing.rst b/doc/develop/testing.rst index f01ca4dc408..87c90eee271 100644 --- a/doc/develop/testing.rst +++ b/doc/develop/testing.rst @@ -36,6 +36,7 @@ U-Boot can be built as a user-space application (e.g. for Linux). This allows test to be executed without needing target hardware. The 'sandbox' target provides this feature and it is widely used in tests. +See :doc:`tests_sandbox` for more information. Pytest Suite ------------ @@ -51,8 +52,16 @@ You can run the tests on sandbox with:: This will produce HTML output in build-sandbox/test-log.html +Some tests run with other versions of sandbox. For example sandbox_flattree +runs the tests with livetree (the hierachical devicetree) disabled. You can +also select particular tests with -k:: + + ./test/py/test.py --bd sandbox_flattree --build -k hello + See test/py/README.md for more information about the pytest suite. +See :doc:`tests_sandbox` for how to run tests directly (not through pytest). + tbot ---- diff --git a/doc/develop/tests_sandbox.rst b/doc/develop/tests_sandbox.rst new file mode 100644 index 00000000000..85bbd4f6734 --- /dev/null +++ b/doc/develop/tests_sandbox.rst @@ -0,0 +1,79 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +Tests Under the Hood +==================== + +Running sandbox tests directly +------------------------------ + +Typically tests are run using the pytest suite. This is easy and always gets +things right. + +But it is also possible to run some sandbox tests directly. For example, this +runs the dm_test_gpio() test which you can find in test/dm/gpio.c:: + + $ ./u-boot -T -c "ut dm gpio" + + + U-Boot 2021.01 + + Model: sandbox + DRAM: 128 MiB + WDT: Started with servicing (60s timeout) + MMC: mmc2: 2 (SD), mmc1: 1 (SD), mmc0: 0 (SD) + In: serial + Out: vidconsole + Err: vidconsole + Model: sandbox + SCSI: + Net: eth0: eth@10002000, eth5: eth@10003000, eth3: sbe5, eth6: eth@10004000 + Test: dm_test_gpio: gpio.c + Test: dm_test_gpio: gpio.c (flat tree) + Failures: 0 + +The -T option tells U-Boot to run with the 'test' devicetree (test.dts) instead +of -D which selects the normal sandbox.dts - this is necessary because many +tests rely on things in the test devicetree. If you try running tests without +-T then you may see failures, like:: + + $ ./u-boot -c "ut dm gpio" + + + U-Boot 2021.01 + + DRAM: 128 MiB + WDT: Not found! + MMC: + In: serial + Out: serial + Err: serial + SCSI: + Net: No ethernet found. + Please run with test device tree: + ./u-boot -d arch/sandbox/dts/test.dtb + Test: dm_test_gpio: gpio.c + test/dm/gpio.c:37, dm_test_gpio(): 0 == gpio_lookup_name("b4", &dev, &offset, &gpio): Expected 0x0 (0), got 0xffffffea (-22) + Test: dm_test_gpio: gpio.c (flat tree) + test/dm/gpio.c:37, dm_test_gpio(): 0 == gpio_lookup_name("b4", &dev, &offset, &gpio): Expected 0x0 (0), got 0xffffffea (-22) + Failures: 2 + +The message above should provide a hint if you forget. Even running with -D +will produce different results. + +You can easily use gdb on these tests, without needing --gdbserver:: + + $ gdb u-boot --args -T -c "ut dm gpio" + ... + (gdb) break dm_test_gpio + Breakpoint 1 at 0x1415bd: file test/dm/gpio.c, line 37. + (gdb) run -T -c "ut dm gpio" + Starting program: u-boot -T -c "ut dm gpio" + Test: dm_test_gpio: gpio.c + + Breakpoint 1, dm_test_gpio (uts=0x5555558029a0 ) + at files/test/dm/gpio.c:37 + 37 ut_assertok(gpio_lookup_name("b4", &dev, &offset, &gpio)); + (gdb) + +You can then single-step and look at variables as needed. + From patchwork Thu Mar 4 13:50:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447323 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=gUCTaGR0; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4Drsl31LLnz9sVt for ; Fri, 5 Mar 2021 00:53:03 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CEC81827E1; Thu, 4 Mar 2021 14:52:13 +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="gUCTaGR0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A4F878277D; Thu, 4 Mar 2021 14:51:57 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) (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 1582A825C6 for ; Thu, 4 Mar 2021 14:51:51 +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-oi1-x236.google.com with SMTP id f3so30110294oiw.13 for ; Thu, 04 Mar 2021 05:51:51 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=YExSWGzH3tq0e5lYCL8u+HMlRilmt0LPdPwrt4EXiC8=; b=gUCTaGR06yb46Ms4BJKX9InIk1kXEORGAj0/dfrid4KHYFpIGBAo9O5Nhl84X9Y/x5 U3LFFwnYBuMRO/3KDseCZCffYX8wLi/8uoDprxQ/xIDdxrmyWz4ufdHPnnjHbjk3nL1a mVQI6vQRKYTt22GIQCCJmu1mP7vECBkehXX8g= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=YExSWGzH3tq0e5lYCL8u+HMlRilmt0LPdPwrt4EXiC8=; b=B3jL/egoimq1bXLhy2w+qzoLEGG3tmFco26ZTdfNEJbsZAO1Gr2fZV5rwND71+6gbF CVopIO15ExSQhBVPaG4bnkp3JhMtOWzHPpvsdYEQCmsJG9HMtvibIuz22nGhycBk2cSj L/sHeeaUAzDoNCoByqLu9caigoo1I9k6ISNH+C4bySg8pJVwzpBn++6uPAymVRhtdjOV Bj7pDduREAKQJgA4TRWzzDIN1cuETqP6GJmltFCOODBTEIKl6bkWsCBOf6G+lW61ADdo fD5M+bEGrAOEibZ5hM9ZTCXAlMLIP9WrJZdtTyKz2BWjbZuSlIYw1cPiOicF5D+8QugB QO3w== X-Gm-Message-State: AOAM530zKLsJcjoyqxQUr1moivBvGrdsYbRUQQG4eTZSS2d2gqihRJWM M3BW93j7Qxc+OOeWKl79Eobw6uRQRExX763R X-Google-Smtp-Source: ABdhPJyeRWaqrk+lpSqhXVmlgHonzQ02F2mXtt2KEJXfdrnCTJT/v1sR9/gEKl3pn2rboYyASUEpZA== X-Received: by 2002:aca:1b05:: with SMTP id b5mr3018046oib.96.1614865909590; Thu, 04 Mar 2021 05:51:49 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.51.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:51:49 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass , Pratyush Yadav Subject: [PATCH v4 07/42] doc: Document how sandbox_spl_tests are run Date: Thu, 4 Mar 2021 06:50:43 -0700 Message-Id: <20210304135118.643277-7-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean Add a few notes about the sandbox_spl tests, since they are special. Signed-off-by: Simon Glass Acked-by: Pratyush Yadav --- Changes in v4: - Fix 'of-pldata' typo Changes in v3: - Reword the SPL tests section for clarity Changes in v2: - Add a note that SPL tests can in fact be run individualy - Document how to run all C tests with 'ut all' - Fix 'get list' typo doc/develop/testing.rst | 5 +++ doc/develop/tests_sandbox.rst | 82 +++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) diff --git a/doc/develop/testing.rst b/doc/develop/testing.rst index 87c90eee271..b181c2e2e41 100644 --- a/doc/develop/testing.rst +++ b/doc/develop/testing.rst @@ -58,6 +58,11 @@ also select particular tests with -k:: ./test/py/test.py --bd sandbox_flattree --build -k hello +There are some special tests that run in SPL. For this you need the sandbox_spl +build:: + + ./test/py/test.py --bd sandbox_spl --build -k test_spl + See test/py/README.md for more information about the pytest suite. See :doc:`tests_sandbox` for how to run tests directly (not through pytest). diff --git a/doc/develop/tests_sandbox.rst b/doc/develop/tests_sandbox.rst index 85bbd4f6734..daf87e53a99 100644 --- a/doc/develop/tests_sandbox.rst +++ b/doc/develop/tests_sandbox.rst @@ -77,3 +77,85 @@ You can easily use gdb on these tests, without needing --gdbserver:: You can then single-step and look at variables as needed. + +Running sandbox_spl tests directly +---------------------------------- + +SPL is the phase before U-Boot proper. It is present in the sandbox_spl build, +so you can run SPL like this:: + + ./spl/u-boot-spl + +SPL tests are special in that they run (only in the SPL phase, of course) if the +-u flag is given:: + + ./spl/u-boot-spl -u + + U-Boot SPL 2021.01-00723-g43c77b51be5-dirty (Jan 24 2021 - 16:38:24 -0700) + Running 5 driver model tests + Test: dm_test_of_plat_base: of_platdata.c (flat tree) + Test: dm_test_of_plat_dev: of_platdata.c (flat tree) + Test: dm_test_of_plat_parent: of_platdata.c (flat tree) + Test: dm_test_of_plat_phandle: of_platdata.c (flat tree) + Test: dm_test_of_plat_props: of_platdata.c (flat tree) + Failures: 0 + + + U-Boot 2021.01-00723-g43c77b51be5-dirty (Jan 24 2021 - 16:38:24 -0700) + + DRAM: 128 MiB + ... + +It is not possible to run SPL tests in U-Boot proper, firstly because they are +not built into U-Boot proper and secondly because the environment is very +different, e.g. some SPL tests rely on of-platdata which is only available in +SPL. + +Note that after running, SPL continues to boot into U-Boot proper. You can add +'-c exit' to make U-Boot quit without doing anything further. It is not +currently possible to run SPL tests and then stop, since the pytests require +that U-Boot produces the expected banner. + +You can use the -k flag to select which tests run:: + + ./spl/u-boot-spl -u -k dm_test_of_plat_parent + +Of course you can use gdb with sandbox_spl, just as with sandbox. + + +Running all tests directly +-------------------------- + +A fast way to run all sandbox tests is:: + + ./u-boot -T -c "ut all" + +It typically runs single-thread in 6 seconds on 2021 hardware, with 2s of that +to the delays in the time test. + +This should not be considered a substitute for 'make check', but can be helpful +for git bisect, etc. + + +What tests are built in? +------------------------ + +Whatever sandbox build is used, which tests are present is determined by which +source files are built. For sandbox_spl, the of_platdata tests are built +because of the build rule in test/dm/Makefile:: + + ifeq ($(CONFIG_SPL_BUILD),y) + obj-$(CONFIG_SPL_OF_PLATDATA) += of_platdata.o + else + ...other tests for non-spl + endif + +You can get a list of tests in a U-Boot ELF file by looking for the +linker_list:: + + $ nm /tmp/b/sandbox_spl/spl/u-boot-spl |grep 2_dm_test + 000000000001f200 D _u_boot_list_2_dm_test_2_dm_test_of_plat_base + 000000000001f220 D _u_boot_list_2_dm_test_2_dm_test_of_plat_dev + 000000000001f240 D _u_boot_list_2_dm_test_2_dm_test_of_plat_parent + 000000000001f260 D _u_boot_list_2_dm_test_2_dm_test_of_plat_phandle + 000000000001f280 D _u_boot_list_2_dm_test_2_dm_test_of_plat_props From patchwork Thu Mar 4 13:50:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447326 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=nXdaFArG; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4Drslp4kKpz9sSC for ; Fri, 5 Mar 2021 00:53:42 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 62ED5827E3; Thu, 4 Mar 2021 14:52:25 +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="nXdaFArG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B3BB382794; Thu, 4 Mar 2021 14:51:59 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) (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 DDA4E826B2 for ; Thu, 4 Mar 2021 14:51:51 +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-ot1-x32a.google.com with SMTP id f33so27231757otf.11 for ; Thu, 04 Mar 2021 05:51:51 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=DgCCNzCtgQaTfZMr2NVmfPA8FGs7mb8r60OXOr5SZnA=; b=nXdaFArG7YFi4/kVmLR7HZg/b3ppQl4W63419nkrBdkUb0MAx0ZEgzcc3NBmfFfFCf EPL2OFka9/I4Ot4HxLMS+s9OBhYUEA2PcYUSbxZTvIXuu3cpkhtJjSPAfLcmY4tAV5RP 58R6LyQQQL1+4CQTvpxXf1bOPtaVhhwrHNeaY= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=DgCCNzCtgQaTfZMr2NVmfPA8FGs7mb8r60OXOr5SZnA=; b=r2QfNVH0m1x0j8hShp6ZSgwdqCyRy04vIKFuhHguSWv/u4TlUbDcCdlxbq10oQkgkv wBbab+viQXxx5FA6vfdXg0HtnEJGrbPHO8GG1jwjBJ2DM2DpLBmzBSUAJxJWzr+HMuYO uUWxwVJTu/mo9deNgPsnGSrX4aQC5K5LgLMk5KK4AXkDpI1Y3ZuKuI5YfyZq6KfxdCfW Ddxy9ExH/hlV/kxd2TPMW9HQEelMSkpkRM0QncjDW9VDJKsz5Bv08waFltQQ1gAdUUnJ hjQEppO+WfI7d1qHNqVGkXS5bl+Sz93onLrbgOMTHicubEdW1rTPpbbO9STk1gjJgGwO TdnQ== X-Gm-Message-State: AOAM531S1ONXY7AUr9BT70fZ4e49xHq946uPk1COo0dSYfoODk1dBmT6 Oc7PE8lZLrl0CyncpemNUZLMu8KGxg48lVry X-Google-Smtp-Source: ABdhPJz6vs/ZPtf+XMBrJMQB9YlmEgHswy3/n7I8agUlslRTDwrKLDhKQZrK3M+mMXp8p+US8PQPPw== X-Received: by 2002:a9d:6d11:: with SMTP id o17mr3420683otp.80.1614865910526; Thu, 04 Mar 2021 05:51:50 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.51.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:51:50 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 08/42] test: Correct setexpr test prefix Date: Thu, 4 Mar 2021 06:50:44 -0700 Message-Id: <20210304135118.643277-8-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean This prefix should be for setexpr, not mem. This means that trying to select just these tests to run does not work. Fix it. For some reason this provokes an assertion failure due to memory not being freed. Move the env_set() in setexpr_test_str() to before the malloc() heap size size is recorded and disable the rest in setexpr_test_str_oper(). Signed-off-by: Simon Glass --- (no changes since v1) test/cmd/setexpr.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/test/cmd/setexpr.c b/test/cmd/setexpr.c index fd6d869c0ed..b483069ff0f 100644 --- a/test/cmd/setexpr.c +++ b/test/cmd/setexpr.c @@ -306,8 +306,8 @@ static int setexpr_test_str(struct unit_test_state *uts) ut_asserteq(1, run_command("setexpr.s fred 0", 0)); ut_assertok(ut_check_delta(start_mem)); - start_mem = ut_check_free(); ut_assertok(env_set("fred", "12345")); + start_mem = ut_check_free(); ut_assertok(run_command("setexpr.s fred *0", 0)); ut_asserteq_str("hello", env_get("fred")); ut_assertok(ut_check_delta(start_mem)); @@ -345,7 +345,22 @@ static int setexpr_test_str_oper(struct unit_test_state *uts) start_mem = ut_check_free(); ut_assertok(run_command("setexpr.s fred *0 + *10", 0)); ut_asserteq_str("hello there", env_get("fred")); - ut_assertok(ut_check_delta(start_mem)); + + /* + * This check does not work with sandbox_flattree, apparently due to + * memory allocations in env_set(). + * + * The truetype console produces lots of memory allocations even though + * the LCD display is not visible. But even without these, it does not + * work. + * + * A better test would be for dlmalloc to record the allocs and frees + * for a particular caller, but that is not supported. + * + * For now, drop this test. + * + * ut_assertok(ut_check_delta(start_mem)); + */ unmap_sysmem(buf); @@ -379,6 +394,6 @@ int do_ut_setexpr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) setexpr_test); const int n_ents = ll_entry_count(struct unit_test, setexpr_test); - return cmd_ut_category("cmd_setexpr", "cmd_mem_", tests, n_ents, argc, - argv); + return cmd_ut_category("cmd_setexpr", "setexpr_test_", tests, n_ents, + argc, argv); } From patchwork Thu Mar 4 13:50:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447324 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=OUPcttSN; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4DrslJ2Y2cz9sSC for ; Fri, 5 Mar 2021 00:53:16 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DE3818278B; Thu, 4 Mar 2021 14:52:16 +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="OUPcttSN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0B57A82774; Thu, 4 Mar 2021 14:51:59 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) (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 04153826F3 for ; Thu, 4 Mar 2021 14:51:53 +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-oi1-x236.google.com with SMTP id l64so30128480oig.9 for ; Thu, 04 Mar 2021 05:51:52 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=r7bEH01GBPrgi5oTnLorSJgA0dmZciBpD9w6eFLIwyA=; b=OUPcttSN42O104DiEgTKNhN0Q/ywHiyJn035bEGn/H23OqDTYl7j7dB7n9kRbMEIuA CYBaQHO4IPv9rGG1e/t6CP5szuYncL5k9b2NwepEHvJA1hAPlZy63m4G/l2aD+kVWQYw fcOfXecUuteiSd3zlSQpa3BTGC1BU27JjYPBE= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=r7bEH01GBPrgi5oTnLorSJgA0dmZciBpD9w6eFLIwyA=; b=KyEuvqHIkXintr4yTMoiM8DCIQkWqfr/11A94ZSns4u7Ks4ylE0/cRRZYHfsHM1tHn IHi5An4+LqFK1Eyv4d2H8wswFblO3FS6c83mwDTNdUAGttt43F11gsEcM2e5xe29Faow s88+WYgY5T7s+Pwk0L5UVv438bZ0KzaO6OQ7f/RmrIhvSgPKeD7uueVB/FCLpY0SCl7G SmrBhHpotuoGkAk8GbCu3z+aXG1125MjbXQKY1G6jlkMUbpLUod0feuxbERgdw6P03py P72wNkFDK/+mcvr7P19EqOeJV/Kzxc8GfcqDjZRlGOtZAv5KmVMHmDhuxcXFh+yLpCwR sLSg== X-Gm-Message-State: AOAM530MQIVzQDaWkh3Qv+9kS4d40phERNVi6d52MTgBtSW8t+59viK7 ZIV59T27O0K42UIf20LdqdstKujeh0fRdjV5 X-Google-Smtp-Source: ABdhPJws96GBVohVcAl1rZdrJf16t7gOVEfy9i0a10dm6BW7BIBIymMsLwLroCu/k3ku9XIeSf4sww== X-Received: by 2002:a05:6808:d46:: with SMTP id w6mr2974512oik.47.1614865911607; Thu, 04 Mar 2021 05:51:51 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.51.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:51:51 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 09/42] test: Mark all driver model tests with a flag Date: Thu, 4 Mar 2021 06:50:45 -0700 Message-Id: <20210304135118.643277-9-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean Add a flag for driver model tests, so we can do special processing for them. Signed-off-by: Simon Glass --- (no changes since v1) include/dm/test.h | 3 ++- include/test/test.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/dm/test.h b/include/dm/test.h index 6ac6672cd6f..dfbc82c756d 100644 --- a/include/dm/test.h +++ b/include/dm/test.h @@ -143,7 +143,8 @@ struct dm_test_state { }; /* Declare a new driver model test */ -#define DM_TEST(_name, _flags) UNIT_TEST(_name, _flags, dm_test) +#define DM_TEST(_name, _flags) \ + UNIT_TEST(_name, UT_TESTF_DM | (_flags), dm_test) /* * struct sandbox_sdl_plat - Platform data for the SDL video driver diff --git a/include/test/test.h b/include/test/test.h index 3fdaa2b5e51..27585507d8c 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -36,6 +36,8 @@ enum { UT_TESTF_FLAT_TREE = BIT(3), /* test needs flat DT */ UT_TESTF_LIVE_TREE = BIT(4), /* needs live device tree */ UT_TESTF_CONSOLE_REC = BIT(5), /* needs console recording */ + /* do extra driver model init and uninit */ + UT_TESTF_DM = BIT(6), }; /** From patchwork Thu Mar 4 13:50:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447328 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=a8E95HGI; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4DrsmM266Hz9sSC for ; Fri, 5 Mar 2021 00:54:11 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A68A782790; Thu, 4 Mar 2021 14:52:31 +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="a8E95HGI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 407E3827BC; Thu, 4 Mar 2021 14:52:03 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) (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 10E368276B for ; Thu, 4 Mar 2021 14:51:54 +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-oi1-x229.google.com with SMTP id s73so4356772oie.1 for ; Thu, 04 Mar 2021 05:51:53 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=wCQcT6NGEQXrU9N+LjpdctyD5yAqK7tzXu2jmu+oEng=; b=a8E95HGIK3YdQHKiONSVERnNFf17Yj7vNZWWAFdzHJnW6cxKtX8Cwbor+o/B3BOwyC u7gPM1C1shRGGVUaJQhTEY68LwkNI+2Np01gjlxwP4IB10ub1uozm4yLBvDP41U9Mxyr fOCg2rlhNpAKZF45WTYDJRBkN8xG904C99UlM= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=wCQcT6NGEQXrU9N+LjpdctyD5yAqK7tzXu2jmu+oEng=; b=TI6gFTXMSvT9ZOqg9X1zKHiROCkwqWVaV+1MpG8RJ0To2Qc/3vONt/+3JVoIcJJoSq KXOWwxWxPiZMk1DaZ0r4j7deknEzwVVozMeUCBa/rV74rLaAPANkjBIRTXoCz8mgrqKY Hma47eF0exLE1AK60qvQWWuvN5ISAs+BkFYssI2B3MhRgq4ONHXpTlRZKdQcLRFkfra2 W2elHeRIThEA4NcXWCCFT5A19K3VIcYSaSPlbEuDe4ozx0fCl6c0rn/ssdhpRngvOIb9 QDwL7FF7oVbu9Di6MDIW2EYgqE4kluvb1I4r4gfpcDV/cN6UzUiQC3gPi65148I9U9UP 6Lrg== X-Gm-Message-State: AOAM531AZyVXp7GgvRAHzjxlrO/VKkDM+VKpzbyBMc+Hke6+z4X4LsKl DfgDfCXCchmwVIMC9OM3UBGAC23hZFjoOrH3 X-Google-Smtp-Source: ABdhPJyc0tSuppoCWzMDMp2VrAZ9DuFqTcHIC0BvNA8AiLkkSrz85MANZ0U6y7ozzF38qgh/VlffeQ== X-Received: by 2002:aca:3946:: with SMTP id g67mr2965461oia.42.1614865912473; Thu, 04 Mar 2021 05:51:52 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.51.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:51:52 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 10/42] test: Rename test-main.c to test-dm.c Date: Thu, 4 Mar 2021 06:50:46 -0700 Message-Id: <20210304135118.643277-10-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean This is the main test function for driver model but not for other tests. Rename the file and the function so this is clear. Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/cpu/spl.c | 2 +- include/test/test.h | 4 ++-- test/dm/Makefile | 2 +- test/dm/{test-main.c => test-dm.c} | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) rename test/dm/{test-main.c => test-dm.c} (98%) diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c index 6926e244ca2..3779d58c3fe 100644 --- a/arch/sandbox/cpu/spl.c +++ b/arch/sandbox/cpu/spl.c @@ -65,7 +65,7 @@ void spl_board_init(void) if (state->run_unittests) { int ret; - ret = dm_test_main(state->select_unittests); + ret = dm_test_run(state->select_unittests); /* continue execution into U-Boot */ } } diff --git a/include/test/test.h b/include/test/test.h index 27585507d8c..d282cb2362d 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -106,7 +106,7 @@ enum { struct udevice *testbus_get_clear_removed(void); /** - * dm_test_main() - Run driver model tests + * dm_test_run() - Run driver model tests * * Run all the available driver model tests, or a selection * @@ -114,6 +114,6 @@ struct udevice *testbus_get_clear_removed(void); * "fdt_pre_reloc"), or NULL to run all * @return 0 if all tests passed, 1 if not */ -int dm_test_main(const char *test_name); +int dm_test_run(const char *test_name); #endif /* __TEST_TEST_H */ diff --git a/test/dm/Makefile b/test/dm/Makefile index fd1455109d4..f5cc5540e8a 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -2,7 +2,7 @@ # # Copyright (c) 2013 Google, Inc -obj-$(CONFIG_UT_DM) += test-main.o +obj-$(CONFIG_UT_DM) += test-dm.o # Tests for particular subsystems - when enabling driver model for a new # subsystem you must add sandbox tests here. diff --git a/test/dm/test-main.c b/test/dm/test-dm.c similarity index 98% rename from test/dm/test-main.c rename to test/dm/test-dm.c index 560f8d63ec6..71e9cf6e5da 100644 --- a/test/dm/test-main.c +++ b/test/dm/test-dm.c @@ -146,7 +146,7 @@ static bool test_matches(const char *test_name, const char *find_name) return false; } -int dm_test_main(const char *test_name) +int dm_test_run(const char *test_name) { struct unit_test *tests = ll_entry_start(struct unit_test, dm_test); const int n_ents = ll_entry_count(struct unit_test, dm_test); @@ -226,5 +226,5 @@ int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) if (argc > 1) test_name = argv[1]; - return dm_test_main(test_name); + return dm_test_run(test_name); } From patchwork Thu Mar 4 13:50:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447327 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=FAsmbAlx; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4Drsm50bytz9sVt for ; Fri, 5 Mar 2021 00:53:57 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 882C782843; Thu, 4 Mar 2021 14:52:28 +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="FAsmbAlx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B305A827AA; Thu, 4 Mar 2021 14:52:04 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) (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 F025C826B9 for ; Thu, 4 Mar 2021 14:51:54 +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-ot1-x32c.google.com with SMTP id j8so1836244otc.0 for ; Thu, 04 Mar 2021 05:51:54 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=V1VP0TSdsM4+4DBXRiIRf8jvTdn/GkeH8w1QoJcCLS4=; b=FAsmbAlxiNJiks+W4lKqDTNY1fe1OcD1UMjMlozNFM+KU98cz/HR1Akf/WH+RTukLP 4mvho7iP3BUDPNrB3IB89hNYbyfu0R8LMbd1GqWIxJo6/f0HQlK+pDvuAI3aJ3+qBINm Xv2wJidy2731aO5u+g8hi6AqPPhUyTOV55NTg= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=V1VP0TSdsM4+4DBXRiIRf8jvTdn/GkeH8w1QoJcCLS4=; b=HHGjqEbk0YCCizO7xpYJFGouhgYb3LMg8KG/22flh7UqtnBvK6135qKe6hJJihnmde D8Ln1MhnWynFt3tj58U10GvXrGni9/73r4Ugfc8e0fWpxhcTG538jo3mdeWeRM+gjPae lfpOtoc5o08L3RjAAM9xR2kvXFxRaTrig9JJciBdW2iV1cHOBEn3Ui/ET/9+wmn4jiF2 HmkRFctaOrB00+1hirwegIsvfYfqmPute9B2Dpyp0JRFyA1TqBdZpv3p3IfSbtUQzCVu UqRHqkrjXOQzg8mnxG+wqsbwRmigrXczx9Ce6JRl1ORAWKxHhnoAZhfQOsyYOhWWJ6/y ajVA== X-Gm-Message-State: AOAM531FWEVvD+ckVtM0ONVZMscqnJopkxxYOSd0bDR+pws0b5hnPmGm FXL95y3CaTydYymsP8J/BbGIjgL5M/IO5qMC X-Google-Smtp-Source: ABdhPJyHozApSx8daMO0qbPNvBEiHCTs165eOxh/KTkRkk0nM/BvM3swlGSnu7Sg3qIiUvPWw+V7Jg== X-Received: by 2002:a9d:7587:: with SMTP id s7mr3750424otk.114.1614865913338; Thu, 04 Mar 2021 05:51:53 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.51.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:51:53 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 11/42] test: Add an overall test runner Date: Thu, 4 Mar 2021 06:50:47 -0700 Message-Id: <20210304135118.643277-11-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean Add a new test runner that will eventually be able to run any test. For now, have it run the 'command' unit tests, so that the functionality in cmd_ut_category() moves into it. Signed-off-by: Simon Glass --- (no changes since v1) include/test/ut.h | 42 ++++++++++++++++++++++++++++++ test/Makefile | 2 ++ test/cmd_ut.c | 38 ++++----------------------- test/test-main.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+), 33 deletions(-) create mode 100644 test/test-main.c diff --git a/include/test/ut.h b/include/test/ut.h index 17400c73ea9..88e75ab791c 100644 --- a/include/test/ut.h +++ b/include/test/ut.h @@ -356,4 +356,46 @@ void ut_silence_console(struct unit_test_state *uts); */ void ut_unsilence_console(struct unit_test_state *uts); +/** + * ut_run_tests() - Run a set of tests + * + * This runs the tests, handling any preparation and clean-up needed. It prints + * the name of each test before running it. + * + * @uts: Test state to update. The caller should ensure that this is zeroed for + * the first call to this function. On exit, @uts->fail_count is + * incremented by the number of failures (0, one hopes) + * @prefix: String prefix for the tests. Any tests that have this prefix will be + * printed without the prefix, so that it is easier to see the unique part + * of the test name. If NULL, no prefix processing is done + * @tests: List of tests to run + * @count: Number of tests to run + * @select_name: Name of a single test to run (from the list provided). If NULL + * then all tests are run + * @return 0 if all tests passed, -ENOENT if test @select_name was not found, + * -EBADF if any failed + */ +int ut_run_tests(struct unit_test_state *uts, const char *prefix, + struct unit_test *tests, int count, const char *select_name); + +/** + * ut_run_tests() - Run a set of tests + * + * This runs the test, handling any preparation and clean-up needed. It prints + * the name of each test before running it. + * + * @category: Category of these tests. This is a string printed at the start to + * announce the the number of tests + * @prefix: String prefix for the tests. Any tests that have this prefix will be + * printed without the prefix, so that it is easier to see the unique part + * of the test name. If NULL, no prefix processing is done + * @tests: List of tests to run + * @count: Number of tests to run + * @select_name: Name of a single test to run (from the list provided). If NULL + * then all tests are run + * @return 0 if all tests passed, -1 if any failed + */ +int ut_run_list(const char *name, const char *prefix, struct unit_test *tests, + int count, const char *select_name); + #endif diff --git a/test/Makefile b/test/Makefile index 932e5173831..5cd284e322e 100644 --- a/test/Makefile +++ b/test/Makefile @@ -2,6 +2,8 @@ # # (C) Copyright 2012 The Chromium Authors +obj-y += test-main.o + ifneq ($(CONFIG_$(SPL_)BLOBLIST),) obj-$(CONFIG_$(SPL_)CMDLINE) += bloblist.o obj-$(CONFIG_$(SPL_)CMDLINE) += bootm.o diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 8f3089890ea..157f6aa9767 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -9,6 +9,7 @@ #include #include #include +#include static int do_ut_all(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); @@ -17,41 +18,12 @@ int cmd_ut_category(const char *name, const char *prefix, struct unit_test *tests, int n_ents, int argc, char *const argv[]) { - struct unit_test_state uts = { .fail_count = 0 }; - struct unit_test *test; - int prefix_len = prefix ? strlen(prefix) : 0; + int ret; - if (argc == 1) - printf("Running %d %s tests\n", n_ents, name); + ret = ut_run_list(name, prefix, tests, n_ents, + argc > 1 ? argv[1] : NULL); - for (test = tests; test < tests + n_ents; test++) { - const char *test_name = test->name; - - /* Remove the prefix */ - if (prefix && !strncmp(test_name, prefix, prefix_len)) - test_name += prefix_len; - - if (argc > 1 && strcmp(argv[1], test_name)) - continue; - printf("Test: %s\n", test->name); - - if (test->flags & UT_TESTF_CONSOLE_REC) { - int ret = console_record_reset_enable(); - - if (ret) { - printf("Skipping: Console recording disabled\n"); - continue; - } - } - - uts.start = mallinfo(); - - test->func(&uts); - } - - printf("Failures: %d\n", uts.fail_count); - - return uts.fail_count ? CMD_RET_FAILURE : 0; + return ret ? CMD_RET_FAILURE : 0; } static struct cmd_tbl cmd_ut_sub[] = { diff --git a/test/test-main.c b/test/test-main.c new file mode 100644 index 00000000000..376e7ebd3d2 --- /dev/null +++ b/test/test-main.c @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2021 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include + +int ut_run_tests(struct unit_test_state *uts, const char *prefix, + struct unit_test *tests, int count, const char *select_name) +{ + struct unit_test *test; + int prefix_len = prefix ? strlen(prefix) : 0; + int found = 0; + + for (test = tests; test < tests + count; test++) { + const char *test_name = test->name; + + /* Remove the prefix */ + if (prefix && !strncmp(test_name, prefix, prefix_len)) + test_name += prefix_len; + + if (select_name && strcmp(select_name, test_name)) + continue; + printf("Test: %s\n", test_name); + found++; + + if (test->flags & UT_TESTF_CONSOLE_REC) { + int ret = console_record_reset_enable(); + + if (ret) { + printf("Skipping: Console recording disabled\n"); + continue; + } + } + + uts->start = mallinfo(); + + test->func(uts); + } + if (select_name && !found) + return -ENOENT; + + return uts->fail_count ? -EBADF : 0; +} + +int ut_run_list(const char *category, const char *prefix, + struct unit_test *tests, int count, const char *select_name) +{ + struct unit_test_state uts = { .fail_count = 0 }; + int ret; + + if (!select_name) + printf("Running %d %s tests\n", count, category); + + ret = ut_run_tests(&uts, prefix, tests, count, select_name); + + if (ret == -ENOENT) + printf("Test '%s' not found\n", select_name); + else + printf("Failures: %d\n", uts.fail_count); + + return ret; +} From patchwork Thu Mar 4 13:50:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447330 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=mtIEWoPy; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4Drsmn1tq5z9sVt for ; Fri, 5 Mar 2021 00:54:33 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C44688270D; Thu, 4 Mar 2021 14:52:36 +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="mtIEWoPy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DB0FE827BC; Thu, 4 Mar 2021 14:52:07 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x235.google.com (mail-oi1-x235.google.com [IPv6:2607:f8b0:4864:20::235]) (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 E468582777 for ; Thu, 4 Mar 2021 14:51:55 +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-oi1-x235.google.com with SMTP id l133so30140809oib.4 for ; Thu, 04 Mar 2021 05:51:55 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=XZnILyS37miM7YGeWKGvnbGHMHBZxjKsRU5y71XHs0M=; b=mtIEWoPyH+miRYD39IG+xHmd1WWgvkbm6/Xr3kYDPuSri3EcMexs7Xq91+1xLdhdCo oaB8gBfrRZc3OBWLn9INp2wMhlW7/2/tJTb+UZS5992s51or7tQj7z1MAGbgKSWEs5jM lIW/5+RK8PRx0hJFnFB916u736CFHWykc/YqA= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=XZnILyS37miM7YGeWKGvnbGHMHBZxjKsRU5y71XHs0M=; b=KW9n/oZgIROPKE9Jx7IFnTHJot62qC4kYGgpvovYNMFhBwD71oi3f7h19VySkSJGpt nmC/epAWWqxkVdBOC7hhsOYfHPDjJSk6Nl5kmjri62mHIgV+Al98lNagZkW2MXqBVu0q BBpSdlhvWNuuJLH5CJWAG4Ijqj55rwCAIYmuG9LjkSnMVHLIDY+gxnPkeKV6YctrOXhi 9ue205r1nivEQUq7B2y6Feyz+G2Mkm7PNKxG0kEZOcERxlYkVCQ8YVFMKslWCkd8F8ED yXhYMXyw/dcipP9ZPLcHiYyuSjJ6u6fMTY7uDU0Si5Ee5D5ThxEFw7YwgWe+Y3JPfs1F UudQ== X-Gm-Message-State: AOAM532JDygc0kj+sG5xDACh2wn42ti3xVxcf+9h1Pg4KaXFjsQXn9cE p2Bf1nT3KnWKsytffZBtWQtOBnpJqg8/3JIE X-Google-Smtp-Source: ABdhPJwX9jVLoN/nWUziD2cu6K54TG0wrTiCefq3lPTiUbsYtmiOETOK7l4f8xxjELme4VvXSNsMCA== X-Received: by 2002:a54:4e8c:: with SMTP id c12mr2908063oiy.175.1614865914379; Thu, 04 Mar 2021 05:51:54 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.51.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:51:54 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 12/42] test: Create pre/post-run functions Date: Thu, 4 Mar 2021 06:50:48 -0700 Message-Id: <20210304135118.643277-12-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean Split out the test preparation into a separation function before expanding it. Add a post-run function as well, currently empty. Signed-off-by: Simon Glass --- (no changes since v1) include/test/ut.h | 20 ++++++++++++++++++++ test/test-main.c | 41 +++++++++++++++++++++++++++++++---------- 2 files changed, 51 insertions(+), 10 deletions(-) diff --git a/include/test/ut.h b/include/test/ut.h index 88e75ab791c..7cb5e10f3af 100644 --- a/include/test/ut.h +++ b/include/test/ut.h @@ -356,6 +356,26 @@ void ut_silence_console(struct unit_test_state *uts); */ void ut_unsilence_console(struct unit_test_state *uts); +/** + * test_pre_run() - Handle any preparation needed to run a test + * + * @uts: Test state + * @test: Test to prepare for + * @return 0 if OK, -EAGAIN to skip this test since some required feature is not + * available, other -ve on error (meaning that testing cannot likely + * continue) + */ +int test_pre_run(struct unit_test_state *uts, struct unit_test *test); + +/** + * test_post_run() - Handle cleaning up after a test + * + * @uts: Test state + * @test: Test to clean up after + * @return 0 if OK, -ve on error (meaning that testing cannot likely continue) + */ +int test_post_run(struct unit_test_state *uts, struct unit_test *test); + /** * ut_run_tests() - Run a set of tests * diff --git a/test/test-main.c b/test/test-main.c index 376e7ebd3d2..7961fd8aa3e 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -8,6 +8,27 @@ #include #include +int test_pre_run(struct unit_test_state *uts, struct unit_test *test) +{ + uts->start = mallinfo(); + + if (test->flags & UT_TESTF_CONSOLE_REC) { + int ret = console_record_reset_enable(); + + if (ret) { + printf("Skipping: Console recording disabled\n"); + return -EAGAIN; + } + } + + return 0; +} + +int test_post_run(struct unit_test_state *uts, struct unit_test *test) +{ + return 0; +} + int ut_run_tests(struct unit_test_state *uts, const char *prefix, struct unit_test *tests, int count, const char *select_name) { @@ -17,6 +38,7 @@ int ut_run_tests(struct unit_test_state *uts, const char *prefix, for (test = tests; test < tests + count; test++) { const char *test_name = test->name; + int ret; /* Remove the prefix */ if (prefix && !strncmp(test_name, prefix, prefix_len)) @@ -27,18 +49,17 @@ int ut_run_tests(struct unit_test_state *uts, const char *prefix, printf("Test: %s\n", test_name); found++; - if (test->flags & UT_TESTF_CONSOLE_REC) { - int ret = console_record_reset_enable(); - - if (ret) { - printf("Skipping: Console recording disabled\n"); - continue; - } - } - - uts->start = mallinfo(); + ret = test_pre_run(uts, test); + if (ret == -EAGAIN) + continue; + if (ret) + return ret; test->func(uts); + + ret = test_post_run(uts, test); + if (ret) + return ret; } if (select_name && !found) return -ENOENT; From patchwork Thu Mar 4 13:50:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447329 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=eIyo71yW; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4DrsmZ5G7rz9sSC for ; Fri, 5 Mar 2021 00:54:22 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 285B78284F; Thu, 4 Mar 2021 14:52:34 +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="eIyo71yW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 84293827A5; Thu, 4 Mar 2021 14:52:05 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x32d.google.com (mail-ot1-x32d.google.com [IPv6:2607:f8b0:4864:20::32d]) (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 8CAE282082 for ; Thu, 4 Mar 2021 14:51:56 +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-ot1-x32d.google.com with SMTP id h22so27281158otr.6 for ; Thu, 04 Mar 2021 05:51:56 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=bZcv9Ipvar4AGc51+/wU0tVHcqev20EidF6E5BGKyOQ=; b=eIyo71yW5+YG1/ek022SpWadPx+8IVSszkrwLy6hU5pWTdZE7E2hk+LbEoGR3f8qbq TNUoGmJ97DW5I08mQt1bak/WELilQeEZESOR9BOkUvnsBYjGrIGf+BrfY15y+Q3vvH2O lh4mfpC/9cOzncTB0+8KXJng8Kqr3eX4k1de8= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=bZcv9Ipvar4AGc51+/wU0tVHcqev20EidF6E5BGKyOQ=; b=bzjnRjqmCFA0gc+uhiUAxjvW4l9u/AydkS5izz0dCYQYGlFMrerUElAvpMtUstadCo UsqdE8YG+HiQ6V7uGP3sRRlaHzN8TtkvRU30etV6oOg1Ie3f8EB+yU70R7pPyCWixTPX DAg/GitfHu3LZxmBwuJEVRrdNycVhEDAJl/cw0A6hPYmljPbF7j5uFPdAVzc1IRtSsCf jz2Ob/r2cxDriH+dqoAvsXYCQ8xtj2kIM8YLde9i6fY3cBHlBkHkyi1DEcQAZEfHCn/r G6RSICY1w8tn0hoHg1JBCmqTC3/Y0lEsf8UNQUCLdsNX1YwEiZRZmY83oZxsqzZCHGe7 b05A== X-Gm-Message-State: AOAM533zN2wemlA+FXg7FlyCTqUOO9PvJKPJVatOc1gbIAMZWQe7mv6f SGMxgSmEZ123LmPWarsClqO9VyEQI124DJJO X-Google-Smtp-Source: ABdhPJxcPxacKe/obr+gQkwYWneJkcC35rxWscbNHmJI9jIlPBuklCWPl0L78k9Z7S0ke9nZcLg0GA== X-Received: by 2002:a9d:7d17:: with SMTP id v23mr428432otn.363.1614865915199; Thu, 04 Mar 2021 05:51:55 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.51.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:51:54 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 13/42] test: Call test_pre/post_run() from driver model tests Date: Thu, 4 Mar 2021 06:50:49 -0700 Message-Id: <20210304135118.643277-13-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean Ultimately we want to get rid of the special driver model test init and use test_pre_run() and test_post_run() for all tests. As a first step, use those function to handle console recording. For now we need a special case for setting uts->start, but that wil go away once all init is in one place. Signed-off-by: Simon Glass --- (no changes since v1) include/dm/test.h | 2 +- test/dm/test-dm.c | 10 +++++----- test/test-main.c | 8 +++++++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/dm/test.h b/include/dm/test.h index dfbc82c756d..c0b463cc0f1 100644 --- a/include/dm/test.h +++ b/include/dm/test.h @@ -144,7 +144,7 @@ struct dm_test_state { /* Declare a new driver model test */ #define DM_TEST(_name, _flags) \ - UNIT_TEST(_name, UT_TESTF_DM | (_flags), dm_test) + UNIT_TEST(_name, UT_TESTF_DM | UT_TESTF_CONSOLE_REC | (_flags), dm_test) /* * struct sandbox_sdl_plat - Platform data for the SDL video driver diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c index 71e9cf6e5da..69a0349d04c 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -97,14 +97,14 @@ static int dm_do_test(struct unit_test_state *uts, struct unit_test *test, (test->flags & UT_TESTF_SCAN_FDT)) ut_assertok(dm_extended_scan(false)); - /* - * Silence the console and rely on console recording to get - * our output. - */ - console_record_reset_enable(); + ut_assertok(test_pre_run(uts, test)); + if (!state->show_test_output) gd->flags |= GD_FLG_SILENT; test->func(uts); + + ut_assertok(test_post_run(uts, test)); + gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD); state_set_skip_delays(false); diff --git a/test/test-main.c b/test/test-main.c index 7961fd8aa3e..9c600094740 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -8,9 +8,13 @@ #include #include +DECLARE_GLOBAL_DATA_PTR; + int test_pre_run(struct unit_test_state *uts, struct unit_test *test) { - uts->start = mallinfo(); + /* DM tests have already done this */ + if (!(test->flags & UT_TESTF_DM)) + uts->start = mallinfo(); if (test->flags & UT_TESTF_CONSOLE_REC) { int ret = console_record_reset_enable(); @@ -26,6 +30,8 @@ int test_pre_run(struct unit_test_state *uts, struct unit_test *test) int test_post_run(struct unit_test_state *uts, struct unit_test *test) { + gd->flags &= ~GD_FLG_RECORD; + return 0; } From patchwork Thu Mar 4 13:50:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447331 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=C7at7YLi; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4Drsn05xJ6z9sVt for ; Fri, 5 Mar 2021 00:54:44 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 718E082850; Thu, 4 Mar 2021 14:52:39 +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="C7at7YLi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 98988827BE; Thu, 4 Mar 2021 14:52:08 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) (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 9502282708 for ; Thu, 4 Mar 2021 14:51:57 +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-ot1-x334.google.com with SMTP id v12so26170983ott.10 for ; Thu, 04 Mar 2021 05:51:57 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=LPuzUuTuRWZatBbrnr4ibvomPxw1MF0uxdyjApIfcVk=; b=C7at7YLijT9kJ24KU6T70JBz07JkHj2mK7SiTGIIYK15UByYKDP4uQPT9guwW99QVr y4mk6JWD++50usqQYMPayERvWvPt/eA3NL1GuadVSYhxtQCGhyhQkpAzJWVF+dK9MGpn IkzsKx4WwDLO303sqmVqZIM9XQcrCteGywlwg= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=LPuzUuTuRWZatBbrnr4ibvomPxw1MF0uxdyjApIfcVk=; b=IyYRIGoCCyGOTbhcH/+JG8TLlxxmC1hw1lBYD/YysWPsD/eKq5geUNnW71WU9arx78 1XI5wyZD0yP61EM8ZpXLIaW5hSr/jxYkn6gIAW+AGoH/tA2z3YxhJkPTuRHuJ2ITBHlC Y7nV/vDlywInBB9zdGm4fYNXsu4THry5GcO/Oem5lx0Kew//X+fpwxGV5E4d6PhKxwpF hZNqbZUJxTKIOPYVON8TqAdyz1RKJJNL2E7lOCSLCfhbepQ5Tj6GSkkR56y3hHqTSBTD p9TJzRYy99tIFnPoClyMCOrbEHhTl7PbiVpzjdUjzuulEgcJ2GvKOtMZjuWGaOwp0Xa7 7mwQ== X-Gm-Message-State: AOAM533ckwhlo8MpDIHeo5bhYKmd6PSZHKadhmz1EDU1iwN6ETaG+jvT dFE5O2HvuEwf7yzIWNq0cfND9K+gjvh2PqMu X-Google-Smtp-Source: ABdhPJz/CsRtZQYEY97mGLu1rkbk4K1f/QmddMRf0maVNx/efdbivZkgcBosG/VGg5bp46h7vmm3tw== X-Received: by 2002:a9d:19a3:: with SMTP id k32mr3505749otk.189.1614865916053; Thu, 04 Mar 2021 05:51:56 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.51.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:51:55 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 14/42] test: Move dm_extended_scan() to test_pre_run() Date: Thu, 4 Mar 2021 06:50:50 -0700 Message-Id: <20210304135118.643277-14-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean Move this step over to the pre-run function. Signed-off-by: Simon Glass --- (no changes since v1) test/dm/test-dm.c | 3 --- test/test-main.c | 7 +++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c index 69a0349d04c..4cb0da13b7c 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -93,9 +93,6 @@ static int dm_do_test(struct unit_test_state *uts, struct unit_test *test, ut_assertok(dm_scan_plat(false)); if (test->flags & UT_TESTF_PROBE_TEST) ut_assertok(do_autoprobe(uts)); - if (!CONFIG_IS_ENABLED(OF_PLATDATA) && - (test->flags & UT_TESTF_SCAN_FDT)) - ut_assertok(dm_extended_scan(false)); ut_assertok(test_pre_run(uts, test)); diff --git a/test/test-main.c b/test/test-main.c index 9c600094740..a971fe0e9c8 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -6,7 +6,10 @@ #include #include +#include +#include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -16,6 +19,10 @@ int test_pre_run(struct unit_test_state *uts, struct unit_test *test) if (!(test->flags & UT_TESTF_DM)) uts->start = mallinfo(); + if (!CONFIG_IS_ENABLED(OF_PLATDATA) && + (test->flags & UT_TESTF_SCAN_FDT)) + ut_assertok(dm_extended_scan(false)); + if (test->flags & UT_TESTF_CONSOLE_REC) { int ret = console_record_reset_enable(); From patchwork Thu Mar 4 13:50:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447334 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=d6m9bget; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4Drsnb4Y8rz9sSC for ; Fri, 5 Mar 2021 00:55:15 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9C10D82867; Thu, 4 Mar 2021 14:52:48 +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="d6m9bget"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 790F0827E1; Thu, 4 Mar 2021 14:52:11 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) (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 2C964826A5 for ; Thu, 4 Mar 2021 14:52:00 +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-ot1-x333.google.com with SMTP id w3so7540777oti.8 for ; Thu, 04 Mar 2021 05:52:00 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=P43RCv2xSUQD5GJJb1x90FWsuT2JOZ85cy6WDv4Kgno=; b=d6m9bget4ChVrgeRchngJXTJGKo0bFXLPq/2KRKEZx41KWQelp3oeZY+QwPnrUaDiI fZxoOj+rhYM8RsQxYs1DWNIVycCAVs4U3KsjPuF7p/B85T4skU4MWcvZjcehVYGhb8Q8 FffXnmNTIW+3m17B/5IwJHU7PLXECD5r1uBoI= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=P43RCv2xSUQD5GJJb1x90FWsuT2JOZ85cy6WDv4Kgno=; b=hq0092RBsh4oHiSIQDr3gYt29WbAjj5jDvkY9pq3XlwrcRL9ceHC0aZwyfduPQXc2+ sxBl5O02Bi7nT5TWTKtehhm/dkQzSygZs3AuuxXVupEGJDISgBMgfCK6G/k2kXMVvLnO +Pt9q9PMHAAmnctaR3nKqBC6Wh97lxiAmU6vcV8pUuMq3ALbZYlk3nj+ZvVmWVplxghZ jvQnVMbxYcc6ymucNVRJBPRjlRPKzynXGHFToaVNkEFAkNghnoCCkRxNkekJgt4bvhiW A3RFiIasfy4HIn7QKcZV4ZVrKcLzTNNEZkjc52UNJZIZLa5oHJ+q4RthFGCRBYOvy/xQ 20lg== X-Gm-Message-State: AOAM5303ABnKDsZ3n0BHpjGBmec7jBeY5jeRT6D0/pyTN3Uv8MMSmVhR LN4MR9xIByRm2PfzUZipIxaevxANgI76Pp5l X-Google-Smtp-Source: ABdhPJwEmZ7D+yq0lPEPnAJLGBBrurDOcyoAD8M5X6dgRn6Qydox2uu/F1mhy3r9HD8bGqKh+2YNdA== X-Received: by 2002:a05:6830:1416:: with SMTP id v22mr3430778otp.239.1614865916939; Thu, 04 Mar 2021 05:51:56 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.51.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:51:56 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 15/42] test: Move do_autoprobe() to test_pre_run() Date: Thu, 4 Mar 2021 06:50:51 -0700 Message-Id: <20210304135118.643277-15-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean Move this step over to the pre-run function. Signed-off-by: Simon Glass --- (no changes since v1) test/dm/test-dm.c | 17 ----------------- test/test-main.c | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c index 4cb0da13b7c..c2e1a1b9207 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -43,21 +43,6 @@ static int dm_test_init(struct unit_test_state *uts, bool of_live) return 0; } -/* Ensure all the test devices are probed */ -static int do_autoprobe(struct unit_test_state *uts) -{ - struct udevice *dev; - int ret; - - /* Scanning the uclass is enough to probe all the devices */ - for (ret = uclass_first_device(UCLASS_TEST, &dev); - dev; - ret = uclass_next_device(&dev)) - ; - - return ret; -} - static int dm_test_destroy(struct unit_test_state *uts) { int id; @@ -91,8 +76,6 @@ static int dm_do_test(struct unit_test_state *uts, struct unit_test *test, uts->start = mallinfo(); if (test->flags & UT_TESTF_SCAN_PDATA) ut_assertok(dm_scan_plat(false)); - if (test->flags & UT_TESTF_PROBE_TEST) - ut_assertok(do_autoprobe(uts)); ut_assertok(test_pre_run(uts, test)); diff --git a/test/test-main.c b/test/test-main.c index a971fe0e9c8..bd2f08a2b42 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -13,12 +13,30 @@ DECLARE_GLOBAL_DATA_PTR; +/* Ensure all the test devices are probed */ +static int do_autoprobe(struct unit_test_state *uts) +{ + struct udevice *dev; + int ret; + + /* Scanning the uclass is enough to probe all the devices */ + for (ret = uclass_first_device(UCLASS_TEST, &dev); + dev; + ret = uclass_next_device(&dev)) + ; + + return ret; +} + int test_pre_run(struct unit_test_state *uts, struct unit_test *test) { /* DM tests have already done this */ if (!(test->flags & UT_TESTF_DM)) uts->start = mallinfo(); + if (test->flags & UT_TESTF_PROBE_TEST) + ut_assertok(do_autoprobe(uts)); + if (!CONFIG_IS_ENABLED(OF_PLATDATA) && (test->flags & UT_TESTF_SCAN_FDT)) ut_assertok(dm_extended_scan(false)); From patchwork Thu Mar 4 13:50:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447332 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=dUwtCbJB; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4DrsnB6Jb5z9sSC for ; Fri, 5 Mar 2021 00:54:54 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1A61482861; Thu, 4 Mar 2021 14:52:42 +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="dUwtCbJB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 79A73827C3; Thu, 4 Mar 2021 14:52:08 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) (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 825E38279C for ; Thu, 4 Mar 2021 14:51:59 +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-ot1-x331.google.com with SMTP id h10so16616398otm.1 for ; Thu, 04 Mar 2021 05:51:59 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=UoC/8qj20jVCDa95uSARZipULHAHynYl4NFHT4Y5clg=; b=dUwtCbJBMXqyMLqLp3e3Lfta2s7stUT+qJu8CbAU3zaKlyt8sZbWZBjTeEndsfiHpY HHjhXB/4HyEVJ2roASg6L6Zy/M3BtYPwDBBaiQokd9luvF9TaV4om0MbsyCKHgN7vOjG 4jGajgMzYrcP7ckjg1JOTBsZsK/+TfElrBZcE= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=UoC/8qj20jVCDa95uSARZipULHAHynYl4NFHT4Y5clg=; b=kFgTe+ukrxmlTeU5phU1wX2SCyoMv8oNWFN4HwR7H4QyYTHkdZ4as/GTlfpBWKr/Ba 1eGXw2zvXwLw8V7ZDtHOgPW42VDPioNlPG0hicE8+6BcaHwqAtEIVVPikby2xiGRv8Iu vsfV3EBCZ8yZytezVATOzBcL5oufbIeefCoQl6m9gdhjBKN54bHdnbelGDjFimjfhbtD eDP/UnTQVLSrH3sUcVEazu/HOcPV1nW3KAESXQ+1oDmV8qBp1ukRKYfgt5CoHfmfH2nE tg9u0CXUfXkUMPggt9MDRF4ec/k6EHPhx+TGTaaqKJe1Krh0EeUlJ2ZO3NADLG3ki2UE IoOQ== X-Gm-Message-State: AOAM533RxpJQ9lJHhGCH9mpSeMAqacsTQgUhCuvZM2F6M7zC7bNz+msp CrxNGA7hK8s5TSgeXVBvCyUWMTxX7Vs0bRIP X-Google-Smtp-Source: ABdhPJx3fXNqkRRwlZo73Lz2gl7arP9XFyIfijzGgWrrBvGmpZyEbO/jk/mrO3NW4YcgSKFpDRhCVw== X-Received: by 2002:a9d:335:: with SMTP id 50mr3383791otv.44.1614865917786; Thu, 04 Mar 2021 05:51:57 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.51.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:51:57 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 16/42] test: Move dm_scan_plat() to test_pre_run() Date: Thu, 4 Mar 2021 06:50:52 -0700 Message-Id: <20210304135118.643277-16-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean Move this step over to the pre-run function. Signed-off-by: Simon Glass --- (no changes since v1) test/dm/test-dm.c | 2 -- test/test-main.c | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c index c2e1a1b9207..18877c7ae56 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -74,8 +74,6 @@ static int dm_do_test(struct unit_test_state *uts, struct unit_test *test, ut_assertok(dm_test_init(uts, of_live)); uts->start = mallinfo(); - if (test->flags & UT_TESTF_SCAN_PDATA) - ut_assertok(dm_scan_plat(false)); ut_assertok(test_pre_run(uts, test)); diff --git a/test/test-main.c b/test/test-main.c index bd2f08a2b42..fe96d739dc4 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -34,6 +34,9 @@ int test_pre_run(struct unit_test_state *uts, struct unit_test *test) if (!(test->flags & UT_TESTF_DM)) uts->start = mallinfo(); + if (test->flags & UT_TESTF_SCAN_PDATA) + ut_assertok(dm_scan_plat(false)); + if (test->flags & UT_TESTF_PROBE_TEST) ut_assertok(do_autoprobe(uts)); From patchwork Thu Mar 4 13:50:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447333 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=h0q7yf8l; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4DrsnP0zvWz9sSC for ; Fri, 5 Mar 2021 00:55:05 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2F20382822; Thu, 4 Mar 2021 14:52:44 +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="h0q7yf8l"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 042E4827BC; Thu, 4 Mar 2021 14:52:10 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) (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 595218275B for ; Thu, 4 Mar 2021 14:52:00 +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-oi1-x229.google.com with SMTP id f3so30110790oiw.13 for ; Thu, 04 Mar 2021 05:52:00 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=x9hVKdYsn+cTZfOvWOsIdMYWG3WhTa8TOyM2wvwMVh0=; b=h0q7yf8lRYcDFYug9hWIjPspoRC1B9iYrJo0saHNQxkxDSSM/Xx+vVqsqZ7sR+e+WH 2VK1awX4TCX02O3RVZMrLU2BPjc/WRMe4VgAL2HNVpHycK0AxGt/pFwnM8//S3pWSyHx IDFkSzdRx5agzLqhuB5MI06CjJ9MnDEIn7uRI= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=x9hVKdYsn+cTZfOvWOsIdMYWG3WhTa8TOyM2wvwMVh0=; b=W2W6UlDAWGu0zKsDrobyWANOT1N1agVoaVr+8tfrJtulJeN6/q9+EW0mUem2X5GeoS VEiMFJtrLrc+P345MiPqj0ObtKD15JfZyonghkGPf8tV4mViAYoSdP7LMz9QcjneRaEb ighFXqAFydM3/KVQlSs+3Nvou4stM2yQmw58rXxcXg30uHNks3Uq4ZJAIUaaodbmmHGf enNiGjjzZD5ceixdS/dxWPJ8AdTi7qmgZug2Z6c7QHh+2HTkCumUPXeizq8ISAdkR4R9 InWDMi142eKIoKUDhrLJdCkoUROv1wrhDTmJ3CqwNvPS7V/VBROaQBKSa5KMZwETsWQG cDKg== X-Gm-Message-State: AOAM530qXZ/RB+1N6Uxf6kYFY+eH2+CcOZio4OnYgMBj8Zj0Goe+bz+Q rJwIN0WyEZ67sKmBKARDYzPUbeHZdZIl5+zg X-Google-Smtp-Source: ABdhPJxNXw22aKL/KCyyTFBRhI2zxpWMkGBCNDnTkwQ19J8BgpKMMuoXbp+CRl4/jDojTVHfdAMwTg== X-Received: by 2002:aca:4486:: with SMTP id r128mr2892078oia.171.1614865918731; Thu, 04 Mar 2021 05:51:58 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.51.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:51:58 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 17/42] test: Drop mallinfo() work-around Date: Thu, 4 Mar 2021 06:50:53 -0700 Message-Id: <20210304135118.643277-17-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean This is not needed now. Drop it. Signed-off-by: Simon Glass --- (no changes since v1) test/dm/test-dm.c | 2 -- test/test-main.c | 4 +--- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c index 18877c7ae56..d1d83e34782 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -73,8 +73,6 @@ static int dm_do_test(struct unit_test_state *uts, struct unit_test *test, !of_live ? " (flat tree)" : ""); ut_assertok(dm_test_init(uts, of_live)); - uts->start = mallinfo(); - ut_assertok(test_pre_run(uts, test)); if (!state->show_test_output) diff --git a/test/test-main.c b/test/test-main.c index fe96d739dc4..db0d82e36c3 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -30,9 +30,7 @@ static int do_autoprobe(struct unit_test_state *uts) int test_pre_run(struct unit_test_state *uts, struct unit_test *test) { - /* DM tests have already done this */ - if (!(test->flags & UT_TESTF_DM)) - uts->start = mallinfo(); + uts->start = mallinfo(); if (test->flags & UT_TESTF_SCAN_PDATA) ut_assertok(dm_scan_plat(false)); From patchwork Thu Mar 4 13:50:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447335 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=PnzyK6Dc; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4Drsnp42npz9sSC for ; Fri, 5 Mar 2021 00:55:26 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id ABC198287F; Thu, 4 Mar 2021 14:52:51 +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="PnzyK6Dc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 45CD1827AB; Thu, 4 Mar 2021 14:52:12 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE, T_FILL_THIS_FORM_SHORT autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) (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 417458278B for ; Thu, 4 Mar 2021 14:52:01 +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-ot1-x32a.google.com with SMTP id r19so27307187otk.2 for ; Thu, 04 Mar 2021 05:52:01 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=Hqf4jp5c4caIzAef7xvlL5BJbLnbEU9rf+DBcbhaKvw=; b=PnzyK6DcP0JFyg1uISPj6Ayal/B0EbZwu6nl2CNCrPcwNSx4OAuZPIldmiHj07tNdP oqaPhnXAnCOJQ/3kYgMU+Qn6zZEzPE9FUkTwXdKLRTTo9cK3Awsx8sloNxHrNCgDb7W9 e4488Vq9FQNdgegEfOWKNV99DcyZjiZA+PB5o= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Hqf4jp5c4caIzAef7xvlL5BJbLnbEU9rf+DBcbhaKvw=; b=JCLRGB874rKJ+rmoC+xuoW2YvLolGrxznZ40B9F7gqPEc3sfMbDzUUellF46LZlGUw Aus++zV13+8I8/6EyjrDeMcAUjYOiLO3wXhfsQxyAApKJnADeJjyM9gBLd1PeVzfqWIk 2O9Vs8kEynJACkeFcyzMg2ijv23lzV2CiuqPxQqCjKZY4rqWwH0209k/DZf1D2SLTTh0 vMPQ5ZyX+zIBMSlSc2Fk8hP9pkM0PZ7RmK/NwCxSYBHdIndWIDI+S3ScYB0C+TI/yYs9 HXCz+0XMQcEztL9XyMBdnGkbU8WyNrQdO0O29Q+kHL3WDqk4PhcZBswzjefgddwPXJMT Hl6A== X-Gm-Message-State: AOAM5334tIumfEfMC+geMFVqi7M0mMasvUU+JwRTcttIMT2LHdu+D3kn d/fd1/hjOo/Yhl8iHhVbeeJUi8DwdPiUsSnf X-Google-Smtp-Source: ABdhPJxm7IE345pNk9woUAIu9AcOmD+2tW0t/WK/jpuFg3UuFtm9Ph3oUCJatUA6+Xn6QgnT1Ntx9w== X-Received: by 2002:a9d:4c82:: with SMTP id m2mr3664873otf.101.1614865919932; Thu, 04 Mar 2021 05:51:59 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.51.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:51:59 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 18/42] test: Move console silencing to test_pre_run() Date: Thu, 4 Mar 2021 06:50:54 -0700 Message-Id: <20210304135118.643277-18-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean We already have a function for silencing the console during tests. Use this from test_pre_run() and drop this code from the driver model tests. Signed-off-by: Simon Glass --- (no changes since v1) test/dm/test-dm.c | 4 ---- test/test-main.c | 3 ++- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c index d1d83e34782..fdd35f663e4 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -66,7 +66,6 @@ static int dm_test_destroy(struct unit_test_state *uts) static int dm_do_test(struct unit_test_state *uts, struct unit_test *test, bool of_live) { - struct sandbox_state *state = state_get_current(); const char *fname = strrchr(test->file, '/') + 1; printf("Test: %s: %s%s\n", test->name, fname, @@ -75,13 +74,10 @@ static int dm_do_test(struct unit_test_state *uts, struct unit_test *test, ut_assertok(test_pre_run(uts, test)); - if (!state->show_test_output) - gd->flags |= GD_FLG_SILENT; test->func(uts); ut_assertok(test_post_run(uts, test)); - gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD); state_set_skip_delays(false); ut_assertok(dm_test_destroy(uts)); diff --git a/test/test-main.c b/test/test-main.c index db0d82e36c3..e273777b6e2 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -50,13 +50,14 @@ int test_pre_run(struct unit_test_state *uts, struct unit_test *test) return -EAGAIN; } } + ut_silence_console(uts); return 0; } int test_post_run(struct unit_test_state *uts, struct unit_test *test) { - gd->flags &= ~GD_FLG_RECORD; + ut_unsilence_console(uts); return 0; } From patchwork Thu Mar 4 13:50:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447336 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=DjHP0opB; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4Drsp12m5qz9sVt for ; Fri, 5 Mar 2021 00:55:37 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 30DD082879; Thu, 4 Mar 2021 14:52:54 +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="DjHP0opB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 154C88277D; Thu, 4 Mar 2021 14:52:14 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oo1-xc34.google.com (mail-oo1-xc34.google.com [IPv6:2607:f8b0:4864:20::c34]) (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 F0FD18277D for ; Thu, 4 Mar 2021 14:52:02 +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-oo1-xc34.google.com with SMTP id e17so6582509oow.4 for ; Thu, 04 Mar 2021 05:52:02 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=HK75Y73HVeXLYKTz7YiqVnF0jbxrA1BvzZfwNJ5wxoA=; b=DjHP0opBX+fnHV5jEsW39F9frmfCw1z2VJSrplYmS+px7bDX4Y2b22P+QMBbwqkzNE oo8HoZfbO1buNmpTwQ2YN/Es3HBZKrErTh9LsQb1dA4qsDUCVuCx6bopDRWVJ5RXc08+ Sp7d9qIJ+txu9afZGu5YRzXcb+UobdtlvAxkY= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=HK75Y73HVeXLYKTz7YiqVnF0jbxrA1BvzZfwNJ5wxoA=; b=ROaF/57zL6jAIqTe07z3PeUmH5RkM5ixtw7uxbaHV4bktzC20VKQFaTmJ5xrDgxh47 /cR+qGFMy8hzZP5LSN+DC16HeeSqQiue/TjoZpM9bqIqYwsZSLNEjUrc8D0cOnsNQttj E32++ZdfiRQBls36gDP0rTjzWiMdm3R638D5lTRkzR3AYgTrQ1h7yIGHI0XOhDUF3qqC k+/HtXXeZbiEMWwEpSthdluR8V4LpIeNzpmh/VklP8MADolQ1kqxqqskp7UfAlqRryl9 Yl7rpZeS8t1Fld3+nOgSLy0DMQTmcG4sX+K7STIUdOtXdrODBd4vYeqhVJYvNlOWPgV3 HLmA== X-Gm-Message-State: AOAM532cm5YrNJ+0tZk9Xt0o4cKmX1bLKzwDrQ9lGC1in0AbeIYEl595 VW0HNes7CJmjxP80DPUrAgpCuPMftsLgY7re X-Google-Smtp-Source: ABdhPJxtAgadNrI6gjhKrzgJuLccVR1gw4E7/pdtawrIpAfmOH0AJU+uqDSBdwuRjoJlXsbRwjtpNQ== X-Received: by 2002:a4a:4cd6:: with SMTP id a205mr3413254oob.4.1614865920993; Thu, 04 Mar 2021 05:52:00 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:00 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 19/42] test: Move delay skipping to test_pre_run() Date: Thu, 4 Mar 2021 06:50:55 -0700 Message-Id: <20210304135118.643277-19-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean This allows delays to be skipped in sandbox tests. Move it to the common pre-init function. Signed-off-by: Simon Glass --- (no changes since v1) include/test/ut.h | 11 +++++++++++ test/dm/test-dm.c | 2 -- test/test-main.c | 2 ++ test/ut.c | 7 +++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/include/test/ut.h b/include/test/ut.h index 7cb5e10f3af..e5ec18e60b0 100644 --- a/include/test/ut.h +++ b/include/test/ut.h @@ -356,6 +356,17 @@ void ut_silence_console(struct unit_test_state *uts); */ void ut_unsilence_console(struct unit_test_state *uts); +/** + * ut_set_skip_delays() - Sets whether delays should be skipped + * + * Normally functions like mdelay() cause U-Boot to wait for a while. This + * allows all such delays to be skipped on sandbox, to speed up tests + * + * @uts: Test state (in case in future we want to keep state here) + * @skip_delays: true to skip delays, false to process them normally + */ +void ut_set_skip_delays(struct unit_test_state *uts, bool skip_delays); + /** * test_pre_run() - Handle any preparation needed to run a test * diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c index fdd35f663e4..569ffbbad93 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -78,8 +78,6 @@ static int dm_do_test(struct unit_test_state *uts, struct unit_test *test, ut_assertok(test_post_run(uts, test)); - state_set_skip_delays(false); - ut_assertok(dm_test_destroy(uts)); return 0; diff --git a/test/test-main.c b/test/test-main.c index e273777b6e2..6f0d32f7e27 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -30,6 +30,8 @@ static int do_autoprobe(struct unit_test_state *uts) int test_pre_run(struct unit_test_state *uts, struct unit_test *test) { + ut_set_skip_delays(uts, false); + uts->start = mallinfo(); if (test->flags & UT_TESTF_SCAN_PDATA) diff --git a/test/ut.c b/test/ut.c index 7328338731c..ea0af153e4a 100644 --- a/test/ut.c +++ b/test/ut.c @@ -133,3 +133,10 @@ void ut_unsilence_console(struct unit_test_state *uts) { gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD); } + +void ut_set_skip_delays(struct unit_test_state *uts, bool skip_delays) +{ +#ifdef CONFIG_SANDBOX + state_set_skip_delays(skip_delays); +#endif +} From patchwork Thu Mar 4 13:50:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447337 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=LEFdtoBA; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4DrspC3mHgz9sSC for ; Fri, 5 Mar 2021 00:55:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 91A4E8288C; Thu, 4 Mar 2021 14:52:56 +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="LEFdtoBA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3FD438278B; Thu, 4 Mar 2021 14:52:15 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) (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 4CA11827B1 for ; Thu, 4 Mar 2021 14:52:03 +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-oi1-x22f.google.com with SMTP id s73so4357252oie.1 for ; Thu, 04 Mar 2021 05:52:03 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ky71vPYSXmgrhfPrhjISh2ZLn08DxacGS/TppWDwm+I=; b=LEFdtoBAyW5Xgb37FoB58+FFhrZo4Pf2eh0qIcVAK0gWoeQAPnchRxSlBSpbMS/3md EzMuFXx2M6cNq19kz9lpKA2SzZoPCjgfpWvCxMCJZ4czROSgUSD1eny2DByWEFFbETmh 1ylF6pAmdqqSM5i47p8uZ8MVZQ291v/ORFbhE= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ky71vPYSXmgrhfPrhjISh2ZLn08DxacGS/TppWDwm+I=; b=nVxGqwsyr0pNYN3JDzhxx/cCyTZllx+VFuCtOj7dPJ0becznnPRygXhyKxgIie7PUX GM7/eqtHU/B5g4tg4vCfiJw7mrJU01/GkQIAAkarghDPmp+ur0vT2n6WgQ2PPJBh+VcP YT08bImS1kIt46Ctc31J1GbiI/drZSDXmNO0rAudO3SZ1JTfG+CFP/bGKL3D6Hz3Y2Ai 47Had6UcXdyVjFnogZguj/0t+v7/xTdhc9YYJpqAysrlsHjPVt7NlqX1JdhQpV4OOLW+ H//CXakWIydMiqzLGUMZmaP/B8L80REnMwSvb75iwoi1S+0JqUaia8+UzbcEku3TY9gX hyVg== X-Gm-Message-State: AOAM532dqZwAvq3MbZ3/sJsh6IYi5//+vUPmZMHt9TtWsQ/mxF4G0YnD r1LdBP8osvx01zeYaExpZqadeWBE9NZDXvz6 X-Google-Smtp-Source: ABdhPJx9nioqRayxrYl/RWkuDLjHWarZJ3x1W9AoWWueZlEbkOmCujHm+436gCQtBmgmrWWx44g8ng== X-Received: by 2002:a05:6808:b07:: with SMTP id s7mr2985894oij.25.1614865921889; Thu, 04 Mar 2021 05:52:01 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:01 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 20/42] test: Handle driver model reinit in test_pre_run() Date: Thu, 4 Mar 2021 06:50:56 -0700 Message-Id: <20210304135118.643277-20-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean For driver model tests we want to reinit the data structures so that everything is in a known state before the test runs. This avoids one test changing something that breaks a subsequent tests. Move the call for this into test_pre_run(). Signed-off-by: Simon Glass --- (no changes since v1) include/test/test.h | 2 ++ include/test/ut.h | 10 ++++++++++ test/dm/test-dm.c | 6 +++--- test/test-main.c | 3 +++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/include/test/test.h b/include/test/test.h index d282cb2362d..6997568cc07 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -15,6 +15,7 @@ * @fail_count: Number of tests that failed * @start: Store the starting mallinfo when doing leak test * @priv: A pointer to some other info some suites want to track + * @of_live: true to use livetree if available, false to use flattree * @of_root: Record of the livetree root node (used for setting up tests) * @expect_str: Temporary string used to hold expected string value * @actual_str: Temporary string used to hold actual string value @@ -24,6 +25,7 @@ struct unit_test_state { struct mallinfo start; void *priv; struct device_node *of_root; + bool of_live; char expect_str[256]; char actual_str[256]; }; diff --git a/include/test/ut.h b/include/test/ut.h index e5ec18e60b0..6e56ca99c31 100644 --- a/include/test/ut.h +++ b/include/test/ut.h @@ -387,6 +387,16 @@ int test_pre_run(struct unit_test_state *uts, struct unit_test *test); */ int test_post_run(struct unit_test_state *uts, struct unit_test *test); +/** + * dm_test_init() - Get ready to run a driver model test + * + * This clears out the driver model data structures. For sandbox it resets the + * state structure. + * + * @uts: Test state + */ +int dm_test_init(struct unit_test_state *uts); + /** * ut_run_tests() - Run a set of tests * diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c index 569ffbbad93..ceeac3fd361 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -24,10 +24,10 @@ DECLARE_GLOBAL_DATA_PTR; struct unit_test_state global_dm_test_state; static struct dm_test_state _global_priv_dm_test_state; -/* Get ready for testing */ -static int dm_test_init(struct unit_test_state *uts, bool of_live) +int dm_test_init(struct unit_test_state *uts) { struct dm_test_state *dms = uts->priv; + bool of_live = uts->of_live; memset(dms, '\0', sizeof(*dms)); gd->dm_root = NULL; @@ -70,7 +70,7 @@ static int dm_do_test(struct unit_test_state *uts, struct unit_test *test, printf("Test: %s: %s%s\n", test->name, fname, !of_live ? " (flat tree)" : ""); - ut_assertok(dm_test_init(uts, of_live)); + uts->of_live = of_live; ut_assertok(test_pre_run(uts, test)); diff --git a/test/test-main.c b/test/test-main.c index 6f0d32f7e27..f14b7b09f79 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -30,6 +30,9 @@ static int do_autoprobe(struct unit_test_state *uts) int test_pre_run(struct unit_test_state *uts, struct unit_test *test) { + if (test->flags & UT_TESTF_DM) + ut_assertok(dm_test_init(uts)); + ut_set_skip_delays(uts, false); uts->start = mallinfo(); From patchwork Thu Mar 4 13:50:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447341 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=JDJcE4UU; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4Drsq13ypMz9sRf for ; Fri, 5 Mar 2021 00:56:29 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B8FD382893; Thu, 4 Mar 2021 14:53:15 +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="JDJcE4UU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BD75482804; Thu, 4 Mar 2021 14:52: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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) (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 808498276B for ; Thu, 4 Mar 2021 14:52: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-oi1-x22f.google.com with SMTP id o3so30132457oic.8 for ; Thu, 04 Mar 2021 05:52: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:in-reply-to:references :mime-version:content-transfer-encoding; bh=BVmvpFDVTCSE0+gHFuqCnD7fHdI4Kl+yneAiKQvGPdg=; b=JDJcE4UUyMKhimC6r5zc1MxTzp5EkCchI90Ftm0xizvmxDpoMQi13KHcVDOZu7OuOj 5b4/fjHJzF1z3KwRyjvB37GRJSSzNAxylri6MYX8cBOeGMT3feuhLBRgd5+NQIi9bPRj x+aZqHQE23SSnme3L7dmNte6i0NrlSp2p9Ezg= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=BVmvpFDVTCSE0+gHFuqCnD7fHdI4Kl+yneAiKQvGPdg=; b=CnhXMnWH4IvaUxFGLX0FRIm6YmQ39qwtVRqI79WMvxLOX+vLcz/kojy977ZAYKW/Gh +of6eVXRjStDe8X7x5ANH141e5MmeHzH/QVKX2j6ZWGELVAC7O1PRo8oIKD2h6YwZc7z 71p9VuoCblzzfx1IoitcqgTuzXyDgeF7D4dqzJcVKv1Cjzm4M34OREc6QpggUa9jzvqD UYnjmUDtat+Kt41z7NxouDtacIbzF7o13V+35rxFCShzvjwF3cY8yk9uPU3Fb4R+piAJ OaLfnCDGT6+2e27FNfUjbimnNYtfKNsj5dlNfXoPbAUYi8frJ1s8AG4EnYz/d7vq+BL1 NzHg== X-Gm-Message-State: AOAM532lRXPivpS0dX1Qee71B1YdGQtr3s1F5UO/2XLRVv5tOi3HZKog hOGqYdaKpSBy+I8IlP/pxk0CzBP2ZQZwgic7 X-Google-Smtp-Source: ABdhPJx0UB/2ngIowqbI7v2AsHuqiCfYEviqN2H0xc3honAIJ4c5+HVgs3/7ruQtmjGRprzFFjKWBA== X-Received: by 2002:a05:6808:105:: with SMTP id b5mr2991372oie.53.1614865922838; Thu, 04 Mar 2021 05:52:02 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:02 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 21/42] test: Drop struct dm_test_state Date: Thu, 4 Mar 2021 06:50:57 -0700 Message-Id: <20210304135118.643277-21-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean Driver model is a core part of U-Boot. We don't really need to have a separate test structure for the driver model tests and it makes it harder to write a test if you have to think about which type of test it is. Subsume the fields from struct dm_test_state into struct unit_test_state and delete the former. Signed-off-by: Simon Glass --- Changes in v4: - Rebase on master include/dm/test.h | 17 ------------- include/test/test.h | 10 ++++++-- test/dm/core.c | 58 ++++++++++++++++++------------------------- test/dm/test-dm.c | 10 ++++---- test/dm/test-driver.c | 4 +-- test/dm/test-uclass.c | 3 +-- 6 files changed, 39 insertions(+), 63 deletions(-) diff --git a/include/dm/test.h b/include/dm/test.h index c0b463cc0f1..fe1cc2e278c 100644 --- a/include/dm/test.h +++ b/include/dm/test.h @@ -125,23 +125,6 @@ extern int dm_testdrv_op_count[DM_TEST_OP_COUNT]; extern struct unit_test_state global_dm_test_state; -/* - * struct dm_test_state - Entire state of dm test system - * - * This is often abreviated to dms. - * - * @root: Root device - * @testdev: Test device - * @force_fail_alloc: Force all memory allocs to fail - * @skip_post_probe: Skip uclass post-probe processing - */ -struct dm_test_state { - struct udevice *root; - struct udevice *testdev; - int force_fail_alloc; - int skip_post_probe; -}; - /* Declare a new driver model test */ #define DM_TEST(_name, _flags) \ UNIT_TEST(_name, UT_TESTF_DM | UT_TESTF_CONSOLE_REC | (_flags), dm_test) diff --git a/include/test/test.h b/include/test/test.h index 6997568cc07..5eeec35f525 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -14,18 +14,24 @@ * * @fail_count: Number of tests that failed * @start: Store the starting mallinfo when doing leak test - * @priv: A pointer to some other info some suites want to track * @of_live: true to use livetree if available, false to use flattree * @of_root: Record of the livetree root node (used for setting up tests) + * @root: Root device + * @testdev: Test device + * @force_fail_alloc: Force all memory allocs to fail + * @skip_post_probe: Skip uclass post-probe processing * @expect_str: Temporary string used to hold expected string value * @actual_str: Temporary string used to hold actual string value */ struct unit_test_state { int fail_count; struct mallinfo start; - void *priv; struct device_node *of_root; bool of_live; + struct udevice *root; + struct udevice *testdev; + int force_fail_alloc; + int skip_post_probe; char expect_str[256]; char actual_str[256]; }; diff --git a/test/dm/core.c b/test/dm/core.c index 35ca689d646..2210345dd14 100644 --- a/test/dm/core.c +++ b/test/dm/core.c @@ -117,14 +117,13 @@ int dm_leak_check_end(struct unit_test_state *uts) /* Test that binding with plat occurs correctly */ static int dm_test_autobind(struct unit_test_state *uts) { - struct dm_test_state *dms = uts->priv; struct udevice *dev; /* * We should have a single class (UCLASS_ROOT) and a single root * device with no children. */ - ut_assert(dms->root); + ut_assert(uts->root); ut_asserteq(1, list_count_items(gd->uclass_root)); ut_asserteq(0, list_count_items(&gd->dm_root->child_head)); ut_asserteq(0, dm_testdrv_op_count[DM_TEST_OP_POST_BIND]); @@ -207,7 +206,6 @@ DM_TEST(dm_test_autobind_uclass_pdata_valid, UT_TESTF_SCAN_PDATA); /* Test that autoprobe finds all the expected devices */ static int dm_test_autoprobe(struct unit_test_state *uts) { - struct dm_test_state *dms = uts->priv; int expected_base_add; struct udevice *dev; struct uclass *uc; @@ -221,7 +219,7 @@ static int dm_test_autoprobe(struct unit_test_state *uts) ut_asserteq(0, dm_testdrv_op_count[DM_TEST_OP_POST_PROBE]); /* The root device should not be activated until needed */ - ut_assert(dev_get_flags(dms->root) & DM_FLAG_ACTIVATED); + ut_assert(dev_get_flags(uts->root) & DM_FLAG_ACTIVATED); /* * We should be able to find the three test devices, and they should @@ -241,7 +239,7 @@ static int dm_test_autoprobe(struct unit_test_state *uts) /* Activating a device should activate the root device */ if (!i) - ut_assert(dev_get_flags(dms->root) & DM_FLAG_ACTIVATED); + ut_assert(dev_get_flags(uts->root) & DM_FLAG_ACTIVATED); } /* @@ -293,7 +291,6 @@ DM_TEST(dm_test_plat, UT_TESTF_SCAN_PDATA); /* Test that we can bind, probe, remove, unbind a driver */ static int dm_test_lifecycle(struct unit_test_state *uts) { - struct dm_test_state *dms = uts->priv; int op_count[DM_TEST_OP_COUNT]; struct udevice *dev, *test_dev; int pingret; @@ -301,7 +298,7 @@ static int dm_test_lifecycle(struct unit_test_state *uts) memcpy(op_count, dm_testdrv_op_count, sizeof(op_count)); - ut_assertok(device_bind_by_name(dms->root, false, &driver_info_manual, + ut_assertok(device_bind_by_name(uts->root, false, &driver_info_manual, &dev)); ut_assert(dev); ut_assert(dm_testdrv_op_count[DM_TEST_OP_BIND] @@ -309,7 +306,7 @@ static int dm_test_lifecycle(struct unit_test_state *uts) ut_assert(!dev_get_priv(dev)); /* Probe the device - it should fail allocating private data */ - dms->force_fail_alloc = 1; + uts->force_fail_alloc = 1; ret = device_probe(dev); ut_assert(ret == -ENOMEM); ut_assert(dm_testdrv_op_count[DM_TEST_OP_PROBE] @@ -317,7 +314,7 @@ static int dm_test_lifecycle(struct unit_test_state *uts) ut_assert(!dev_get_priv(dev)); /* Try again without the alloc failure */ - dms->force_fail_alloc = 0; + uts->force_fail_alloc = 0; ut_assertok(device_probe(dev)); ut_assert(dm_testdrv_op_count[DM_TEST_OP_PROBE] == op_count[DM_TEST_OP_PROBE] + 2); @@ -349,19 +346,18 @@ DM_TEST(dm_test_lifecycle, UT_TESTF_SCAN_PDATA | UT_TESTF_PROBE_TEST); /* Test that we can bind/unbind and the lists update correctly */ static int dm_test_ordering(struct unit_test_state *uts) { - struct dm_test_state *dms = uts->priv; struct udevice *dev, *dev_penultimate, *dev_last, *test_dev; int pingret; - ut_assertok(device_bind_by_name(dms->root, false, &driver_info_manual, + ut_assertok(device_bind_by_name(uts->root, false, &driver_info_manual, &dev)); ut_assert(dev); /* Bind two new devices (numbers 4 and 5) */ - ut_assertok(device_bind_by_name(dms->root, false, &driver_info_manual, + ut_assertok(device_bind_by_name(uts->root, false, &driver_info_manual, &dev_penultimate)); ut_assert(dev_penultimate); - ut_assertok(device_bind_by_name(dms->root, false, &driver_info_manual, + ut_assertok(device_bind_by_name(uts->root, false, &driver_info_manual, &dev_last)); ut_assert(dev_last); @@ -376,7 +372,7 @@ static int dm_test_ordering(struct unit_test_state *uts) ut_assert(dev_last == test_dev); /* Add back the original device 3, now in position 5 */ - ut_assertok(device_bind_by_name(dms->root, false, &driver_info_manual, + ut_assertok(device_bind_by_name(uts->root, false, &driver_info_manual, &dev)); ut_assert(dev); @@ -568,7 +564,6 @@ static int create_children(struct unit_test_state *uts, struct udevice *parent, static int dm_test_children(struct unit_test_state *uts) { - struct dm_test_state *dms = uts->priv; struct udevice *top[NODE_COUNT]; struct udevice *child[NODE_COUNT]; struct udevice *grandchild[NODE_COUNT]; @@ -578,12 +573,12 @@ static int dm_test_children(struct unit_test_state *uts) int i; /* We don't care about the numbering for this test */ - dms->skip_post_probe = 1; + uts->skip_post_probe = 1; ut_assert(NODE_COUNT > 5); /* First create 10 top-level children */ - ut_assertok(create_children(uts, dms->root, NODE_COUNT, 0, top)); + ut_assertok(create_children(uts, uts->root, NODE_COUNT, 0, top)); /* Now a few have their own children */ ut_assertok(create_children(uts, top[2], NODE_COUNT, 2, NULL)); @@ -654,7 +649,6 @@ DM_TEST(dm_test_children, 0); static int dm_test_device_reparent(struct unit_test_state *uts) { - struct dm_test_state *dms = uts->priv; struct udevice *top[NODE_COUNT]; struct udevice *child[NODE_COUNT]; struct udevice *grandchild[NODE_COUNT]; @@ -664,12 +658,12 @@ static int dm_test_device_reparent(struct unit_test_state *uts) int i; /* We don't care about the numbering for this test */ - dms->skip_post_probe = 1; + uts->skip_post_probe = 1; ut_assert(NODE_COUNT > 5); /* First create 10 top-level children */ - ut_assertok(create_children(uts, dms->root, NODE_COUNT, 0, top)); + ut_assertok(create_children(uts, uts->root, NODE_COUNT, 0, top)); /* Now a few have their own children */ ut_assertok(create_children(uts, top[2], NODE_COUNT, 2, NULL)); @@ -815,15 +809,14 @@ DM_TEST(dm_test_device_reparent, 0); /* Test that pre-relocation devices work as expected */ static int dm_test_pre_reloc(struct unit_test_state *uts) { - struct dm_test_state *dms = uts->priv; struct udevice *dev; /* The normal driver should refuse to bind before relocation */ - ut_asserteq(-EPERM, device_bind_by_name(dms->root, true, + ut_asserteq(-EPERM, device_bind_by_name(uts->root, true, &driver_info_manual, &dev)); /* But this one is marked pre-reloc */ - ut_assertok(device_bind_by_name(dms->root, true, + ut_assertok(device_bind_by_name(uts->root, true, &driver_info_pre_reloc, &dev)); return 0; @@ -836,10 +829,9 @@ DM_TEST(dm_test_pre_reloc, 0); */ static int dm_test_remove_active_dma(struct unit_test_state *uts) { - struct dm_test_state *dms = uts->priv; struct udevice *dev; - ut_assertok(device_bind_by_name(dms->root, false, &driver_info_act_dma, + ut_assertok(device_bind_by_name(uts->root, false, &driver_info_act_dma, &dev)); ut_assert(dev); @@ -872,7 +864,7 @@ static int dm_test_remove_active_dma(struct unit_test_state *uts) * the active DMA remove call */ ut_assertok(device_unbind(dev)); - ut_assertok(device_bind_by_name(dms->root, false, &driver_info_manual, + ut_assertok(device_bind_by_name(uts->root, false, &driver_info_manual, &dev)); ut_assert(dev); @@ -895,25 +887,24 @@ DM_TEST(dm_test_remove_active_dma, 0); /* Test removal of 'vital' devices */ static int dm_test_remove_vital(struct unit_test_state *uts) { - struct dm_test_state *dms = uts->priv; struct udevice *normal, *dma, *vital, *dma_vital; /* Skip the behaviour in test_post_probe() */ - dms->skip_post_probe = 1; + uts->skip_post_probe = 1; - ut_assertok(device_bind_by_name(dms->root, false, &driver_info_manual, + ut_assertok(device_bind_by_name(uts->root, false, &driver_info_manual, &normal)); ut_assertnonnull(normal); - ut_assertok(device_bind_by_name(dms->root, false, &driver_info_act_dma, + ut_assertok(device_bind_by_name(uts->root, false, &driver_info_act_dma, &dma)); ut_assertnonnull(dma); - ut_assertok(device_bind_by_name(dms->root, false, + ut_assertok(device_bind_by_name(uts->root, false, &driver_info_vital_clk, &vital)); ut_assertnonnull(vital); - ut_assertok(device_bind_by_name(dms->root, false, + ut_assertok(device_bind_by_name(uts->root, false, &driver_info_act_dma_vital_clk, &dma_vital)); ut_assertnonnull(dma_vital); @@ -1133,11 +1124,10 @@ DM_TEST(dm_test_uclass_names, UT_TESTF_SCAN_PDATA); static int dm_test_inactive_child(struct unit_test_state *uts) { - struct dm_test_state *dms = uts->priv; struct udevice *parent, *dev1, *dev2; /* Skip the behaviour in test_post_probe() */ - dms->skip_post_probe = 1; + uts->skip_post_probe = 1; ut_assertok(uclass_first_device_err(UCLASS_TEST, &parent)); diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c index ceeac3fd361..15adc53f533 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -22,14 +22,15 @@ DECLARE_GLOBAL_DATA_PTR; struct unit_test_state global_dm_test_state; -static struct dm_test_state _global_priv_dm_test_state; int dm_test_init(struct unit_test_state *uts) { - struct dm_test_state *dms = uts->priv; bool of_live = uts->of_live; - memset(dms, '\0', sizeof(*dms)); + uts->root = NULL; + uts->testdev = NULL; + uts->force_fail_alloc = false; + uts->skip_post_probe = false; gd->dm_root = NULL; if (!CONFIG_IS_ENABLED(OF_PLATDATA)) memset(dm_testdrv_op_count, '\0', sizeof(dm_testdrv_op_count)); @@ -38,7 +39,7 @@ int dm_test_init(struct unit_test_state *uts) /* Determine whether to make the live tree available */ gd_set_of_root(of_live ? uts->of_root : NULL); ut_assertok(dm_init(of_live)); - dms->root = dm_root(); + uts->root = dm_root(); return 0; } @@ -124,7 +125,6 @@ int dm_test_run(const char *test_name) struct unit_test *test; int found; - uts->priv = &_global_priv_dm_test_state; uts->fail_count = 0; if (!CONFIG_IS_ENABLED(OF_PLATDATA)) { diff --git a/test/dm/test-driver.c b/test/dm/test-driver.c index ca7626a0668..63dc9d335ae 100644 --- a/test/dm/test-driver.c +++ b/test/dm/test-driver.c @@ -116,10 +116,8 @@ static int test_manual_bind(struct udevice *dev) static int test_manual_probe(struct udevice *dev) { - struct dm_test_state *dms = uts->priv; - dm_testdrv_op_count[DM_TEST_OP_PROBE]++; - if (!dms->force_fail_alloc) + if (!uts->force_fail_alloc) dev_set_priv(dev, calloc(1, sizeof(struct dm_test_priv))); if (!dev_get_priv(dev)) return -ENOMEM; diff --git a/test/dm/test-uclass.c b/test/dm/test-uclass.c index f1b7aaa727f..f4b540c9278 100644 --- a/test/dm/test-uclass.c +++ b/test/dm/test-uclass.c @@ -71,13 +71,12 @@ static int test_post_probe(struct udevice *dev) struct dm_test_uclass_perdev_priv *priv = dev_get_uclass_priv(dev); struct uclass *uc = dev->uclass; - struct dm_test_state *dms = uts->priv; dm_testdrv_op_count[DM_TEST_OP_POST_PROBE]++; ut_assert(priv); ut_assert(device_active(dev)); priv->base_add = 0; - if (dms->skip_post_probe) + if (uts->skip_post_probe) return 0; if (&prev->uclass_node != &uc->dev_head) { struct dm_test_uclass_perdev_priv *prev_uc_priv From patchwork Thu Mar 4 13:50:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447342 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=BweruMsa; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4DrsqF0gB0z9sRf for ; Fri, 5 Mar 2021 00:56:41 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A12D1828AB; Thu, 4 Mar 2021 14:53:18 +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="BweruMsa"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 722118280D; Thu, 4 Mar 2021 14:52:20 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) (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 7EBBF82765 for ; Thu, 4 Mar 2021 14:52:05 +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-oi1-x22f.google.com with SMTP id i21so27872947oii.2 for ; Thu, 04 Mar 2021 05:52:05 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=l6e7TboSQnQr82M71fihSVASMToChUEpJBIrzlaVRFU=; b=BweruMsa5rzv920B4GC1KvKD34dNlvqwiHTiyi0L13oQ1r4Jj+CSzJXN5xTZAaSmx0 Xy1H+A24H2D6ZmaiqByjxvwdytK/SKQJyrFxryIGlsSgXrOMYXVye9UE+UI3NrQcRbpS VUJW/KyBEWKugoGaTc+aO6XDR6i+9N8HF4Hck= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=l6e7TboSQnQr82M71fihSVASMToChUEpJBIrzlaVRFU=; b=eB0wE1HsUcGhplvzh8koNfCxy4u0aw8sM8K4kMZo9nP7mAomlSgtIRxnlQQjRFdbXT KxCkubeZnqAhmPqzez7Y7Lu2DmcxT/RZ9VwsDAVeDEJ+8NV4zp3TjsZLCPb0Gkvm8SEI O55Ry8oZAjNE8TN29bpVMT7OqcBFb3z2Lz/wpP7EEFJtXo6BoELu/uEylLY8oxu6V/UP vZK8ynuhEh6rQdbH2KI3K7A+g2DFJL3H2ijV7/cuDfM28ICzj+7dQZ/ImFYepsKe0oVZ gdEW9vR288Z6kqVn+Mf7e51SQBfnLEkkjrqEwTGnGIPm7+JD3LNgrbS+DJpExcLv9F/j diBg== X-Gm-Message-State: AOAM5317rKiclZDMaZhzIdDc7Ny81YD0YBCfYOli6OBda3czEuQdZ3bA 9a1RPdOayafgBu+pTXXAlTqTqsVyRSFhT7lj X-Google-Smtp-Source: ABdhPJx9eEPpmZAAOVQiZXIYwmQB2evUMjG9S8+VTeOguN7chuv59uOvn3cYBER3XOlW1rmbrfQwtw== X-Received: by 2002:a05:6808:10ca:: with SMTP id s10mr3051271ois.33.1614865923878; Thu, 04 Mar 2021 05:52:03 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:03 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 22/42] test: Move dm_test_init() into test-main.c Date: Thu, 4 Mar 2021 06:50:58 -0700 Message-Id: <20210304135118.643277-22-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean Move this function into test-main so that all the init is in one place. Rename it so that its purpose is clearer. Signed-off-by: Simon Glass --- (no changes since v1) include/test/ut.h | 9 --------- test/dm/test-dm.c | 22 ---------------------- test/test-main.c | 33 ++++++++++++++++++++++++++++++++- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/include/test/ut.h b/include/test/ut.h index 6e56ca99c31..4e0aba9f700 100644 --- a/include/test/ut.h +++ b/include/test/ut.h @@ -387,15 +387,6 @@ int test_pre_run(struct unit_test_state *uts, struct unit_test *test); */ int test_post_run(struct unit_test_state *uts, struct unit_test *test); -/** - * dm_test_init() - Get ready to run a driver model test - * - * This clears out the driver model data structures. For sandbox it resets the - * state structure. - * - * @uts: Test state - */ -int dm_test_init(struct unit_test_state *uts); /** * ut_run_tests() - Run a set of tests diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c index 15adc53f533..d601e497522 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -23,27 +22,6 @@ DECLARE_GLOBAL_DATA_PTR; struct unit_test_state global_dm_test_state; -int dm_test_init(struct unit_test_state *uts) -{ - bool of_live = uts->of_live; - - uts->root = NULL; - uts->testdev = NULL; - uts->force_fail_alloc = false; - uts->skip_post_probe = false; - gd->dm_root = NULL; - if (!CONFIG_IS_ENABLED(OF_PLATDATA)) - memset(dm_testdrv_op_count, '\0', sizeof(dm_testdrv_op_count)); - state_reset_for_test(state_get_current()); - - /* Determine whether to make the live tree available */ - gd_set_of_root(of_live ? uts->of_root : NULL); - ut_assertok(dm_init(of_live)); - uts->root = dm_root(); - - return 0; -} - static int dm_test_destroy(struct unit_test_state *uts) { int id; diff --git a/test/test-main.c b/test/test-main.c index f14b7b09f79..8b0121bdcec 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -7,12 +7,43 @@ #include #include #include +#include #include +#include #include #include DECLARE_GLOBAL_DATA_PTR; +/** + * dm_test_pre_run() - Get ready to run a driver model test + * + * This clears out the driver model data structures. For sandbox it resets the + * state structure + * + * @uts: Test state + */ +static int dm_test_pre_run(struct unit_test_state *uts) +{ + bool of_live = uts->of_live; + + uts->root = NULL; + uts->testdev = NULL; + uts->force_fail_alloc = false; + uts->skip_post_probe = false; + gd->dm_root = NULL; + if (!CONFIG_IS_ENABLED(OF_PLATDATA)) + memset(dm_testdrv_op_count, '\0', sizeof(dm_testdrv_op_count)); + state_reset_for_test(state_get_current()); + + /* Determine whether to make the live tree available */ + gd_set_of_root(of_live ? uts->of_root : NULL); + ut_assertok(dm_init(of_live)); + uts->root = dm_root(); + + return 0; +} + /* Ensure all the test devices are probed */ static int do_autoprobe(struct unit_test_state *uts) { @@ -31,7 +62,7 @@ static int do_autoprobe(struct unit_test_state *uts) int test_pre_run(struct unit_test_state *uts, struct unit_test *test) { if (test->flags & UT_TESTF_DM) - ut_assertok(dm_test_init(uts)); + ut_assertok(dm_test_pre_run(uts)); ut_set_skip_delays(uts, false); From patchwork Thu Mar 4 13:50:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447338 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=dq3kzitD; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4DrspP458Gz9sSC for ; Fri, 5 Mar 2021 00:55:57 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2BE6782887; Thu, 4 Mar 2021 14:53:00 +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="dq3kzitD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 59B348280D; Thu, 4 Mar 2021 14:52:17 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oo1-xc32.google.com (mail-oo1-xc32.google.com [IPv6:2607:f8b0:4864:20::c32]) (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 5D7B5806F1 for ; Thu, 4 Mar 2021 14:52:06 +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-oo1-xc32.google.com with SMTP id x10so6599235oor.3 for ; Thu, 04 Mar 2021 05:52:06 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=hoCPa2QL7zJJhXbhgeLWLjkPxfLle/0IKG7SP/ZoZIo=; b=dq3kzitDWwNGboId0GH73T2VWJUVqzowB/708ZTDqCFYl7dJsYUk3ccV5u8BXE37vP omNgS+6t8DUkmYXSQl2JiXe7XsS9c1c9OQxbrgo7D82hT2sv3+Af7+t0qF2NisP28iG2 bfYeP36VZdbO+eAP7gu1DAC6fYYmaNiQLijHQ= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=hoCPa2QL7zJJhXbhgeLWLjkPxfLle/0IKG7SP/ZoZIo=; b=TNe4Qw1rY2qt3GOOMUrbP+Y06Eb4WY05kPFgs0mZg9Ek+LPeYUkmkyRgK0L0XbpEI4 hVDIucubJozCRRb8+mfj2fVtZqLMuNEVZZuSGXtCGC04rP163827wT4hnv4qV8vq98Xm 9QSdmi/XkxSmZnnaHGYL6DkPGxZKGHvo71ql6cmPtVzDe/J2z2zL+TUCyynikKFOsqpV f8U8o4RBobnw88/CugJDBLnnwgJly1Xfkd5xfpastR4WOeh+DyECdECScddHrU+MsTco /dfio99fQHLOBd4zfoAnXOvjqztNgGWsv+8Ub1tebkaRlAFlWKt4slsofIW9Z0fAXLc/ Ey9A== X-Gm-Message-State: AOAM533nWgLhIgLcSirHSMRQD/coW9g2MGpTfUo2oZgMrQ+qH9HMQJGl R9Sx15CVaGov8AqK0CHMRc14c7a5Et/U+Axg X-Google-Smtp-Source: ABdhPJx5qB/GuY8SQt8W+YQ69F+3Gv668865XSzuSTguJWPnURZojAxrVEgx5b54BAiW1nJcEpzjLw== X-Received: by 2002:a4a:304a:: with SMTP id z10mr3472945ooz.26.1614865924756; Thu, 04 Mar 2021 05:52:04 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:04 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 23/42] test: Move dm_test_destroy() into test-main.c Date: Thu, 4 Mar 2021 06:50:59 -0700 Message-Id: <20210304135118.643277-23-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean Move this function into the common test runner and rename it to dm_test_post_run() so that its purpose is clear. Signed-off-by: Simon Glass --- (no changes since v1) test/dm/test-dm.c | 22 ---------------------- test/test-main.c | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c index d601e497522..df938395bb6 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -22,26 +22,6 @@ DECLARE_GLOBAL_DATA_PTR; struct unit_test_state global_dm_test_state; -static int dm_test_destroy(struct unit_test_state *uts) -{ - int id; - - for (id = 0; id < UCLASS_COUNT; id++) { - struct uclass *uc; - - /* - * If the uclass doesn't exist we don't want to create it. So - * check that here before we call uclass_find_device(). - */ - uc = uclass_find(id); - if (!uc) - continue; - ut_assertok(uclass_destroy(uc)); - } - - return 0; -} - static int dm_do_test(struct unit_test_state *uts, struct unit_test *test, bool of_live) { @@ -57,8 +37,6 @@ static int dm_do_test(struct unit_test_state *uts, struct unit_test *test, ut_assertok(test_post_run(uts, test)); - ut_assertok(dm_test_destroy(uts)); - return 0; } diff --git a/test/test-main.c b/test/test-main.c index 8b0121bdcec..3806c2ad89c 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -44,6 +45,26 @@ static int dm_test_pre_run(struct unit_test_state *uts) return 0; } +static int dm_test_post_run(struct unit_test_state *uts) +{ + int id; + + for (id = 0; id < UCLASS_COUNT; id++) { + struct uclass *uc; + + /* + * If the uclass doesn't exist we don't want to create it. So + * check that here before we call uclass_find_device(). + */ + uc = uclass_find(id); + if (!uc) + continue; + ut_assertok(uclass_destroy(uc)); + } + + return 0; +} + /* Ensure all the test devices are probed */ static int do_autoprobe(struct unit_test_state *uts) { @@ -94,6 +115,8 @@ int test_pre_run(struct unit_test_state *uts, struct unit_test *test) int test_post_run(struct unit_test_state *uts, struct unit_test *test) { ut_unsilence_console(uts); + if (test->flags & UT_TESTF_DM) + ut_assertok(dm_test_post_run(uts)); return 0; } From patchwork Thu Mar 4 13:51:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447339 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=QWiDzQSu; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4Drspb4zz8z9sSC for ; Fri, 5 Mar 2021 00:56:07 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 88ABA82898; Thu, 4 Mar 2021 14:53: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=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="QWiDzQSu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9736F82777; Thu, 4 Mar 2021 14:52:19 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) (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 29CB5827AA for ; Thu, 4 Mar 2021 14:52:07 +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-oi1-x22f.google.com with SMTP id w65so6579742oie.7 for ; Thu, 04 Mar 2021 05:52:07 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=tgcX9ymSRmM4w/DMJ5iV3lBWNzqorxMMWWyBip5DiHQ=; b=QWiDzQSudekC3rMRA9gW+R9eG9Nb6CVyzMFqINzz10d1BYaBIYqR5c3IYOZXtfRv5V N/MkJYQBBEr6ht4asiTkorzpFRYki//uo9eBpqTuwTWNgcfkdvE98i1fDz5qKbfcXblZ XPf3dZpoEPmnC1D40QxJjhrkWeF5WDXV8FfZY= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=tgcX9ymSRmM4w/DMJ5iV3lBWNzqorxMMWWyBip5DiHQ=; b=GOzmoW8OX+0pPsrTDeh52RTX1ij10fBjcOFiehtRcXOzoG45iFiyFuF79je6isk4jr gIOPOJkbIGwmd7F9TwUlj+QNmQYkrA5AIeOzv1vgICcUPp19Bv1sGCA0mYtBPGI6d0E/ ysXICRxzdDXAdNis6xQKySoHqH5egeZnZFM6rQqMuIZD2FeZjrKc29eawESJ9CF2GaM5 Rwxi+MyLRsEER4YAVkfQ0iY3jneOt4t5WQzDnCWZDPlhcnG42tlenXmt4n2sEaS7yWY0 oS5or2Bep/At5Cqft5hgx5tVyvAZe0ItVSt425tXEvSDCglZqwe8Ybn99v1UVcNi+mfG F2Yg== X-Gm-Message-State: AOAM530uVyMfBio/6G2OqbCiw+fdt5DI0t+GjchrvOCwO3qMmk920coE D2/Aj78quLrQVMNKEuY+PTUnsckRV7roWhvJ X-Google-Smtp-Source: ABdhPJygSmXEzBtPxRJOS1K2+/lrxb9gnbnEQlyz6xcougX0sKq8Z/uZdSVcbqv7WLnRLLFpfT/kXw== X-Received: by 2002:aca:d5d1:: with SMTP id m200mr2870120oig.102.1614865925657; Thu, 04 Mar 2021 05:52:05 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:05 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 24/42] test: Move test running into a separate function Date: Thu, 4 Mar 2021 06:51:00 -0700 Message-Id: <20210304135118.643277-24-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean Add a function to handle the preparation for running a test and the post-test clean-up. Signed-off-by: Simon Glass --- (no changes since v1) include/test/ut.h | 16 ++++++++++++++++ test/test-main.c | 32 +++++++++++++++++++++++--------- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/include/test/ut.h b/include/test/ut.h index 4e0aba9f700..98f699cbba2 100644 --- a/include/test/ut.h +++ b/include/test/ut.h @@ -387,6 +387,22 @@ int test_pre_run(struct unit_test_state *uts, struct unit_test *test); */ int test_post_run(struct unit_test_state *uts, struct unit_test *test); +/** + * ut_run_test() - Run a single test + * + * This runs the test, handling any preparation and clean-up needed. It prints + * the name of each test before running it. + * + * @uts: Test state to update. The caller should ensure that this is zeroed for + * the first call to this function. On exit, @uts->fail_count is + * incremented by the number of failures (0, one hopes) + * @test: Test to run + * @name: Name of test, possibly skipping a prefix that should not be displayed + * @return 0 if all tests passed, -EAGAIN if the test should be skipped, -1 if + * any failed + */ +int ut_run_test(struct unit_test_state *uts, struct unit_test *test, + const char *name); /** * ut_run_tests() - Run a set of tests diff --git a/test/test-main.c b/test/test-main.c index 3806c2ad89c..dee28d35d82 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -121,6 +121,28 @@ int test_post_run(struct unit_test_state *uts, struct unit_test *test) return 0; } +int ut_run_test(struct unit_test_state *uts, struct unit_test *test, + const char *test_name) +{ + int ret; + + printf("Test: %s\n", test_name); + + ret = test_pre_run(uts, test); + if (ret == -EAGAIN) + return -EAGAIN; + if (ret) + return ret; + + test->func(uts); + + ret = test_post_run(uts, test); + if (ret) + return ret; + + return 0; +} + int ut_run_tests(struct unit_test_state *uts, const char *prefix, struct unit_test *tests, int count, const char *select_name) { @@ -138,20 +160,12 @@ int ut_run_tests(struct unit_test_state *uts, const char *prefix, if (select_name && strcmp(select_name, test_name)) continue; - printf("Test: %s\n", test_name); + ret = ut_run_test(uts, test, test_name); found++; - - ret = test_pre_run(uts, test); if (ret == -EAGAIN) continue; if (ret) return ret; - - test->func(uts); - - ret = test_post_run(uts, test); - if (ret) - return ret; } if (select_name && !found) return -ENOENT; From patchwork Thu Mar 4 13:51:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447340 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=TXjrINMR; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4Drspp4Wh7z9sRf for ; Fri, 5 Mar 2021 00:56:18 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5B9D0827DE; Thu, 4 Mar 2021 14:53:07 +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="TXjrINMR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4B9EF8280F; Thu, 4 Mar 2021 14:52:19 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) (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 552AE82777 for ; Thu, 4 Mar 2021 14:52:08 +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-oi1-x231.google.com with SMTP id q203so7116398oih.5 for ; Thu, 04 Mar 2021 05:52:08 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=u9IhV8PiGPke8egjnHU/MrEoDsyBqJiIvlrkFBAvHng=; b=TXjrINMRf/wUHCyAFHjbUBU+8VYPZfoqnIPXs1dOHDXrZQQStCoVLfiImtDNPVT06s ShkMNV2DyX1vze/KgWob9ymQEqZXm2BbH9V7JPaq5CE+CP71gmVFs2OpV9xxI2vMtHOD OzkDawPLp0Elbl7bMT6h5IDzCiD5GP+pw1Dq4= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=u9IhV8PiGPke8egjnHU/MrEoDsyBqJiIvlrkFBAvHng=; b=Qi1UBvSMvUc950hfUnLrDpSX9qFhmM+0J+w+SKoXFX6ey/Kn9FeFjq2WLEcpFiir04 YjBQWQ9iKXpy5zfu8/QaHplkSBvn4NB03M/1J23aNDasRGpWywnoN/D60/UveqXsd+Hr CEd1BAs1ogbS2RuWJew3Zb6Q7nI6fLtyLXIloCQg1pXdfTFAXUi//dQ1EaNuCsJQl5zV WkOfzw+xxyDD8OSeuwRyJsFc0sOXOh8GOX7o7amF4WmMAJ2fo97ZiymBQ3/M0R2FfIP0 P2sWJzB/uIQtEq7FUZ3aGmuopWHFdzjWyCZs2jRQ3qhzCIEHFN02gSeYWKAk3MIlHoxT NS3A== X-Gm-Message-State: AOAM531QqIMqqnqPbPSe/hKibhk5SJV2hAkpM9RVJ5DJ8Y8R7oK2l4UO IP9pvsk8sfYSEGatgJEZ8/TQpq6W7bN20tOn X-Google-Smtp-Source: ABdhPJyQVP0Oq6bSROPIoG2SA/PDuC6JJNGVMWZShxdaCgDg0652UJX0pCXS0LLZ2BntWWxOzmLSug== X-Received: by 2002:aca:b5c5:: with SMTP id e188mr2971158oif.17.1614865926562; Thu, 04 Mar 2021 05:52:06 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:06 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 25/42] test: Use ut_run_test() to run driver model tests Date: Thu, 4 Mar 2021 06:51:01 -0700 Message-Id: <20210304135118.643277-25-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean Instead of having a separate function for running driver model tests, use the common one. Make the pre/post-run functions private since we don't need these outside of test-main.c Signed-off-by: Simon Glass --- (no changes since v1) include/test/ut.h | 20 -------------------- test/dm/test-dm.c | 11 +---------- test/test-main.c | 26 +++++++++++++++++++++++--- 3 files changed, 24 insertions(+), 33 deletions(-) diff --git a/include/test/ut.h b/include/test/ut.h index 98f699cbba2..adef0b7e1cf 100644 --- a/include/test/ut.h +++ b/include/test/ut.h @@ -367,26 +367,6 @@ void ut_unsilence_console(struct unit_test_state *uts); */ void ut_set_skip_delays(struct unit_test_state *uts, bool skip_delays); -/** - * test_pre_run() - Handle any preparation needed to run a test - * - * @uts: Test state - * @test: Test to prepare for - * @return 0 if OK, -EAGAIN to skip this test since some required feature is not - * available, other -ve on error (meaning that testing cannot likely - * continue) - */ -int test_pre_run(struct unit_test_state *uts, struct unit_test *test); - -/** - * test_post_run() - Handle cleaning up after a test - * - * @uts: Test state - * @test: Test to clean up after - * @return 0 if OK, -ve on error (meaning that testing cannot likely continue) - */ -int test_post_run(struct unit_test_state *uts, struct unit_test *test); - /** * ut_run_test() - Run a single test * diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c index df938395bb6..b01123c7409 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -25,17 +25,8 @@ struct unit_test_state global_dm_test_state; static int dm_do_test(struct unit_test_state *uts, struct unit_test *test, bool of_live) { - const char *fname = strrchr(test->file, '/') + 1; - - printf("Test: %s: %s%s\n", test->name, fname, - !of_live ? " (flat tree)" : ""); uts->of_live = of_live; - - ut_assertok(test_pre_run(uts, test)); - - test->func(uts); - - ut_assertok(test_post_run(uts, test)); + ut_assertok(ut_run_test(uts, test, test->name)); return 0; } diff --git a/test/test-main.c b/test/test-main.c index dee28d35d82..32c4d4b1996 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -80,7 +80,16 @@ static int do_autoprobe(struct unit_test_state *uts) return ret; } -int test_pre_run(struct unit_test_state *uts, struct unit_test *test) +/** + * test_pre_run() - Handle any preparation needed to run a test + * + * @uts: Test state + * @test: Test to prepare for + * @return 0 if OK, -EAGAIN to skip this test since some required feature is not + * available, other -ve on error (meaning that testing cannot likely + * continue) + */ +static int test_pre_run(struct unit_test_state *uts, struct unit_test *test) { if (test->flags & UT_TESTF_DM) ut_assertok(dm_test_pre_run(uts)); @@ -112,7 +121,14 @@ int test_pre_run(struct unit_test_state *uts, struct unit_test *test) return 0; } -int test_post_run(struct unit_test_state *uts, struct unit_test *test) +/** + * test_post_run() - Handle cleaning up after a test + * + * @uts: Test state + * @test: Test to clean up after + * @return 0 if OK, -ve on error (meaning that testing cannot likely continue) + */ +static int test_post_run(struct unit_test_state *uts, struct unit_test *test) { ut_unsilence_console(uts); if (test->flags & UT_TESTF_DM) @@ -124,9 +140,13 @@ int test_post_run(struct unit_test_state *uts, struct unit_test *test) int ut_run_test(struct unit_test_state *uts, struct unit_test *test, const char *test_name) { + const char *fname = strrchr(test->file, '/') + 1; + const char *note = ""; int ret; - printf("Test: %s\n", test_name); + if ((test->flags & UT_TESTF_DM) && !uts->of_live) + note = " (flat tree)"; + printf("Test: %s: %s%s\n", test_name, fname, note); ret = test_pre_run(uts, test); if (ret == -EAGAIN) From patchwork Thu Mar 4 13:51:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447346 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=n7ZLlyJ2; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4Drsr46J7Rz9sRf for ; Fri, 5 Mar 2021 00:57:24 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 19520828D3; Thu, 4 Mar 2021 14:53:30 +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="n7ZLlyJ2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CAEA98284C; Thu, 4 Mar 2021 14:52:29 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oo1-xc2d.google.com (mail-oo1-xc2d.google.com [IPv6:2607:f8b0:4864:20::c2d]) (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 5BA6F827BF for ; Thu, 4 Mar 2021 14:52:13 +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-oo1-xc2d.google.com with SMTP id z22so6587371oop.0 for ; Thu, 04 Mar 2021 05:52:13 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=Nc2gzDZybu9uORBJuPMy3uHYK2P/DiNyt+1qjMpNLa8=; b=n7ZLlyJ2epp+jurUFGVrnQq6kKfXMsK4YsDj0iDJqRNCMp/9Q4u3Y5dqQ5yqXRySY0 /ncK3Y11cxVkg2m2yEoKi2ge8hox0IkbECNcLdZUHntRgjiKLETO2WEgXg9+DgAgxBiL CWQk1iwRnGggLN6M+MOR7Ylh0WB2t+OXCFyzw= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Nc2gzDZybu9uORBJuPMy3uHYK2P/DiNyt+1qjMpNLa8=; b=C72LVroDyGvsMoVyCV6ZFkMeY1InW5rYPUMVaIm9a7DlBXk0ux1poDNX8mOcKDjZjO 7MEZnBoidRKTy9rW34cNVxlfMKKSj3Jn3g5G1B837dWsSctdV0QuCvj4tFrlhfYg0i7p xvtuknai3nHSBSFBKJl51T/huEDYi5+/b5dSVmS9CQXZ7uS9/hhVHDZiIw6pBVdkVTkv YMNabexGwolbQJ+xaMqOfEu6e52t622ZkvQ3g/zYunO4SU59yBfr9bHGN98Rq9UhUnUz iwF2zx3yrsobyAgp8JO9hw4XQEH1wXc5au1YNDaDeM4516lPsamql4R/QXfN7OeyTI+o UYhw== X-Gm-Message-State: AOAM531Hhd29ESpSkj6gcQF6ZN+93CvshOA6pCISNOhqiSusrvx0l+wh cshWByhpOe+4yJIskIIOOuMN46DpaDVB1/Tq X-Google-Smtp-Source: ABdhPJzJqTxzC6Rzw5Dp18cjwg5rXssdSLxXzqnwG6VJPDEUW8p1ju/JDIVBui5iZKTjLJIpb+pAow== X-Received: by 2002:a4a:e1e4:: with SMTP id u4mr3375589ood.41.1614865927798; Thu, 04 Mar 2021 05:52:07 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:07 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 26/42] test: Drop dm_do_test() Date: Thu, 4 Mar 2021 06:51:02 -0700 Message-Id: <20210304135118.643277-26-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean In an effort to make use of a common test runner, use ut_run_test() directly to run driver model tests. Signed-off-by: Simon Glass --- (no changes since v1) test/dm/test-dm.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c index b01123c7409..de41fc09db0 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -22,15 +22,6 @@ DECLARE_GLOBAL_DATA_PTR; struct unit_test_state global_dm_test_state; -static int dm_do_test(struct unit_test_state *uts, struct unit_test *test, - bool of_live) -{ - uts->of_live = of_live; - ut_assertok(ut_run_test(uts, test, test->name)); - - return 0; -} - /** * dm_test_run_on_flattree() - Check if we should run a test with flat DT * @@ -103,7 +94,8 @@ int dm_test_run(const char *test_name) runs = 0; if (CONFIG_IS_ENABLED(OF_LIVE)) { if (!(test->flags & UT_TESTF_FLAT_TREE)) { - ut_assertok(dm_do_test(uts, test, true)); + uts->of_live = true; + ut_assertok(ut_run_test(uts, test, test->name)); runs++; } } @@ -114,7 +106,8 @@ int dm_test_run(const char *test_name) */ if (!(test->flags & UT_TESTF_LIVE_TREE) && (!runs || dm_test_run_on_flattree(test))) { - ut_assertok(dm_do_test(uts, test, false)); + uts->of_live = false; + ut_assertok(ut_run_test(uts, test, test->name)); runs++; } found++; From patchwork Thu Mar 4 13:51:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447344 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=eWrb5Ik3; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4Drsqh2jP8z9sRf for ; Fri, 5 Mar 2021 00:57:04 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 922CE828B8; Thu, 4 Mar 2021 14:53:24 +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="eWrb5Ik3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 202AC82824; Thu, 4 Mar 2021 14:52:25 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) (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 6733D827E3 for ; Thu, 4 Mar 2021 14:52: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=sjg@chromium.org Received: by mail-oi1-x22f.google.com with SMTP id o3so30132862oic.8 for ; Thu, 04 Mar 2021 05:52:11 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=GUIIUQALvREwWvK4EJP4EkcwXw6io8xo3LY4z/VWaFo=; b=eWrb5Ik3wg17IP4pu/OAmi75rfNW5Ty1ufelKnmF3J6diApFcuh0dtlP8e5+B0dT4E bEOmOZYZHWBxxAHfeaS+wgKh4UIM8khgoNDYWRPHw0iKoPvrnP7YcIZdrXS6IgpYEa8h u9PspMLBKP+wMGC1zu31FfKyuO6aRLP3XcSsY= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=GUIIUQALvREwWvK4EJP4EkcwXw6io8xo3LY4z/VWaFo=; b=Z9jRyFylU8jH+VuHr6b4sAlNK8GBRbsLMPoVMGfzkbO2B/343hgle57K8ZhtoHL5gZ dVh5kQf6eJnudJ6KFzLS0pc9tZwn7lVS+itXmgz7WKxkpmZQ9zqSbzR9iVPpaA4eBbQ0 FLIVqGKOVf0xosky5H9vzKqOihOqtJyjGqH2nCbfNe5UXi6hi49AntAVSh3ZO4MRYwCx XBMk4hzaIG6vj+xioDLWANjL39NiVWNnj+LkE+5SG7YYuognMkRQlASqF8ZS9eFaM0RY /DyQhQhbvkxzemC4tFpdXci3NEUYCO0AtBo3Kpaxe1y01DE6d3R83teHMTsF4/HzrHL7 byjA== X-Gm-Message-State: AOAM531s89kzCpNFmR+ylOeAYZKUdLIzs8Ug06bI596XFK3AahGWHVt2 im/yL9GHGMY8bGcjFlZeUH2+OJh0Bus9ITlM X-Google-Smtp-Source: ABdhPJwLV3S4UXJyqMw/oCQUAq9k9jifW9P15QuZHQiRgJhvjHyaBNGUxix/CHzS44L41k1niWk0RA== X-Received: by 2002:aca:7514:: with SMTP id q20mr3063370oic.86.1614865928647; Thu, 04 Mar 2021 05:52:08 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:08 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 27/42] test: Add ut_run_test_live_flat() to run tests twice Date: Thu, 4 Mar 2021 06:51:03 -0700 Message-Id: <20210304135118.643277-27-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean Driver model tests are generally run twice, once with livetree enable and again with it disabled. Add a function to handle this and call it from the driver model test runner. Make ut_run_test() private since it is not used outside test-main.c now. Signed-off-by: Simon Glass --- (no changes since v2) Changes in v2: - Fix conditions so non-DM SPL tests are actually run include/test/ut.h | 13 +++++---- test/dm/test-dm.c | 37 +------------------------- test/test-main.c | 67 ++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 73 insertions(+), 44 deletions(-) diff --git a/include/test/ut.h b/include/test/ut.h index adef0b7e1cf..d06bc5089be 100644 --- a/include/test/ut.h +++ b/include/test/ut.h @@ -368,10 +368,13 @@ void ut_unsilence_console(struct unit_test_state *uts); void ut_set_skip_delays(struct unit_test_state *uts, bool skip_delays); /** - * ut_run_test() - Run a single test + * ut_run_test_live_flat() - Run a test with both live and flat tree * - * This runs the test, handling any preparation and clean-up needed. It prints - * the name of each test before running it. + * This calls ut_run_test() with livetree enabled, which is the standard setup + * for runnig tests. Then, for driver model test, it calls it again with + * livetree disabled. This allows checking of flattree being used when OF_LIVE + * is enabled, as is the case in U-Boot proper before relocation, as well as in + * SPL. * * @uts: Test state to update. The caller should ensure that this is zeroed for * the first call to this function. On exit, @uts->fail_count is @@ -381,8 +384,8 @@ void ut_set_skip_delays(struct unit_test_state *uts, bool skip_delays); * @return 0 if all tests passed, -EAGAIN if the test should be skipped, -1 if * any failed */ -int ut_run_test(struct unit_test_state *uts, struct unit_test *test, - const char *name); +int ut_run_test_live_flat(struct unit_test_state *uts, struct unit_test *test, + const char *name); /** * ut_run_tests() - Run a set of tests diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c index de41fc09db0..826b64565e8 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -22,21 +22,6 @@ DECLARE_GLOBAL_DATA_PTR; struct unit_test_state global_dm_test_state; -/** - * dm_test_run_on_flattree() - Check if we should run a test with flat DT - * - * This skips long/slow tests where there is not much value in running a flat - * DT test in addition to a live DT test. - * - * @return true to run the given test on the flat device tree - */ -static bool dm_test_run_on_flattree(struct unit_test *test) -{ - const char *fname = strrchr(test->file, '/') + 1; - - return !strstr(fname, "video") || strstr(test->name, "video_base"); -} - static bool test_matches(const char *test_name, const char *find_name) { if (!find_name) @@ -85,31 +70,11 @@ int dm_test_run(const char *test_name) uts->of_root = gd_of_root(); for (test = tests; test < tests + n_ents; test++) { const char *name = test->name; - int runs; if (!test_matches(name, test_name)) continue; - /* Run with the live tree if possible */ - runs = 0; - if (CONFIG_IS_ENABLED(OF_LIVE)) { - if (!(test->flags & UT_TESTF_FLAT_TREE)) { - uts->of_live = true; - ut_assertok(ut_run_test(uts, test, test->name)); - runs++; - } - } - - /* - * Run with the flat tree if we couldn't run it with live tree, - * or it is a core test. - */ - if (!(test->flags & UT_TESTF_LIVE_TREE) && - (!runs || dm_test_run_on_flattree(test))) { - uts->of_live = false; - ut_assertok(ut_run_test(uts, test, test->name)); - runs++; - } + ut_assertok(ut_run_test_live_flat(uts, test, test->name)); found++; } diff --git a/test/test-main.c b/test/test-main.c index 32c4d4b1996..4e17c9edb28 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -80,6 +80,24 @@ static int do_autoprobe(struct unit_test_state *uts) return ret; } +/* + * ut_test_run_on_flattree() - Check if we should run a test with flat DT + * + * This skips long/slow tests where there is not much value in running a flat + * DT test in addition to a live DT test. + * + * @return true to run the given test on the flat device tree + */ +static bool ut_test_run_on_flattree(struct unit_test *test) +{ + const char *fname = strrchr(test->file, '/') + 1; + + if (!(test->flags & UT_TESTF_DM)) + return false; + + return !strstr(fname, "video") || strstr(test->name, "video_base"); +} + /** * test_pre_run() - Handle any preparation needed to run a test * @@ -137,8 +155,22 @@ static int test_post_run(struct unit_test_state *uts, struct unit_test *test) return 0; } -int ut_run_test(struct unit_test_state *uts, struct unit_test *test, - const char *test_name) +/** + * ut_run_test() - Run a single test + * + * This runs the test, handling any preparation and clean-up needed. It prints + * the name of each test before running it. + * + * @uts: Test state to update. The caller should ensure that this is zeroed for + * the first call to this function. On exit, @uts->fail_count is + * incremented by the number of failures (0, one hopes) + * @test_name: Test to run + * @name: Name of test, possibly skipping a prefix that should not be displayed + * @return 0 if all tests passed, -EAGAIN if the test should be skipped, -1 if + * any failed + */ +static int ut_run_test(struct unit_test_state *uts, struct unit_test *test, + const char *test_name) { const char *fname = strrchr(test->file, '/') + 1; const char *note = ""; @@ -163,6 +195,35 @@ int ut_run_test(struct unit_test_state *uts, struct unit_test *test, return 0; } +int ut_run_test_live_flat(struct unit_test_state *uts, struct unit_test *test, + const char *name) +{ + int runs; + + /* Run with the live tree if possible */ + runs = 0; + if (CONFIG_IS_ENABLED(OF_LIVE)) { + if (!(test->flags & UT_TESTF_FLAT_TREE)) { + uts->of_live = true; + ut_assertok(ut_run_test(uts, test, test->name)); + runs++; + } + } + + /* + * Run with the flat tree if we couldn't run it with live tree, + * or it is a core test. + */ + if (!(test->flags & UT_TESTF_LIVE_TREE) && + (!runs || ut_test_run_on_flattree(test))) { + uts->of_live = false; + ut_assertok(ut_run_test(uts, test, test->name)); + runs++; + } + + return 0; +} + int ut_run_tests(struct unit_test_state *uts, const char *prefix, struct unit_test *tests, int count, const char *select_name) { @@ -180,7 +241,7 @@ int ut_run_tests(struct unit_test_state *uts, const char *prefix, if (select_name && strcmp(select_name, test_name)) continue; - ret = ut_run_test(uts, test, test_name); + ret = ut_run_test_live_flat(uts, test, test_name); found++; if (ret == -EAGAIN) continue; From patchwork Thu Mar 4 13:51:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447345 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=TJFmyVQx; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4Drsqt3Bl5z9sSC for ; Fri, 5 Mar 2021 00:57:14 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 35EFE8284C; Thu, 4 Mar 2021 14:53:27 +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="TJFmyVQx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6993382838; Thu, 4 Mar 2021 14:52:26 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) (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 15AB4827D2 for ; Thu, 4 Mar 2021 14:52: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=sjg@chromium.org Received: by mail-oi1-x229.google.com with SMTP id m25so17123733oie.12 for ; Thu, 04 Mar 2021 05:52:11 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=MkjAZbzKwzP0XlGbFhvnFEmOF2nDMrhYmT47BvKz/lQ=; b=TJFmyVQxBgQhaJXpJarup0hhaV3qUb7P+1Gyvsp0f2fq9sAI+iveg0kO4z0uzG2Duo JSUHqSJ4YmoIT6/4A+D3hDm92GSntv9b3tsWGQEww64Oh/UMKCBPMVgrjhv/oDCa/X+K R099uOIqyKapD80quOGQW/manrBoBjapHmX/4= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=MkjAZbzKwzP0XlGbFhvnFEmOF2nDMrhYmT47BvKz/lQ=; b=aKeWA9kgQDv7OABlqPh7MJGV2X8r1enl2/xcRhgdU3wTa6qSo1pBHCpic1G9gVzq2q CVA9zbHl0z/MDbyIhWtbsjBTMFvcocTuslYewZ8TTAyyHmOqFUgLrf2XQuTcQX/mLwwN vpEAb/9vXHxbWQ5z/rRzeP2Q2Lo9MEEtncRmFXG5X/hdU//JLvcChEciCmozoB3gUy2D JjLSaqrHhlO/nxz2R15YxjiYkm0El9A5URxC6R1BJsAjhEfzANT9NSBI3aA1LbnskQ1J +rvpjy/wtIySOPJ1VH4wEUOSX4BLx3Fe6yBOmYoArmhkmbmJgtj21SyMzk32vVGL0/sw fGIQ== X-Gm-Message-State: AOAM5301hjtM6qw226hewPNWLIduFXyL8TW/GNW/EXiO6/xpwluulMiZ IT1/CHUc9KyJLi5iExrhHc0pf5RdSWxtjVjZ X-Google-Smtp-Source: ABdhPJxJE/Kh+cIL/8zHlNDV/L8jDDWo6xcaB9ztZFarKyusDDRGTk7xZeOejZBZ2tQ8RABTiQcVtw== X-Received: by 2002:aca:916:: with SMTP id 22mr3004220oij.52.1614865929489; Thu, 04 Mar 2021 05:52:09 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:09 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 28/42] test: Use a local variable for test state Date: Thu, 4 Mar 2021 06:51:04 -0700 Message-Id: <20210304135118.643277-28-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean At present we use a global test state for all driver-model tests. Make use of a local struct like we do with the other tests. To make this work, add functions to get and set this state. When a test starts, the state is set (so it can be used in the test). When a test finishes, the state is unset, so it cannot be used by mistake. Signed-off-by: Simon Glass --- (no changes since v3) Changes in v3: - Use test_set_state() throughout test-main.c instead of direct assignment include/test/ut.h | 14 ++++++++++++++ test/dm/test-dm.c | 4 +--- test/dm/test-driver.c | 10 +++++++++- test/dm/test-uclass.c | 7 +++++-- test/test-main.c | 18 ++++++++++++++++++ 5 files changed, 47 insertions(+), 6 deletions(-) diff --git a/include/test/ut.h b/include/test/ut.h index d06bc5089be..bed0e6eb5f6 100644 --- a/include/test/ut.h +++ b/include/test/ut.h @@ -367,6 +367,20 @@ void ut_unsilence_console(struct unit_test_state *uts); */ void ut_set_skip_delays(struct unit_test_state *uts, bool skip_delays); +/** + * test_get_state() - Get the active test state + * + * @return the currently active test state, or NULL if none + */ +struct unit_test_state *test_get_state(void); + +/** + * test_set_state() - Set the active test state + * + * @uts: Test state to use as currently active test state, or NULL if none + */ +void test_set_state(struct unit_test_state *uts); + /** * ut_run_test_live_flat() - Run a test with both live and flat tree * diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c index 826b64565e8..cdaf27bf987 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -20,8 +20,6 @@ DECLARE_GLOBAL_DATA_PTR; -struct unit_test_state global_dm_test_state; - static bool test_matches(const char *test_name, const char *find_name) { if (!find_name) @@ -44,7 +42,7 @@ int dm_test_run(const char *test_name) { struct unit_test *tests = ll_entry_start(struct unit_test, dm_test); const int n_ents = ll_entry_count(struct unit_test, dm_test); - struct unit_test_state *uts = &global_dm_test_state; + struct unit_test_state uts_s = { .fail_count = 0 }, *uts = &uts_s; struct unit_test *test; int found; diff --git a/test/dm/test-driver.c b/test/dm/test-driver.c index 63dc9d335ae..02cb974b0f7 100644 --- a/test/dm/test-driver.c +++ b/test/dm/test-driver.c @@ -18,7 +18,6 @@ #include int dm_testdrv_op_count[DM_TEST_OP_COUNT]; -static struct unit_test_state *uts = &global_dm_test_state; static int testdrv_ping(struct udevice *dev, int pingval, int *pingret) { @@ -37,6 +36,8 @@ static const struct test_ops test_ops = { static int test_bind(struct udevice *dev) { + struct unit_test_state *uts = test_get_state(); + /* Private data should not be allocated */ ut_assert(!dev_get_priv(dev)); @@ -46,6 +47,7 @@ static int test_bind(struct udevice *dev) static int test_probe(struct udevice *dev) { + struct unit_test_state *uts = test_get_state(); struct dm_test_priv *priv = dev_get_priv(dev); /* Private data should be allocated */ @@ -58,6 +60,8 @@ static int test_probe(struct udevice *dev) static int test_remove(struct udevice *dev) { + struct unit_test_state *uts = test_get_state(); + /* Private data should still be allocated */ ut_assert(dev_get_priv(dev)); @@ -67,6 +71,8 @@ static int test_remove(struct udevice *dev) static int test_unbind(struct udevice *dev) { + struct unit_test_state *uts = test_get_state(); + /* Private data should not be allocated */ ut_assert(!dev_get_priv(dev)); @@ -116,6 +122,8 @@ static int test_manual_bind(struct udevice *dev) static int test_manual_probe(struct udevice *dev) { + struct unit_test_state *uts = test_get_state(); + dm_testdrv_op_count[DM_TEST_OP_PROBE]++; if (!uts->force_fail_alloc) dev_set_priv(dev, calloc(1, sizeof(struct dm_test_priv))); diff --git a/test/dm/test-uclass.c b/test/dm/test-uclass.c index f4b540c9278..067701734a0 100644 --- a/test/dm/test-uclass.c +++ b/test/dm/test-uclass.c @@ -17,8 +17,6 @@ #include #include -static struct unit_test_state *uts = &global_dm_test_state; - int test_ping(struct udevice *dev, int pingval, int *pingret) { const struct test_ops *ops = device_get_ops(dev); @@ -31,6 +29,7 @@ int test_ping(struct udevice *dev, int pingval, int *pingret) static int test_post_bind(struct udevice *dev) { + struct unit_test_state *uts = test_get_state(); struct dm_test_perdev_uc_pdata *uc_pdata; dm_testdrv_op_count[DM_TEST_OP_POST_BIND]++; @@ -56,6 +55,7 @@ static int test_pre_unbind(struct udevice *dev) static int test_pre_probe(struct udevice *dev) { struct dm_test_uclass_perdev_priv *priv = dev_get_uclass_priv(dev); + struct unit_test_state *uts = test_get_state(); dm_testdrv_op_count[DM_TEST_OP_PRE_PROBE]++; ut_assert(priv); @@ -66,6 +66,7 @@ static int test_pre_probe(struct udevice *dev) static int test_post_probe(struct udevice *dev) { + struct unit_test_state *uts = test_get_state(); struct udevice *prev = list_entry(dev->uclass_node.prev, struct udevice, uclass_node); @@ -100,6 +101,8 @@ static int test_pre_remove(struct udevice *dev) static int test_init(struct uclass *uc) { + struct unit_test_state *uts = test_get_state(); + dm_testdrv_op_count[DM_TEST_OP_INIT]++; ut_assert(uclass_get_priv(uc)); diff --git a/test/test-main.c b/test/test-main.c index 4e17c9edb28..139fc1f6f18 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -16,6 +16,19 @@ DECLARE_GLOBAL_DATA_PTR; +/* This is valid when a test is running, NULL otherwise */ +static struct unit_test_state *cur_test_state; + +struct unit_test_state *test_get_state(void) +{ + return cur_test_state; +} + +void test_set_state(struct unit_test_state *uts) +{ + cur_test_state = uts; +} + /** * dm_test_pre_run() - Get ready to run a driver model test * @@ -180,6 +193,9 @@ static int ut_run_test(struct unit_test_state *uts, struct unit_test *test, note = " (flat tree)"; printf("Test: %s: %s%s\n", test_name, fname, note); + /* Allow access to test state from drivers */ + test_set_state(uts); + ret = test_pre_run(uts, test); if (ret == -EAGAIN) return -EAGAIN; @@ -192,6 +208,8 @@ static int ut_run_test(struct unit_test_state *uts, struct unit_test *test, if (ret) return ret; + test_set_state( NULL); + return 0; } From patchwork Thu Mar 4 13:51:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447347 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=eUQ2DZKj; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4DrsrH1THbz9sRf for ; Fri, 5 Mar 2021 00:57:35 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 49B01827D3; Thu, 4 Mar 2021 14:53:33 +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="eUQ2DZKj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7B1A08284F; Thu, 4 Mar 2021 14:52:31 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) (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 2E5BF826B2 for ; Thu, 4 Mar 2021 14:52:13 +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-oi1-x22c.google.com with SMTP id l133so30141729oib.4 for ; Thu, 04 Mar 2021 05:52:13 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=fx9miAvHqFxfyUJCZXZcQMoyGpdWDMEy8wHjHWPs73Y=; b=eUQ2DZKjiWqNnJx7jKKfuxFQF8tCXtT0Ia1Y5qpiXXw4ICC8vuTKTs5dfxJoGgjgWk HCiSrtmG6B1/1yHWxx8dVCC6fxdlNOykiBAf3hCJkwLPQ3S4+SZLIck+6gH2pQKoZJDi 8Lmr9SSZW46EtA9vWrPsqLt/wl7eAX6roUGf4= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=fx9miAvHqFxfyUJCZXZcQMoyGpdWDMEy8wHjHWPs73Y=; b=IF+VqwC6rJZ6M4QOe/ItMi4bTMUU80O1wh9qKEIeM4On428AToNwGeMEx1MpLnXrpD Wz6vsHbUEi+FHwa7nfep1sZ/HuvergsdsBEAfo2nT8+4h0JUToWX0UEtFlHrUK/TSWDp Yh7/eKlNtvPbb26sjRkzRHbAZsBSPAwhfuaDjC3qntdm6CrUNrkpw/Zb6DVHReroed9/ RvGX8uE71EExJrpRNY/6VL671gQLqAFpGgQlfd2qqGtwvXAz2y/hIKhLjG4+973YcUa6 wxVm6iLkwiTlHl/ZZisQMuBwqMT1In6PnmQiwW1D7Mcg4cDDDxU85hV9fJlJXAfuM/gn bmhg== X-Gm-Message-State: AOAM533RAohVBcQxlUfga+gXTMli6io4iHAMFzQFruMiXSfN/JEySZfU dvz+1kzsXiUmhhq/gUBsglbfTTFdFkyRdpVM X-Google-Smtp-Source: ABdhPJzC8Qwam8hCC2z8SY4MaIdo+hgi7zP0S0xkyFBZGM1eivUKh4LO4T0t74MqfDyPLqfg90E9CQ== X-Received: by 2002:aca:e189:: with SMTP id y131mr3046520oig.71.1614865930672; Thu, 04 Mar 2021 05:52:10 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:10 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 29/42] test: Run driver-model tests using ut_run_list() Date: Thu, 4 Mar 2021 06:51:05 -0700 Message-Id: <20210304135118.643277-29-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean Use this function instead of implementing it separately for driver model. Make ut_run_tests() private since it is only used in test-main.c Signed-off-by: Simon Glass --- (no changes since v2) Changes in v2: - Allow for prefix to be NULL, to match function comment include/test/ut.h | 42 ----------------------- test/dm/test-dm.c | 45 +++--------------------- test/test-main.c | 87 +++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 81 insertions(+), 93 deletions(-) diff --git a/include/test/ut.h b/include/test/ut.h index bed0e6eb5f6..fbbba286ee0 100644 --- a/include/test/ut.h +++ b/include/test/ut.h @@ -381,48 +381,6 @@ struct unit_test_state *test_get_state(void); */ void test_set_state(struct unit_test_state *uts); -/** - * ut_run_test_live_flat() - Run a test with both live and flat tree - * - * This calls ut_run_test() with livetree enabled, which is the standard setup - * for runnig tests. Then, for driver model test, it calls it again with - * livetree disabled. This allows checking of flattree being used when OF_LIVE - * is enabled, as is the case in U-Boot proper before relocation, as well as in - * SPL. - * - * @uts: Test state to update. The caller should ensure that this is zeroed for - * the first call to this function. On exit, @uts->fail_count is - * incremented by the number of failures (0, one hopes) - * @test: Test to run - * @name: Name of test, possibly skipping a prefix that should not be displayed - * @return 0 if all tests passed, -EAGAIN if the test should be skipped, -1 if - * any failed - */ -int ut_run_test_live_flat(struct unit_test_state *uts, struct unit_test *test, - const char *name); - -/** - * ut_run_tests() - Run a set of tests - * - * This runs the tests, handling any preparation and clean-up needed. It prints - * the name of each test before running it. - * - * @uts: Test state to update. The caller should ensure that this is zeroed for - * the first call to this function. On exit, @uts->fail_count is - * incremented by the number of failures (0, one hopes) - * @prefix: String prefix for the tests. Any tests that have this prefix will be - * printed without the prefix, so that it is easier to see the unique part - * of the test name. If NULL, no prefix processing is done - * @tests: List of tests to run - * @count: Number of tests to run - * @select_name: Name of a single test to run (from the list provided). If NULL - * then all tests are run - * @return 0 if all tests passed, -ENOENT if test @select_name was not found, - * -EBADF if any failed - */ -int ut_run_tests(struct unit_test_state *uts, const char *prefix, - struct unit_test *tests, int count, const char *select_name); - /** * ut_run_tests() - Run a set of tests * diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c index cdaf27bf987..20af1c13b3c 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -20,31 +20,14 @@ DECLARE_GLOBAL_DATA_PTR; -static bool test_matches(const char *test_name, const char *find_name) -{ - if (!find_name) - return true; - - if (!strcmp(test_name, find_name)) - return true; - - /* All tests have this prefix */ - if (!strncmp(test_name, "dm_test_", 8)) - test_name += 8; - - if (!strcmp(test_name, find_name)) - return true; - - return false; -} +struct unit_test_state global_dm_test_state; int dm_test_run(const char *test_name) { struct unit_test *tests = ll_entry_start(struct unit_test, dm_test); const int n_ents = ll_entry_count(struct unit_test, dm_test); struct unit_test_state uts_s = { .fail_count = 0 }, *uts = &uts_s; - struct unit_test *test; - int found; + struct device_node *of_root; uts->fail_count = 0; @@ -60,29 +43,11 @@ int dm_test_run(const char *test_name) } } - if (!test_name) - printf("Running %d driver model tests\n", n_ents); - else - - found = 0; - uts->of_root = gd_of_root(); - for (test = tests; test < tests + n_ents; test++) { - const char *name = test->name; - - if (!test_matches(name, test_name)) - continue; - - ut_assertok(ut_run_test_live_flat(uts, test, test->name)); - found++; - } - - if (test_name && !found) - printf("Test '%s' not found\n", test_name); - else - printf("Failures: %d\n", uts->fail_count); + of_root = gd_of_root(); + ut_run_list("driver model", "dm_test_", tests, n_ents, test_name); /* Put everything back to normal so that sandbox works as expected */ - gd_set_of_root(uts->of_root); + gd_set_of_root(of_root); gd->dm_root = NULL; ut_assertok(dm_init(CONFIG_IS_ENABLED(OF_LIVE))); dm_scan_plat(false); diff --git a/test/test-main.c b/test/test-main.c index 139fc1f6f18..16c0d13ea55 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -111,6 +111,38 @@ static bool ut_test_run_on_flattree(struct unit_test *test) return !strstr(fname, "video") || strstr(test->name, "video_base"); } +/** + * test_matches() - Check if a test should be run + * + * This checks if the a test should be run. In the normal case of running all + * tests, @select_name is NULL. + * + * @prefix: String prefix for the tests. Any tests that have this prefix will be + * printed without the prefix, so that it is easier to see the unique part + * of the test name. If NULL, no prefix processing is done + * @test_name: Name of current test + * @select_name: Name of test to run (or NULL for all) + * @return true to run this test, false to skip it + */ +static bool test_matches(const char *prefix, const char *test_name, + const char *select_name) +{ + if (!select_name) + return true; + + if (!strcmp(test_name, select_name)) + return true; + + /* All tests have this prefix */ + if (prefix && !strncmp(test_name, prefix, strlen(prefix))) + test_name += strlen(prefix); + + if (!strcmp(test_name, select_name)) + return true; + + return false; +} + /** * test_pre_run() - Handle any preparation needed to run a test * @@ -213,8 +245,25 @@ static int ut_run_test(struct unit_test_state *uts, struct unit_test *test, return 0; } -int ut_run_test_live_flat(struct unit_test_state *uts, struct unit_test *test, - const char *name) +/** + * ut_run_test_live_flat() - Run a test with both live and flat tree + * + * This calls ut_run_test() with livetree enabled, which is the standard setup + * for runnig tests. Then, for driver model test, it calls it again with + * livetree disabled. This allows checking of flattree being used when OF_LIVE + * is enabled, as is the case in U-Boot proper before relocation, as well as in + * SPL. + * + * @uts: Test state to update. The caller should ensure that this is zeroed for + * the first call to this function. On exit, @uts->fail_count is + * incremented by the number of failures (0, one hopes) + * @test: Test to run + * @name: Name of test, possibly skipping a prefix that should not be displayed + * @return 0 if all tests passed, -EAGAIN if the test should be skipped, -1 if + * any failed + */ +static int ut_run_test_live_flat(struct unit_test_state *uts, + struct unit_test *test, const char *name) { int runs; @@ -242,24 +291,39 @@ int ut_run_test_live_flat(struct unit_test_state *uts, struct unit_test *test, return 0; } -int ut_run_tests(struct unit_test_state *uts, const char *prefix, - struct unit_test *tests, int count, const char *select_name) +/** + * ut_run_tests() - Run a set of tests + * + * This runs the tests, handling any preparation and clean-up needed. It prints + * the name of each test before running it. + * + * @uts: Test state to update. The caller should ensure that this is zeroed for + * the first call to this function. On exit, @uts->fail_count is + * incremented by the number of failures (0, one hopes) + * @prefix: String prefix for the tests. Any tests that have this prefix will be + * printed without the prefix, so that it is easier to see the unique part + * of the test name. If NULL, no prefix processing is done + * @tests: List of tests to run + * @count: Number of tests to run + * @select_name: Name of a single test to run (from the list provided). If NULL + * then all tests are run + * @return 0 if all tests passed, -ENOENT if test @select_name was not found, + * -EBADF if any failed + */ +static int ut_run_tests(struct unit_test_state *uts, const char *prefix, + struct unit_test *tests, int count, + const char *select_name) { struct unit_test *test; - int prefix_len = prefix ? strlen(prefix) : 0; int found = 0; for (test = tests; test < tests + count; test++) { const char *test_name = test->name; int ret; - /* Remove the prefix */ - if (prefix && !strncmp(test_name, prefix, prefix_len)) - test_name += prefix_len; - - if (select_name && strcmp(select_name, test_name)) + if (!test_matches(prefix, test_name, select_name)) continue; - ret = ut_run_test_live_flat(uts, test, test_name); + ret = ut_run_test_live_flat(uts, test, select_name); found++; if (ret == -EAGAIN) continue; @@ -281,6 +345,7 @@ int ut_run_list(const char *category, const char *prefix, if (!select_name) printf("Running %d %s tests\n", count, category); + uts.of_root = gd_of_root(); ret = ut_run_tests(&uts, prefix, tests, count, select_name); if (ret == -ENOENT) From patchwork Thu Mar 4 13:51:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447343 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=VtR9AIHc; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4DrsqS4JW2z9sSC for ; Fri, 5 Mar 2021 00:56:52 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 762D0828A9; Thu, 4 Mar 2021 14:53:22 +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="VtR9AIHc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DEEE5826A5; Thu, 4 Mar 2021 14:52:24 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) (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 EE2C1826A5 for ; Thu, 4 Mar 2021 14:52:12 +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-oi1-x236.google.com with SMTP id l64so30129570oig.9 for ; Thu, 04 Mar 2021 05:52:12 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=4u7RTj0kyjgrZpvKKaQ3Suw06lIiUzUMDGL6bkAzumA=; b=VtR9AIHcqt6UQPxys5BMprPYScYzE1Tmi38mJIYJxAVBMcqvCaoYSbj8jV8SGCtTeZ 6ud5ZIcXP4jjZ+TTNGDAShSQDYGbrt4nrI8BSd8A/4vYK1VkgXY2oOU7hQebmsV3cdI9 qVe7KckAjevJdQcI2Suy+YdMUFquBnLKzHm7s= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=4u7RTj0kyjgrZpvKKaQ3Suw06lIiUzUMDGL6bkAzumA=; b=rmbqZMM+zyn8//e4dt5WJPx7SGVTbDAcg7W56LwItbmd2jZl8kG+C740IVJ7xwiRzK IJmt8zPt3Orno0FPh/6BIwFWqxjk8lVsxIc7sy5O6LTr6XeeViA+9evV4/qTOf5Ry0xP KxxRDfuCyS34pJDroX0rqu4+jmazj1pnwr4Yj0OqMjd/CWpBT+KwRDvZ158PfrJRDDk2 VMoViXi3BGU6fxniDaJgkmDoziiHgM2X2Kh1Js9A08gJdau9VrMPkkPU81TzfqxHBces +cLIrhVMCNUn3q3Kr/7wy00Da7kkhwXGrZXdkRm1R8meGKjXbqPeo+C9FRwugggWd/1m LXZg== X-Gm-Message-State: AOAM533sNGJwbg7LsSqijiBCpVrCDJ/9jN4u0UC3Gc44O9o/sg2A2+XS eRgEgIltk8A5dnVzdQ+22Y1I6mPXwBRiLoRV X-Google-Smtp-Source: ABdhPJzQqfHgS0vvLA8uE5H+Ao+Qr9VEkTDa/wG4j2EbmyIVEySTYgzLmmVgOw8fR/GQ9GK03pj+pg== X-Received: by 2002:aca:d690:: with SMTP id n138mr2895390oig.65.1614865931505; Thu, 04 Mar 2021 05:52:11 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:11 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 30/42] test: Use return values in dm_test_run() Date: Thu, 4 Mar 2021 06:51:06 -0700 Message-Id: <20210304135118.643277-30-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean Update this function to use the return value of ut_run_list() to check for success/failure, so that they are in sync. Also return a command success code so that the caller gets what it expects. Signed-off-by: Simon Glass --- (no changes since v1) test/dm/test-dm.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c index 20af1c13b3c..54e6577b009 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -20,16 +20,13 @@ DECLARE_GLOBAL_DATA_PTR; -struct unit_test_state global_dm_test_state; - int dm_test_run(const char *test_name) { struct unit_test *tests = ll_entry_start(struct unit_test, dm_test); const int n_ents = ll_entry_count(struct unit_test, dm_test); struct unit_test_state uts_s = { .fail_count = 0 }, *uts = &uts_s; struct device_node *of_root; - - uts->fail_count = 0; + int ret; if (!CONFIG_IS_ENABLED(OF_PLATDATA)) { /* @@ -39,22 +36,23 @@ int dm_test_run(const char *test_name) if (!gd->fdt_blob || fdt_next_node(gd->fdt_blob, 0, NULL) < 0) { puts("Please run with test device tree:\n" " ./u-boot -d arch/sandbox/dts/test.dtb\n"); - ut_assert(gd->fdt_blob); + return CMD_RET_FAILURE; } } of_root = gd_of_root(); - ut_run_list("driver model", "dm_test_", tests, n_ents, test_name); + ret = ut_run_list("driver model", "dm_test_", tests, n_ents, test_name); /* Put everything back to normal so that sandbox works as expected */ gd_set_of_root(of_root); gd->dm_root = NULL; - ut_assertok(dm_init(CONFIG_IS_ENABLED(OF_LIVE))); + if (dm_init(CONFIG_IS_ENABLED(OF_LIVE))) + return CMD_RET_FAILURE; dm_scan_plat(false); if (!CONFIG_IS_ENABLED(OF_PLATDATA)) dm_scan_fdt(false); - return uts->fail_count ? CMD_RET_FAILURE : 0; + return ret ? CMD_RET_FAILURE : 0; } int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) From patchwork Thu Mar 4 13:51:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447349 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=f91/8/Fd; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4Drsrg2h2Rz9sW8 for ; Fri, 5 Mar 2021 00:57:55 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1FA14828CB; Thu, 4 Mar 2021 14:53:39 +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="f91/8/Fd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4219B8284C; Thu, 4 Mar 2021 14:52:32 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) (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 8D5B9826FB for ; Thu, 4 Mar 2021 14:52:15 +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-oi1-x232.google.com with SMTP id w65so6580182oie.7 for ; Thu, 04 Mar 2021 05:52:15 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=m1TOl/Uscrtas3MI6SulnSlmJy9BzUQf6FoyC7/qMWM=; b=f91/8/FdQ4KnkIV+G+8NPZHGqQsr7bTaT/7q+StrqHTErz06/Te6XC5SM41fBFeXab eG0A0j/6weGgqp2sHCEEl+f3lKDBqellmwo2B/C69j8XNmyG/Z6C7Kyb4Ykzl031t7me Wowo1Y/JsGjJNapvZh/zRVYmYYgvYkcYOibDo= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=m1TOl/Uscrtas3MI6SulnSlmJy9BzUQf6FoyC7/qMWM=; b=QGphvEqth+mDYZMDduX7p82pIEhe87v1na2SmeI6rOmtQjC0SEcILMcUqohOYZHfnH B64AWj3sMWN9UCe8zizxQZQge7YabFwVtj740CMUFHv6EfU2wLR+Ssi69OJr+IGuU/70 QVEaDuvXHLLdc8faJic/A60L+Pzrr2aSUtdgzS0ygwb11MKnHCjqtfdbDiSWszU/j4V3 BT/1A+59jThTPqICysOMaHIdyyWKzPNylUdUtO086iyQf1FgeqEv+Jw/vQh2YswNvYfl 5PzlVv+/Sl7mdGM4yJttD3kgfeNwGFt5rvtHeL0S4RXh7ds0tkg/thca3XdEkSeQvgc9 nupA== X-Gm-Message-State: AOAM532qkmYTiKUAw7odF2I7rP/C7aawJjQa2Vmzq3e1EkdaGUt4Abo/ JTiinLCqk88WB77NtbrVpP9+1QXXteJGTRxs X-Google-Smtp-Source: ABdhPJwtKL/092I5bzyH6s9fkSYPcrjH1sohkAamOlzqasnwgI5Qpash7MPrdLuJbq+NzFgJ0m5ZSw== X-Received: by 2002:aca:acc2:: with SMTP id v185mr2922073oie.28.1614865932754; Thu, 04 Mar 2021 05:52:12 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:12 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 31/42] test: Move the devicetree check into ut_run_list() Date: Thu, 4 Mar 2021 06:51:07 -0700 Message-Id: <20210304135118.643277-31-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean Add a check to ut_run_list() as to whether a list has driver model tests. Move the logic for the test devicetree into that function, in an effort to eventually remove all logic from dm_test_run(). Signed-off-by: Simon Glass --- (no changes since v1) test/dm/test-dm.c | 13 ------------- test/test-main.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c index 54e6577b009..8cb99ed80cc 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -24,22 +24,9 @@ int dm_test_run(const char *test_name) { struct unit_test *tests = ll_entry_start(struct unit_test, dm_test); const int n_ents = ll_entry_count(struct unit_test, dm_test); - struct unit_test_state uts_s = { .fail_count = 0 }, *uts = &uts_s; struct device_node *of_root; int ret; - if (!CONFIG_IS_ENABLED(OF_PLATDATA)) { - /* - * If we have no device tree, or it only has a root node, then - * these * tests clearly aren't going to work... - */ - if (!gd->fdt_blob || fdt_next_node(gd->fdt_blob, 0, NULL) < 0) { - puts("Please run with test device tree:\n" - " ./u-boot -d arch/sandbox/dts/test.dtb\n"); - return CMD_RET_FAILURE; - } - } - of_root = gd_of_root(); ret = ut_run_list("driver model", "dm_test_", tests, n_ents, test_name); diff --git a/test/test-main.c b/test/test-main.c index 16c0d13ea55..8138fb43875 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -143,6 +143,25 @@ static bool test_matches(const char *prefix, const char *test_name, return false; } +/* + * ut_list_has_dm_tests() - Check if a list of tests has driver model ones + * + * @tests: List of tests to run + * @count: Number of tests to ru + * @return true if any of the tests have the UT_TESTF_DM flag + */ +static bool ut_list_has_dm_tests(struct unit_test *tests, int count) +{ + struct unit_test *test; + + for (test = tests; test < tests + count; test++) { + if (test->flags & UT_TESTF_DM) + return true; + } + + return false; +} + /** * test_pre_run() - Handle any preparation needed to run a test * @@ -342,6 +361,19 @@ int ut_run_list(const char *category, const char *prefix, struct unit_test_state uts = { .fail_count = 0 }; int ret; + if (!CONFIG_IS_ENABLED(OF_PLATDATA) && + ut_list_has_dm_tests(tests, count)) { + /* + * If we have no device tree, or it only has a root node, then + * these * tests clearly aren't going to work... + */ + if (!gd->fdt_blob || fdt_next_node(gd->fdt_blob, 0, NULL) < 0) { + puts("Please run with test device tree:\n" + " ./u-boot -d arch/sandbox/dts/test.dtb\n"); + return CMD_RET_FAILURE; + } + } + if (!select_name) printf("Running %d %s tests\n", count, category); From patchwork Thu Mar 4 13:51:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447350 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=EnYXKJ2N; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4Drsrs5SkJz9sRf for ; Fri, 5 Mar 2021 00:58:05 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E3BE4828EA; Thu, 4 Mar 2021 14:53:41 +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="EnYXKJ2N"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 411C3827F9; Thu, 4 Mar 2021 14:52:34 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) (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 47FE082806 for ; Thu, 4 Mar 2021 14:52:17 +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-oi1-x22f.google.com with SMTP id d20so30132434oiw.10 for ; Thu, 04 Mar 2021 05:52:17 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=GWE/rYv/WhQ1BBWZ9yc2TTBBtVum8dw7+RrrGdEhPag=; b=EnYXKJ2Nr6H6aD/uGWA426MHvXoxnPJZD/RG9nNrV+5PxJjhIHfMtiBlYh3iEaU8yK rd8vbeb7fOZ/A7EYWajQFnc3aCysxUlzqOIUT1XzyRuE/5pTtrJY7UkHVgHBOkq9PYMK t2r1dtVsPFXrEPo7awRJqZ5APZdyAiXnFOx4c= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=GWE/rYv/WhQ1BBWZ9yc2TTBBtVum8dw7+RrrGdEhPag=; b=I4jEFrB588W8bHOl1lD600MJ+a+o4eNPyn9c/PJlpaAQ+TV7GjCI4sAjJ/t7IiBdYZ GNBerphybEzlPXAityVY3FlWjXo7TYOKyt1E/WRgEhVfT+a5xE2iiucCGnKGgzI5mIbh vGwAEmsb3duGVKcQ2OyLgrEHMhZwK5316/JxSRXbS2+VE5p5NQyKbgEJrIfmh/4gXb// bQBF9IREgrFjA+ZNsXPjuNk8RVWrquK9EWN+fxirdXMdUFX6UMFjyQoSSHWN4KmqSGzW mFJalXsaUX0DO24OrtKcLQZ9NAqnFP7nYYGCsLkWhklOf6YU9kf3FFoaU09f6Bkqzi7d 4bIQ== X-Gm-Message-State: AOAM531+KJ28lyL6Ym7AEHdeekZClJTpshr67nIBydS4TZjgpWvBMfws KFXBZq5s4iiDULzydC79p1Bq6v6upYeszI4u X-Google-Smtp-Source: ABdhPJzfPfQuNCjGUhyoVajaGfwn4UixQvqF8VkTIfc+NRZuhXEi1yT9dk2D+66KjhkzbA1ezrGpJw== X-Received: by 2002:a05:6808:da:: with SMTP id t26mr2922092oic.77.1614865933704; Thu, 04 Mar 2021 05:52:13 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:13 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 32/42] test: Move restoring of driver model state to ut_run_list() Date: Thu, 4 Mar 2021 06:51:08 -0700 Message-Id: <20210304135118.643277-32-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean Add this functionality to ut_run_list() so it can be removed from dm_test_run(). At this point all tests are run through ut_run_list(). Signed-off-by: Simon Glass --- (no changes since v1) test/dm/test-dm.c | 11 ----------- test/test-main.c | 30 +++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c index 8cb99ed80cc..cb4f99537df 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -24,21 +24,10 @@ int dm_test_run(const char *test_name) { struct unit_test *tests = ll_entry_start(struct unit_test, dm_test); const int n_ents = ll_entry_count(struct unit_test, dm_test); - struct device_node *of_root; int ret; - of_root = gd_of_root(); ret = ut_run_list("driver model", "dm_test_", tests, n_ents, test_name); - /* Put everything back to normal so that sandbox works as expected */ - gd_set_of_root(of_root); - gd->dm_root = NULL; - if (dm_init(CONFIG_IS_ENABLED(OF_LIVE))) - return CMD_RET_FAILURE; - dm_scan_plat(false); - if (!CONFIG_IS_ENABLED(OF_PLATDATA)) - dm_scan_fdt(false); - return ret ? CMD_RET_FAILURE : 0; } diff --git a/test/test-main.c b/test/test-main.c index 8138fb43875..6edd49f0b61 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -143,7 +143,7 @@ static bool test_matches(const char *prefix, const char *test_name, return false; } -/* +/** * ut_list_has_dm_tests() - Check if a list of tests has driver model ones * * @tests: List of tests to run @@ -162,6 +162,28 @@ static bool ut_list_has_dm_tests(struct unit_test *tests, int count) return false; } +/** + * dm_test_restore() Put things back to normal so sandbox works as expected + * + * @of_root: Value to set for of_root + * @return 0 if OK, -ve on error + */ +static int dm_test_restore(struct device_node *of_root) +{ + int ret; + + gd_set_of_root(of_root); + gd->dm_root = NULL; + ret = dm_init(CONFIG_IS_ENABLED(OF_LIVE)); + if (ret) + return ret; + dm_scan_plat(false); + if (!CONFIG_IS_ENABLED(OF_PLATDATA)) + dm_scan_fdt(false); + + return 0; +} + /** * test_pre_run() - Handle any preparation needed to run a test * @@ -359,10 +381,12 @@ int ut_run_list(const char *category, const char *prefix, struct unit_test *tests, int count, const char *select_name) { struct unit_test_state uts = { .fail_count = 0 }; + bool has_dm_tests = false; int ret; if (!CONFIG_IS_ENABLED(OF_PLATDATA) && ut_list_has_dm_tests(tests, count)) { + has_dm_tests = true; /* * If we have no device tree, or it only has a root node, then * these * tests clearly aren't going to work... @@ -385,5 +409,9 @@ int ut_run_list(const char *category, const char *prefix, else printf("Failures: %d\n", uts.fail_count); + /* Best efforts only...ignore errors */ + if (has_dm_tests) + dm_test_restore(uts.of_root); + return ret; } From patchwork Thu Mar 4 13:51:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447348 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=CnRpWXTw; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4DrsrT5gp2z9sRf for ; Fri, 5 Mar 2021 00:57:45 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A7CC3828E2; Thu, 4 Mar 2021 14:53:36 +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="CnRpWXTw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8BA65827F9; Thu, 4 Mar 2021 14:52:31 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) (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 22B47827AB for ; Thu, 4 Mar 2021 14:52:16 +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-ot1-x32f.google.com with SMTP id t16so7741749ott.3 for ; Thu, 04 Mar 2021 05:52:16 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=Sbei1cac4dp/CJIaKieDZbP9+mTJYy5cf2z8NctGi2E=; b=CnRpWXTwcTsZew8TBINqeBwgamFUhVXPN3ATNcOqj8J+TFD1qBmmzue+8gIdmqusCi WuowLUrcw3Mn1f+0AZssb9+c144X0BBw2KvcI9gfwHmnzc6aJLAoUaQyeKHQoTAWLX9a 6YxZqWsFOzzw9SvjXniXHzgqODYNO1+x4vUfU= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Sbei1cac4dp/CJIaKieDZbP9+mTJYy5cf2z8NctGi2E=; b=J8v7l6/CewTnfQerVSc9NPoBbGB8wP2Sd4huNEvkZ2EVIJKUjnqYuP913R55MhLz52 3KLhIzxldYNKG1w8TxY8EoHGElRCpZM/pYDudS1Ovl3SiDh9KhtI0Sq5SyRAIYGWfK4N U3MrQHhl2ElWjS9xNkX4f/q8Ovb36Lkq/Kv2719EwJ37LPIpT30V3/n/4rEjWfX4Cptq KO67xieJ5QggCt8XzMlLF5NR8pLoChffiPtDYFB4HlhrYwbkWTYfys1qOP5rB2dW/+4G 2L4wL7/zh8vaBhezGM6O3VJxSFOrEx4sDv5VpQjJv41fpi3i0nT9eiZ6/lfVPIb9HaVD dUjg== X-Gm-Message-State: AOAM531i9da8JuDP8Qul+nlqyuQmFJBmDys/I0xdzTksKmw6MO18P2M+ 8JL2whT9gQFD1ToXsPfBD2b88OKNS4loDRd9 X-Google-Smtp-Source: ABdhPJze2LqtVMFCfzF3bVVflbD0d+vRURmfJ9/+9HFl/D1nr1DDSdp8kJ6gJHRXN1GcK4F6YhS5hA== X-Received: by 2002:a9d:146:: with SMTP id 64mr3568208otu.346.1614865934723; Thu, 04 Mar 2021 05:52:14 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:14 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 33/42] test: log: Rename log main test file to log_ut.c Date: Thu, 4 Mar 2021 06:51:09 -0700 Message-Id: <20210304135118.643277-33-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean The current name is the same as the main test runner file. Rename it to avoid confusion. Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt --- (no changes since v1) test/log/Makefile | 2 +- test/log/{test-main.c => log_ut.c} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename test/log/{test-main.c => log_ut.c} (100%) diff --git a/test/log/Makefile b/test/log/Makefile index 3f09deb644b..a3dedace043 100644 --- a/test/log/Makefile +++ b/test/log/Makefile @@ -7,7 +7,7 @@ obj-$(CONFIG_CMD_LOG) += log_filter.o ifdef CONFIG_UT_LOG -obj-y += test-main.o +obj-y += log_ut.o ifdef CONFIG_SANDBOX obj-$(CONFIG_LOG_SYSLOG) += syslog_test.o diff --git a/test/log/test-main.c b/test/log/log_ut.c similarity index 100% rename from test/log/test-main.c rename to test/log/log_ut.c From patchwork Thu Mar 4 13:51:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447355 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=IMA+Q+10; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4Drssy0hcdz9sRf for ; Fri, 5 Mar 2021 00:59:02 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E33A082919; Thu, 4 Mar 2021 14:53:54 +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="IMA+Q+10"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0AAD782879; Thu, 4 Mar 2021 14:52:42 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) (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 21E4882804 for ; Thu, 4 Mar 2021 14:52:22 +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-oi1-x233.google.com with SMTP id s73so4358426oie.1 for ; Thu, 04 Mar 2021 05:52:22 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=g+h7Re+GyhDkV7qpPs1PG1Uawfy1dUZ855HBWOjnRA8=; b=IMA+Q+10/Vbl8WdhqCJ98jbFq413lqLZ4hRBTBZgZcg73ChhLKKw/n3IZ0320uNVER d7HEQdjRnSWZriLHztK1HFbZ+6NT4JKcxr33scP/mrEDYUOUMkAZrfcitG/lkmkJLGvQ yxBOeWjTU4cWfX2o419nAgKB1S53NTxCRoyS0= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=g+h7Re+GyhDkV7qpPs1PG1Uawfy1dUZ855HBWOjnRA8=; b=GRgyKA0uwpO2wo2kpeIZYYOwsn7MjDJoeGMEGkcPDAXCqrlQV/O4YwqDAKR+KsDlPG UM7k9YwJKX8vWSQVlzT22F4EmL1nAXkgWMSHbA8h9GZVJF3pFXgxe8K6PbV76SCYOEKN 2h2XE/1sTFfPum5xSahQMFQho9Uz/sBJSA7OmcAu2viBmGZJTfArCV5BaR0hcpWZGsVd 5rR7wgl6SyRM4TtRL7WuxK1e1xLl3Uo2QFNPIROOViK/qx3n5+1EtO4N+5jGyDFxITI5 /0Pfw1M4kRUdYeFi9dANK5Uo5VhzVCLvR1UX/UpaIg0FGP4vCLi/Is+L5uxz4kSJ7uYB yoPg== X-Gm-Message-State: AOAM530GMXOfINRg4PXisNsSt87CA1jc1UCWPTfLUCmL3fuRDEOlSUl6 RrdgQKooQFJ7VzE6iOhMOdUn5AxlSE41mgpm X-Google-Smtp-Source: ABdhPJy5T18s0krtThKNvSWacq1s5we+pY13xPBzfrRdzwPfi4/uT0UeUNN9Pi9Gx69YE0boHDZA0A== X-Received: by 2002:aca:7516:: with SMTP id q22mr1438325oic.158.1614865935696; Thu, 04 Mar 2021 05:52:15 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:15 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 34/42] test: Add a macros for finding tests in linker_lists Date: Thu, 4 Mar 2021 06:51:10 -0700 Message-Id: <20210304135118.643277-34-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean At present we use the linker list directly. This is not very friendly, so add a helpful macro instead. This will also allow us to change the naming later without updating this code. Signed-off-by: Simon Glass --- (no changes since v1) include/test/test.h | 6 ++++++ test/bloblist.c | 5 ++--- test/bootm.c | 4 ++-- test/cmd/mem.c | 4 ++-- test/cmd/setexpr.c | 5 ++--- test/compression.c | 5 ++--- test/dm/test-dm.c | 4 ++-- test/env/cmd_ut_env.c | 4 ++-- test/lib/cmd_ut_lib.c | 4 ++-- test/log/log_ut.c | 4 ++-- test/optee/cmd_ut_optee.c | 5 ++--- test/overlay/cmd_ut_overlay.c | 5 ++--- test/str_ut.c | 5 ++--- test/unicode_ut.c | 4 ++-- 14 files changed, 32 insertions(+), 32 deletions(-) diff --git a/include/test/test.h b/include/test/test.h index 5eeec35f525..b16c9135f2c 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -93,6 +93,12 @@ struct unit_test { .func = _name, \ } +/* Get the start of a list of unit tests for a particular category */ +#define UNIT_TEST_SUITE_START(_suite) \ + ll_entry_start(struct unit_test, _suite) +#define UNIT_TEST_SUITE_COUNT(_suite) \ + ll_entry_count(struct unit_test, _suite) + /* Sizes for devres tests */ enum { TEST_DEVRES_SIZE = 100, diff --git a/test/bloblist.c b/test/bloblist.c index 6953d3010a6..d876b639184 100644 --- a/test/bloblist.c +++ b/test/bloblist.c @@ -387,9 +387,8 @@ BLOBLIST_TEST(bloblist_test_reloc, 0); int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = ll_entry_start(struct unit_test, - bloblist_test); - const int n_ents = ll_entry_count(struct unit_test, bloblist_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(bloblist_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(bloblist_test); return cmd_ut_category("bloblist", "bloblist_test_", tests, n_ents, argc, argv); diff --git a/test/bootm.c b/test/bootm.c index 563d6ebaa5a..8528982ae11 100644 --- a/test/bootm.c +++ b/test/bootm.c @@ -240,8 +240,8 @@ BOOTM_TEST(bootm_test_subst_both, 0); int do_ut_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = ll_entry_start(struct unit_test, bootm_test); - const int n_ents = ll_entry_count(struct unit_test, bootm_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(bootm_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(bootm_test); return cmd_ut_category("bootm", "bootm_test_", tests, n_ents, argc, argv); diff --git a/test/cmd/mem.c b/test/cmd/mem.c index fbaa8a4b3cf..d76f47cf311 100644 --- a/test/cmd/mem.c +++ b/test/cmd/mem.c @@ -12,8 +12,8 @@ int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = ll_entry_start(struct unit_test, mem_test); - const int n_ents = ll_entry_count(struct unit_test, mem_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(mem_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(mem_test); return cmd_ut_category("cmd_mem", "mem_test_", tests, n_ents, argc, argv); diff --git a/test/cmd/setexpr.c b/test/cmd/setexpr.c index b483069ff0f..27113c083c5 100644 --- a/test/cmd/setexpr.c +++ b/test/cmd/setexpr.c @@ -390,9 +390,8 @@ SETEXPR_TEST(setexpr_test_str_long, UT_TESTF_CONSOLE_REC); int do_ut_setexpr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = ll_entry_start(struct unit_test, - setexpr_test); - const int n_ents = ll_entry_count(struct unit_test, setexpr_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(setexpr_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(setexpr_test); return cmd_ut_category("cmd_setexpr", "setexpr_test_", tests, n_ents, argc, argv); diff --git a/test/compression.c b/test/compression.c index a2a4b9ff9e8..4cd1be564f3 100644 --- a/test/compression.c +++ b/test/compression.c @@ -539,9 +539,8 @@ COMPRESSION_TEST(compression_test_bootm_none, 0); int do_ut_compression(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = ll_entry_start(struct unit_test, - compression_test); - const int n_ents = ll_entry_count(struct unit_test, compression_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(compression_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(compression_test); return cmd_ut_category("compression", "compression_test_", tests, n_ents, argc, argv); diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c index cb4f99537df..729becf57b2 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -22,8 +22,8 @@ DECLARE_GLOBAL_DATA_PTR; int dm_test_run(const char *test_name) { - struct unit_test *tests = ll_entry_start(struct unit_test, dm_test); - const int n_ents = ll_entry_count(struct unit_test, dm_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(dm_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(dm_test); int ret; ret = ut_run_list("driver model", "dm_test_", tests, n_ents, test_name); diff --git a/test/env/cmd_ut_env.c b/test/env/cmd_ut_env.c index a440b1bfb0e..d65a32179ce 100644 --- a/test/env/cmd_ut_env.c +++ b/test/env/cmd_ut_env.c @@ -12,8 +12,8 @@ int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = ll_entry_start(struct unit_test, env_test); - const int n_ents = ll_entry_count(struct unit_test, env_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(env_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(env_test); return cmd_ut_category("environment", "env_test_", tests, n_ents, argc, argv); diff --git a/test/lib/cmd_ut_lib.c b/test/lib/cmd_ut_lib.c index f5c7bf3d3b0..f1ac015b2c8 100644 --- a/test/lib/cmd_ut_lib.c +++ b/test/lib/cmd_ut_lib.c @@ -13,8 +13,8 @@ int do_ut_lib(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = ll_entry_start(struct unit_test, lib_test); - const int n_ents = ll_entry_count(struct unit_test, lib_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(lib_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(lib_test); return cmd_ut_category("lib", "lib_test_", tests, n_ents, argc, argv); } diff --git a/test/log/log_ut.c b/test/log/log_ut.c index c534add493e..5aa3a184004 100644 --- a/test/log/log_ut.c +++ b/test/log/log_ut.c @@ -13,8 +13,8 @@ int do_ut_log(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]) { - struct unit_test *tests = ll_entry_start(struct unit_test, log_test); - const int n_ents = ll_entry_count(struct unit_test, log_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(log_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(log_test); return cmd_ut_category("log", "log_test_", tests, n_ents, argc, argv); diff --git a/test/optee/cmd_ut_optee.c b/test/optee/cmd_ut_optee.c index 9fa4c91e0dd..c3887ab11d9 100644 --- a/test/optee/cmd_ut_optee.c +++ b/test/optee/cmd_ut_optee.c @@ -94,9 +94,8 @@ OPTEE_TEST(optee_fdt_protected_memory, 0); int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = ll_entry_start(struct unit_test, - optee_test); - const int n_ents = ll_entry_count(struct unit_test, optee_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(optee_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(optee_test); struct unit_test_state *uts; void *fdt_optee = &__dtb_test_optee_optee_begin; void *fdt_no_optee = &__dtb_test_optee_no_optee_begin; diff --git a/test/overlay/cmd_ut_overlay.c b/test/overlay/cmd_ut_overlay.c index c001fb183fe..56a3df17138 100644 --- a/test/overlay/cmd_ut_overlay.c +++ b/test/overlay/cmd_ut_overlay.c @@ -213,9 +213,8 @@ OVERLAY_TEST(fdt_overlay_stacked, 0); int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = ll_entry_start(struct unit_test, - overlay_test); - const int n_ents = ll_entry_count(struct unit_test, overlay_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(overlay_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(overlay_test); struct unit_test_state *uts; void *fdt_base = &__dtb_test_fdt_base_begin; void *fdt_overlay = &__dtb_test_fdt_overlay_begin; diff --git a/test/str_ut.c b/test/str_ut.c index cd5045516d1..359d7d4ea1f 100644 --- a/test/str_ut.c +++ b/test/str_ut.c @@ -107,9 +107,8 @@ STR_TEST(str_simple_strtoul, 0); int do_ut_str(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = ll_entry_start(struct unit_test, - str_test); - const int n_ents = ll_entry_count(struct unit_test, str_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(str_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(str_test); return cmd_ut_category("str", "str_", tests, n_ents, argc, argv); } diff --git a/test/unicode_ut.c b/test/unicode_ut.c index 6130ef0b549..7b9c020eff9 100644 --- a/test/unicode_ut.c +++ b/test/unicode_ut.c @@ -615,8 +615,8 @@ UNICODE_TEST(unicode_test_efi_create_indexed_name); int do_ut_unicode(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = ll_entry_start(struct unit_test, unicode_test); - const int n_ents = ll_entry_count(struct unit_test, unicode_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(unicode_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(unicode_test); return cmd_ut_category("Unicode", "unicode_test_", tests, n_ents, argc, argv); From patchwork Thu Mar 4 13:51:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447357 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=KyE6aKCK; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4DrstM5pwnz9sRf for ; Fri, 5 Mar 2021 00:59:23 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AD29781FDD; Thu, 4 Mar 2021 14:54:00 +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="KyE6aKCK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ABDB08286B; Thu, 4 Mar 2021 14:52:42 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) (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 3E5668280D for ; Thu, 4 Mar 2021 14:52:23 +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-oi1-x232.google.com with SMTP id a13so30163724oid.0 for ; Thu, 04 Mar 2021 05:52:23 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=wb655gGRQiGSn3WwGH6xwatQe9exDXys5V2UQ7TBRbA=; b=KyE6aKCKtmeRs1ueCr9692b02In1BaFR6KdznZOK8VpJzCQEQblkSH32Uc5HnOvSX9 FpTmrAO+l56J853OhKBpEhlaUEcKE9d/lTLvH6ncCDm+OCx293o7Z1/fIDNMBY/tj9BH LTEsXWPv4Lf+h5AKCF+rAnmtsxyX7goIpWfrc= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=wb655gGRQiGSn3WwGH6xwatQe9exDXys5V2UQ7TBRbA=; b=ViK7fLcP6Pe+cN5nnV0mWkb4w4TY2dGa9sv0w1xuhn7/22EH3gtVqGI3QzVzycLHV8 ZLj8QeTWn99FIfxviiKaqN/H431h7APbI+vPoesSIyEN5POlDn2b73l3SydHI8UxwGCo WEXZliYEDY5cXud239BPdAQId7kB4gDmzAgBrAPV5VU6NE85JOrrB3iSe9mDwSv+m8xa Dy+4/1QJEFKKp4MEUuKFcq2tI2x5jJb0KvRHJ8mG8/2ygYuoucdxpkCy6YuBu6+gfznx LcelxG07foEWL2gRGJgAmEs36hd7AGKIF7UnuChfVXIWu60Uz7xjadC+rQ3LYCOoKVJc la2w== X-Gm-Message-State: AOAM531en1qflOUuR4kqQf7hyYi4Yfwze7bUPu9tYZsgZikffZgGQ/gf q0NYU5SbQbL5q1EK1blNIHhi05CFyEqSc8Xg X-Google-Smtp-Source: ABdhPJwDXRHzdJiUIm0wk4Bmpj112f2HM+lwK9zIiHOtJ6vWHZ4AKJZeVBS8+FgUr504wRrboAfdiQ== X-Received: by 2002:aca:1b05:: with SMTP id b5mr3019210oib.96.1614865936669; Thu, 04 Mar 2021 05:52:16 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:16 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 35/42] test: Rename all linker lists to have a ut_ prefix Date: Thu, 4 Mar 2021 06:51:11 -0700 Message-Id: <20210304065106.v4.35.Ide325abe75154eaf4508ab04c88eba23804fa291@changeid> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean At present each test suite has its own portion of the linker_list section of the image, but other lists are interspersed. This makes it hard to enumerate all the available tests without knowing the suites that each one is in. Place all tests together in a single contiguous list by giving them common prefix not used elsewhere in U-Boot. This makes it possible to find the start and end of all tests. Signed-off-by: Simon Glass --- (no changes since v3) Changes in v3: - Update the pytest collector as well include/test/test.h | 8 ++++---- test/py/conftest.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/test/test.h b/include/test/test.h index b16c9135f2c..3330dcc72d3 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -86,18 +86,18 @@ struct unit_test { * @_suite: name of the test suite concatenated with "_test" */ #define UNIT_TEST(_name, _flags, _suite) \ - ll_entry_declare(struct unit_test, _name, _suite) = { \ + ll_entry_declare(struct unit_test, _name, ut_ ## _suite) = { \ .file = __FILE__, \ .name = #_name, \ .flags = _flags, \ .func = _name, \ } -/* Get the start of a list of unit tests for a particular category */ +/* Get the start of a list of unit tests for a particular suite */ #define UNIT_TEST_SUITE_START(_suite) \ - ll_entry_start(struct unit_test, _suite) + ll_entry_start(struct unit_test, ut_ ## _suite) #define UNIT_TEST_SUITE_COUNT(_suite) \ - ll_entry_count(struct unit_test, _suite) + ll_entry_count(struct unit_test, ut_ ## _suite) /* Sizes for devres tests */ enum { diff --git a/test/py/conftest.py b/test/py/conftest.py index 9bfd9263455..1b909cde9d3 100644 --- a/test/py/conftest.py +++ b/test/py/conftest.py @@ -226,7 +226,7 @@ def pytest_configure(config): import u_boot_console_exec_attach console = u_boot_console_exec_attach.ConsoleExecAttach(log, ubconfig) -re_ut_test_list = re.compile(r'_u_boot_list_2_(.*)_test_2_\1_test_(.*)\s*$') +re_ut_test_list = re.compile(r'_u_boot_list_2_ut_(.*)_test_2_\1_test_(.*)\s*$') def generate_ut_subtest(metafunc, fixture_name, sym_path): """Provide parametrization for a ut_subtest fixture. From patchwork Thu Mar 4 13:51:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447353 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=fqyKx2YX; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4DrssW73NJz9sRf for ; Fri, 5 Mar 2021 00:58:39 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9E4F4828F7; Thu, 4 Mar 2021 14:53:49 +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="fqyKx2YX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B9B9A82850; Thu, 4 Mar 2021 14:52:37 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) (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 61DD6827E9 for ; Thu, 4 Mar 2021 14:52:20 +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-oi1-x233.google.com with SMTP id j1so30161131oiw.3 for ; Thu, 04 Mar 2021 05:52:20 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=VeEKzIxhdMsEdk1goDoQhtO0Vfwq055vfyXYrT+ZE3E=; b=fqyKx2YXhqC23RSDkd03CTSJVADIPmFMT0/64kAwME6Pb0CWkQz558kLtOM3y6QVhN fsJgYceG4GqDpWzQQtmMLRcDBZWjb/ki1d+q22penT17ogETuuwXhGoKedReBiwJ45PU F3UbYmuSJOxSOtFjDhwBGbNotMbGFkbIceXvA= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=VeEKzIxhdMsEdk1goDoQhtO0Vfwq055vfyXYrT+ZE3E=; b=mjmtiVxpbVg11N1lZKNlkkhwnA/o1hkaDF5D9lthhlBicFTDAdR9qRTEmf2R6kJRfe m0UH5RNi4qqScPrT9vlo4GoQOuwA7KtutBNO5lb+3Ctl4XRMVWQnZOaSw0VHkkhyMn9N cNsTQGwMq79VoTijcdix2Jk5dyfaPQD8X6aQtYFHl7o1lDe5VqjFtqT0Ua5IohoEganX ii59rootKAw+kIMn0kk0VvvVGPRTj14fF2AL3Rrm+lX/1FoATdA8ycICsJPLFJYOpXNO MXzGfAtaHLkSuRzscxewjXO2D5DM9eQFASpzC1esBy+lXalm273z5iLKLJRn3gpAS0WH m86A== X-Gm-Message-State: AOAM530WD30vXZlKUcMgnZUWM29IMvB4MLWtcOR/4mgY1wKG2S0045MW gFqWe1PlTKc8rhWljdRvsik7CuXQZ983W6yF X-Google-Smtp-Source: ABdhPJx1FeGwPzv1PcjmiQqLe3XwUgvBAeBWrWoa/hLsmJF5U5XVnaVH59EYEnI/oTiSehOzG/IhaA== X-Received: by 2002:aca:4c4d:: with SMTP id z74mr2872918oia.178.1614865937461; Thu, 04 Mar 2021 05:52:17 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:17 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 36/42] test: Allow SPL to run any available test Date: Thu, 4 Mar 2021 06:51:12 -0700 Message-Id: <20210304135118.643277-35-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean At present SPL only runs driver model tests. Update it to run all available tests, i.e. in any test suite. Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/cpu/spl.c | 7 +++++-- include/test/test.h | 16 +++++----------- test/dm/test-dm.c | 11 ++++++++++- test/test-main.c | 17 +++++++++++++---- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c index 3779d58c3fe..ce5aae87fb6 100644 --- a/arch/sandbox/cpu/spl.c +++ b/arch/sandbox/cpu/spl.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include DECLARE_GLOBAL_DATA_PTR; @@ -63,9 +63,12 @@ void spl_board_init(void) preloader_console_init(); if (state->run_unittests) { + struct unit_test *tests = UNIT_TEST_ALL_START(); + const int count = UNIT_TEST_ALL_COUNT(); int ret; - ret = dm_test_run(state->select_unittests); + ret = ut_run_list("spl", NULL, tests, count, + state->select_unittests); /* continue execution into U-Boot */ } } diff --git a/include/test/test.h b/include/test/test.h index 3330dcc72d3..0b124edd601 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -99,6 +99,11 @@ struct unit_test { #define UNIT_TEST_SUITE_COUNT(_suite) \ ll_entry_count(struct unit_test, ut_ ## _suite) +/* Use ! and ~ so that all tests will be sorted between these two values */ +#define UNIT_TEST_ALL_START() ll_entry_start(struct unit_test, ut_!) +#define UNIT_TEST_ALL_END() ll_entry_start(struct unit_test, ut_~) +#define UNIT_TEST_ALL_COUNT() (UNIT_TEST_ALL_END() - UNIT_TEST_ALL_START()) + /* Sizes for devres tests */ enum { TEST_DEVRES_SIZE = 100, @@ -119,15 +124,4 @@ enum { */ struct udevice *testbus_get_clear_removed(void); -/** - * dm_test_run() - Run driver model tests - * - * Run all the available driver model tests, or a selection - * - * @test_name: Name of single test to run (e.g. "dm_test_fdt_pre_reloc" or just - * "fdt_pre_reloc"), or NULL to run all - * @return 0 if all tests passed, 1 if not - */ -int dm_test_run(const char *test_name); - #endif /* __TEST_TEST_H */ diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c index 729becf57b2..9ba2ba23d5d 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -20,7 +20,16 @@ DECLARE_GLOBAL_DATA_PTR; -int dm_test_run(const char *test_name) +/** + * dm_test_run() - Run driver model tests + * + * Run all the available driver model tests, or a selection + * + * @test_name: Name of single test to run (e.g. "dm_test_fdt_pre_reloc" or just + * "fdt_pre_reloc"), or NULL to run all + * @return 0 if all tests passed, 1 if not + */ +static int dm_test_run(const char *test_name) { struct unit_test *tests = UNIT_TEST_SUITE_START(dm_test); const int n_ents = UNIT_TEST_SUITE_COUNT(dm_test); diff --git a/test/test-main.c b/test/test-main.c index 6edd49f0b61..e1b49e091ab 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -119,7 +119,8 @@ static bool ut_test_run_on_flattree(struct unit_test *test) * * @prefix: String prefix for the tests. Any tests that have this prefix will be * printed without the prefix, so that it is easier to see the unique part - * of the test name. If NULL, no prefix processing is done + * of the test name. If NULL, any suite name (xxx_test) is considered to be + * a prefix. * @test_name: Name of current test * @select_name: Name of test to run (or NULL for all) * @return true to run this test, false to skip it @@ -133,9 +134,17 @@ static bool test_matches(const char *prefix, const char *test_name, if (!strcmp(test_name, select_name)) return true; - /* All tests have this prefix */ - if (prefix && !strncmp(test_name, prefix, strlen(prefix))) - test_name += strlen(prefix); + if (!prefix) { + const char *p = strstr(test_name, "_test_"); + + /* convert xxx_test_yyy to yyy, i.e. remove the suite name */ + if (p) + test_name = p + 6; + } else { + /* All tests have this prefix */ + if (!strncmp(test_name, prefix, strlen(prefix))) + test_name += strlen(prefix); + } if (!strcmp(test_name, select_name)) return true; From patchwork Thu Mar 4 13:51:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447351 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=nY/tpsyR; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4Drss430Kjz9sRf for ; Fri, 5 Mar 2021 00:58:16 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C8DF5828FD; Thu, 4 Mar 2021 14:53:44 +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="nY/tpsyR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3C69082857; Thu, 4 Mar 2021 14:52:36 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE, T_FILL_THIS_FORM_SHORT autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) (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 108A38276B for ; Thu, 4 Mar 2021 14:52:20 +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-oi1-x232.google.com with SMTP id q203so7117208oih.5 for ; Thu, 04 Mar 2021 05:52:19 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=3RuKvFhySolsAjowShwSKp9R30R3Ah8bs34aYOsOc74=; b=nY/tpsyRHT9/arv2XM6YHJpQFHjwAEDQHDZ2np7cON9rBZdDd4m59P5RHZ+ydGW2gn 9KQP8TfHnrN8KmqzIWM2HjRw5b+gaBUr2tcAds1iLPZ3tWwzqNjlmshTeCOZXiTDtXg7 RQ0kVfmeZNrSymE55ow/Raoqgkj5Bi3ZXoBu4= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=3RuKvFhySolsAjowShwSKp9R30R3Ah8bs34aYOsOc74=; b=D1joj+fqTd7BFR7YQAH1VJiYoVPVV4AHViyGeiafkz5jQKNpis7wYaLzYvb6TytZ8m 6AGO6QELmJ7MWb8d1sMCPHxE1syEyIZS1btcLTxHgyDn68+RIxW/0AKZRf5h48HYfz9F PUuyeslG8pcnvISThBvtPD/gd595/yJOaSaPePc4IRu+Ia0jC/c4jZ+5/ZRpyrso6r+u W2X5O/2BlF704gDMv+dc59cIdpVT1Z1AeuZGXggv2uY2/6jbnTDxAFhTH2UsBtm9JSKN AVivW1Ervxu26Zu+FwlKo5bXnMFaaxHocn4O6Zyw7WVE4sV+tFbMOmhHJxuYSxlF8AXd 1qCg== X-Gm-Message-State: AOAM533LE4YUmvwft5fgyZprmGY6BG8SQQCd9IVAchifoXvVbsn+mOV0 Xi96CeKby0G+mQCYh2GL0s/O7OwTOMh2bXZ9 X-Google-Smtp-Source: ABdhPJyl2fPafD123JHpsrHXfIlfj07vXBr/lUCawIr+xR55rjvoIfI9FlFbKZ0bv0JhziR8VKTyRQ== X-Received: by 2002:a05:6808:1d7:: with SMTP id x23mr2915410oic.31.1614865938364; Thu, 04 Mar 2021 05:52:18 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:18 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 37/42] sandbox: Update os_find_u_boot() to find the .img file Date: Thu, 4 Mar 2021 06:51:13 -0700 Message-Id: <20210304135118.643277-36-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean At present this function can only locate the u-boot ELF file. For SPL it is handy to be able to locate u-boot.img since this is what would normally be loaded by SPL. Add another argument to allow this to be selected. While we are here, update the function to load SPL when running in TPL, since that is the next stage. Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/cpu/os.c | 8 +++++--- arch/sandbox/cpu/spl.c | 2 +- include/os.h | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index f5000e64966..2d9583c17ca 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -777,7 +777,7 @@ int os_jump_to_image(const void *dest, int size) return os_jump_to_file(fname); } -int os_find_u_boot(char *fname, int maxlen) +int os_find_u_boot(char *fname, int maxlen, bool use_img) { struct sandbox_state *state = state_get_current(); const char *progname = state->argv[0]; @@ -801,8 +801,8 @@ int os_find_u_boot(char *fname, int maxlen) return 0; } - /* Look for 'u-boot-tpl' in the tpl/ directory */ - p = strstr(fname, "/tpl/"); + /* Look for 'u-boot-spl' in the spl/ directory */ + p = strstr(fname, "/spl/"); if (p) { p[1] = 's'; fd = os_open(fname, O_RDONLY); @@ -829,6 +829,8 @@ int os_find_u_boot(char *fname, int maxlen) if (p) { /* Remove the "spl" characters */ memmove(p, p + 4, strlen(p + 4) + 1); + if (use_img) + strcat(p, ".img"); fd = os_open(fname, O_RDONLY); if (fd >= 0) { close(fd); diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c index ce5aae87fb6..f82b0d3de16 100644 --- a/arch/sandbox/cpu/spl.c +++ b/arch/sandbox/cpu/spl.c @@ -37,7 +37,7 @@ static int spl_board_load_image(struct spl_image_info *spl_image, char fname[256]; int ret; - ret = os_find_u_boot(fname, sizeof(fname)); + ret = os_find_u_boot(fname, sizeof(fname), false); if (ret) { printf("(%s not found, error %d)\n", fname, ret); return ret; diff --git a/include/os.h b/include/os.h index d2a4afeca0f..77d8bd89d0f 100644 --- a/include/os.h +++ b/include/os.h @@ -324,9 +324,10 @@ int os_jump_to_image(const void *dest, int size); * * @fname: place to put full path to U-Boot * @maxlen: maximum size of @fname + * @use_img: select the 'u-boot.img' file instead of the 'u-boot' ELF file * Return: 0 if OK, -NOSPC if the filename is too large, -ENOENT if not found */ -int os_find_u_boot(char *fname, int maxlen); +int os_find_u_boot(char *fname, int maxlen, bool use_img); /** * os_spl_to_uboot() - Run U-Boot proper From patchwork Thu Mar 4 13:51:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447354 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=YSYXzeCz; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4Drssl1J7Gz9sRf for ; Fri, 5 Mar 2021 00:58:51 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 05D038290E; Thu, 4 Mar 2021 14:53:52 +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="YSYXzeCz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B32F7827E9; Thu, 4 Mar 2021 14:52:38 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) (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 E2F3082765 for ; Thu, 4 Mar 2021 14:52:20 +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-oi1-x22d.google.com with SMTP id f3so30112051oiw.13 for ; Thu, 04 Mar 2021 05:52:20 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=RmxTd9zMknSIyymhahQ8pzvfo8TtH69advGBLW2uaWY=; b=YSYXzeCz8evYMINz829PKl4ZlrwjDJo+IzZopHnssGzl34t4r6tqMGyyfaQNaxBb/K pR5rcG92INLjcpgmwBI8x015b3fkmY5gdBAbV/jMtDhRead6P99utAojmT17CnyMbMSA 3bF6uK9Y9YiUtaW2QMXdmUhOgzKJsT1tb30Hc= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=RmxTd9zMknSIyymhahQ8pzvfo8TtH69advGBLW2uaWY=; b=jFdmGctT02N/98Aam+PjYoEx2E32RxQSR3Av3dIooLK9XMGkZdooG//upz+l4L2VHh QkdTPNtQzQwsa8cLqrw79WNnTb6z3V4l7P9hDaorwuP/qDBPkIGMQphma7Cnan+MXF6J t426f3PzHWp4ATJSid1E8gTOQL9wPsXJUyYkuHUNIVzsbwwA5qYDGl91p4QJMAiPwVcB VFSW+ha8xqF1Q6Fz8Ycm86otPG3Ai5OFMqKR8BrXpCzGV4639ylNgrRN6xxNqoB+DDcA y/1+FoYFzuu3g6sp1+1doyN3Fmnw2CUlZwPRWwg1AwEQ+9Y417jsMuMKI+B8ziVGRIlg 67cQ== X-Gm-Message-State: AOAM531r1nu2K6rtJW6NxlttbIYLwpDQLh/bmYFYer2jz/orw36RCkDp iTIU7p4N4aZPs70FT58IgcG+nXsm18y3AiYY X-Google-Smtp-Source: ABdhPJw/Qty12GEUoqWg03QfThFBDu2fOpcK7iHS4/ucK0WjdAMTmIl8wpIMQfkuV4HG9OlDg5f6ug== X-Received: by 2002:a05:6808:d46:: with SMTP id w6mr2975724oik.47.1614865939186; Thu, 04 Mar 2021 05:52:19 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:18 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 38/42] spl: Convert spl_fit to work with sandbox Date: Thu, 4 Mar 2021 06:51:14 -0700 Message-Id: <20210304135118.643277-37-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean At present this casts addresses to pointers so cannot work with sandbox. Update the code to use map_sysmem() instead. As part of this change, the existing load_ptr is renamed to src_ptr since it is not a pointer to load_addr. It is confusing to use a similar name for something that is not actually related. For the alignment code, ALIGN() is used instead of open-coded alignment. Add a comment to the line that casts away a const. Use a (new) load_ptr variable to access memory at address load_addr. Signed-off-by: Simon Glass --- (no changes since v1) common/spl/spl.c | 3 ++- common/spl/spl_fit.c | 27 +++++++++++++++------------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index bb91b761fc7..5f51098a88f 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -168,7 +169,7 @@ __weak void spl_board_prepare_for_boot(void) __weak struct image_header *spl_get_load_buffer(ssize_t offset, size_t size) { - return (struct image_header *)(CONFIG_SYS_TEXT_BASE + offset); + return map_sysmem(CONFIG_SYS_TEXT_BASE + offset, 0); } void spl_set_header_raw_uboot(struct spl_image_info *spl_image) diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index 75c8ff065bb..49508fc5180 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -235,11 +236,11 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector, size_t length; int len; ulong size; - ulong load_addr, load_ptr; + ulong load_addr; + void *load_ptr; void *src; ulong overhead; int nr_sectors; - int align_len = ARCH_DMA_MINALIGN - 1; uint8_t image_comp = -1, type = -1; const void *data; const void *fit = ctx->fit; @@ -269,11 +270,13 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector, } if (external_data) { + void *src_ptr; + /* External data */ if (fit_image_get_data_size(fit, node, &len)) return -ENOENT; - load_ptr = (load_addr + align_len) & ~align_len; + src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len); length = len; overhead = get_aligned_image_overhead(info, offset); @@ -281,12 +284,12 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector, if (info->read(info, sector + get_aligned_image_offset(info, offset), - nr_sectors, (void *)load_ptr) != nr_sectors) + nr_sectors, src_ptr) != nr_sectors) return -EIO; - debug("External data: dst=%lx, offset=%x, size=%lx\n", - load_ptr, offset, (unsigned long)length); - src = (void *)load_ptr + overhead; + debug("External data: dst=%p, offset=%x, size=%lx\n", + src_ptr, offset, (unsigned long)length); + src = src_ptr + overhead; } else { /* Embedded data */ if (fit_image_get_data(fit, node, &data, &length)) { @@ -295,7 +298,7 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector, } debug("Embedded data: dst=%lx, size=%lx\n", load_addr, (unsigned long)length); - src = (void *)data; + src = (void *)data; /* cast away const */ } if (CONFIG_IS_ENABLED(FIT_SIGNATURE)) { @@ -309,16 +312,16 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector, if (CONFIG_IS_ENABLED(FIT_IMAGE_POST_PROCESS)) board_fit_image_post_process(&src, &length); + load_ptr = map_sysmem(load_addr, length); if (IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP) { size = length; - if (gunzip((void *)load_addr, CONFIG_SYS_BOOTM_LEN, - src, &size)) { + if (gunzip(load_ptr, CONFIG_SYS_BOOTM_LEN, src, &size)) { puts("Uncompressing error\n"); return -EIO; } length = size; } else { - memcpy((void *)load_addr, src, length); + memcpy(load_ptr, src, length); } if (image_info) { @@ -383,7 +386,7 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image, } /* Make the load-address of the FDT available for the SPL framework */ - spl_image->fdt_addr = (void *)image_info.load_addr; + spl_image->fdt_addr = map_sysmem(image_info.load_addr, 0); if (CONFIG_IS_ENABLED(FIT_IMAGE_TINY)) return 0; From patchwork Thu Mar 4 13:51:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447352 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=bwRfgBnj; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4DrssJ108Dz9sRf for ; Fri, 5 Mar 2021 00:58:28 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BED2382909; Thu, 4 Mar 2021 14:53:46 +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="bwRfgBnj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F2D39827E9; Thu, 4 Mar 2021 14:52:37 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x22b.google.com (mail-oi1-x22b.google.com [IPv6:2607:f8b0:4864:20::22b]) (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 882668280F for ; Thu, 4 Mar 2021 14:52:21 +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-oi1-x22b.google.com with SMTP id d20so30132777oiw.10 for ; Thu, 04 Mar 2021 05:52:21 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=aO+PrWQYfdEoqa23Ja7ZowCpvwHb351qv3OfcOsWJG4=; b=bwRfgBnjSmF+d9349dAdxVJgesj2seI854VjINQYqItYu8dG+GBqIlKi0+az+GyD7h iFQb5Ry+VOSY3v1bH54zhlDO1glKwnb6UiNmTUxeiUVK+gRglFI5AZCWGG/figO1Ww6O eETrSdsHdV82CCoRtl3v/Gm6/I9TwnqJZFyyU= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=aO+PrWQYfdEoqa23Ja7ZowCpvwHb351qv3OfcOsWJG4=; b=GVMIanJCZa+ha+wzstjm2QigZXS9o+kJbg+e2u3KtHi2OJI3i9LE9rluTgoUUf+vJv AzER0YPnGy6kIDDOJ9RDnkP3oYerVwRt9tVXjfubWqLvr6IGTJSeZx4+T1kq3jZ6wL3J d/O+p+qk6KWEkSUUzzHxe47cGPvjJ5AFTdugDuD6oCtsFG8a4BSOPvaBjcz6VWhnEkBB 3zKLPvra7GsVBV5PrYlTalhjd49Qs/3T8WXj6Yn3LLWjf51uIAAojff7ROqSAu0nP7dS uIiy4FqpC0GqjzWOClAL2RVQpo8FLQ4jMI4wFWmrAYOZldUdRmqZj384kwjbIirEFw6T BglA== X-Gm-Message-State: AOAM531la1MeWRqy138qOBsua0uzPEGi2hJ5CpswttrtAMdIvzfPDzPW 7LevWW3qE0oF1xG/QXpHFT7PTqwXPYEz+ojT X-Google-Smtp-Source: ABdhPJzm8zOgZJ6I/fDgx7rZyfrw6XeA96Qvkw28R8A1pHhECYEHR+FJ1ATYWv+ckLQ+K1CJcjPPWQ== X-Received: by 2002:aca:c146:: with SMTP id r67mr2961330oif.131.1614865940081; Thu, 04 Mar 2021 05:52:20 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:19 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 39/42] doc: Move coccinelle into its own section Date: Thu, 4 Mar 2021 06:51:15 -0700 Message-Id: <20210304135118.643277-38-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean This tool has nothing to do with testing. Create a new section for 'refactoring' and move it into there. It is likely that other topics may fall under the same heading, such as using moveconfig and search/replace tools. Signed-off-by: Simon Glass --- (no changes since v1) doc/develop/index.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/develop/index.rst b/doc/develop/index.rst index 50b1de3bdff..9208668a2d4 100644 --- a/doc/develop/index.rst +++ b/doc/develop/index.rst @@ -30,7 +30,14 @@ Testing .. toctree:: :maxdepth: 1 - coccinelle testing py_testing tests_sandbox + +Refactoring +----------- + +.. toctree:: + :maxdepth: 1 + + coccinelle From patchwork Thu Mar 4 13:51:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447356 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=RnazA5Dx; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4Drst90WsCz9sW8 for ; Fri, 5 Mar 2021 00:59:13 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 26B8F8291F; Thu, 4 Mar 2021 14:53:58 +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="RnazA5Dx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EA9AC82862; Thu, 4 Mar 2021 14:52:42 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) (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 8452382822 for ; Thu, 4 Mar 2021 14:52:22 +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-oi1-x22f.google.com with SMTP id q203so7117387oih.5 for ; Thu, 04 Mar 2021 05:52:22 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=1QxWurWZixvZR58sFuLONiTI7SrlHuEs4GOKQ5nuInM=; b=RnazA5DxiHC6aI2ocTb5uF1m1Ay3IMTzso6aCIMgnybQ2LWmFnDn37ARH5vAuVbCrO UGdhrBbUE5NO9UtBNquU1AvipYHQJ0JGHtumaWBXvJI2lYy0ivigt6kEnUT6CMdz8pOx X/UjSMdk4vMlYaK+iUN6ijbKiiZa50iUPQ90A= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=1QxWurWZixvZR58sFuLONiTI7SrlHuEs4GOKQ5nuInM=; b=cdVKX2Qp9Me+P+vWt1YCOuYrXZINrxvJmcZ9IMtUOHOEnrvRXqxpCMFrJPjVlwI+lB ZH6/oOYRYSgLdEI2h3jG72J6U6pZQnUEDH4gMkDqSnknzz3kR8i/h7HBCWAGHh+HcL1W 496wjldPFOJpuSe24MLJREPcbnR+MaGlZzaUgKLfnLgWygvKzKUk+EUIGcoZDU7Xgvwp wXbl/eB3Rdy+YtiBJWROvgdwC5ZFfZ7RP2qeU1G2JOj3lzxgFf3PGBYO1UrBAw+uL87S n+EGH0PH2DUoNUO+67gjQ/0NwqomKxN8HOuO5MJwFzirZMp+RWF6+tY0wbq19TFp250E ZyEA== X-Gm-Message-State: AOAM5312ligMfBWzGsHiVivwHra+op89f8UdGiit0VQDoLEQ6h1x3e0V GCcJLFUkuhvpMqjj/ffWWm1KR3vHHfX7Emvy X-Google-Smtp-Source: ABdhPJzLubp7xRyAB6cCE5ivUqJL3cYwgJiFKbIeO6p23No98wAlO81bTDL6geLVMJGc6AVrKy7n4w== X-Received: by 2002:aca:f3d6:: with SMTP id r205mr582019oih.48.1614865941038; Thu, 04 Mar 2021 05:52:21 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:20 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass , Alexandru Gagniuc Subject: [PATCH v4 40/42] spl: test: Add a test for spl_load_simple_fit() Date: Thu, 4 Mar 2021 06:51:16 -0700 Message-Id: <20210304135118.643277-39-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean As an example of an SPL test, add a new test for loading a FIT within SPL. This runs on sandbox_spl. For this to work, the text base is adjusted so that there is plenty of space available. While we are here, document struct spl_load_info properly, since this is currently ambiguous. This test only verifies the logic path. It does not actually check that the image is loaded correctly. It is not possible for sandbox's SPL to actually run u-boot.img since it currently includes u-boot.bin rather than u-boot. Further work could expand the test in that direction. The need for this was noted at: http://patchwork.ozlabs.org/project/uboot/patch/20201216000944.2832585-3-mr.nuke.me@gmail.com/ Signed-off-by: Simon Glass --- (no changes since v1) configs/sandbox_spl_defconfig | 2 +- doc/arch/sandbox.rst | 4 +- include/spl.h | 9 ++++ test/Makefile | 1 + test/image/Makefile | 5 ++ test/image/spl_load.c | 91 +++++++++++++++++++++++++++++++++++ 6 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 test/image/Makefile create mode 100644 test/image/spl_load.c diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig index c0118702a81..2696d0b6cdd 100644 --- a/configs/sandbox_spl_defconfig +++ b/configs/sandbox_spl_defconfig @@ -1,4 +1,4 @@ -CONFIG_SYS_TEXT_BASE=0 +CONFIG_SYS_TEXT_BASE=0x200000 CONFIG_SPL_LIBCOMMON_SUPPORT=y CONFIG_SPL_LIBGENERIC_SUPPORT=y CONFIG_NR_DRAM_BANKS=1 diff --git a/doc/arch/sandbox.rst b/doc/arch/sandbox.rst index 60ee1e0741a..1ccb5344ac6 100644 --- a/doc/arch/sandbox.rst +++ b/doc/arch/sandbox.rst @@ -537,5 +537,7 @@ Addr Config Usage e000 CONFIG_BLOBLIST_ADDR Blob list 10000 CONFIG_MALLOC_F_ADDR Early memory allocation f0000 CONFIG_PRE_CON_BUF_ADDR Pre-console buffer - 100000 CONFIG_TRACE_EARLY_ADDR Early trace buffer (if enabled) + 100000 CONFIG_TRACE_EARLY_ADDR Early trace buffer (if enabled). Also used + as the SPL load buffer in spl_test_load(). + 200000 CONFIG_SYS_TEXT_BASE Load buffer for U-Boot (sandbox_spl only) ======= ======================== =============================== diff --git a/include/spl.h b/include/spl.h index 0d134587de2..4f6e0e53f5d 100644 --- a/include/spl.h +++ b/include/spl.h @@ -222,6 +222,15 @@ struct spl_load_info { void *priv; int bl_len; const char *filename; + /** + * read() - Read from device + * + * @load: Information about the load state + * @sector: Sector number to read from (each @load->bl_len bytes) + * @count: Number of sectors to read + * @buf: Buffer to read into + * @return number of sectors read, 0 on error + */ ulong (*read)(struct spl_load_info *load, ulong sector, ulong count, void *buf); }; diff --git a/test/Makefile b/test/Makefile index 5cd284e322e..a26e915e050 100644 --- a/test/Makefile +++ b/test/Makefile @@ -3,6 +3,7 @@ # (C) Copyright 2012 The Chromium Authors obj-y += test-main.o +obj-$(CONFIG_SANDBOX) += image/ ifneq ($(CONFIG_$(SPL_)BLOBLIST),) obj-$(CONFIG_$(SPL_)CMDLINE) += bloblist.o diff --git a/test/image/Makefile b/test/image/Makefile new file mode 100644 index 00000000000..c4039df707f --- /dev/null +++ b/test/image/Makefile @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright 2021 Google LLC + +obj-$(CONFIG_SPL_BUILD) += spl_load.o diff --git a/test/image/spl_load.c b/test/image/spl_load.c new file mode 100644 index 00000000000..851603ddd75 --- /dev/null +++ b/test/image/spl_load.c @@ -0,0 +1,91 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2021 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include +#include +#include +#include + +/* Declare a new SPL test */ +#define SPL_TEST(_name, _flags) UNIT_TEST(_name, _flags, spl_test) + +/* Context used for this test */ +struct text_ctx { + int fd; +}; + +static ulong read_fit_image(struct spl_load_info *load, ulong sector, + ulong count, void *buf) +{ + struct text_ctx *text_ctx = load->priv; + off_t offset, ret; + ssize_t res; + + offset = sector * load->bl_len; + ret = os_lseek(text_ctx->fd, offset, OS_SEEK_SET); + if (ret != offset) { + printf("Failed to seek to %zx, got %zx (errno=%d)\n", offset, + ret, errno); + return 0; + } + + res = os_read(text_ctx->fd, buf, count * load->bl_len); + if (res == -1) { + printf("Failed to read %lx bytes, got %ld (errno=%d)\n", + count * load->bl_len, res, errno); + return 0; + } + + return count; +} + +int board_fit_config_name_match(const char *name) +{ + return 0; +} + +struct image_header *spl_get_load_buffer(ssize_t offset, size_t size) +{ + return map_sysmem(0x100000, 0); +} + +static int spl_test_load(struct unit_test_state *uts) +{ + struct spl_image_info image; + struct image_header *header; + struct text_ctx text_ctx; + struct spl_load_info load; + char fname[256]; + int ret; + int fd; + + memset(&load, '\0', sizeof(load)); + load.bl_len = 512; + load.read = read_fit_image; + + ret = os_find_u_boot(fname, sizeof(fname), true); + if (ret) { + printf("(%s not found, error %d)\n", fname, ret); + return ret; + } + load.filename = fname; + + header = spl_get_load_buffer(-sizeof(*header), sizeof(*header)); + + fd = os_open(fname, OS_O_RDONLY); + ut_assert(fd >= 0); + ut_asserteq(512, os_read(fd, header, 512)); + text_ctx.fd = fd; + + load.priv = &text_ctx; + + ut_assertok(spl_load_simple_fit(&image, &load, 0, header)); + + return 0; +} +SPL_TEST(spl_test_load, 0); From patchwork Thu Mar 4 13:51:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447358 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=fCVY9Zys; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4DrstZ18F7z9sRf for ; Fri, 5 Mar 2021 00:59:34 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4663B8292E; Thu, 4 Mar 2021 14:54:05 +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="fCVY9Zys"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4F6B88287F; Thu, 4 Mar 2021 14:52:46 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) (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 9A06C8282E for ; Thu, 4 Mar 2021 14:52:23 +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-ot1-x331.google.com with SMTP id r19so27308328otk.2 for ; Thu, 04 Mar 2021 05:52:23 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=4uQ8eXfW8WWgby0JzrJtcjVof3dtHyIPEAiOoeUhx+I=; b=fCVY9ZysLiYtZeq429WGj19PwNiTSjpoEXHSpfZUVlwU/7afN7CAFYNVVR2oFdhiCe 7qhQWpS01R3A/Qh2kTi/VDrNYHYnfK3udVil3belcNHOD/wgrtGNwuBNcOe+KA0PLqyF t45UUZlnqL4lFt8na6sFLQk9HuD7aoK3TLFm0= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=4uQ8eXfW8WWgby0JzrJtcjVof3dtHyIPEAiOoeUhx+I=; b=Z6bhzOui83oXtuTcQyhvTcjU4S1aMaNWPvX10bDjbBTyu3QnzGoeNxPcSH64VGf7jW lWEylIYJWDxB7upxgOjf01pkwIVyOS5N+mM8U7xHMq3uL0DdcnnVNPpgaNSWnibp/dqO x7a3RGGXzsEC4t2Mb/QrhTmGkPnzq2KT5o8HWza1jQIdqrAVqKO9GFcvm/Q7tYTtBw2H SYkXpudKVZmyVh6kg2N6lK2AK6+VMiY5OWnEKDeL0jItXwd3OyNKfWkJb/SJyc4cHxlQ 4HezlAQAfDnJLWi93fLX2sFXAJaOIgOfa+N68rMXJ8OPwX32gZE9a85qgOlUIxRnFfMd g7rA== X-Gm-Message-State: AOAM531pl7Er55UbhZabAEyWlrLZMCM1MSSxwnRys5uAMPs9ESg7bX7S uXUsDa32uqX+8PGd3xQrwpUP4KZABRvhdSwp X-Google-Smtp-Source: ABdhPJz1914msnwNfHa/ykuCu5INut652xEwgxtmdPg7k3p4ZMOGEe5sQDCoi4QzG6b3qwhfVI954Q== X-Received: by 2002:a9d:3bc4:: with SMTP id k62mr3444503otc.318.1614865941909; Thu, 04 Mar 2021 05:52:21 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:21 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 41/42] test: sandbox: Move sandbox test docs into doc/develop Date: Thu, 4 Mar 2021 06:51:17 -0700 Message-Id: <20210304135118.643277-40-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean At present some of the documentation about running sandbox tests is in the sandbox docs. It makes more sense to put it in with the other testing docs, with a link there from sandbox. Update the documentation accordingly. Also add a paragraph explaining why sandbox exists and the test philosophy that it uses. Signed-off-by: Simon Glass --- (no changes since v1) doc/arch/sandbox.rst | 44 +++++++---------------------------- doc/develop/tests_sandbox.rst | 44 +++++++++++++++++++++++++++++++++-- 2 files changed, 51 insertions(+), 37 deletions(-) diff --git a/doc/arch/sandbox.rst b/doc/arch/sandbox.rst index 1ccb5344ac6..1638b050002 100644 --- a/doc/arch/sandbox.rst +++ b/doc/arch/sandbox.rst @@ -17,6 +17,12 @@ of the sandbox U-Boot. The purpose of running U-Boot under Linux is to test all the generic code, not specific to any one architecture. The idea is to create unit tests which we can run to test this upper level code. +Sandbox allows development of many types of new features in a traditional way, +rather than needing to test each iteration on real hardware. Many U-Boot +features were developed on sandbox, including the core driver model, most +uclasses, verified boot, bloblist, logging and dozens of others. Sandbox has +enabled many large-scale code refactors as well. + CONFIG_SANDBOX is defined when building a native board. The board name is 'sandbox' but the vendor name is unset, so there is a @@ -486,42 +492,10 @@ Testing ------- U-Boot sandbox can be used to run various tests, mostly in the test/ -directory. These include: - -command_ut: - Unit tests for command parsing and handling -compression: - Unit tests for U-Boot's compression algorithms, useful for - security checking. It supports gzip, bzip2, lzma and lzo. -driver model: - Run this pytest:: - - ./test/py/test.py --bd sandbox --build -k ut_dm -v - -image: - Unit tests for images: - test/image/test-imagetools.sh - multi-file images - test/image/test-fit.py - FIT images -tracing: - test/trace/test-trace.sh tests the tracing system (see README.trace) -verified boot: - See test/vboot/vboot_test.sh for this - -If you change or enhance any of the above subsystems, you shold write or -expand a test and include it with your patch series submission. Test -coverage in U-Boot is limited, as we need to work to improve it. - -Note that many of these tests are implemented as commands which you can -run natively on your board if desired (and enabled). - -To run all tests use "make check". - -To run a single test in an existing sandbox build, you can use -T to use the -test device tree, and -c to select the test: - - /tmp/b/sandbox/u-boot -T -c "ut dm pci_busdev" +directory. -This runs dm_test_pci_busdev() which is in test/dm/pci.c +See :doc:`../develop/tests_sandbox` for more information and +:doc:`../develop/testing` for information about testing generally. Memory Map diff --git a/doc/develop/tests_sandbox.rst b/doc/develop/tests_sandbox.rst index daf87e53a99..8c2eac4c5f4 100644 --- a/doc/develop/tests_sandbox.rst +++ b/doc/develop/tests_sandbox.rst @@ -1,7 +1,47 @@ .. SPDX-License-Identifier: GPL-2.0+ -Tests Under the Hood -==================== +Sandbox tests +============= + +Test Design +----------- + +Most uclasses and many functions of U-Boot have sandbox tests. This allows much +of the code to be checked in an developer-friendly environment. + +Sandbox provides a way to write and run unit tests. The traditional approach to +unit tests is to build lots of little executables, one for each test or +category of tests. With sandbox, so far as possible, all the tests share a +small number of executables (e.g. 'u-boot' for sandbox, 'u-boot-spl' and +'u-boot' for sandbox_spl) and can be run very quickly. The vast majority of +tests can run on the 'sandbox' build, + +Available tests +--------------- + +Some of the available tests are: + + - command_ut: Unit tests for command parsing and handling + - compression: Unit tests for U-Boot's compression algorithms, useful for + security checking. It supports gzip, bzip2, lzma and lzo. + - image: Unit tests for images: + + - test/image/test-imagetools.sh - multi-file images + - test/py/tests/test-fit.py - FIT images + - tracing: test/trace/test-trace.sh tests the tracing system (see + README.trace) + - verified boot: test/py/tests/test_vboot.py + +If you change or enhance any U-Boot subsystem, you should write or expand a +test and include it with your patch series submission. Test coverage in some +older areas of U-Boot is still somewhat limited and we need to work to improve +it. + +Note that many of these tests are implemented as commands which you can +run natively on your board if desired (and enabled). + +To run all tests, use 'make check'. + Running sandbox tests directly ------------------------------ From patchwork Thu Mar 4 13:51:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447359 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=QmcbNlsi; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 ozlabs.org (Postfix) with ESMTPS id 4Drstm4ygDz9sRf for ; Fri, 5 Mar 2021 00:59:44 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3FE9A827E4; Thu, 4 Mar 2021 14:54:09 +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="QmcbNlsi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DB65882879; Thu, 4 Mar 2021 14:52:49 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) (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 BEA5A82835 for ; Thu, 4 Mar 2021 14:52:24 +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-oi1-x233.google.com with SMTP id o3so30133781oic.8 for ; Thu, 04 Mar 2021 05:52:24 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=CWGb99uRQzfvCdrEtzum5vYFGD3iBmRCr8GXnBI6CzU=; b=QmcbNlsib8HsF1dfpQm7a3DQBz8gLJrL6Vk0AbbWygIJq81/IwrSoNCpFTlviJTCrK RVkpnxxTgz3ahk/Db+EcvNOja0AvbOxWSG9Am8k7alBPL9cTVwzZNoGuiBz0kL9kkn6+ HzrqmG8nkVjlIZLg4Rjk4BtLnn1ibxJl+RoXU= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=CWGb99uRQzfvCdrEtzum5vYFGD3iBmRCr8GXnBI6CzU=; b=ojmiKr6phNiZi3zWE3xWUvD7ueprqhxq5vHKwGaWl4nRtlzs4u943MiCG5tuyuPXLG x/iCVVIPeNdjq8TKr7eV3khY0qct/J48apmE/W9iaoDm0c69sFvocXZlzRcU6puMulLb B9erWlH3TGI+ClHDoB2pacgxrqPA+XUdrfCRus26+fwpSMqCffLdcqxwWn4D5Ozo6vMU pm3l5fVfTzov8Y8ESB3uuoEz+gqjlKRfxZWdQAufR/YiHFLaqXjTaLowXjWkxdVQ9EaY ZM8GyGezPszgA0/4vg23elzTYYArP7RUiYiArpH3H/1a7Dvu61bqS8YvCCYqJ39yUWFW topQ== X-Gm-Message-State: AOAM530MZvMLqXIUrbLYf960NId/bk+4nb6Vfy6u+LhbJ60vkW+e/3rs 3Z0K2Mp7N8g6qbVECis1cSQjxvAauJWpm8F4 X-Google-Smtp-Source: ABdhPJyyMbvFzTL7E/cvGGAyKomCmtDGm5zO2kOpCliqlS5J9LA01kzzG5zPt68+dRdNs6iRf9IEgg== X-Received: by 2002:aca:35c2:: with SMTP id c185mr3060766oia.144.1614865942811; Thu, 04 Mar 2021 05:52:22 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:22 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 42/42] doc: Explain briefly how to write new tests Date: Thu, 4 Mar 2021 06:51:18 -0700 Message-Id: <20210304065106.v4.42.I75afce900b89102e704e83aa38967777cba25273@changeid> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean Add a second on writing tests, covering when to use Python and C, where to put the tests, etc. Add a link to the existing Python test documentation. Signed-off-by: Simon Glass --- Changes in v4: - Add correct SPDX header Changes in v2: - Add new patches to cover running an SPL test doc/develop/index.rst | 1 + doc/develop/py_testing.rst | 3 +- doc/develop/testing.rst | 2 + doc/develop/tests_sandbox.rst | 7 + doc/develop/tests_writing.rst | 339 ++++++++++++++++++++++++++++++++++ 5 files changed, 351 insertions(+), 1 deletion(-) create mode 100644 doc/develop/tests_writing.rst diff --git a/doc/develop/index.rst b/doc/develop/index.rst index 9208668a2d4..8f0a598b5f2 100644 --- a/doc/develop/index.rst +++ b/doc/develop/index.rst @@ -32,6 +32,7 @@ Testing testing py_testing + tests_writing tests_sandbox Refactoring diff --git a/doc/develop/py_testing.rst b/doc/develop/py_testing.rst index 7f01858cfda..c4cecc0a01b 100644 --- a/doc/develop/py_testing.rst +++ b/doc/develop/py_testing.rst @@ -13,7 +13,8 @@ results. Advantages of this approach are: U-Boot; there can be no disconnect. - There is no need to write or embed test-related code into U-Boot itself. It is asserted that writing test-related code in Python is simpler and more - flexible than writing it all in C. + flexible than writing it all in C. But see :doc:`tests_writing` for caveats + and more discussion / analysis. - It is reasonably simple to interact with U-Boot in this way. Requirements diff --git a/doc/develop/testing.rst b/doc/develop/testing.rst index b181c2e2e41..ced13ac8bb4 100644 --- a/doc/develop/testing.rst +++ b/doc/develop/testing.rst @@ -117,6 +117,8 @@ or is covered sparingly. So here are some suggestions: is much easier to add onto a test - writing a new large test can seem daunting to most contributors. +See doc:`tests_writing` for how to write tests. + Future work ----------- diff --git a/doc/develop/tests_sandbox.rst b/doc/develop/tests_sandbox.rst index 8c2eac4c5f4..7e5cc84e43c 100644 --- a/doc/develop/tests_sandbox.rst +++ b/doc/develop/tests_sandbox.rst @@ -199,3 +199,10 @@ linker_list:: 000000000001f240 D _u_boot_list_2_dm_test_2_dm_test_of_plat_parent 000000000001f260 D _u_boot_list_2_dm_test_2_dm_test_of_plat_phandle 000000000001f280 D _u_boot_list_2_dm_test_2_dm_test_of_plat_props + + +Writing tests +------------- + +See :doc:`tests_writing` for how to write new tests. + diff --git a/doc/develop/tests_writing.rst b/doc/develop/tests_writing.rst new file mode 100644 index 00000000000..d926c00f6e1 --- /dev/null +++ b/doc/develop/tests_writing.rst @@ -0,0 +1,339 @@ +.. SPDX-License-Identifier: GPL-2.0+ +.. Copyright 2021 Google LLC +.. sectionauthor:: Simon Glass + +Writing Tests +============= + +This describes how to write tests in U-Boot and describes the possible options. + +Test types +---------- + +There are two basic types of test in U-Boot: + + - Python tests, in test/py/tests + - C tests, in test/ and its subdirectories + +Python tests talk to U-Boot via the command line. They support both sandbox and +real hardware. They typically do not require building test code into U-Boot +itself. They are fairly slow to run, due to the command-line interface and there +being two separate processes. Python tests are fairly easy to write. They can +be a little tricky to debug sometimes due to the voluminous output of pytest. + +C tests are written directly in U-Boot. While they can be used on boards, they +are more commonly used with sandbox, as they obviously add to U-Boot code size. +C tests are easy to write so long as the required facilities exist. Where they +do not it can involve refactoring or adding new features to sandbox. They are +fast to run and easy to debug. + +Regardless of which test type is used, all tests are collected and run by the +pytest framework, so there is typically no need to run them separately. This +means that C tests can be used when it makes sense, and Python tests when it +doesn't. + + +This table shows how to decide whether to write a C or Python test: + +===================== =========================== ============================= +Attribute C test Python test +===================== =========================== ============================= +Fast to run? Yes No (two separate processes) +Easy to write? Yes, if required test Yes + features exist in sandbox +Needs code in U-Boot? Yes No, provided the test can be + executed and the result + determined using the command + line +Easy to debug? Yes Yes, but the amount of output can + sometimes require a bit of digging +Can use gdb? Yes, directly Yes, with --gdbserver +Can run on boards? Some can, but only if Yes + compiled in and not + dependent on sandboxau +===================== =========================== ============================= + + +Python or C +----------- + +Typically in U-Boot we encourage C test using sandbox for all features. This +allows fast testing, easy development and allows contributors to make changes +without needing dozens of boards to test with. + +When a test requires setup or interaction with the running host (such as to +generate images and then running U-Boot to check that they can be loaded), or +cannot be run on sandbox, Python tests should be used. These should typically +NOT rely on running with sandbox, but instead should function correctly on any +board supported by U-Boot. + + +How slow are Python tests? +-------------------------- + +Under the hood, Python tests work by starting a sandbox test and connecting to +it via a pipe. Each interaction with the U-Boot process requires at least a +context switch to handle the pipe interaction. The test sends a command to +U-Boot, which then reacts and shows some output, then the test sees that and +continues. Of course on real hardware, communications delays (e.g. with a serial +console) make this slower. + +For comparison, consider a test that checks the 'md' (memory dump). All times +below are approximate, as measured on an AMD 2950X system. Here is is the test +in Python:: + + @pytest.mark.buildconfigspec('cmd_memory') + def test_md(u_boot_console): + """Test that md reads memory as expected, and that memory can be modified + using the mw command.""" + + ram_base = u_boot_utils.find_ram_base(u_boot_console) + addr = '%08x' % ram_base + val = 'a5f09876' + expected_response = addr + ': ' + val + u_boot_console.run_command('mw ' + addr + ' 0 10') + response = u_boot_console.run_command('md ' + addr + ' 10') + assert(not (expected_response in response)) + u_boot_console.run_command('mw ' + addr + ' ' + val) + response = u_boot_console.run_command('md ' + addr + ' 10') + assert(expected_response in response) + +This runs a few commands and checks the output. Note that it runs a command, +waits for the response and then checks it agains what is expected. If run by +itself it takes around 800ms, including test collection. For 1000 runs it takes +19 seconds, or 19ms per run. Of course 1000 runs it not that useful since we +only want to run it once. + +There is no exactly equivalent C test, but here is a similar one that tests 'ms' +(memory search):: + + /* Test 'ms' command with bytes */ + static int mem_test_ms_b(struct unit_test_state *uts) + { + u8 *buf; + + buf = map_sysmem(0, BUF_SIZE + 1); + memset(buf, '\0', BUF_SIZE); + buf[0x0] = 0x12; + buf[0x31] = 0x12; + buf[0xff] = 0x12; + buf[0x100] = 0x12; + ut_assertok(console_record_reset_enable()); + run_command("ms.b 1 ff 12", 0); + ut_assert_nextline("00000030: 00 12 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................"); + ut_assert_nextline("--"); + ut_assert_nextline("000000f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 12 ................"); + ut_assert_nextline("2 matches"); + ut_assert_console_end(); + + ut_asserteq(2, env_get_hex("memmatches", 0)); + ut_asserteq(0xff, env_get_hex("memaddr", 0)); + ut_asserteq(0xfe, env_get_hex("mempos", 0)); + + unmap_sysmem(buf); + + return 0; + } + MEM_TEST(mem_test_ms_b, UT_TESTF_CONSOLE_REC); + +This runs the command directly in U-Boot, then checks the console output, also +directly in U-Boot. If run by itself this takes 100ms. For 1000 runs it takes +660ms, or 0.66ms per run. + +So overall running a C test is perhaps 8 times faster individually and the +interactions are perhaps 25 times faster. + +It should also be noted that the C test is fairly easy to debug. You can set a +breakpoint on do_mem_search(), which is what implements the 'ms' command, +single step to see what might be wrong, etc. That is also possible with the +pytest, but requires two terminals and --gdbserver. + + +Why does speed matter? +---------------------- + +Many development activities rely on running tests: + + - 'git bisect run make qcheck' can be used to find a failing commit + - test-driven development relies on quick iteration of build/test + - U-Boot's continuous integration (CI) systems make use of tests. Running + all sandbox tests typically takes 90 seconds and running each qemu test + takes about 30 seconds. This is currently dwarfed by the time taken to + build all boards + +As U-Boot continues to grow its feature set, fast and reliable tests are a +critical factor factor in developer productivity and happiness. + + +Writing C tests +--------------- + +C tests are arranged into suites which are typically executed by the 'ut' +command. Each suite is in its own file. This section describes how to accomplish +some common test tasks. + + +Add a new driver model test +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Use this when adding a test for a new or existing uclass, adding new operations +or features to a uclass, adding new ofnode or dev_read_() functions, or anything +else related to driver model. + +Find a suitable place for your test, perhaps near other test functions in +existing code, or in a new file. Each uclass should have its own test file. + +Declare the test with:: + + /* Test that ... */ + static int dm_test_uclassname_what(struct unit_test_state *uts) + { + /* test code here */ + + return 0; + } + DM_TEST(dm_test_uclassname_what, UT_TESTF_SCAN_FDT); + +Replace 'uclassname' with the name of your uclass, if applicable. Replace 'what' +with what you are testing. + +The flags for DM_TEST() are defined in test/test.h and you typically want +UT_TESTF_SCAN_FDT so that the devicetree is scanned and all devices are bound +and ready for use. The DM_TEST macro adds UT_TESTF_DM automatically so that +the test runner knows it is a driver model test. + +Driver model tests are special in that the entire driver model state is +recreated anew for each test. This ensures that if a previous test deletes a +device, for example, it does not affect subsequent tests. Driver model tests +also run both with livetree and flattree, to ensure that both devicetree +implementations work as expected. + +Example commit: c48cb7ebfb4 ("sandbox: add ADC unit tests") [1] + +[1] https://gitlab.denx.de/u-boot/u-boot/-/commit/c48cb7ebfb4 + + +Add a C test to an existing suite +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Use this when you are adding to or modifying an existing feature outside driver +model. An example is bloblist. + +Add a new function in the same file as the rest of the suite and register it +with the suite. For example, to add a new mem_search test:: + + /* Test 'ms' command with 32-bit values */ + static int mem_test_ms_new_thing(struct unit_test_state *uts) + { + /* test code here*/ + + return 0; + } + MEM_TEST(mem_test_ms_new_thing, UT_TESTF_CONSOLE_REC); + +Note that the MEM_TEST() macros is defined at the top of the file. + +Example commit: 9fe064646d2 ("bloblist: Support relocating to a larger space") [1] + +[1] https://gitlab.denx.de/u-boot/u-boot/-/commit/9fe064646d2 + + +Add a new test suite +~~~~~~~~~~~~~~~~~~~~ + +Each suite should focus on one feature or subsystem, so if you are writing a +new one of those, you should add a new suite. + +Create a new file in test/ or a subdirectory and define a macro to register the +suite. For example:: + + #include + #include + #include + #include + #include + + /* Declare a new wibble test */ + #define WIBBLE_TEST(_name, _flags) UNIT_TEST(_name, _flags, wibble_test) + + /* Tetss go here */ + + /* At the bottom of the file: */ + + int do_ut_wibble(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) + { + struct unit_test *tests = UNIT_TEST_SUITE_START(wibble_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(wibble_test); + + return cmd_ut_category("cmd_wibble", "wibble_test_", tests, n_ents, argc, argv); + } + +Then add new tests to it as above. + +Register this new suite in test/cmd_ut.c by adding to cmd_ut_sub[]:: + + /* Within cmd_ut_sub[]... */ + + U_BOOT_CMD_MKENT(wibble, CONFIG_SYS_MAXARGS, 1, do_ut_wibble, "", ""), + +and adding new help to ut_help_text[]:: + + "ut wibble - Test the wibble feature\n" + +If your feature is conditional on a particular Kconfig, then you can use #ifdef +to control that. + +Finally, add the test to the build by adding to the Makefile in the same +directory:: + + obj-$(CONFIG_$(SPL_)CMDLINE) += wibble.o + +Note that CMDLINE is never enabled in SPL, so this test will only be present in +U-Boot proper. See below for how to do SPL tests. + +As before, you can add an extra Kconfig check if needed:: + + ifneq ($(CONFIG_$(SPL_)WIBBLE),) + obj-$(CONFIG_$(SPL_)CMDLINE) += wibble.o + endif + + +Example commit: 919e7a8fb64 ("test: Add a simple test for bloblist") [1] + +[1] https://gitlab.denx.de/u-boot/u-boot/-/commit/919e7a8fb64 + + +Making the test run from pytest +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +All C tests must run from pytest. Typically this is automatic, since pytest +scans the U-Boot executable for available tests to run. So long as you have a +'ut' subcommand for your test suite, it will run. The same applies for driver +model tests since they use the 'ut dm' subcommand. + +See test/py/tests/test_ut.py for how unit tests are run. + + +Add a C test for SPL +~~~~~~~~~~~~~~~~~~~~ + +Note: C tests are only available for sandbox_spl at present. There is currently +no mechanism in other boards to existing SPL tests even if they are built into +the image. + +SPL tests cannot be run from the 'ut' command since there are no commands +available in SPL. Instead, sandbox (only) calls ut_run_list() on start-up, when +the -u flag is given. This runs the available unit tests, no matter what suite +they are in. + +To create a new SPL test, follow the same rules as above, either adding to an +existing suite or creating a new one. + +An example SPL test is spl_test_load(). + + +Writing Python tests +-------------------- + +See :doc:`py_testing` for brief notes how to write Python tests. You +should be able to use the existing tests in test/py/tests as examples.