Skip to content

Commit

Permalink
Introduced platform restriction for tests. Restricted UDPOptions test…
Browse files Browse the repository at this point in the history
… for Linux and GNU only.
  • Loading branch information
Mikolaj Malecki committed Dec 23, 2024
1 parent 96b4b4d commit c493712
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,7 @@ if (ENABLE_UNITTESTS AND ENABLE_CXX11)
srt_add_program_dont_install(test-srt ${SOURCES_unittests})
srt_make_application(test-srt)
target_include_directories(test-srt PRIVATE ${SSL_INCLUDE_DIRS} ${GTEST_INCLUDE_DIRS})
target_compile_definitions(test-srt PRIVATE "-DSRT_TEST_SYSTEM_NAME=\"${CMAKE_SYSTEM_NAME}\"")

target_link_libraries(
test-srt
Expand Down
10 changes: 10 additions & 0 deletions test/test_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ class TestEnv: public testing::Environment
// All must be static, return bool. Arguments allowed.
// The name must start with Allowed_.
static bool Allowed_IPv6();

template<typename... Args>
static bool Allowed_Platform(const std::string& first, const Args&... follow)
{
if (first == SRT_TEST_SYSTEM_NAME)
return true;
return Allowed_Platform(follow...);
}

static bool Allowed_Platform() { return false; }
};

#define SRTST_REQUIRES(feature,...) if (!srt::TestEnv::Allowed_##feature(__VA_ARGS__)) { return; }
Expand Down
2 changes: 2 additions & 0 deletions test/test_reuseaddr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,8 @@ TEST_F(ReuseAddr, DiffAddr)

TEST_F(ReuseAddr, UDPOptions)
{
SRTST_REQUIRES(Platform, "Linux", "GNU");

MAKE_UNIQUE_SOCK(bs1, "general ipv6", prepareServerSocket());
MAKE_UNIQUE_SOCK(bs2, "mapped ipv4", prepareServerSocket());

Expand Down

0 comments on commit c493712

Please sign in to comment.