Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [RFC PATCH v6 0/5] Add TST_TEST_DATA and TST_TEST_DATA_IFS + cleanup
@ 2018-06-01  7:28 Petr Vorel
  2018-06-01  7:28 ` [LTP] [RFC PATCH v6 1/5] tst_test.sh: Hide "private" variables with "_tst_" prefix Petr Vorel
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Petr Vorel @ 2018-06-01  7:28 UTC (permalink / raw)
  To: ltp

Hi,

Changes v5->v6:
Fixes bugs reported by Alexey:
* Removed wrong _tst_i increment in for loop
* Fix doc:
-When '$TST_TEST_DATA' is used with '$TST_CNT', here used with space as default
-'$TST_TEST_DATA_IFS' value Similar it would be using these variables with
-separate functions.
+'$TST_TEST_DATA' can be used with '$TST_CNT'. If '$TST_TEST_DATA_IFS' not specified,
+space as default value is used. Of course, it's possible to use separate functions.

Hopefully ready to merge.

Kind regards,
Petr


Petr Vorel (5):
  tst_test.sh: Hide "private" variables with "_tst_" prefix
  tst_test.sh: Warn about using "private" variable or function
  tst_test.sh: Filter out commented out lines from warnings
  tst_test.sh: s/resm/res/
  tst_test.sh: Add TST_TEST_DATA and TST_TEST_DATA_IFS

 doc/test-writing-guidelines.txt |  79 ++++++++++++++++++++++++++---
 testcases/lib/tst_test.sh       | 110 +++++++++++++++++++++++++---------------
 2 files changed, 141 insertions(+), 48 deletions(-)

-- 
2.16.3


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

* [LTP] [RFC PATCH v6 1/5] tst_test.sh: Hide "private" variables with "_tst_" prefix
  2018-06-01  7:28 [LTP] [RFC PATCH v6 0/5] Add TST_TEST_DATA and TST_TEST_DATA_IFS + cleanup Petr Vorel
@ 2018-06-01  7:28 ` Petr Vorel
  2018-06-01  7:28 ` [LTP] [RFC PATCH v6 2/5] tst_test.sh: Warn about using "private" variable or function Petr Vorel
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Petr Vorel @ 2018-06-01  7:28 UTC (permalink / raw)
  To: ltp

Variables in tst_run and out of functions are visible to the test.
Adding prefix "_tst_" manifest they're private.

NOTE: kept $res from tst_run() as it's going to be moved into separate
function in new commit.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/lib/tst_test.sh | 57 +++++++++++++++++++++++------------------------
 1 file changed, 28 insertions(+), 29 deletions(-)

diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 779383392..337d33ca4 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -32,7 +32,7 @@ export TST_TMPDIR_RHOST=0
 
 . tst_ansi_color.sh
 
-tst_do_exit()
+_tst_do_exit()
 {
 	local ret=0
 
@@ -79,7 +79,7 @@ tst_do_exit()
 	exit $ret
 }
 
-tst_inc_res()
+_tst_inc_res()
 {
 	case "$1" in
 	TPASS) TST_PASS=$((TST_PASS+1));;
@@ -100,7 +100,7 @@ tst_res()
 	tst_color_enabled
 	local color=$?
 
-	tst_inc_res "$res"
+	_tst_inc_res "$res"
 
 	printf "$TST_ID $TST_COUNT "
 	tst_print_colored $res "$res: "
@@ -113,7 +113,7 @@ tst_brk()
 	shift
 
 	tst_res "$res" "$@"
-	tst_do_exit
+	_tst_do_exit
 }
 
 ROD_SILENT()
@@ -230,14 +230,14 @@ tst_usage()
 	echo "-i n    Execute test n times"
 }
 
-tst_resstr()
+_tst_resstr()
 {
 	echo "$TST_PASS$TST_FAIL$TST_CONF"
 }
 
-tst_rescmp()
+_tst_rescmp()
 {
-	local res=$(tst_resstr)
+	local res=$(_tst_resstr)
 
 	if [ "$1" = "$res" ]; then
 		tst_brk TBROK "Test didn't report any results"
@@ -246,31 +246,30 @@ tst_rescmp()
 
 tst_run()
 {
-	local tst_i
+	local _tst_i
+	local _tst_name
 
 	if [ -n "$TST_TEST_PATH" ]; then
-		for tst_i in $(grep TST_ "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`].*//'); do
-			case "$tst_i" in
+		for _tst_i in $(grep TST_ "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`].*//'); do
+			case "$_tst_i" in
 			SETUP|CLEANUP|TESTFUNC|ID|CNT|MIN_KVER);;
 			OPTS|USAGE|PARSE_ARGS|POS_ARGS);;
 			NEEDS_ROOT|NEEDS_TMPDIR|NEEDS_DEVICE|DEVICE);;
 			NEEDS_CMDS|NEEDS_MODULE|MODPATH|DATAROOT);;
 			IPV6);;
-			*) tst_res TWARN "Reserved variable TST_$tst_i used!";;
+			*) tst_res TWARN "Reserved variable TST_$_tst_i used!";;
 			esac
 		done
 	fi
 
-	local name
-
 	OPTIND=1
 
-	while getopts "hi:$TST_OPTS" name $TST_ARGS; do
-		case $name in
+	while getopts "hi:$TST_OPTS" _tst_name $TST_ARGS; do
+		case $_tst_name in
 		'h') tst_usage; exit 0;;
 		'i') TST_ITERATIONS=$OPTARG;;
 		'?') tst_usage; exit 2;;
-		*) $TST_PARSE_ARGS "$name" "$OPTARG";;
+		*) $TST_PARSE_ARGS "$_tst_name" "$OPTARG";;
 		esac
 	done
 
@@ -350,35 +349,35 @@ tst_run()
 	while [ $TST_ITERATIONS -gt 0 ]; do
 		if [ -n "$TST_CNT" ]; then
 			if type ${TST_TESTFUNC}1 > /dev/null 2>&1; then
-				for tst_i in $(seq $TST_CNT); do
-					local res=$(tst_resstr)
-					$TST_TESTFUNC$tst_i
-					tst_rescmp "$res"
+				for _tst_i in $(seq $TST_CNT); do
+					local _tst_res=$(_tst_resstr)
+					$TST_TESTFUNC$_tst_i
+					_tst_rescmp "$_tst_res"
 					TST_COUNT=$((TST_COUNT+1))
 				done
 			else
-				for tst_i in $(seq $TST_CNT); do
-					local res=$(tst_resstr)
-					$TST_TESTFUNC $tst_i
-					tst_rescmp "$res"
+				for _tst_i in $(seq $TST_CNT); do
+					local _tst_res=$(_tst_resstr)
+					$TST_TESTFUNC $_tst_i
+					_tst_rescmp "$_tst_res"
 					TST_COUNT=$((TST_COUNT+1))
 				done
 			fi
 		else
-			local res=$(tst_resstr)
+			local _tst_res=$(_tst_resstr)
 			$TST_TESTFUNC
-			tst_rescmp "$res"
+			_tst_rescmp "$_tst_res"
 			TST_COUNT=$((TST_COUNT+1))
 		fi
 		TST_ITERATIONS=$((TST_ITERATIONS-1))
 	done
 
-	tst_do_exit
+	_tst_do_exit
 }
 
 if [ -z "$TST_ID" ]; then
-	filename=$(basename $0)
-	TST_ID=${filename%%.*}
+	_tst_filename=$(basename $0)
+	TST_ID=${_tst_filename%%.*}
 fi
 export TST_ID="$TST_ID"
 
-- 
2.16.3


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

* [LTP] [RFC PATCH v6 2/5] tst_test.sh: Warn about using "private" variable or function
  2018-06-01  7:28 [LTP] [RFC PATCH v6 0/5] Add TST_TEST_DATA and TST_TEST_DATA_IFS + cleanup Petr Vorel
  2018-06-01  7:28 ` [LTP] [RFC PATCH v6 1/5] tst_test.sh: Hide "private" variables with "_tst_" prefix Petr Vorel
@ 2018-06-01  7:28 ` Petr Vorel
  2018-06-01  7:28 ` [LTP] [RFC PATCH v6 3/5] tst_test.sh: Filter out commented out lines from warnings Petr Vorel
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Petr Vorel @ 2018-06-01  7:28 UTC (permalink / raw)
  To: ltp

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

diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 337d33ca4..de5d65039 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -260,6 +260,10 @@ tst_run()
 			*) tst_res TWARN "Reserved variable TST_$_tst_i used!";;
 			esac
 		done
+
+		for _tst_i in $(grep _tst_ "$TST_TEST_PATH" | sed 's/.*_tst_//; s/[="} \t\/:`].*//'); do
+			tst_res TWARN "Private variable or function _tst_$_tst_i used!"
+		done
 	fi
 
 	OPTIND=1
-- 
2.16.3


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

* [LTP] [RFC PATCH v6 3/5] tst_test.sh: Filter out commented out lines from warnings
  2018-06-01  7:28 [LTP] [RFC PATCH v6 0/5] Add TST_TEST_DATA and TST_TEST_DATA_IFS + cleanup Petr Vorel
  2018-06-01  7:28 ` [LTP] [RFC PATCH v6 1/5] tst_test.sh: Hide "private" variables with "_tst_" prefix Petr Vorel
  2018-06-01  7:28 ` [LTP] [RFC PATCH v6 2/5] tst_test.sh: Warn about using "private" variable or function Petr Vorel
@ 2018-06-01  7:28 ` Petr Vorel
  2018-06-04 21:06   ` Cyril Hrubis
  2018-06-01  7:28 ` [LTP] [RFC PATCH v6 4/5] tst_test.sh: s/resm/res/ Petr Vorel
  2018-06-01  7:28 ` [LTP] [RFC PATCH v6 5/5] tst_test.sh: Add TST_TEST_DATA and TST_TEST_DATA_IFS Petr Vorel
  4 siblings, 1 reply; 11+ messages in thread
From: Petr Vorel @ 2018-06-01  7:28 UTC (permalink / raw)
  To: ltp

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/lib/tst_test.sh | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index de5d65039..098ff7bd2 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -244,13 +244,21 @@ _tst_rescmp()
 	fi
 }
 
+_tst_get_used_var()
+{
+	local _tst_pattern="$1"
+
+	grep $_tst_pattern "$TST_TEST_PATH" | grep -v '^[[:space:]]*#' | \
+		sed "s/.*${_tst_pattern}//;"' s/[="} \t\/:`].*//'
+}
+
 tst_run()
 {
 	local _tst_i
 	local _tst_name
 
 	if [ -n "$TST_TEST_PATH" ]; then
-		for _tst_i in $(grep TST_ "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`].*//'); do
+		for _tst_i in $(_tst_get_used_var "TST_"); do
 			case "$_tst_i" in
 			SETUP|CLEANUP|TESTFUNC|ID|CNT|MIN_KVER);;
 			OPTS|USAGE|PARSE_ARGS|POS_ARGS);;
@@ -261,7 +269,7 @@ tst_run()
 			esac
 		done
 
-		for _tst_i in $(grep _tst_ "$TST_TEST_PATH" | sed 's/.*_tst_//; s/[="} \t\/:`].*//'); do
+		for _tst_i in $(_tst_get_used_var "_tst_"); do
 			tst_res TWARN "Private variable or function _tst_$_tst_i used!"
 		done
 	fi
-- 
2.16.3


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

* [LTP] [RFC PATCH v6 4/5] tst_test.sh: s/resm/res/
  2018-06-01  7:28 [LTP] [RFC PATCH v6 0/5] Add TST_TEST_DATA and TST_TEST_DATA_IFS + cleanup Petr Vorel
                   ` (2 preceding siblings ...)
  2018-06-01  7:28 ` [LTP] [RFC PATCH v6 3/5] tst_test.sh: Filter out commented out lines from warnings Petr Vorel
@ 2018-06-01  7:28 ` Petr Vorel
  2018-06-01  7:28 ` [LTP] [RFC PATCH v6 5/5] tst_test.sh: Add TST_TEST_DATA and TST_TEST_DATA_IFS Petr Vorel
  4 siblings, 0 replies; 11+ messages in thread
From: Petr Vorel @ 2018-06-01  7:28 UTC (permalink / raw)
  To: ltp

resm is for legacy API.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/lib/tst_test.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 098ff7bd2..621e3eec0 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -88,7 +88,7 @@ _tst_inc_res()
 	TWARN) TST_WARN=$((TST_WARN+1));;
 	TCONF) TST_CONF=$((TST_CONF+1));;
 	TINFO) ;;
-	*) tst_brk TBROK "Invalid resm type '$1'";;
+	*) tst_brk TBROK "Invalid res type '$1'";;
 	esac
 }
 
-- 
2.16.3


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

* [LTP] [RFC PATCH v6 5/5] tst_test.sh: Add TST_TEST_DATA and TST_TEST_DATA_IFS
  2018-06-01  7:28 [LTP] [RFC PATCH v6 0/5] Add TST_TEST_DATA and TST_TEST_DATA_IFS + cleanup Petr Vorel
                   ` (3 preceding siblings ...)
  2018-06-01  7:28 ` [LTP] [RFC PATCH v6 4/5] tst_test.sh: s/resm/res/ Petr Vorel
@ 2018-06-01  7:28 ` Petr Vorel
  2018-06-05 15:09   ` Cyril Hrubis
  4 siblings, 1 reply; 11+ messages in thread
From: Petr Vorel @ 2018-06-01  7:28 UTC (permalink / raw)
  To: ltp

This is specific only for shell.

Each run of tst_run gets passed sequence number of a test being run
as '$1' and corresponding part of data from TST_TEST_DATA as '$2'.

Also create internal functions _tst_run_tests() and _tst_run_test()
to reduce duplicity.

Introduced dependencies: cut tr wc.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 doc/test-writing-guidelines.txt | 79 +++++++++++++++++++++++++++++++++++++----
 testcases/lib/tst_test.sh       | 59 +++++++++++++++++++-----------
 2 files changed, 110 insertions(+), 28 deletions(-)

diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
index fb7dcb591..62b31aae0 100644
--- a/doc/test-writing-guidelines.txt
+++ b/doc/test-writing-guidelines.txt
@@ -1442,20 +1442,23 @@ TST_CNT=2
 
 test1()
 {
-	tst_res TPASS "Test 1 passed"
+	tst_res TPASS "Test $1 passed"
 }
 
 test2()
 {
-	tst_res TPASS "Test 2 passed"
+	tst_res TPASS "Test $1 passed"
 }
 
 tst_run
+# output:
+# foo 1 TPASS: Test 1 passed
+# foo 2 TPASS: Test 2 passed
 -------------------------------------------------------------------------------
 
 If '$TST_CNT' is set, the test library looks if there are functions named
 '$\{TST_TESTFUNC\}1', ..., '$\{TST_TESTFUNC\}$\{TST_CNT\}' and if these are
-found they are executed one by one.
+found they are executed one by one. The test number is passed to it in the '$1'.
 
 [source,sh]
 -------------------------------------------------------------------------------
@@ -1471,18 +1474,80 @@ TST_CNT=2
 do_test()
 {
 	case $1 in
-	1) tst_res TPASS "Test 1 passed";;
-	2) tst_res TPASS "Test 2 passed";;
+	1) tst_res TPASS "Test $1 passed";;
+	2) tst_res TPASS "Test $1 passed";;
 	esac
 }
 
 tst_run
+# output:
+# foo 1 TPASS: Test 1 passed
+# foo 2 TPASS: Test 2 passed
 -------------------------------------------------------------------------------
 
 Otherwise, if '$TST_CNT' is set but there is no '$\{TST_TESTFUNC\}1', etc.,
 the '$TST_TESTFUNC' is executed '$TST_CNT' times and the test number is passed
 to it in the '$1'.
 
+[source,sh]
+-------------------------------------------------------------------------------
+#!/bin/sh
+#
+# Example test with tests in a single function, using $TST_TEST_DATA and
+# $TST_TEST_DATA_IFS
+#
+
+TST_TESTFUNC=do_test
+TST_TEST_DATA="foo:bar:d dd"
+TST_TEST_DATA_IFS=":"
+. tst_test.sh
+
+do_test()
+{
+	tst_res TPASS "Test $1 passed with data '$2'"
+}
+
+tst_run
+# output:
+# foo 1 TPASS: Test 1 passed with data 'foo'
+# foo 2 TPASS: Test 1 passed with data 'bar'
+# foo 3 TPASS: Test 1 passed with data 'd dd'
+-------------------------------------------------------------------------------
+
+It's possible to pass data for function with '$TST_TEST_DATA'. Optional
+'$TST_TEST_DATA_IFS' is used for splitting, default value is space.
+
+[source,sh]
+-------------------------------------------------------------------------------
+#!/bin/sh
+#
+# Example test with tests in a single function, using $TST_TEST_DATA and $TST_CNT
+#
+
+TST_TESTFUNC=do_test
+TST_CNT=2
+TST_TEST_DATA="foo bar"
+. tst_test.sh
+
+do_test()
+{
+	case $1 in
+	1) tst_res TPASS "Test $1 passed with data '$2'";;
+	2) tst_res TPASS "Test $1 passed with data '$2'";;
+	esac
+}
+
+tst_run
+# output:
+# foo 1 TPASS: Test 1 passed with data 'foo'
+# foo 2 TPASS: Test 2 passed with data 'foo'
+# foo 3 TPASS: Test 1 passed with data 'bar'
+# foo 4 TPASS: Test 2 passed with data 'bar'
+-------------------------------------------------------------------------------
+
+'$TST_TEST_DATA' can be used with '$TST_CNT'. If '$TST_TEST_DATA_IFS' not specified,
+space as default value is used. Of course, it's possible to use separate functions.
+
 2.3.2 Library variables
 ^^^^^^^^^^^^^^^^^^^^^^^
 
@@ -1587,8 +1652,8 @@ these can be listed with passing help '-h' option to any test.
 The function that prints the usage is passed in '$TST_USAGE', the help for
 the options implemented in the library is appended when usage is printed.
 
-Lastly the fucntion '$PARSE_ARGS' is called with the option name in '$1' and,
-if option has argument, its value in '$2'.
+Lastly the fucntion '$PARSE_ARGS' is called with the option name in the '$1'
+and, if option has argument, its value in the '$2'.
 
 [source,sh]
 -------------------------------------------------------------------------------
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 621e3eec0..228da5644 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -255,6 +255,8 @@ _tst_get_used_var()
 tst_run()
 {
 	local _tst_i
+	local _tst_data
+	local _tst_max
 	local _tst_name
 
 	if [ -n "$TST_TEST_PATH" ]; then
@@ -264,7 +266,7 @@ tst_run()
 			OPTS|USAGE|PARSE_ARGS|POS_ARGS);;
 			NEEDS_ROOT|NEEDS_TMPDIR|NEEDS_DEVICE|DEVICE);;
 			NEEDS_CMDS|NEEDS_MODULE|MODPATH|DATAROOT);;
-			IPV6);;
+			IPV6|TEST_DATA|TEST_DATA_IFS);;
 			*) tst_res TWARN "Reserved variable TST_$_tst_i used!";;
 			esac
 		done
@@ -359,27 +361,15 @@ tst_run()
 
 	#TODO check that test reports some results for each test function call
 	while [ $TST_ITERATIONS -gt 0 ]; do
-		if [ -n "$TST_CNT" ]; then
-			if type ${TST_TESTFUNC}1 > /dev/null 2>&1; then
-				for _tst_i in $(seq $TST_CNT); do
-					local _tst_res=$(_tst_resstr)
-					$TST_TESTFUNC$_tst_i
-					_tst_rescmp "$_tst_res"
-					TST_COUNT=$((TST_COUNT+1))
-				done
-			else
-				for _tst_i in $(seq $TST_CNT); do
-					local _tst_res=$(_tst_resstr)
-					$TST_TESTFUNC $_tst_i
-					_tst_rescmp "$_tst_res"
-					TST_COUNT=$((TST_COUNT+1))
-				done
-			fi
+		if [ -n "$TST_TEST_DATA" ]; then
+			tst_check_cmds cut tr wc
+			_tst_max=$(( $(echo $TST_TEST_DATA | tr -cd "$TST_TEST_DATA_IFS" | wc -c) +1))
+			for _tst_i in $(seq $_tst_max); do
+				_tst_data="$(echo "$TST_TEST_DATA" | cut -d"$TST_TEST_DATA_IFS" -f$_tst_i)"
+				_tst_run_tests "$_tst_data"
+			done
 		else
-			local _tst_res=$(_tst_resstr)
-			$TST_TESTFUNC
-			_tst_rescmp "$_tst_res"
-			TST_COUNT=$((TST_COUNT+1))
+			_tst_run_tests
 		fi
 		TST_ITERATIONS=$((TST_ITERATIONS-1))
 	done
@@ -387,6 +377,31 @@ tst_run()
 	_tst_do_exit
 }
 
+_tst_run_tests()
+{
+	local _tst_data="$1"
+	local _tst_i
+
+	for _tst_i in $(seq ${TST_CNT:-1}); do
+		if type ${TST_TESTFUNC}1 > /dev/null 2>&1; then
+			_tst_run_test "$TST_TESTFUNC$_tst_i" $_tst_i "$_tst_data"
+		else
+			_tst_run_test "$TST_TESTFUNC" $_tst_i "$_tst_data"
+		fi
+	done
+}
+
+_tst_run_test()
+{
+	local _tst_res=$(_tst_resstr)
+	local _tst_fnc="$1"
+	shift
+
+	$_tst_fnc "$@"
+	_tst_rescmp "$_tst_res"
+	TST_COUNT=$((TST_COUNT+1))
+}
+
 if [ -z "$TST_ID" ]; then
 	_tst_filename=$(basename $0)
 	TST_ID=${_tst_filename%%.*}
@@ -411,6 +426,8 @@ if [ -z "$TST_NO_DEFAULT_RUN" ]; then
 		tst_brk TBROK "TST_TESTFUNC is not defined"
 	fi
 
+	TST_TEST_DATA_IFS="${TST_TEST_DATA_IFS:- }"
+
 	if [ -n "$TST_CNT" ]; then
 		if ! tst_is_int "$TST_CNT"; then
 			tst_brk TBROK "TST_CNT must be integer"
-- 
2.16.3


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

* [LTP] [RFC PATCH v6 3/5] tst_test.sh: Filter out commented out lines from warnings
  2018-06-01  7:28 ` [LTP] [RFC PATCH v6 3/5] tst_test.sh: Filter out commented out lines from warnings Petr Vorel
@ 2018-06-04 21:06   ` Cyril Hrubis
  2018-06-04 21:34     ` Petr Vorel
  0 siblings, 1 reply; 11+ messages in thread
From: Cyril Hrubis @ 2018-06-04 21:06 UTC (permalink / raw)
  To: ltp

Hi!
What is the usecase for this?

I know that comments does not count as a code but why would the test
need to comment with a reserved name in it?

> ---
>  testcases/lib/tst_test.sh | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
> index de5d65039..098ff7bd2 100644
> --- a/testcases/lib/tst_test.sh
> +++ b/testcases/lib/tst_test.sh
> @@ -244,13 +244,21 @@ _tst_rescmp()
>  	fi
>  }
>  
> +_tst_get_used_var()
> +{
> +	local _tst_pattern="$1"
> +
> +	grep $_tst_pattern "$TST_TEST_PATH" | grep -v '^[[:space:]]*#' | \
> +		sed "s/.*${_tst_pattern}//;"' s/[="} \t\/:`].*//'

As far as I can tell this does not work for:

foo # run function foo

> +}

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [RFC PATCH v6 3/5] tst_test.sh: Filter out commented out lines from warnings
  2018-06-04 21:06   ` Cyril Hrubis
@ 2018-06-04 21:34     ` Petr Vorel
  2018-06-05 14:38       ` Cyril Hrubis
  0 siblings, 1 reply; 11+ messages in thread
From: Petr Vorel @ 2018-06-04 21:34 UTC (permalink / raw)
  To: ltp

Hi Cyril,


> Hi!
> What is the usecase for this?

> I know that comments does not count as a code but why would the test
> need to comment with a reserved name in it?
OK, let's drop it.

> > ---
> >  testcases/lib/tst_test.sh | 12 ++++++++++--
> >  1 file changed, 10 insertions(+), 2 deletions(-)

> > diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
> > index de5d65039..098ff7bd2 100644
> > --- a/testcases/lib/tst_test.sh
> > +++ b/testcases/lib/tst_test.sh
> > @@ -244,13 +244,21 @@ _tst_rescmp()
> >  	fi
> >  }

> > +_tst_get_used_var()
> > +{
> > +	local _tst_pattern="$1"
> > +
> > +	grep $_tst_pattern "$TST_TEST_PATH" | grep -v '^[[:space:]]*#' | \
> > +		sed "s/.*${_tst_pattern}//;"' s/[="} \t\/:`].*//'

> As far as I can tell this does not work for:

> foo # run function foo
Not sure what you expected. The behavior is:

* no warning for:
  # _tst_foo run function _tst_foo

* warning for:
  _tst_foo # run function _tst_foo

I take it as your NACK anyway :).

Kind regards,
Petr

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

* [LTP] [RFC PATCH v6 3/5] tst_test.sh: Filter out commented out lines from warnings
  2018-06-04 21:34     ` Petr Vorel
@ 2018-06-05 14:38       ` Cyril Hrubis
  0 siblings, 0 replies; 11+ messages in thread
From: Cyril Hrubis @ 2018-06-05 14:38 UTC (permalink / raw)
  To: ltp

Hi!
> > foo # run function foo
> Not sure what you expected. The behavior is:
> 
> * no warning for:
>   # _tst_foo run function _tst_foo
> 
> * warning for:
>   _tst_foo # run function _tst_foo

We will also get warning for:

tst_foo # we are not allowed to call _tst_foo

I was trying to point out that the solution is incomplete...

But anyway I see no point in proceeding further with the implemtation.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [RFC PATCH v6 5/5] tst_test.sh: Add TST_TEST_DATA and TST_TEST_DATA_IFS
  2018-06-01  7:28 ` [LTP] [RFC PATCH v6 5/5] tst_test.sh: Add TST_TEST_DATA and TST_TEST_DATA_IFS Petr Vorel
@ 2018-06-05 15:09   ` Cyril Hrubis
  2018-06-05 18:43     ` Petr Vorel
  0 siblings, 1 reply; 11+ messages in thread
From: Cyril Hrubis @ 2018-06-05 15:09 UTC (permalink / raw)
  To: ltp

Hi!
Apart from the patch that we discussed the rest of the patchset looks
good to me, acked.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [RFC PATCH v6 5/5] tst_test.sh: Add TST_TEST_DATA and TST_TEST_DATA_IFS
  2018-06-05 15:09   ` Cyril Hrubis
@ 2018-06-05 18:43     ` Petr Vorel
  0 siblings, 0 replies; 11+ messages in thread
From: Petr Vorel @ 2018-06-05 18:43 UTC (permalink / raw)
  To: ltp

Hi Cyril, Alexey,

> Hi!
> Apart from the patch that we discussed the rest of the patchset looks
> good to me, acked.
I'll remove "3/5] tst_test.sh: Filter out commented out lines from
warnings" and split comment in 2/5 into new line as it's too long.

Thanks both for your review, I'll add your ack.


Kind regards,
Petr

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

end of thread, other threads:[~2018-06-05 18:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-01  7:28 [LTP] [RFC PATCH v6 0/5] Add TST_TEST_DATA and TST_TEST_DATA_IFS + cleanup Petr Vorel
2018-06-01  7:28 ` [LTP] [RFC PATCH v6 1/5] tst_test.sh: Hide "private" variables with "_tst_" prefix Petr Vorel
2018-06-01  7:28 ` [LTP] [RFC PATCH v6 2/5] tst_test.sh: Warn about using "private" variable or function Petr Vorel
2018-06-01  7:28 ` [LTP] [RFC PATCH v6 3/5] tst_test.sh: Filter out commented out lines from warnings Petr Vorel
2018-06-04 21:06   ` Cyril Hrubis
2018-06-04 21:34     ` Petr Vorel
2018-06-05 14:38       ` Cyril Hrubis
2018-06-01  7:28 ` [LTP] [RFC PATCH v6 4/5] tst_test.sh: s/resm/res/ Petr Vorel
2018-06-01  7:28 ` [LTP] [RFC PATCH v6 5/5] tst_test.sh: Add TST_TEST_DATA and TST_TEST_DATA_IFS Petr Vorel
2018-06-05 15:09   ` Cyril Hrubis
2018-06-05 18:43     ` Petr Vorel

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