Commit bccb2434 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 56b8ddda
......@@ -223,34 +223,40 @@ int M(VMA *vma, pgoff_t idx) { return bitmap_test_bit(vma->page_ismappedv, idx)
ok1(!pagemap_get(&(fileh)->pagemap, (pgoffset))); \
} while (0)
/* _pagev_str returns string representation for vector of pages.
* the memory has to be freed by user. */
char *_pagev_str(Page **pagev, int pagec) {
char *vstr;
size_t _;
FILE *w = open_memstream(&vstr, &_);
fprintf(w, "[");
for (int i=0; i<pagec; i++)
fprintf(w, "%sp%ld", (i > 0 ? ", " : ""), pagev[i]->f_pgoffset);
fprintf(w, "]");
fclose(w);
return vstr;
}
/* _assert_pagev asserts that two page vectors are the same */
void _assert_pagev(const char *subj, Page **vok, int nok, Page **pagev, int n,
const char *func, const char *file, int line)
{
int i;
char *vstr = _pagev_str(pagev, n);
if (!(n == nok && !memcmp(pagev, vok, n*sizeof(*pagev)))) {
char *vstr_ok = _pagev_str(vok, nok);
fprintf(stderr, "%s: failed\n", subj);
fprintf(stderr, "have: [");
for (i=0; i<n; i++)
fprintf(stderr, "%sp%ld", (i > 0 ? ", " : ""), pagev[i]->f_pgoffset);
fprintf(stderr, "]\n");
fprintf(stderr, "want: [");
for (i=0; i<nok; i++)
fprintf(stderr, "%sp%ld", (i > 0 ? ", " : ""), vok[i]->f_pgoffset);
fprintf(stderr, "]\n");
fprintf(stderr, "have: %s\n", vstr);
fprintf(stderr, "want: %s\n", vstr_ok);
_gen_result(0, func, file, line, "%s failed", subj);
free(vstr_ok);
} else {
pass("%s %s", subj, vstr);
}
else {
char *vstr;
asprintf(&vstr, "[");
for (i=0; i<n; i++)
asprintf(&vstr, "%sp%ld", (i > 0 ? ", " : ""), pagev[i]->f_pgoffset);
asprintf(&vstr, "]");
pass("%s %s", subj, vstr);
free(vstr);
}
}
/* _check_mru checks that ram has MRU pages as specified by pagev. */
......
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