Skip to content

Commit 136c5b4

Browse files
x-y-zakpm00
authored andcommitted
selftests/mm: use selftests framework to print test result
Otherwise the number of tests does not match the reality. Link: https://lkml.kernel.org/r/[email protected] Fixes: 391e869 ("mm: selftest to verify zero-filled pages are mapped to zeropage") Signed-off-by: Zi Yan <[email protected]> Cc: Alexander Zhu <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Shuah Khan <[email protected]> Cc: Usama Arif <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 91fe0e4 commit 136c5b4

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

tools/testing/selftests/mm/split_huge_page_test.c

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -108,38 +108,28 @@ static void verify_rss_anon_split_huge_page_all_zeroes(char *one_page, int nr_hp
108108
unsigned long rss_anon_before, rss_anon_after;
109109
size_t i;
110110

111-
if (!check_huge_anon(one_page, 4, pmd_pagesize)) {
112-
printf("No THP is allocated\n");
113-
exit(EXIT_FAILURE);
114-
}
111+
if (!check_huge_anon(one_page, 4, pmd_pagesize))
112+
ksft_exit_fail_msg("No THP is allocated\n");
115113

116114
rss_anon_before = rss_anon();
117-
if (!rss_anon_before) {
118-
printf("No RssAnon is allocated before split\n");
119-
exit(EXIT_FAILURE);
120-
}
115+
if (!rss_anon_before)
116+
ksft_exit_fail_msg("No RssAnon is allocated before split\n");
121117

122118
/* split all THPs */
123119
write_debugfs(PID_FMT, getpid(), (uint64_t)one_page,
124120
(uint64_t)one_page + len, 0);
125121

126122
for (i = 0; i < len; i++)
127-
if (one_page[i] != (char)0) {
128-
printf("%ld byte corrupted\n", i);
129-
exit(EXIT_FAILURE);
130-
}
123+
if (one_page[i] != (char)0)
124+
ksft_exit_fail_msg("%ld byte corrupted\n", i);
131125

132-
if (!check_huge_anon(one_page, 0, pmd_pagesize)) {
133-
printf("Still AnonHugePages not split\n");
134-
exit(EXIT_FAILURE);
135-
}
126+
if (!check_huge_anon(one_page, 0, pmd_pagesize))
127+
ksft_exit_fail_msg("Still AnonHugePages not split\n");
136128

137129
rss_anon_after = rss_anon();
138-
if (rss_anon_after >= rss_anon_before) {
139-
printf("Incorrect RssAnon value. Before: %ld After: %ld\n",
130+
if (rss_anon_after >= rss_anon_before)
131+
ksft_exit_fail_msg("Incorrect RssAnon value. Before: %ld After: %ld\n",
140132
rss_anon_before, rss_anon_after);
141-
exit(EXIT_FAILURE);
142-
}
143133
}
144134

145135
void split_pmd_zero_pages(void)
@@ -150,7 +140,7 @@ void split_pmd_zero_pages(void)
150140

151141
one_page = allocate_zero_filled_hugepage(len);
152142
verify_rss_anon_split_huge_page_all_zeroes(one_page, nr_hpages, len);
153-
printf("Split zero filled huge pages successful\n");
143+
ksft_test_result_pass("Split zero filled huge pages successful\n");
154144
free(one_page);
155145
}
156146

@@ -491,7 +481,7 @@ int main(int argc, char **argv)
491481
if (argc > 1)
492482
optional_xfs_path = argv[1];
493483

494-
ksft_set_plan(3+9);
484+
ksft_set_plan(4+9);
495485

496486
pagesize = getpagesize();
497487
pageshift = ffs(pagesize) - 1;

0 commit comments

Comments
 (0)