mirror of https://gerrit.osmocom.org/libosmocore
gsm0408_test: add unittest for gsm_gsmtime2fn()
The function gsm_gsmtime2fn(), which is used to compute a frame number value from given starting time values T1, T2 and T3 has no unit test. Due to to the modulo that is used the computation can be a bit tricky. Lets add a unit-test to make sure the function works as expected. Change-Id: I8b9b71c8dcccf3b44326b5e61229f4637689d763
This commit is contained in:
parent
94705d042a
commit
b6a3836ad2
|
@ -1760,6 +1760,27 @@ static void test_rach_tx_integer_raw2val(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void test_gsm_gsmtime2fn(void)
|
||||
{
|
||||
struct gsm_time gsm_time;
|
||||
uint32_t fn;
|
||||
uint32_t fn_recovered;
|
||||
|
||||
for (fn = 0; fn < 42432; fn++) {
|
||||
gsm_time.t1 = (fn / 1326) % 32;
|
||||
gsm_time.t2 = fn % 26;
|
||||
gsm_time.t3 = fn % 51;
|
||||
|
||||
fn_recovered = gsm_gsmtime2fn(&gsm_time);
|
||||
|
||||
if (fn_recovered != fn) {
|
||||
printf(" Wrong frame number computed! t1=%d, t2=%d, t3=%d ==> fn=%d, expected fn=%d\n",
|
||||
gsm_time.t1, gsm_time.t2, gsm_time.t3, fn_recovered, fn);
|
||||
OSMO_ASSERT(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
test_bearer_cap();
|
||||
|
@ -1779,6 +1800,7 @@ int main(int argc, char **argv)
|
|||
test_range_encoding();
|
||||
test_power_ctrl();
|
||||
test_rach_tx_integer_raw2val();
|
||||
test_gsm_gsmtime2fn();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue