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