1 /* A few tests for the trace library */
3 /* Copyright (c) 2004, 2005, 2006, 2009, 2010. The SimGrid Team.
4 * All rights reserved. */
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. */
15 #include "surf/trace_mgr.h"
16 #include "surf/surf.h"
19 XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test,
20 "Messages specific for surf example");
25 tmgr_history_t history = tmgr_history_new();
26 tmgr_trace_t trace_A = tmgr_trace_new("trace_A.txt");
27 tmgr_trace_t trace_B = tmgr_trace_new("trace_B.txt");
28 double next_event_date = -1.0;
30 char *resource = NULL;
31 char *host_A = strdup("Host A");
32 char *host_B = strdup("Host B");
34 tmgr_history_add_trace(history, trace_A, 1.0, 2, host_A);
35 tmgr_history_add_trace(history, trace_B, 0.0, 0, host_B);
37 while ((next_event_date = tmgr_history_next_date(history)) != -1.0) {
38 XBT_DEBUG("%g" " : \n", next_event_date);
39 while (tmgr_history_get_next_event_leq(history, next_event_date,
40 &value, (void **) &resource)) {
41 XBT_DEBUG("\t %s : " "%g" "\n", resource, value);
43 if (next_event_date > 1000)
47 tmgr_history_free(history);
57 int main(int argc, char **argv)
59 surf_init(&argc, argv);