diff options
author | Loic Blot <loic.blot@unix-experience.fr> | 2015-02-15 14:28:41 +0000 |
---|---|---|
committer | Loic Blot <loic.blot@unix-experience.fr> | 2015-02-15 14:30:34 +0000 |
commit | 8aebc31a173fa3e6b80f25219b23131d9974a160 (patch) | |
tree | 8a0d27a221ec83fe450eb057f758e15a61fe231f | |
parent | a3e2b3e40467e44ff068c5893bd6ccd3a695db61 (diff) | |
download | minetest-8aebc31a173fa3e6b80f25219b23131d9974a160.tar.gz minetest-8aebc31a173fa3e6b80f25219b23131d9974a160.tar.bz2 minetest-8aebc31a173fa3e6b80f25219b23131d9974a160.zip |
Fix unit test if there isn't a localhost address (for example FreeBSD jails), second part
-rw-r--r-- | src/test.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/test.cpp b/src/test.cpp index ed92ad43a..43955b86f 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -1865,9 +1865,24 @@ struct TestConnection: public TestBase Handler hand_server("server"); Handler hand_client("client"); + Address address(0, 0, 0, 0, 30001); + Address bind_addr(0, 0, 0, 0, 30001); + /* + * Try to use the bind_address for servers with no localhost address + * For example: FreeBSD jails + */ + std::string bind_str = g_settings->get("bind_address"); + try { + bind_addr.Resolve(bind_str.c_str()); + + if (!bind_addr.isIPv6()) { + address = bind_addr; + } + } catch (ResolveError &e) { + } + infostream<<"** Creating server Connection"<<std::endl; con::Connection server(proto_id, 512, 5.0, false, &hand_server); - Address address(0,0,0,0, 30001); server.Serve(address); infostream<<"** Creating client Connection"<<std::endl; @@ -1878,7 +1893,11 @@ struct TestConnection: public TestBase sleep_ms(50); - Address server_address(127,0,0,1, 30001); + Address server_address(127, 0, 0, 1, 30001); + if (address != Address(0, 0, 0, 0, 30001)) { + server_address = bind_addr; + } + infostream<<"** running client.Connect()"<<std::endl; client.Connect(server_address); |