Skip to content

Commit

Permalink
[tests] strict encyption: debug trace torned off
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko authored and rndi committed Sep 13, 2019
1 parent 24f3d6d commit d7cbf97
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
1 change: 0 additions & 1 deletion test/test_epoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,6 @@ TEST(CEPoll, ThreadedUpdate)
SRTSOCKET client_sock = srt_socket(AF_INET, SOCK_DGRAM, 0);
EXPECT_NE(client_sock, SRT_ERROR);

const int yes = 1;
const int no = 0;
EXPECT_NE(srt_setsockopt (client_sock, 0, SRTO_RCVSYN, &no, sizeof no), SRT_ERROR); // for async connect
EXPECT_NE(srt_setsockopt (client_sock, 0, SRTO_SNDSYN, &no, sizeof no), SRT_ERROR); // for async connect
Expand Down
28 changes: 13 additions & 15 deletions test/test_strict_encription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class TestStrictEncryption
int SetStrictEncryption(PEER_TYPE peer, bool value)
{
const SRTSOCKET &socket = peer == PEER_CALLER ? m_caller_socket : m_listener_socket;
return srt_setsockopt(socket, 0, SRTO_STRICTENC, value ? &s_yes : &s_no, sizeof s_yes);
return srt_setsockopt(socket, 0, SRTO_ENFORCEDENCRYPTION, value ? &s_yes : &s_no, sizeof s_yes);
}


Expand All @@ -252,7 +252,7 @@ class TestStrictEncryption
const SRTSOCKET socket = peer_type == PEER_CALLER ? m_caller_socket : m_listener_socket;
int value = -1;
int value_len = sizeof value;
EXPECT_EQ(srt_getsockopt(socket, 0, SRTO_STRICTENC, (void*)&value, &value_len), SRT_SUCCESS);
EXPECT_EQ(srt_getsockopt(socket, 0, SRTO_ENFORCEDENCRYPTION, (void*)&value, &value_len), SRT_SUCCESS);
return value ? true : false;
}

Expand Down Expand Up @@ -368,26 +368,25 @@ class TestStrictEncryption
EXPECT_EQ(GetSocetkOption(accepted_socket, SRTO_SNDKMSTATE), expect.km_state[CHECK_SOCKET_ACCEPTED]);
if (m_is_tracing)
{
std::cout << "Socket state accepted: " << m_socket_state[srt_getsockstate(accepted_socket)] << "\n";
std::cout << "KM State accepted: " << m_km_state[GetKMState(accepted_socket)] << '\n';
std::cout << "RCV KM State accepted: " << m_km_state[GetSocetkOption(accepted_socket, SRTO_RCVKMSTATE)] << '\n';
std::cout << "SND KM State accepted: " << m_km_state[GetSocetkOption(accepted_socket, SRTO_SNDKMSTATE)] << '\n';
std::cerr << "Socket state accepted: " << m_socket_state[srt_getsockstate(accepted_socket)] << "\n";
std::cerr << "KM State accepted: " << m_km_state[GetKMState(accepted_socket)] << '\n';
std::cerr << "RCV KM State accepted: " << m_km_state[GetSocetkOption(accepted_socket, SRTO_RCVKMSTATE)] << '\n';
std::cerr << "SND KM State accepted: " << m_km_state[GetSocetkOption(accepted_socket, SRTO_SNDKMSTATE)] << '\n';
}
}
std::cout << "srt_accept() thread finished\n";
});

if (is_blocking == false)
accepting_thread.join();

if (m_is_tracing)
{
std::cout << "Socket state caller: " << m_socket_state[srt_getsockstate(m_caller_socket)] << "\n";
std::cout << "Socket state listener: " << m_socket_state[srt_getsockstate(m_listener_socket)] << "\n";
std::cout << "KM State caller: " << m_km_state[GetKMState(m_caller_socket)] << '\n';
std::cout << "RCV KM State caller: " << m_km_state[GetSocetkOption(m_caller_socket, SRTO_RCVKMSTATE)] << '\n';
std::cout << "SND KM State caller: " << m_km_state[GetSocetkOption(m_caller_socket, SRTO_SNDKMSTATE)] << '\n';
std::cout << "KM State listener: " << m_km_state[GetKMState(m_listener_socket)] << '\n';
std::cerr << "Socket state caller: " << m_socket_state[srt_getsockstate(m_caller_socket)] << "\n";
std::cerr << "Socket state listener: " << m_socket_state[srt_getsockstate(m_listener_socket)] << "\n";
std::cerr << "KM State caller: " << m_km_state[GetKMState(m_caller_socket)] << '\n';
std::cerr << "RCV KM State caller: " << m_km_state[GetSocetkOption(m_caller_socket, SRTO_RCVKMSTATE)] << '\n';
std::cerr << "SND KM State caller: " << m_km_state[GetSocetkOption(m_caller_socket, SRTO_SNDKMSTATE)] << '\n';
std::cerr << "KM State listener: " << m_km_state[GetKMState(m_listener_socket)] << '\n';
}

// If a blocking call to srt_connect() returned error, then the state is not valid,
Expand All @@ -403,7 +402,6 @@ class TestStrictEncryption
// srt_accept() has no timeout, so we have to close the socket and wait for the thread to exit.
// Just give it some time and close the socket.
std::this_thread::sleep_for(std::chrono::milliseconds(50));
std::cout << "Closing the listener socket\n";
ASSERT_NE(srt_close(m_listener_socket), SRT_ERROR);
accepting_thread.join();
}
Expand All @@ -421,7 +419,7 @@ class TestStrictEncryption
const int s_yes = 1;
const int s_no = 0;

const bool m_is_tracing = true;
const bool m_is_tracing = false;
static const char* m_km_state[];
static const char* m_socket_state[];
};
Expand Down

0 comments on commit d7cbf97

Please sign in to comment.