-/* Copyright (c) 2017-2021. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2022. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
explicit Replayer(std::vector<std::string> args)
{
const char* actor_name = args[0].c_str();
- simgrid::xbt::replay_runner(actor_name, nullptr);
+ if (args.size() > 1) { // split mode, the trace file was provided in the deployment file
+ const char* trace_filename = args[1].c_str();
+ simgrid::xbt::replay_runner(actor_name, trace_filename);
+ } else { // Merged mode
+ simgrid::xbt::replay_runner(actor_name);
+ }
}
void operator()() const
double clock = simgrid::s4u::Engine::get_clock();
ACT_DEBUG("Entering Close: %s (filename: %s)", NAME.c_str(), file_name.c_str());
- XBT_ATTRIB_UNUSED auto count = opened_files.erase(full_name);
- xbt_assert(count == 1, "File not found in opened files: %s", full_name.c_str());
+ xbt_assert(opened_files.erase(full_name) == 1, "File not found in opened files: %s", full_name.c_str());
log_action(action, simgrid::s4u::Engine::get_clock() - clock);
}
e.register_actor<Replayer>("p0");
e.load_deployment(argv[2]);
+ if (argv[3] != nullptr)
+ xbt_replay_set_tracefile(argv[3]);
+
/* Action registration */
xbt_replay_action_register("open", Replayer::open);
xbt_replay_action_register("read", Replayer::read);
xbt_replay_action_register("close", Replayer::close);
- std::ifstream ifs;
- if (argv[3]) {
- ifs.open(argv[3], std::ifstream::in);
- simgrid::xbt::action_fs = &ifs;
- }
-
e.run();
- simgrid::xbt::action_fs = nullptr;
-
XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
return 0;