From patchwork Wed Feb 2 01:08:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 539311 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1192237imr; Tue, 1 Feb 2022 17:12:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+3pr7sbusg2dZSWKw5zXdna8x7Ey7rnkyhRKgm1bbWHe+6gHl9Aue8U1bRYFQl8OOX6vP X-Received: by 2002:a17:906:9742:: with SMTP id o2mr14520991ejy.126.1643764338539; Tue, 01 Feb 2022 17:12:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643764338; cv=none; d=google.com; s=arc-20160816; b=ecHeE9ymXBDC8CrObWD2/pDWnRZF/0QETNCnbKVNqrjDI3Un8sxdjYm8t0RHy1RzGX yiGDqmS36lI/Z64MywPYckQDyG/LU+ywi69ijLIEvk18++60WciIPkd1arj7p19+QxiN XY3+oFgaUxzl3QcNU2agbdyMywv7DQWLwRwfSnBNSkfjYZX14J0wRNdXusSH2u+Xdnos JbrKcjYRCak8LrYy08m+1R+IBcitE0bkN09xlzgwVVny8HF4SZd2RxQKg1+iKuOWxuoN Hu33onBnwrC2l34C4b3Z8/mRpKLeD/gZssAWlgKnCz1gfjRqhLVNitzh8vyZEr2PkGYx hzxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=j3rJkD9O8Gq+NKRNVXk0fZH0z+fLRoy2YIwtxpZ2jIo=; b=dXhYJBHt8ugCpLcsEW6IgGYNJ2Nt8AQoa3zLXsx2W+5kpxVaLA2Z1jcTWszWCGwRF2 CIuwPfNk631V6Gn+rQ9MC4yksHk34ZWf6tZmP0kU/yaa4YvAUYaDGnkyXekAOx7mdi11 9ZFBDQLdF8XUDHHBa2xsaib3wZVXDxDnjrGI1KJ86p/l2sDherGMx1kwSiFXhI/1Yxcm sJ+nLocrxR36JzQX8ZipUSwn+XtngK81w9Qj1F5XXvHU8Ou2UbI0vr9RytgzuMdU8sKf kSctjz6n4cVe8VAEnriT6+GGQs5piFU1VQhtEOHSCc/L4IXVue9BZdwGjOMUHUOA5Ely U/Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zI6CMT1w; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id j5si9470502ejo.379.2022.02.01.17.12.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:12:18 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zI6CMT1w; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 19F2F838F9; Wed, 2 Feb 2022 02:10:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.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=linaro.org header.i=@linaro.org header.b="zI6CMT1w"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7634B838B6; Wed, 2 Feb 2022 02:10:16 +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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) (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 39CD1838D6 for ; Wed, 2 Feb 2022 02:10:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x1034.google.com with SMTP id v15-20020a17090a4ecf00b001b82db48754so206686pjl.2 for ; Tue, 01 Feb 2022 17:10:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j3rJkD9O8Gq+NKRNVXk0fZH0z+fLRoy2YIwtxpZ2jIo=; b=zI6CMT1wkn8vFRWxTobgxcuKdLdbKPkcblYYzFVfqv2pDHEUDVqRsEDC17OcXCtb/V wgp1VNbTbia1FseDon92YOPz57FGnSxXD7E/20eE9q8AePS+gcV4CsG6tg9jV/x6zxdk wHvtYEGVwBkDA+zrFOiUI98WmyKMNMjwMdaRVKVliNQFzUrOfYNaCCvPjNV15usijNqu AQjr3kzidjren0C0seOMIetaqH80jVWca/qxF2FAe3eenaKO7BxCOw7bH3l6y3NcFUHS gX8OojEA+NhuIvmISFJe7trlwYADRzUqLOJHmBKXM4nWrCFpHk28ZnSIr71GRUi5nXwu jxJg== 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=j3rJkD9O8Gq+NKRNVXk0fZH0z+fLRoy2YIwtxpZ2jIo=; b=ih9yb5Qiqk6XqbUXHpspB2ON7sKBBmOGG6RXZgHRA8C6v9ji/sAx/cxuiQ2F3KWvS4 3f3WJhJ8fRWKOsotr+9Rbv91qS9yej04RkTfg+9YA6IMnsBhjRRPkT1L3rZAeYRazz3M 9urvX6SqRfmoG9scWJwSKXnXEflQTLmUEyIxY4IOvrUPBjCgAu4x5FVjRyo9h+JHYZFy nv97OPmTK1yopsRLI3gFVEIc8uSLcrVE9Y76UMhOe9dhz0lXBA71yxoBqlAkH6pWBVDZ EYsCdaCoWUhmlfI9WmcOgtnxIHkcqpKxGPUQHBumcHh2w0VRmfwiAw4W6ty73jMM4n/R JG3A== X-Gm-Message-State: AOAM530R74/YgHplhBAUpvrUM958d44xDNnkYEYV37S181u1EO7uXU1s dgS+aVo7nZYhnIw3TLj23G63yA== X-Received: by 2002:a17:903:32cb:: with SMTP id i11mr28441677plr.37.1643764207159; Tue, 01 Feb 2022 17:10:07 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:314e:b83b:fa90:7f2e]) by smtp.gmail.com with ESMTPSA id f5sm10761429pfc.0.2022.02.01.17.10.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:10:06 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 11/19] test: dm: add tests for tag support Date: Wed, 2 Feb 2022 10:08:45 +0900 Message-Id: <20220202010853.40405-12-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220202010853.40405-1-takahiro.akashi@linaro.org> References: <20220202010853.40405-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 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.5 at phobos.denx.de X-Virus-Status: Clean The new test covers all tag-related interfaces. Signed-off-by: AKASHI Takahiro --- test/dm/Makefile | 1 + test/dm/tag.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 test/dm/tag.c diff --git a/test/dm/Makefile b/test/dm/Makefile index d46552fbf320..dc3177dbb7f4 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -102,6 +102,7 @@ obj-y += syscon.o obj-$(CONFIG_RESET_SYSCON) += syscon-reset.o obj-$(CONFIG_SYSINFO) += sysinfo.o obj-$(CONFIG_SYSINFO_GPIO) += sysinfo-gpio.o +obj-$(CONFIG_UT_DM) += tag.o obj-$(CONFIG_TEE) += tee.o obj-$(CONFIG_TIMER) += timer.o obj-$(CONFIG_DM_USB) += usb.o diff --git a/test/dm/tag.c b/test/dm/tag.c new file mode 100644 index 000000000000..8599fdc242d8 --- /dev/null +++ b/test/dm/tag.c @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * DM tag test + * + * Copyright (c) 2021 Linaro Limited + * Author: AKASHI Takahiro + */ + +#include +#include +#include /* DM_TEST() */ +#include /* struct unit_test_state */ +#include /* assertions */ + +/* + * Test dm_tag_ptr() API + */ +static int dm_test_tag_ptr(struct unit_test_state *uts) +{ + ulong val; + void *ptr = NULL; + + ut_assertok(dev_tag_set_ptr(uts->root, DM_TAG_EFI, &val)); + + ut_assertok(dev_tag_get_ptr(uts->root, DM_TAG_EFI, &ptr)); + + ut_asserteq_ptr(&val, ptr); + + ut_assertok(dev_tag_del(uts->root, DM_TAG_EFI)); + + return 0; +} +DM_TEST(dm_test_tag_ptr, 0); + +/* + * Test dm_tag_val() API + */ +static int dm_test_tag_val(struct unit_test_state *uts) +{ + ulong val1 = 0x12345678, val2 = 0; + + ut_assertok(dev_tag_set_val(uts->root, DM_TAG_EFI, val1)); + + ut_assertok(dev_tag_get_val(uts->root, DM_TAG_EFI, &val2)); + + ut_asserteq_64(val1, val2); + + ut_assertok(dev_tag_del(uts->root, DM_TAG_EFI)); + + return 0; +} +DM_TEST(dm_test_tag_val, 0); + +/* + * Test against an invalid tag + */ +static int dm_test_tag_inval(struct unit_test_state *uts) +{ + ulong val; + + ut_asserteq(-EINVAL, dev_tag_set_ptr(uts->root, DM_TAG_COUNT, &val)); + + return 0; +} +DM_TEST(dm_test_tag_inval, 0); + +/* + * Test dm_tag_del_all() AP: + */ +static int dm_test_tag_del_all(struct unit_test_state *uts) +{ + ulong val; + + ut_assertok(dev_tag_set_ptr(uts->root, DM_TAG_EFI, &val)); + + ut_assertok(dev_tag_del_all(uts->root)); + + return 0; +} +DM_TEST(dm_test_tag_del_all, 0);