X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/6310d76aa3949b9e51c9884dc7a141d12af4637e..df278c2d5978eeee48427b054927b67ed9b19750:/testsuite/xbt/graphxml_usage.c diff --git a/testsuite/xbt/graphxml_usage.c b/testsuite/xbt/graphxml_usage.c index 9fbccbdb60..89255a7640 100644 --- a/testsuite/xbt/graphxml_usage.c +++ b/testsuite/xbt/graphxml_usage.c @@ -7,59 +7,152 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include -#include +#include "xbt/module.h" +#include "xbt/sysdep.h" #include "xbt/graph.h" #include "xbt/graphxml.h" -#include "xbt/dynar.h" -#include +#include "xbt/log.h" +XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Logging specific to graphxml test"); +static void *node_label_and_data(xbt_node_t node, const char *label, + const char *data) +{ + char *lbl = xbt_strdup(label); + return lbl; +} +#define free_label free + +static const char *node_name(xbt_node_t n) +{ + return xbt_graph_node_get_data(n); +} + void test(char *graph_file); void test(char *graph_file) { - int i,j; + int test_node_deletion = 0; + int test_edge_deletion = 0; + int test_export_xml = 1; + int test_export_dot = 1; + int test_export_length = 1; + int test_shortest_paths = 1; + int test_topo_sort = 1; + int i, j; unsigned long n; - xbt_dynar_t dynar=NULL; - xbt_dynar_t dynar1=NULL; - xbt_graph_t graph = xbt_graph_read(graph_file); - n=xbt_dynar_length(xbt_graph_get_nodes( graph)); + xbt_dynar_t edges = NULL; + xbt_dynar_t nodes = NULL; + + xbt_graph_t graph = + xbt_graph_read(graph_file, &node_label_and_data, NULL); + + n = xbt_dynar_length(xbt_graph_get_nodes(graph)); - double *d=xbt_graph_get_length_matrix(graph); + if (test_export_xml) { + INFO0("---- Testing XML export. Exporting to testgraph.xml ----"); + xbt_graph_export_graphxml(graph, "testgraph.xml", NULL, NULL, NULL, + NULL); + } + if (test_export_dot) { + INFO0("---- Testing GraphViz export. Exporting to testgraph.dot ----"); + xbt_graph_export_graphviz(graph, "testgraph.dot", node_name, NULL); + } + + if (test_export_length) { + char *buf = NULL; + double *adj = NULL; + + INFO0("---- Dumping Edge lengths ----"); + adj = xbt_graph_get_length_matrix(graph); + buf = calloc(n * 20, sizeof(char)); + for (i = 0; i < n; i++) { + for (j = 0; j < n; j++) { + sprintf(buf + strlen(buf), "%le\t", adj[i * n + j]); + } + INFO1("%s", buf); + buf[0] = '\000'; + } + free(buf); + free(adj); + } + + if (test_shortest_paths) { + char *buf = NULL; + xbt_node_t *route = NULL; - for(i=0;i