1 /* synchro_crashtest -- tries to crash the logging mechanism by doing parallel logs*/
3 /* Copyright (c) 2007-2022. The SimGrid Team. All rights reserved. */
5 /* This program is free software; you can redistribute it and/or modify it
6 * under the terms of the license (GNU LGPL) which comes with this package. */
8 #include "simgrid/s4u/Engine.hpp"
13 XBT_LOG_NEW_DEFAULT_CATEGORY(synchro_crashtest, "Logs of this example");
15 constexpr int test_amount = 99; /* Up to 99 to not break the logs (and thus the testing mechanism) */
16 constexpr int crasher_amount = 99; /* Up to 99 to not break the logs (and thus the testing mechanism) */
18 constexpr bool more_info = false; /* SET IT TO TRUE TO GET MORE INFO */
20 /* Code ran by each thread */
21 static void crasher_thread(int id)
23 for (int i = 0; i < test_amount; i++) {
25 XBT_INFO("%03d (%02d|%02d|%02d|%02d|%02d|%02d|%02d|%02d|%02d)", test_amount - i, id, id, id, id, id, id, id, id,
28 XBT_INFO("XXX (XX|XX|XX|XX|XX|XX|XX|XX|XX)");
32 int main(int argc, char* argv[])
34 simgrid::s4u::Engine e(&argc, argv);
36 std::array<std::thread, crasher_amount> crashers;
40 for (std::thread& thr : crashers)
41 thr = std::thread(crasher_thread, id++);
44 for (std::thread& thr : crashers)