linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] selftests/mm: Output cleanups for the compaction test
@ 2024-02-09 14:30 Mark Brown
  2024-02-09 14:30 ` [PATCH 1/2] selftests/mm: Log skipped compaction test as a skip Mark Brown
  2024-02-09 14:30 ` [PATCH 2/2] selftests/mm: Log a consistent test name for check_compaction Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Mark Brown @ 2024-02-09 14:30 UTC (permalink / raw)
  To: Andrew Morton, Shuah Khan
  Cc: Muhammad Usama Anjum, Ryan Roberts, linux-mm, linux-kselftest,
	linux-kernel, Mark Brown

A couple of small updates for the check_compaction selftest which make
it play more nicely with test automation systems.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
Mark Brown (2):
      selftests/mm: Log skipped compaction test as a skip
      selftests/mm: Log a consistent test name for check_compaction

 tools/testing/selftests/mm/compaction_test.c | 37 +++++++++++++++-------------
 1 file changed, 20 insertions(+), 17 deletions(-)
---
base-commit: b1d3a0e70c3881d2f8cf6692ccf7c2a4fb2d030d
change-id: 20240208-kselftest-mm-cleanup-30edd2e567cb

Best regards,
-- 
Mark Brown <broonie@kernel.org>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] selftests/mm: Log skipped compaction test as a skip
  2024-02-09 14:30 [PATCH 0/2] selftests/mm: Output cleanups for the compaction test Mark Brown
@ 2024-02-09 14:30 ` Mark Brown
  2024-02-09 14:30 ` [PATCH 2/2] selftests/mm: Log a consistent test name for check_compaction Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2024-02-09 14:30 UTC (permalink / raw)
  To: Andrew Morton, Shuah Khan
  Cc: Muhammad Usama Anjum, Ryan Roberts, linux-mm, linux-kselftest,
	linux-kernel, Mark Brown

When the compaction test is run it checks to make sure that prerequistives
the test requires are available and skips the tests if not. When this
happens we log the test as a pass rather than a skip, log as a skip so that
the distinction is clear and automation can see unexpected skips.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 tools/testing/selftests/mm/compaction_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/mm/compaction_test.c b/tools/testing/selftests/mm/compaction_test.c
index 656afba02dbc..30150929c8c5 100644
--- a/tools/testing/selftests/mm/compaction_test.c
+++ b/tools/testing/selftests/mm/compaction_test.c
@@ -174,7 +174,7 @@ int main(int argc, char **argv)
 	ksft_print_header();
 
 	if (prereq() || geteuid())
-		return ksft_exit_pass();
+		return ksft_exit_skip("Prerequisites unsatisfied\n");
 
 	ksft_set_plan(1);
 

-- 
2.39.2



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] selftests/mm: Log a consistent test name for check_compaction
  2024-02-09 14:30 [PATCH 0/2] selftests/mm: Output cleanups for the compaction test Mark Brown
  2024-02-09 14:30 ` [PATCH 1/2] selftests/mm: Log skipped compaction test as a skip Mark Brown
@ 2024-02-09 14:30 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2024-02-09 14:30 UTC (permalink / raw)
  To: Andrew Morton, Shuah Khan
  Cc: Muhammad Usama Anjum, Ryan Roberts, linux-mm, linux-kselftest,
	linux-kernel, Mark Brown

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.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 tools/testing/selftests/mm/compaction_test.c | 35 +++++++++++++++-------------
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/tools/testing/selftests/mm/compaction_test.c b/tools/testing/selftests/mm/compaction_test.c
index 30150929c8c5..533999b6c284 100644
--- a/tools/testing/selftests/mm/compaction_test.c
+++ b/tools/testing/selftests/mm/compaction_test.c
@@ -95,21 +95,22 @@ int check_compaction(unsigned long mem_free, unsigned int hugepage_size)
 
 	fd = open("/proc/sys/vm/nr_hugepages", O_RDWR | O_NONBLOCK);
 	if (fd < 0) {
-		ksft_test_result_fail("Failed to open /proc/sys/vm/nr_hugepages: %s\n",
-				      strerror(errno));
-		return -1;
+		ksft_print_msg("Failed to open /proc/sys/vm/nr_hugepages: %s\n",
+			       strerror(errno));
+		ret = -1;
+		goto out;
 	}
 
 	if (read(fd, initial_nr_hugepages, sizeof(initial_nr_hugepages)) <= 0) {
-		ksft_test_result_fail("Failed to read from /proc/sys/vm/nr_hugepages: %s\n",
-				      strerror(errno));
+		ksft_print_msg("Failed to read from /proc/sys/vm/nr_hugepages: %s\n",
+			       strerror(errno));
 		goto close_fd;
 	}
 
 	/* Start with the initial condition of 0 huge pages*/
 	if (write(fd, "0", sizeof(char)) != sizeof(char)) {
-		ksft_test_result_fail("Failed to write 0 to /proc/sys/vm/nr_hugepages: %s\n",
-				      strerror(errno));
+		ksft_print_msg("Failed to write 0 to /proc/sys/vm/nr_hugepages: %s\n",
+			       strerror(errno));
 		goto close_fd;
 	}
 
@@ -118,16 +119,16 @@ int check_compaction(unsigned long mem_free, unsigned int hugepage_size)
 	/* Request a large number of huge pages. The Kernel will allocate
 	   as much as it can */
 	if (write(fd, "100000", (6*sizeof(char))) != (6*sizeof(char))) {
-		ksft_test_result_fail("Failed to write 100000 to /proc/sys/vm/nr_hugepages: %s\n",
-				      strerror(errno));
+		ksft_print_msg("Failed to write 100000 to /proc/sys/vm/nr_hugepages: %s\n",
+			       strerror(errno));
 		goto close_fd;
 	}
 
 	lseek(fd, 0, SEEK_SET);
 
 	if (read(fd, nr_hugepages, sizeof(nr_hugepages)) <= 0) {
-		ksft_test_result_fail("Failed to re-read from /proc/sys/vm/nr_hugepages: %s\n",
-				      strerror(errno));
+		ksft_print_msg("Failed to re-read from /proc/sys/vm/nr_hugepages: %s\n",
+			       strerror(errno));
 		goto close_fd;
 	}
 
@@ -139,24 +140,26 @@ int check_compaction(unsigned long mem_free, unsigned int hugepage_size)
 
 	if (write(fd, initial_nr_hugepages, strlen(initial_nr_hugepages))
 	    != strlen(initial_nr_hugepages)) {
-		ksft_test_result_fail("Failed to write value to /proc/sys/vm/nr_hugepages: %s\n",
-				      strerror(errno));
+		ksft_print_msg("Failed to write value to /proc/sys/vm/nr_hugepages: %s\n",
+			       strerror(errno));
 		goto close_fd;
 	}
 
+	ksft_print_msg("Number of huge pages allocated = %d\n",
+		       atoi(nr_hugepages));
+
 	if (compaction_index > 3) {
 		ksft_print_msg("ERROR: Less that 1/%d of memory is available\n"
 			       "as huge pages\n", compaction_index);
-		ksft_test_result_fail("No of huge pages allocated = %d\n", (atoi(nr_hugepages)));
 		goto close_fd;
 	}
 
-	ksft_test_result_pass("Memory compaction succeeded. No of huge pages allocated = %d\n",
-			      (atoi(nr_hugepages)));
 	ret = 0;
 
  close_fd:
 	close(fd);
+ out:
+	ksft_test_result(ret == 0, "check_compaction\n");
 	return ret;
 }
 

-- 
2.39.2



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-02-09 14:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-09 14:30 [PATCH 0/2] selftests/mm: Output cleanups for the compaction test Mark Brown
2024-02-09 14:30 ` [PATCH 1/2] selftests/mm: Log skipped compaction test as a skip Mark Brown
2024-02-09 14:30 ` [PATCH 2/2] selftests/mm: Log a consistent test name for check_compaction Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox