Change in libosmocore[master]: fix tdef_test.c: do call the function-to-test in all cases

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
Wed Mar 6 05:58:45 UTC 2019


Neels Hofmeyr has uploaded this change for review. ( https://gerrit.osmocom.org/13142


Change subject: fix tdef_test.c: do call the function-to-test in all cases
......................................................................

fix tdef_test.c: do call the function-to-test in all cases

Always call osmo_tdef_fsm_inst_state_chg(), also when no timeout is defined.

When there is no timeout defined for a state, tdef_test.c tries to be smart and
print different output. In that mess, I missed the fact that
osmo_tdef_fsm_inst_state_chg() isn't always called as it should. In the same
mess, the resulting state was never printed until the preceding patch, which
helped to hide this bug.

Change-Id: I1d953d99854422bff8eb32f051e9c6147bc836b6
---
M tests/tdef/tdef_test.c
M tests/tdef/tdef_test.ok
M tests/tdef/tdef_test_range_64bit.ok
3 files changed, 19 insertions(+), 19 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/42/13142/1

diff --git a/tests/tdef/tdef_test.c b/tests/tdef/tdef_test.c
index fe2accf..12ca802 100644
--- a/tests/tdef/tdef_test.c
+++ b/tests/tdef/tdef_test.c
@@ -323,12 +323,12 @@
 #define test_tdef_fsm_state_chg(tdefs, NEXT_STATE) do { \
 		const struct osmo_tdef_state_timeout *st = osmo_tdef_get_state_timeout(NEXT_STATE, \
 										       test_tdef_state_timeouts); \
+		int rc = osmo_tdef_fsm_inst_state_chg(fi, NEXT_STATE, test_tdef_state_timeouts, tdefs, 999); \
 		if (!st) { \
-			printf(" --> %s (no timer configured for this state)\t", \
-			       osmo_fsm_state_name(&test_tdef_fsm, NEXT_STATE)); \
+			printf(" --> %s (no timer configured for this state) rc=%d;\t", \
+			       osmo_fsm_state_name(&test_tdef_fsm, NEXT_STATE), rc); \
 		} else { \
 			struct osmo_tdef *t = osmo_tdef_get_entry(tdefs, st->T); \
-			int rc = osmo_tdef_fsm_inst_state_chg(fi, NEXT_STATE, test_tdef_state_timeouts, tdefs, 999); \
 			printf(" --> %s (configured as T%d%s %lu %s) rc=%d;\t", \
 			       osmo_fsm_state_name(&test_tdef_fsm, NEXT_STATE), \
 			       st->T, st->keep_timer ? "(keep_timer)" : "", \
diff --git a/tests/tdef/tdef_test.ok b/tests/tdef/tdef_test.ok
index 1acf0e6..135951e 100644
--- a/tests/tdef/tdef_test.ok
+++ b/tests/tdef/tdef_test.ok
@@ -131,16 +131,16 @@
 Time passes: 23.045678 s
 state=A T=1, 76.954322 s remaining
  --> L (configured as T123(keep_timer) 1 s) rc=0;	state=L T=123, 76.954322 s remaining
- --> O (no timer configured for this state)	state=L T=123, 76.954322 s remaining
- --> L (configured as T123(keep_timer) 1 s) rc=0;	state=L T=123, 76.954322 s remaining
+ --> O (no timer configured for this state) rc=0;	state=O T=0, no timeout
+ --> L (configured as T123(keep_timer) 1 s) rc=0;	state=L T=123, no timeout
 - test T=0:
- --> O (no timer configured for this state)	state=L T=123, 76.954322 s remaining
+ --> O (no timer configured for this state) rc=0;	state=O T=0, no timeout
 - test no timer:
- --> X (no timer configured for this state)	state=L T=123, 76.954322 s remaining
+ --> X (no timer configured for this state) rc=0;	state=X T=0, no timeout
 - test undefined timer, using default_val arg of osmo_tdef_fsm_inst_state_chg(), here passed as 999:
  --> Y (configured as T666 0 -) rc=0;	state=Y T=666, 999.000000 s remaining
 - test disallowed transition:
- --> Z (no timer configured for this state)	state=Y T=666, 999.000000 s remaining
- --> B (configured as T2 100 ms) rc=0;	state=B T=2, 1.000000 s remaining
- --> C (configured as T3 100 m) rc=0;	state=C T=3, 6000.000000 s remaining
- --> D (configured as T4 100 custom-unit) rc=0;	state=D T=4, 100.000000 s remaining
+ --> Z (no timer configured for this state) rc=0;	state=Z T=0, no timeout
+ --> B (configured as T2 100 ms) rc=-1;	state=Z T=0, no timeout
+ --> C (configured as T3 100 m) rc=-1;	state=Z T=0, no timeout
+ --> D (configured as T4 100 custom-unit) rc=-1;	state=Z T=0, no timeout
diff --git a/tests/tdef/tdef_test_range_64bit.ok b/tests/tdef/tdef_test_range_64bit.ok
index 72ac466..eed58e6 100644
--- a/tests/tdef/tdef_test_range_64bit.ok
+++ b/tests/tdef/tdef_test_range_64bit.ok
@@ -159,12 +159,12 @@
 Time passes: 23.045678 s
 state=A T=1, 76.954322 s remaining
  --> L (configured as T123(keep_timer) 1 s) rc=0;	state=L T=123, 76.954322 s remaining
- --> O (no timer configured for this state)	state=L T=123, 76.954322 s remaining
- --> L (configured as T123(keep_timer) 1 s) rc=0;	state=L T=123, 76.954322 s remaining
+ --> O (no timer configured for this state) rc=0;	state=O T=0, no timeout
+ --> L (configured as T123(keep_timer) 1 s) rc=0;	state=L T=123, no timeout
 - test T=0:
- --> O (no timer configured for this state)	state=L T=123, 76.954322 s remaining
+ --> O (no timer configured for this state) rc=0;	state=O T=0, no timeout
 - test no timer:
- --> X (no timer configured for this state)	state=L T=123, 76.954322 s remaining
+ --> X (no timer configured for this state) rc=0;	state=X T=0, no timeout
 - test undefined timer, using default_val arg of osmo_tdef_fsm_inst_state_chg(), here passed as 999:
  --> Y (configured as T666 0 -) rc=0;	state=Y T=666, 999.000000 s remaining
 - test large T:
@@ -370,7 +370,7 @@
  --> M (configured as T2147483647 18446744073709551615 s) rc=0;	state=M T=2147483647, 2147483647.000000 s remaining
  --> M (configured as T2147483647 0 s) rc=0;	state=M T=2147483647, no timeout
 - test disallowed transition:
- --> Z (no timer configured for this state)	state=M T=2147483647, no timeout
- --> B (configured as T2 100 ms) rc=0;	state=B T=2, 1.000000 s remaining
- --> C (configured as T3 100 m) rc=0;	state=C T=3, 6000.000000 s remaining
- --> D (configured as T4 100 custom-unit) rc=0;	state=D T=4, 100.000000 s remaining
+ --> Z (no timer configured for this state) rc=0;	state=Z T=0, no timeout
+ --> B (configured as T2 100 ms) rc=-1;	state=Z T=0, no timeout
+ --> C (configured as T3 100 m) rc=-1;	state=Z T=0, no timeout
+ --> D (configured as T4 100 custom-unit) rc=-1;	state=Z T=0, no timeout

-- 
To view, visit https://gerrit.osmocom.org/13142
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1d953d99854422bff8eb32f051e9c6147bc836b6
Gerrit-Change-Number: 13142
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190306/70ae1abc/attachment.htm>


More information about the gerrit-log mailing list