diff options
author | Sylvain Munaut <tnt@246tNt.com> | 2022-04-20 13:29:21 +0000 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2022-04-20 15:48:26 +0200 |
commit | ce817ca1491390d1f67051a7180ea73c3596a70e (patch) | |
tree | e404eb5839cac9b8c05f4483c0fac6edec9cfa40 /tests | |
parent | f226f50d12a02af460f996be3b3cab8377b3100e (diff) |
rifo_test: Use a helper function for the rifo init
Because we poke at some of the internals we need to make
sure to maintain the internal state consistent.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I5d9397be391c60f732c89f158d25660e1f32cfac
Diffstat (limited to 'tests')
-rw-r--r-- | tests/rifo/rifo_test.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/tests/rifo/rifo_test.c b/tests/rifo/rifo_test.c index 06c882c..4e7ae45 100644 --- a/tests/rifo/rifo_test.c +++ b/tests/rifo/rifo_test.c @@ -11,6 +11,13 @@ static void *g_e1d_ctx; static uint32_t init_next_out_fn; +static void rifo_init(struct frame_rifo *rifo) +{ + frame_rifo_init(rifo); + rifo->next_out_fn = init_next_out_fn; + rifo->last_in_fn = init_next_out_fn - 1; +} + static void rifo_in(struct frame_rifo *rifo, uint8_t *frame, uint32_t fn) { int rc = frame_rifo_in(rifo, frame, fn); @@ -32,6 +39,7 @@ static void missing_frames(uint8_t modulo) struct frame_rifo rifo; frame_rifo_init(&rifo); rifo.next_out_fn = init_next_out_fn; + rifo.last_in_fn = init_next_out_fn - 1; printf("\nTEST: %s, starting at FN: %u\n", __func__, init_next_out_fn); @@ -54,8 +62,7 @@ static void missing_frames(uint8_t modulo) static void reordered_in(void) { struct frame_rifo rifo; - frame_rifo_init(&rifo); - rifo.next_out_fn = init_next_out_fn; + rifo_init(&rifo); printf("\nTEST: %s, starting at FN: %u\n", __func__, init_next_out_fn); @@ -76,8 +83,7 @@ static void reordered_in(void) static void correct_order(void) { struct frame_rifo rifo; - frame_rifo_init(&rifo); - rifo.next_out_fn = init_next_out_fn; + rifo_init(&rifo); printf("\nTEST: %s, starting at FN: %u\n", __func__, init_next_out_fn); @@ -98,8 +104,7 @@ static void correct_order(void) static void too_old_frames(void) { struct frame_rifo rifo; - frame_rifo_init(&rifo); - rifo.next_out_fn = init_next_out_fn; + rifo_init(&rifo); printf("\nTEST: %s, starting at FN: %u\n", __func__, init_next_out_fn); @@ -133,8 +138,7 @@ static void bound_check(void) { uint8_t frame[32]; struct frame_rifo rifo; - frame_rifo_init(&rifo); - rifo.next_out_fn = init_next_out_fn; + rifo_init(&rifo); printf("\nTEST: %s, starting at FN: %u\n", __func__, init_next_out_fn); |