[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 03/12] tests/qtest/qos: add qos_dump_graph()
From: |
Christian Schoenebeck |
Subject: |
[PATCH 03/12] tests/qtest/qos: add qos_dump_graph() |
Date: |
Sun, 27 Sep 2020 12:39:17 +0200 |
This new function is purely for debugging purposes. It prints the
current qos graph to stdout and allows to identify problems in the
created qos graph e.g. when writing new qos tests.
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
---
tests/qtest/libqos/qgraph.c | 54 +++++++++++++++++++++++++++++++++++++
tests/qtest/libqos/qgraph.h | 20 ++++++++++++++
2 files changed, 74 insertions(+)
diff --git a/tests/qtest/libqos/qgraph.c b/tests/qtest/libqos/qgraph.c
index 61faf6b27d..e70635750e 100644
--- a/tests/qtest/libqos/qgraph.c
+++ b/tests/qtest/libqos/qgraph.c
@@ -805,3 +805,57 @@ void qos_delete_cmd_line(const char *name)
node->command_line = NULL;
}
}
+
+#define RED(txt) ( \
+ "\033[0;91m" txt \
+ "\033[0m" \
+)
+
+#define GREEN(txt) ( \
+ "\033[0;92m" txt \
+ "\033[0m" \
+)
+
+void qos_dump_graph(void)
+{
+ GList *keys;
+ GList *l;
+ QOSGraphEdgeList *list;
+ QOSGraphEdge *e, *next;
+ QOSGraphNode *dest_node, *node;
+
+ printf("ALL QGRAPH EDGES: {\n");
+ keys = g_hash_table_get_keys(edge_table);
+ for (l = keys; l != NULL; l = l->next) {
+ const gchar *key = l->data;
+ printf("\t src='%s'\n", key);
+ list = get_edgelist(key);
+ QSLIST_FOREACH_SAFE(e, list, edge_list, next) {
+ dest_node = g_hash_table_lookup(node_table, e->dest);
+ printf("\t\t|-> dest='%s' type=%d (node=%p)",
+ e->dest, e->type, dest_node);
+ if (!dest_node) {
+ printf(RED(" <------- ERROR !"));
+ }
+ printf("\n");
+ }
+ }
+ g_list_free(keys);
+ printf("}\n");
+
+ printf("ALL QGRAPH NODES: {\n");
+ keys = g_hash_table_get_keys(node_table);
+ for (l = keys; l != NULL; l = l->next) {
+ const gchar *key = l->data;
+ node = g_hash_table_lookup(node_table, key);
+ printf("\t name='%s' ", key);
+ if (node->qemu_name) {
+ printf("qemu_name='%s' ", node->qemu_name);
+ }
+ printf("type=%d cmd_line='%s' [%s]\n",
+ node->type, node->command_line,
+ node->available ? GREEN("available") : RED("UNAVAILBLE"));
+ }
+ g_list_free(keys);
+ 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,
QTestState *qts);
QOSGraphObject *qos_driver_new(QOSGraphNode *node, QOSGraphObject *parent,
QGuestAllocator *alloc, void *arg);
+/**
+ * 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 simply
+ * 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 support for
+ * a certain feature).
+ */
+void qos_dump_graph(void);
#endif
--
2.20.1
- [PATCH 05/12] tests/qtest/qos-test: add QTEST_DUMP_ENV environment variable, (continued)
- [PATCH 05/12] tests/qtest/qos-test: add QTEST_DUMP_ENV environment variable, Christian Schoenebeck, 2020/09/27
- [PATCH 12/12] tests/9pfs: add local Tmkdir test, Christian Schoenebeck, 2020/09/27
- [PATCH 06/12] tests/qtest/qos-test: add environment variable QTEST_DEBUG, Christian Schoenebeck, 2020/09/27
- [PATCH 07/12] test/9pfs: change export tag name to qtest-synth, Christian Schoenebeck, 2020/09/27
- [PATCH 04/12] tests/qtest/qos-test: new QTEST_DUMP_GRAPH environment variable, Christian Schoenebeck, 2020/09/27
- [PATCH 02/12] tests/qtest/qgraph: add qos_node_create_driver_named(), Christian Schoenebeck, 2020/09/27
- [PATCH 01/12] tests/qtest/qgraph: add qemu_name to QOSGraphNode, Christian Schoenebeck, 2020/09/27
- [PATCH 09/12] tests/9pfs: introduce local tests, Christian Schoenebeck, 2020/09/27
- [PATCH 03/12] tests/qtest/qos: add qos_dump_graph(),
Christian Schoenebeck <=
- [PATCH 08/12] tests/9pfs: refactor test names and test devices, Christian Schoenebeck, 2020/09/27
[PATCH 10/12] tests/9pfs: wipe local 9pfs test directory, Christian Schoenebeck, 2020/09/27
[PATCH 11/12] tests/9pfs: add virtio_9p_test_path(), Christian Schoenebeck, 2020/09/27