From patchwork Fri Feb 27 05:06:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Axtens X-Patchwork-Id: 444146 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5D62C14012A for ; Fri, 27 Feb 2015 16:07:04 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="verification failed; unprotected key" header.d=axtens.net header.i=@axtens.net header.b=WofYzKY5; dkim-adsp=none (unprotected policy); dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 390F11A00B8 for ; Fri, 27 Feb 2015 16:07:04 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="verification failed; unprotected key" header.d=axtens.net header.i=@axtens.net header.b=WofYzKY5; dkim-adsp=none (unprotected policy); dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mail-pa0-x22d.google.com (mail-pa0-x22d.google.com [IPv6:2607:f8b0:400e:c03::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3F1D71A0064 for ; Fri, 27 Feb 2015 16:06:47 +1100 (AEDT) Received: by pabli10 with SMTP id li10so3755576pab.0 for ; Thu, 26 Feb 2015 21:06:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BJT6GsMfmijw14F3w+6nG2WkJk0ULWDgwLMY9jQZ8iw=; b=WofYzKY5O36/HgXIH6LAKojJcNkiHkI4C2D3AL/8EeOdP6xs21I1Kg79WDjp9W8/W/ acHe1YzoH6qXcB7F1XPnNayZq4zSHoAxDxjQz6JBJooStog1j2PiDMWcn+w6KDTK/6oF aMhFdtZGONt6W6rKbzY5Rmhz6IzyhZwPd6gL0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BJT6GsMfmijw14F3w+6nG2WkJk0ULWDgwLMY9jQZ8iw=; b=Wm+/I6LeoC9q/cB5WYUUcccanVIbgNYu6dHbHJuA3Ql1Uv6DCWXzvdcoUEFoC+AaSs qOrlSVB/pAlWj9qXjNDhc6BAGt8Wi4UDIiTPGm8j/8QfawWIIR/nngvtSqdP0/vA/BQO nbKbX1X1NeUs6S5a0W2yPJ94TKzqE/3HDFrYowpEYshsm7UaaN584hKQpfOdNj7GbTsS 8pZxSdGY6tbsjixI5wTte//yeKaDeAHSauXVHPcBxPsoYSJ7WRcnrNVhLpLM5K0Fg14/ 1x8bOQaUjhCTwdnEmC3A2qbua+E4K1RYjAtsPnpJPZ56JuMq0JfvZr8GApjuMEMOa4lf 1CQQ== X-Gm-Message-State: ALoCoQlFuubBsRDn27O+EV9YpneTc2ZQaTQ5uBC8TOH5TM1EHEHpQAmniGR1cxYWbKDZ+J4yDhcP X-Received: by 10.66.119.238 with SMTP id kx14mr20540525pab.41.1425013605285; Thu, 26 Feb 2015 21:06:45 -0800 (PST) Received: from omicron.ozlabs.ibm.com (bh02i525f01.au.ibm.com. [202.81.18.30]) by mx.google.com with ESMTPSA id qj3sm2590607pac.31.2015.02.26.21.06.43 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Feb 2015 21:06:44 -0800 (PST) From: Daniel Axtens To: skiboot@lists.ozlabs.org Date: Fri, 27 Feb 2015 16:06:35 +1100 Message-Id: <1425013595-13600-5-git-send-email-dja@axtens.net> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1425013595-13600-1-git-send-email-dja@axtens.net> References: <1425013595-13600-1-git-send-email-dja@axtens.net> Subject: [Skiboot] [PATCH 4/4] core/test: Test compatible, chip id and phandle related DT functions X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Signed-off-by: Daniel Axtens --- core/test/run-device.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/core/test/run-device.c b/core/test/run-device.c index 101b56f..cd6ec8d 100644 --- a/core/test/run-device.c +++ b/core/test/run-device.c @@ -54,6 +54,7 @@ int main(void) unsigned int n; char *s; size_t sz; + u32 phandle; root = dt_new_root(""); assert(!list_top(&root->properties, struct dt_property, list)); @@ -241,5 +242,60 @@ int main(void) /* No leaks for valgrind! */ dt_free(root); + + /* Test compatible and chip id. */ + root = dt_new_root(""); + + c1 = dt_new(root, "chip1"); + dt_add_property_cells(c1, "ibm,chip-id", 0xcafe); + assert(dt_get_chip_id(c1) == 0xcafe); + dt_add_property_strings(c1, "compatible", + "specific-fake-chip", + "generic-fake-chip"); + assert(dt_node_is_compatible(c1, "specific-fake-chip")); + assert(dt_node_is_compatible(c1, "generic-fake-chip")); + + c2 = dt_new(root, "chip2"); + dt_add_property_cells(c2, "ibm,chip-id", 0xbeef); + assert(dt_get_chip_id(c2) == 0xbeef); + dt_add_property_strings(c2, "compatible", + "specific-fake-bus", + "generic-fake-bus"); + + gc1 = dt_new(c1, "coprocessor1"); + dt_add_property_strings(gc1, "compatible", + "specific-fake-coprocessor"); + + gc2 = dt_new(c1, "node-without-compatible"); + assert(__dt_find_property(gc2, "compatible") == NULL); + assert(!dt_node_is_compatible(gc2, "any-property")); + + assert(dt_find_compatible_node(root, NULL, "generic-fake-bus") == c2); + assert(dt_find_compatible_node(root, c2, "generic-fake-bus") == NULL); + + /* we can find the coprocessor once on the cpu */ + assert(dt_find_compatible_node_on_chip(root, + NULL, + "specific-fake-coprocessor", + 0xcafe) == gc1); + assert(dt_find_compatible_node_on_chip(root, + gc1, + "specific-fake-coprocessor", + 0xcafe) == NULL); + + /* we can't find the coprocessor on the bus */ + assert(dt_find_compatible_node_on_chip(root, + NULL, + "specific-fake-coprocessor", + 0xbeef) == NULL); + + /* Test phandles. We override the automatically generated one. */ + phandle = 0xf00; + dt_add_property(gc2, "phandle", (const void *)&phandle, 4); + assert(last_phandle == 0xf00); + assert(dt_find_by_phandle(root, 0xf00) == gc2); + assert(dt_find_by_phandle(root, 0xf0f) == NULL); + + dt_free(root); return 0; }