| 663 | } ui_delete_fixture_t; |
| 664 | |
| 665 | static int ui_delete_fixture_init(ui_delete_fixture_t *fx) { |
| 666 | memset(fx, 0, sizeof(*fx)); |
| 667 | char *tmp = th_mktempdir("cbm_httpd_delete"); |
| 668 | if (!tmp) |
| 669 | return -1; |
| 670 | snprintf(fx->tmpdir, sizeof(fx->tmpdir), "%s", tmp); |
| 671 | snprintf(fx->cache_dir, sizeof(fx->cache_dir), "%s/cache", fx->tmpdir); |
| 672 | snprintf(fx->root_dir, sizeof(fx->root_dir), "%s/root", fx->tmpdir); |
| 673 | |
| 674 | const char *saved = getenv("CBM_CACHE_DIR"); |
| 675 | fx->saved_cache_dir = saved ? strdup(saved) : NULL; |
| 676 | if (th_mkdir_p(fx->cache_dir) != 0 || th_mkdir_p(fx->root_dir) != 0) { |
| 677 | return -1; |
| 678 | } |
| 679 | cbm_setenv("CBM_CACHE_DIR", fx->cache_dir, 1); |
| 680 | |
| 681 | fx->store = cbm_store_open_memory(); |
| 682 | fx->watcher = cbm_watcher_new(fx->store, NULL, NULL); |
| 683 | return fx->store && fx->watcher ? 0 : -1; |
| 684 | } |
| 685 | |
| 686 | static void ui_delete_fixture_cleanup(ui_delete_fixture_t *fx) { |
| 687 | if (fx->watcher) |
no test coverage detected