summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Christensen <jdc@uwo.ca>2023-02-12 09:39:07 -0500
committerDan Christensen <jdc@uwo.ca>2023-02-12 09:39:07 -0500
commit3daf7e186d9e1dfc340d9130493ebbc00cbfbb4a (patch)
tree813b19e8bb77edcb6037924b25f24963ec216be7
parentc705c8573d648e00cd4921435d913e6493fa3a65 (diff)
testsuite/hashindex.py: add comments about validity of hashtables
-rw-r--r--src/borg/testsuite/hashindex.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/borg/testsuite/hashindex.py b/src/borg/testsuite/hashindex.py
index d29ea722b..6ae3e179b 100644
--- a/src/borg/testsuite/hashindex.py
+++ b/src/borg/testsuite/hashindex.py
@@ -478,6 +478,9 @@ class HashIndexCompactTestCase(HashIndexDataTestCase):
self.write_entry(key, 0xFFFFFFFE, 0, 0)
def compare_indexes(self, idx1, idx2):
+ """Check that the two hash tables contain the same data. idx1
+ is allowed to have "mis-filed" entries, because we only need to
+ iterate over it. But idx2 needs to support lookup."""
for k, v in idx1.iteritems():
assert v == idx2[k]
assert len(idx1) == len(idx2)
@@ -504,6 +507,9 @@ class HashIndexCompactTestCase(HashIndexDataTestCase):
idx = self.index_from_data()
cpt = self.index_from_data()
cpt.compact()
+ # Note that idx is not a valid hash table, since the entries are not
+ # stored where they should be. So lookups of the form idx[k] can fail.
+ # But cpt is a valid hash table, since there are no empty buckets.
assert idx.size() == 1024 + num_buckets * (32 + 3 * 4)
assert cpt.size() == 1024 + num_entries * (32 + 3 * 4)
self.compare_indexes(idx, cpt)