| 447 | } ui_delete_fixture_t; |
| 448 | |
| 449 | static int ui_delete_fixture_init(ui_delete_fixture_t *fx) { |
| 450 | memset(fx, 0, sizeof(*fx)); |
| 451 | char *tmp = th_mktempdir("cbm_httpd_delete"); |
| 452 | if (!tmp) |
| 453 | return -1; |
| 454 | snprintf(fx->tmpdir, sizeof(fx->tmpdir), "%s", tmp); |
| 455 | snprintf(fx->cache_dir, sizeof(fx->cache_dir), "%s/cache", fx->tmpdir); |
| 456 | snprintf(fx->root_dir, sizeof(fx->root_dir), "%s/root", fx->tmpdir); |
| 457 | |
| 458 | const char *saved = getenv("CBM_CACHE_DIR"); |
| 459 | fx->saved_cache_dir = saved ? strdup(saved) : NULL; |
| 460 | if (th_mkdir_p(fx->cache_dir) != 0 || th_mkdir_p(fx->root_dir) != 0) { |
| 461 | return -1; |
| 462 | } |
| 463 | cbm_setenv("CBM_CACHE_DIR", fx->cache_dir, 1); |
| 464 | |
| 465 | fx->store = cbm_store_open_memory(); |
| 466 | fx->watcher = cbm_watcher_new(fx->store, NULL, NULL); |
| 467 | return fx->store && fx->watcher ? 0 : -1; |
| 468 | } |
| 469 | |
| 470 | static void ui_delete_fixture_cleanup(ui_delete_fixture_t *fx) { |
| 471 | if (fx->watcher) |
no test coverage detected