Skip to content

Commit 42a600d

Browse files
herlesupreethcodebot
authored andcommitted
unittest: add test to verify assigning of leftover bytes to last SDU
1 parent 196b823 commit 42a600d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/unittests/scheduler/ue_scheduling/logical_channel_test.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,3 +271,27 @@ TEST(ul_logical_channel_test, when_logical_channel_groups_are_inactive_then_no_u
271271
ul_lch_mng2.set_status(lcg_id, false);
272272
ASSERT_EQ(ul_lch_mng2.pending_bytes(), 0);
273273
}
274+
275+
TEST(dl_logical_channel_test, assign_leftover_bytes_to_sdu_if_leftover_bytes_is_less_than_five_bytes)
276+
{
277+
const unsigned tb_size = 309;
278+
279+
dl_logical_channel_manager lch_mng;
280+
lcid_dl_sch_t ce_lcid = lcid_dl_sch_t::UE_CON_RES_ID;
281+
const unsigned dummy_ce_payload = 0;
282+
lch_mng.handle_mac_ce_indication({.ce_lcid = ce_lcid, .ce_payload = dummy_ce_payload});
283+
lch_mng.set_status(LCID_SRB0, true);
284+
lch_mng.set_status(LCID_SRB1, true);
285+
lch_mng.handle_dl_buffer_status_indication(LCID_SRB0, 295);
286+
lch_mng.handle_dl_buffer_status_indication(LCID_SRB1, 10000);
287+
288+
dl_msg_lc_info subpdu;
289+
290+
unsigned allocated_bytes = 0;
291+
// ConRes occupies 7 bytes => 6 bytes ConRes CE + 1 bytes header.
292+
allocated_bytes += lch_mng.allocate_ue_con_res_id_mac_ce(subpdu, tb_size);
293+
// SRB0 SDU requires at least 298 bytes => 295 payload size + 3 bytes MAC header. Leftover bytes = 4 bytes.
294+
allocated_bytes += lch_mng.allocate_mac_sdu(subpdu, tb_size - allocated_bytes, LCID_SRB0);
295+
// Verify leftover bytes are assigned to the last SDU.
296+
ASSERT_EQ(allocated_bytes, tb_size);
297+
}

0 commit comments

Comments
 (0)