[v4,4/5] Add newlib shell test for tst_multiply_timeout()
diff mbox series

Message ID 20191018124502.25599-5-cfamullaconrad@suse.de
State Not Applicable
Delegated to: Petr Vorel
Headers show
Series
  • [v4,1/5] tst_test.sh: Use LTP_TIMEOUT_MUL in TST_RETRY_FN()
Related show

Commit Message

Clemens Famulla-Conrad Oct. 18, 2019, 12:45 p.m. UTC
Simple test for different kinds of calls from tst_multiply_timeout()
---
 lib/newlib_tests/shell/test_timeout_mul.sh | 43 ++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100755 lib/newlib_tests/shell/test_timeout_mul.sh

Comments

Li Wang Oct. 21, 2019, 9:28 a.m. UTC | #1
On Fri, Oct 18, 2019 at 8:45 PM Clemens Famulla-Conrad <
cfamullaconrad@suse.de> wrote:

> Simple test for different kinds of calls from tst_multiply_timeout()
>

Patch 4/5 and 5/5 needs "Signed-off-by: ..." tag, otherwise LGTM.
    Reviewed-by: Li Wang <liwang@redhat.com>

---
>  lib/newlib_tests/shell/test_timeout_mul.sh | 43
> ++++++++++++++++++++++++++++++
>  1 file changed, 43 insertions(+)
>  create mode 100755 lib/newlib_tests/shell/test_timeout_mul.sh
>
> diff --git a/lib/newlib_tests/shell/test_timeout_mul.sh
> b/lib/newlib_tests/shell/test_timeout_mul.sh
> new file mode 100755
> index 000000000..6682e5d66
> --- /dev/null
> +++ b/lib/newlib_tests/shell/test_timeout_mul.sh
> @@ -0,0 +1,43 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2019 Clemens Famulla-Conrad <cfamullaconrad@suse.de>
> +
> +TST_TESTFUNC=do_test
> +. tst_test.sh
> +
> +
> +call_it()
> +{
> +       local SAVE_MUL=${LTP_TIMEOUT_MUL}
> +       $1
> +       eval "exp_value=\$$2"
> +       if [ "$exp_value" -ne "$3" ]; then
> +               tst_brk TBROK "LTP_TIMEOUT_MUL=$SAVE_MUL $1 ($exp_value !=
> $3)"
> +       else
> +               tst_res TPASS "LTP_TIMEOUT_MUL=$SAVE_MUL $1 ($exp_value ==
> $3)"
> +       fi
> +}
> +
> +do_test()
> +{
> +       LTP_TIMEOUT_MUL=2
> +       local sec=1
> +
> +       call_it 'tst_multiply_timeout sec' 'sec' 2
> +
> +       sec=1
> +       LTP_TIMEOUT_MUL="1.5"
> +       call_it 'tst_multiply_timeout sec' 'sec' 2
> +
> +       sec=1
> +       LTP_TIMEOUT_MUL=0.5
> +       call_it 'tst_multiply_timeout sec' 'sec' 1
> +
> +       sec=1
> +       LTP_TIMEOUT_MUL=2
> +       call_it 'tst_multiply_timeout sec' 'sec' 2
> +       call_it 'tst_multiply_timeout sec' 'sec' 4
> +       call_it 'tst_multiply_timeout sec' 'sec' 8
> +}
> +
> +tst_run
> --
> 2.16.4
>
>
Petr Vorel Oct. 22, 2019, 8:08 a.m. UTC | #2
Hi,

> +do_test()
> +{
> +	LTP_TIMEOUT_MUL=2
> +	local sec=1
> +
> +	call_it 'tst_multiply_timeout sec' 'sec' 2
still some issue with this patchset. Making the function private
(_tst_multiply_timeout), we obviously get warning:
test_timeout_mul 1 TWARN: Private variable or function _tst_multiply_timeout used!

Unless we want to to add some special variable for library tests
(i.e. TST_IGNORE_WARN), the function cannot be used directly

I suggest to push the patchset change to use float (not to be postponed even
more), but without this patchset. Tests should be later added.

Kind regards,
Petr

> +	sec=1
> +	LTP_TIMEOUT_MUL="1.5"
> +	call_it 'tst_multiply_timeout sec' 'sec' 2
> +
> +	sec=1
> +	LTP_TIMEOUT_MUL=0.5
> +	call_it 'tst_multiply_timeout sec' 'sec' 1
> +
> +	sec=1
> +	LTP_TIMEOUT_MUL=2
> +	call_it 'tst_multiply_timeout sec' 'sec' 2
> +	call_it 'tst_multiply_timeout sec' 'sec' 4
> +	call_it 'tst_multiply_timeout sec' 'sec' 8
> +}
> +
> +tst_run
Clemens Famulla-Conrad Oct. 22, 2019, 12:31 p.m. UTC | #3
On Tue, 2019-10-22 at 10:08 +0200, Petr Vorel wrote:
> Hi,
> 
> > +do_test()
> > +{
> > +	LTP_TIMEOUT_MUL=2
> > +	local sec=1
> > +
> > +	call_it 'tst_multiply_timeout sec' 'sec' 2
> 
> still some issue with this patchset. Making the function private
> (_tst_multiply_timeout), we obviously get warning:
> test_timeout_mul 1 TWARN: Private variable or function
> _tst_multiply_timeout used!
> 
> Unless we want to to add some special variable for library tests
> (i.e. TST_IGNORE_WARN), the function cannot be used directly
> 
> I suggest to push the patchset change to use float (not to be
> postponed even
> more), but without this patchset. Tests should be later added.

+1

Patch
diff mbox series

diff --git a/lib/newlib_tests/shell/test_timeout_mul.sh b/lib/newlib_tests/shell/test_timeout_mul.sh
new file mode 100755
index 000000000..6682e5d66
--- /dev/null
+++ b/lib/newlib_tests/shell/test_timeout_mul.sh
@@ -0,0 +1,43 @@ 
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2019 Clemens Famulla-Conrad <cfamullaconrad@suse.de>
+
+TST_TESTFUNC=do_test
+. tst_test.sh
+
+
+call_it()
+{
+	local SAVE_MUL=${LTP_TIMEOUT_MUL}
+	$1
+	eval "exp_value=\$$2"
+	if [ "$exp_value" -ne "$3" ]; then
+		tst_brk TBROK "LTP_TIMEOUT_MUL=$SAVE_MUL $1 ($exp_value != $3)"
+	else
+		tst_res TPASS "LTP_TIMEOUT_MUL=$SAVE_MUL $1 ($exp_value == $3)"
+	fi
+}
+
+do_test()
+{
+	LTP_TIMEOUT_MUL=2
+	local sec=1
+
+	call_it 'tst_multiply_timeout sec' 'sec' 2
+
+	sec=1
+	LTP_TIMEOUT_MUL="1.5"
+	call_it 'tst_multiply_timeout sec' 'sec' 2
+
+	sec=1
+	LTP_TIMEOUT_MUL=0.5
+	call_it 'tst_multiply_timeout sec' 'sec' 1
+
+	sec=1
+	LTP_TIMEOUT_MUL=2
+	call_it 'tst_multiply_timeout sec' 'sec' 2
+	call_it 'tst_multiply_timeout sec' 'sec' 4
+	call_it 'tst_multiply_timeout sec' 'sec' 8
+}
+
+tst_run