From patchwork Thu May 28 14:20:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1299835 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=h6y0g/9l; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 49Xqcy5G33z9sSf for ; Fri, 29 May 2020 00:21:20 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 518F7813B3; Thu, 28 May 2020 16:21:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="h6y0g/9l"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 75BDD813B8; Thu, 28 May 2020 16:21:12 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) (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 89FA8812FF for ; Thu, 28 May 2020 16:21:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd41.google.com with SMTP id d5so20628531ios.9 for ; Thu, 28 May 2020 07:21:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ir0Rj8zludyOwR0NdAW4iJyUy/Q97jph5foFA1wUzMk=; b=h6y0g/9lm5Xndc7rZg++OJfvENR4k+YXBIJ/FvCVEleWGLBUTSpk/8WHZr5OLQcPwh cC6EqTZ9rqLoeJ/T7AKAZdJQx1sY7y+Ljy47tvy6/DCiShEsJlB8c+8EO09arybje/ci nXCzPcaOCL70EwUVI+Hg3HsL1RAb5+JKA/4Dw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ir0Rj8zludyOwR0NdAW4iJyUy/Q97jph5foFA1wUzMk=; b=IxDpdQbSQRySLcCpCgPOBE/P/RKKlafsd4dSr5cD6pZuC4RnIcjfiZMLhSjt/O8YTL zEPvrfoh5vG7j7QVNkQpTMxYDpzz9n9+sxdfVwqu3efbRTvvb/b2dEI1It9soZF6b70G Iwbo/N2dRPNAql84MporIIUg5adEHBY6WbiyAcqQVgHjJgO6Ulbcj3i5uhe8a1BMaCK5 d6mDjde4OthSixxDhs2dCG0HRF+9eF8O116X7Q7OueQ3SkBo+aYkovijq8QNCtXqQRrQ xxxVlzeIHRBCqFbrw3xKCpll7oLrq3/zJzhMc2gAs4gGMxGvbeDQXt2otaehHFpfT2LQ ngQw== X-Gm-Message-State: AOAM532WXhPrvxRW+KnhTuK9f7j2rfPDLsLnNandY8m7u+OnEMckDUAr YaGlMh0r2LJ4tn7o9daPtNrGRC1X/Y/sbw== X-Google-Smtp-Source: ABdhPJw19szN1c8fVq5QMiveSU48nsbkSm0zCx9InGxVYS/4lCHwBBFEp1nUrXldpH6m+TyzDVZ65w== X-Received: by 2002:a5d:91d2:: with SMTP id k18mr2547592ior.20.1590675667471; Thu, 28 May 2020 07:21:07 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id k17sm1631257ios.1.2020.05.28.07.21.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 May 2020 07:21:06 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Matthias Brugger , Ovidiu Panait , Simon Glass , Marek Vasut , Pavel Herrmann Subject: [PATCH] dm: test: Add a test for dm_test_dev_read_addr_ptr() Date: Thu, 28 May 2020 08:20:47 -0600 Message-Id: <20200528082045.1.Ibd999a0382164a37d1e59c00c8c7a9ff92b8f53a@changeid> X-Mailer: git-send-email 2.27.0.rc0.183.gde8f92d652-goog MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean Check the behaviour of this function. Hopefully this is start of a complete test suite for the dev_read...() functions. Signed-off-by: Simon Glass --- Due to the nature of the test harness, this tests all cases: 1. CONFIG_OF_LIVE and livetree in use (normal sandbox test, gd->of_root is set) 2. CONFIG_OF_LIVE but livetree not yet in use (sandbox with gd->of_root = NULL) 3. !CONFIG_OF_LIVE (in sandbox_flattree) The third one is tested by 'make qcheck' which calls test/run test/dm/Makefile | 1 + test/dm/read.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 test/dm/read.c diff --git a/test/dm/Makefile b/test/dm/Makefile index 6c18fd04ce..ad2d3547f5 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -4,6 +4,7 @@ obj-$(CONFIG_UT_DM) += bus.o obj-$(CONFIG_UT_DM) += nop.o +obj-$(CONFIG_UT_DM) += read.o obj-$(CONFIG_UT_DM) += test-driver.o obj-$(CONFIG_UT_DM) += test-fdt.o obj-$(CONFIG_UT_DM) += test-main.o diff --git a/test/dm/read.c b/test/dm/read.c new file mode 100644 index 0000000000..38b128b144 --- /dev/null +++ b/test/dm/read.c @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Livetree API + * + * Copyright 2020 Google LLC + */ + +#include +#include +#include +#include +#include +#include +#include + +/* Test that dev_read_addr_ptr() works in flattree and livetree */ +static int dm_test_dev_read_addr_ptr(struct unit_test_state *uts) +{ + struct udevice *gpio, *dev; + void *ptr; + + /* Test for missing reg property */ + ut_assertok(uclass_first_device_err(UCLASS_GPIO, &gpio)); + ut_assertnull(dev_read_addr_ptr(gpio)); + + ut_assertok(syscon_get_by_driver_data(SYSCON0, &dev)); + ptr = dev_read_addr_ptr(dev); + ut_asserteq(0x10, map_to_sysmem(ptr)); + + /* See dm_test_fdt_translation() which has more tests */ + + return 0; +} +DM_TEST(dm_test_dev_read_addr_ptr, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);