| 68 | void restore_state(); |
| 69 | |
| 70 | int |
| 71 | create_config(int num) |
| 72 | { |
| 73 | int i = 0; |
| 74 | int vol_num = 1; |
| 75 | // clear all old configurations before adding new test cases |
| 76 | config_volumes.clear_all(); |
| 77 | switch (num) { |
| 78 | case 0: |
| 79 | for (i = 0; i < gndisks; i++) { |
| 80 | CacheDisk *d = gdisks[i]; |
| 81 | int blocks = d->num_usable_blocks; |
| 82 | if (blocks < STORE_BLOCKS_PER_STRIPE) { |
| 83 | Warning("Cannot run Cache_vol regression: not enough disk space"); |
| 84 | return 0; |
| 85 | } |
| 86 | /* create 128 MB volumes */ |
| 87 | for (; blocks >= STORE_BLOCKS_PER_STRIPE; blocks -= STORE_BLOCKS_PER_STRIPE) { |
| 88 | if (vol_num > 255) { |
| 89 | break; |
| 90 | } |
| 91 | ConfigVol *cp = new ConfigVol(); |
| 92 | cp->number = vol_num++; |
| 93 | cp->scheme = CACHE_HTTP_TYPE; |
| 94 | cp->size = 128; |
| 95 | cp->in_percent = false; |
| 96 | cp->cachep = nullptr; |
| 97 | config_volumes.cp_queue.enqueue(cp); |
| 98 | config_volumes.num_volumes++; |
| 99 | config_volumes.num_http_volumes++; |
| 100 | } |
| 101 | } |
| 102 | Dbg(dbg_ctl_cache_vol_test, "%d 128 Megabyte Volumes", vol_num - 1); |
| 103 | break; |
| 104 | |
| 105 | case 1: { |
| 106 | for (i = 0; i < gndisks; i++) { |
| 107 | gdisks[i]->delete_all_volumes(); |
| 108 | } |
| 109 | |
| 110 | // calculate the total free space |
| 111 | off_t total_space = 0; |
| 112 | for (i = 0; i < gndisks; i++) { |
| 113 | off_t vol_blocks = gdisks[i]->num_usable_blocks; |
| 114 | /* round down the blocks to the nearest |
| 115 | multiple of STORE_BLOCKS_PER_STRIPE */ |
| 116 | vol_blocks = (vol_blocks / STORE_BLOCKS_PER_STRIPE) * STORE_BLOCKS_PER_STRIPE; |
| 117 | total_space += vol_blocks; |
| 118 | } |
| 119 | |
| 120 | // make sure we have at least 1280 M bytes |
| 121 | if (total_space < ((10 << 27) >> STORE_BLOCK_SHIFT)) { |
| 122 | // Skip this test case due to small space |
| 123 | Warning("Not enough space for 10 volume"); |
| 124 | return 0; |
| 125 | } |
| 126 | |
| 127 | vol_num = 1; |
no test coverage detected