Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
all DHT examples are now called dht-<protocol>
[simgrid.git] / examples / simdag / dot / dot_test2.c
1 /* simple test trying to load a DOT file.                                   */
2
3 /* Copyright (c) 2010-2016. The SimGrid Team.
4  * All rights reserved.                                                     */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 #include "simgrid/simdag.h"
10 #include <stdio.h>
11
12 XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Logging specific to this SimDag example");
13
14 int main(int argc, char **argv)
15 {
16   xbt_dynar_t dot;
17   unsigned int cursor;
18   SD_task_t task, *dot_as_array=NULL;
19
20   /* SD initialization */
21   SD_init(&argc, argv);
22
23   /* Check our arguments */
24   xbt_assert(argc > 1, "Usage: %s dot_file", argv[0]);
25
26   /* load the DOT file */
27   dot = SD_dotload(argv[1]);
28
29   /* Display all the tasks */
30   XBT_INFO("------------------- Display all tasks of the loaded DAG ---------------------------");
31   xbt_dynar_foreach(dot, cursor, task) {
32       SD_task_dump(task);
33     }
34
35   XBT_INFO("--------------------- Transform the dynar into an array ---------------------------");
36   cursor=0;
37   dot_as_array = (SD_task_t*) xbt_dynar_to_array(dot);
38   XBT_INFO("----------------------------- dump tasks again ------------------------------------");
39   while ((task=dot_as_array[cursor++])){
40     SD_task_dump(task);
41   }
42
43   cursor=0;
44   while ((task=dot_as_array[cursor++])){
45     SD_task_destroy(task);
46   }
47
48   free(dot_as_array);
49
50   /* exit */
51   SD_exit();
52   return 0;
53 }