aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/enet/unix.c2
-rw-r--r--tests/sockets/test_gethostbyname.c9
2 files changed, 8 insertions, 3 deletions
diff --git a/tests/enet/unix.c b/tests/enet/unix.c
index a225b57d..67d4a8b8 100644
--- a/tests/enet/unix.c
+++ b/tests/enet/unix.c
@@ -80,7 +80,7 @@ enet_address_set_host (ENetAddress * address, const char * name)
char buffer [2048];
int errnum;
-#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__EMSCRIPTEN__)
gethostbyname_r (name, & hostData, buffer, sizeof (buffer), & hostEntry, & errnum);
#else
hostEntry = gethostbyname_r (name, & hostData, buffer, sizeof (buffer), & errnum);
diff --git a/tests/sockets/test_gethostbyname.c b/tests/sockets/test_gethostbyname.c
index de7da706..459c6b98 100644
--- a/tests/sockets/test_gethostbyname.c
+++ b/tests/sockets/test_gethostbyname.c
@@ -13,12 +13,17 @@
int main() {
char str[INET_ADDRSTRLEN];
+ struct hostent *host = NULL;
+ struct hostent hostData;
struct in_addr addr;
const char *res;
+ char buffer[2048];
int err;
- // resolve the hostname ot an actual address
- struct hostent *host = gethostbyname("slashdot.org");
+ // gethostbyname_r calls the same stuff as gethostbyname, so we'll test the
+ // more complicated one.
+ // resolve the hostname to an actual address
+ gethostbyname_r("slashdot.org", &hostData, buffer, sizeof(buffer), &host, &err);
assert(host->h_addrtype == AF_INET);
assert(host->h_length == sizeof(uint32_t));