diff mbox series

[RFC,v5,2/5] tst_test.sh: Warn about using "private" variable or function

Message ID 20180525215725.7218-3-pvorel@suse.cz
State Superseded
Delegated to: Cyril Hrubis
Headers show
Series tst_test.sh: Add TST_TEST_DATA and TST_TEST_DATA_IFS + cleanup | expand

Commit Message

Petr Vorel May 25, 2018, 9:57 p.m. UTC
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/lib/tst_test.sh | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Alexey Kodanev May 30, 2018, 3:47 p.m. UTC | #1
On 26.05.2018 00:57, Petr Vorel wrote:
> 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!"

Hi Petr,


For example "do_virt_dev_tst_01()" function name in the test, it is
also a private function name?


> +		done
>  	fi
>  
>  	OPTIND=1
>
Petr Vorel May 31, 2018, 5:55 a.m. UTC | #2
Hi Alexey,

...
> > +		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!"

> Hi Petr,


> For example "do_virt_dev_tst_01()" function name in the test, it is
> also a private function name?
No, the goal was to separate library names (e.g. anything in tst_test.sh) from test
itself. I.e. we can use any name in test, just avoid using namespace _tst_ (or TST_ except
doing the setup itself.


Kind regards,
Petr
diff mbox series

Patch

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