mbox series

[0/3] Add tst_iterate_fd()

Message ID 20231004124712.3833-1-chrubis@suse.cz (mailing list archive)
Headers show
Series Add tst_iterate_fd() | expand

Message

Cyril Hrubis Oct. 4, 2023, 12:47 p.m. UTC
- adds tst_iterate_fd() functionality
 - make use of tst_iterate_fd() in readahead01
 - add accept03 test which uses tst_iterate_fd()

This is a prototype for how the functionality to iterate over different
file descriptors should look like it converts one tests and adds
another. There is plenty of other syscalls that can use this kind of
testing, e.g. all fooat() syscalls where we can pass invalid dir_fd, the
plan is to add these if/once we agree on the API.

Cyril Hrubis (3):
  lib: Add tst_fd_iterate()
  syscalls/readahead01: Make use of tst_fd_iterate()
  syscalls: accept: Add tst_fd_iterate() test

 include/tst_fd.h                              |  39 ++++++
 include/tst_test.h                            |   1 +
 lib/tst_fd.c                                  | 116 ++++++++++++++++++
 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/accept/.gitignore   |   1 +
 testcases/kernel/syscalls/accept/accept01.c   |   8 --
 testcases/kernel/syscalls/accept/accept03.c   |  46 +++++++
 .../kernel/syscalls/readahead/readahead01.c   |  46 +++----
 8 files changed, 224 insertions(+), 34 deletions(-)
 create mode 100644 include/tst_fd.h
 create mode 100644 lib/tst_fd.c
 create mode 100644 testcases/kernel/syscalls/accept/accept03.c

Comments

Richard Palethorpe Oct. 10, 2023, 10:13 a.m. UTC | #1
Hello,

Cyril Hrubis <chrubis@suse.cz> writes:

>  - adds tst_iterate_fd() functionality
>  - make use of tst_iterate_fd() in readahead01
>  - add accept03 test which uses tst_iterate_fd()
>
> This is a prototype for how the functionality to iterate over different
> file descriptors should look like it converts one tests and adds
> another. There is plenty of other syscalls that can use this kind of
> testing, e.g. all fooat() syscalls where we can pass invalid dir_fd, the
> plan is to add these if/once we agree on the API.

I imagine the results of using this with splice could be very interesting.

>
> Cyril Hrubis (3):
>   lib: Add tst_fd_iterate()
>   syscalls/readahead01: Make use of tst_fd_iterate()
>   syscalls: accept: Add tst_fd_iterate() test
>
>  include/tst_fd.h                              |  39 ++++++
>  include/tst_test.h                            |   1 +
>  lib/tst_fd.c                                  | 116 ++++++++++++++++++
>  runtest/syscalls                              |   1 +
>  testcases/kernel/syscalls/accept/.gitignore   |   1 +
>  testcases/kernel/syscalls/accept/accept01.c   |   8 --
>  testcases/kernel/syscalls/accept/accept03.c   |  46 +++++++
>  .../kernel/syscalls/readahead/readahead01.c   |  46 +++----
>  8 files changed, 224 insertions(+), 34 deletions(-)
>  create mode 100644 include/tst_fd.h
>  create mode 100644 lib/tst_fd.c
>  create mode 100644 testcases/kernel/syscalls/accept/accept03.c
>
> -- 
> 2.41.0
Cyril Hrubis Oct. 10, 2023, 1:20 p.m. UTC | #2
Hi!
> >  - adds tst_iterate_fd() functionality
> >  - make use of tst_iterate_fd() in readahead01
> >  - add accept03 test which uses tst_iterate_fd()
> >
> > This is a prototype for how the functionality to iterate over different
> > file descriptors should look like it converts one tests and adds
> > another. There is plenty of other syscalls that can use this kind of
> > testing, e.g. all fooat() syscalls where we can pass invalid dir_fd, the
> > plan is to add these if/once we agree on the API.
> 
> I imagine the results of using this with splice could be very interesting.

Good idea, I guess that we need to figure out how to do carthesian
multiplication on the different file descriptors though. Maybe we need
to treat the tst_interate_fd() as an iterator so that we can advance to
the next fd with each call, so that we can do:

	struct tst_fd fd_in = {}, fd_out = {};

	while (tst_iterate_fd(&fd_in)) {
		while (tst_iterate_fd(&fd_out)) {
			...
			TST_TEST(splice(fd_in.fd, 0, fd_out.fd, 0, ...));
			...
		}
	}
Richard Palethorpe Oct. 11, 2023, 8:42 a.m. UTC | #3
Hello,

Cyril Hrubis <chrubis@suse.cz> writes:

> Hi!
>> >  - adds tst_iterate_fd() functionality
>> >  - make use of tst_iterate_fd() in readahead01
>> >  - add accept03 test which uses tst_iterate_fd()
>> >
>> > This is a prototype for how the functionality to iterate over different
>> > file descriptors should look like it converts one tests and adds
>> > another. There is plenty of other syscalls that can use this kind of
>> > testing, e.g. all fooat() syscalls where we can pass invalid dir_fd, the
>> > plan is to add these if/once we agree on the API.
>> 
>> I imagine the results of using this with splice could be very interesting.
>
> Good idea, I guess that we need to figure out how to do carthesian
> multiplication on the different file descriptors though. Maybe we need
> to treat the tst_interate_fd() as an iterator so that we can advance to
> the next fd with each call, so that we can do:
>
> 	struct tst_fd fd_in = {}, fd_out = {};
>
> 	while (tst_iterate_fd(&fd_in)) {
> 		while (tst_iterate_fd(&fd_out)) {
> 			...
> 			TST_TEST(splice(fd_in.fd, 0, fd_out.fd, 0, ...));
> 			...
> 		}
> 	}

This looks promising. I think it would be good to try this sooner rather
than later.
Cyril Hrubis Oct. 11, 2023, 8:52 a.m. UTC | #4
Hi!
> This looks promising. I think it would be good to try this sooner rather
> than later.

Already rewriting the code...