From nobody Fri May 17 05:54:44 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1611707875; cv=none; d=zohomail.com; s=zohoarc; b=JqIzFMkOPL9+IZTRn/VoxJPdr1yUfMZMxNXeosGR7bYizJRCInp7G3tQfX/Exf8ELDrRLmnw7cMGV8QhdC6/PDYg+aNE7H0SoqAr+7n70IocGsiA4zyhtU5kTPbs/0urxgYGYxqFki8WiC/2LHfGxA/xv5/XdGfXb57xvXsJLNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611707875; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=WvVhQGQ1SCY3KFTTIsaCf80vUTbNa1hTBVbenWIbNlI=; b=DgK7CZoNxkGd3uyl6lSinMwdHTtURhlluAyaWzNG6AKVdJjO4MRhvMzSfZXiwf+S3YvS0wBio7qAZrpSjTo/RbQwetGm8SZVgt87CnH9F/mOAZjyDr5POTnn4h0teDYGa8powa0V44Thw+635rEQAjHe9Oq3qL6kBbuamlR/NiI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1611707874818702.812010940863; Tue, 26 Jan 2021 16:37:54 -0800 (PST) Received: from localhost ([::1]:34936 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l4YqH-0003YD-SK for importer@patchew.org; Tue, 26 Jan 2021 19:37:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57090) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3be962ff38f3396f8040deaa5ffdab525c4e0b16@lizzy.crudebyte.com>) id 1l4YpP-00037z-Gk for qemu-devel@nongnu.org; Tue, 26 Jan 2021 19:36:59 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:52279) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3be962ff38f3396f8040deaa5ffdab525c4e0b16@lizzy.crudebyte.com>) id 1l4YpN-0006bT-R1 for qemu-devel@nongnu.org; Tue, 26 Jan 2021 19:36:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=WvVhQGQ1SCY3KFTTIsaCf80vUTbNa1hTBVbenWIbNlI=; b=k4dn+ 9Wxmz6FXYNW20S00rNIdc1oU9Pfy1hw9UZL1+NLKqpYnCpCepxsyJfU3mK6k3VadfUWNUBYAAQ60P /KJpGpMdkmu89mt2dzGQo/PA4lxKgq8BdYoBCCb9aZucnz8Af4zLIl6Brl9KFlbKTBIu9imz4dtD5 tQ2CnJ244xOr7cMpC2aIM9TUS+xb5uEqsdVgMVWbK8alksrPZdF753wtwUEPooXfytNr2ZWmJlZCb Anr8AazBqsZGHVYgzu1R77P75mBZ2qGkV7siBlFs8XxFpdHuudqzfswtbAO8O8njbmb/S1GQbbl0U 1dHBcYZn6baLv3UFcAYfVmvA1J99A==; Message-Id: <3be962ff38f3396f8040deaa5ffdab525c4e0b16.1611704181.git.qemu_oss@crudebyte.com> In-Reply-To: References: Date: Wed, 27 Jan 2021 00:00:34 +0100 Subject: [PATCH 1/5] libqos/qgraph: add qos_node_create_driver_named() To: qemu-devel@nongnu.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=3be962ff38f3396f8040deaa5ffdab525c4e0b16@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini , Thomas Huth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Reply-to: Christian Schoenebeck From: qemu_oss--- via X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" So far the qos subsystem of the qtest framework had the limitation that only one instance of the same official QEMU (QMP) driver name could be created for qtests. That's because a) the created qos node names must always be unique, b) the node name must match the official QEMU driver name being instantiated and c) all nodes are in a global space shared by all tests. This patch removes this limitation by introducing a new function qos_node_create_driver_named() which allows test case authors to specify a node name being different from the actual associated QEMU driver name. It fills the new 'qemu_name' field of QOSGraphNode for that purpose. Adjust build_driver_cmd_line() and qos_graph_node_set_availability() to correctly deal with either accessing node name vs. node's qemu_name correctly. Signed-off-by: Christian Schoenebeck --- tests/qtest/libqos/qgraph.c | 54 ++++++++++++++++++++++++++-- tests/qtest/libqos/qgraph.h | 16 +++++++++ tests/qtest/libqos/qgraph_internal.h | 1 + 3 files changed, 68 insertions(+), 3 deletions(-) diff --git a/tests/qtest/libqos/qgraph.c b/tests/qtest/libqos/qgraph.c index fc49cfa879..61faf6b27d 100644 --- a/tests/qtest/libqos/qgraph.c +++ b/tests/qtest/libqos/qgraph.c @@ -153,6 +153,7 @@ static QOSGraphNode *create_node(const char *name, QOSN= odeType type) static void destroy_node(void *val) { QOSGraphNode *node =3D val; + g_free(node->qemu_name); g_free(node->command_line); g_free(node); } @@ -286,7 +287,8 @@ static void build_machine_cmd_line(QOSGraphNode *node, = const char *args) */ static void build_driver_cmd_line(QOSGraphNode *node) { - node->command_line =3D g_strconcat(" -device ", node->name, NULL); + const char *name =3D node->qemu_name ?: node->name; + node->command_line =3D g_strconcat(" -device ", name, NULL); } =20 /* qos_print_cb(): callback prints all path found by the DFS algorithm. */ @@ -631,6 +633,15 @@ void qos_node_create_driver(const char *name, QOSCreat= eDriverFunc function) node->u.driver.constructor =3D function; } =20 +void qos_node_create_driver_named(const char *name, const char *qemu_name, + QOSCreateDriverFunc function) +{ + QOSGraphNode *node =3D create_node(name, QNODE_DRIVER); + node->qemu_name =3D g_strdup(qemu_name); + build_driver_cmd_line(node); + node->u.driver.constructor =3D function; +} + void qos_node_contains(const char *container, const char *contained, QOSGraphEdgeOptions *opts, ...) { @@ -663,7 +674,7 @@ void qos_node_consumes(const char *consumer, const char= *interface, add_edge(interface, consumer, QEDGE_CONSUMED_BY, opts); } =20 -void qos_graph_node_set_availability(const char *node, bool av) +static void qos_graph_node_set_availability_explicit(const char *node, boo= l av) { QOSGraphEdgeList *elist; QOSGraphNode *n =3D search_node(node); @@ -678,9 +689,46 @@ void qos_graph_node_set_availability(const char *node,= bool av) } QSLIST_FOREACH_SAFE(e, elist, edge_list, next) { if (e->type =3D=3D QEDGE_CONTAINS || e->type =3D=3D QEDGE_PRODUCES= ) { - qos_graph_node_set_availability(e->dest, av); + qos_graph_node_set_availability_explicit(e->dest, av); + } + } +} + +/* + * Behaves as qos_graph_node_set_availability_explicit(), except that the + * former always matches by node name only, whereas this function matches = both + * by node name and node's optional 'qemu_name' field. + */ +void qos_graph_node_set_availability(const char *node, bool av) +{ + GList *l; + QOSGraphEdgeList *elist; + QOSGraphEdge *e, *next; + QOSGraphNode *n; + GList *keys =3D g_hash_table_get_keys(node_table); + + for (l =3D keys; l !=3D NULL; l =3D l->next) { + const gchar *key =3D l->data; + n =3D g_hash_table_lookup(node_table, key); + /* + * node's 'qemu_name' is set if there is more than one device with + * the same QEMU (QMP) device name + */ + const char *node_name =3D n->qemu_name ?: n->name; + if (g_strcmp0(node_name, node) =3D=3D 0) { + n->available =3D av; + elist =3D get_edgelist(n->name); + if (elist) { + QSLIST_FOREACH_SAFE(e, elist, edge_list, next) { + if (e->type =3D=3D QEDGE_CONTAINS || e->type =3D=3D QE= DGE_PRODUCES) + { + qos_graph_node_set_availability_explicit(e->dest, = av); + } + } + } } } + g_list_free(keys); } =20 void qos_graph_foreach_test_path(QOSTestCallback fn) diff --git a/tests/qtest/libqos/qgraph.h b/tests/qtest/libqos/qgraph.h index 5f63d352ca..f472949f68 100644 --- a/tests/qtest/libqos/qgraph.h +++ b/tests/qtest/libqos/qgraph.h @@ -452,6 +452,22 @@ void qos_node_create_machine_args(const char *name, */ void qos_node_create_driver(const char *name, QOSCreateDriverFunc function= ); =20 +/** + * Behaves as qos_node_create_driver() with the extension of allowing to + * specify a different node name vs. associated QEMU device name. + * + * Use this function instead of qos_node_create_driver() if you need to cr= eate + * several instances of the same QEMU device. You are free to choose a cus= tom + * node name, however the chosen node name must always be unique. + * + * @param name: custom, unique name of the node to be created + * @param qemu_name: actual (official) QEMU driver name the node shall be + * associated with + * @param function: driver constructor + */ +void qos_node_create_driver_named(const char *name, const char *qemu_name, + QOSCreateDriverFunc function); + /** * qos_node_contains(): creates one or more edges of type QEDGE_CONTAINS * and adds them to the edge list mapped to @container in the diff --git a/tests/qtest/libqos/qgraph_internal.h b/tests/qtest/libqos/qgra= ph_internal.h index 968fa69450..974985dce9 100644 --- a/tests/qtest/libqos/qgraph_internal.h +++ b/tests/qtest/libqos/qgraph_internal.h @@ -56,6 +56,7 @@ struct QOSGraphNode { bool available; /* set by QEMU via QMP, used during graph walk */ bool visited; /* used during graph walk */ char *name; /* used to identify the node */ + char *qemu_name; /* optional: see qos_node_create_driver_named() */ char *command_line; /* used to start QEMU at test execution */ union { struct { --=20 2.20.1 From nobody Fri May 17 05:54:44 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1611708009; cv=none; d=zohomail.com; s=zohoarc; b=FYSnh5EGURHzEfLD58JE/Et6xKcaYrHiCDsLHI6GxZIqBAaiMhefV0SZlbczWqBXs92ItPEQJ+hMqq7nJAdInJsNudBDNurrYbp4HaOgr1Aw3xQ4nCc6m7OOmq+WCUbOq30j70zxRk3b8vRSAukG84XkP8LsdnKYGp0fXNOTnrs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611708009; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=PFFmgNGyfC+nMCQ95QvPope9mXT2GQdf/3JbIMDlfLo=; b=ARhHrwg5IO8/7yY4S5XeOsQ2cTrIV8y2dU2Q8nLI3ZDJRgAq4wBZQbmQBtGcSIKMr7V5GGlY0veoRAmoR/8q7Nd1jWoEH3Gclp1KcqorfXADpppjvf2JWElQkU8wddxRLzhsLiBoV0fLry1QK+oLY0Wef/jh/8xc+hQX91slMCY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1611708009288879.1271334407509; Tue, 26 Jan 2021 16:40:09 -0800 (PST) Received: from localhost ([::1]:37458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l4YsR-0004fO-4r for importer@patchew.org; Tue, 26 Jan 2021 19:40:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <653a5ef61c5e7d160e4d6294e542c57ea324cee4@lizzy.crudebyte.com>) id 1l4YqQ-0003vm-1y for qemu-devel@nongnu.org; Tue, 26 Jan 2021 19:38:02 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:41355) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <653a5ef61c5e7d160e4d6294e542c57ea324cee4@lizzy.crudebyte.com>) id 1l4YqO-0006xM-Gx for qemu-devel@nongnu.org; Tue, 26 Jan 2021 19:38:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=PFFmgNGyfC+nMCQ95QvPope9mXT2GQdf/3JbIMDlfLo=; b=B9iw+ bhC5gWm8uC08iqMHq4Xm08g+rsmWzLtcXJnZrYWK+x2yriy7MRM2I81uRDFjgMGYizB0RL8Hkq111 CsglRfsLMXfjyCKOpb/eKk46NthOvBo84w4S2GRkxf66z2U3BFdEWefAV5k+hvrpoF/UdBfeB36Nv yOU17Z8z6eFD3lGGbphjuydoqz5Pa5pRmVO1D8OULKPUPvYwv+LO5KOgGHsYjrQRlNPh1pQFevVJU XpHZK78FnZBlJXD9JoTILun1YbPUejEgFgYX3w8KJopI2XqiHwSPrju4ln33XVUJAA5fWCtQPi6pT LSZU8h4TWoAplcSKAbU2mRLYnkoHw==; Message-Id: <653a5ef61c5e7d160e4d6294e542c57ea324cee4.1611704181.git.qemu_oss@crudebyte.com> In-Reply-To: References: Date: Wed, 27 Jan 2021 00:04:22 +0100 Subject: [PATCH 2/5] libqos/qgraph_internal: add qos_printf() and qos_printf_literal() To: qemu-devel@nongnu.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=653a5ef61c5e7d160e4d6294e542c57ea324cee4@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini , Thomas Huth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Reply-to: Christian Schoenebeck From: qemu_oss--- via X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" These two are macros wrapping regular printf() call. They are intended to be used instead of calling printf() directly in order to avoid breaking TAP output format. TAP output format is enabled by using --tap command line argument. Starting with glib 2.62 it is enabled by default. Unfortunately there is currently no public glib API available to check whether TAP output format is enabled. For that reason qos_printf() simply always prepends a '#' character for now. Signed-off-by: Christian Schoenebeck Reviewed-by: Thomas Huth --- tests/qtest/libqos/qgraph_internal.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/qtest/libqos/qgraph_internal.h b/tests/qtest/libqos/qgra= ph_internal.h index 974985dce9..c0025f5ab9 100644 --- a/tests/qtest/libqos/qgraph_internal.h +++ b/tests/qtest/libqos/qgraph_internal.h @@ -255,4 +255,15 @@ void qos_delete_cmd_line(const char *name); */ void qos_graph_node_set_availability(const char *node, bool av); =20 +/* + * Prepends a '#' character in front for not breaking TAP output format. + */ +#define qos_printf(...) printf("# " __VA_ARGS__) + +/* + * Intended for printing something literally, i.e. for appending text as is + * to a line already been started by qos_printf() before. + */ +#define qos_printf_literal printf + #endif --=20 2.20.1 From nobody Fri May 17 05:54:44 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1611707797; cv=none; d=zohomail.com; s=zohoarc; b=gj/bw3S/tf4qyVKMWYf2PO8jqfEq0HMo9u5btfso12OXUNvmuLFIMgG590G6vdhKMyeAWUDS3klefxXEBz3Zo9ti5z1eKcl1tDkWiDU0uSwpztizSyWaMCR7itKkU7o6iW0J9yfLXftWMIMYBI4zYGILKv05r/52KcpkR/+GR9o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611707797; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=BUVJ8zEuDaY9bM/dEoBtgD6L+KGLkJedtreai+3b6RQ=; b=dfmAeyp4EucRxullj55C7o0Kg+dX/apLG+Jtnf3wR1WIMwrSKpgzVr8CQ8Uqco9ClraSUmshWrH+ilGND4/f3SQFNQSHuo9GW/ssK6qpBZp8GkDOkmdpiPXr5shFfEWigklOfJzbJyV9NY082DvOcLRIfe79g/Tp7ZQ9VWkIKns= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1611707797728650.9317018441035; Tue, 26 Jan 2021 16:36:37 -0800 (PST) Received: from localhost ([::1]:60872 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l4Yp2-0002aV-4Z for importer@patchew.org; Tue, 26 Jan 2021 19:36:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <6bffb6e38589fb2c06a2c1b5deed33f3e710fed1@lizzy.crudebyte.com>) id 1l4YoP-0002B8-1O for qemu-devel@nongnu.org; Tue, 26 Jan 2021 19:35:57 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:36151) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <6bffb6e38589fb2c06a2c1b5deed33f3e710fed1@lizzy.crudebyte.com>) id 1l4YoM-00068p-Pl for qemu-devel@nongnu.org; Tue, 26 Jan 2021 19:35:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=BUVJ8zEuDaY9bM/dEoBtgD6L+KGLkJedtreai+3b6RQ=; b=T8if/ hi8wcy7Zed6681C482voJ+zM8dpY1IIW/fz64YMKkvnFHltilXHv/qtqqsVoR4W9WM4Co+5tJKtMq P0NpBk+6d7uefDKBvMJRmbr5tQ1LtCKpKz75ZicLg704TpoTePmD6NgElTKUZDrDrdJbEuclA1gNd ODixH3YMYOOLumqLQ4qETnaveR8R0/yNpUUOJaQQJ5rwTwnK+6k6uJKaFfqyAQ5gCiK2ZoGm1E+UG bBpKxIAtVPi1skuRWcQilMhXAwwuV5IsX5EBhascifXnw9bpXIjfQ2kKit/TrdCxYQHL1Tl32ut+z I2hhvNDgkB9gePBl6/6puPrVL/5IA==; Message-Id: <6bffb6e38589fb2c06a2c1b5deed33f3e710fed1.1611704181.git.qemu_oss@crudebyte.com> In-Reply-To: References: Date: Wed, 27 Jan 2021 00:08:03 +0100 Subject: [PATCH 3/5] tests/qtest/qos-test: dump qos graph if verbose To: qemu-devel@nongnu.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=6bffb6e38589fb2c06a2c1b5deed33f3e710fed1@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini , Thomas Huth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Reply-to: Christian Schoenebeck From: qemu_oss--- via X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If qtests were run in verbose mode (i.e. if --verbose CL argument was provided) then dump the generated qos graph (all nodes and edges, along with their current individual availability status) to stdout, which allows to identify problems in the created qos graph e.g. when writing new qos tests. See API doc comment on function qos_dump_graph() for details. Signed-off-by: Christian Schoenebeck --- tests/qtest/libqos/qgraph.c | 45 +++++++++++++++++++++++++++++++++++++ tests/qtest/libqos/qgraph.h | 20 +++++++++++++++++ tests/qtest/qos-test.c | 3 +++ 3 files changed, 68 insertions(+) diff --git a/tests/qtest/libqos/qgraph.c b/tests/qtest/libqos/qgraph.c index 61faf6b27d..b3b1a31f81 100644 --- a/tests/qtest/libqos/qgraph.c +++ b/tests/qtest/libqos/qgraph.c @@ -805,3 +805,48 @@ void qos_delete_cmd_line(const char *name) node->command_line =3D NULL; } } + +void qos_dump_graph(void) +{ + GList *keys; + GList *l; + QOSGraphEdgeList *list; + QOSGraphEdge *e, *next; + QOSGraphNode *dest_node, *node; + + qos_printf("ALL QGRAPH EDGES: {\n"); + keys =3D g_hash_table_get_keys(edge_table); + for (l =3D keys; l !=3D NULL; l =3D l->next) { + const gchar *key =3D l->data; + qos_printf("\t src=3D'%s'\n", key); + list =3D get_edgelist(key); + QSLIST_FOREACH_SAFE(e, list, edge_list, next) { + dest_node =3D g_hash_table_lookup(node_table, e->dest); + qos_printf("\t\t|-> dest=3D'%s' type=3D%d (node=3D%p)", + e->dest, e->type, dest_node); + if (!dest_node) { + qos_printf_literal(" <------- ERROR !"); + } + qos_printf_literal("\n"); + } + } + g_list_free(keys); + qos_printf("}\n"); + + qos_printf("ALL QGRAPH NODES: {\n"); + keys =3D g_hash_table_get_keys(node_table); + for (l =3D keys; l !=3D NULL; l =3D l->next) { + const gchar *key =3D l->data; + node =3D g_hash_table_lookup(node_table, key); + qos_printf("\t name=3D'%s' ", key); + if (node->qemu_name) { + qos_printf_literal("qemu_name=3D'%s' ", node->qemu_name); + } + qos_printf_literal("type=3D%d cmd_line=3D'%s' [%s]\n", + node->type, node->command_line, + node->available ? "available" : "UNAVAILBLE" + ); + } + g_list_free(keys); + qos_printf("}\n"); +} diff --git a/tests/qtest/libqos/qgraph.h b/tests/qtest/libqos/qgraph.h index f472949f68..07a32535f1 100644 --- a/tests/qtest/libqos/qgraph.h +++ b/tests/qtest/libqos/qgraph.h @@ -586,5 +586,25 @@ QOSGraphObject *qos_machine_new(QOSGraphNode *node, QT= estState *qts); QOSGraphObject *qos_driver_new(QOSGraphNode *node, QOSGraphObject *parent, QGuestAllocator *alloc, void *arg); =20 +/** + * Just for debugging purpose: prints all currently existing nodes and + * edges to stdout. + * + * All qtests add themselves to the overall qos graph by calling qgraph + * functions that add device nodes and edges between the individual graph + * nodes for tests. As the actual graph is assmbled at runtime by the qos + * subsystem, it is sometimes not obvious how the overall graph looks like. + * E.g. when writing new tests it may happen that those new tests are simp= ly + * ignored by the qtest framework. + * + * This function allows to identify problems in the created qgraph. Keep in + * mind: only tests with a path down from the actual test case node (leaf)= up + * to the graph's root node are actually executed by the qtest framework. = And + * the qtest framework uses QMP to automatically check which QEMU drivers = are + * actually currently available, and accordingly qos marks certain pathes = as + * 'unavailable' in such cases (e.g. when QEMU was compiled without suppor= t for + * a certain feature). + */ +void qos_dump_graph(void); =20 #endif diff --git a/tests/qtest/qos-test.c b/tests/qtest/qos-test.c index 8fdf87b183..d98ef78613 100644 --- a/tests/qtest/qos-test.c +++ b/tests/qtest/qos-test.c @@ -322,6 +322,9 @@ int main(int argc, char **argv) qos_set_machines_devices_available(); =20 qos_graph_foreach_test_path(walk_path); + if (g_test_verbose()) { + qos_dump_graph(); + } g_test_run(); qtest_end(); qos_graph_destroy(); --=20 2.20.1 From nobody Fri May 17 05:54:44 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1611708062; cv=none; d=zohomail.com; s=zohoarc; b=lKeWDmS5uGUEJOun+fXq3N5geBkAyp49Sh9C+OSd3bPhP/IbIlxqJ+5zFY37BtMY+29+smcvJAdj494o8KeiNSA1wRPXbqFG0Pr1wFXEPrtEHt3s4DaYgCV9RnbPe+hhjUKjaSHWCRihlF9UUR6c/MS5Pqhc62Tg9dQoBK/UgIg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611708062; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=xJY34z9y4a9luo9WI4JB4/BrWS6UutKjACaKNcoQfdM=; b=ipIVDdM8zkbZhuu8+jdbUCQ7uNY/+4/xgWXSUm2S4pMXqMy4n98+afYEMiDvFyx8359/LdBG6/A/0Yo5fjMEZs48l7pSer/yOEb+lKkPq/4x7cRRBh+eN3A5VliiLaTX78WmiMw2dyQajYBZ8oWp2WEicmX2CmS734ljWxLaIBU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1611708062741962.1411534079367; Tue, 26 Jan 2021 16:41:02 -0800 (PST) Received: from localhost ([::1]:38970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l4YtJ-0005PO-Om for importer@patchew.org; Tue, 26 Jan 2021 19:41:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57370) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <21d77b33c578d80b5bba1068e61fd3562958b3c2@lizzy.crudebyte.com>) id 1l4YrU-0004R4-34 for qemu-devel@nongnu.org; Tue, 26 Jan 2021 19:39:09 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:38823) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <21d77b33c578d80b5bba1068e61fd3562958b3c2@lizzy.crudebyte.com>) id 1l4YrP-0007JD-LF for qemu-devel@nongnu.org; Tue, 26 Jan 2021 19:39:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=xJY34z9y4a9luo9WI4JB4/BrWS6UutKjACaKNcoQfdM=; b=jnzMK Zvnfd6QPe2ISbcOYXjjm4mLEC7zJ7uZXyMIUIOj7oV+WzZ5De8zrSeKKg0/ZcXus+RDkmddiBmagK yv9zMWMKAa6E1EkRxo0wv+rD+u68WADTN35IVdktIhJ9223x/k7o3UubbFV0bZgeCyaCqrnVCliVM QLjE74W+/+j85JsYyg+sCVrsEwhtEntjTGmeUIPyWOgbC0wogQGtB73/mSRXjj1VOYkEgxNFVBkjg avJ8OnplQ0ni3SDA7QoIBW0k6HnBh3532iqLj+EkEMvk7licvqC3RrKp53vTAHN9fn5UlSoUq5S9o uMQ6N3gzKnsYdHfgSwL5TxMzq9eBg==; Message-Id: <21d77b33c578d80b5bba1068e61fd3562958b3c2.1611704181.git.qemu_oss@crudebyte.com> In-Reply-To: References: Date: Wed, 27 Jan 2021 00:17:36 +0100 Subject: [PATCH 4/5] tests/qtest/qos-test: dump environment variables if verbose To: qemu-devel@nongnu.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=21d77b33c578d80b5bba1068e61fd3562958b3c2@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini , Thomas Huth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Reply-to: Christian Schoenebeck From: qemu_oss--- via X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If qtests are run in verbose mode (i.e. if --verbose CL argument was provided) then print all environment variables to stdout before running the individual tests. It is common nowadays, at least being able to output all config vectors in a build chain, especially if it is required to investigate build- and test-issues on foreign/remote machines, which includes environment variables. In the context of writing new test cases this is also useful for finding out whether there are already some existing options for common questions like is there a preferred location for writing test files to? Is there a maximum size for test data? Is there a deadline for running tests? Use qos_printf() instead of g_test_message() to avoid the latter cluttering the output. Signed-off-by: Christian Schoenebeck --- tests/qtest/qos-test.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/qtest/qos-test.c b/tests/qtest/qos-test.c index d98ef78613..b279b6f816 100644 --- a/tests/qtest/qos-test.c +++ b/tests/qtest/qos-test.c @@ -313,9 +313,16 @@ static void walk_path(QOSGraphNode *orig_path, int len) * machine/drivers/test objects * - Cleans up everything */ -int main(int argc, char **argv) +int main(int argc, char **argv, char** envp) { g_test_init(&argc, &argv, NULL); + if (g_test_verbose()) { + qos_printf("ENVIRONMENT VARIABLES: {\n"); + for (char **env =3D envp; *env !=3D 0; env++) { + qos_printf("\t%s\n", *env); + } + qos_printf("}\n"); + } qos_graph_init(); module_call_init(MODULE_INIT_QOM); module_call_init(MODULE_INIT_LIBQOS); --=20 2.20.1 From nobody Fri May 17 05:54:44 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1611708224; cv=none; d=zohomail.com; s=zohoarc; b=lrZnTyymTV9zaVfJ9aFztavMcs93WgpGqNA/OhuK8gCyA5Rl7JgGNZXdiYUYtqXkhrZPwpUBdFHbItzy0oEQdEeisA1FLPQZyjp4K5DwlOTkkvP5W9b5XozGmyAuIvrgCB8UzWiKXe/wKMaSanrnMo1hJXTr5wSdoe3RJqtV2iE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611708224; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=lRzWEo6b7k9+kApoB+89gLCgSlgbKdep1hgOxL6/O8s=; b=Ice+BaDle0jBPVP32W0T3jGJCMmuROK2i1vp4ivZJZWWiQQ4QmkoQ9VkGEeaQ/G5eSa5NCpmBzouvgVJZ05HP1bhsW9KtThuozUOkGfYrb80hXzOcOQ3DWDA8ml491HyVnjnL6NySBHpSgP+H+kGLkdvFYvdo0bAeDb/IKeURbI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1611708224752899.1607062660488; Tue, 26 Jan 2021 16:43:44 -0800 (PST) Received: from localhost ([::1]:43358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l4Yvv-0007F3-JM for importer@patchew.org; Tue, 26 Jan 2021 19:43:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <110bef3595cb841dfa1b86733c174ac9774eb37e@lizzy.crudebyte.com>) id 1l4YsV-00058B-71 for qemu-devel@nongnu.org; Tue, 26 Jan 2021 19:40:11 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:39029) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <110bef3595cb841dfa1b86733c174ac9774eb37e@lizzy.crudebyte.com>) id 1l4YsT-0007ao-OP for qemu-devel@nongnu.org; Tue, 26 Jan 2021 19:40:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=lRzWEo6b7k9+kApoB+89gLCgSlgbKdep1hgOxL6/O8s=; b=MNsvY LWcj1Cz3mE3nQH579Vxuvj7w+H7N/S9rZSdNeTyEANH2ZHcae6pBPBfxMwACW2Dd1E6K3w8rFWBQl J2/WDIl0q4sPe0ttT+l+ru4rAz25sx1nj+pqmMq3oWmGfpLv/2z1OxFIGng2I5JYq1plg6wsqjIFm nZ+oyu8JDWQ5Qqe7ryexKy5EIt5IG4ICG/FKMt4MI1JDuKETYWr0KaSLVQWnrL73/IrE7i7UZmaev rD+yY37wNWyA9fRIpQkhzxXmDrGTa8Xm+W9/9Do6mPYWwpWA+IW6V+/5wAerYETEuieL3tI8Y03uN d/mYptw3dRpS1WaUvDGbuuzKdsBhA==; Message-Id: <110bef3595cb841dfa1b86733c174ac9774eb37e.1611704181.git.qemu_oss@crudebyte.com> In-Reply-To: References: Date: Wed, 27 Jan 2021 00:26:16 +0100 Subject: [PATCH 5/5] tests/qtest/qos-test: dump QEMU command if verbose To: qemu-devel@nongnu.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=110bef3595cb841dfa1b86733c174ac9774eb37e@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini , Thomas Huth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Reply-to: Christian Schoenebeck From: qemu_oss--- via X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If qtests are run in verbose mode (i.e. if --verbose CL argument was provided) then print the assembled qemu command line for each test. Use qos_printf() instead of g_test_message() to avoid the latter cluttering the output. Signed-off-by: Christian Schoenebeck --- tests/qtest/qos-test.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/qtest/qos-test.c b/tests/qtest/qos-test.c index b279b6f816..f97d0a08fd 100644 --- a/tests/qtest/qos-test.c +++ b/tests/qtest/qos-test.c @@ -89,6 +89,9 @@ static void qos_set_machines_devices_available(void) =20 static void restart_qemu_or_continue(char *path) { + if (g_test_verbose()) { + qos_printf("Run QEMU with: '%s'\n", path); + } /* compares the current command line with the * one previously executed: if they are the same, * don't restart QEMU, if they differ, stop previous --=20 2.20.1