aboutsummaryrefslogtreecommitdiffstats
path: root/tests/tdef/tdef_test.c
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2019-03-06 06:03:24 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2019-03-06 06:59:47 +0100
commit4f54c6c48d90ee94c3115a8ea6c60333e398e116 (patch)
tree1c7e8496794ee1f0758f530292aba92f191e2b1f /tests/tdef/tdef_test.c
parent5734bff3b01da2a7369da07f77ad617c3ac32096 (diff)
tdef_test: tweak output to prepare for a fix
- Always print the state after a state transition. This shows that actually state transitions are missing for states that have no timer defined. This is a bug in tdef_test.c, to be fixed subsequently. - Instead of total time passed since start, print the individual fake time intervals. Omit initial useless zero fake time advance. - Add two more state transitions, back out from and into a state that has no timeout set. Change-Id: Icb31af96d37741e256ff07868f3d4f5c48cdda74
Diffstat (limited to 'tests/tdef/tdef_test.c')
-rw-r--r--tests/tdef/tdef_test.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/tests/tdef/tdef_test.c b/tests/tdef/tdef_test.c
index f5b6413c..fe2accfa 100644
--- a/tests/tdef/tdef_test.c
+++ b/tests/tdef/tdef_test.c
@@ -287,7 +287,7 @@ const struct timeval fake_time_start_time = { 123, 456 };
osmo_gettimeofday_override_add(secs, usecs); \
osmo_clock_override_add(CLOCK_MONOTONIC, secs, usecs * 1000); \
timersub(&osmo_gettimeofday_override_time, &fake_time_start_time, &diff); \
- printf("Total time passed: %ld.%06ld s\n", diff.tv_sec, diff.tv_usec); \
+ printf("Time passes: %ld.%06ld s\n", (long)secs, (long)usecs); \
osmo_timers_prepare(); \
osmo_timers_update(); \
} while (0)
@@ -303,7 +303,6 @@ void fake_time_start()
clock_override->tv_sec = fake_time_start_time.tv_sec;
clock_override->tv_nsec = fake_time_start_time.tv_usec * 1000;
osmo_clock_override_enable(CLOCK_MONOTONIC, true);
- fake_time_passes(0, 0);
}
static void print_fsm_state(struct osmo_fsm_inst *fi)
@@ -325,18 +324,18 @@ static void print_fsm_state(struct osmo_fsm_inst *fi)
const struct osmo_tdef_state_timeout *st = osmo_tdef_get_state_timeout(NEXT_STATE, \
test_tdef_state_timeouts); \
if (!st) { \
- printf(" --> %s (no timer configured for this state)\n", \
+ printf(" --> %s (no timer configured for this state)\t", \
osmo_fsm_state_name(&test_tdef_fsm, NEXT_STATE)); \
} 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), \
+ 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)" : "", \
t? t->val : 0, t? osmo_tdef_unit_name(t->unit) : "-", \
rc); \
- print_fsm_state(fi); \
} \
+ print_fsm_state(fi); \
} while(0)
@@ -378,6 +377,8 @@ static void test_tdef_state_timeout(bool test_range)
fake_time_passes(23, 45678);
print_fsm_state(fi);
test_tdef_fsm_state_chg(tdefs, S_L);
+ test_tdef_fsm_state_chg(tdefs, S_O);
+ test_tdef_fsm_state_chg(tdefs, S_L);
printf("- test T=0:\n");
test_tdef_fsm_state_chg(tdefs, S_O);