blob: 29ebfb735f8dc77d04d18dee1a619893095197fa [file] [log] [blame]
Neels Hofmeyr0e8df1c2019-02-11 20:32:25 +01001
2test_use_count_fsm()
3DFOO DEBUG foo(a){IN_USE}: Allocated
4DFOO DEBUG foo(b){IN_USE}: Allocated
5DFOO DEBUG foo(c){IN_USE}: Allocated
6
7all use counts:
8a: 0 (-)
9b: 0 (-)
10c: 0 (-)
113 foos
12
13A few gets and puts, logging source file information
Oliver Smith04bfb712021-12-14 12:07:20 +010014DFOO NOTICE foo(a){IN_USE}: a +1 barring: now used by 1 (barring) (use_count_test.c:219)
15DFOO NOTICE foo(b){IN_USE}: b +1 barring: now used by 1 (barring) (use_count_test.c:221)
16DFOO NOTICE foo(b){IN_USE}: b +1 fighting: now used by 2 (barring,fighting) (use_count_test.c:222)
Neels Hofmeyr0e8df1c2019-02-11 20:32:25 +010017
18all use counts:
19a: 1 (barring)
20b: 2 (barring,fighting)
21c: 0 (-)
223 foos
23
24Attempt to get more than one on limited 'barring' user:
Oliver Smith04bfb712021-12-14 12:07:20 +010025DFOO ERROR foo(b){IN_USE}: Attempt to get more than one barring (use_count_test.c:227)
Neels Hofmeyr0e8df1c2019-02-11 20:32:25 +010026osmo_use_count_get_put(b, barring, 1) returned error: -34 Numerical result out of range
27
28all use counts:
29a: 1 (barring)
30b: 2 (barring,fighting)
31c: 0 (-)
323 foos
33
34Put away one user of b
Oliver Smith04bfb712021-12-14 12:07:20 +010035DFOO NOTICE foo(b){IN_USE}: b -1 barring: now used by 1 (fighting) (use_count_test.c:231)
Neels Hofmeyr0e8df1c2019-02-11 20:32:25 +010036
37all use counts:
38a: 1 (barring)
39b: 1 (fighting)
40c: 0 (-)
413 foos
42
43(no longer log source file information)
44Test null use token
45DFOO NOTICE foo(a){IN_USE}: a +1 NULL: now used by 2 (barring,NULL)
46
47all use counts:
48a: 2 (barring,NULL)
49b: 1 (fighting)
50c: 0 (-)
513 foos
52
53DFOO NOTICE foo(a){IN_USE}: a -1 NULL: now used by 1 (barring)
54
55all use counts:
56a: 1 (barring)
57b: 1 (fighting)
58c: 0 (-)
593 foos
60
61Put away last user of a, goes to RELEASING state and waits for a hypothetic async release process
62DFOO NOTICE foo(a){IN_USE}: a -1 barring: now used by 0 (-)
63DFOO DEBUG foo(a){IN_USE}: Received Event FOO_EV_UNUSED
64DFOO DEBUG foo(a){IN_USE}: state_chg to IN_RELEASE
65DFOO NOTICE foo(a){IN_RELEASE}: a +1 releasing: now used by 1 (releasing)
66
67all use counts:
68a: 1 (releasing)
69b: 1 (fighting)
70c: 0 (-)
713 foos
72
73Async releasing of a is done, will dealloc
74DFOO NOTICE foo(a){IN_RELEASE}: a -1 releasing: now used by 0 (-)
75DFOO DEBUG foo(a){IN_RELEASE}: Received Event FOO_EV_UNUSED
76DFOO DEBUG foo(a){IN_RELEASE}: Terminating (cause = OSMO_FSM_TERM_REGULAR)
77DFOO DEBUG foo(a){IN_RELEASE}: Freeing instance
78DFOO DEBUG foo(a){IN_RELEASE}: Deallocated
79
80all use counts:
81b: 1 (fighting)
82c: 0 (-)
832 foos
84
85Use b multiple times
86DFOO NOTICE foo(b){IN_USE}: b +1 kungfoo: now used by 2 (fighting,kungfoo)
87DFOO NOTICE foo(b){IN_USE}: b +1 kungfoo: now used by 3 (fighting,2*kungfoo)
88DFOO NOTICE foo(b){IN_USE}: b -1 kungfoo: now used by 2 (fighting,kungfoo)
89DFOO NOTICE foo(b){IN_USE}: b +1 kungfoo: now used by 3 (fighting,2*kungfoo)
90DFOO NOTICE foo(b){IN_USE}: b +1 kungfoo: now used by 4 (fighting,3*kungfoo)
91
92all use counts:
93b: 4 (fighting,3*kungfoo)
94c: 0 (-)
952 foos
96
97Test range: set kung-fu to INT32_MAX-1, then get three more; total count gets max-clamped to INT32_MAX
98DFOO NOTICE foo(b){IN_USE}: b +2147483643 kungfoo: now used by 2147483647 (fighting,2147483646*kungfoo)
99
100all use counts:
101b: 2147483647 (fighting,2147483646*kungfoo)
102c: 0 (-)
1032 foos
104
105DFOO NOTICE foo(b){IN_USE}: b +1 kungfoo: now used by 2147483647 (fighting,2147483647*kungfoo)
106osmo_use_count_get_put(b, kungfoo, 1) returned error: -34 Numerical result out of range
107osmo_use_count_get_put(b, kungfoo, 1) returned error: -34 Numerical result out of range
108DFOO NOTICE foo(b){IN_USE}: b +2 fighting: now used by 2147483647 (3*fighting,2147483647*kungfoo)
109DFOO NOTICE foo(b){IN_USE}: b -3 kungfoo: now used by 2147483647 (3*fighting,2147483644*kungfoo)
110DFOO NOTICE foo(b){IN_USE}: b -1 kungfoo: now used by 2147483646 (3*fighting,2147483643*kungfoo)
111DFOO NOTICE foo(b){IN_USE}: b -1 kungfoo: now used by 2147483645 (3*fighting,2147483642*kungfoo)
112DFOO NOTICE foo(b){IN_USE}: b +1 fighting: now used by 2147483646 (4*fighting,2147483642*kungfoo)
113DFOO NOTICE foo(b){IN_USE}: b +1 fighting: now used by 2147483647 (5*fighting,2147483642*kungfoo)
114DFOO NOTICE foo(b){IN_USE}: b +1 fighting: now used by 2147483647 (6*fighting,2147483642*kungfoo)
115
116all use counts:
117b: 2147483647 (6*fighting,2147483642*kungfoo)
118c: 0 (-)
1192 foos
120
121Release all uses of b
122DFOO NOTICE foo(b){IN_USE}: b -2147483642 kungfoo: now used by 6 (6*fighting)
123DFOO NOTICE foo(b){IN_USE}: b -6 fighting: now used by 0 (-)
124DFOO DEBUG foo(b){IN_USE}: Received Event FOO_EV_UNUSED
125DFOO DEBUG foo(b){IN_USE}: state_chg to IN_RELEASE
126DFOO NOTICE foo(b){IN_RELEASE}: b +1 releasing: now used by 1 (releasing)
127Signal async release as done
128DFOO NOTICE foo(b){IN_RELEASE}: b -1 releasing: now used by 0 (-)
129DFOO DEBUG foo(b){IN_RELEASE}: Received Event FOO_EV_UNUSED
130DFOO DEBUG foo(b){IN_RELEASE}: Terminating (cause = OSMO_FSM_TERM_REGULAR)
131DFOO DEBUG foo(b){IN_RELEASE}: Freeing instance
132DFOO DEBUG foo(b){IN_RELEASE}: Deallocated
133
134all use counts:
135c: 0 (-)
1361 foos
137
138Release something not gotten before: a get/put bug goes into negative count
139DFOO NOTICE foo(c){IN_USE}: c -1 kungfoo: now used by -1 (-1*kungfoo)
140DFOO ERROR foo(c){IN_USE}: Negative use count on kungfoo: -1 (-1*kungfoo)
141
142all use counts:
143c: -1 (-1*kungfoo)
1441 foos
145
146More negative
147DFOO NOTICE foo(c){IN_USE}: c -1 kungfoo: now used by -2 (-2*kungfoo)
148DFOO ERROR foo(c){IN_USE}: Negative use count on kungfoo: -2 (-2*kungfoo)
149DFOO NOTICE foo(c){IN_USE}: c -1 kungfoo: now used by -3 (-3*kungfoo)
150DFOO ERROR foo(c){IN_USE}: Negative use count on kungfoo: -3 (-3*kungfoo)
151
152all use counts:
153c: -3 (-3*kungfoo)
1541 foos
155
156Also release c
157DFOO NOTICE foo(c){IN_USE}: c +4 kungfoo: now used by 1 (kungfoo)
158DFOO NOTICE foo(c){IN_USE}: c -1 kungfoo: now used by 0 (-)
159DFOO DEBUG foo(c){IN_USE}: Received Event FOO_EV_UNUSED
160DFOO DEBUG foo(c){IN_USE}: state_chg to IN_RELEASE
161DFOO NOTICE foo(c){IN_RELEASE}: c +1 releasing: now used by 1 (releasing)
162Signal async release as done
163DFOO NOTICE foo(c){IN_RELEASE}: c -1 releasing: now used by 0 (-)
164DFOO DEBUG foo(c){IN_RELEASE}: Received Event FOO_EV_UNUSED
165DFOO DEBUG foo(c){IN_RELEASE}: Terminating (cause = OSMO_FSM_TERM_REGULAR)
166DFOO DEBUG foo(c){IN_RELEASE}: Freeing instance
167DFOO DEBUG foo(c){IN_RELEASE}: Deallocated
168
169all use counts:
1700 foos
171