Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] Add test and some future API changes for startup/cleanup #3100 #3104

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed bugs in the test and improved testing
Mikolaj Malecki committed Jan 14, 2025
commit 62e3500241300250475b9a38b1efe8cbe430e741
5 changes: 5 additions & 0 deletions test/test_common.cpp
Original file line number Diff line number Diff line change
@@ -38,6 +38,9 @@ TEST(General, Startup)
EXPECT_EQ(srt::CUDT::uglobal().getInstanceStatus(), std::make_pair(1, true));

EXPECT_EQ(srt_close(sock), 0);

// Do the cleanup again, to not leave it up to the global destructor.
EXPECT_EQ(srt_cleanup(), 0);
}

void test_cipaddress_pton(const char* peer_ip, int family, const uint32_t (&ip)[4])
@@ -76,6 +79,8 @@ void test_cipaddress_pton(const char* peer_ip, int family, const uint32_t (&ip)[
// Example IPv4 address: 192.168.0.1
TEST(CIPAddress, IPv4_pton)
{
// Check the NEXT TEST of General/Startup, if it has done the cleanup.
EXPECT_EQ(srt::CUDT::uglobal().getInstanceStatus(), std::make_pair(0, false));
srt::TestInit srtinit;
const char* peer_ip = "192.168.0.1";
const uint32_t ip[4] = {htobe32(0xC0A80001), 0, 0, 0};
4 changes: 1 addition & 3 deletions test/test_connection_timeout.cpp
Original file line number Diff line number Diff line change
@@ -211,7 +211,7 @@ TEST(TestConnectionAPI, Accept)
using namespace std::chrono;
using namespace srt;

srt_startup();
TestInit srtinit;

const SRTSOCKET caller_sock = srt_create_socket();
const SRTSOCKET listener_sock = srt_create_socket();
@@ -266,8 +266,6 @@ TEST(TestConnectionAPI, Accept)
}
srt_close(caller_sock);
srt_close(listener_sock);

srt_cleanup();
}



Unchanged files with check annotations Beta

ScopedLock gcinit(m_InitLock);
if (implicit && m_iInstanceCount > 0)
// [reinstate in 1.6.0] return m_iInstanceCount;

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
return 1;
if (m_iInstanceCount++ > 0)
// [reinstate in 1.6.0] return m_iInstanceCount;

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
return 1;
if (m_bGCStatus)

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
// [reinstate in 1.6.0] return m_iInstanceCount;
return 1;
if (!force)
{
if (m_iInstanceCount == 0 || --m_iInstanceCount > 0)

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
// [reinstate in 1.6.0] return m_iInstanceCount;
return 0;
}