hpdata: Add a test.

We're about to make the functionality here more complicated; testing hpdata
directly (rather than relying on user's tests) will make debugging easier.
This commit is contained in:
David Goldblatt
2020-12-02 07:04:01 -08:00
committed by David Goldblatt
parent 3ed0b4e8a3
commit d9f7e6c668
3 changed files with 69 additions and 2 deletions

View File

@@ -112,10 +112,15 @@ hpdata_assert_empty(hpdata_t *hpdata) {
assert(hpdata_nfree_get(hpdata) == HUGEPAGE_PAGES);
}
static inline bool
hpdata_consistent(hpdata_t *hpdata) {
return fb_urange_longest(hpdata->active_pages, HUGEPAGE_PAGES)
== hpdata_longest_free_range_get(hpdata);
}
static inline void
hpdata_assert_consistent(hpdata_t *hpdata) {
assert(fb_urange_longest(hpdata->active_pages, HUGEPAGE_PAGES)
== hpdata_longest_free_range_get(hpdata));
assert(hpdata_consistent(hpdata));
}
TYPED_LIST(hpdata_list, hpdata_t, ql_link)