From patchwork Sat Sep 11 17:20:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1526781 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=lQKmODp8; 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) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H6KJt01xJz9sVw for ; Sun, 12 Sep 2021 03:21:01 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2554483831; Sat, 11 Sep 2021 19:20:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="lQKmODp8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 82C878382A; Sat, 11 Sep 2021 19:20:26 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) (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 C421883831 for ; Sat, 11 Sep 2021 19:20:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qv1-xf29.google.com with SMTP id z12so3402699qvx.5 for ; Sat, 11 Sep 2021 10:20:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KgiWTQ7cbDPGQPLTV7oZFOErpRuJMXfweEwAZi7kcEA=; b=lQKmODp8TEEYY4gTZOqbbLOVh4miAyeSMw+IkU/EOBKnCQZu15UTAmD8txjDNeIm2J 0ruK8T0bM8j6DbRLt175ndkSDYkXZvnfrZ8LvpAE0Wv1ybsWJeMkluIwTNBKY/kVm0dP NgELctHot9OhsdcNi5bYk30KZ4nzBiGqIheP6wg+EuMipSUVGK2EzBhz/grHzmoM89KZ z0GWAzCAQpiOeLHxz7KFvddURcPjaIeCv8cpuY0B2FlxXLKyLc/Uvr7WHUkUPNgpy67b dPQQAZdjBoMyN02h6rJ24xp9zGbn00ykK/Wa3EQHZdug7J7Ft8+g1GCkyJarzgXVxZOn kGcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KgiWTQ7cbDPGQPLTV7oZFOErpRuJMXfweEwAZi7kcEA=; b=ZfdXNuKGVMNM2kHh5oaYAhJZmzaGBjLv9kf7Xk1vbgx8QfPd1Ak6qoq6fFDSYEWLAn LG13dHk5ecHl0BO6bxJyP8TYogmUJKI5VXYfHcf016VYLKZVmxZ/8mV/N0y4IUv7Tgch gAvSC4zP8zduFGM9ABNR53y1uN9ElwtsfzowUDHVgGsKbyXc7KxADdS+brP/oEqiHmMQ dSq2mW5hCSYxYu/PGCds4HCYgD7hmeFe7sSb+Ofgy7wcwV8i+eVXIIBGBSZnq1CjVvJ8 qV24p0pbLWDRXUvOHzaByQS8azrhhHTMZ5m+WIzYUbsgXwPPNoM70haURXt8O1xSgT9X gtmA== X-Gm-Message-State: AOAM533opoNLFfugrxeeG3RvgpMKYLW5hi6x/98S3JQd/zuI3SJWb+Oq PV66AaPBZiIfoSB5RHJbeo6NwYpIfRo= X-Google-Smtp-Source: ABdhPJyl3EkBzKsQ4Yfo13TBuFaZ68XnLu+MxlA2SBFHim0erDa/tZ1DNnt+iZUY9Q3u42Il50hmqA== X-Received: by 2002:a05:6214:3ea:: with SMTP id cf10mr3016749qvb.53.1631380815073; Sat, 11 Sep 2021 10:20:15 -0700 (PDT) Received: from godwin.fios-router.home (pool-108-45-127-224.washdc.fios.verizon.net. [108.45.127.224]) by smtp.gmail.com with ESMTPSA id d12sm1295669qtq.61.2021.09.11.10.20.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Sep 2021 10:20:14 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de, Leo Liang Cc: Bin Meng , Damien Le Moal , Lukasz Majewski , Sean Anderson , Simon Glass Subject: [PATCH v2 3/4] test: dm: k210: Reduce duplication in test cases Date: Sat, 11 Sep 2021 13:20:02 -0400 Message-Id: <20210911172003.899301-3-seanga2@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210911172003.899301-1-seanga2@gmail.com> References: <20210911172003.899301-1-seanga2@gmail.com> 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 Having to copy-paste the same 3 lines makes adding new test cases error-prone. Use a macro. Signed-off-by: Sean Anderson Reviewed-by: Simon Glass Reviewed-by: Leo Yu-Chi Liang --- (no changes since v1) test/dm/k210_pll.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/test/dm/k210_pll.c b/test/dm/k210_pll.c index 54764f269c..5574ac96fa 100644 --- a/test/dm/k210_pll.c +++ b/test/dm/k210_pll.c @@ -69,27 +69,21 @@ static int dm_test_k210_pll(struct unit_test_state *uts) &theirs)); ut_asserteq(-EINVAL, k210_pll_calc_config(1500000000, 20000000, &theirs)); + ut_asserteq(-EINVAL, k210_pll_calc_config(1750000000, 13300000, + &theirs)); /* Verify we get the same output with brute-force */ - ut_assertok(dm_test_k210_pll_calc_config(390000000, 26000000, &ours)); - ut_assertok(k210_pll_calc_config(390000000, 26000000, &theirs)); - ut_assertok(dm_test_k210_pll_compare(&ours, &theirs)); +#define compare(rate, rate_in) do { \ + ut_assertok(dm_test_k210_pll_calc_config(rate, rate_in, &ours)); \ + ut_assertok(k210_pll_calc_config(rate, rate_in, &theirs)); \ + ut_assertok(dm_test_k210_pll_compare(&ours, &theirs)); \ +} while (0) - ut_assertok(dm_test_k210_pll_calc_config(26000000, 390000000, &ours)); - ut_assertok(k210_pll_calc_config(26000000, 390000000, &theirs)); - ut_assertok(dm_test_k210_pll_compare(&ours, &theirs)); - - ut_assertok(dm_test_k210_pll_calc_config(400000000, 26000000, &ours)); - ut_assertok(k210_pll_calc_config(400000000, 26000000, &theirs)); - ut_assertok(dm_test_k210_pll_compare(&ours, &theirs)); - - ut_assertok(dm_test_k210_pll_calc_config(27000000, 26000000, &ours)); - ut_assertok(k210_pll_calc_config(27000000, 26000000, &theirs)); - ut_assertok(dm_test_k210_pll_compare(&ours, &theirs)); - - ut_assertok(dm_test_k210_pll_calc_config(26000000, 27000000, &ours)); - ut_assertok(k210_pll_calc_config(26000000, 27000000, &theirs)); - ut_assertok(dm_test_k210_pll_compare(&ours, &theirs)); + compare(390000000, 26000000); + compare(26000000, 390000000); + compare(400000000, 26000000); + compare(27000000, 26000000); + compare(26000000, 27000000); return 0; }