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/internal_config.h"
8 #include "src/mc/explo/Exploration.hpp"
9 #include "src/mc/mc_config.hpp"
10 #include "src/mc/mc_exit.hpp"
13 #include "smpi/smpi.h"
20 int main(int argc, char** argv)
22 xbt_assert(argc >= 2, "Missing arguments");
24 // Currently, we need this before sg_config_init:
25 _sg_do_model_check = 1;
27 // The initialization function can touch argv.
28 // We make a copy of argv before modifying it in order to pass the original value to the model-checked application:
29 std::vector<char*> argv_copy{argv, argv + argc + 1};
31 xbt_log_init(&argc, argv);
33 smpi_init_options(); // only performed once
35 sg_config_init(&argc, argv);
37 simgrid::mc::CheckerAlgorithm algo;
38 if (_sg_mc_comms_determinism || _sg_mc_send_determinism)
39 algo = simgrid::mc::CheckerAlgorithm::CommDeterminism;
40 else if (_sg_mc_unfolding_checker)
41 algo = simgrid::mc::CheckerAlgorithm::UDPOR;
42 else if (_sg_mc_property_file.get().empty())
43 algo = simgrid::mc::CheckerAlgorithm::Safety;
45 algo = simgrid::mc::CheckerAlgorithm::Liveness;
47 int res = SIMGRID_MC_EXIT_SUCCESS;
48 std::unique_ptr<simgrid::mc::Exploration> checker{simgrid::mc::Api::get().initialize(argv_copy.data(), algo)};
51 } catch (const simgrid::mc::DeadlockError&) {
52 res = SIMGRID_MC_EXIT_DEADLOCK;
53 } catch (const simgrid::mc::TerminationError&) {
54 res = SIMGRID_MC_EXIT_NON_TERMINATION;
55 } catch (const simgrid::mc::LivenessError&) {
56 res = SIMGRID_MC_EXIT_LIVENESS;
58 simgrid::mc::Api::get().s_close();
59 checker.release(); // FIXME: this line should not exist, but it segfaults in liveness