diff mbox series

selftest/vm: clarify error statement in gup_test

Message ID 20220330215257.112029-1-sidhartha.kumar@oracle.com (mailing list archive)
State New
Headers show
Series selftest/vm: clarify error statement in gup_test | expand

Commit Message

Sidhartha Kumar March 30, 2022, 9:52 p.m. UTC
Print two possible reasons /sys/kernel/debug/gup_test
cannot be opened to help users of this test diagnose
failures.

Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Cc: stable@vger.kernel.org # 5.15+
---
 tools/testing/selftests/vm/gup_test.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Andrew Morton March 31, 2022, 1:54 a.m. UTC | #1
On Wed, 30 Mar 2022 21:52:57 +0000 Sidhartha Kumar <sidhartha.kumar@oracle.com> wrote:

> Print two possible reasons /sys/kernel/debug/gup_test
> cannot be opened to help users of this test diagnose
> failures.
> 
> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> Cc: stable@vger.kernel.org # 5.15+
>
> ...
>
> --- a/tools/testing/selftests/vm/gup_test.c
> +++ b/tools/testing/selftests/vm/gup_test.c
> @@ -205,7 +205,9 @@ int main(int argc, char **argv)
>  
>  	gup_fd = open("/sys/kernel/debug/gup_test", O_RDWR);
>  	if (gup_fd == -1) {
> -		perror("open");
> +		perror("failed to open /sys/kernel/debug/gup_test");
> +		printf("check if CONFIG_GUP_TEST is enabled in kernel config\n");
> +		printf("check if debugfs is mounted at /sys/kernel/debug\n");
>  		exit(1);
>  	}

Thanks.  I don't think this is -stable material...
Shuah Khan March 31, 2022, 7:28 p.m. UTC | #2
On 3/30/22 3:52 PM, Sidhartha Kumar wrote:
> Print two possible reasons /sys/kernel/debug/gup_test
> cannot be opened to help users of this test diagnose
> failures.
> 

Thank you for the patch to improve rather cryptic error messages.

> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> Cc: stable@vger.kernel.org # 5.15+
> ---
>   tools/testing/selftests/vm/gup_test.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/vm/gup_test.c b/tools/testing/selftests/vm/gup_test.c
> index fe043f67798b0..c496bcefa7a0e 100644
> --- a/tools/testing/selftests/vm/gup_test.c
> +++ b/tools/testing/selftests/vm/gup_test.c
> @@ -205,7 +205,9 @@ int main(int argc, char **argv)
>   
>   	gup_fd = open("/sys/kernel/debug/gup_test", O_RDWR);
>   	if (gup_fd == -1) {
> -		perror("open");
> +		perror("failed to open /sys/kernel/debug/gup_test");
> +		printf("check if CONFIG_GUP_TEST is enabled in kernel config\n");
> +		printf("check if debugfs is mounted at /sys/kernel/debug\n");

Instead of adding 3 messages in a row, please check the errno to figure
out why it failed and print an appropriate message.

If open fails because CONFIG_GUP_TEST is not enabled, the test should skip
the test instead of fail. Failing will indicate a test failure which is not
the case. The test couldn't be run due to unmet dependencies.

This test requires root access. A check for root privilege and skip the
test for the same reason stated above.

>   		exit(1);
>   	}
>   
> 

Please send v2 with these changes.

thanks,
-- Shuah
diff mbox series

Patch

diff --git a/tools/testing/selftests/vm/gup_test.c b/tools/testing/selftests/vm/gup_test.c
index fe043f67798b0..c496bcefa7a0e 100644
--- a/tools/testing/selftests/vm/gup_test.c
+++ b/tools/testing/selftests/vm/gup_test.c
@@ -205,7 +205,9 @@  int main(int argc, char **argv)
 
 	gup_fd = open("/sys/kernel/debug/gup_test", O_RDWR);
 	if (gup_fd == -1) {
-		perror("open");
+		perror("failed to open /sys/kernel/debug/gup_test");
+		printf("check if CONFIG_GUP_TEST is enabled in kernel config\n");
+		printf("check if debugfs is mounted at /sys/kernel/debug\n");
 		exit(1);
 	}