| 264 | } |
| 265 | |
| 266 | static inline void test_shm_malloc(void) |
| 267 | { |
| 268 | unsigned long used, rused, frags, new_used, new_rused, new_frags; |
| 269 | |
| 270 | MALLOC = osips_shm_malloc; |
| 271 | REALLOC = osips_shm_realloc; |
| 272 | FREE = osips_shm_free; |
| 273 | |
| 274 | used = get_stat_val(get_stat(_str("used_size"))); |
| 275 | rused = get_stat_val(get_stat(_str("real_used_size"))); |
| 276 | frags = get_stat_val(get_stat(_str("fragments"))); |
| 277 | |
| 278 | LM_INFO("Starting SHM stress test...\n"); |
| 279 | LM_INFO("================================\n"); |
| 280 | LM_INFO("used: %ld\n", used); |
| 281 | LM_INFO("real_used: %ld\n", rused); |
| 282 | LM_INFO("max_real_used: %ld\n", get_stat_val(get_stat(_str("max_used_size")))); |
| 283 | LM_INFO("fragments: %ld\n", get_stat_val(get_stat(_str("fragments")))); |
| 284 | LM_INFO("================================\n"); |
| 285 | |
| 286 | _test_malloc(TEST_MALLOC_PROCS, shm_frag_overhead); |
| 287 | |
| 288 | new_used = get_stat_val(get_stat(_str("used_size"))); |
| 289 | new_rused = get_stat_val(get_stat(_str("real_used_size"))); |
| 290 | new_frags = get_stat_val(get_stat(_str("fragments"))); |
| 291 | |
| 292 | LM_INFO("SHM test complete. Final stats:\n"); |
| 293 | LM_INFO("================================\n"); |
| 294 | LM_INFO("used: %ld -> %ld\n", used, new_used); |
| 295 | LM_INFO("real_used: %ld -> %ld\n", rused, new_rused); |
| 296 | LM_INFO("max_real_used: %ld\n", get_stat_val(get_stat(_str("max_used_size")))); |
| 297 | LM_INFO("fragments: %ld -> %ld\n", frags, new_frags); |
| 298 | LM_INFO("mallocs %ld : %ld aligned-mallocs\n", mallocs, aligned_mallocs); |
| 299 | LM_INFO("reallocs %ld : %ld aligned-reallocs\n", reallocs, aligned_reallocs); |
| 300 | LM_INFO("frees %ld\n", frees); |
| 301 | LM_INFO("================================\n"); |
| 302 | |
| 303 | ok(new_used == used, "check stats: shm_used"); |
| 304 | /* we don't yet have a way of testing the correctness of real_used |
| 305 | ok(new_rused == rused, "check stats: shm_rused"); */ |
| 306 | |
| 307 | ok(mallocs == aligned_mallocs, "check shm_malloc() alignment"); |
| 308 | ok(reallocs == aligned_reallocs, "check shm_realloc() alignment"); |
| 309 | } |
| 310 | |
| 311 | void test_malloc(void) |
| 312 | { |
no test coverage detected