diff mbox series

[net-next,01/13] selftests: ncdevmem: Add a flag for the selftest

Message ID 20240912171251.937743-2-sdf@fomichev.me (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series selftests: ncdevmem: Add ncdevmem to ksft | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 7 this patch: 7
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 2 maintainers not CCed: shuah@kernel.org linux-kselftest@vger.kernel.org
netdev/build_clang success Errors and warnings before: 7 this patch: 7
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 7 this patch: 7
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 30 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest warning net-next-2024-09-13--00-00 (tests: 536)

Commit Message

Stanislav Fomichev Sept. 12, 2024, 5:12 p.m. UTC
And rename it to 'probing'. This is gonna be used in the selftests
to probe devmem functionality.

Cc: Mina Almasry <almasrymina@google.com>
Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
---
 tools/testing/selftests/net/ncdevmem.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Mina Almasry Sept. 12, 2024, 8:36 p.m. UTC | #1
On Thu, Sep 12, 2024 at 10:12 AM Stanislav Fomichev <sdf@fomichev.me> wrote:
>
> And rename it to 'probing'. This is gonna be used in the selftests
> to probe devmem functionality.
>
> Cc: Mina Almasry <almasrymina@google.com>
> Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
> ---
>  tools/testing/selftests/net/ncdevmem.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/net/ncdevmem.c b/tools/testing/selftests/net/ncdevmem.c
> index 64d6805381c5..352dba211fb0 100644
> --- a/tools/testing/selftests/net/ncdevmem.c
> +++ b/tools/testing/selftests/net/ncdevmem.c
> @@ -523,8 +523,9 @@ void run_devmem_tests(void)
>  int main(int argc, char *argv[])
>  {
>         int is_server = 0, opt;
> +       int probe = 0;
>
> -       while ((opt = getopt(argc, argv, "ls:c:p:v:q:t:f:")) != -1) {
> +       while ((opt = getopt(argc, argv, "ls:c:p:v:q:t:f:P")) != -1) {
>                 switch (opt) {
>                 case 'l':
>                         is_server = 1;
> @@ -550,6 +551,9 @@ int main(int argc, char *argv[])
>                 case 'f':
>                         ifname = optarg;
>                         break;
> +               case 'P':
> +                       probe = 1;
> +                       break;
>                 case '?':
>                         printf("unknown option: %c\n", optopt);
>                         break;
> @@ -561,7 +565,10 @@ int main(int argc, char *argv[])
>         for (; optind < argc; optind++)
>                 printf("extra arguments: %s\n", argv[optind]);
>
> -       run_devmem_tests();
> +       if (probe) {
> +               run_devmem_tests();
> +               return 0;
> +       }
>

Before this change:
./ncdevmem (runs run_devmem_tests() and exits)
./ncdevmem -l: runs devmem tests and listens

And I plan to add, for the tx path:

./ncdevmem -c: runs devmem tests and does a devmem client.

After this change, running ncdevmem with no flags just exits without
doing anything; a bit weird IMO, but I'm not opposed if you see an
upside.

Is your intention with this change to not run the devmem tests on
listen? Maybe something like:

if (is_server)
  return do_server();
else if (is_client) /* to be added */
  return do_client();
else
  run_devmem_tests();

return 0;

?

But, I'm not totally opposed if you see an upside. Maybe use -p
instead of -P for consistency.



--
Thanks,
Mina
Stanislav Fomichev Sept. 12, 2024, 9:59 p.m. UTC | #2
On 09/12, Mina Almasry wrote:
> On Thu, Sep 12, 2024 at 10:12 AM Stanislav Fomichev <sdf@fomichev.me> wrote:
> >
> > And rename it to 'probing'. This is gonna be used in the selftests
> > to probe devmem functionality.
> >
> > Cc: Mina Almasry <almasrymina@google.com>
> > Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
> > ---
> >  tools/testing/selftests/net/ncdevmem.c | 11 +++++++++--
> >  1 file changed, 9 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/testing/selftests/net/ncdevmem.c b/tools/testing/selftests/net/ncdevmem.c
> > index 64d6805381c5..352dba211fb0 100644
> > --- a/tools/testing/selftests/net/ncdevmem.c
> > +++ b/tools/testing/selftests/net/ncdevmem.c
> > @@ -523,8 +523,9 @@ void run_devmem_tests(void)
> >  int main(int argc, char *argv[])
> >  {
> >         int is_server = 0, opt;
> > +       int probe = 0;
> >
> > -       while ((opt = getopt(argc, argv, "ls:c:p:v:q:t:f:")) != -1) {
> > +       while ((opt = getopt(argc, argv, "ls:c:p:v:q:t:f:P")) != -1) {
> >                 switch (opt) {
> >                 case 'l':
> >                         is_server = 1;
> > @@ -550,6 +551,9 @@ int main(int argc, char *argv[])
> >                 case 'f':
> >                         ifname = optarg;
> >                         break;
> > +               case 'P':
> > +                       probe = 1;
> > +                       break;
> >                 case '?':
> >                         printf("unknown option: %c\n", optopt);
> >                         break;
> > @@ -561,7 +565,10 @@ int main(int argc, char *argv[])
> >         for (; optind < argc; optind++)
> >                 printf("extra arguments: %s\n", argv[optind]);
> >
> > -       run_devmem_tests();
> > +       if (probe) {
> > +               run_devmem_tests();
> > +               return 0;
> > +       }
> >
> 
> Before this change:
> ./ncdevmem (runs run_devmem_tests() and exits)
> ./ncdevmem -l: runs devmem tests and listens
> 
> And I plan to add, for the tx path:
> 
> ./ncdevmem -c: runs devmem tests and does a devmem client.
> 
> After this change, running ncdevmem with no flags just exits without
> doing anything; a bit weird IMO, but I'm not opposed if you see an
> upside.
> 
> Is your intention with this change to not run the devmem tests on
> listen? Maybe something like:
> 
> if (is_server)
>   return do_server();
> else if (is_client) /* to be added */
>   return do_client();
> else
>   run_devmem_tests();
> 
> return 0;
> 
> ?

SG! That's even better without the extra flag.
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/ncdevmem.c b/tools/testing/selftests/net/ncdevmem.c
index 64d6805381c5..352dba211fb0 100644
--- a/tools/testing/selftests/net/ncdevmem.c
+++ b/tools/testing/selftests/net/ncdevmem.c
@@ -523,8 +523,9 @@  void run_devmem_tests(void)
 int main(int argc, char *argv[])
 {
 	int is_server = 0, opt;
+	int probe = 0;
 
-	while ((opt = getopt(argc, argv, "ls:c:p:v:q:t:f:")) != -1) {
+	while ((opt = getopt(argc, argv, "ls:c:p:v:q:t:f:P")) != -1) {
 		switch (opt) {
 		case 'l':
 			is_server = 1;
@@ -550,6 +551,9 @@  int main(int argc, char *argv[])
 		case 'f':
 			ifname = optarg;
 			break;
+		case 'P':
+			probe = 1;
+			break;
 		case '?':
 			printf("unknown option: %c\n", optopt);
 			break;
@@ -561,7 +565,10 @@  int main(int argc, char *argv[])
 	for (; optind < argc; optind++)
 		printf("extra arguments: %s\n", argv[optind]);
 
-	run_devmem_tests();
+	if (probe) {
+		run_devmem_tests();
+		return 0;
+	}
 
 	if (is_server)
 		return do_server();