diff options
author | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2014-11-24 14:40:28 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2014-12-02 09:18:19 +0100 |
commit | aec03a1f136abcd9bf59f4ec7cce9bd490fe8c81 (patch) | |
tree | 8c848d56c7ab8a55695117bdac51f6b47153b7e2 | |
parent | 59ac49dc1fd3b1435ef2eeb0b5daf555a946cde6 (diff) |
sgsn/test: Don't rely on the actual PRNG sequence
Currently the expected P-TMSI generated by the SGSN is hard-coded
into the test. This adds a dependency on the implementation of rand()
and thus the libc used. This breaks the test e.g. on FreeBSD.
This patch modifies test_gmm_attach() to srand(1) first, generate the
P-TMSI, and finally srand(1) again before starting the test.
Sponsored-by: On-Waves ehf
-rw-r--r-- | openbsc/tests/sgsn/sgsn_test.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c index d6091fdab..464f4d742 100644 --- a/openbsc/tests/sgsn/sgsn_test.c +++ b/openbsc/tests/sgsn/sgsn_test.c @@ -297,6 +297,7 @@ static void test_gmm_attach(void) struct gprs_ra_id raid = { 0, }; struct sgsn_mm_ctx *ctx = NULL; struct sgsn_mm_ctx *ictx; + uint32_t ptmsi1; uint32_t foreign_tlli; uint32_t local_tlli = 0; struct gprs_llc_lle *lle; @@ -340,6 +341,13 @@ static void test_gmm_attach(void) /* reset the PRNG used by sgsn_alloc_ptmsi */ srand(1); + ptmsi1 = sgsn_alloc_ptmsi(); + OSMO_ASSERT(ptmsi1 != GSM_RESERVED_TMSI); + + /* reset the PRNG, so that the same P-TMSI sequence will be generated + * again */ + srand(1); + sgsn_acl_add("123456789012345", &sgsn->cfg); foreign_tlli = gprs_tmsi2tlli(0xc0000023, TLLI_FOREIGN); @@ -381,7 +389,7 @@ static void test_gmm_attach(void) OSMO_ASSERT(sgsn_tx_counter == 1); /* this has been randomly assigned by the SGSN */ - local_tlli = gprs_tmsi2tlli(0xeb8b4567, TLLI_LOCAL); + local_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL); /* inject the attach complete */ send_0408_message(ctx->llme, local_tlli, |