mbox series

[00/20] tests/9p: introduce declarative function calls

Message ID cover.1664917004.git.qemu_oss@crudebyte.com (mailing list archive)
Headers show
Series tests/9p: introduce declarative function calls | expand

Message

Christian Schoenebeck Oct. 4, 2022, 8:56 p.m. UTC
This series converts relevant 9p (test) client functions to use named
function arguments. For instance

    do_walk_expect_error(v9p, "non-existent", ENOENT);

becomes

    twalk({
        .client = v9p, .path = "non-existent", .expectErr = ENOENT
    });

The intention is to make the actual 9p test code more readable, and easier
to maintain on the long-term.

Not only makes it clear what a literal passed to a function is supposed to
do, it also makes the order and selection of arguments very liberal, and
allows to merge multiple, similar functions into one single function.

This is basically just refactoring, it does not change behaviour.

PREREQUISITES
=============

This series requires the following additional patch to work correctly:

https://lore.kernel.org/all/E1odrya-0004Fv-97@lizzy.crudebyte.com/
https://github.com/cschoenebeck/qemu/commit/23d01367fc7a4f27be323ed6d195c527bec9ede1

Christian Schoenebeck (20):
  tests/9p: merge *walk*() functions
  tests/9p: simplify callers of twalk()
  tests/9p: merge v9fs_tversion() and do_version()
  tests/9p: merge v9fs_tattach(), do_attach(), do_attach_rqid()
  tests/9p: simplify callers of tattach()
  tests/9p: convert v9fs_tgetattr() to declarative arguments
  tests/9p: simplify callers of tgetattr()
  tests/9p: convert v9fs_treaddir() to declarative arguments
  tests/9p: simplify callers of treaddir()
  tests/9p: convert v9fs_tlopen() to declarative arguments
  tests/9p: simplify callers of tlopen()
  tests/9p: convert v9fs_twrite() to declarative arguments
  tests/9p: simplify callers of twrite()
  tests/9p: convert v9fs_tflush() to declarative arguments
  tests/9p: merge v9fs_tmkdir() and do_mkdir()
  tests/9p: merge v9fs_tlcreate() and do_lcreate()
  tests/9p: merge v9fs_tsymlink() and do_symlink()
  tests/9p: merge v9fs_tlink() and do_hardlink()
  tests/9p: merge v9fs_tunlinkat() and do_unlinkat()
  tests/9p: remove unnecessary g_strdup() calls

 tests/qtest/libqos/virtio-9p-client.c | 569 +++++++++++++++++++++-----
 tests/qtest/libqos/virtio-9p-client.h | 408 ++++++++++++++++--
 tests/qtest/virtio-9p-test.c          | 529 ++++++++----------------
 3 files changed, 1031 insertions(+), 475 deletions(-)

Comments

Christian Schoenebeck Oct. 12, 2022, 10 a.m. UTC | #1
On Dienstag, 4. Oktober 2022 22:56:44 CEST Christian Schoenebeck wrote:
> This series converts relevant 9p (test) client functions to use named
> function arguments. For instance
> 
>     do_walk_expect_error(v9p, "non-existent", ENOENT);
> 
> becomes
> 
>     twalk({
>         .client = v9p, .path = "non-existent", .expectErr = ENOENT
>     });
> 
> The intention is to make the actual 9p test code more readable, and easier
> to maintain on the long-term.
> 
> Not only makes it clear what a literal passed to a function is supposed to
> do, it also makes the order and selection of arguments very liberal, and
> allows to merge multiple, similar functions into one single function.
> 
> This is basically just refactoring, it does not change behaviour.

Too massive for review?

If so, then I'll probably just go ahead and prepare a PR early next week with 
this queued as well. It's just test code refactoring, so I am quite painless 
about these changes.

Best regards,
Christian Schoenebeck

> 
> PREREQUISITES
> =============
> 
> This series requires the following additional patch to work correctly:
> 
> https://lore.kernel.org/all/E1odrya-0004Fv-97@lizzy.crudebyte.com/
> https://github.com/cschoenebeck/qemu/commit/23d01367fc7a4f27be323ed6d195c527
> bec9ede1
> 
> Christian Schoenebeck (20):
>   tests/9p: merge *walk*() functions
>   tests/9p: simplify callers of twalk()
>   tests/9p: merge v9fs_tversion() and do_version()
>   tests/9p: merge v9fs_tattach(), do_attach(), do_attach_rqid()
>   tests/9p: simplify callers of tattach()
>   tests/9p: convert v9fs_tgetattr() to declarative arguments
>   tests/9p: simplify callers of tgetattr()
>   tests/9p: convert v9fs_treaddir() to declarative arguments
>   tests/9p: simplify callers of treaddir()
>   tests/9p: convert v9fs_tlopen() to declarative arguments
>   tests/9p: simplify callers of tlopen()
>   tests/9p: convert v9fs_twrite() to declarative arguments
>   tests/9p: simplify callers of twrite()
>   tests/9p: convert v9fs_tflush() to declarative arguments
>   tests/9p: merge v9fs_tmkdir() and do_mkdir()
>   tests/9p: merge v9fs_tlcreate() and do_lcreate()
>   tests/9p: merge v9fs_tsymlink() and do_symlink()
>   tests/9p: merge v9fs_tlink() and do_hardlink()
>   tests/9p: merge v9fs_tunlinkat() and do_unlinkat()
>   tests/9p: remove unnecessary g_strdup() calls
> 
>  tests/qtest/libqos/virtio-9p-client.c | 569 +++++++++++++++++++++-----
>  tests/qtest/libqos/virtio-9p-client.h | 408 ++++++++++++++++--
>  tests/qtest/virtio-9p-test.c          | 529 ++++++++----------------
>  3 files changed, 1031 insertions(+), 475 deletions(-)
Greg Kurz Oct. 12, 2022, 1:58 p.m. UTC | #2
On Wed, 12 Oct 2022 12:00:40 +0200
Christian Schoenebeck <qemu_oss@crudebyte.com> wrote:

> On Dienstag, 4. Oktober 2022 22:56:44 CEST Christian Schoenebeck wrote:
> > This series converts relevant 9p (test) client functions to use named
> > function arguments. For instance
> > 
> >     do_walk_expect_error(v9p, "non-existent", ENOENT);
> > 
> > becomes
> > 
> >     twalk({
> >         .client = v9p, .path = "non-existent", .expectErr = ENOENT
> >     });
> > 
> > The intention is to make the actual 9p test code more readable, and easier
> > to maintain on the long-term.
> > 
> > Not only makes it clear what a literal passed to a function is supposed to
> > do, it also makes the order and selection of arguments very liberal, and
> > allows to merge multiple, similar functions into one single function.
> > 
> > This is basically just refactoring, it does not change behaviour.
> 
> Too massive for review?
> 

Yeah, sorry :-(

But since the approach you're taking here may be valuable elsewhere,
and this is qtest, it seems fair to ask Thomas and Laurent to have
a look :-)

> If so, then I'll probably just go ahead and prepare a PR early next week with 
> this queued as well. It's just test code refactoring, so I am quite painless 
> about these changes.
> 
> Best regards,
> Christian Schoenebeck
> 
> > 
> > PREREQUISITES
> > =============
> > 
> > This series requires the following additional patch to work correctly:
> > 
> > https://lore.kernel.org/all/E1odrya-0004Fv-97@lizzy.crudebyte.com/
> > https://github.com/cschoenebeck/qemu/commit/23d01367fc7a4f27be323ed6d195c527
> > bec9ede1
> > 
> > Christian Schoenebeck (20):
> >   tests/9p: merge *walk*() functions
> >   tests/9p: simplify callers of twalk()
> >   tests/9p: merge v9fs_tversion() and do_version()
> >   tests/9p: merge v9fs_tattach(), do_attach(), do_attach_rqid()
> >   tests/9p: simplify callers of tattach()
> >   tests/9p: convert v9fs_tgetattr() to declarative arguments
> >   tests/9p: simplify callers of tgetattr()
> >   tests/9p: convert v9fs_treaddir() to declarative arguments
> >   tests/9p: simplify callers of treaddir()
> >   tests/9p: convert v9fs_tlopen() to declarative arguments
> >   tests/9p: simplify callers of tlopen()
> >   tests/9p: convert v9fs_twrite() to declarative arguments
> >   tests/9p: simplify callers of twrite()
> >   tests/9p: convert v9fs_tflush() to declarative arguments
> >   tests/9p: merge v9fs_tmkdir() and do_mkdir()
> >   tests/9p: merge v9fs_tlcreate() and do_lcreate()
> >   tests/9p: merge v9fs_tsymlink() and do_symlink()
> >   tests/9p: merge v9fs_tlink() and do_hardlink()
> >   tests/9p: merge v9fs_tunlinkat() and do_unlinkat()
> >   tests/9p: remove unnecessary g_strdup() calls
> > 
> >  tests/qtest/libqos/virtio-9p-client.c | 569 +++++++++++++++++++++-----
> >  tests/qtest/libqos/virtio-9p-client.h | 408 ++++++++++++++++--
> >  tests/qtest/virtio-9p-test.c          | 529 ++++++++----------------
> >  3 files changed, 1031 insertions(+), 475 deletions(-)
> 
> 
>
Christian Schoenebeck Oct. 13, 2022, 1:34 p.m. UTC | #3
On Mittwoch, 12. Oktober 2022 15:58:06 CEST Greg Kurz wrote:
> On Wed, 12 Oct 2022 12:00:40 +0200
> Christian Schoenebeck <qemu_oss@crudebyte.com> wrote:
> 
> > On Dienstag, 4. Oktober 2022 22:56:44 CEST Christian Schoenebeck wrote:
> > > This series converts relevant 9p (test) client functions to use named
> > > function arguments. For instance
> > > 
> > >     do_walk_expect_error(v9p, "non-existent", ENOENT);
> > > 
> > > becomes
> > > 
> > >     twalk({
> > >         .client = v9p, .path = "non-existent", .expectErr = ENOENT
> > >     });
> > > 
> > > The intention is to make the actual 9p test code more readable, and 
easier
> > > to maintain on the long-term.
> > > 
> > > Not only makes it clear what a literal passed to a function is supposed 
to
> > > do, it also makes the order and selection of arguments very liberal, and
> > > allows to merge multiple, similar functions into one single function.
> > > 
> > > This is basically just refactoring, it does not change behaviour.
> > 
> > Too massive for review?
> > 
> 
> Yeah, sorry :-(
> 
> But since the approach you're taking here may be valuable elsewhere,
> and this is qtest, it seems fair to ask Thomas and Laurent to have
> a look :-)

Thomas, Laurent, if you had some spare cycles to look at this, that would be 
much appreciated!

Otherwise if not possible then I'll go ahead with PR next week as said.

Best regards,
Christian Schoenebeck
Christian Schoenebeck Oct. 18, 2022, 11:54 a.m. UTC | #4
On Tuesday, October 4, 2022 10:56:44 PM CEST Christian Schoenebeck wrote:
> This series converts relevant 9p (test) client functions to use named
> function arguments. For instance
> 
>     do_walk_expect_error(v9p, "non-existent", ENOENT);
> 
> becomes
> 
>     twalk({
>         .client = v9p, .path = "non-existent", .expectErr = ENOENT
>     });
> 
> The intention is to make the actual 9p test code more readable, and easier
> to maintain on the long-term.
> 
> Not only makes it clear what a literal passed to a function is supposed to
> do, it also makes the order and selection of arguments very liberal, and
> allows to merge multiple, similar functions into one single function.
> 
> This is basically just refactoring, it does not change behaviour.

Queued on 9p.next:
https://github.com/cschoenebeck/qemu/commits/9p.next

Thanks!

Next 9p PR end of this week.

Best regards,
Christian Schoenebeck