From patchwork Mon Nov 9 04:08:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1396498 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; dmarc=pass (p=none dis=none) header.from=chromium.org 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=Ba5BMRLi; 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) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CTyDX22Llz9sRK for ; Mon, 9 Nov 2020 15:09:16 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 031FB8249D; Mon, 9 Nov 2020 05:09:06 +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="Ba5BMRLi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7BCF2823DE; Mon, 9 Nov 2020 05:08:58 +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, T_FILL_THIS_FORM_SHORT,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) (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 75A43823DE for ; Mon, 9 Nov 2020 05:08:55 +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-io1-xd41.google.com with SMTP id k21so8430612ioa.9 for ; Sun, 08 Nov 2020 20:08:55 -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:mime-version :content-transfer-encoding; bh=JGKnV8hUSdG2ctzP/NKbdBKFFqVMJPQmRtG9ikWCzbo=; b=Ba5BMRLiyVJ4j3qDofeYPdMyP/G6l/oOJ1WRC6Zn4DV7Un0+jeTbJCBaeE7r+eHny+ 0k9IyCBguowSh4XtyKkTVZZkMCdOg36ukBK0TPrnLR/4tqcXHmdHXt9qi9T5iRaQfj7L wTWcvmcdtp3ujNq0x9S7ZhRCpyc9N+r60rT/4= 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:mime-version :content-transfer-encoding; bh=JGKnV8hUSdG2ctzP/NKbdBKFFqVMJPQmRtG9ikWCzbo=; b=C9ujLcXgCjKy3U4QyAliNnXGbDgXO835Mimhc95KVqUu7+R7W9YJTGaENz1wuyqHVa gUoBCNKHEP0Nys/Iy2hMaoES/uCsvnY/Pw0d8dIhxD2M1TbvRQJu+BkCKRq/4f0xskQy KNHvYJc/B2Vw09ZoPgo92Cgi9ZraOiL85Ha+zhykbLx8S4xkT/605j0cMcb8tCLOHIfD n13gnQzYFMPxKPAoah8qGEJ8JQn1lQLAydQJcbhHAQ9+N/DiQd7jKdquzZ421Ig2Amtm qCe7na3E7SbnBV5EkQROk7Pg8lTUdOXLSYZCygNMXgS0W8mw3A4nFiK/v8NQs1V331lz ev3w== X-Gm-Message-State: AOAM532rsliV8clNNiG2EQ1nQemCERqjWlCas7UjrYBK9TuXg/cOOWd+ S6ZPiC6uw3yhlP6183k+244PymhI9Mhqkw== X-Google-Smtp-Source: ABdhPJx6K6KSRK/DI5TkdjnmgrxnTMK4RdbpkB4skXqyp1iseXN7bzhbzRO8AXZCcUgA5o2KPJ0pZA== X-Received: by 2002:a02:9716:: with SMTP id x22mr9216372jai.114.1604894930554; Sun, 08 Nov 2020 20:08:50 -0800 (PST) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id w12sm5102075iou.42.2020.11.08.20.08.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Nov 2020 20:08:49 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Kever Yang , Bin Meng , Dario Binacchi , Philippe Reynes , Wolfgang Wallner Subject: [PATCH 1/2] test: Avoid assuming sandbox board for bloblist test Date: Sun, 8 Nov 2020 21:08:43 -0700 Message-Id: <20201108210834.1.I08cec35c8482583834811d48894f358277c662aa@changeid> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8-goog 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 tests assumes it is running on sandbox. Add a few functions to handle silencing the console on any board and use those instead. Reported-by: Kever Yang Signed-off-by: Simon Glass --- include/test/ut.h | 18 ++++++++++++++++++ test/bloblist.c | 13 ++++--------- test/ut.c | 18 ++++++++++++++++++ 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/include/test/ut.h b/include/test/ut.h index 3f2ee7514b8..17400c73ea9 100644 --- a/include/test/ut.h +++ b/include/test/ut.h @@ -338,4 +338,22 @@ ulong ut_check_free(void); */ long ut_check_delta(ulong last); +/** + * ut_silence_console() - Silence the console if requested by the user + * + * This stops test output from appear on the console. It is the default on + * sandbox, unless the -v flag is given. For other boards, this does nothing. + * + * @uts: Test state (in case in future we want to keep state here) + */ +void ut_silence_console(struct unit_test_state *uts); + +/** + * ut_unsilence_console() - Unsilence the console after a test + * + * This restarts console output again and turns off console recording. This + * happens on all boards, including sandbox. + */ +void ut_unsilence_console(struct unit_test_state *uts); + #endif diff --git a/test/bloblist.c b/test/bloblist.c index 0bb9e2d81e7..900299dd68e 100644 --- a/test/bloblist.c +++ b/test/bloblist.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -240,7 +239,6 @@ BLOBLIST_TEST(bloblist_test_checksum, 0); /* Test the 'bloblist info' command */ static int bloblist_test_cmd_info(struct unit_test_state *uts) { - struct sandbox_state *state = state_get_current(); struct bloblist_hdr *hdr; char *data, *data2; @@ -250,8 +248,7 @@ static int bloblist_test_cmd_info(struct unit_test_state *uts) data2 = bloblist_ensure(TEST_TAG2, TEST_SIZE2); console_record_reset_enable(); - if (!state->show_test_output) - gd->flags |= GD_FLG_SILENT; + ut_silence_console(uts); console_record_reset(); run_command("bloblist info", 0); ut_assert_nextline("base: %lx", (ulong)map_to_sysmem(hdr)); @@ -259,7 +256,7 @@ static int bloblist_test_cmd_info(struct unit_test_state *uts) ut_assert_nextline("alloced: 70 112 Bytes"); ut_assert_nextline("free: 390 912 Bytes"); ut_assert_console_end(); - gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD); + ut_unsilence_console(uts); return 0; } @@ -268,7 +265,6 @@ BLOBLIST_TEST(bloblist_test_cmd_info, 0); /* Test the 'bloblist list' command */ static int bloblist_test_cmd_list(struct unit_test_state *uts) { - struct sandbox_state *state = state_get_current(); struct bloblist_hdr *hdr; char *data, *data2; @@ -278,8 +274,7 @@ static int bloblist_test_cmd_list(struct unit_test_state *uts) data2 = bloblist_ensure(TEST_TAG2, TEST_SIZE2); console_record_reset_enable(); - if (!state->show_test_output) - gd->flags |= GD_FLG_SILENT; + ut_silence_console(uts); console_record_reset(); run_command("bloblist list", 0); ut_assert_nextline("Address Size Tag Name"); @@ -288,7 +283,7 @@ static int bloblist_test_cmd_list(struct unit_test_state *uts) ut_assert_nextline("%08lx %8x 2 SPL hand-off", (ulong)map_to_sysmem(data2), TEST_SIZE2); ut_assert_console_end(); - gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD); + ut_unsilence_console(uts); return 0; } diff --git a/test/ut.c b/test/ut.c index 95bdd66de6a..44ed1ba2d31 100644 --- a/test/ut.c +++ b/test/ut.c @@ -8,6 +8,9 @@ #include #include #include +#ifdef CONFIG_SANDBOX +#include +#endif #include #include @@ -114,3 +117,18 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes) return upto == total_bytes ? 0 : 1; } + +void ut_silence_console(struct unit_test_state *uts) +{ +#ifdef CONFIG_SANDBOX + struct sandbox_state *state = state_get_current(); + + if (!state->show_test_output) + gd->flags |= GD_FLG_SILENT; +#endif +} + +void ut_unsilence_console(struct unit_test_state *uts) +{ + gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD); +}