diff --git a/src/tests/kits/net/Jamfile b/src/tests/kits/net/Jamfile index c285db161a..67719858b2 100644 --- a/src/tests/kits/net/Jamfile +++ b/src/tests/kits/net/Jamfile @@ -39,6 +39,7 @@ SubInclude HAIKU_TOP src tests kits net ipv6 ; HaikuSubInclude libnetapi ; SubInclude HAIKU_TOP src tests kits net multicast ; SubInclude HAIKU_TOP src tests kits net netperf ; +SubInclude HAIKU_TOP src tests kits net posixnet ; SubInclude HAIKU_TOP src tests kits net service ; SubInclude HAIKU_TOP src tests kits net sock ; SubInclude HAIKU_TOP src tests kits net tcp_shell ; diff --git a/src/tests/kits/net/posixnet/GetAddrInfo.cpp b/src/tests/kits/net/posixnet/GetAddrInfo.cpp new file mode 100644 index 0000000000..6450f208c3 --- /dev/null +++ b/src/tests/kits/net/posixnet/GetAddrInfo.cpp @@ -0,0 +1,56 @@ +/* + * Copyright 2014, Haiku, inc. + * Distributed under the terms of the MIT licence + */ + + +#include "GetAddrInfo.h" + +#include +#include +#include + +#include +#include + + +GetAddrInfoTest::GetAddrInfoTest() +{ +} + + +GetAddrInfoTest::~GetAddrInfoTest() +{ +} + + +void +GetAddrInfoTest::EmptyTest() +{ + struct addrinfo* info; + addrinfo hint = {0}; + hint.ai_family = AF_INET; + hint.ai_flags = AI_PASSIVE; + + // Trying to resolve an empty host... + int result = getaddrinfo("", NULL, &hint, &info); + + if (info) + freeaddrinfo(info); + + // getaddrinfo shouldn't suggest that this may work better by trying again. + CPPUNIT_ASSERT(result != EAI_EAGAIN); + // TODO it should also not take 22 seconds before it says so! +} + + +/* static */ void +GetAddrInfoTest::AddTests(BTestSuite& parent) +{ + CppUnit::TestSuite& suite = *new CppUnit::TestSuite("GetAddrInfoTest"); + + suite.addTest(new CppUnit::TestCaller( + "GetAddrInfoTest::EmptyTest", &GetAddrInfoTest::EmptyTest)); + + parent.addTest("GetAddrInfoTest", &suite); +} diff --git a/src/tests/kits/net/posixnet/GetAddrInfo.h b/src/tests/kits/net/posixnet/GetAddrInfo.h new file mode 100644 index 0000000000..ec826c8b65 --- /dev/null +++ b/src/tests/kits/net/posixnet/GetAddrInfo.h @@ -0,0 +1,25 @@ +/* + * Copyright 2014 Haiku, inc. + * Distributed under the terms of the MIT License. + */ +#ifndef GET_ADDR_INFO_TEST_H +#define GET_ADDR_INFO_TEST_H + + +#include +#include + + +class GetAddrInfoTest: public BTestCase { +public: + GetAddrInfoTest(); + virtual ~GetAddrInfoTest(); + + void EmptyTest(); + + static void AddTests(BTestSuite& suite); +}; + + +#endif + diff --git a/src/tests/kits/net/posixnet/Jamfile b/src/tests/kits/net/posixnet/Jamfile new file mode 100644 index 0000000000..5c0ab067fc --- /dev/null +++ b/src/tests/kits/net/posixnet/Jamfile @@ -0,0 +1,12 @@ +SubDir HAIKU_TOP src tests kits net posixnet ; + +UsePrivateHeaders private shared ; + +UnitTestLib posixnettest.so : + PosixNetTestAddon.cpp + + GetAddrInfo.cpp + + : be $(TARGET_NETWORK_LIBS) [ TargetLibstdc++ ] + ; + diff --git a/src/tests/kits/net/posixnet/PosixNetTestAddon.cpp b/src/tests/kits/net/posixnet/PosixNetTestAddon.cpp new file mode 100644 index 0000000000..8817c8af6c --- /dev/null +++ b/src/tests/kits/net/posixnet/PosixNetTestAddon.cpp @@ -0,0 +1,22 @@ +/* + * Copyright 2014 Haiku, Inc. + * Distributed under the terms of the MIT License. + */ + + +#include +#include + +#include "GetAddrInfo.h" + + +BTestSuite* +getTestSuite() +{ + BTestSuite* suite = new BTestSuite("PosixNet"); + + GetAddrInfoTest::AddTests(*suite); + + return suite; +} +