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;