[LTP] [PATCH 1/2] tst_test.sh: Fix calling not yet loaded cleanup function

Petr Vorel pvorel@suse.cz
Tue May 19 08:37:40 CEST 2020


Hi Jörg,

> >   	TST_DO_EXIT=1
> > -	if [ -n "$TST_CLEANUP" -a -z "$TST_NO_CLEANUP" ]; then
> > +	if [ -n "$TST_SETUP_STARTED" -a -n "$TST_RUN_STARTED" -a \
> > +		-n "$TST_CLEANUP" -a -z "$TST_NO_CLEANUP" ]; then
> In the description you write "[after] running either setup or test
> function". But this implementation
> is "after running setup and test function". Cleanup should also be executed,
> if only setup was run right?
Thanks! Yes, I meant -o (or), but typed -a (and).

> > @@ -592,9 +594,11 @@ tst_run()
> >   			_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_STARTED=1
> >   				_tst_run_tests "$_tst_data"
> >   			done
> >   		else
> > +			TST_RUN_STARTED=1
> >   			_tst_run_tests
> >   		fi
> Is it really important, that test is started? Shouldn't it be enough if we
> got to the point, where the test
> could be started. Moving TST_RUN_STARTED out of the condition would reduce
> repetition.

Well, if you look into the code, there is tst_require_cmds call in if clause,
which should pass:

	#TODO check that test reports some results for each test function call
	while [ $TST_ITERATIONS -gt 0 ]; do
		if [ -n "$TST_TEST_DATA" ]; then
			tst_require_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_STARTED=1
				_tst_run_tests "$_tst_data"
			done
		else
			TST_RUN_STARTED=1
			_tst_run_tests
		fi
		TST_ITERATIONS=$((TST_ITERATIONS-1))
	done

Kind regards,
Petr


More information about the ltp mailing list