Adjust all tests to rely on automatic event loop exiting.

This commit is contained in:
Sönke Ludwig 2017-06-10 10:28:16 +02:00
parent d99eb1be34
commit b20dd9b398
No known key found for this signature in database
GPG key ID: D95E8DB493EE314C
10 changed files with 15 additions and 34 deletions

View file

@ -39,8 +39,8 @@ void main()
assert(change.kind == FileChangeKind.removed); assert(change.kind == FileChangeKind.removed);
assert(change.directory == "."); assert(change.directory == ".");
assert(change.name == testFilename); assert(change.name == testFilename);
eventDriver.watchers.releaseRef(id);
s_done = true; s_done = true;
eventDriver.core.exit();
break; break;
} }
}); });
@ -63,7 +63,7 @@ void main()
ExitReason er; ExitReason er;
do er = eventDriver.core.processEvents(Duration.max); do er = eventDriver.core.processEvents(Duration.max);
while (er == ExitReason.idle); while (er == ExitReason.idle);
//assert(er == ExitReason.outOfWaiters); // FIXME: see above assert(er == ExitReason.outOfWaiters);
assert(s_done); assert(s_done);
s_done = false; s_done = false;

View file

@ -21,13 +21,12 @@ void main()
catch (Exception e) assert(false, e.msg); catch (Exception e) assert(false, e.msg);
} }
s_done = true; s_done = true;
eventDriver.core.exit();
}); });
ExitReason er; ExitReason er;
do er = eventDriver.core.processEvents(Duration.max); do er = eventDriver.core.processEvents(Duration.max);
while (er == ExitReason.idle); while (er == ExitReason.idle);
//assert(er == ExitReason.outOfWaiters); // FIXME: see above assert(er == ExitReason.outOfWaiters);
assert(s_done); assert(s_done);
s_done = false; s_done = false;
} }

View file

@ -27,7 +27,6 @@ void test(bool notify_all)
assert(!s_done); assert(!s_done);
s_done = true; s_done = true;
eventDriver.timers.cancelWait(tm); eventDriver.timers.cancelWait(tm);
eventDriver.core.exit();
}); });
}); });
@ -51,7 +50,7 @@ void test(bool notify_all)
ExitReason er; ExitReason er;
do er = eventDriver.core.processEvents(Duration.max); do er = eventDriver.core.processEvents(Duration.max);
while (er == ExitReason.idle); while (er == ExitReason.idle);
//assert(er == ExitReason.outOfWaiters); // FIXME: see above assert(er == ExitReason.outOfWaiters);
assert(s_done); assert(s_done);
s_done = false; s_done = false;
} }

View file

@ -18,11 +18,6 @@ void main()
auto f = eventDriver.files.open("test.txt", FileOpenMode.createTrunc); auto f = eventDriver.files.open("test.txt", FileOpenMode.createTrunc);
assert(eventDriver.files.getSize(f) == 0); assert(eventDriver.files.getSize(f) == 0);
auto data = cast(const(ubyte)[])"Hello, World!"; auto data = cast(const(ubyte)[])"Hello, World!";
auto tm = eventDriver.timers.create();
eventDriver.timers.set(tm, 500.msecs, 0.msecs);
eventDriver.timers.wait(tm, (tm) {
assert(false, "File operation stalled.");
});
eventDriver.files.write(f, 0, data[0 .. 7], IOMode.all, (f, status, nbytes) { eventDriver.files.write(f, 0, data[0 .. 7], IOMode.all, (f, status, nbytes) {
assert(status == IOStatus.ok); assert(status == IOStatus.ok);
@ -48,7 +43,6 @@ void main()
} (); } ();
eventDriver.files.releaseRef(f); eventDriver.files.releaseRef(f);
s_done = true; s_done = true;
eventDriver.core.exit();
}); });
}); });
}); });
@ -57,7 +51,7 @@ void main()
ExitReason er; ExitReason er;
do er = eventDriver.core.processEvents(Duration.max); do er = eventDriver.core.processEvents(Duration.max);
while (er == ExitReason.idle); while (er == ExitReason.idle);
//assert(er == ExitReason.outOfWaiters); // FIXME: see above assert(er == ExitReason.outOfWaiters);
assert(s_done); assert(s_done);
s_done = false; s_done = false;
} }

View file

@ -21,8 +21,8 @@ void main()
assert(!s_done); assert(!s_done);
assert(status == SignalStatus.ok); assert(status == SignalStatus.ok);
assert(sig == () @trusted { return SIGUSR1; } ()); assert(sig == () @trusted { return SIGUSR1; } ());
eventDriver.signals.releaseRef(id);
s_done = true; s_done = true;
eventDriver.core.exit();
}); });
auto tm = eventDriver.timers.create(); auto tm = eventDriver.timers.create();
@ -34,7 +34,7 @@ void main()
ExitReason er; ExitReason er;
do er = eventDriver.core.processEvents(Duration.max); do er = eventDriver.core.processEvents(Duration.max);
while (er == ExitReason.idle); while (er == ExitReason.idle);
//assert(er == ExitReason.outOfWaiters); // FIXME: see above assert(er == ExitReason.outOfWaiters);
assert(s_done); assert(s_done);
s_done = false; s_done = false;

View file

@ -43,9 +43,6 @@ void main()
destroy(server); destroy(server);
destroy(client); destroy(client);
s_done = true; s_done = true;
// FIXME: this shouldn't ne necessary:
eventDriver.core.exit();
})(s_rbuf, IOMode.immediate); })(s_rbuf, IOMode.immediate);
})(s_rbuf[0 .. 0], IOMode.once); })(s_rbuf[0 .. 0], IOMode.once);
}); });
@ -67,7 +64,7 @@ void main()
ExitReason er; ExitReason er;
do er = eventDriver.core.processEvents(Duration.max); do er = eventDriver.core.processEvents(Duration.max);
while (er == ExitReason.idle); while (er == ExitReason.idle);
//assert(er == ExitReason.outOfWaiters); // FIXME: see above assert(er == ExitReason.outOfWaiters);
assert(s_done); assert(s_done);
s_done = false; s_done = false;

View file

@ -43,9 +43,6 @@ void main()
destroy(server); destroy(server);
destroy(client); destroy(client);
s_done = true; s_done = true;
// FIXME: this shouldn't ne necessary:
eventDriver.core.exit();
})(s_rbuf, IOMode.once); })(s_rbuf, IOMode.once);
})(s_rbuf, IOMode.once); })(s_rbuf, IOMode.once);
}); });
@ -62,7 +59,7 @@ void main()
ExitReason er; ExitReason er;
do er = eventDriver.core.processEvents(Duration.max); do er = eventDriver.core.processEvents(Duration.max);
while (er == ExitReason.idle); while (er == ExitReason.idle);
//assert(er == ExitReason.outOfWaiters); // FIXME: see above assert(er == ExitReason.outOfWaiters);
assert(s_done); assert(s_done);
s_done = false; s_done = false;
} }

View file

@ -34,10 +34,11 @@ void main()
s_cnt++; s_cnt++;
assert(dur > 100.msecs * s_cnt); assert(dur > 100.msecs * s_cnt);
assert(dur < 100.msecs * s_cnt + 20.msecs); assert(dur < 100.msecs * s_cnt + 20.msecs);
assert(s_cnt <= 3);
if (s_cnt == 3) { if (s_cnt == 3) {
s_done = true; s_done = true;
eventDriver.core.exit(); eventDriver.timers.stop(timer);
} else eventDriver.timers.wait(tm, &secondTier); } else eventDriver.timers.wait(tm, &secondTier);
} catch (Exception e) { } catch (Exception e) {
assert(false, e.msg); assert(false, e.msg);
@ -52,7 +53,7 @@ void main()
ExitReason er; ExitReason er;
do er = eventDriver.core.processEvents(Duration.max); do er = eventDriver.core.processEvents(Duration.max);
while (er == ExitReason.idle); while (er == ExitReason.idle);
//assert(er == ExitReason.outOfWaiters); // FIXME: see above assert(er == ExitReason.outOfWaiters);
assert(s_done); assert(s_done);
s_done = false; s_done = false;
} }

View file

@ -55,9 +55,6 @@ void main()
destroy(s_connectedSocket); destroy(s_connectedSocket);
s_done = true; s_done = true;
log("done."); log("done.");
// FIXME: this shouldn't be necessary:
eventDriver.core.exit();
})(s_rbuf, IOMode.immediate); })(s_rbuf, IOMode.immediate);
}); });
})(s_rbuf, IOMode.once); })(s_rbuf, IOMode.once);
@ -70,7 +67,7 @@ void main()
ExitReason er; ExitReason er;
do er = eventDriver.core.processEvents(Duration.max); do er = eventDriver.core.processEvents(Duration.max);
while (er == ExitReason.idle); while (er == ExitReason.idle);
//assert(er == ExitReason.outOfWaiters); // FIXME: see above assert(er == ExitReason.outOfWaiters);
assert(s_done); assert(s_done);
} }

View file

@ -118,9 +118,6 @@ void testStream()
destroy(server); destroy(server);
destroy(client); destroy(client);
s_done = true; s_done = true;
// FIXME: this shouldn't ne necessary:
eventDriver.core.exit();
})(s_rbuf, IOMode.once); })(s_rbuf, IOMode.once);
})(s_rbuf, IOMode.once); })(s_rbuf, IOMode.once);
}); });
@ -137,7 +134,7 @@ void testStream()
ExitReason er; ExitReason er;
do er = eventDriver.core.processEvents(Duration.max); do er = eventDriver.core.processEvents(Duration.max);
while (er == ExitReason.idle); while (er == ExitReason.idle);
//assert(er == ExitReason.outOfWaiters); // FIXME: see above assert(er == ExitReason.outOfWaiters);
assert(s_done); assert(s_done);
s_done = false; s_done = false;
} }