diff mbox series

[v2,2/4] lib/C-API: Add option -V to print LTP version

Message ID 20230719110051.1237775-3-pvorel@suse.cz
State Accepted
Headers show
Series Makefile: Add C header with generated LTP version | expand

Commit Message

Petr Vorel July 19, 2023, 11 a.m. UTC
It can be useful for troubleshooting reported issues.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 lib/tst_test.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Cyril Hrubis July 25, 2023, 12:01 p.m. UTC | #1
Hi!
> It can be useful for troubleshooting reported issues.

I still wonder if this should be rather put into the output of the -h or
both.

> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>  lib/tst_test.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index 04da456c6..456d3d1e6 100644
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -34,6 +34,7 @@
>  #include "old_resource.h"
>  #include "old_device.h"
>  #include "old_tmpdir.h"
> +#include "ltp-version.h"
>  
>  /*
>   * Hack to get TCID defined in newlib tests
> @@ -509,6 +510,7 @@ static struct option {
>  	{"h",  "-h       Prints this help"},
>  	{"i:", "-i n     Execute test n times"},
>  	{"I:", "-I x     Execute test for n seconds"},
> +	{"V",  "-V       Prints LTP version"},
>  	{"C:", "-C ARG   Run child process with ARG arguments (used internally)"},
>  };
>  
> @@ -686,6 +688,10 @@ static void parse_opts(int argc, char *argv[])
>  			else
>  				duration = SAFE_STRTOF(optarg, 0.1, HUGE_VALF);
>  		break;
> +		case 'V':
> +			fprintf(stderr, "LTP version: " LTP_VERSION "\n");
> +			exit(0);
> +		break;
>  		case 'C':
>  #ifdef UCLINUX
>  			child_args = optarg;
> -- 
> 2.40.1
>
Petr Vorel July 25, 2023, 12:23 p.m. UTC | #2
Hi Cyril,

> Hi!
> > It can be useful for troubleshooting reported issues.

> I still wonder if this should be rather put into the output of the -h or
> both.

I used -V, because this is common, but I have no problem to add it to -h
or even move to -h (i.e. not introduce -V).

Any more opinions, please?

Kind regards,
Petr

> > Signed-off-by: Petr Vorel <pvorel@suse.cz>
> > ---
> >  lib/tst_test.c | 6 ++++++
> >  1 file changed, 6 insertions(+)

> > diff --git a/lib/tst_test.c b/lib/tst_test.c
> > index 04da456c6..456d3d1e6 100644
> > --- a/lib/tst_test.c
> > +++ b/lib/tst_test.c
> > @@ -34,6 +34,7 @@
> >  #include "old_resource.h"
> >  #include "old_device.h"
> >  #include "old_tmpdir.h"
> > +#include "ltp-version.h"

> >  /*
> >   * Hack to get TCID defined in newlib tests
> > @@ -509,6 +510,7 @@ static struct option {
> >  	{"h",  "-h       Prints this help"},
> >  	{"i:", "-i n     Execute test n times"},
> >  	{"I:", "-I x     Execute test for n seconds"},
> > +	{"V",  "-V       Prints LTP version"},
> >  	{"C:", "-C ARG   Run child process with ARG arguments (used internally)"},
> >  };

> > @@ -686,6 +688,10 @@ static void parse_opts(int argc, char *argv[])
> >  			else
> >  				duration = SAFE_STRTOF(optarg, 0.1, HUGE_VALF);
> >  		break;
> > +		case 'V':
> > +			fprintf(stderr, "LTP version: " LTP_VERSION "\n");
> > +			exit(0);
> > +		break;
> >  		case 'C':
> >  #ifdef UCLINUX
> >  			child_args = optarg;
> > -- 
> > 2.40.1
diff mbox series

Patch

diff --git a/lib/tst_test.c b/lib/tst_test.c
index 04da456c6..456d3d1e6 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -34,6 +34,7 @@ 
 #include "old_resource.h"
 #include "old_device.h"
 #include "old_tmpdir.h"
+#include "ltp-version.h"
 
 /*
  * Hack to get TCID defined in newlib tests
@@ -509,6 +510,7 @@  static struct option {
 	{"h",  "-h       Prints this help"},
 	{"i:", "-i n     Execute test n times"},
 	{"I:", "-I x     Execute test for n seconds"},
+	{"V",  "-V       Prints LTP version"},
 	{"C:", "-C ARG   Run child process with ARG arguments (used internally)"},
 };
 
@@ -686,6 +688,10 @@  static void parse_opts(int argc, char *argv[])
 			else
 				duration = SAFE_STRTOF(optarg, 0.1, HUGE_VALF);
 		break;
+		case 'V':
+			fprintf(stderr, "LTP version: " LTP_VERSION "\n");
+			exit(0);
+		break;
 		case 'C':
 #ifdef UCLINUX
 			child_args = optarg;