Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4EE67EB64DC for ; Tue, 11 Jul 2023 22:52:11 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8750886924; Wed, 12 Jul 2023 00:52:09 +0200 (CEST) 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="OQy82NwW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 810F88691D; Wed, 12 Jul 2023 00:52:08 +0200 (CEST) Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) (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 3307286924 for ; Wed, 12 Jul 2023 00:52:04 +0200 (CEST) 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-io1-xd29.google.com with SMTP id ca18e2360f4ac-7835e5fa459so216112039f.2 for ; Tue, 11 Jul 2023 15:52:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689115922; x=1691707922; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=uACRvjAXie3G/Nab32YZ0iSGBnamZ/h9EVICwalFISs=; b=OQy82NwW2sZVh6aPLEAoSfP1Mvoh8v6ZusHkditf/dzBHYKfJAgaCgPjOce+a8rWyR qP0OoET2M7RqFfc5j5dOMtFw1vdbuz6t10wKdrDXVjtd9M12pRyPFI6ZnLwKtzQLo0oS I6gy27LVAf1JBjDGEmNXI9b8363WoTJlkmpZk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689115922; x=1691707922; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=uACRvjAXie3G/Nab32YZ0iSGBnamZ/h9EVICwalFISs=; b=C1C1custfu2ZvMPOCbj64qCaRXYnFrT6iTGLPzbDdDvJyGQUpi4F3F/snfy73BAOTp qsqqT16pS1nvBfMkAfb53Ddc7Iq/9tKSjdtbaWIKIN7NQElhPW7Pob8zv+U60EVTKRfM FYV/mpHOiXNX8SVhC29P/J7KZxbUJuKOM+50VztR7x5PAfE26EeSWKg6Kf4CT6K3oYlV sD2U0RY7eMtLKZJ3aX5rtHZc2F90MfRkRkL2o0dN2qOohKr/dcNXKaxHvTZjdvfmvczH kLqQg+kWXFYIEw0BeIhjUc1rqJyAqWeAYdg7+OoSJwUd4CwX/tfvQEX1h4f65ZWVG67M mirQ== X-Gm-Message-State: ABy/qLago5BYAO4GFpBKaIXH3O28/HkkYBms+SIDAhUIhpkVJ4XY6I1Y h+xFe2f+D3xY0a6S1Msw/0d7CnjHkaRYI5a1cxg= X-Google-Smtp-Source: APBJJlFZgM7FGS5SHIeaXgJPOwszuzpVuDMQlPUupk3DDo4R9kLVEIOUpDSYh2QHpZ6n7rVwnb5lgA== X-Received: by 2002:a5e:8d04:0:b0:787:8fc:75d8 with SMTP id m4-20020a5e8d04000000b0078708fc75d8mr7809766ioj.9.1689115922311; Tue, 11 Jul 2023 15:52:02 -0700 (PDT) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id k14-20020a6bef0e000000b007870c56387dsm878158ioh.49.2023.07.11.15.52.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jul 2023 15:52:02 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Marek Vasut , Simon Glass , Marek Vasut Subject: [PATCH] bdinfo: Correct use of assertions Date: Tue, 11 Jul 2023 16:51:56 -0600 Message-ID: <20230711225159.2328495-1-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.390.g38632f3daf-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean This test was written for the incorrect use of assertions. Update it to build with the previous approach, where tests fail at the first assertion. Signed-off-by: Simon Glass --- test/cmd/bdinfo.c | 79 +++++++++++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 30 deletions(-) diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c index 9068df79c4f2..cddf1a46d491 100644 --- a/test/cmd/bdinfo.c +++ b/test/cmd/bdinfo.c @@ -27,19 +27,25 @@ DECLARE_GLOBAL_DATA_PTR; /* Declare a new bdinfo test */ #define BDINFO_TEST(_name, _flags) UNIT_TEST(_name, _flags, bdinfo_test) -static void bdinfo_test_num_l(struct unit_test_state *uts, - const char *name, ulong value) +static int test_num_l(struct unit_test_state *uts, const char *name, + ulong value) { - ut_assert_nextline("%-12s= 0x%0*lx", name, 2 * (int)sizeof(value), value); + ut_assert_nextline("%-12s= 0x%0*lx", name, 2 * (int)sizeof(value), + value); + + return 0; } -static void bdinfo_test_num_ll(struct unit_test_state *uts, - const char *name, unsigned long long value) +static int test_num_ll(struct unit_test_state *uts, const char *name, + unsigned long long value) { - ut_assert_nextline("%-12s= 0x%.*llx", name, 2 * (int)sizeof(ulong), value); + ut_assert_nextline("%-12s= 0x%.*llx", name, 2 * (int)sizeof(ulong), + value); + + return 0; } -static void test_eth(struct unit_test_state *uts) +static int test_eth(struct unit_test_state *uts) { const int idx = eth_get_dev_index(); uchar enetaddr[6]; @@ -59,9 +65,11 @@ static void test_eth(struct unit_test_state *uts) else ut_assert_nextline("%-12s= %pM", name, enetaddr); ut_assert_nextline("IP addr = %s", env_get("ipaddr")); + + return 0; } -static void test_video_info(struct unit_test_state *uts) +static int test_video_info(struct unit_test_state *uts) { const struct udevice *dev; struct uclass *uc; @@ -73,22 +81,25 @@ static void test_video_info(struct unit_test_state *uts) struct video_priv *upriv = dev_get_uclass_priv(dev); struct video_uc_plat *plat = dev_get_uclass_plat(dev); - bdinfo_test_num_ll(uts, "FB base", (ulong)upriv->fb); + ut_assertok(test_num_ll(uts, "FB base", + (ulong)upriv->fb)); if (upriv->copy_fb) { - bdinfo_test_num_ll(uts, "FB copy", - (ulong)upriv->copy_fb); - bdinfo_test_num_l(uts, " copy size", - plat->copy_size); + ut_assertok(test_num_ll(uts, "FB copy", + (ulong)upriv->copy_fb)); + ut_assertok(test_num_l(uts, " copy size", + plat->copy_size)); } ut_assert_nextline("%-12s= %dx%dx%d", "FB size", upriv->xsize, upriv->ysize, 1 << upriv->bpix); } } + + return 0; } -static void lmb_test_dump_region(struct unit_test_state *uts, - struct lmb_region *rgn, char *name) +static int lmb_test_dump_region(struct unit_test_state *uts, + struct lmb_region *rgn, char *name) { unsigned long long base, size, end; enum lmb_flags flags; @@ -105,13 +116,17 @@ static void lmb_test_dump_region(struct unit_test_state *uts, ut_assert_nextline(" %s[%d]\t[0x%llx-0x%llx], 0x%08llx bytes flags: %x", name, i, base, end, size, flags); } + + return 0; } -static void lmb_test_dump_all(struct unit_test_state *uts, struct lmb *lmb) +static int lmb_test_dump_all(struct unit_test_state *uts, struct lmb *lmb) { ut_assert_nextline("lmb_dump_all:"); lmb_test_dump_region(uts, &lmb->memory, "memory"); lmb_test_dump_region(uts, &lmb->reserved, "reserved"); + + return 0; } static int bdinfo_test_move(struct unit_test_state *uts) @@ -123,44 +138,48 @@ static int bdinfo_test_move(struct unit_test_state *uts) ut_assertok(console_record_reset_enable()); ut_assertok(run_commandf("bdinfo")); - bdinfo_test_num_l(uts, "boot_params", 0); + ut_assertok(test_num_l(uts, "boot_params", 0)); for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) { if (bd->bi_dram[i].size) { - bdinfo_test_num_l(uts, "DRAM bank", i); - bdinfo_test_num_ll(uts, "-> start", bd->bi_dram[i].start); - bdinfo_test_num_ll(uts, "-> size", bd->bi_dram[i].size); + ut_assertok(test_num_l(uts, "DRAM bank", i)); + ut_assertok(test_num_ll(uts, "-> start", + bd->bi_dram[i].start)); + ut_assertok(test_num_ll(uts, "-> size", + bd->bi_dram[i].size)); } } /* CONFIG_SYS_HAS_SRAM testing not supported */ - bdinfo_test_num_l(uts, "flashstart", 0); - bdinfo_test_num_l(uts, "flashsize", 0); - bdinfo_test_num_l(uts, "flashoffset", 0); + ut_assertok(test_num_l(uts, "flashstart", 0)); + ut_assertok(test_num_l(uts, "flashsize", 0)); + ut_assertok(test_num_l(uts, "flashoffset", 0)); ut_assert_nextline("baudrate = %lu bps", env_get_ulong("baudrate", 10, 1234)); - bdinfo_test_num_l(uts, "relocaddr", gd->relocaddr); - bdinfo_test_num_l(uts, "reloc off", gd->reloc_off); + ut_assertok(test_num_l(uts, "relocaddr", gd->relocaddr)); + ut_assertok(test_num_l(uts, "reloc off", gd->reloc_off)); ut_assert_nextline("%-12s= %u-bit", "Build", (uint)sizeof(void *) * 8); if (IS_ENABLED(CONFIG_CMD_NET)) - test_eth(uts); + ut_assertok(test_eth(uts)); /* * Make sure environment variable "fdtcontroladdr" address * matches mapped control DT address. */ ut_assert(map_to_sysmem(gd->fdt_blob) == env_get_hex("fdtcontroladdr", 0x1234)); - bdinfo_test_num_l(uts, "fdt_blob", (ulong)map_to_sysmem(gd->fdt_blob)); - bdinfo_test_num_l(uts, "new_fdt", (ulong)map_to_sysmem(gd->new_fdt)); - bdinfo_test_num_l(uts, "fdt_size", (ulong)gd->fdt_size); + ut_assertok(test_num_l(uts, "fdt_blob", + (ulong)map_to_sysmem(gd->fdt_blob))); + ut_assertok(test_num_l(uts, "new_fdt", + (ulong)map_to_sysmem(gd->new_fdt))); + ut_assertok(test_num_l(uts, "fdt_size", (ulong)gd->fdt_size)); if (IS_ENABLED(CONFIG_VIDEO)) test_video_info(uts); /* The gd->multi_dtb_fit may not be available, hence, #if below. */ #if CONFIG_IS_ENABLED(MULTI_DTB_FIT) - bdinfo_test_num_l(uts, "multi_dtb_fit", (ulong)gd->multi_dtb_fit); + ut_assertok(test_num_l(uts, "multi_dtb_fit", (ulong)gd->multi_dtb_fit)); #endif if (IS_ENABLED(CONFIG_LMB) && gd->fdt_blob) { -- 2.41.0.390.g38632f3daf-goog