From patchwork Wed Nov 3 23:23:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1550632 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=m4RkCDiD; dkim-atps=neutral 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hl2t54Ck1z9sRN for ; Thu, 4 Nov 2021 10:24:45 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8A4388366B; Thu, 4 Nov 2021 00:24:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="m4RkCDiD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1557C835B9; Thu, 4 Nov 2021 00:23:52 +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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D6B17835AF for ; Thu, 4 Nov 2021 00:23:42 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kabel@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id AA466608FB; Wed, 3 Nov 2021 23:23:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1635981822; bh=IDPnaHFKwAPaSQO0Szd0iUhy+bZspt/Bh+4v+3tucY8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m4RkCDiDnpb6/SGHIcXJXWHnjDcd/gkBjocNyb/UZLdMlXGVWCoWIPYS/AnuNTG5t WFqe32kyHuRqYz02a1+h7/ic0F62O34bZdtVbaTSjVa4VFLTVAfSpfzqedJpMbFyjW COXV1zTuou3lvBnu9hYRtpHdqeYatr3LDb2dJh33WjNvmUBnTad8Of80N1h3Lhabtw hGg9zBzrKddEzrBh27W29V3mImQ6cw5ViTyxo2O5yobL30japU2L82JW1GhOBO2yug RLCpFL5J0W8JEJ1F6UuFG5c2LiwbaFhwY2dvwbc6dLzavyMCnw+4ZDpEEfXsWz4xqG z+8erRlPbHYxw== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Simon Glass , =?utf-8?q?Pali_Roh=C3=A1r?= Cc: u-boot@lists.denx.de, =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH v2 05/12] test: Use ut_asserteq_str() instead of ut_assertok(strcmp()) Date: Thu, 4 Nov 2021 00:23:25 +0100 Message-Id: <20211103232332.2737-6-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211103232332.2737-1-kabel@kernel.org> References: <20211103232332.2737-1-kabel@kernel.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.103.2 at phobos.denx.de X-Virus-Status: Clean From: Marek BehĂșn Use the ut_asserteq_str() assertion instead of strcmp() function and ut_assertok()ing it's result. Signed-off-by: Marek BehĂșn Reviewed-by: Simon Glass --- test/dm/cpu.c | 4 ++-- test/dm/soc.c | 4 ++-- test/dm/sysinfo.c | 6 +++--- test/dm/usb.c | 2 +- test/dm/virtio.c | 2 +- test/print_ut.c | 32 ++++++++++++++++---------------- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/test/dm/cpu.c b/test/dm/cpu.c index d7e596ee39..0cda364131 100644 --- a/test/dm/cpu.c +++ b/test/dm/cpu.c @@ -32,7 +32,7 @@ static int dm_test_cpu(struct unit_test_state *uts) ut_asserteq(cpu_is_current(dev), 1); ut_assertok(cpu_get_desc(dev, text, sizeof(text))); - ut_assertok(strcmp(text, "LEG Inc. SuperMegaUltraTurbo CPU No. 1")); + ut_asserteq_str(text, "LEG Inc. SuperMegaUltraTurbo CPU No. 1"); ut_assertok(cpu_get_info(dev, &info)); ut_asserteq(info.cpu_freq, 42 * 42 * 42 * 42 * 42); @@ -42,7 +42,7 @@ static int dm_test_cpu(struct unit_test_state *uts) ut_asserteq(cpu_get_count(dev), 42); ut_assertok(cpu_get_vendor(dev, text, sizeof(text))); - ut_assertok(strcmp(text, "Languid Example Garbage Inc.")); + ut_asserteq_str(text, "Languid Example Garbage Inc."); return 0; } diff --git a/test/dm/soc.c b/test/dm/soc.c index 17e1b5ba01..6e14c98391 100644 --- a/test/dm/soc.c +++ b/test/dm/soc.c @@ -91,10 +91,10 @@ static int dm_test_soc(struct unit_test_state *uts) ut_assertok(soc_get(&dev)); ut_assertok(soc_get_machine(dev, text, sizeof(text))); - ut_assertok(strcmp(text, "SANDBOX123")); + ut_asserteq_str(text, "SANDBOX123"); ut_assertok(soc_get_family(dev, text, sizeof(text))); - ut_assertok(strcmp(text, "SANDBOX1xx")); + ut_asserteq_str(text, "SANDBOX1xx"); ut_assertok(soc_get_revision(dev, text, sizeof(text))); ut_asserteq_str(text, "1.0"); diff --git a/test/dm/sysinfo.c b/test/dm/sysinfo.c index 488412ab14..2c1bd1ce40 100644 --- a/test/dm/sysinfo.c +++ b/test/dm/sysinfo.c @@ -36,7 +36,7 @@ static int dm_test_sysinfo(struct unit_test_state *uts) ut_asserteq(6, sysinfo_get_str(sysinfo, STR_VACATIONSPOT, sizeof(str), str)); - ut_assertok(strcmp(str, "R'lyeh")); + ut_asserteq_str(str, "R'lyeh"); ut_assertok(sysinfo_get_int(sysinfo, INT_TEST1, &i)); ut_asserteq(0, i); @@ -46,7 +46,7 @@ static int dm_test_sysinfo(struct unit_test_state *uts) ut_asserteq(7, sysinfo_get_str(sysinfo, STR_VACATIONSPOT, sizeof(str), str)); - ut_assertok(strcmp(str, "Carcosa")); + ut_asserteq_str(str, "Carcosa"); ut_assertok(sysinfo_get_int(sysinfo, INT_TEST1, &i)); ut_asserteq(1, i); @@ -56,7 +56,7 @@ static int dm_test_sysinfo(struct unit_test_state *uts) ut_asserteq(7, sysinfo_get_str(sysinfo, STR_VACATIONSPOT, sizeof(str), str)); - ut_assertok(strcmp(str, "Yuggoth")); + ut_asserteq_str(str, "Yuggoth"); return 0; } diff --git a/test/dm/usb.c b/test/dm/usb.c index 5d6ceefce0..055134a485 100644 --- a/test/dm/usb.c +++ b/test/dm/usb.c @@ -56,7 +56,7 @@ static int dm_test_usb_flash(struct unit_test_state *uts) ut_asserteq(512, dev_desc->blksz); memset(cmp, '\0', sizeof(cmp)); ut_asserteq(2, blk_dread(dev_desc, 0, 2, cmp)); - ut_assertok(strcmp(cmp, "this is a test")); + ut_asserteq_str(cmp, "this is a test"); ut_assertok(usb_stop()); return 0; diff --git a/test/dm/virtio.c b/test/dm/virtio.c index 9a7e658cce..7154449f60 100644 --- a/test/dm/virtio.c +++ b/test/dm/virtio.c @@ -28,7 +28,7 @@ static int dm_test_virtio_base(struct unit_test_state *uts) /* check the child virtio-blk device is bound */ ut_assertok(device_find_first_child(bus, &dev)); ut_assertnonnull(dev); - ut_assertok(strcmp(dev->name, "virtio-blk#0")); + ut_asserteq_str(dev->name, "virtio-blk#0"); /* check driver status */ ut_assertok(virtio_get_status(dev, &status)); diff --git a/test/print_ut.c b/test/print_ut.c index 11d8580e55..70670a3a14 100644 --- a/test/print_ut.c +++ b/test/print_ut.c @@ -32,13 +32,13 @@ static int print_guid(struct unit_test_state *uts) char str[40]; sprintf(str, "%pUb", guid); - ut_assertok(strcmp("01020304-0506-0708-090a-0b0c0d0e0f10", str)); + ut_asserteq_str("01020304-0506-0708-090a-0b0c0d0e0f10", str); sprintf(str, "%pUB", guid); - ut_assertok(strcmp("01020304-0506-0708-090A-0B0C0D0E0F10", str)); + ut_asserteq_str("01020304-0506-0708-090A-0B0C0D0E0F10", str); sprintf(str, "%pUl", guid); - ut_assertok(strcmp("04030201-0605-0807-090a-0b0c0d0e0f10", str)); + ut_asserteq_str("04030201-0605-0807-090a-0b0c0d0e0f10", str); sprintf(str, "%pUL", guid); - ut_assertok(strcmp("04030201-0605-0807-090A-0B0C0D0E0F10", str)); + ut_asserteq_str("04030201-0605-0807-090A-0B0C0D0E0F10", str); return 0; } @@ -70,11 +70,11 @@ static int print_efi_ut(struct unit_test_state *uts) dp_end->length = sizeof(struct efi_device_path); snprintf(str, sizeof(str), "_%pD_", buf); - ut_assertok(strcmp("_/SD(3)_", str)); + ut_asserteq_str("_/SD(3)_", str); /* NULL device path */ snprintf(str, sizeof(str), "_%pD_", NULL); - ut_assertok(strcmp("__", str)); + ut_asserteq_str("__", str); return 0; } @@ -89,41 +89,41 @@ static int print_printf(struct unit_test_state *uts) int len; snprintf(str, sizeof(str), "testing"); - ut_assertok(strcmp("testing", str)); + ut_asserteq_str("testing", str); snprintf(str, sizeof(str), "testing but too long"); - ut_assertok(strcmp("testing b", str)); + ut_asserteq_str("testing b", str); snprintf(str, 1, "testing none"); - ut_assertok(strcmp("", str)); + ut_asserteq_str("", str); *str = 'x'; snprintf(str, 0, "testing none"); ut_asserteq('x', *str); sprintf(big_str, "_%ls_", L"foo"); - ut_assertok(strcmp("_foo_", big_str)); + ut_asserteq_str("_foo_", big_str); /* Test the banner function */ s = display_options_get_banner(true, str, sizeof(str)); ut_asserteq_ptr(str, s); - ut_assertok(strcmp("\n\nU-Boo\n\n", s)); + ut_asserteq_str("\n\nU-Boo\n\n", s); /* Assert that we do not overwrite memory before the buffer */ str[0] = '`'; s = display_options_get_banner(true, str + 1, 1); ut_asserteq_ptr(str + 1, s); - ut_assertok(strcmp("`", str)); + ut_asserteq_str("`", str); str[0] = '~'; s = display_options_get_banner(true, str + 1, 2); ut_asserteq_ptr(str + 1, s); - ut_assertok(strcmp("~\n", str)); + ut_asserteq_str("~\n", str); /* The last two characters are set to \n\n for all buffer sizes > 2 */ s = display_options_get_banner(false, str, sizeof(str)); ut_asserteq_ptr(str, s); - ut_assertok(strcmp("U-Boot \n\n", s)); + ut_asserteq_str("U-Boot \n\n", s); /* Give it enough space for some of the version */ big_str_len = strlen(version_string) - 5; @@ -131,7 +131,7 @@ static int print_printf(struct unit_test_state *uts) big_str_len); ut_asserteq_ptr(big_str, s); ut_assertok(strncmp(version_string, s, big_str_len - 3)); - ut_assertok(strcmp("\n\n", s + big_str_len - 3)); + ut_asserteq_str("\n\n", s + big_str_len - 3); /* Give it enough space for the version and some of the build tag */ big_str_len = strlen(version_string) + 9 + 20; @@ -142,7 +142,7 @@ static int print_printf(struct unit_test_state *uts) ut_assertok(strncmp(version_string, s, len)); ut_assertok(strncmp(", Build: ", s + len, 9)); ut_assertok(strncmp(FAKE_BUILD_TAG, s + 9 + len, 12)); - ut_assertok(strcmp("\n\n", s + big_str_len - 3)); + ut_asserteq_str("\n\n", s + big_str_len - 3); return 0; }