Adjust UDP test for macOS loopback behavior.

This commit is contained in:
Sönke Ludwig 2017-01-23 19:34:42 +01:00
parent 86ff9ea0d0
commit e8a0968ded

View file

@ -7,7 +7,7 @@ module test;
import eventcore.core; import eventcore.core;
import eventcore.socket; import eventcore.socket;
import std.socket : InternetAddress; import std.socket : InternetAddress;
import core.time : Duration; import core.time : Duration, msecs;
DatagramSocket s_baseSocket; DatagramSocket s_baseSocket;
DatagramSocket s_freeSocket; DatagramSocket s_freeSocket;
@ -41,21 +41,25 @@ void main()
assert(bytes == pack2.length); assert(bytes == pack2.length);
})(pack2, IOMode.once, baddr); })(pack2, IOMode.once, baddr);
s_baseSocket.receive!((status, bts, scope addr) { auto tm = eventDriver.timers.create();
log("receive2: %s %s", status, bts); eventDriver.timers.set(tm, 50.msecs, 0.msecs);
assert(status == IOStatus.ok); eventDriver.timers.wait(tm, (tm) {
assert(bts == pack2.length); s_baseSocket.receive!((status, bts, scope addr) {
assert(s_rbuf[0 .. pack2.length] == pack2); log("receive2: %s %s", status, bts);
assert(status == IOStatus.ok);
assert(bts == pack2.length);
assert(s_rbuf[0 .. pack2.length] == pack2);
destroy(s_baseSocket); destroy(s_baseSocket);
destroy(s_freeSocket); destroy(s_freeSocket);
destroy(s_connectedSocket); destroy(s_connectedSocket);
s_done = true; s_done = true;
log("done."); log("done.");
// FIXME: this shouldn't ne necessary: // FIXME: this shouldn't be necessary:
eventDriver.core.exit(); eventDriver.core.exit();
})(s_rbuf, IOMode.immediate); })(s_rbuf, IOMode.immediate);
});
})(s_rbuf, IOMode.once); })(s_rbuf, IOMode.once);
s_connectedSocket.send!((status, bytes) { s_connectedSocket.send!((status, bytes) {
log("send1: %s %s", status, bytes); log("send1: %s %s", status, bytes);