From patchwork Fri Apr 15 07:15:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 561939 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp115144map; Fri, 15 Apr 2022 00:16:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZS1qS9VIoHku8qkre2YB1cufOP2HBf3rE/9Cgq/mPpU8vAMn/vPgICAsDZyRmXNcGGwWw X-Received: by 2002:a17:907:7242:b0:6da:b561:d523 with SMTP id ds2-20020a170907724200b006dab561d523mr5214748ejc.118.1650007006436; Fri, 15 Apr 2022 00:16:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650007006; cv=none; d=google.com; s=arc-20160816; b=XrdGHdzqKJLcsvJfiJQF/F8V1KKho9njlxEKz4pq0FUDU9shq4QHQCCGOEJF/5/X4x 9u8vbPVpeS/FIH1czUW52EfqqkihcBJ4inoiK4Pu79JIyZJVR8crtK8RP8p/XnFAgbl6 ciPthwKnwkhua180gI0u/mxKFWEeNAUyv1gMmV3gbFgX74owI0Mee9vUbp52AYIQcePM 3Asz+6yMjaOfMl+Ip2qfOzMw3yHjuYJocr0AY6Vf2CQMgTEK4qAIFkqs9+HzqNusoTVb UFXNiimSUNzCHMF041TV4aFCC8HkZqI18uwg0LkGFKzRCuW6k4xpbfIRbiDaE0wa6lmW zKNQ== 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=Eacsu420BmAUaZohJQkVTvQ2VcDs8tSzthJkjHbBuEFs/fxTEenL9LH0cIjvieK7UH d7v0s4naSW0xx+2OEGY10mKUUh3MZ/lamsm54MueXtf1VuEtHiS/Mm6Cm5kivWxzODhc rR2HNBvLsEOzNsCDSm6I7T5AlItEH41elpkX76EH3JJGrq123QU88+5modbQ4reoxJxP eP9Cycm8mZ/W5gzLgW9tBaKHs47YW33cd3oBAJC4kb+vcWBbMTCmJ4KIh4hwh0BzJb2/ c4BRy8lNUXz48xxEsJO7InVxnS4VUSQBnLAZEafSUM0tABzdxC5Q9s/7Wh+logrMeRJV bDPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Z2/SxQR9"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id vp6-20020a17090712c600b006e1442ff695si480235ejb.590.2022.04.15.00.16.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:16:46 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Z2/SxQR9"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 DFD3F83B3A; Fri, 15 Apr 2022 09:16:30 +0200 (CEST) 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="Z2/SxQR9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 30AB8839BD; Fri, 15 Apr 2022 09:16:28 +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=-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-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) (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 E2FE883AD0 for ; Fri, 15 Apr 2022 09:16:22 +0200 (CEST) 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-pj1-x1035.google.com with SMTP id h15-20020a17090a054f00b001cb7cd2b11dso7722486pjf.5 for ; Fri, 15 Apr 2022 00:16:22 -0700 (PDT) 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=Z2/SxQR9PRGujfeRsiUagBS5AxO+LS+bYJxIMoliBO6D7Ah6UV+0TiC8zLpp9RhLnC 40WVb4s3ehoXftPcUi5wFytiUxDc6Fmmr3VNWkdJ3zJuxdbsi+CAhP3OKLL3u6FqcgD6 LlTl/2vhs1o99jhiKj8NKdf9Qn4YWhZRKVsUMfUwo62S/d6puVJ6fiKSat1kNlnNRQDn tC5/Jz7N+G/mScI9cXT1c5zEGRGTpQ5MrNR4WJxp+/ekfbJRGPEECRxC8nb3gZD21Qxi 6tAgxjphSjjmfgvcl/M22I97jy21CDz7dCfiWgRuxV1UDSQm8tVBw9MqXlapmorAUKgI FHAQ== 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=nG5cvKDMbjcyM/OETfU/yho4wETh9MxMu+Apcs8CJdlEFBJVQV/WSsV93YwKRs9xTU HcAP4RyRF25/ruPIhZqu++Tz8jLWS55mB93PeAkVPS2YatCx7U+lgb/baWt1dQ4/9fSE b29q/n2lq0tSPdI1fD3E8ieyA92SLu2al1CHwyRj0Uez+NHBOQA6A6x7+hLpoR4XyybH HmOpXZXY++suIw2vME5eBlzfiMmSnKVJ9Gnfz+R5Egis96mrjPDDEdiemH6kYuTEhLA6 r7bz40jayfSl8z7rwUxjZZoNoiyhSF+LRDpp2rTdsiRkOL0PDCSgCZhgbkYqxB7fygGC xsoQ== X-Gm-Message-State: AOAM532HgxgqT1gD6/D3bKARV+KMlfUgrlMh3PTVyxZfDcUM0qKejGMd fWM+jBYJc5ij2Szo8qBAvmd/0w9zeXoa7A== X-Received: by 2002:a17:90b:4b89:b0:1c7:d452:4bc1 with SMTP id lr9-20020a17090b4b8900b001c7d4524bc1mr2759435pjb.134.1650006981373; Fri, 15 Apr 2022 00:16:21 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:18f3:1e4:6c4:6ea3]) by smtp.gmail.com with ESMTPSA id p1-20020a17090a0e4100b001ce188720e5sm3566921pja.53.2022.04.15.00.16.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:16:21 -0700 (PDT) From: AKASHI Takahiro To: 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 v4 03/12] test: dm: add tests for tag support Date: Fri, 15 Apr 2022 16:15:37 +0900 Message-Id: <20220415071546.122475-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220415071546.122475-1-takahiro.akashi@linaro.org> References: <20220415071546.122475-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);