Skip to content

Commit 264b8a7

Browse files
brooniegregkh
authored andcommitted
selftests/mm: log a consistent test name for check_compaction
[ Upstream commit f3b7568 ] Every test result report in the compaction test prints a distinct log messae, and some of the reports print a name that varies at runtime. This causes problems for automation since a lot of automation software uses the printed string as the name of the test, if the name varies from run to run and from pass to fail then the automation software can't identify that a test changed result or that the same tests are being run. Refactor the logging to use a consistent name when printing the result of the test, printing the existing messages as diagnostic information instead so they are still available for people trying to interpret the results. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]> Cc: Muhammad Usama Anjum <[email protected]> Cc: Ryan Roberts <[email protected]> Cc: Shuah Khan <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Stable-dep-of: d4202e6 ("selftests/mm: compaction_test: fix bogus test success on Aarch64") Signed-off-by: Sasha Levin <[email protected]>
1 parent 5ba3913 commit 264b8a7

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

tools/testing/selftests/vm/compaction_test.c

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,23 +95,24 @@ int check_compaction(unsigned long mem_free, unsigned int hugepage_size)
9595

9696
fd = open("/proc/sys/vm/nr_hugepages", O_RDWR | O_NONBLOCK);
9797
if (fd < 0) {
98-
ksft_test_result_fail("Failed to open /proc/sys/vm/nr_hugepages: %s\n",
99-
strerror(errno));
100-
return -1;
98+
ksft_print_msg("Failed to open /proc/sys/vm/nr_hugepages: %s\n",
99+
strerror(errno));
100+
ret = -1;
101+
goto out;
101102
}
102103

103104
if (read(fd, initial_nr_hugepages, sizeof(initial_nr_hugepages)) <= 0) {
104-
ksft_test_result_fail("Failed to read from /proc/sys/vm/nr_hugepages: %s\n",
105-
strerror(errno));
105+
ksft_print_msg("Failed to read from /proc/sys/vm/nr_hugepages: %s\n",
106+
strerror(errno));
106107
goto close_fd;
107108
}
108109

109110
lseek(fd, 0, SEEK_SET);
110111

111112
/* Start with the initial condition of 0 huge pages*/
112113
if (write(fd, "0", sizeof(char)) != sizeof(char)) {
113-
ksft_test_result_fail("Failed to write 0 to /proc/sys/vm/nr_hugepages: %s\n",
114-
strerror(errno));
114+
ksft_print_msg("Failed to write 0 to /proc/sys/vm/nr_hugepages: %s\n",
115+
strerror(errno));
115116
goto close_fd;
116117
}
117118

@@ -120,16 +121,16 @@ int check_compaction(unsigned long mem_free, unsigned int hugepage_size)
120121
/* Request a large number of huge pages. The Kernel will allocate
121122
as much as it can */
122123
if (write(fd, "100000", (6*sizeof(char))) != (6*sizeof(char))) {
123-
ksft_test_result_fail("Failed to write 100000 to /proc/sys/vm/nr_hugepages: %s\n",
124-
strerror(errno));
124+
ksft_print_msg("Failed to write 100000 to /proc/sys/vm/nr_hugepages: %s\n",
125+
strerror(errno));
125126
goto close_fd;
126127
}
127128

128129
lseek(fd, 0, SEEK_SET);
129130

130131
if (read(fd, nr_hugepages, sizeof(nr_hugepages)) <= 0) {
131-
ksft_test_result_fail("Failed to re-read from /proc/sys/vm/nr_hugepages: %s\n",
132-
strerror(errno));
132+
ksft_print_msg("Failed to re-read from /proc/sys/vm/nr_hugepages: %s\n",
133+
strerror(errno));
133134
goto close_fd;
134135
}
135136

@@ -141,24 +142,26 @@ int check_compaction(unsigned long mem_free, unsigned int hugepage_size)
141142

142143
if (write(fd, initial_nr_hugepages, strlen(initial_nr_hugepages))
143144
!= strlen(initial_nr_hugepages)) {
144-
ksft_test_result_fail("Failed to write value to /proc/sys/vm/nr_hugepages: %s\n",
145-
strerror(errno));
145+
ksft_print_msg("Failed to write value to /proc/sys/vm/nr_hugepages: %s\n",
146+
strerror(errno));
146147
goto close_fd;
147148
}
148149

150+
ksft_print_msg("Number of huge pages allocated = %d\n",
151+
atoi(nr_hugepages));
152+
149153
if (compaction_index > 3) {
150154
ksft_print_msg("ERROR: Less that 1/%d of memory is available\n"
151155
"as huge pages\n", compaction_index);
152-
ksft_test_result_fail("No of huge pages allocated = %d\n", (atoi(nr_hugepages)));
153156
goto close_fd;
154157
}
155158

156-
ksft_test_result_pass("Memory compaction succeeded. No of huge pages allocated = %d\n",
157-
(atoi(nr_hugepages)));
158159
ret = 0;
159160

160161
close_fd:
161162
close(fd);
163+
out:
164+
ksft_test_result(ret == 0, "check_compaction\n");
162165
return ret;
163166
}
164167

0 commit comments

Comments
 (0)