userfaultfd: selftests: Small fixes
Subsystems (2)
cover userfaultfd: selftests: Small fixes
There're some very trivial fixes that I kept locally to userfaultfd selftest program. Please have a look, thanks.
Peter Xu (3):
userfaultfd/selftests: Always dump something in modes userfaultfd/selftests: Fix retval check for userfaultfd_open() userfaultfd/selftests: Hint the test runner on required privilege
tools/testing/selftests/vm/userfaultfd.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
Signature · 1 line
2.26.2
PATCH 1/3 userfaultfd/selftests: Always dump something in modes
BOUNCE_POLL is a special bit that if cleared it means "READ" instead. Dump that too otherwise we'll see tests with empty modes.
--- tools/testing/selftests/vm/userfaultfd.c | 2 ++ 1 file changed, 2 insertions(+)
tools/testing/selftests/vm/userfaultfd.c +2 -0
@@ -1230,6 +1230,8 @@ static int userfaultfd_stress(void)printf (" ver" );if (bounces &BOUNCE_POLL )printf (" poll" ); +else +printf (" read" );printf (", " );fflush (stdout);
Signature · 1 line
2.26.2
PATCH 2/3 userfaultfd/selftests: Fix retval check for userfaultfd_open()
In reply to Peter Xuuserfaultfd_open() returns 1 for errors rather than negatives. Fix it on all the callers so when UFFDIO_API failed the test will bail out.
--- tools/testing/selftests/vm/userfaultfd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/vm/userfaultfd.c +4 -4
@@ -993,7 +993,7 @@ static int userfaultfd_zeropage_test(void)if (uffd_test_ops->release_pages (area_dst))return 1 ; -if (userfaultfd_open (0 ) <0 ) +if (userfaultfd_open (0 ))return 1 ; uffdio_register.range.start = (unsigned long ) area_dst; uffdio_register.range.len = nr_pages * page_size;
@@ -1038,7 +1038,7 @@ static int userfaultfd_events_test(void) features =UFFD_FEATURE_EVENT_FORK |UFFD_FEATURE_EVENT_REMAP |UFFD_FEATURE_EVENT_REMOVE ; -if (userfaultfd_open (features) <0 ) +if (userfaultfd_open (features))return 1 ;fcntl (uffd,F_SETFL , uffd_flags |O_NONBLOCK );
@@ -1101,7 +1101,7 @@ static int userfaultfd_sig_test(void)return 1 ; features =UFFD_FEATURE_EVENT_FORK |UFFD_FEATURE_SIGBUS ; -if (userfaultfd_open (features) <0 ) +if (userfaultfd_open (features))return 1 ;fcntl (uffd,F_SETFL , uffd_flags |O_NONBLOCK );
@@ -1170,7 +1170,7 @@ static int userfaultfd_stress(void)if (!area_dst)return 1 ; -if (userfaultfd_open (0 ) <0 ) +if (userfaultfd_open (0 ))return 1 ; count_verify =malloc (nr_pages *sizeof (unsigned long long ));
Signature · 1 line
2.26.2
PATCH 3/3 userfaultfd/selftests: Hint the test runner on required privilege
In reply to Peter XuNow userfaultfd test program requires either root or ptrace privilege due to the signal/event tests. When UFFDIO_API failed, hint the test runner about this fact verbosely.
--- tools/testing/selftests/vm/userfaultfd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/vm/userfaultfd.c +2 -1
@@ -755,7 +755,8 @@ static int userfaultfd_open(int features) uffdio_api.api =UFFD_API ; uffdio_api.features = features;if (ioctl (uffd,UFFDIO_API , &uffdio_api)) { -fprintf (stderr,"UFFDIO_API\n" ); +fprintf (stderr,"UFFDIO_API failed.\nPlease make sure to " +"run with either root or ptrace capability.\n" );return 1 ; }if (uffdio_api.api !=UFFD_API ) {
Signature · 1 line
2.26.2