From patchwork Tue Mar 8 11:36:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 549278 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp2539934mag; Tue, 8 Mar 2022 03:40:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJzVz8Qvvw8CSu0W2m5mXTOfLuHuZ+gJfE+xccyut+PdrNldpTkgmu8gcrVGnZAEgjYRQeCp X-Received: by 2002:a17:906:7316:b0:6d7:16be:b584 with SMTP id di22-20020a170906731600b006d716beb584mr12941359ejc.759.1646739605642; Tue, 08 Mar 2022 03:40:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646739605; cv=none; d=google.com; s=arc-20160816; b=GPHY6nqxgL+OZxdAS0wsQv8QguCqRKDMRMDXVkwtedzvLzAYifb82Fym5zu2FBHGbw JzpVCtxJZxWG97zWI8RaGGhJ2BgfEJ8GZqsw9N+Znt1CJb6PDk/CpiT94WAdcBQeyxhI n5bSZecXUcWO5qjYCxMSk5BNxq5UgKMuEydmNdjJIYZ5nEtSk22twOhSAb/9zJU0uJLG RW/jx1cZ5zuKj9kD1FzCtsnaNb8NYhwicAidSiLTspDNFQLsl2fYd6kR+2B+mwLKK7nx hJUlJetKdfV4WhC3wzVsDSzCeFifLlyZ/aL8Uo/S5JUw3ys1mkZBP+Yhk7cnIrbIDwFG Kmkw== 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=3zhbFhwoFiwMQkaYNb5BSiBvrj1lKF9eqN1bn4CV1xU=; b=GZjqDyZvaxiA0Kyo7iR8+lbAHqAPYGKKGl4RnB7RvSFkvtQqmuE3p1wbsgiwcdpfKA Pc9JqYg5SyFq/3i+MNa3X7klM2QGdF+nxGOrYVWYOBwKs3pFpYo8QM11UXcF363Spkd0 YjsOm8V79NSiGen37lbeGEDstOLu68I1ZYz6eJuiyCuj6l44q8KkTbnYni61sY4N4c/M 10v0kMjmmFAFoYEPjoqxHC5TcOa6N/N+7W4SM+i/NLuWJUqE99wGfN3JqC0IXO1f0Pph G8v3EeMYMKe0BfEbZUVW0TdI+rQEL3e0wDcPhs+Oouxk7CgN6F6BkoxwIn/FLKwOGI85 REmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=k1vPtueI; 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 w25-20020aa7da59000000b004163298f2c7si4796961eds.357.2022.03.08.03.40.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 03:40:05 -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=k1vPtueI; 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 7B5968398B; Tue, 8 Mar 2022 12:39:53 +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="k1vPtueI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 19F5083934; Tue, 8 Mar 2022 12:39:37 +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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) (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 4EF4183984 for ; Tue, 8 Mar 2022 12:38:19 +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=takahiro.akashi@linaro.org Received: by mail-pg1-x536.google.com with SMTP id o8so16210733pgf.9 for ; Tue, 08 Mar 2022 03:38:19 -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=3zhbFhwoFiwMQkaYNb5BSiBvrj1lKF9eqN1bn4CV1xU=; b=k1vPtueIki+IdkfqqxqDXinzJcDGp+JUJLl9HPAggYubNLzbH/vhGBUGP3XBfBhc4I KQo5iaGZlhWcYHGlNyrZmvzcDBeO8fQYFAmriwVlFUW0Vou8b0jHiNgOvFsoYEDSy+HZ g9XKEo8tVLSjM5oSsKPY9plXTZ+8wuBtBVqv+OtZegXxVD1qRgdGPN9G8G+ctFumAwP9 3fNn0iZpVW9ibmvJMgb8wwTCmkvjv1m3DF0Zvreo8SpwV+vcn/87AGPE45F6amURjlLV LVHGNaEm/acVqOfwM5UlhtJw802NdZmedSAEJADPxtNKJHLzQjYQOlGy+4nzJ2inROm1 kABA== 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=3zhbFhwoFiwMQkaYNb5BSiBvrj1lKF9eqN1bn4CV1xU=; b=vmHMb0tik9kWeLkiTjR0I1pNoxW9ruj+znfnRQtRpho5GCpC9kaVsPERIaCZs1Am3w 5hEecNPV3m0JCszszBmVgZf6prUNzLLjySOXphlv7/5jLJgSPwDf07vRXxanNBM9y/GY OFH6K1SOT0Gafk1yrAiCLMYYAGb5HXXIZ9kAF4kWUTWWNAXnZye8Q3a/TMWwVWSUb4JK Its6UBFy3pSA+7kkgHjYHlPpUvV4ZeG3Rq4uD+i9ULgCus25/fdwd6KcBO9FO2qeYE/o K2LrpcPHrzSu0/1MR/Jlc3yu2mOUpb30GoUIjiehSWYMamOIi414SMQ2H3hrPcUGIEAX 5QKw== X-Gm-Message-State: AOAM5320Mz/lIskUb9rfTDnGj3CieRkmFeleqiCp6rUJvix0JzhTfkWN Op9s9vOvHj2JVgWMaw7LEjciBA== X-Received: by 2002:a62:1608:0:b0:4f6:f496:c678 with SMTP id 8-20020a621608000000b004f6f496c678mr11240971pfw.49.1646739497404; Tue, 08 Mar 2022 03:38:17 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:b94a:f47a:3d51:185c]) by smtp.gmail.com with ESMTPSA id z2-20020a17090a170200b001bf2d530d64sm3434677pjd.2.2022.03.08.03.38.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 03:38:17 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.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 v3 10/19] test: dm: add tests for tag support Date: Tue, 8 Mar 2022 20:36:48 +0900 Message-Id: <20220308113657.221101-11-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220308113657.221101-1-takahiro.akashi@linaro.org> References: <20220308113657.221101-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 Reviewed-by: Simon Glass --- test/dm/Makefile | 1 + test/dm/tag.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 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..8289954e7c26 --- /dev/null +++ b/test/dm/tag.c @@ -0,0 +1,84 @@ +// 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);