From aec03a1f136abcd9bf59f4ec7cce9bd490fe8c81 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Mon, 24 Nov 2014 14:40:28 +0100 Subject: 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 --- openbsc/tests/sgsn/sgsn_test.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'openbsc') 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, -- cgit v1.2.3