From patchwork Thu Aug 16 06:00:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 958115 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41rbKd0Yxkz9s4Z for ; Thu, 16 Aug 2018 16:00:37 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="VYTPkTkI"; 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 41rbKc45GFzDr5t for ; Thu, 16 Aug 2018 16:00:36 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="VYTPkTkI"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41rbKX0FYHzDqgF for ; Thu, 16 Aug 2018 16:00:32 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="VYTPkTkI"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 41rbKW5cyBz9s4Z; Thu, 16 Aug 2018 16:00:31 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1534399231; bh=AIQyvsaZypYUiKmeZRoA1baAqxqFaMM7yZMMELT9kv4=; h=From:To:Cc:Subject:Date:From; b=VYTPkTkI3fm7uDFKUVWKztzyFi1APmlyQCr4aYBeXB+wygC/liRExFE/BTfEpG+BB +HFSzezO5TZ/E1d+aWKZg7O5u7JLOudIFhiAg5kDNRfcNXYrHJz6S41kgUk1tNkLw2 vPJBeSE7sZDpMswVNV3+Ge2tc1pMTj7JAIQCeh84P1N9YE03k/hnXWLGkckkJ3AeSk lcgMrdovWpEBUXAb/EiL44SH61NVM/BKD5h8IPC59joZ+7e7q0rlSsqQuTBxyblKWS XWFBVNb1XJdGS8rBJKO9bhSoquPU72lFE+GIoIbLNsu+nIfQJxjjvCAhcYvttTKbfy LaU1OgAV8+IvA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 16 Aug 2018 16:00:28 +1000 Message-Id: <20180816060030.1011842-1-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.1 Subject: [Pdbg] [PATCH 1/3] tests: Add tests for libpdbg target functions X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- Makefile.am | 17 ++- src/tests/libpdbg_target_test.c | 256 ++++++++++++++++++++++++++++++++ 2 files changed, 271 insertions(+), 2 deletions(-) create mode 100644 src/tests/libpdbg_target_test.c diff --git a/Makefile.am b/Makefile.am index e79d023..48177e9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,14 +3,16 @@ AM_MAKEFLAGS = --no-print-directory GIT_SHA1 ?= `git --work-tree=$(top_srcdir) --git-dir=$(top_srcdir)/.git describe --always --long --dirty 2>/dev/null || echo unknown` +libpdbg_tests = libpdbg_target_test + bin_PROGRAMS = pdbg -check_PROGRAMS = optcmd_test +check_PROGRAMS = $(libpdbg_tests) optcmd_test PDBG_TESTS = \ tests/test_selection.sh \ tests/test_hw_bmc.sh -TESTS = optcmd_test $(PDBG_TESTS) +TESTS = $(libpdbg_tests) optcmd_test $(PDBG_TESTS) TEST_EXTENSIONS = .sh SH_LOG_DRIVER = $(SHELL) $(srcdir)/tests/run_test.sh @@ -146,6 +148,17 @@ libccan_a_SOURCES = \ ccan/str/str.c \ ccan/str/str.h +libpdbg_test_cflags = -I$(top_srcdir)/libpdbg -I$(top_srcdir)/libfdt +libpdbg_test_ldflags = -Wl,--whole-archive,-lpdbg,--no-whole-archive +libpdbg_test_ldadd = -L.libs libpdbg.la libfdt.la + +libpdbg_target_test_SOURCES = src/tests/libpdbg_target_test.c +libpdbg_target_test_CFLAGS = $(libpdbg_test_cflags) +libpdbg_target_test_LDFLAGS = $(libpdbg_test_ldflags) +libpdbg_target_test_LDADD = fake.dtb.o $(libpdbg_test_ldadd) + +src/tests/libpdbg_target_test.c: fake.dt.h + M4_V = $(M4_V_$(V)) M4_V_ = $(M4_V_$(AM_DEFAULT_VERBOSITY)) M4_V_0 = @echo " M4 " $@; diff --git a/src/tests/libpdbg_target_test.c b/src/tests/libpdbg_target_test.c new file mode 100644 index 0000000..6b64326 --- /dev/null +++ b/src/tests/libpdbg_target_test.c @@ -0,0 +1,256 @@ +/* Copyright 2018 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +#include + +#include "fake.dt.h" + +static int count_target(struct pdbg_target *parent, const char *classname) +{ + struct pdbg_target *target; + int n = 0; + + pdbg_for_each_target(classname, parent, target) { + n++; + } + + return n; +} + +static int count_class_target(const char *classname) +{ + struct pdbg_target *target; + int n = 0; + + pdbg_for_each_class_target(classname, target) { + n++; + } + + return n; +} + +static int count_child_target(struct pdbg_target *parent) +{ + struct pdbg_target *child; + int n = 0; + + pdbg_for_each_child_target(parent, child) { + n++; + } + + return n; +} + +int main(void) +{ + struct pdbg_target *root, *target, *parent, *parent2; + const char *name; + int count; + + pdbg_targets_init(&_binary_fake_dtb_o_start); + + root = pdbg_target_root(); + assert(root); + + count = count_class_target("fsi"); + assert(count == 1); + + count = count_class_target("pib"); + assert(count == 8); + + count = count_class_target("core"); + assert(count == 32); + + count = count_class_target("thread"); + assert(count == 64); + + pdbg_for_each_class_target("fsi", target) { + parent = pdbg_target_parent("fsi", target); + assert(parent == NULL); + + parent = pdbg_target_parent("pib", target); + assert(parent == NULL); + + parent = pdbg_target_parent("core", target); + assert(parent == NULL); + + parent = pdbg_target_parent("thread", target); + assert(parent == NULL); + + count = count_child_target(target); + assert(count == 8); + + count = count_target(target, "fsi"); + assert(count == 1); + + count = count_target(target, "pib"); + assert(count == 8); + + count = count_target(target, "core"); + assert(count == 32); + + count = count_target(target, "thread"); + assert(count == 64); + + name = pdbg_target_name(target); + assert(!strcmp(name, "Fake FSI")); + + name = pdbg_target_class_name(target); + assert(!strcmp(name, "fsi")); + + name = pdbg_target_dn_name(target); + assert(!strncmp(name, "fsi", 3)); + } + + pdbg_for_each_class_target("pib", target) { + parent = pdbg_target_parent("fsi", target); + assert(parent); + + parent2 = pdbg_target_require_parent("fsi", target); + assert(parent == parent2); + + parent = pdbg_target_parent("pib", target); + assert(parent == NULL); + + parent = pdbg_target_parent("core", target); + assert(parent == NULL); + + parent = pdbg_target_parent("thread", target); + assert(parent == NULL); + + count = count_child_target(target); + assert(count == 4); + + count = count_target(target, "fsi"); + assert(count == 0); + + count = count_target(target, "pib"); + assert(count == 1); + + count = count_target(target, "core"); + assert(count == 4); + + count = count_target(target, "thread"); + assert(count == 8); + + name = pdbg_target_name(target); + assert(!strcmp(name, "Fake PIB")); + + name = pdbg_target_class_name(target); + assert(!strcmp(name, "pib")); + + name = pdbg_target_dn_name(target); + assert(!strncmp(name, "pib", 3)); + } + + pdbg_for_each_class_target("core", target) { + parent = pdbg_target_parent("fsi", target); + assert(parent); + + parent2 = pdbg_target_require_parent("fsi", target); + assert(parent == parent2); + + parent = pdbg_target_parent("pib", target); + assert(parent); + + parent2 = pdbg_target_require_parent("pib", target); + assert(parent == parent2); + + parent = pdbg_target_parent("core", target); + assert(parent == NULL); + + parent = pdbg_target_parent("thread", target); + assert(parent == NULL); + + count = count_child_target(target); + assert(count == 2); + + count = count_target(target, "fsi"); + assert(count == 0); + + count = count_target(target, "pib"); + assert(count == 0); + + count = count_target(target, "core"); + assert(count == 1); + + count = count_target(target, "thread"); + assert(count == 2); + + name = pdbg_target_name(target); + assert(!strcmp(name, "Fake Core")); + + name = pdbg_target_class_name(target); + assert(!strcmp(name, "core")); + + name = pdbg_target_dn_name(target); + assert(!strncmp(name, "core", 4)); + } + + pdbg_for_each_class_target("thread", target) { + parent = pdbg_target_parent("fsi", target); + assert(parent); + + parent2 = pdbg_target_require_parent("fsi", target); + assert(parent == parent2); + + parent = pdbg_target_parent("pib", target); + assert(parent); + + parent2 = pdbg_target_require_parent("pib", target); + assert(parent == parent2); + + parent = pdbg_target_parent("core", target); + assert(parent); + + parent2 = pdbg_target_require_parent("core", target); + assert(parent == parent2); + + parent = pdbg_target_parent("thread", target); + assert(parent == NULL); + + count = count_child_target(target); + assert(count == 0); + + count = count_target(target, "fsi"); + assert(count == 0); + + count = count_target(target, "pib"); + assert(count == 0); + + count = count_target(target, "core"); + assert(count == 0); + + count = count_target(target, "thread"); + assert(count == 1); + + name = pdbg_target_name(target); + assert(!strcmp(name, "Fake Thread")); + + name = pdbg_target_class_name(target); + assert(!strcmp(name, "thread")); + + name = pdbg_target_dn_name(target); + assert(!strncmp(name, "thread", 6)); + } + + return 0; +} From patchwork Thu Aug 16 06:00:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 958116 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41rbKh4r1Dz9s4v for ; Thu, 16 Aug 2018 16:00:40 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="wBuVrUrG"; 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 41rbKh2KNpzDr5p for ; Thu, 16 Aug 2018 16:00:40 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="wBuVrUrG"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41rbKX3wMpzDqmF for ; Thu, 16 Aug 2018 16:00:32 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="wBuVrUrG"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 41rbKW75cJz9s4v; Thu, 16 Aug 2018 16:00:31 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1534399232; bh=cAqhrJOBNJ6dvv80b2XzoMO7nn9U5dxk3ZW7/d40TI8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wBuVrUrG/OuKAHEJoh/ZBkR9mJ/AnZ0InAf0D1XTINzyLcjkSRxncl5NiKouMJj6U Dx4+px7OYPEhtwDcczWOn7MkLQILFUbU4JqP+SDLPw9e6uLs60v8zTRBfRE9Ozf4GM 1GEpoHDGmDv0psTTly5jwTyZRgPeMzIDtSauVRjknQPcRQLDtyW2G9neM1iwg8bK01 x1MzgeFY+KB44uTMS2aNmA0orvgFDi4njtXwjQMlEFMFW/Nbtqsq0Wdkd16L6Feoo8 J8VfgijFIHe3vOoZOX/SmpJ/eWcsywmkC0koobxBvKmeBQYYXqGHCZeFxcOMlpT4qp 0FNJKP3DMRM6g== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 16 Aug 2018 16:00:29 +1000 Message-Id: <20180816060030.1011842-2-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180816060030.1011842-1-amitay@ozlabs.org> References: <20180816060030.1011842-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH 2/3] tests: Add tests for libpdbg probe functions X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- Makefile.am | 22 ++- src/tests/libpdbg_probe_test.c | 249 +++++++++++++++++++++++++++++++++ 2 files changed, 270 insertions(+), 1 deletion(-) create mode 100644 src/tests/libpdbg_probe_test.c diff --git a/Makefile.am b/Makefile.am index 48177e9..9d85e9c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,7 +3,10 @@ AM_MAKEFLAGS = --no-print-directory GIT_SHA1 ?= `git --work-tree=$(top_srcdir) --git-dir=$(top_srcdir)/.git describe --always --long --dirty 2>/dev/null || echo unknown` -libpdbg_tests = libpdbg_target_test +libpdbg_tests = libpdbg_target_test \ + libpdbg_probe_test1 \ + libpdbg_probe_test2 \ + libpdbg_probe_test3 bin_PROGRAMS = pdbg check_PROGRAMS = $(libpdbg_tests) optcmd_test @@ -159,6 +162,23 @@ libpdbg_target_test_LDADD = fake.dtb.o $(libpdbg_test_ldadd) src/tests/libpdbg_target_test.c: fake.dt.h +libpdbg_probe_test1_SOURCES = src/tests/libpdbg_probe_test.c +libpdbg_probe_test1_CFLAGS = $(libpdbg_test_cflags) -DTEST_ID=1 +libpdbg_probe_test1_LDFLAGS = $(libpdbg_test_ldflags) +libpdbg_probe_test1_LDADD = fake.dtb.o $(libpdbg_test_ldadd) + +libpdbg_probe_test2_SOURCES = src/tests/libpdbg_probe_test.c +libpdbg_probe_test2_CFLAGS = $(libpdbg_test_cflags) -DTEST_ID=2 +libpdbg_probe_test2_LDFLAGS = $(libpdbg_test_ldflags) +libpdbg_probe_test2_LDADD = fake.dtb.o $(libpdbg_test_ldadd) + +libpdbg_probe_test3_SOURCES = src/tests/libpdbg_probe_test.c +libpdbg_probe_test3_CFLAGS = $(libpdbg_test_cflags) -DTEST_ID=3 +libpdbg_probe_test3_LDFLAGS = $(libpdbg_test_ldflags) +libpdbg_probe_test3_LDADD = fake.dtb.o $(libpdbg_test_ldadd) + +src/tests/libpdbg_probe_test.c: fake.dt.h + M4_V = $(M4_V_$(V)) M4_V_ = $(M4_V_$(AM_DEFAULT_VERBOSITY)) M4_V_0 = @echo " M4 " $@; diff --git a/src/tests/libpdbg_probe_test.c b/src/tests/libpdbg_probe_test.c new file mode 100644 index 0000000..e0be78d --- /dev/null +++ b/src/tests/libpdbg_probe_test.c @@ -0,0 +1,249 @@ +/* Copyright 2018 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +#include + +#include "fake.dt.h" + +static void for_each_target(struct pdbg_target *parent, + void (*callback)(struct pdbg_target *target, + enum pdbg_target_status status), + enum pdbg_target_status status) +{ + struct pdbg_target *child; + + assert(parent); + + callback(parent, status); + + pdbg_for_each_child_target(parent, child) { + for_each_target(child, callback, status); + } +} + +static void for_target_to_root(struct pdbg_target *target, + void (*callback)(struct pdbg_target *target, + enum pdbg_target_status status), + enum pdbg_target_status status) +{ + assert(target); + + do { + callback(target, status); + target = pdbg_target_parent(NULL, target); + } while (target != NULL); +} + +static void check_status(struct pdbg_target *target, + enum pdbg_target_status status) +{ + struct pdbg_target *root; + + root = pdbg_target_root(); + if (target == root) { + if (pdbg_target_status(target) != status) { + printf("root node: status=%u, expected=%u\n", + pdbg_target_status(target), status); + } + return; + } + + assert(pdbg_target_status(target) == status); +} + +static void test1(void) +{ + struct pdbg_target *root, *target; + + pdbg_targets_init(&_binary_fake_dtb_o_start); + + root = pdbg_target_root(); + assert(root); + + for_each_target(root, check_status, PDBG_TARGET_UNKNOWN); + + pdbg_target_probe_all(root); + for_each_target(root, check_status, PDBG_TARGET_ENABLED); + + pdbg_for_each_class_target("fsi", target) { + pdbg_target_release(target); + } + pdbg_for_each_class_target("fsi", target) { + check_status(target, PDBG_TARGET_PENDING_RELEASE); + } + pdbg_for_each_class_target("pib", target) { + for_each_target(target, check_status, PDBG_TARGET_ENABLED); + } + + pdbg_for_each_class_target("pib", target) { + pdbg_target_release(target); + } + pdbg_for_each_class_target("fsi", target) { + check_status(target, PDBG_TARGET_PENDING_RELEASE); + } + pdbg_for_each_class_target("pib", target) { + check_status(target, PDBG_TARGET_PENDING_RELEASE); + } + pdbg_for_each_class_target("core", target) { + for_each_target(target, check_status, PDBG_TARGET_ENABLED); + } + + pdbg_for_each_class_target("core", target) { + pdbg_target_release(target); + } + pdbg_for_each_class_target("fsi", target) { + check_status(target, PDBG_TARGET_PENDING_RELEASE); + } + pdbg_for_each_class_target("pib", target) { + check_status(target, PDBG_TARGET_PENDING_RELEASE); + } + pdbg_for_each_class_target("core", target) { + check_status(target, PDBG_TARGET_PENDING_RELEASE); + } + pdbg_for_each_class_target("thread", target) { + check_status(target, PDBG_TARGET_ENABLED); + } + + pdbg_for_each_class_target("thread", target) { + pdbg_target_release(target); + } + for_each_target(root, check_status, PDBG_TARGET_RELEASED); +} + +static void test2(void) +{ + struct pdbg_target *root, *target; + enum pdbg_target_status status; + + pdbg_targets_init(&_binary_fake_dtb_o_start); + + root = pdbg_target_root(); + assert(root); + + for_each_target(root, check_status, PDBG_TARGET_UNKNOWN); + + pdbg_for_each_class_target("pib", target) { + status = pdbg_target_probe(target); + assert(status == PDBG_TARGET_ENABLED); + + for_target_to_root(target, check_status, PDBG_TARGET_ENABLED); + } + pdbg_for_each_class_target("core", target) { + for_each_target(target, check_status, PDBG_TARGET_UNKNOWN); + } + + pdbg_for_each_class_target("core", target) { + status = pdbg_target_probe(target); + assert(status == PDBG_TARGET_ENABLED); + + for_target_to_root(target, check_status, PDBG_TARGET_ENABLED); + } + pdbg_for_each_class_target("thread", target) { + for_each_target(target, check_status, PDBG_TARGET_UNKNOWN); + } + + pdbg_for_each_class_target("core", target) { + pdbg_target_probe_all(target); + } + pdbg_for_each_class_target("thread", target) { + for_each_target(target, check_status, PDBG_TARGET_ENABLED); + } + + pdbg_for_each_class_target("core", target) { + pdbg_target_release(target); + } + pdbg_for_each_class_target("fsi", target) { + check_status(target, PDBG_TARGET_ENABLED); + } + pdbg_for_each_class_target("pib", target) { + check_status(target, PDBG_TARGET_ENABLED); + } + pdbg_for_each_class_target("core", target) { + check_status(target, PDBG_TARGET_PENDING_RELEASE); + } + pdbg_for_each_class_target("thread", target) { + check_status(target, PDBG_TARGET_ENABLED); + } + + pdbg_for_each_class_target("thread", target) { + pdbg_target_release(target); + } + for_each_target(root, check_status, PDBG_TARGET_RELEASED); +} + +static void test3(void) +{ + struct pdbg_target *root, *target; + enum pdbg_target_status status; + + pdbg_targets_init(&_binary_fake_dtb_o_start); + + root = pdbg_target_root(); + assert(root); + + for_each_target(root, check_status, PDBG_TARGET_UNKNOWN); + + pdbg_for_each_class_target("core", target) { + pdbg_target_status_set(target, PDBG_TARGET_DISABLED); + } + pdbg_for_each_class_target("thread", target) { + check_status(target, PDBG_TARGET_UNKNOWN); + } + + pdbg_for_each_class_target("thread", target) { + status = pdbg_target_probe(target); + assert(status == PDBG_TARGET_UNKNOWN); + check_status(target, PDBG_TARGET_UNKNOWN); + } + + pdbg_target_probe_all(root); + + pdbg_for_each_class_target("core", target) { + check_status(target, PDBG_TARGET_DISABLED); + } + pdbg_for_each_class_target("thread", target) { + check_status(target, PDBG_TARGET_UNKNOWN); + } + + pdbg_for_each_class_target("pib", target) { + pdbg_target_release(target); + } + pdbg_for_each_class_target("pib", target) { + for_target_to_root(target, check_status, PDBG_TARGET_RELEASED); + } +} + +int main(void) +{ + int test_id = TEST_ID; + + if (test_id == 1) { + test1(); + } else if (test_id == 2) { + test2(); + } else if (test_id == 3) { + test3(); + } else { + printf("No test for TEST_ID=%d\n", test_id); + return 1; + } + + return 0; +} From patchwork Thu Aug 16 06:00:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 958117 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41rbKm4c5Fz9s4Z for ; Thu, 16 Aug 2018 16:00:44 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="c/nilyz7"; 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 41rbKm1CqgzDrDF for ; Thu, 16 Aug 2018 16:00:44 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="c/nilyz7"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41rbKY0Vz6zDqgF for ; Thu, 16 Aug 2018 16:00:33 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="c/nilyz7"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 41rbKX3YpNz9s5b; Thu, 16 Aug 2018 16:00:32 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1534399232; bh=p8N/dD8vHo9FynY6kMSKjuPLS+qO17N/sRLgt/UcGWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c/nilyz7qMnEA1i1bZiEdgRwqZzeOMxo92i2gFM+2Sx6+kwBjMwz/ExhwmjqOnKWI sTY2PJbmNnb0HxBknSRK3/M7DTtIhzlHDtKidDD0VjUSlBRlwVEAQ4I3gPqvRlNnQT QE1jwgKKZ2ywhcP8Uxlz1gtQUPzmjnWJbE/UUsy8Qw2NhqKPTk3ZpcUr1wGhydacEU JUdJOVQGo5mMRX7R4cDglsnblo6sCMnZ+CR8HOdPCJbjOK7MxGIk6Kv8RvXzPxwXmy Ikw3OvwkvYiK3AXiI5kMowI4aDKhWVc9xwaBrkZMsGyGNc3ioJbfonduu+1EFea9HP 2/KUXmsj+g5nQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 16 Aug 2018 16:00:30 +1000 Message-Id: <20180816060030.1011842-3-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180816060030.1011842-1-amitay@ozlabs.org> References: <20180816060030.1011842-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH 3/3] build: Add dummy target to build test binaries X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile.am b/Makefile.am index 9d85e9c..df3bbcd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -17,6 +17,8 @@ PDBG_TESTS = \ TESTS = $(libpdbg_tests) optcmd_test $(PDBG_TESTS) +test: $(libpdbg_tests) + TEST_EXTENSIONS = .sh SH_LOG_DRIVER = $(SHELL) $(srcdir)/tests/run_test.sh