+ selftests-mm-hugetlb-read-hwpoison-conform-test-to-tap-format-output.patch added to mm-nonmm-unstable branch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: selftests/mm: hugetlb-read-hwpoison: conform test to TAP format output
has been added to the -mm mm-nonmm-unstable branch.  Its filename is
     selftests-mm-hugetlb-read-hwpoison-conform-test-to-tap-format-output.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/selftests-mm-hugetlb-read-hwpoison-conform-test-to-tap-format-output.patch

This patch will later appear in the mm-nonmm-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days

------------------------------------------------------
From: Muhammad Usama Anjum <usama.anjum@xxxxxxxxxxxxx>
Subject: selftests/mm: hugetlb-read-hwpoison: conform test to TAP format output
Date: Fri, 26 Jan 2024 16:21:24 +0500

Conform the layout, informational and status messages to TAP.  No
functional change is intended other than the layout of output messages.

Link: https://lkml.kernel.org/r/20240126112129.1480265-5-usama.anjum@xxxxxxxxxxxxx
Reviewed-by: Jiaqi Yan <jiaqiyan@xxxxxxxxxx>
Signed-off-by: Muhammad Usama Anjum <usama.anjum@xxxxxxxxxxxxx>
Cc: Shuah Khan <shuah@xxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 tools/testing/selftests/mm/hugetlb-read-hwpoison.c |  116 +++++------
 1 file changed, 54 insertions(+), 62 deletions(-)

--- a/tools/testing/selftests/mm/hugetlb-read-hwpoison.c~selftests-mm-hugetlb-read-hwpoison-conform-test-to-tap-format-output
+++ a/tools/testing/selftests/mm/hugetlb-read-hwpoison.c
@@ -58,8 +58,8 @@ static bool verify_chunk(char *buf, size
 
 	for (i = 0; i < len; ++i) {
 		if (buf[i] != val) {
-			printf(PREFIX ERROR_PREFIX "check fail: buf[%lu] = %u != %u\n",
-				i, buf[i], val);
+			ksft_print_msg(PREFIX ERROR_PREFIX "check fail: buf[%lu] = %u != %u\n",
+				       i, buf[i], val);
 			return false;
 		}
 	}
@@ -75,21 +75,21 @@ static bool seek_read_hugepage_filemap(i
 	ssize_t total_ret_count = 0;
 	char val = offset / wr_chunk_size + offset % wr_chunk_size;
 
-	printf(PREFIX PREFIX "init val=%u with offset=0x%lx\n", val, offset);
-	printf(PREFIX PREFIX "expect to read 0x%lx bytes of data in total\n",
-	       expected);
+	ksft_print_msg(PREFIX PREFIX "init val=%u with offset=0x%lx\n", val, offset);
+	ksft_print_msg(PREFIX PREFIX "expect to read 0x%lx bytes of data in total\n",
+		       expected);
 	if (lseek(fd, offset, SEEK_SET) < 0) {
-		perror(PREFIX ERROR_PREFIX "seek failed");
+		ksft_perror(PREFIX ERROR_PREFIX "seek failed");
 		return false;
 	}
 
 	while (offset + total_ret_count < len) {
 		ret_count = read(fd, buf, wr_chunk_size);
 		if (ret_count == 0) {
-			printf(PREFIX PREFIX "read reach end of the file\n");
+			ksft_print_msg(PREFIX PREFIX "read reach end of the file\n");
 			break;
 		} else if (ret_count < 0) {
-			perror(PREFIX ERROR_PREFIX "read failed");
+			ksft_perror(PREFIX ERROR_PREFIX "read failed");
 			break;
 		}
 		++val;
@@ -98,8 +98,8 @@ static bool seek_read_hugepage_filemap(i
 
 		total_ret_count += ret_count;
 	}
-	printf(PREFIX PREFIX "actually read 0x%lx bytes of data in total\n",
-	       total_ret_count);
+	ksft_print_msg(PREFIX PREFIX "actually read 0x%lx bytes of data in total\n",
+		       total_ret_count);
 
 	return total_ret_count == expected;
 }
@@ -112,15 +112,15 @@ static bool read_hugepage_filemap(int fd
 	ssize_t total_ret_count = 0;
 	char val = 0;
 
-	printf(PREFIX PREFIX "expect to read 0x%lx bytes of data in total\n",
-	       expected);
+	ksft_print_msg(PREFIX PREFIX "expect to read 0x%lx bytes of data in total\n",
+		       expected);
 	while (total_ret_count < len) {
 		ret_count = read(fd, buf, wr_chunk_size);
 		if (ret_count == 0) {
-			printf(PREFIX PREFIX "read reach end of the file\n");
+			ksft_print_msg(PREFIX PREFIX "read reach end of the file\n");
 			break;
 		} else if (ret_count < 0) {
-			perror(PREFIX ERROR_PREFIX "read failed");
+			ksft_perror(PREFIX ERROR_PREFIX "read failed");
 			break;
 		}
 		++val;
@@ -129,8 +129,8 @@ static bool read_hugepage_filemap(int fd
 
 		total_ret_count += ret_count;
 	}
-	printf(PREFIX PREFIX "actually read 0x%lx bytes of data in total\n",
-	       total_ret_count);
+	ksft_print_msg(PREFIX PREFIX "actually read 0x%lx bytes of data in total\n",
+		       total_ret_count);
 
 	return total_ret_count == expected;
 }
@@ -142,14 +142,14 @@ test_hugetlb_read(int fd, size_t len, si
 	char *filemap = NULL;
 
 	if (ftruncate(fd, len) < 0) {
-		perror(PREFIX ERROR_PREFIX "ftruncate failed");
+		ksft_perror(PREFIX ERROR_PREFIX "ftruncate failed");
 		return status;
 	}
 
 	filemap = mmap(NULL, len, PROT_READ | PROT_WRITE,
 		       MAP_SHARED | MAP_POPULATE, fd, 0);
 	if (filemap == MAP_FAILED) {
-		perror(PREFIX ERROR_PREFIX "mmap for primary mapping failed");
+		ksft_perror(PREFIX ERROR_PREFIX "mmap for primary mapping failed");
 		goto done;
 	}
 
@@ -162,7 +162,7 @@ test_hugetlb_read(int fd, size_t len, si
 	munmap(filemap, len);
 done:
 	if (ftruncate(fd, 0) < 0) {
-		perror(PREFIX ERROR_PREFIX "ftruncate back to 0 failed");
+		ksft_perror(PREFIX ERROR_PREFIX "ftruncate back to 0 failed");
 		status = TEST_FAILED;
 	}
 
@@ -179,14 +179,14 @@ test_hugetlb_read_hwpoison(int fd, size_
 	const unsigned long pagesize = getpagesize();
 
 	if (ftruncate(fd, len) < 0) {
-		perror(PREFIX ERROR_PREFIX "ftruncate failed");
+		ksft_perror(PREFIX ERROR_PREFIX "ftruncate failed");
 		return status;
 	}
 
 	filemap = mmap(NULL, len, PROT_READ | PROT_WRITE,
 		       MAP_SHARED | MAP_POPULATE, fd, 0);
 	if (filemap == MAP_FAILED) {
-		perror(PREFIX ERROR_PREFIX "mmap for primary mapping failed");
+		ksft_perror(PREFIX ERROR_PREFIX "mmap for primary mapping failed");
 		goto done;
 	}
 
@@ -201,7 +201,7 @@ test_hugetlb_read_hwpoison(int fd, size_
 	 */
 	hwp_addr = filemap + len / 2 + pagesize;
 	if (madvise(hwp_addr, pagesize, MADV_HWPOISON) < 0) {
-		perror(PREFIX ERROR_PREFIX "MADV_HWPOISON failed");
+		ksft_perror(PREFIX ERROR_PREFIX "MADV_HWPOISON failed");
 		goto unmap;
 	}
 
@@ -228,7 +228,7 @@ unmap:
 	munmap(filemap, len);
 done:
 	if (ftruncate(fd, 0) < 0) {
-		perror(PREFIX ERROR_PREFIX "ftruncate back to 0 failed");
+		ksft_perror(PREFIX ERROR_PREFIX "ftruncate back to 0 failed");
 		status = TEST_FAILED;
 	}
 
@@ -240,27 +240,32 @@ static int create_hugetlbfs_file(struct
 	int fd;
 
 	fd = memfd_create("hugetlb_tmp", MFD_HUGETLB);
-	if (fd < 0) {
-		perror(PREFIX ERROR_PREFIX "could not open hugetlbfs file");
-		return -1;
-	}
+	if (fd < 0)
+		ksft_exit_fail_msg(PREFIX ERROR_PREFIX "could not open hugetlbfs file: %s\n",
+				   strerror(errno));
 
 	memset(file_stat, 0, sizeof(*file_stat));
+
 	if (fstatfs(fd, file_stat)) {
-		perror(PREFIX ERROR_PREFIX "fstatfs failed");
-		goto close;
+		close(fd);
+		ksft_exit_fail_msg(PREFIX ERROR_PREFIX "fstatfs failed: %s\n", strerror(errno));
 	}
 	if (file_stat->f_type != HUGETLBFS_MAGIC) {
-		printf(PREFIX ERROR_PREFIX "not hugetlbfs file\n");
-		goto close;
+		close(fd);
+		ksft_exit_fail_msg(PREFIX ERROR_PREFIX "not hugetlbfs file\n");
 	}
 
 	return fd;
-close:
-	close(fd);
-	return -1;
 }
 
+#define KSFT_PRINT_MSG(status, fmt, ...)					\
+	do {									\
+		if (status == TEST_SKIPPED)					\
+			ksft_test_result_skip(fmt, __VA_ARGS__);		\
+		else								\
+			ksft_test_result(status == TEST_PASSED, fmt, __VA_ARGS__); \
+	} while (0)
+
 int main(void)
 {
 	int fd;
@@ -273,50 +278,37 @@ int main(void)
 	};
 	size_t i;
 
+	ksft_print_header();
+	ksft_set_plan(12);
+
 	for (i = 0; i < ARRAY_SIZE(wr_chunk_sizes); ++i) {
-		printf("Write/read chunk size=0x%lx\n",
-		       wr_chunk_sizes[i]);
+		ksft_print_msg("Write/read chunk size=0x%lx\n",
+			       wr_chunk_sizes[i]);
 
 		fd = create_hugetlbfs_file(&file_stat);
-		if (fd < 0)
-			goto create_failure;
-		printf(PREFIX "HugeTLB read regression test...\n");
+		ksft_print_msg(PREFIX "HugeTLB read regression test...\n");
 		status = test_hugetlb_read(fd, file_stat.f_bsize,
 					   wr_chunk_sizes[i]);
-		printf(PREFIX "HugeTLB read regression test...%s\n",
-		       status_to_str(status));
+		KSFT_PRINT_MSG(status, PREFIX "HugeTLB read regression test...%s\n",
+			       status_to_str(status));
 		close(fd);
-		if (status == TEST_FAILED)
-			return -1;
 
 		fd = create_hugetlbfs_file(&file_stat);
-		if (fd < 0)
-			goto create_failure;
-		printf(PREFIX "HugeTLB read HWPOISON test...\n");
+		ksft_print_msg(PREFIX "HugeTLB read HWPOISON test...\n");
 		status = test_hugetlb_read_hwpoison(fd, file_stat.f_bsize,
 						    wr_chunk_sizes[i], false);
-		printf(PREFIX "HugeTLB read HWPOISON test...%s\n",
-		       status_to_str(status));
+		KSFT_PRINT_MSG(status, PREFIX "HugeTLB read HWPOISON test...%s\n",
+			       status_to_str(status));
 		close(fd);
-		if (status == TEST_FAILED)
-			return -1;
 
 		fd = create_hugetlbfs_file(&file_stat);
-		if (fd < 0)
-			goto create_failure;
-		printf(PREFIX "HugeTLB seek then read HWPOISON test...\n");
+		ksft_print_msg(PREFIX "HugeTLB seek then read HWPOISON test...\n");
 		status = test_hugetlb_read_hwpoison(fd, file_stat.f_bsize,
 						    wr_chunk_sizes[i], true);
-		printf(PREFIX "HugeTLB seek then read HWPOISON test...%s\n",
-		       status_to_str(status));
+		KSFT_PRINT_MSG(status, PREFIX "HugeTLB seek then read HWPOISON test...%s\n",
+			       status_to_str(status));
 		close(fd);
-		if (status == TEST_FAILED)
-			return -1;
 	}
 
-	return 0;
-
-create_failure:
-	printf(ERROR_PREFIX "Abort test: failed to create hugetlbfs file\n");
-	return -1;
+	ksft_finished();
 }
_

Patches currently in -mm which might be from usama.anjum@xxxxxxxxxxxxx are

selftests-core-include-linux-close_rangeh-for-close_range_-macros.patch
selftests-mm-hugetlb_reparenting_test-do-not-unmount.patch
selftests-mm-run_vmtests-remove-sudo-and-conform-to-tap.patch
selftests-mm-save-and-restore-nr_hugepages-value.patch
selftests-mm-protection_keys-save-restore-nr_hugepages-settings.patch
selftests-mm-run_vmtestssh-add-missing-tests.patch
selftests-mm-hugepage-shm-conform-test-to-tap-format-output.patch
selftests-mm-hugepage-vmemmap-conform-test-to-tap-format-output.patch
selftests-mm-hugetlb-madvise-conform-test-to-tap-format-output.patch
selftests-mm-khugepaged-conform-test-to-tap-format-output.patch
selftests-mm-hugetlb-read-hwpoison-conform-test-to-tap-format-output.patch
selftests-mm-ksm_tests-conform-test-to-tap-format-output.patch
selftests-mm-config-add-missing-configs.patch





[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux