1 /* Copyright (c) 2015-2021. The SimGrid Team.
2 * All rights reserved. */
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. */
7 #include "simgrid/sg_config.hpp"
8 #include "src/mc/checker/Checker.hpp"
9 #include "src/mc/mc_config.hpp"
10 #include "src/mc/mc_exit.hpp"
11 #include "src/internal_config.h"
14 #include "smpi/smpi.h"
21 using api = simgrid::mc::Api;
24 char** argvdup(int argc, char** argv)
26 auto* argv_copy = new char*[argc + 1];
27 std::memcpy(argv_copy, argv, sizeof(char*) * argc);
28 argv_copy[argc] = nullptr;
32 int main(int argc, char** argv)
35 xbt_die("Missing arguments.\n");
37 // Currently, we need this before sg_config_init:
38 _sg_do_model_check = 1;
40 // The initialization function can touch argv.
41 // We make a copy of argv before modifying it in order to pass the original value to the model-checked application:
42 char** argv_copy = argvdup(argc, argv);
44 xbt_log_init(&argc, argv);
46 smpi_init_options(); // only performed once
48 sg_config_init(&argc, argv);
50 simgrid::mc::CheckerAlgorithm algo;
51 if (_sg_mc_comms_determinism || _sg_mc_send_determinism)
52 algo = simgrid::mc::CheckerAlgorithm::CommDeterminism;
53 else if (_sg_mc_unfolding_checker)
54 algo = simgrid::mc::CheckerAlgorithm::UDPOR;
55 else if (_sg_mc_property_file.get().empty())
56 algo = simgrid::mc::CheckerAlgorithm::Safety;
58 algo = simgrid::mc::CheckerAlgorithm::Liveness;
60 int res = SIMGRID_MC_EXIT_SUCCESS;
61 auto checker = api::get().initialize(argv_copy, algo);
64 } catch (const simgrid::mc::DeadlockError&) {
65 res = SIMGRID_MC_EXIT_DEADLOCK;
66 } catch (const simgrid::mc::TerminationError&) {
67 res = SIMGRID_MC_EXIT_NON_TERMINATION;
68 } catch (const simgrid::mc::LivenessError&) {
69 res = SIMGRID_MC_EXIT_LIVENESS;