dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/30945 )
Change subject: gsm0408_test: add unittest for gsm_gsmtime2fn() ...................................................................... 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 --- M tests/gsm0408/gsm0408_test.c 1 file changed, 22 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/45/30945/1 diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c index a226718..4436d51 100644 --- a/tests/gsm0408/gsm0408_test.c +++ b/tests/gsm0408/gsm0408_test.c @@ -1760,6 +1760,27 @@ } } +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 @@ test_range_encoding(); test_power_ctrl(); test_rach_tx_integer_raw2val(); + test_gsm_gsmtime2fn(); return EXIT_SUCCESS; } -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/30945 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I8b9b71c8dcccf3b44326b5e61229f4637689d763 Gerrit-Change-Number: 30945 Gerrit-PatchSet: 1 Gerrit-Owner: dexter <pma...@sysmocom.de> Gerrit-MessageType: newchange