Commit 8461fbf0 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 675e6415
...@@ -224,15 +224,39 @@ int M(VMA *vma, pgoff_t idx) { return bitmap_test_bit(vma->page_ismappedv, idx) ...@@ -224,15 +224,39 @@ int M(VMA *vma, pgoff_t idx) { return bitmap_test_bit(vma->page_ismappedv, idx)
} while (0) } while (0)
/* check that ram has MRU pages as specified by pagev */ /* check that ram has MRU pages as specified by pagev */
void _check_mru(RAM *ram, Page *pagev[], int pagec) { void _check_mru(RAM *ram, Page *mruok[], int nok, const char *func, const char *file, int line) {
// XXX Page **mruv = NULL, *page;
int n = 0, i;
struct list_head *hlru = ram->lru_list.prev;
// collect actual mru
while (hlru != &ram->lru_list) {
page = list_entry(hlru, typeof(*page), lru);
n++;
mruv = realloc(mruv, n*sizeof(*mruv));
mruv[n-1] = page;
}
if (!(n == nok && memcmp(mruv, mruok, n))) {
fprintf(stderr, "check_mru: different\n");
fprintf(stderr, "have: [");
for (i=0; i<n; i++)
fprintf(stderr, "%sp%ld", (i > 0 ? ", " : ""), mruv[i]->f_pgoffset);
fprintf(stderr, "]\n");
fprintf(stderr, "want: [");
for (i=0; i<nok; i++)
fprintf(stderr, "%sp%ld", (i > 0 ? ", " : ""), mruok[i]->f_pgoffset);
fprintf(stderr, "]\n");
_gen_result(0, func, file, line, "check_mru failed");
}
free(mruv);
} }
// XXX + fail with line
// CHECK_MRU(ram, ...pagev) // CHECK_MRU(ram, ...pagev)
#define CHECK_MRU(ram, ...) do { \ #define CHECK_MRU(ram, ...) do { \
Page *__pagev[] = {__VA_ARGS__}; \ Page *__mruok[] = {__VA_ARGS__}; \
_check_mru(ram, __pagev, ARRAY_SIZE(__pagev)); \ _check_mru(ram, __mruok, ARRAY_SIZE(__mruok), __func__, __FILE__, __LINE__); \
} while(0) } while(0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment