From 4c365329a963434fe4bb04fec94e5d3d3bb4749c Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Wed, 29 Jul 2020 00:36:37 +0200 Subject: bsc CBSP: f_gen_page(): allow passing explicit payload len Keep the default of using a random payload length, but also allow picking one specifically. TC_cbsp_write_bss() will use this in a subsequent patch. Change-Id: I259da42cbcbfdfe930aabb45c9de8a2b67c69629 --- bsc/BSC_Tests_CBSP.ttcn | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'bsc') diff --git a/bsc/BSC_Tests_CBSP.ttcn b/bsc/BSC_Tests_CBSP.ttcn index f54de9b2..ea080a27 100644 --- a/bsc/BSC_Tests_CBSP.ttcn +++ b/bsc/BSC_Tests_CBSP.ttcn @@ -135,13 +135,17 @@ private function f_cbsp_init_tail() runs on cbsp_test_CT { } } -function f_gen_page() return CBSP_IE { - /* The maximum CBSP page payload space is 88, but 6 bytes of payload header are added in the first page: the - * maximum length generated here thus is 82. The minimum generated length is 1 (avoiding zero length). - * note, f_rnd_int(82) returns [0..81], so this results in a len ranging [1..82]: */ - var integer len := 1 + f_rnd_int(82); - var octetstring payload := f_rnd_octstring(len); - return valueof(ts_CbspMsgContent(payload, len)); +/* Generate a CBSP payload: random size for payload_len == 0, or specific fixed size for payload_len > 0. */ +function f_gen_page(integer payload_len := 0) return CBSP_IE { + if (payload_len < 1) { + /* The maximum CBSP page payload space is 88, but 6 bytes of payload header are added in the first page: + * the maximum length generated here thus is 82. The minimum generated length is 1 (avoiding zero + * length). Note, f_rnd_int(82) returns [0..81], so this results in a len ranging [1..82]: */ + payload_len := 1 + f_rnd_int(82); + } + log("Generating CBSP payload: ", payload_len, " octets"); + var octetstring payload := f_rnd_octstring(payload_len); + return valueof(ts_CbspMsgContent(payload, payload_len)); } function f_cbsp_reset_bss(integer idx) runs on CBSP_Adapter_CT { -- cgit v1.2.3