Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
40ebac31e462649bb5bd0f6397ed010860d8f87f
[simgrid.git] / teshsuite / simdag / platforms / basic_parsing_test.c
1 /* Copyright (c) 2008-2015. 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 "simgrid/simdag.h"
10
11 int main(int argc, char **argv)
12 {
13   /* SD initialization */
14
15   SD_workstation_t w1, w2;
16   const SD_workstation_t *workstations;
17   const SD_link_t *route;
18   const char *name1;
19   const char *name2;
20   int route_size, i, j, k;
21   int list_size;
22
23 #ifdef _XBT_WIN32
24   setbuf(stderr, NULL);
25   setbuf(stdout, NULL);
26 #else
27   setvbuf(stdout, NULL, _IOLBF, 0);
28 #endif
29
30   SD_init(&argc, argv);
31
32   /* creation of the environment */
33   SD_create_environment(argv[1]);
34   printf("Workstation number: %d, link number: %d\n",
35          SD_workstation_get_number(), SD_link_get_number());
36
37   if (argc >= 3) {
38     if (!strcmp(argv[2], "ONE_LINK")) {
39       workstations = SD_workstation_get_list();
40       w1 = workstations[0];
41       w2 = workstations[1];
42       name1 = SD_workstation_get_name(w1);
43       name2 = SD_workstation_get_name(w2);
44
45       printf("Route between %s and %s\n", name1, name2);
46       route = SD_route_get_list(w1, w2);
47       route_size = SD_route_get_size(w1, w2);
48       printf("Route size %d\n", route_size);
49       for (i = 0; i < route_size; i++) {
50       printf("  Link %s: latency = %f, bandwidth = %f\n",
51            SD_link_get_name(route[i]),
52            SD_link_get_current_latency(route[i]),
53            SD_link_get_current_bandwidth(route[i]));
54       }
55       printf("Route latency = %f, route bandwidth = %f\n",
56          SD_route_get_current_latency(w1, w2),
57          SD_route_get_current_bandwidth(w1, w2));
58     }
59     if (!strcmp(argv[2], "FULL_LINK")) {
60       workstations = SD_workstation_get_list();
61       list_size = SD_workstation_get_number();
62       for (i = 0; i < list_size; i++) {
63       w1 = workstations[i];
64       name1 = SD_workstation_get_name(w1);
65       for (j = 0; j < list_size; j++) {
66         w2 = workstations[j];
67         name2 = SD_workstation_get_name(w2);
68         printf("Route between %s and %s\n", name1, name2);
69         route = SD_route_get_list(w1, w2);
70         route_size = SD_route_get_size(w1, w2);
71         printf("  Route size %d\n", route_size);
72         for (k = 0; k < route_size; k++) {
73         printf("  Link %s: latency = %f, bandwidth = %f\n",
74              SD_link_get_name(route[k]),
75              SD_link_get_current_latency(route[k]),
76              SD_link_get_current_bandwidth(route[k]));
77         }
78         printf("  Route latency = %f, route bandwidth = %f\n",
79            SD_route_get_current_latency(w1, w2),
80            SD_route_get_current_bandwidth(w1, w2));
81       }
82       }
83     }
84     if (!strcmp(argv[2], "PROP")) {
85       printf("SG_TEST_mem: %s\n",
86           SD_workstation_get_property_value(SD_workstation_get_by_name("host1"),
87           "SG_TEST_mem")
88           );
89       printf("Author: %s\n", SD_as_router_get_property_value("AS0", "author"));
90       printf("AS1: %s\n", SD_as_router_get_property_value("AS1", "name"));
91       printf("AS2: %s\n", SD_as_router_get_property_value("AS2", "name"));
92     }
93   }
94
95   SD_exit();
96   return 0;
97 }