{
return get_issuer() == other->get_issuer();
}
+void RandomSimcall::serialize(Simcall& type, char* buffer)
+{
+ type = Simcall::RANDOM;
+ std::stringstream stream;
+
+ stream << min_ << ' ' << max_;
+ strcpy(buffer, stream.str().c_str());
+}
+
bool MutexSimcall::depends(SimcallObserver* other)
{
if (dynamic_cast<RandomSimcall*>(other) != nullptr)
res->next_value_ = next_value_;
return res;
}
- void serialize(Simcall& type, char* buffer) override { type = Simcall::RANDOM; }
+ void serialize(Simcall& type, char* buffer) override;
int get_max_consider() const override;
void prepare(int times_considered) override;
std::string dot_label(int times_considered) const override;
#include "src/mc/api/Transition.hpp"
#include "xbt/asserts.h"
+#include "xbt/string.hpp"
#include <simgrid/config.h>
+
#if SIMGRID_HAVE_MC
#include "src/mc/ModelChecker.hpp"
#endif
mc_model_checker->wait_for_requests();
#endif
}
+std::string RandomTransition::to_string(bool verbose)
+{
+ return xbt::string_printf("Random([%d;%d] ~> %d)", min_, max_, times_considered_);
+}
+
+RandomTransition::RandomTransition(aid_t issuer, int times_considered, char* buffer)
+ : Transition(issuer, times_considered)
+{
+ std::stringstream stream(buffer);
+ stream >> min_ >> max_;
+}
} // namespace mc
} // namespace simgrid
static unsigned long get_replayed_transitions() { return replayed_transitions_; }
};
+class RandomTransition : public Transition {
+ int min_;
+ int max_;
+
+public:
+ std::string to_string(bool verbose) override;
+ RandomTransition(aid_t issuer, int times_considered, char* buffer);
+ bool depends(const Transition* other) const override { return false; } // Independent with any other transition
+};
+
} // namespace mc
} // namespace simgrid
if (aid_ == other->aid_)
return false;
+ if (dynamic_cast<const RandomTransition*>(other) != nullptr)
+ return false; // Random is indep with any transition
+
if (auto* send = dynamic_cast<const CommSendTransition*>(other))
return send->depends(this);
if (aid_ == other->aid_)
return false;
+ if (dynamic_cast<const RandomTransition*>(other) != nullptr)
+ return false; // Random is indep with any transition
+
if (const auto* other_irecv = dynamic_cast<const CommRecvTransition*>(other))
return mbox_ == other_irecv->mbox_;
if (aid_ == other->aid_)
return false;
+ if (dynamic_cast<const RandomTransition*>(other) != nullptr)
+ return false; // Random is indep with any transition
+
if (const auto* other_isend = dynamic_cast<const CommSendTransition*>(other))
return mbox_ == other_isend->mbox_;
return new CommRecvTransition(issuer, times_considered, buffer);
case kernel::actor::SimcallObserver::Simcall::ISEND:
return new CommSendTransition(issuer, times_considered, buffer);
+
+ case kernel::actor::SimcallObserver::Simcall::RANDOM:
+ return new RandomTransition(issuer, times_considered, buffer);
+
case kernel::actor::SimcallObserver::Simcall::UNKNOWN:
return new Transition(issuer, times_considered);
default:
> [ 0.000000] (0:maestro@) *** PROPERTY NOT VALID ***
> [ 0.000000] (0:maestro@) **************************
> [ 0.000000] (0:maestro@) Counter-example execution trace:
-> [ 0.000000] (0:maestro@) [(1)Fafard (app)] MC_RANDOM(3)
-> [ 0.000000] (0:maestro@) [(1)Fafard (app)] MC_RANDOM(4)
+> [ 0.000000] (0:maestro@) Random([0;5] ~> 3)
+> [ 0.000000] (0:maestro@) Random([0;5] ~> 4)
> [ 0.000000] (0:maestro@) Path = 1/3;1/4
> [ 0.000000] (0:maestro@) Expanded states = 27
> [ 0.000000] (0:maestro@) Visited states = 68
-> [ 0.000000] (0:maestro@) Executed transitions = 46
+> [ 0.000000] (0:maestro@) Executed transitions = 27
! expect return 6
# because SIMGRID_MC_EXIT_PROGRAM_CRASH = 6
> [ 0.000000] (0:maestro@) **************************
> [ 0.000000] (0:maestro@) From signal: Aborted
> [ 0.000000] (0:maestro@) Counter-example execution trace:
-> [ 0.000000] (0:maestro@) [(1)Fafard (app)] MC_RANDOM(3)
-> [ 0.000000] (0:maestro@) [(1)Fafard (app)] MC_RANDOM(4)
+> [ 0.000000] (0:maestro@) Random([0;5] ~> 3)
+> [ 0.000000] (0:maestro@) Random([0;5] ~> 4)
> [ 0.000000] (0:maestro@) Path = 1/3;1/4
> [ 0.000000] (0:maestro@) Expanded states = 27
> [ 0.000000] (0:maestro@) Visited states = 68
-> [ 0.000000] (0:maestro@) Executed transitions = 46
+> [ 0.000000] (0:maestro@) Executed transitions = 27
> [ 0.000000] (0:maestro@) Stack trace not displayed because you passed --log=no_loc
$ ${bindir:=.}/../../../bin/simgrid-mc ${bindir:=.}/random-bug printf ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%a@%h)%e%m%n" --log=xbt_cfg.thresh:warning
> [ 0.000000] (0:maestro@) No property violation found.
> [ 0.000000] (0:maestro@) Expanded states = 43
> [ 0.000000] (0:maestro@) Visited states = 108
-> [ 0.000000] (0:maestro@) Executed transitions = 72
+> [ 0.000000] (0:maestro@) Executed transitions = 42
! expect return 6
# because SIMGRID_MC_EXIT_PROGRAM_CRASH = 6
> [ 0.000000] (0:maestro@) **************************
> [ 0.000000] (0:maestro@) From signal: Segmentation fault
> [ 0.000000] (0:maestro@) Counter-example execution trace:
-> [ 0.000000] (0:maestro@) [(1)Fafard (app)] MC_RANDOM(3)
-> [ 0.000000] (0:maestro@) [(1)Fafard (app)] MC_RANDOM(4)
+> [ 0.000000] (0:maestro@) Random([0;5] ~> 3)
+> [ 0.000000] (0:maestro@) Random([0;5] ~> 4)
> [ 0.000000] (0:maestro@) Path = 1/3;1/4
> [ 0.000000] (0:maestro@) Expanded states = 27
> [ 0.000000] (0:maestro@) Visited states = 68
-> [ 0.000000] (0:maestro@) Executed transitions = 46
+> [ 0.000000] (0:maestro@) Executed transitions = 27
> [ 0.000000] (0:maestro@) Stack trace not displayed because you passed --log=no_loc