Skip to contentSkip to conversation

lib/tst_test: Do TBROK on unexpected arguments.

RFC PATCH New Cyril Hrubis 2 participants 3 messages Oct 2, 2017 – Oct 3, 2017 Library code

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 lib/tst_test: Do TBROK on unexpected arguments.

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

commit 8501feeb89e8a47e7feacd80179d852c3810249c

Author: Sandeep Patil <[email protected]>
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.

---
 lib/tst_test.c | 3 +++
 1 file changed, 3 insertions(+)
lib/tst_test.c +3 -0
index a627242a6..26414e31c 100644
@@ -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)
Signature · 1 line
2.13.5
#1 lore raw

RFC PATCH 1/1 lib/tst_test: Do TBROK on unexpected arguments.

Hi,

lib/tst_test.c static void parse_opts(int argc, char *argv[]) · line 496

Quoted 2 lines
lib/tst_test.c +2 -0
+	if (optind < argc)
+		tst_brk(TBROK, "Unexpected argument(s) '%s'...", argv[optind]);

LGTM.

Kind regards,
Petr