summaryrefslogtreecommitdiff
path: root/tests/storage_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/storage_test.c')
-rw-r--r--tests/storage_test.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/storage_test.c b/tests/storage_test.c
index 3217095..0e93ad9 100644
--- a/tests/storage_test.c
+++ b/tests/storage_test.c
@@ -1,10 +1,13 @@
#include "storage/store.h"
#include "sys/system.h"
+#include "mcp/tools/common/history.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "base/allocator.h"
+
static int failures;
#define CHECK(value) \
do \
@@ -103,6 +106,31 @@ main(void)
CHECK(tiny_store_open(&store, directory) == TINY_STORE_OK);
CHECK(tiny_store_entry_count(store) == 2);
+ {
+ size_t failure_index;
+ bool built = false;
+ for (failure_index = 0; failure_index < 64; ++failure_index)
+ {
+ tiny_history_index_t *history;
+ size_t baseline = tiny_allocator_outstanding();
+ tiny_allocator_fail_after(failure_index);
+ history = tiny_history_index_build(store);
+ tiny_allocator_reset();
+ if (history)
+ {
+ const size_t *entries = NULL;
+ size_t entry_count = 0;
+ CHECK(tiny_history_index_session(history, "unit", &entries, &entry_count));
+ CHECK(entry_count == 2 && entries[0] == 0 && entries[1] == 1);
+ tiny_history_index_free(history);
+ CHECK(tiny_allocator_outstanding() == baseline);
+ built = true;
+ break;
+ }
+ CHECK(tiny_allocator_outstanding() == baseline);
+ }
+ CHECK(built);
+ }
for (operation = 0; operation < sizeof(rebuild_failures) / sizeof(rebuild_failures[0]);
++operation)
{