Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add a test reproducing the issue experienced by Luke Bertot
[simgrid.git] / teshsuite / simdag / platforms / basic_parsing_test.c
1 /* Copyright (c) 2008-2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include "simdag/simdag.h"
10 #include "surf/surf_private.h"
11
12 extern routing_platf_t routing_platf;
13
14 int main(int argc, char **argv)
15 {
16   /* initialisation of SD */
17
18   SD_workstation_t w1, w2;
19   const SD_workstation_t *workstations;
20   const SD_link_t *route;
21   const char *name1;
22   const char *name2;
23   int route_size, i, j, k;
24   int list_size;
25
26 #ifdef _XBT_WIN32
27   setbuf(stderr, NULL);
28   setbuf(stdout, NULL);
29 #else
30   setvbuf(stdout, NULL, _IOLBF, 0);
31 #endif
32
33   SD_init(&argc, argv);
34
35   /* creation of the environment */
36   SD_create_environment(argv[1]);
37   printf("Workstation number: %d, link number: %d\n",
38          SD_workstation_get_number(), SD_link_get_number());
39
40   if (argc >= 3) {
41     if (!strcmp(argv[2], "ONE_LINK")) {
42       workstations = SD_workstation_get_list();
43       w1 = workstations[0];
44       w2 = workstations[1];
45       name1 = SD_workstation_get_name(w1);
46       name2 = SD_workstation_get_name(w2);
47
48       printf("Route between %s and %s\n", name1, name2);
49       route = SD_route_get_list(w1, w2);
50       route_size = SD_route_get_size(w1, w2);
51       printf("Route size %d\n", route_size);
52       for (i = 0; i < route_size; i++) {
53       printf("  Link %s: latency = %f, bandwidth = %f\n",
54            SD_link_get_name(route[i]),
55            SD_link_get_current_latency(route[i]),
56            SD_link_get_current_bandwidth(route[i]));
57       }
58       printf("Route latency = %f, route bandwidth = %f\n",
59          SD_route_get_current_latency(w1, w2),
60          SD_route_get_current_bandwidth(w1, w2));
61     }
62     if (!strcmp(argv[2], "FULL_LINK")) {
63       workstations = SD_workstation_get_list();
64       list_size = SD_workstation_get_number();
65       for (i = 0; i < list_size; i++) {
66       w1 = workstations[i];
67       name1 = SD_workstation_get_name(w1);
68       for (j = 0; j < list_size; j++) {
69         w2 = workstations[j];
70         name2 = SD_workstation_get_name(w2);
71         printf("Route between %s and %s\n", name1, name2);
72         route = SD_route_get_list(w1, w2);
73         route_size = SD_route_get_size(w1, w2);
74         printf("  Route size %d\n", route_size);
75         for (k = 0; k < route_size; k++) {
76         printf("  Link %s: latency = %f, bandwidth = %f\n",
77              SD_link_get_name(route[k]),
78              SD_link_get_current_latency(route[k]),
79              SD_link_get_current_bandwidth(route[k]));
80         }
81         printf("  Route latency = %f, route bandwidth = %f\n",
82            SD_route_get_current_latency(w1, w2),
83            SD_route_get_current_bandwidth(w1, w2));
84       }
85       }
86     }
87     if (!strcmp(argv[2], "PROP")) {
88       printf("SG_TEST_mem: %s\n",
89           SD_workstation_get_property_value(SD_workstation_get_by_name("host1"),
90           "SG_TEST_mem")
91           );
92       printf("Author: %s\n", SD_as_router_get_property_value("AS0", "author"));
93       printf("AS1: %s\n", SD_as_router_get_property_value("AS1", "name"));
94       printf("AS2: %s\n", SD_as_router_get_property_value("AS2", "name"));
95     }
96   }
97
98   SD_exit();
99   return 0;
100 }