Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'oldstyle_element_set'
[simgrid.git] / teshsuite / msg / trace / test_trace_integration.c
1 /* Copyright (c) 2009-2010, 2012-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/msg.h"
10 #include "xbt/log.h"
11 #include "xbt/asserts.h"
12
13 XBT_LOG_NEW_DEFAULT_CATEGORY(test_trace_integration,
14                              "Messages specific for this msg example");
15
16 int test_trace(int argc, char *argv[]);
17
18 /** test the trace integration cpu model */
19 int test_trace(int argc, char *argv[])
20 {
21   msg_task_t task;
22   double task_comp_size = 2800;
23   double task_prio = 1.0;
24
25   xbt_assert (argc == 3,"Wrong number of arguments!\nUsage: %s <task computational size in FLOPS> <task priority>", argv[0]);
26
27   task_comp_size = xbt_str_parse_double(argv[1],"Invalid computational size: %s");
28   task_prio = xbt_str_parse_double(argv[2], "Invalid task priority: %s");
29
30   XBT_INFO("Testing the trace integration cpu model: CpuTI");
31   XBT_INFO("Task size: %f", task_comp_size);
32   XBT_INFO("Task prio: %f", task_prio);
33
34   /* Create and execute a single task. */
35   task = MSG_task_create("proc 0", task_comp_size, 0, NULL);
36   MSG_task_set_priority(task, task_prio);
37   MSG_task_execute(task);
38   MSG_task_destroy(task);
39
40   XBT_INFO("Test finished");
41
42   return 0;
43 }
44
45 /** Main function */
46 int main(int argc, char *argv[])
47 {
48   msg_error_t res = MSG_OK;
49
50   /* Verify if the platform xml file was passed by command line. */
51   MSG_init(&argc, argv);
52   xbt_assert(argc > 2, "Usage: %s test_trace_integration_model.xml deployment.xml\n", argv[0]);
53
54   /* Register SimGrid process function. */
55   MSG_function_register("test_trace", test_trace);
56   /* Use the same file for platform and deployment. */
57   MSG_create_environment(argv[1]);
58   MSG_launch_application(argv[2]);
59   /* Run the example. */
60   res = MSG_main();
61
62   return res != MSG_OK;
63 }