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;