From patchwork Sun Jan 31 03:32:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1433794 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=dY4R/teo; 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 4DSxbM6Prmz9sCD for ; Sun, 31 Jan 2021 14:37:19 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0817C82694; Sun, 31 Jan 2021 04:34: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="dY4R/teo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6FFE8826CD; Sun, 31 Jan 2021 04:33: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.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-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) (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 53070826AD for ; Sun, 31 Jan 2021 04:33: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=sjg@chromium.org Received: by mail-il1-x12b.google.com with SMTP id y5so12371309ilg.4 for ; Sat, 30 Jan 2021 19:33:25 -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=czh4S7nf1ylOnI2smlYwGdgeATWvcEQA9fJyLRm4/q0=; b=dY4R/teorpOTZvzSL8VkJkFUQnZFo55c9jJ7Fumz072cHGebYZFWve2p0ZnntRyocB H3iOQDRakBPD8FziBPZiiIaVXJ6OoE5oUoVMVvs3MYfezZfiklgx12nxxmZiwCDHUI4t iC6ybI4qeWKdeEKMIoXLeIWevMe/s4boQL3OM= 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=czh4S7nf1ylOnI2smlYwGdgeATWvcEQA9fJyLRm4/q0=; b=O75+/K3qRu5mUop8Fo4Rm+0pE4wmGIoVAv3YMw2+P/S++YiYgojT4NvLXiOPPzysSp xPAG7ND6r48Xw4vUlhrO32FIpQqkV5HPv0hQ+KCK2PYzC6sFKVdrwQX025eNcP2kLSuc jUyVFa9DdsbK0vvhL8FQ7nUEAcG/NOLSLxam8vYKCEX4QPBlO4tYNAOMGu1PC2/3Ji5C oYXHduhlFqdPWiN8UCLaxUW86QyHeYdVuWz41ODQ7XXlmCv68BbGjAnBVzORr2lhsapA ttfWZs4OGqtNwJp6vYUV4mFzvnrFroJSB/ji6fzNh2lByKPFbpG+naY2Iu9QDPLl01rP shgQ== X-Gm-Message-State: AOAM533Bl5ZJy/it37gK3GZukJZC0Bi1NL4GIL7rGbf4pajC8MggAYM5 R3pJN6NU025vQQlWQWwOKwpRGdFytCkaqAGj X-Google-Smtp-Source: ABdhPJyoHvT8chiJNlHcZBN9ZeYvXQMV7YzsFhlgKTn2pviL12yJ0aAdZ6GLF6U12hS95g9xIJWW+w== X-Received: by 2002:a92:48c5:: with SMTP id j66mr7803403ilg.230.1612064003959; Sat, 30 Jan 2021 19:33:23 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Jan 2021 19:33:23 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Stephen Warren , Stephen Warren , Tom Rini , Simon Glass Subject: [PATCH v2 23/40] test: Use ut_run_test() to run driver model tests Date: Sat, 30 Jan 2021 20:32:31 -0700 Message-Id: <20210131033248.1502385-24-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 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 90da143bc51..38505c2e7a0 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -24,17 +24,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)