public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [RFC] [PATCH] lib/tst_test: Do TBROK on unexpected arguments.
@ 2017-10-02  9:19 Cyril Hrubis
  2017-10-02 17:36 ` Petr Vorel
  0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2017-10-02  9:19 UTC (permalink / raw)
  To: ltp

The argument parsing code in the test library ignored positional arguments and
that lead to:

commit 8501feeb89e8a47e7feacd80179d852c3810249c
Author: Sandeep Patil <sspatil@google.com>
Date:   Fri Sep 22 15:59:41 2017 -0700

    mm: mmapstress04: Remove arguments passed to the test.

Which removed leftover arguments from the testcase much later after the test
was rewritten. The correct behavior for the library is to issue TBROK on
unexpected command line parameters.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 lib/tst_test.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/tst_test.c b/lib/tst_test.c
index a627242a6..26414e31c 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -491,6 +491,9 @@ static void parse_opts(int argc, char *argv[])
 			parse_topt(topts_len, opt, optarg);
 		}
 	}
+
+	if (optind < argc)
+		tst_brk(TBROK, "Unexpected argument(s) '%s'...", argv[optind]);
 }
 
 int tst_parse_int(const char *str, int *val, int min, int max)
-- 
2.13.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [LTP] [RFC] [PATCH] lib/tst_test: Do TBROK on unexpected arguments.
  2017-10-02  9:19 [LTP] [RFC] [PATCH] lib/tst_test: Do TBROK on unexpected arguments Cyril Hrubis
@ 2017-10-02 17:36 ` Petr Vorel
  2017-10-03 15:42   ` Cyril Hrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Petr Vorel @ 2017-10-02 17:36 UTC (permalink / raw)
  To: ltp

Hi,

> +	if (optind < argc)
> +		tst_brk(TBROK, "Unexpected argument(s) '%s'...", argv[optind]);
LGTM.

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [LTP] [RFC] [PATCH] lib/tst_test: Do TBROK on unexpected arguments.
  2017-10-02 17:36 ` Petr Vorel
@ 2017-10-03 15:42   ` Cyril Hrubis
  0 siblings, 0 replies; 3+ messages in thread
From: Cyril Hrubis @ 2017-10-03 15:42 UTC (permalink / raw)
  To: ltp

Hi!
Pushed.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-10-03 15:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-02  9:19 [LTP] [RFC] [PATCH] lib/tst_test: Do TBROK on unexpected arguments Cyril Hrubis
2017-10-02 17:36 ` Petr Vorel
2017-10-03 15:42   ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox