Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of framagit.org:simgrid/simgrid
[simgrid.git] / teshsuite / mc / random-bug / random-bug.c
1 /* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include <simgrid/msg.h>
7 #include <simgrid/modelchecker.h>
8
9 #include <stdio.h> /* snprintf */
10
11 XBT_LOG_NEW_DEFAULT_CATEGORY(random_bug, "Application");
12
13 /** An (fake) application with a bug occuring for some random values */
14 static int app(int argc, char *argv[])
15 {
16   int x = MC_random(0, 5);
17   int y = MC_random(0, 5);
18
19   if (MC_is_active()) {
20     MC_assert(x !=3 || y !=4);
21   }
22   if (x ==3 && y ==4) {
23     fprintf(stderr, "Error reached\n");
24   }
25
26   return 0;
27 }
28
29 /** Main function */
30 int main(int argc, char *argv[])
31 {
32   MSG_init(&argc, argv);
33   MSG_function_register("app", &app);
34   MSG_create_environment(argv[1]);
35   MSG_process_create("app", app, NULL, MSG_get_host_by_name("Tremblay"));
36   return MSG_main();
37 }