linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Muhammad Usama Anjum <usama.anjum@collabora.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Muhammad Usama Anjum <usama.anjum@collabora.com>,
	kernel@collabora.com, linux-mm@kvack.org,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	Shuah Khan <shuah@kernel.org>
Subject: Re: [PATCH v3 1/7] selftests/mm: hugepage-shm: conform test to TAP format output
Date: Tue, 23 Jan 2024 12:52:20 +0500	[thread overview]
Message-ID: <965acceb-9aa1-473f-a873-40eaaebe5d0c@collabora.com> (raw)
In-Reply-To: <20240115073247.1280266-1-usama.anjum@collabora.com>

Hi Andrew,

There hasn't been any comment on these. I guess, they can be picked up now?

Thanks,

On 1/15/24 12:32 PM, Muhammad Usama Anjum wrote:
> Conform the layout, informational and status messages to TAP. No
> functional change is intended other than the layout of output messages.
> 
> The "." was being printed inside for loop to indicate the writes
> progress. This was extraneous and hence removed in the patch.
> 
> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> ---
>  tools/testing/selftests/mm/hugepage-shm.c | 47 +++++++++++------------
>  1 file changed, 22 insertions(+), 25 deletions(-)
> 
> diff --git a/tools/testing/selftests/mm/hugepage-shm.c b/tools/testing/selftests/mm/hugepage-shm.c
> index 478bb1e989e9..f949dbbc3454 100644
> --- a/tools/testing/selftests/mm/hugepage-shm.c
> +++ b/tools/testing/selftests/mm/hugepage-shm.c
> @@ -34,11 +34,10 @@
>  #include <sys/ipc.h>
>  #include <sys/shm.h>
>  #include <sys/mman.h>
> +#include "../kselftest.h"
>  
>  #define LENGTH (256UL*1024*1024)
>  
> -#define dprintf(x)  printf(x)
> -
>  /* Only ia64 requires this */
>  #ifdef __ia64__
>  #define ADDR (void *)(0x8000000000000000UL)
> @@ -54,44 +53,42 @@ int main(void)
>  	unsigned long i;
>  	char *shmaddr;
>  
> +	ksft_print_header();
> +	ksft_set_plan(1);
> +
>  	shmid = shmget(2, LENGTH, SHM_HUGETLB | IPC_CREAT | SHM_R | SHM_W);
> -	if (shmid < 0) {
> -		perror("shmget");
> -		exit(1);
> -	}
> -	printf("shmid: 0x%x\n", shmid);
> +	if (shmid < 0)
> +		ksft_exit_fail_msg("shmget: %s\n", strerror(errno));
> +
> +	ksft_print_msg("shmid: 0x%x\n", shmid);
>  
>  	shmaddr = shmat(shmid, ADDR, SHMAT_FLAGS);
>  	if (shmaddr == (char *)-1) {
> -		perror("Shared memory attach failure");
>  		shmctl(shmid, IPC_RMID, NULL);
> -		exit(2);
> +		ksft_exit_fail_msg("Shared memory attach failure: %s\n", strerror(errno));
>  	}
> -	printf("shmaddr: %p\n", shmaddr);
>  
> -	dprintf("Starting the writes:\n");
> -	for (i = 0; i < LENGTH; i++) {
> +	ksft_print_msg("shmaddr: %p\n", shmaddr);
> +
> +	ksft_print_msg("Starting the writes:");
> +	for (i = 0; i < LENGTH; i++)
>  		shmaddr[i] = (char)(i);
> -		if (!(i % (1024 * 1024)))
> -			dprintf(".");
> -	}
> -	dprintf("\n");
> +	ksft_print_msg("Done.\n");
>  
> -	dprintf("Starting the Check...");
> +	ksft_print_msg("Starting the Check...");
>  	for (i = 0; i < LENGTH; i++)
> -		if (shmaddr[i] != (char)i) {
> -			printf("\nIndex %lu mismatched\n", i);
> -			exit(3);
> -		}
> -	dprintf("Done.\n");
> +		if (shmaddr[i] != (char)i)
> +			ksft_exit_fail_msg("\nIndex %lu mismatched\n", i);
> +	ksft_print_msg("Done.\n");
>  
>  	if (shmdt((const void *)shmaddr) != 0) {
> -		perror("Detach failure");
>  		shmctl(shmid, IPC_RMID, NULL);
> -		exit(4);
> +		ksft_exit_fail_msg("Detach failure: %s\n", strerror(errno));
>  	}
>  
>  	shmctl(shmid, IPC_RMID, NULL);
>  
> -	return 0;
> +	ksft_test_result_pass("Completed test\n");
> +
> +	ksft_finished();
>  }

-- 
BR,
Muhammad Usama Anjum


      parent reply	other threads:[~2024-01-23  7:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-15  7:32 Muhammad Usama Anjum
2024-01-15  7:32 ` [PATCH v3 2/7] selftests/mm: hugepage-vmemmap: " Muhammad Usama Anjum
2024-01-15  7:32 ` [PATCH v3 3/7] selftests/mm: hugetlb-madvise: " Muhammad Usama Anjum
2024-01-15  7:32 ` [PATCH v3 4/7] selftests/mm: khugepaged: " Muhammad Usama Anjum
2024-01-15  7:32 ` [PATCH v3 5/7] selftests/mm: hugetlb-read-hwpoison: " Muhammad Usama Anjum
2024-01-16 17:07   ` Jiaqi Yan
2024-01-17  5:34     ` Muhammad Usama Anjum
2024-01-15  7:32 ` [PATCH v3 6/7] selftests/mm: ksm_tests: " Muhammad Usama Anjum
2024-01-15  7:32 ` [PATCH v3 7/7] selftests/mm: config: add missing configs Muhammad Usama Anjum
2024-01-23  7:52 ` Muhammad Usama Anjum [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=965acceb-9aa1-473f-a873-40eaaebe5d0c@collabora.com \
    --to=usama.anjum@collabora.com \
    --cc=akpm@linux-foundation.org \
    --cc=kernel@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox