Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Removes the gras_config.h inclusion, adds the portable.h inclusion for win32 portability.
[simgrid.git] / testsuite / surf / trace_usage.c
1 /*      $Id$     */
2
3 /* A few tests for the trace library                                       */
4
5 /* Copyright (c) 2004 Arnaud Legrand. All rights reserved.                  */
6
7 /* This program is free software; you can redistribute it and/or modify it
8  * under the terms of the license (GNU LGPL) which comes with this package. */
9
10 #include <stdlib.h>
11 #include <stdio.h>
12 #include <string.h>
13 #include "surf/trace_mgr.h"
14 #include "surf/surf.h"
15
16 #include "xbt/log.h"
17 XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test,"Messages specific for surf example");
18
19 void test(void);
20 void test(void)
21 {
22   tmgr_history_t history = tmgr_history_new();
23   tmgr_trace_t trace_A = tmgr_trace_new("trace_A.txt");
24   tmgr_trace_t trace_B = tmgr_trace_new("trace_B.txt");
25   double next_event_date = -1.0;
26   double value = -1.0;
27   char *resource = NULL;
28   char *host_A = strdup("Host A");
29   char *host_B = strdup("Host B");
30
31   tmgr_history_add_trace(history, trace_A, 1.0, 2, host_A);
32   tmgr_history_add_trace(history, trace_B, 0.0, 0, host_B);
33
34   while ((next_event_date = tmgr_history_next_date(history)) != -1.0) {
35     DEBUG1("%g" " : \n", next_event_date);
36     while (tmgr_history_get_next_event_leq(history, next_event_date,
37                                            &value, (void **) &resource)) {
38       DEBUG2("\t %s : " "%g" "\n", resource, value);
39     }
40     if (next_event_date > 1000)
41       break;
42   }
43
44   tmgr_history_free(history);
45   free(host_B);
46   free(host_A);
47 }
48
49
50 int main(int argc, char **argv)
51 {
52   surf_init(&argc,argv);
53   test();
54   surf_exit();
55   return 0;
56 }