Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge pull request #200 from Takishipp/clear_fct
[simgrid.git] / teshsuite / mc / random-bug / random-bug.c
1 /* Copyright (c) 2014-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 <simgrid/msg.h>
8 #include <simgrid/modelchecker.h>
9
10 XBT_LOG_NEW_DEFAULT_CATEGORY(random_bug, "Application");
11
12 /** An (fake) application with a bug occuring for some random values */
13 static int app(int argc, char *argv[])
14 {
15   int x = MC_random(0, 5);
16   int y = MC_random(0, 5);
17
18   if (MC_is_active()) {
19     MC_assert(x !=3 || y !=4);
20   }
21   if (x ==3 && y ==4) {
22     fprintf(stderr, "Error reached\n");
23   }
24
25   return 0;
26 }
27
28 /** Main function */
29 int main(int argc, char *argv[])
30 {
31   MSG_init(&argc, argv);
32   MSG_function_register("app", &app);
33   MSG_create_environment(argv[1]);
34   MSG_process_create("app", app, NULL, MSG_get_host_by_name("Tremblay"));
35   return MSG_main();
36 }