Skip to content

Commit 00e14f7

Browse files
maxsharabaykoMikołaj Małeckiethouris
authored
[tests] Extending socket options test to group options (#3086).
Co-authored-by: Mikołaj Małecki <[email protected]> Co-authored-by: Sektor van Skijlen <[email protected]>
1 parent 7b77d4c commit 00e14f7

File tree

6 files changed

+394
-82
lines changed

6 files changed

+394
-82
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ matrix:
6565
- BUILD_TYPE=Release
6666
- BUILD_OPTS='-DENABLE_MONOTONIC_CLOCK=ON'
6767
script:
68+
- echo COMPILER $TRAVIS_COMPILER
69+
- echo SYSTEM $TRAVIS_OS_NAME
70+
- echo BUILD_TYPE $BUILD_TYPE
71+
- echo BUILD_OPTS $BUILD_OPTS
6872
- if [ "$TRAVIS_COMPILER" == "x86_64-w64-mingw32-g++" ]; then
6973
export CC="x86_64-w64-mingw32-gcc";
7074
export CXX="x86_64-w64-mingw32-g++";

srtcore/group.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,14 @@ void CUDTGroup::setOpt(SRT_SOCKOPT optName, const void* optval, int optlen)
461461
}
462462
}
463463

464+
// Before possibly storing the option, check if it is settable on a socket.
465+
CSrtConfig testconfig;
466+
467+
// Note: this call throws CUDTException by itself.
468+
int result = testconfig.set(optName, optval, optlen);
469+
if (result == -1) // returned in case of unknown option
470+
throw CUDTException(MJ_NOTSUP, MN_INVAL, 0);
471+
464472
// Store the option regardless if pre or post. This will apply
465473
m_config.push_back(ConfigItem(optName, optval, optlen));
466474
}
@@ -724,8 +732,10 @@ static bool getOptDefault(SRT_SOCKOPT optname, void* pw_optval, int& w_optlen)
724732
RD(int64_t(-1));
725733
case SRTO_INPUTBW:
726734
RD(int64_t(-1));
735+
case SRTO_MININPUTBW:
736+
RD(int64_t(0));
727737
case SRTO_OHEADBW:
728-
RD(0);
738+
RD(SRT_OHEAD_DEFAULT_P100);
729739
case SRTO_STATE:
730740
RD(SRTS_INIT);
731741
case SRTO_EVENT:
@@ -746,8 +756,9 @@ static bool getOptDefault(SRT_SOCKOPT optname, void* pw_optval, int& w_optlen)
746756
RD(false);
747757
case SRTO_LATENCY:
748758
case SRTO_RCVLATENCY:
749-
case SRTO_PEERLATENCY:
750759
RD(SRT_LIVE_DEF_LATENCY_MS);
760+
case SRTO_PEERLATENCY:
761+
RD(0);
751762
case SRTO_TLPKTDROP:
752763
RD(true);
753764
case SRTO_SNDDROPDELAY:
@@ -758,14 +769,15 @@ static bool getOptDefault(SRT_SOCKOPT optname, void* pw_optval, int& w_optlen)
758769
RD(SRT_DEF_VERSION);
759770
case SRTO_PEERVERSION:
760771
RD(0);
761-
772+
case SRTO_PEERIDLETIMEO:
773+
RD(CSrtConfig::COMM_RESPONSE_TIMEOUT_MS);
762774
case SRTO_CONNTIMEO:
763-
RD(-1);
775+
RD(CSrtConfig::DEF_CONNTIMEO_S * 1000); // required milliseconds
764776
case SRTO_DRIFTTRACER:
765777
RD(true);
766778

767779
case SRTO_MINVERSION:
768-
RD(0);
780+
RD(SRT_VERSION_MAJ1);
769781
case SRTO_STREAMID:
770782
RD(std::string());
771783
case SRTO_CONGESTION:
@@ -776,6 +788,10 @@ static bool getOptDefault(SRT_SOCKOPT optname, void* pw_optval, int& w_optlen)
776788
RD(0);
777789
case SRTO_GROUPMINSTABLETIMEO:
778790
RD(CSrtConfig::COMM_DEF_MIN_STABILITY_TIMEOUT_MS);
791+
case SRTO_LOSSMAXTTL:
792+
RD(0);
793+
case SRTO_RETRANSMITALGO:
794+
RD(1);
779795
}
780796

781797
#undef RD

srtcore/socketconfig.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ written by
7070
#define SRT_VERSION_MIN(v) (0x00FF00 & (v))
7171
#define SRT_VERSION_PCH(v) (0x0000FF & (v))
7272

73+
static const int SRT_OHEAD_DEFAULT_P100 = 25;
74+
7375
// NOTE: SRT_VERSION is primarily defined in the build file.
7476
extern const int32_t SRT_DEF_VERSION;
7577

@@ -316,7 +318,7 @@ struct CSrtConfig: CSrtMuxerConfig
316318
, iCryptoMode(CIPHER_MODE_AUTO)
317319
, llInputBW(0)
318320
, llMinInputBW(0)
319-
, iOverheadBW(25)
321+
, iOverheadBW(SRT_OHEAD_DEFAULT_P100)
320322
, bRcvNakReport(true)
321323
, iMaxReorderTolerance(0) // Sensible optimal value is 10, 0 preserves old behavior
322324
, uKmRefreshRatePkt(0)

test/test_bonding.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,12 +380,18 @@ TEST(Bonding, Options)
380380
uint32_t val = 16;
381381
EXPECT_NE(srt_setsockflag(grp, SRTO_PBKEYLEN, &val, (int) sizeof val), SRT_ERROR);
382382

383+
const bool bfalse = true;
384+
EXPECT_EQ(srt_setsockflag(grp, SRTO_RENDEZVOUS, &bfalse, (int)sizeof bfalse), SRT_ERROR);
385+
383386
#ifdef ENABLE_AEAD_API_PREVIEW
384387
val = 1;
385388
EXPECT_NE(srt_setsockflag(grp, SRTO_CRYPTOMODE, &val, sizeof val), SRT_ERROR);
386389
#endif
387390
#endif
388391

392+
const string packet_filter = "fec,cols:10,rows:5";
393+
EXPECT_NE(srt_setsockflag(grp, SRTO_PACKETFILTER, packet_filter.c_str(), (int)packet_filter.size()), SRT_ERROR);
394+
389395
// ================
390396
// Linger is an option of a trivial type, but differes from other integer-typed options.
391397
// Therefore checking it specifically.
@@ -451,6 +457,11 @@ TEST(Bonding, Options)
451457

452458
check_streamid(gs);
453459

460+
std::array<char, 800> tmpbuf;
461+
auto opt_len = (int)tmpbuf.size();
462+
EXPECT_EQ(srt_getsockflag(gs, SRTO_PACKETFILTER, tmpbuf.data(), &opt_len), SRT_SUCCESS);
463+
std::cout << "Packet filter: " << std::string(tmpbuf.data(), opt_len) << '\n';
464+
454465
// Connected, wait to close
455466
latch.wait(ux);
456467

test/test_env.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ class TestEnv: public testing::Environment
5050
}
5151

5252
static bool Allowed_Platform() { return false; }
53+
54+
#ifdef ENABLE_BONDING
55+
static bool Allowed_Bonding() { return true; }
56+
#else
57+
static bool Allowed_Bonding() { return false; }
58+
#endif
5359
};
5460

5561
#define SRTST_REQUIRES(feature,...) if (!srt::TestEnv::Allowed_##feature(__VA_ARGS__)) { return; }

0 commit comments

Comments
 (0)