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