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