namespace simgrid::mc {
-simgrid::mc::Exploration* Api::initialize(char** argv, const std::unordered_map<std::string, std::string>& env,
- simgrid::mc::ExplorationAlgorithm algo)
-{
- remote_app_ = std::make_unique<simgrid::mc::RemoteApp>([argv, &env] {
- int i = 1;
- while (argv[i] != nullptr && argv[i][0] == '-')
- i++;
-
- for (auto const& [key, val] : env) {
- XBT_INFO("setenv '%s'='%s'", key.c_str(), val.c_str());
- setenv(key.c_str(), val.c_str(), 1);
- }
- xbt_assert(argv[i] != nullptr,
- "Unable to find a binary to exec on the command line. Did you only pass config flags?");
- execvp(argv[i], argv + i);
- xbt_die("The model-checked process failed to exec(%s): %s", argv[i], strerror(errno));
- });
-
- simgrid::mc::Exploration* explo;
- switch (algo) {
- case ExplorationAlgorithm::CommDeterminism:
- explo = simgrid::mc::create_communication_determinism_checker(*(remote_app_.get()));
- break;
-
- case ExplorationAlgorithm::UDPOR:
- explo = simgrid::mc::create_udpor_checker(*(remote_app_.get()));
- break;
-
- case ExplorationAlgorithm::Safety:
- explo = simgrid::mc::create_dfs_exploration(*(remote_app_.get()));
- break;
-
- case ExplorationAlgorithm::Liveness:
- explo = simgrid::mc::create_liveness_checker(*(remote_app_.get()));
- break;
-
- default:
- THROW_IMPOSSIBLE;
- }
-
- mc_model_checker->set_exploration(explo);
- return explo;
-}
-
-
std::size_t Api::get_remote_heap_bytes() const
{
RemoteProcess& process = mc_model_checker->get_remote_process();
#include <memory>
#include <unistd.h>
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(mc);
+
static simgrid::config::Flag<std::string> _sg_mc_setenv{
"model-check/setenv", "Extra environment variables to pass to the child process (ex: 'AZE=aze;QWE=qwe').", "",
[](std::string_view value) {
token.c_str());
environment[kv[0]] = kv[1];
}
+ auto remote_app = std::make_unique<simgrid::mc::RemoteApp>([argv_copy, &environment] {
+ int i = 1;
+ while (argv_copy[i] != nullptr && argv_copy[i][0] == '-')
+ i++;
+
+ for (auto const& [key, val] : environment) {
+ XBT_INFO("setenv '%s'='%s'", key.c_str(), val.c_str());
+ setenv(key.c_str(), val.c_str(), 1);
+ }
+ xbt_assert(argv_copy[i] != nullptr,
+ "Unable to find a binary to exec on the command line. Did you only pass config flags?");
+ execvp(argv_copy[i], argv_copy.data() + i);
+ xbt_die("The model-checked process failed to exec(%s): %s", argv_copy[i], strerror(errno));
+ });
+
+ simgrid::mc::Exploration* explo;
+ switch (algo) {
+ case simgrid::mc::ExplorationAlgorithm::CommDeterminism:
+ explo = simgrid::mc::create_communication_determinism_checker(*remote_app.get());
+ break;
+
+ case simgrid::mc::ExplorationAlgorithm::UDPOR:
+ explo = simgrid::mc::create_udpor_checker(*remote_app.get());
+ break;
- int res = SIMGRID_MC_EXIT_SUCCESS;
- std::unique_ptr<simgrid::mc::Exploration> checker{
- simgrid::mc::Api::get().initialize(argv_copy.data(), environment, algo)};
+ case simgrid::mc::ExplorationAlgorithm::Safety:
+ explo = simgrid::mc::create_dfs_exploration(*remote_app.get());
+ break;
+
+ case simgrid::mc::ExplorationAlgorithm::Liveness:
+ explo = simgrid::mc::create_liveness_checker(*remote_app.get());
+ break;
+
+ default:
+ THROW_IMPOSSIBLE;
+ }
+ mc_model_checker->set_exploration(explo);
+ std::unique_ptr<simgrid::mc::Exploration> checker{explo};
try {
checker->run();
} catch (const simgrid::mc::DeadlockError&) {
- res = SIMGRID_MC_EXIT_DEADLOCK;
+ return SIMGRID_MC_EXIT_DEADLOCK;
} catch (const simgrid::mc::TerminationError&) {
- res = SIMGRID_MC_EXIT_NON_TERMINATION;
+ return SIMGRID_MC_EXIT_NON_TERMINATION;
} catch (const simgrid::mc::LivenessError&) {
- res = SIMGRID_MC_EXIT_LIVENESS;
+ return SIMGRID_MC_EXIT_LIVENESS;
}
- return res;
+ return SIMGRID_MC_EXIT_SUCCESS;
}