1 /* Copyright (c) 2014-2021. The SimGrid Team. All rights reserved. */
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. */
7 #include <simgrid/modelchecker.h>
8 #include <simgrid/s4u.hpp>
11 XBT_LOG_NEW_DEFAULT_CATEGORY(random_bug, "For this example");
13 enum class Behavior { ABORT, ASSERT, PRINTF };
17 /** A fake application with a bug occurring for some random values */
20 int x = MC_random(0, 5);
21 int y = MC_random(0, 5);
23 if (behavior == Behavior::ASSERT) {
24 MC_assert(x != 3 || y != 4);
25 } else if (behavior == Behavior::PRINTF) {
27 XBT_ERROR("Error reached");
28 } else { // behavior == Behavior::ABORT
34 int main(int argc, char* argv[])
36 simgrid::s4u::Engine e(&argc, argv);
37 xbt_assert(argc == 3, "Usage: random-bug raise|assert <platformfile>");
38 if (strcmp(argv[1], "abort") == 0) {
39 XBT_INFO("Behavior: abort");
40 behavior = Behavior::ABORT;
41 } else if (strcmp(argv[1], "assert") == 0) {
42 XBT_INFO("Behavior: assert");
43 behavior = Behavior::ASSERT;
44 } else if (strcmp(argv[1], "printf") == 0) {
45 XBT_INFO("Behavior: printf");
46 behavior = Behavior::PRINTF;
48 xbt_die("Please use either 'abort', 'assert' or 'printf' as first parameter, to specify what to do when the error "
52 e.load_platform(argv[2]);
54 simgrid::s4u::Actor::create("app", simgrid::s4u::Host::by_name("Fafard"), &app);