Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
01339a99
Commit
01339a99
authored
Jul 10, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X CHECK_MRU -> CHECK_MRU + CHECK_DIRTY
parent
a30e0568
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
20 deletions
+53
-20
bigfile/tests/test_virtmem.c
bigfile/tests/test_virtmem.c
+53
-20
No files found.
bigfile/tests/test_virtmem.c
View file @
01339a99
...
...
@@ -223,44 +223,77 @@ int M(VMA *vma, pgoff_t idx) { return bitmap_test_bit(vma->page_ismappedv, idx)
ok1(!pagemap_get(&(fileh)->pagemap, (pgoffset))); \
} while (0)
/* _check_mru checks that ram has MRU pages as specified by pagev */
void
_check_mru
(
RAM
*
ram
,
Page
*
mruok
[],
int
nok
,
const
char
*
func
,
const
char
*
file
,
int
line
)
{
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
;
hlru
=
hlru
->
prev
;
}
/* _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
;
if
(
!
(
n
==
nok
&&
!
memcmp
(
mruv
,
mruok
,
n
*
sizeof
(
*
mruok
))))
{
fprintf
(
stderr
,
"
check_mru: different
\n
"
);
if
(
!
(
n
==
nok
&&
!
memcmp
(
pagev
,
vok
,
n
*
sizeof
(
*
pagev
))))
{
fprintf
(
stderr
,
"
%s: different
\n
"
,
subj
);
fprintf
(
stderr
,
"have: ["
);
for
(
i
=
0
;
i
<
n
;
i
++
)
fprintf
(
stderr
,
"%sp%ld"
,
(
i
>
0
?
", "
:
""
),
mru
v
[
i
]
->
f_pgoffset
);
fprintf
(
stderr
,
"%sp%ld"
,
(
i
>
0
?
", "
:
""
),
page
v
[
i
]
->
f_pgoffset
);
fprintf
(
stderr
,
"]
\n
"
);
fprintf
(
stderr
,
"want: ["
);
for
(
i
=
0
;
i
<
nok
;
i
++
)
fprintf
(
stderr
,
"%sp%ld"
,
(
i
>
0
?
", "
:
""
),
mru
ok
[
i
]
->
f_pgoffset
);
fprintf
(
stderr
,
"%sp%ld"
,
(
i
>
0
?
", "
:
""
),
v
ok
[
i
]
->
f_pgoffset
);
fprintf
(
stderr
,
"]
\n
"
);
_gen_result
(
0
,
func
,
file
,
line
,
"
check_mru failed"
);
_gen_result
(
0
,
func
,
file
,
line
,
"
%s failed"
,
subj
);
}
}
/* _check_mru checks that ram has MRU pages as specified by pagev */
void
_check_mru
(
RAM
*
ram
,
Page
*
mruok
[],
int
nok
,
const
char
*
func
,
const
char
*
file
,
int
line
)
{
Page
**
mruv
=
NULL
,
*
page
;
int
n
=
0
;
struct
list_head
*
h
;
// collect mruv
list_for_each_backwardly
(
h
,
&
ram
->
lru_list
)
{
page
=
list_entry
(
h
,
typeof
(
*
page
),
lru
);
n
++
;
mruv
=
realloc
(
mruv
,
n
*
sizeof
(
*
mruv
));
mruv
[
n
-
1
]
=
page
;
}
_assert_pagev
(
"check_mru"
,
mruok
,
nok
,
mruv
,
n
,
func
,
file
,
line
);
free
(
mruv
);
}
/* CHECK_MRU(ram, ...pagev) -
check
that ram has MRU pages as expected */
/* CHECK_MRU(ram, ...pagev) -
assert
that ram has MRU pages as expected */
#define CHECK_MRU(ram, ...) do { \
Page *__mruok[] = {__VA_ARGS__}; \
_check_mru(ram, __mruok, ARRAY_SIZE(__mruok), __func__, __FILE__, __LINE__); \
} while(0)
void
_check_dity
(
BigFileH
*
fileh
,
Page
*
dirtyok
[],
int
nok
,
const
char
*
func
,
const
char
*
file
,
int
line
)
{
Page
**
dirtyv
=
NULL
,
*
page
;
int
n
=
0
;
struct
list_head
*
h
;
// collect dirtyv
list_for_each
(
h
,
&
fileh
->
dirty_pages
)
{
page
=
list_entry
(
h
,
typeof
(
*
page
),
in_dirty
);
n
++
;
dirtyv
=
realloc
(
dirtyv
,
n
*
sizeof
(
*
dirtyv
));
dirtyv
[
n
-
1
]
=
page
;
}
_assert_pagev
(
"check_dirty"
,
dirtyok
,
nok
,
dirtyv
,
n
,
func
,
file
,
line
);
free
(
dirtyv
);
}
/* CHECK_DIRTY(fileh, ...pagev) - assert that fileh has dirty pages as expected */
#define CHECK_DIRTY(fileh, ...) do { \
Page *__dirtyok[] = {__VA_ARGS__}; \
_check_dirty(fileh, __dirtyok, ARRAY_SIZE(__dirtyok), __func__, __FILE__, __LINE__); \
} while(0)
/* vma_on_pagefault() assumes virtmem_lock is taken by caller and can ask it to
* retry. Handle fault to the end, like on_pagefault() does. */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment