[RFC,8/9] testcases: test.sh: Check if "getconf" is available
diff mbox series

Message ID 20180423094639.14612-9-mylene.josserand@bootlin.com
State Changes Requested
Delegated to: Cyril Hrubis
Headers show
Series
  • testcases: small improvements with TCONF
Related show

Commit Message

Mylène Josserand April 23, 2018, 9:46 a.m. UTC
In case TST_NEEDS_CHECKPOINTS is set to 1, the "getconf"
binary is used. This binary may not be installed in the system
and it will return a FAIL. Instead, add a check on this binary
to return "TCONF" in that case.

Signed-off-by: Mylène Josserand <mylene.josserand@bootlin.com>
---
 testcases/lib/test.sh | 2 ++
 1 file changed, 2 insertions(+)

Comments

Cyril Hrubis April 23, 2018, 10:17 a.m. UTC | #1
Hi!
> In case TST_NEEDS_CHECKPOINTS is set to 1, the "getconf"
> binary is used. This binary may not be installed in the system
> and it will return a FAIL. Instead, add a check on this binary
> to return "TCONF" in that case.
> 
> Signed-off-by: Myl??ne Josserand <mylene.josserand@bootlin.com>
> ---
>  testcases/lib/test.sh | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/testcases/lib/test.sh b/testcases/lib/test.sh
> index bce9893a9..b27dbf4ab 100644
> --- a/testcases/lib/test.sh
> +++ b/testcases/lib/test.sh
> @@ -421,6 +421,8 @@ fi
>  if [ "$TST_NEEDS_CHECKPOINTS" = "1" ]; then
>  	LTP_IPC_PATH="/dev/shm/ltp_${TCID}_$$"
>  
> +	tst_check_cmds "getconf"
> +
>  	LTP_IPC_SIZE=$(getconf PAGESIZE)
>  	if [ $? -ne 0 ]; then
>  		tst_brkm TBROK "getconf PAGESIZE failed"

This would be better fixed by creating a binary helper in testcases/lib/
same as we did for example for sub-second sleep with tst_sleep.c. We can
create tst_pagesize.c that would just print the result of getpagesize().
Mylène Josserand April 27, 2018, 9:39 a.m. UTC | #2
Hello,

On Mon, 23 Apr 2018 12:17:53 +0200
Cyril Hrubis <chrubis@suse.cz> wrote:

> Hi!
> > In case TST_NEEDS_CHECKPOINTS is set to 1, the "getconf"
> > binary is used. This binary may not be installed in the system
> > and it will return a FAIL. Instead, add a check on this binary
> > to return "TCONF" in that case.
> > 
> > Signed-off-by: Myl??ne Josserand <mylene.josserand@bootlin.com>
> > ---
> >  testcases/lib/test.sh | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/testcases/lib/test.sh b/testcases/lib/test.sh
> > index bce9893a9..b27dbf4ab 100644
> > --- a/testcases/lib/test.sh
> > +++ b/testcases/lib/test.sh
> > @@ -421,6 +421,8 @@ fi
> >  if [ "$TST_NEEDS_CHECKPOINTS" = "1" ]; then
> >  	LTP_IPC_PATH="/dev/shm/ltp_${TCID}_$$"
> >  
> > +	tst_check_cmds "getconf"
> > +
> >  	LTP_IPC_SIZE=$(getconf PAGESIZE)
> >  	if [ $? -ne 0 ]; then
> >  		tst_brkm TBROK "getconf PAGESIZE failed"  
> 
> This would be better fixed by creating a binary helper in testcases/lib/
> same as we did for example for sub-second sleep with tst_sleep.c. We can
> create tst_pagesize.c that would just print the result of getpagesize().
> 

Okay, thank you for the hint. I will have a look.

Best regards,

Patch
diff mbox series

diff --git a/testcases/lib/test.sh b/testcases/lib/test.sh
index bce9893a9..b27dbf4ab 100644
--- a/testcases/lib/test.sh
+++ b/testcases/lib/test.sh
@@ -421,6 +421,8 @@  fi
 if [ "$TST_NEEDS_CHECKPOINTS" = "1" ]; then
 	LTP_IPC_PATH="/dev/shm/ltp_${TCID}_$$"
 
+	tst_check_cmds "getconf"
+
 	LTP_IPC_SIZE=$(getconf PAGESIZE)
 	if [ $? -ne 0 ]; then
 		tst_brkm TBROK "getconf PAGESIZE failed"