From patchwork Sun Jan 31 03:32:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1433788 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=fUb9N/Ix; 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 4DSxZF4yftz9t0l for ; Sun, 31 Jan 2021 14:36:21 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6029882709; Sun, 31 Jan 2021 04:34: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="fUb9N/Ix"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5818482674; Sun, 31 Jan 2021 04:33:22 +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.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) (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 1509982545 for ; Sun, 31 Jan 2021 04:33:19 +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-il1-x134.google.com with SMTP id a1so12381308ilr.5 for ; Sat, 30 Jan 2021 19:33: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=akEJMf8W3dNrhvLmjtvvv+2uEfYYrpCsijlOcsC5W24=; b=fUb9N/IxBKzG20XpOi2L5QtN6VwoRekYYht9taHIfNFePtxPdTMlotBB5WVes39X/j EnA6Ehu/ojief+52aQbQBvFEIx9oJ0TM20+48JP2XME1PiHfFKt+NHi3CUCFnU1da9mQ XEkqpdsLw9KKQSFlpD0GYt1P9cEUKoVzS+gok= 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=akEJMf8W3dNrhvLmjtvvv+2uEfYYrpCsijlOcsC5W24=; b=GxTZCk2uHL+SwppPzybpZH4Uf2dfHoFwNXwMIbkfBVDqOe0RMV64RSu3ijmB6ClGtN sR2N342Wyxar8yeGnIDseWT19YINzT3Sg3EFens1Y52JKitREm9E3AzLmTRz+57UXc9u YfMyh0XsoUy7Q8B5ZKPlPccLMAgNrDR301ZzwcmM/Jj8Ix2S+QeVgv1EBCnGrQJKPxAC E3J7I2U8eHA7Nct8s8HD/62m0olwh6ZAGTZqCYByXFKxxCf6s8/t4LzAjsoHHQP59kPZ L2BOtaJUojL0ZvJPg0igXlioxBTTwo16735af30k80MNBcIStGaE6npqcOHqkVc0Hqvu pa2A== X-Gm-Message-State: AOAM531ccuVBnTmuC7wRRSzj4FkvKhlgGJkDHFZ9EoWgwSUNy7rafYLG Pe5elW+z3naJVpdY4SHqd2r2sIJTIMTo7noR X-Google-Smtp-Source: ABdhPJxLXmGHN15sPYv6/8ALMHwE8XmAhqMlV1/YcWZn89giKTy3tc76YnXYrJ/pQnIZwgo1jbc5vQ== X-Received: by 2002:a05:6e02:589:: with SMTP id c9mr8014561ils.70.1612063997698; Sat, 30 Jan 2021 19:33:17 -0800 (PST) Received: from localhost.localdomain (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id n193sm6086745iod.21.2021.01.30.19.33.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Jan 2021 19:33:17 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Stephen Warren , Stephen Warren , Tom Rini , Simon Glass Subject: [PATCH v2 17/40] test: Move delay skipping to test_pre_run() Date: Sat, 30 Jan 2021 20:32:25 -0700 Message-Id: <20210131033248.1502385-18-sjg@chromium.org> X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog In-Reply-To: <20210131033248.1502385-1-sjg@chromium.org> References: <20210131033248.1502385-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.3 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 3ffbc382358..398216b6c76 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -77,8 +77,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 44ed1ba2d31..e18d85e556c 100644 --- a/test/ut.c +++ b/test/ut.c @@ -132,3 +132,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 +}