blob: 3c4a0930899bf570cc5fcc3176b2ab8186a7a8f2 [file] [log] [blame]
Neels Hofmeyr0fd615f2019-01-26 20:36:12 +01001
2test_tdef_get()
3T1=100s
4osmo_tdef_get(1, s) = 100
5osmo_tdef_get(1, ms) = 100000
6osmo_tdef_get(1, m) = 2
7osmo_tdef_get(1, custom-unit) = 100
8T2=100ms
9osmo_tdef_get(2, s) = 1
10osmo_tdef_get(2, ms) = 100
11osmo_tdef_get(2, m) = 1
12osmo_tdef_get(2, custom-unit) = 100
13T3=100m
14osmo_tdef_get(3, s) = 6000
15osmo_tdef_get(3, ms) = 6000000
16osmo_tdef_get(3, m) = 100
17osmo_tdef_get(3, custom-unit) = 100
18T4=100custom-unit
19osmo_tdef_get(4, s) = 100
20osmo_tdef_get(4, ms) = 100
21osmo_tdef_get(4, m) = 100
22osmo_tdef_get(4, custom-unit) = 100
23T7=50s
24osmo_tdef_get(7, s) = 50
25osmo_tdef_get(7, ms) = 50000
26osmo_tdef_get(7, m) = 1
27osmo_tdef_get(7, custom-unit) = 50
28T8=300s
29osmo_tdef_get(8, s) = 300
30osmo_tdef_get(8, ms) = 300000
31osmo_tdef_get(8, m) = 5
32osmo_tdef_get(8, custom-unit) = 300
33T9=5m
34osmo_tdef_get(9, s) = 300
35osmo_tdef_get(9, ms) = 300000
36osmo_tdef_get(9, m) = 5
37osmo_tdef_get(9, custom-unit) = 5
38T10=20m
39osmo_tdef_get(10, s) = 1200
40osmo_tdef_get(10, ms) = 1200000
41osmo_tdef_get(10, m) = 20
42osmo_tdef_get(10, custom-unit) = 20
43T1000=2000ms
44osmo_tdef_get(1000, s) = 2
45osmo_tdef_get(1000, ms) = 2000
46osmo_tdef_get(1000, m) = 1
47osmo_tdef_get(1000, custom-unit) = 2000
48T1001=60000ms
49osmo_tdef_get(1001, s) = 60
50osmo_tdef_get(1001, ms) = 60000
51osmo_tdef_get(1001, m) = 1
52osmo_tdef_get(1001, custom-unit) = 60000
Neels Hofmeyr0fd615f2019-01-26 20:36:12 +010053T1004=1ms
54osmo_tdef_get(1004, s) = 1
55osmo_tdef_get(1004, ms) = 1
56osmo_tdef_get(1004, m) = 1
57osmo_tdef_get(1004, custom-unit) = 1
58T1005=0ms
59osmo_tdef_get(1005, s) = 0
60osmo_tdef_get(1005, ms) = 0
61osmo_tdef_get(1005, m) = 0
62osmo_tdef_get(1005, custom-unit) = 0
63T1006=0s
64osmo_tdef_get(1006, s) = 0
65osmo_tdef_get(1006, ms) = 0
66osmo_tdef_get(1006, m) = 0
67osmo_tdef_get(1006, custom-unit) = 0
68T1007=0m
69osmo_tdef_get(1007, s) = 0
70osmo_tdef_get(1007, ms) = 0
71osmo_tdef_get(1007, m) = 0
72osmo_tdef_get(1007, custom-unit) = 0
73T1008=0custom-unit
74osmo_tdef_get(1008, s) = 0
75osmo_tdef_get(1008, ms) = 0
76osmo_tdef_get(1008, m) = 0
77osmo_tdef_get(1008, custom-unit) = 0
Neels Hofmeyr0fd615f2019-01-26 20:36:12 +010078T0=1custom-unit
79osmo_tdef_get(0, s) = 1
80osmo_tdef_get(0, ms) = 1
81osmo_tdef_get(0, m) = 1
82osmo_tdef_get(0, custom-unit) = 1
83T123=1s
84osmo_tdef_get(123, s) = 1
85osmo_tdef_get(123, ms) = 1000
86osmo_tdef_get(123, m) = 1
87osmo_tdef_get(123, custom-unit) = 1
88
89test_tdef_get_nonexisting()
90osmo_tdef_get(tdefs, 5, s, 999) = 999
91osmo_tdef_get(tdefs, 5, ms, 999) = 999
92osmo_tdef_get(tdefs, 5, m, 999) = 999
93osmo_tdef_get(tdefs, 5, custom-unit, 999) = 999
94
95test_tdef_set_and_get()
96setting 7 = 42
97T7=42s(def=50)
98osmo_tdef_get(7, ms) = 42000
99osmo_tdef_get(7, s) = 42
100osmo_tdef_get(7, m) = 1
101osmo_tdef_get(7, custom-unit) = 42
102setting 7 = 420
103T7=420s(def=50)
104osmo_tdef_get(7, ms) = 420000
105osmo_tdef_get(7, s) = 420
106osmo_tdef_get(7, m) = 7
107osmo_tdef_get(7, custom-unit) = 420
Pau Espin Pedrol0cbe8f02019-09-17 13:13:52 +0200108setting 7 = 10 (ERANGE)
109T7=420s(def=50)
110osmo_tdef_get(7, ms) = 420000
111osmo_tdef_get(7, s) = 420
112osmo_tdef_get(7, m) = 7
113osmo_tdef_get(7, custom-unit) = 420
114setting 7 = 900 (ERANGE)
115T7=420s(def=50)
116osmo_tdef_get(7, ms) = 420000
117osmo_tdef_get(7, s) = 420
118osmo_tdef_get(7, m) = 7
119osmo_tdef_get(7, custom-unit) = 420
Pau Espin Pedrol9168cc92019-09-18 13:18:18 +0200120setting 23 = 50 (EEXIST)
Neels Hofmeyr0fd615f2019-01-26 20:36:12 +0100121resetting
122T7=50s
123osmo_tdef_get(7, s) = 50
124
125test_tdef_state_timeout()
Neels Hofmeyr0fd615f2019-01-26 20:36:12 +0100126state=A T=0, no timeout
127 --> A (configured as T1 100 s) rc=0; state=A T=1, 100.000000 s remaining
128 --> B (configured as T2 100 ms) rc=0; state=B T=2, 1.000000 s remaining
129 --> C (configured as T3 100 m) rc=0; state=C T=3, 6000.000000 s remaining
130 --> D (configured as T4 100 custom-unit) rc=0; state=D T=4, 100.000000 s remaining
131 --> G (configured as T7 50 s) rc=0; state=G T=7, 50.000000 s remaining
132 --> H (configured as T8 300 s) rc=0; state=H T=8, 300.000000 s remaining
133 --> I (configured as T9 5 m) rc=0; state=I T=9, 300.000000 s remaining
134 --> J (configured as T10 20 m) rc=0; state=J T=10, 1200.000000 s remaining
135- test keep_timer:
Neels Hofmeyr4f54c6c2019-03-06 06:03:24 +0100136Time passes: 123.045678 s
Neels Hofmeyr0fd615f2019-01-26 20:36:12 +0100137state=J T=10, 1076.954322 s remaining
138 --> K (configured as T0(keep_timer) 1 custom-unit) rc=0; state=K T=10, 1076.954322 s remaining
139 --> A (configured as T1 100 s) rc=0; state=A T=1, 100.000000 s remaining
Neels Hofmeyr4f54c6c2019-03-06 06:03:24 +0100140Time passes: 23.045678 s
Neels Hofmeyr0fd615f2019-01-26 20:36:12 +0100141state=A T=1, 76.954322 s remaining
142 --> K (configured as T0(keep_timer) 1 custom-unit) rc=0; state=K T=1, 76.954322 s remaining
143 --> A (configured as T1 100 s) rc=0; state=A T=1, 100.000000 s remaining
Neels Hofmeyr4f54c6c2019-03-06 06:03:24 +0100144Time passes: 23.045678 s
Neels Hofmeyr0fd615f2019-01-26 20:36:12 +0100145state=A T=1, 76.954322 s remaining
Neels Hofmeyrd4b79c82019-03-06 05:43:23 +0100146 --> L (configured as T123(keep_timer) 1 s) rc=0; state=L T=1, 76.954322 s remaining
Neels Hofmeyr4ea69822019-03-06 06:14:01 +0100147 --> O (no timer configured for this state) rc=0; state=O T=0, no timeout
Neels Hofmeyrd4b79c82019-03-06 05:43:23 +0100148 --> L (configured as T123(keep_timer) 1 s) rc=0; state=L T=123, 1.000000 s remaining
Neels Hofmeyr0fd615f2019-01-26 20:36:12 +0100149- test T=0:
Neels Hofmeyr4ea69822019-03-06 06:14:01 +0100150 --> O (no timer configured for this state) rc=0; state=O T=0, no timeout
Neels Hofmeyr0fd615f2019-01-26 20:36:12 +0100151- test no timer:
Neels Hofmeyr4ea69822019-03-06 06:14:01 +0100152 --> X (no timer configured for this state) rc=0; state=X T=0, no timeout
Neels Hofmeyr0fd615f2019-01-26 20:36:12 +0100153- test undefined timer, using default_val arg of osmo_tdef_fsm_inst_state_chg(), here passed as 999:
Neels Hofmeyr7b740f72019-02-06 01:08:43 +0100154 --> Y (configured as T666 0 -) rc=0; state=Y T=666, 999.000000 s remaining
Neels Hofmeyr0fd615f2019-01-26 20:36:12 +0100155- test disallowed transition:
Neels Hofmeyr4ea69822019-03-06 06:14:01 +0100156 --> Z (no timer configured for this state) rc=0; state=Z T=0, no timeout
157 --> B (configured as T2 100 ms) rc=-1; state=Z T=0, no timeout
158 --> C (configured as T3 100 m) rc=-1; state=Z T=0, no timeout
159 --> D (configured as T4 100 custom-unit) rc=-1; state=Z T=0, no timeout