Add invocation queue to DrivenEngine, use it for lua source
This commit is contained in:
@@ -24,9 +24,11 @@ static void dump_lines(StreamBuffer *in, StreamBuffer *out, int chid) {
|
||||
|
||||
// This test is the minimal possible DrivenEngine.
|
||||
class DriverStubTest : public DrivenEngine {
|
||||
virtual void event_init(int argc, char *argv[]) {
|
||||
virtual void event_init(std::string_view srcpk, int argc, char *argv[]) override {
|
||||
stop_driver();
|
||||
}
|
||||
virtual void event_update() override {
|
||||
}
|
||||
};
|
||||
|
||||
// This test connects to a public webserver and prints
|
||||
@@ -34,13 +36,13 @@ class DriverStubTest : public DrivenEngine {
|
||||
class DriverWebServerTest : public DrivenEngine {
|
||||
public:
|
||||
eng::vector<SharedChannel> channels_;
|
||||
virtual void event_init(int argc, char *argv[]) {
|
||||
virtual void event_init(std::string_view srcpk, int argc, char *argv[]) override {
|
||||
SharedChannel ch = new_outgoing_channel("cert:stanford.edu:443");
|
||||
ch->out()->write_bytes("GET https://stanford.edu/xbanankjdsh.html HTTP/1.1\n\n");
|
||||
channels_.emplace_back(std::move(ch));
|
||||
}
|
||||
|
||||
virtual void event_update() {
|
||||
virtual void event_update() override {
|
||||
SharedChannel stdioch = get_stdio_channel();
|
||||
dump_lines(stdioch->in(), stdioch->out(), 0);
|
||||
eng::vector<SharedChannel> keep;
|
||||
@@ -60,13 +62,13 @@ public:
|
||||
class DriverDNSFailTest : public DrivenEngine {
|
||||
public:
|
||||
eng::vector<SharedChannel> channels_;
|
||||
virtual void event_init(int argc, char *argv[]) {
|
||||
virtual void event_init(std::string_view srcpk, int argc, char *argv[]) override {
|
||||
SharedChannel ch = new_outgoing_channel("akjsdkajshdakjshd.alk:80");
|
||||
ch->out()->write_bytes("GET http://stanford.edu/index.html HTTP/1.1\n\n");
|
||||
channels_.emplace_back(std::move(ch));
|
||||
}
|
||||
|
||||
virtual void event_update() {
|
||||
virtual void event_update() override {
|
||||
SharedChannel stdioch = get_stdio_channel();
|
||||
dump_lines(stdioch->in(), stdioch->out(), 0);
|
||||
eng::vector<SharedChannel> keep;
|
||||
@@ -87,12 +89,12 @@ class DriverPrintClockTest : public DrivenEngine {
|
||||
public:
|
||||
int count_;
|
||||
double last_clock_;
|
||||
virtual void event_init(int argc, char *argv[]) {
|
||||
virtual void event_init(std::string_view srcpk, int argc, char *argv[]) override {
|
||||
count_ = 0;
|
||||
last_clock_ = 0.0;
|
||||
}
|
||||
|
||||
virtual void event_update() {
|
||||
virtual void event_update() override {
|
||||
double clock = get_clock();
|
||||
if (clock > last_clock_ + 0.5) {
|
||||
int ms = eng::memhash();
|
||||
@@ -112,13 +114,15 @@ class RunUnitTests : public DrivenEngine {
|
||||
private:
|
||||
UniqueWorld world_;
|
||||
|
||||
void event_init(int argc, char *argv[])
|
||||
void event_init(std::string_view srcpk, int argc, char *argv[]) override
|
||||
{
|
||||
world_.reset(new World(WORLD_TYPE_MASTER));
|
||||
world_->update_source(get_lua_source_pack());
|
||||
world_->update_source(srcpk);
|
||||
world_->run_unittests();
|
||||
stop_driver();
|
||||
}
|
||||
|
||||
void event_update() override {}
|
||||
};
|
||||
|
||||
DrivenEngineDefine("driverstubtest", DriverStubTest);
|
||||
|
||||
Reference in New Issue
Block a user