Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make unit tests less flaky.

  • Loading branch information...
commit 3e06501787b569f244e37e0e36e9ce504b662ec6 1 parent 5e5f871
@ThomasHabets authored
Showing with 15 additions and 11 deletions.
  1. +1 −0  TODO
  2. +10 −8 src/socket_test.cc
  3. +4 −3 src/sslsocket_test.cc
View
1  TODO
@@ -2,6 +2,7 @@ TODO before 0.08
----------------
* kill connection when cert expires, not just deny new connections
* Provide grsec RBAC config
+* make ping failures result in disconnection
TODO before 1.00
View
18 src/socket_test.cc
@@ -8,6 +8,8 @@
#include"socket.h"
#include"gaiwrap.h"
+const char* listenport = "22345";
+
TEST(Socket, Debug)
{
Socket sock;
@@ -32,7 +34,7 @@ TEST(Socket, FdOps)
TEST(Socket, Listen)
{
Socket sock;
- sock.listen(AF_UNSPEC, "", "12345");
+ sock.listen(AF_UNSPEC, "", listenport);
EXPECT_LE(0, sock.getfd());
}
@@ -46,14 +48,14 @@ TEST(Socket, ReuseAddrBeforeSocket)
TEST(Socket, InvalidAF)
{
Socket sock;
- EXPECT_THROW(sock.listen(-1, "", "12345"),
+ EXPECT_THROW(sock.listen(-1, "", listenport),
GetAddrInfo::ErrBase);
}
TEST(Socket, InvalidBindAddress)
{
Socket sock;
- EXPECT_THROW(sock.listen(AF_UNSPEC, "1.1.1.1", "12345"),
+ EXPECT_THROW(sock.listen(AF_UNSPEC, "1.1.1.1", listenport),
Socket::ErrSys);
}
@@ -61,8 +63,8 @@ TEST(Socket, ListenPortBusy)
{
Socket sock1;
Socket sock2;
- sock1.listen(AF_UNSPEC, "", "12345");
- EXPECT_THROW(sock2.listen(AF_UNSPEC, "", "12345"),
+ sock1.listen(AF_UNSPEC, "", listenport);
+ EXPECT_THROW(sock2.listen(AF_UNSPEC, "", listenport),
Socket::ErrSys);
}
@@ -97,7 +99,7 @@ TEST(Socket, PeerWhenNotInit)
TEST(Socket, PeerWhenNotConnected)
{
Socket sock;
- sock.listen(AF_UNSPEC, "", "12345");
+ sock.listen(AF_UNSPEC, "", listenport);
EXPECT_THROW(sock.get_peer_addr_string(),
Socket::ErrSys);
}
@@ -106,8 +108,8 @@ TEST(Socket, LoopData)
{
Socket s1;
Socket s2;
- s1.listen(AF_UNSPEC, "", "12345");
- s2.connect(AF_UNSPEC, "127.0.0.1", "12345");
+ s1.listen(AF_UNSPEC, "", listenport);
+ s2.connect(AF_UNSPEC, "127.0.0.1", listenport);
Socket serv;
serv.setfd(s1.accept());
View
7 src/sslsocket_test.cc
@@ -10,6 +10,7 @@
#include"sslsocket.h"
Logger *logger = NULL;
+const char* listenport = "22345";
class AutoJoin {
public:
@@ -30,8 +31,8 @@ class SSLSocketTest: public ::testing::Test {
SSLSocket sc_, sl_;
void connect_tcp()
{
- sl_.listen(AF_UNSPEC, "", "12345");
- sc_.connect(AF_UNSPEC, "localhost", "12345");
+ sl_.listen(AF_UNSPEC, "", listenport);
+ sc_.connect(AF_UNSPEC, "localhost", listenport);
}
void set_certs(SSLSocket&ss)
@@ -79,7 +80,7 @@ class SSLSocketTest: public ::testing::Test {
TEST_F(SSLSocketTest, Listen)
{
SSLSocket sock;
- sock.listen(AF_UNSPEC, "", "12345");
+ sock.listen(AF_UNSPEC, "", listenport);
}
TEST_F(SSLSocketTest, ReadBeforeAnything)
Please sign in to comment.
Something went wrong with that request. Please try again.