diff options
author | Mattes D <github@xoft.cz> | 2015-01-11 12:59:07 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2015-01-22 20:12:45 +0100 |
commit | 251c96952bb80c57f24d243def2677e3ee94efe1 (patch) | |
tree | f515b91116bd04f0ea638be1dd31b3b9ce89d33d /tests | |
parent | cNetwork: Implemented HostnameToIP lookups. (diff) | |
download | cuberite-251c96952bb80c57f24d243def2677e3ee94efe1.tar cuberite-251c96952bb80c57f24d243def2677e3ee94efe1.tar.gz cuberite-251c96952bb80c57f24d243def2677e3ee94efe1.tar.bz2 cuberite-251c96952bb80c57f24d243def2677e3ee94efe1.tar.lz cuberite-251c96952bb80c57f24d243def2677e3ee94efe1.tar.xz cuberite-251c96952bb80c57f24d243def2677e3ee94efe1.tar.zst cuberite-251c96952bb80c57f24d243def2677e3ee94efe1.zip |
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Network/NameLookup.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/tests/Network/NameLookup.cpp b/tests/Network/NameLookup.cpp index daa72a3cb..74a57258c 100644 --- a/tests/Network/NameLookup.cpp +++ b/tests/Network/NameLookup.cpp @@ -25,7 +25,7 @@ class cFinishLookupCallbacks: virtual void OnError(int a_ErrorCode) override { LOGD("Error %d while performing lookup!", a_ErrorCode); - abort(); + exit(a_ErrorCode); } virtual void OnFinished(void) override @@ -49,15 +49,28 @@ int main() { cEvent evtFinish; + // Look up google.com (has multiple IP addresses): LOGD("Network test: Looking up google.com"); if (!cNetwork::HostnameToIP("google.com", std::make_shared<cFinishLookupCallbacks>(evtFinish))) { - LOGWARNING("Cannot resolve google.com"); + LOGWARNING("Cannot resolve google.com to IP"); abort(); } LOGD("Name lookup has been successfully queued"); - evtFinish.Wait(); + LOGD("Lookup finished."); + + // Look up 8.8.8.8 (Google free DNS): + LOGD("Network test: Looking up IP 8.8.8.8"); + if (!cNetwork::IPToHostName("8.8.8.8", std::make_shared<cFinishLookupCallbacks>(evtFinish))) + { + LOGWARNING("Cannot resolve 8.8.8.8 to name"); + abort(); + } + LOGD("IP lookup has been successfully queued"); + evtFinish.Wait(); + LOGD("IP lookup finished."); + LOGD("Network test finished"); return 0; } |