| 943 | } |
| 944 | |
| 945 | void test_reftable_stack__auto_compaction(void) |
| 946 | { |
| 947 | struct reftable_write_options opts = { |
| 948 | .disable_auto_compact = 1, |
| 949 | }; |
| 950 | struct reftable_stack *st = NULL; |
| 951 | char *dir = get_tmp_dir(__LINE__); |
| 952 | size_t i, N = 100; |
| 953 | int err; |
| 954 | |
| 955 | cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0); |
| 956 | |
| 957 | for (i = 0; i < N; i++) { |
| 958 | char name[100]; |
| 959 | struct reftable_ref_record ref = { |
| 960 | .refname = name, |
| 961 | .update_index = reftable_stack_next_update_index(st), |
| 962 | .value_type = REFTABLE_REF_SYMREF, |
| 963 | .value.symref = (char *) "master", |
| 964 | }; |
| 965 | snprintf(name, sizeof(name), "branch%04"PRIuMAX, (uintmax_t)i); |
| 966 | |
| 967 | err = reftable_stack_add(st, write_test_ref, &ref, 0); |
| 968 | cl_assert(!err); |
| 969 | |
| 970 | err = reftable_stack_auto_compact(st); |
| 971 | cl_assert(!err); |
| 972 | cl_assert(i < 2 || st->merged->tables_len < 2 * fastlogN(i, 2)); |
| 973 | } |
| 974 | |
| 975 | cl_assert(reftable_stack_compaction_stats(st)->entries_written < |
| 976 | (uint64_t)(N * fastlogN(N, 2))); |
| 977 | |
| 978 | reftable_stack_destroy(st); |
| 979 | clear_dir(dir); |
| 980 | } |
| 981 | |
| 982 | void test_reftable_stack__auto_compaction_factor(void) |
| 983 | { |
nothing calls this directly
no test coverage detected