1 /* Copyright (c) 2015-2022. 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. */
6 #include "simgrid/sg_config.hpp"
7 #include "src/mc/explo/Exploration.hpp"
8 #include "src/mc/mc_config.hpp"
9 #include "src/mc/mc_exit.hpp"
12 #include "smpi/smpi.h"
15 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(mc);
17 int main(int argc, char** argv)
19 xbt_assert(argc >= 2, "Missing arguments");
21 // Currently, we need this before sg_config_init:
22 _sg_do_model_check = 1;
24 // The initialization function can touch argv.
25 // We make a copy of argv before modifying it in order to pass the original value to the model-checked application:
26 std::vector<char*> argv_copy{argv, argv + argc + 1};
28 xbt_log_init(&argc, argv);
30 smpi_init_options(); // that's OK to call it twice, and we need it ASAP
32 sg_config_init(&argc, argv);
34 simgrid::mc::Exploration* explo;
35 if (_sg_mc_comms_determinism || _sg_mc_send_determinism)
36 explo = simgrid::mc::create_communication_determinism_checker(argv_copy);
37 else if (_sg_mc_unfolding_checker)
38 explo = simgrid::mc::create_udpor_checker(argv_copy);
39 else if (_sg_mc_property_file.get().empty())
40 explo = simgrid::mc::create_dfs_exploration(argv_copy);
42 explo = simgrid::mc::create_liveness_checker(argv_copy);
44 std::unique_ptr<simgrid::mc::Exploration> checker{explo};
48 } catch (const simgrid::mc::DeadlockError&) {
49 return SIMGRID_MC_EXIT_DEADLOCK;
50 } catch (const simgrid::mc::TerminationError&) {
51 return SIMGRID_MC_EXIT_NON_TERMINATION;
52 } catch (const simgrid::mc::LivenessError&) {
53 return SIMGRID_MC_EXIT_LIVENESS;
55 return SIMGRID_MC_EXIT_SUCCESS;