| 139 | _sync_flag++; |
| 140 | } |
| 141 | static void test_static_mutex_release(void) |
| 142 | { |
| 143 | rt_err_t result; |
| 144 | |
| 145 | _sync_flag = 0; |
| 146 | |
| 147 | result = rt_mutex_init(&static_mutex, "static_mutex", RT_IPC_FLAG_PRIO); |
| 148 | if (RT_EOK != result) |
| 149 | { |
| 150 | uassert_true(RT_FALSE); |
| 151 | return; |
| 152 | } |
| 153 | |
| 154 | result = rt_mutex_release(&static_mutex); |
| 155 | uassert_true(result < 0); |
| 156 | |
| 157 | /* take mutex */ |
| 158 | result = rt_mutex_take(&static_mutex, RT_WAITING_FOREVER); |
| 159 | if (RT_EOK != result) |
| 160 | uassert_true(RT_FALSE); |
| 161 | |
| 162 | /* release mutex */ |
| 163 | result = rt_mutex_release(&static_mutex); |
| 164 | if (RT_EOK != result) |
| 165 | uassert_true(RT_FALSE); |
| 166 | |
| 167 | rt_thread_t tid = rt_thread_create("mutex_th", |
| 168 | static_mutex_release_entry, |
| 169 | &static_mutex, |
| 170 | THREAD_STACKSIZE, |
| 171 | 10, |
| 172 | 10); |
| 173 | if (RT_NULL == tid) |
| 174 | { |
| 175 | uassert_true(RT_FALSE); |
| 176 | return; |
| 177 | } |
| 178 | |
| 179 | /* startup thread and take mutex second */ |
| 180 | rt_thread_startup(tid); |
| 181 | |
| 182 | while (_sync_flag != 1) |
| 183 | { |
| 184 | rt_thread_mdelay(10); |
| 185 | } |
| 186 | |
| 187 | result = rt_mutex_detach(&static_mutex); |
| 188 | if (RT_EOK != result) |
| 189 | uassert_true(RT_FALSE); |
| 190 | |
| 191 | uassert_true(RT_TRUE); |
| 192 | } |
| 193 | |
| 194 | /* static trytake test */ |
| 195 | static void static_mutex_trytake_entry(void *param) |
nothing calls this directly
no test coverage detected