<p>Neels Hofmeyr has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/13142">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">fix tdef_test.c: do call the function-to-test in all cases<br><br>Always call osmo_tdef_fsm_inst_state_chg(), also when no timeout is defined.<br><br>When there is no timeout defined for a state, tdef_test.c tries to be smart and<br>print different output. In that mess, I missed the fact that<br>osmo_tdef_fsm_inst_state_chg() isn't always called as it should. In the same<br>mess, the resulting state was never printed until the preceding patch, which<br>helped to hide this bug.<br><br>Change-Id: I1d953d99854422bff8eb32f051e9c6147bc836b6<br>---<br>M tests/tdef/tdef_test.c<br>M tests/tdef/tdef_test.ok<br>M tests/tdef/tdef_test_range_64bit.ok<br>3 files changed, 19 insertions(+), 19 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/42/13142/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/tests/tdef/tdef_test.c b/tests/tdef/tdef_test.c</span><br><span>index fe2accf..12ca802 100644</span><br><span>--- a/tests/tdef/tdef_test.c</span><br><span>+++ b/tests/tdef/tdef_test.c</span><br><span>@@ -323,12 +323,12 @@</span><br><span> #define test_tdef_fsm_state_chg(tdefs, NEXT_STATE) do { \</span><br><span>          const struct osmo_tdef_state_timeout *st = osmo_tdef_get_state_timeout(NEXT_STATE, \</span><br><span>                                                                                        test_tdef_state_timeouts); \</span><br><span style="color: hsl(120, 100%, 40%);">+           int rc = osmo_tdef_fsm_inst_state_chg(fi, NEXT_STATE, test_tdef_state_timeouts, tdefs, 999); \</span><br><span>               if (!st) { \</span><br><span style="color: hsl(0, 100%, 40%);">-                    printf(" --> %s (no timer configured for this state)\t", \</span><br><span style="color: hsl(0, 100%, 40%);">-                        osmo_fsm_state_name(&test_tdef_fsm, NEXT_STATE)); \</span><br><span style="color: hsl(120, 100%, 40%);">+                        printf(" --> %s (no timer configured for this state) rc=%d;\t", \</span><br><span style="color: hsl(120, 100%, 40%);">+                               osmo_fsm_state_name(&test_tdef_fsm, NEXT_STATE), rc); \</span><br><span>           } else { \</span><br><span>                   struct osmo_tdef *t = osmo_tdef_get_entry(tdefs, st->T); \</span><br><span style="color: hsl(0, 100%, 40%);">-                   int rc = osmo_tdef_fsm_inst_state_chg(fi, NEXT_STATE, test_tdef_state_timeouts, tdefs, 999); \</span><br><span>                       printf(" --> %s (configured as T%d%s %lu %s) rc=%d;\t", \</span><br><span>                              osmo_fsm_state_name(&test_tdef_fsm, NEXT_STATE), \</span><br><span>                               st->T, st->keep_timer ? "(keep_timer)" : "", \</span><br><span>diff --git a/tests/tdef/tdef_test.ok b/tests/tdef/tdef_test.ok</span><br><span>index 1acf0e6..135951e 100644</span><br><span>--- a/tests/tdef/tdef_test.ok</span><br><span>+++ b/tests/tdef/tdef_test.ok</span><br><span>@@ -131,16 +131,16 @@</span><br><span> Time passes: 23.045678 s</span><br><span> state=A T=1, 76.954322 s remaining</span><br><span>  --> L (configured as T123(keep_timer) 1 s) rc=0;      state=L T=123, 76.954322 s remaining</span><br><span style="color: hsl(0, 100%, 40%);">- --> O (no timer configured for this state)      state=L T=123, 76.954322 s remaining</span><br><span style="color: hsl(0, 100%, 40%);">- --> L (configured as T123(keep_timer) 1 s) rc=0;        state=L T=123, 76.954322 s remaining</span><br><span style="color: hsl(120, 100%, 40%);">+ --> O (no timer configured for this state) rc=0;      state=O T=0, no timeout</span><br><span style="color: hsl(120, 100%, 40%);">+ --> L (configured as T123(keep_timer) 1 s) rc=0;   state=L T=123, no timeout</span><br><span> - test T=0:</span><br><span style="color: hsl(0, 100%, 40%);">- --> O (no timer configured for this state)  state=L T=123, 76.954322 s remaining</span><br><span style="color: hsl(120, 100%, 40%);">+ --> O (no timer configured for this state) rc=0;      state=O T=0, no timeout</span><br><span> - test no timer:</span><br><span style="color: hsl(0, 100%, 40%);">- --> X (no timer configured for this state)       state=L T=123, 76.954322 s remaining</span><br><span style="color: hsl(120, 100%, 40%);">+ --> X (no timer configured for this state) rc=0;      state=X T=0, no timeout</span><br><span> - test undefined timer, using default_val arg of osmo_tdef_fsm_inst_state_chg(), here passed as 999:</span><br><span>  --> Y (configured as T666 0 -) rc=0;     state=Y T=666, 999.000000 s remaining</span><br><span> - test disallowed transition:</span><br><span style="color: hsl(0, 100%, 40%);">- --> Z (no timer configured for this state)    state=Y T=666, 999.000000 s remaining</span><br><span style="color: hsl(0, 100%, 40%);">- --> B (configured as T2 100 ms) rc=0;  state=B T=2, 1.000000 s remaining</span><br><span style="color: hsl(0, 100%, 40%);">- --> C (configured as T3 100 m) rc=0;       state=C T=3, 6000.000000 s remaining</span><br><span style="color: hsl(0, 100%, 40%);">- --> D (configured as T4 100 custom-unit) rc=0;  state=D T=4, 100.000000 s remaining</span><br><span style="color: hsl(120, 100%, 40%);">+ --> Z (no timer configured for this state) rc=0;       state=Z T=0, no timeout</span><br><span style="color: hsl(120, 100%, 40%);">+ --> B (configured as T2 100 ms) rc=-1;     state=Z T=0, no timeout</span><br><span style="color: hsl(120, 100%, 40%);">+ --> C (configured as T3 100 m) rc=-1;      state=Z T=0, no timeout</span><br><span style="color: hsl(120, 100%, 40%);">+ --> D (configured as T4 100 custom-unit) rc=-1;    state=Z T=0, no timeout</span><br><span>diff --git a/tests/tdef/tdef_test_range_64bit.ok b/tests/tdef/tdef_test_range_64bit.ok</span><br><span>index 72ac466..eed58e6 100644</span><br><span>--- a/tests/tdef/tdef_test_range_64bit.ok</span><br><span>+++ b/tests/tdef/tdef_test_range_64bit.ok</span><br><span>@@ -159,12 +159,12 @@</span><br><span> Time passes: 23.045678 s</span><br><span> state=A T=1, 76.954322 s remaining</span><br><span>  --> L (configured as T123(keep_timer) 1 s) rc=0;      state=L T=123, 76.954322 s remaining</span><br><span style="color: hsl(0, 100%, 40%);">- --> O (no timer configured for this state)      state=L T=123, 76.954322 s remaining</span><br><span style="color: hsl(0, 100%, 40%);">- --> L (configured as T123(keep_timer) 1 s) rc=0;        state=L T=123, 76.954322 s remaining</span><br><span style="color: hsl(120, 100%, 40%);">+ --> O (no timer configured for this state) rc=0;      state=O T=0, no timeout</span><br><span style="color: hsl(120, 100%, 40%);">+ --> L (configured as T123(keep_timer) 1 s) rc=0;   state=L T=123, no timeout</span><br><span> - test T=0:</span><br><span style="color: hsl(0, 100%, 40%);">- --> O (no timer configured for this state)  state=L T=123, 76.954322 s remaining</span><br><span style="color: hsl(120, 100%, 40%);">+ --> O (no timer configured for this state) rc=0;      state=O T=0, no timeout</span><br><span> - test no timer:</span><br><span style="color: hsl(0, 100%, 40%);">- --> X (no timer configured for this state)       state=L T=123, 76.954322 s remaining</span><br><span style="color: hsl(120, 100%, 40%);">+ --> X (no timer configured for this state) rc=0;      state=X T=0, no timeout</span><br><span> - test undefined timer, using default_val arg of osmo_tdef_fsm_inst_state_chg(), here passed as 999:</span><br><span>  --> Y (configured as T666 0 -) rc=0;     state=Y T=666, 999.000000 s remaining</span><br><span> - test large T:</span><br><span>@@ -370,7 +370,7 @@</span><br><span>  --> M (configured as T2147483647 18446744073709551615 s) rc=0;    state=M T=2147483647, 2147483647.000000 s remaining</span><br><span>  --> M (configured as T2147483647 0 s) rc=0;  state=M T=2147483647, no timeout</span><br><span> - test disallowed transition:</span><br><span style="color: hsl(0, 100%, 40%);">- --> Z (no timer configured for this state) state=M T=2147483647, no timeout</span><br><span style="color: hsl(0, 100%, 40%);">- --> B (configured as T2 100 ms) rc=0;       state=B T=2, 1.000000 s remaining</span><br><span style="color: hsl(0, 100%, 40%);">- --> C (configured as T3 100 m) rc=0;       state=C T=3, 6000.000000 s remaining</span><br><span style="color: hsl(0, 100%, 40%);">- --> D (configured as T4 100 custom-unit) rc=0;  state=D T=4, 100.000000 s remaining</span><br><span style="color: hsl(120, 100%, 40%);">+ --> Z (no timer configured for this state) rc=0;       state=Z T=0, no timeout</span><br><span style="color: hsl(120, 100%, 40%);">+ --> B (configured as T2 100 ms) rc=-1;     state=Z T=0, no timeout</span><br><span style="color: hsl(120, 100%, 40%);">+ --> C (configured as T3 100 m) rc=-1;      state=Z T=0, no timeout</span><br><span style="color: hsl(120, 100%, 40%);">+ --> D (configured as T4 100 custom-unit) rc=-1;    state=Z T=0, no timeout</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/13142">change 13142</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/13142"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I1d953d99854422bff8eb32f051e9c6147bc836b6 </div>
<div style="display:none"> Gerrit-Change-Number: 13142 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>