summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/fsm/fsm_test.c38
-rw-r--r--tests/fsm/fsm_test.err15
-rw-r--r--tests/fsm/fsm_test.ok4
3 files changed, 57 insertions, 0 deletions
diff --git a/tests/fsm/fsm_test.c b/tests/fsm/fsm_test.c
index 34a83993..7aac8d3e 100644
--- a/tests/fsm/fsm_test.c
+++ b/tests/fsm/fsm_test.c
@@ -349,6 +349,43 @@ static void test_state_chg_keep_timer()
fprintf(stderr, "--- %s() done\n", __func__);
}
+static void test_state_chg_T()
+{
+ struct osmo_fsm_inst *fi;
+
+ fprintf(stderr, "\n--- %s()\n", __func__);
+
+ fsm.timer_cb = NULL;
+
+ /* Test setting to timeout_secs = 0, T = 0 */
+ fi = osmo_fsm_inst_alloc(&fsm, g_ctx, NULL, LOGL_DEBUG, NULL);
+ OSMO_ASSERT(fi);
+
+ osmo_fsm_inst_state_chg(fi, ST_ONE, 23, 42);
+ printf("T = %d\n", fi->T);
+ OSMO_ASSERT(fi->T == 42);
+ osmo_fsm_inst_state_chg(fi, ST_TWO, 0, 0);
+ printf("T = %d\n", fi->T);
+ OSMO_ASSERT(fi->T == 0);
+
+ osmo_fsm_inst_term(fi, OSMO_FSM_TERM_REQUEST, NULL);
+
+ /* Test setting to timeout_secs = 0, T != 0 */
+ fi = osmo_fsm_inst_alloc(&fsm, g_ctx, NULL, LOGL_DEBUG, NULL);
+ OSMO_ASSERT(fi);
+
+ osmo_fsm_inst_state_chg(fi, ST_ONE, 23, 42);
+ printf("T = %d\n", fi->T);
+ OSMO_ASSERT(fi->T == 42);
+ osmo_fsm_inst_state_chg(fi, ST_TWO, 0, 11);
+ printf("T = %d\n", fi->T);
+ OSMO_ASSERT(fi->T == 11);
+
+ osmo_fsm_inst_term(fi, OSMO_FSM_TERM_REQUEST, NULL);
+
+ fprintf(stderr, "--- %s() done\n", __func__);
+}
+
static const struct log_info_cat default_categories[] = {
[DMAIN] = {
.name = "DMAIN",
@@ -390,6 +427,7 @@ int main(int argc, char **argv)
test_id_api();
test_state_chg_keep_timer();
+ test_state_chg_T();
osmo_fsm_unregister(&fsm);
exit(0);
diff --git a/tests/fsm/fsm_test.err b/tests/fsm/fsm_test.err
index 85606e2a..bf474aba 100644
--- a/tests/fsm/fsm_test.err
+++ b/tests/fsm/fsm_test.err
@@ -101,3 +101,18 @@ Test_FSM{TWO}: Timeout of T10
Test_FSM{TWO}: Freeing instance
Test_FSM{TWO}: Deallocated
--- test_state_chg_keep_timer() done
+
+--- test_state_chg_T()
+Test_FSM{NULL}: Allocated
+Test_FSM{NULL}: state_chg to ONE
+Test_FSM{ONE}: state_chg to TWO
+Test_FSM{TWO}: Terminating (cause = OSMO_FSM_TERM_REQUEST)
+Test_FSM{TWO}: Freeing instance
+Test_FSM{TWO}: Deallocated
+Test_FSM{NULL}: Allocated
+Test_FSM{NULL}: state_chg to ONE
+Test_FSM{ONE}: state_chg to TWO
+Test_FSM{TWO}: Terminating (cause = OSMO_FSM_TERM_REQUEST)
+Test_FSM{TWO}: Freeing instance
+Test_FSM{TWO}: Deallocated
+--- test_state_chg_T() done
diff --git a/tests/fsm/fsm_test.ok b/tests/fsm/fsm_test.ok
index e69de29b..c3536fba 100644
--- a/tests/fsm/fsm_test.ok
+++ b/tests/fsm/fsm_test.ok
@@ -0,0 +1,4 @@
+T = 42
+T = 0
+T = 42
+T = 11