Logo AND Algorithmique Numérique Distribuée

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