[PATCH] libosmocore[master]: timer_test: remove all random elements

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Thu Sep 22 04:33:08 UTC 2016


Review at  https://gerrit.osmocom.org/887

timer_test: remove all random elements

Change-Id: I9833031407e99f5d7a1144c26b68a7e320b2020d
---
M tests/timer/timer_test.c
1 file changed, 6 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/87/887/1

diff --git a/tests/timer/timer_test.c b/tests/timer/timer_test.c
index 461d060..d8e1ec9 100644
--- a/tests/timer/timer_test.c
+++ b/tests/timer/timer_test.c
@@ -93,7 +93,7 @@
 		osmo_gettimeofday(&v->start, NULL);
 		v->timer.cb = secondary_timer_fired;
 		v->timer.data = v;
-		unsigned int seconds = (random() % 10) + 1;
+		unsigned int seconds = (i & 0x7) + 1;
 		v->stop.tv_sec = v->start.tv_sec + seconds;
 		v->stop.tv_usec = v->start.tv_usec;
 		osmo_timer_schedule(&v->timer, seconds, 0);
@@ -111,6 +111,7 @@
 	struct test_timer *v = data, *this, *tmp;
 	struct timeval current, res;
 	struct timeval precision = { 0, TIME_BETWEEN_TIMER_CHECKS + 1};
+	int i;
 
 	osmo_gettimeofday(&current, NULL);
 
@@ -143,9 +144,11 @@
 		exit(EXIT_SUCCESS);
 	}
 
-	/* randomly (10%) deletion of timers. */
+	/* "random" deletion of timers. */
+	i = 0;
 	llist_for_each_entry_safe(this, tmp, &timer_test_list, head) {
-		if ((random() % 100) < 10) {
+		i ++;
+		if (!(i & 0x3)) {
 			osmo_timer_del(&this->timer);
 			llist_del(&this->head);
 			talloc_free(this);

-- 
To view, visit https://gerrit.osmocom.org/887
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9833031407e99f5d7a1144c26b68a7e320b2020d
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list