diff mbox series

[v2] math: Add GLIBC_TEST_LIBM_VERBOSE environment variable support.

Message ID 20240509022714.558030-1-josimmon@redhat.com
State New
Headers show
Series [v2] math: Add GLIBC_TEST_LIBM_VERBOSE environment variable support. | expand

Commit Message

Joe Simmons-Talbott May 9, 2024, 2:27 a.m. UTC
From: Joe Talbott <joetalbott@gmail.com>

Allow the libm-test-driver based tests to have their verbosity set based
on the GLIBC_TEST_LIBM_VERBOSE environment variable.  This allows the entire
testsuite to be run with a non-default verbosity.

While here check the conversion for the verbose option as well.
---
 math/libm-test-support.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

Comments

Carlos O'Donell May 14, 2024, 12:52 p.m. UTC | #1
On 5/8/24 10:27 PM, Joe Simmons-Talbott wrote:
> From: Joe Talbott <joetalbott@gmail.com>
> 
> Allow the libm-test-driver based tests to have their verbosity set based
> on the GLIBC_TEST_LIBM_VERBOSE environment variable.  This allows the entire
> testsuite to be run with a non-default verbosity.
> 
> While here check the conversion for the verbose option as well.

LGTM. Please push. You might have to change your other series to rebase on top of this.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  math/libm-test-support.c | 23 +++++++++++++++++++++--
>  1 file changed, 21 insertions(+), 2 deletions(-)
> 
> diff --git a/math/libm-test-support.c b/math/libm-test-support.c
> index 1d60ac783b..0cae545f86 100644
> --- a/math/libm-test-support.c
> +++ b/math/libm-test-support.c
> @@ -130,7 +130,7 @@ static int noTests;	/* number of tests (without testing exceptions) */
>  static int noExcTests;	/* number of tests for exception flags */
>  static int noErrnoTests;/* number of tests for errno values */
>  
> -static int verbose;
> +static unsigned int verbose;

OK. Defaults to zero.

>  static int output_max_error;	/* Should the maximal errors printed?  */
>  static int output_points;	/* Should the single function results printed?  */
>  static int ignore_max_ulp;	/* Should we ignore max_ulp?  */
> @@ -1057,7 +1057,14 @@ parse_opt (int key, char *arg, struct argp_state *state)
>        break;
>      case 'v':
>        if (optarg)
> -	verbose = (unsigned int) strtoul (optarg, NULL, 0);
> +	{
> +	  char *optstr_conv = optarg;
> +	  unsigned int opt_verbose;
> +
> +	  opt_verbose = (unsigned int) strtoul (optarg, &optstr_conv, 0);
> +          if (*optstr_conv == '\0' && optstr_conv != optarg)
> +            verbose = opt_verbose;

OK. Set it if conversion succeeded.

> +	}
>        else
>  	verbose = 3;
>        break;
> @@ -1139,6 +1146,7 @@ libm_test_init (int argc, char **argv)
>    int remaining;
>    char *ulps_file_path;
>    size_t dir_len = 0;
> +  char *envstr_verbose;
>  
>    verbose = 1;
>    output_ulps = 0;
> @@ -1148,6 +1156,17 @@ libm_test_init (int argc, char **argv)
>    /* XXX set to 0 for releases.  */
>    ignore_max_ulp = 0;
>  
> +  envstr_verbose = getenv("GLIBC_TEST_LIBM_VERBOSE");
> +  if (envstr_verbose != NULL)
> +    {
> +      char *envstr_conv = envstr_verbose;
> +      unsigned int env_verbose;
> +
> +      env_verbose = (unsigned int) strtoul (envstr_verbose, &envstr_conv, 0);
> +      if (*envstr_conv == '\0' && envstr_conv != envstr_verbose)
> +        verbose = env_verbose;

OK. Likewise set it if conversion succeeded.

> +    }
> +
>    /* Parse and process arguments.  */
>    argp_parse (&argp, argc, argv, 0, &remaining, NULL);
>
Joe Simmons-Talbott May 14, 2024, 3:33 p.m. UTC | #2
On Tue, May 14, 2024 at 8:52 AM Carlos O'Donell <carlos@redhat.com> wrote:
>
> On 5/8/24 10:27 PM, Joe Simmons-Talbott wrote:
> > From: Joe Talbott <joetalbott@gmail.com>
> >
> > Allow the libm-test-driver based tests to have their verbosity set based
> > on the GLIBC_TEST_LIBM_VERBOSE environment variable.  This allows the entire
> > testsuite to be run with a non-default verbosity.
> >
> > While here check the conversion for the verbose option as well.
>
> LGTM. Please push. You might have to change your other series to rebase on top of this.
>
> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
>

Thank you for the review.  Pushed.

Joe
> > ---
> >  math/libm-test-support.c | 23 +++++++++++++++++++++--
> >  1 file changed, 21 insertions(+), 2 deletions(-)
> >
> > diff --git a/math/libm-test-support.c b/math/libm-test-support.c
> > index 1d60ac783b..0cae545f86 100644
> > --- a/math/libm-test-support.c
> > +++ b/math/libm-test-support.c
> > @@ -130,7 +130,7 @@ static int noTests;       /* number of tests (without testing exceptions) */
> >  static int noExcTests;       /* number of tests for exception flags */
> >  static int noErrnoTests;/* number of tests for errno values */
> >
> > -static int verbose;
> > +static unsigned int verbose;
>
> OK. Defaults to zero.
>
> >  static int output_max_error; /* Should the maximal errors printed?  */
> >  static int output_points;    /* Should the single function results printed?  */
> >  static int ignore_max_ulp;   /* Should we ignore max_ulp?  */
> > @@ -1057,7 +1057,14 @@ parse_opt (int key, char *arg, struct argp_state *state)
> >        break;
> >      case 'v':
> >        if (optarg)
> > -     verbose = (unsigned int) strtoul (optarg, NULL, 0);
> > +     {
> > +       char *optstr_conv = optarg;
> > +       unsigned int opt_verbose;
> > +
> > +       opt_verbose = (unsigned int) strtoul (optarg, &optstr_conv, 0);
> > +          if (*optstr_conv == '\0' && optstr_conv != optarg)
> > +            verbose = opt_verbose;
>
> OK. Set it if conversion succeeded.
>
> > +     }
> >        else
> >       verbose = 3;
> >        break;
> > @@ -1139,6 +1146,7 @@ libm_test_init (int argc, char **argv)
> >    int remaining;
> >    char *ulps_file_path;
> >    size_t dir_len = 0;
> > +  char *envstr_verbose;
> >
> >    verbose = 1;
> >    output_ulps = 0;
> > @@ -1148,6 +1156,17 @@ libm_test_init (int argc, char **argv)
> >    /* XXX set to 0 for releases.  */
> >    ignore_max_ulp = 0;
> >
> > +  envstr_verbose = getenv("GLIBC_TEST_LIBM_VERBOSE");
> > +  if (envstr_verbose != NULL)
> > +    {
> > +      char *envstr_conv = envstr_verbose;
> > +      unsigned int env_verbose;
> > +
> > +      env_verbose = (unsigned int) strtoul (envstr_verbose, &envstr_conv, 0);
> > +      if (*envstr_conv == '\0' && envstr_conv != envstr_verbose)
> > +        verbose = env_verbose;
>
> OK. Likewise set it if conversion succeeded.
>
> > +    }
> > +
> >    /* Parse and process arguments.  */
> >    argp_parse (&argp, argc, argv, 0, &remaining, NULL);
> >
>
> --
> Cheers,
> Carlos.
>
diff mbox series

Patch

diff --git a/math/libm-test-support.c b/math/libm-test-support.c
index 1d60ac783b..0cae545f86 100644
--- a/math/libm-test-support.c
+++ b/math/libm-test-support.c
@@ -130,7 +130,7 @@  static int noTests;	/* number of tests (without testing exceptions) */
 static int noExcTests;	/* number of tests for exception flags */
 static int noErrnoTests;/* number of tests for errno values */
 
-static int verbose;
+static unsigned int verbose;
 static int output_max_error;	/* Should the maximal errors printed?  */
 static int output_points;	/* Should the single function results printed?  */
 static int ignore_max_ulp;	/* Should we ignore max_ulp?  */
@@ -1057,7 +1057,14 @@  parse_opt (int key, char *arg, struct argp_state *state)
       break;
     case 'v':
       if (optarg)
-	verbose = (unsigned int) strtoul (optarg, NULL, 0);
+	{
+	  char *optstr_conv = optarg;
+	  unsigned int opt_verbose;
+
+	  opt_verbose = (unsigned int) strtoul (optarg, &optstr_conv, 0);
+          if (*optstr_conv == '\0' && optstr_conv != optarg)
+            verbose = opt_verbose;
+	}
       else
 	verbose = 3;
       break;
@@ -1139,6 +1146,7 @@  libm_test_init (int argc, char **argv)
   int remaining;
   char *ulps_file_path;
   size_t dir_len = 0;
+  char *envstr_verbose;
 
   verbose = 1;
   output_ulps = 0;
@@ -1148,6 +1156,17 @@  libm_test_init (int argc, char **argv)
   /* XXX set to 0 for releases.  */
   ignore_max_ulp = 0;
 
+  envstr_verbose = getenv("GLIBC_TEST_LIBM_VERBOSE");
+  if (envstr_verbose != NULL)
+    {
+      char *envstr_conv = envstr_verbose;
+      unsigned int env_verbose;
+
+      env_verbose = (unsigned int) strtoul (envstr_verbose, &envstr_conv, 0);
+      if (*envstr_conv == '\0' && envstr_conv != envstr_verbose)
+        verbose = env_verbose;
+    }
+
   /* Parse and process arguments.  */
   argp_parse (&argp, argc, argv, 0, &remaining, NULL);