rlc: Test the basic of the gprs_rlc_v_n code for remembering the state

This commit is contained in:
Holger Hans Peter Freyther 2013-11-24 22:00:43 +01:00
parent 270f7fce1d
commit e9b1ebba9d
4 changed files with 31 additions and 3 deletions

View File

@ -386,8 +386,6 @@ void Encoding::write_packet_uplink_ack(struct gprs_rlcmac_bts *bts,
for (i = 0, bbn = (tbf->dir.ul.window.v_r() - 64) & mod_sns_half; i < 64;
i++, bbn = (bbn + 1) & mod_sns_half) {
bit = tbf->dir.ul.v_n.state(bbn);
if (bit == 0)
bit = ' ';
show_v_n[i] = bit;
if (bit == 'R')
rbb = (rbb << 1)|1;

View File

@ -138,3 +138,8 @@ void gprs_rlc_v_b::state(char *show_v_b, const gprs_rlc_dl_window &w)
}
show_v_b[i] = '\0';
}
void gprs_rlc_v_n::reset()
{
memset(m_v_n, 0x0, sizeof(m_v_n));
}

View File

@ -130,6 +130,8 @@ private:
};
struct gprs_rlc_v_n {
void reset();
void mark_received(int index);
void mark_missing(int index);
@ -357,5 +359,8 @@ inline bool gprs_rlc_v_n::is_received(int index) const
inline char gprs_rlc_v_n::state(int index) const
{
return m_v_n[index];
char bit = m_v_n[index];
if (bit == '\0')
return ' ';
return bit;
}

View File

@ -115,12 +115,32 @@ static void test_rlc_v_b()
}
}
static void test_rlc_v_n()
{
{
gprs_rlc_v_n vn;
vn.reset();
OSMO_ASSERT(!vn.is_received(0x23));
OSMO_ASSERT(vn.state(0x23) == ' ');
vn.mark_received(0x23);
OSMO_ASSERT(vn.is_received(0x23));
OSMO_ASSERT(vn.state(0x23) == 'R');
vn.mark_missing(0x23);
OSMO_ASSERT(!vn.is_received(0x23));
OSMO_ASSERT(vn.state(0x23) == 'N');
}
}
int main(int argc, char **argv)
{
printf("Making some basic type testing.\n");
test_llc();
test_rlc();
test_rlc_v_b();
test_rlc_v_n();
return EXIT_SUCCESS;
}