From patchwork Tue Apr 19 01:05:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 563296 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp2860308map; Mon, 18 Apr 2022 18:06:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYhVTFDSSjP3hjsgwXmIt9A0uiTevkirD/VWLqDnpE2Ag5egy64RMJMrjhi4f9PvzCDjdw X-Received: by 2002:a17:907:7f8c:b0:6ef:e43e:f08f with SMTP id qk12-20020a1709077f8c00b006efe43ef08fmr3043ejc.733.1650330374823; Mon, 18 Apr 2022 18:06:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650330374; cv=none; d=google.com; s=arc-20160816; b=ggQho/U9Qri73on4Q6aufC8qf/Rs/lXzGog0uZaFWZG/mF/NuA4TEunPeZNMgNnScr n2RyTPntA9Ih1ATXVyN1g8HfNa8vzKsqGDNS134fKDRNANKzOIrxyLDti38JGxML3gzK oXfOWDw7jyWEPZdFFpSI5pcEmUxx8wf3VBFbX9P50Ckogn4AOjqO4xR7T/vy+AW1zEFk okD2+9QttBxHhKRvrSlyLAgSh0r6iZCEJBQlQVJpYSH4LZiEhyOXPYCNG+S824D9Rhgw g7mq57TGolCtLCYqIqg9H8qPrLrF7Mf4TNMZIKe5ScbRU6TTJcnPqbTxhpTKhtCQOpRa ct6g== 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=X4ldgdiIZtVImr4HX58TCjQnaBqBK5CDq+KOM7Bc6H6bJaAIBrvrb4KrFCZKp20N+1 EL2ouGTAwza1T0Y9IhiVaWOqtg6pdDWCRTGWsOsWgDiBNaraWPzWcOudSZC7psO8jwxe SXXoOiQJs8I9ZI3lPuApTeQFe1UTHDQDkZLdnKlEHO46O4YfyzdlMJBOWPnqI9OofMHQ i2X7nZ4KAXZQQOxE2ipBZo4DXcwYUgAuNSM5kDYig1AY1OwCTBcEPfMKiwnHFx3gCbC+ w42Gl5fhfg0ntCZKrN4ZqVUBAPUSbDTrNZ2d4AseigEEEB0bSDfQM7wdaRCg3EoDjhNP UKtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W6N7oHwR; 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 b8-20020a170906038800b006e8cb4353f2si7224821eja.302.2022.04.18.18.06.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:06:14 -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=W6N7oHwR; 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 4123583D8E; Tue, 19 Apr 2022 03:06:07 +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="W6N7oHwR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A86D383C11; Tue, 19 Apr 2022 03:05:54 +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-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) (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 5330A83C06 for ; Tue, 19 Apr 2022 03:05:47 +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-x102d.google.com with SMTP id mm4-20020a17090b358400b001cb93d8b137so818743pjb.2 for ; Mon, 18 Apr 2022 18:05:47 -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=W6N7oHwRJxB/mvAwHQY663/VXmgTCjTngepzDgiS+mYU4HjY2kGUvQCxmpHHqtgfO3 rNv0PsFVZluCzWiKM3El8iR7xZSSXtOSvTwPbpUgAho6w0zuwuwkF302tBDaASNR4XKe UhAx4NbGi4VLGdf/AEHcYsD97lEpvgaM511uzIixEwv/uayfhTY2BM5IdbH8Ann3YeTm B/fs/lH6AyteHO4Y/UmFe0YpBeWe4Ui/5kBxx1GF9siqaHDcyDqs8BFnJqQBWwwL5eNy iM9WRtV9bNqohnUJLKaSwu6RBxh/9XGSrtG3SucsipHzoOCtkMdcP9JlF8g9o2n87HBo DGoQ== 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=gC/UiFnTlIZTQ4bMEe4RYw0ZL+O5XBshBEanq8/PyprW0wM5IV8AmErhz32OsBiYbj AEjLWdL2mKr2fmLhOJECNIguvWwCl5PXUtNhPH+DgrTZqV/fZzOnD5KbL5qLlE1iCcMy rz85IjzptYXI6qYB5XiW73ql62JUWDubTZoNHyn8OOo4PYGQZFvlW4QDNEmhgqQRPIno avgkE2B+kQyh7Z2NW80LpDYhVjA+hRzed1I41TDLN3J2wB02qDNJJuFaWf/yJHjt/xMl StPKWHEh2JFRCAzUQTN0Etft8UdHkUuXUxUI4fcTSbkG5DktXBgl2DDsFPagz8RMA0L+ RYsw== X-Gm-Message-State: AOAM533mc6zLsShJwY9CwoJsvtMcuNuimTfye6ZmerAdoMSGEM5OaKFf VPHUBaYRdBVOhO0M+kdR4MfFIA== X-Received: by 2002:a17:90a:b014:b0:1cb:ba36:8fe1 with SMTP id x20-20020a17090ab01400b001cbba368fe1mr21476839pjq.67.1650330345699; Mon, 18 Apr 2022 18:05:45 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:5858:d3a6:5cad:ceeb]) by smtp.gmail.com with ESMTPSA id k137-20020a633d8f000000b0039800918b00sm14043756pga.77.2022.04.18.18.05.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:05:45 -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 v5 03/12] test: dm: add tests for tag support Date: Tue, 19 Apr 2022 10:05:08 +0900 Message-Id: <20220419010517.47175-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220419010517.47175-1-takahiro.akashi@linaro.org> References: <20220419010517.47175-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);