Skip to content

Commit

Permalink
test: move test_rtcp_decode_badmsg() to separate testcase (#1041)
Browse files Browse the repository at this point in the history
* test: move test_rtcp_decode_badmsg() to separate testcase

* test: fix test_rtcp_decode_badmsg for OOM
  • Loading branch information
alfredh authored Jan 5, 2024
1 parent a3991df commit 34cce57
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
23 changes: 8 additions & 15 deletions test/rtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,21 +320,17 @@ static const uint8_t rtcp_sdes[] =
"";


static int test_rtcp_decode_badmsg(void)
int test_rtcp_decode_badmsg(void)
{
struct rtcp_msg *msg = NULL;
uint32_t ssrc = 0xcafebabe;
struct mbuf *mb;
int err = 0;

mb = mbuf_alloc(128);
if (!mb) {
err = ENOMEM;
goto out;
}
struct mbuf *mb = mbuf_alloc(128);
if (!mb)
return ENOMEM;

err = rtcp_encode(mb, RTCP_PSFB, RTCP_PSFB_SLI,
ssrc, ssrc, NULL, NULL);
int err = rtcp_encode(mb, RTCP_PSFB, RTCP_PSFB_SLI,
ssrc, ssrc, NULL, NULL);
if (err)
goto out;

Expand All @@ -344,7 +340,8 @@ static int test_rtcp_decode_badmsg(void)

mb->pos = 0;

if (EBADMSG != rtcp_decode(&msg, mb)) {
int ret = rtcp_decode(&msg, mb);
if (EBADMSG != ret && ret != ENOMEM) {
err = EBADMSG;
goto out;
}
Expand Down Expand Up @@ -413,10 +410,6 @@ int test_rtcp_decode(void)
if (err)
goto out;

err = test_rtcp_decode_badmsg();
if (err)
return err;

out:
mem_deref(msg);
mem_deref(mb);
Expand Down
1 change: 1 addition & 0 deletions test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ static const struct test tests[] = {
TEST(test_rtcp_encode),
TEST(test_rtcp_encode_afb),
TEST(test_rtcp_decode),
TEST(test_rtcp_decode_badmsg),
TEST(test_rtcp_packetloss),
TEST(test_rtcp_twcc),
TEST(test_sa_class),
Expand Down
1 change: 1 addition & 0 deletions test/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ int test_rtpext(void);
int test_rtcp_encode(void);
int test_rtcp_encode_afb(void);
int test_rtcp_decode(void);
int test_rtcp_decode_badmsg(void);
int test_rtcp_packetloss(void);
int test_rtcp_twcc(void);
int test_sa_class(void);
Expand Down

0 comments on commit 34cce57

Please sign in to comment.