Skip to contentSkip to conversation

testcases: small improvements with TCONF

RFC PATCH New Mylène Josserand 4 participants 30 messages Apr 23, 2018 – Jun 5, 2018

lore
Share & tools
lore
#0 lore raw

cover testcases: small improvements with TCONF

Hello everyone,

I am currently trying LTP on an embededed device and while running some tests, I noticed that some of them are returning "FAIL" but most of the time, it is because some binaries (or options) are not available on my root filesystem. Instead of returning "FAIL", I think they should return "TCONF". This is what this series does.

I haven't finished to run all the tests yet so I will send another bunch of patches with other improvements. As it is the first time I used this project and that I contributes to it, reviews or feedbacks on this first set of patches would be very appreciated.

Thank you in advance!

Best regards,
Mylène

Mylène Josserand (9):
testcases: su: Fix userdel use
testcases: ar: Add TST_NEEDS_CMDS on "ar"
testcases: file: Add TST_NEEDS_CMDS on readelf
testcases: tar: Add TST_NEEDS_CMDS on gzip and bzip
testcases: logrotate: Check if "file" command exists
testcases: wc: Add "unrecognized option" as TCONF
testcases: df: Add "--printf" option as needed commands
testcases: test.sh: Check if "getconf" is available
testcases: cpuset: Check if "getconf" is available

 testcases/commands/ar/ar01                                    | 3 +++
 testcases/commands/df/df01.sh                                 | 2 ++
 testcases/commands/file/file01.sh                             | 2 ++
 testcases/commands/logrotate/logrotate_tests.sh               | 3 ++-
 testcases/commands/su/su01                                    | 6 ++++--
 testcases/commands/tar/tar_tests.sh                           | 2 ++
 testcases/commands/wc/wc01.sh                                 | 2 +-
 testcases/kernel/controllers/cpuset/cpuset_regression_test.sh | 2 ++
 testcases/lib/test.sh                                         | 2 ++
 9 files changed, 20 insertions(+), 4 deletions(-)
Signature · 1 line
2.11.0
#1 lore raw

RFC PATCH 1/9 testcases: su: Fix userdel use

In case "getent" command is not available in the system, the userdel command will never be executed and for the second use, the test will fail with:
useradd: user 'su_usr1' already exists

Fix that by moving "userdel" command in a new line.

---
 testcases/commands/su/su01 | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
testcases/commands/su/su01 +4 -2
index 34386d937..1eedcb636 100755
@@ -86,7 +86,8 @@ rm -f $TEST_ENV_FILE > /dev/null 2>&1
 #Create 1st test user
     #erase user if he may exist , so we can have a clean en
         rm -rf /home/$TEST_USER1
-        getent passwd $TEST_USER1 > /dev/null 2>&1 && userdel $TEST_USER1
+        getent passwd $TEST_USER1 > /dev/null 2>&1
+	userdel $TEST_USER1
 	sleep 1
 
         useradd -m -g users $TEST_USER1
@@ -121,7 +122,8 @@ rm -f $TEST_ENV_FILE > /dev/null 2>&1
 #Create 2nd test user
 	#erase user if he may exist , so we can have a clean en
         rm -rf /home/$TEST_USER2
-        getent passwd $TEST_USER2 > /dev/null 2>&1 && userdel $TEST_USER2
+        getent passwd $TEST_USER2 > /dev/null 2>&1
+	userdel $TEST_USER2
 	sleep 1
 
         useradd -m -g users $TEST_USER2
Signature · 1 line
2.11.0
#2 lore raw

RFC PATCH 1/9 testcases: su: Fix userdel use

Hi!

Quoted 17 lines

In case "getent" command is not available in the system, the userdel command will never be executed and for the second use, the test will fail with:
useradd: user 'su_usr1' already exists

Fix that by moving "userdel" command in a new line.

---
 testcases/commands/su/su01 | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
testcases/commands/su/su01 +0 -0
index 34386d937..1eedcb636 100755

testcases/commands/su/su01 rm -f $TEST_ENV_FILE > /dev/null 2>&1 · line 90

Quoted 6 lines
testcases/commands/su/su01 +2 -1
@@ -86,7 +86,8 @@ rm -f $TEST_ENV_FILE > /dev/null 2>&1
 #Create 1st test user
     #erase user if he may exist , so we can have a clean en
         rm -rf /home/$TEST_USER1
-        getent passwd $TEST_USER1 > /dev/null 2>&1 && userdel $TEST_USER1
+        getent passwd $TEST_USER1 > /dev/null 2>&1
+	userdel $TEST_USER1

I'm pretty sure this was intended to be:

"delete user only if it exists already"

So the whole getent line is useless after this change.

Also I suppose we shouldn't delete users in the test setup anyways, but the whole tests is a mess and should be cleaned up...

Signature · 2 lines
Cyril Hrubis
[email protected]
#3 lore raw

RFC PATCH 1/9 testcases: su: Fix userdel use

Hello,

Quoted 14 lines · Cyril Hrubis

testcases/commands/su/su01 rm -f $TEST_ENV_FILE > /dev/null 2>&1 · line 90

Quoted 11 lines
testcases/commands/su/su01 +2 -1
index 34386d937..1eedcb636 100755
@@ -86,7 +86,8 @@ rm -f $TEST_ENV_FILE > /dev/null 2>&1
 #Create 1st test user
     #erase user if he may exist , so we can have a clean en
         rm -rf /home/$TEST_USER1
-        getent passwd $TEST_USER1 > /dev/null 2>&1 && userdel $TEST_USER1
+        getent passwd $TEST_USER1 > /dev/null 2>&1
+	userdel $TEST_USER1  

I'm pretty sure this was intended to be:

Quoted 3 lines

"delete user only if it exists already"

So the whole getent line is useless after this change.

Perhaps the getent line can be replaced with something like:

grep -q "^$TEST_USER1:" /etc/passwd && userdel $TEST_USER1

Best regards,

Thomas Petazzoni

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
#4 lore raw

RFC PATCH 2/9 testcases: ar: Add TST_NEEDS_CMDS on "ar"

In reply to Mylène Josserand

In case "ar" binary is not available, the test will fail. It should return a TCONF as we just do not have the binary.

This commit adds TST_NEEDS_CMDS macro on "ar". Thanks to that, it will return "TCONF" and not "FAIL" when "ar" is not available.

---
 testcases/commands/ar/ar01 | 3 +++
 1 file changed, 3 insertions(+)
testcases/commands/ar/ar01 +3 -0
index ddab2e0f0..edaa24657 100644
@@ -22,9 +22,12 @@
 #
 # This is a basic ar command test.
 #
+AR=${AR:=ar}
 TST_CNT=17
 TST_TESTFUNC=test
 TST_NEEDS_TMPDIR=1
+TST_NEEDS_CMDS="$AR"
+
 . tst_test.sh
 
 test1()
Signature · 1 line
2.11.0
#5 lore raw

RFC PATCH 2/9 testcases: ar: Add TST_NEEDS_CMDS on "ar"

Hi!
And the rest of the patches I haven't commented on looks good to me.

Signature · 2 lines
Cyril Hrubis
[email protected]
#6 lore raw

RFC PATCH 2/9 testcases: ar: Add TST_NEEDS_CMDS on "ar"

Hello,

Quoted 3 lines · On Mon, 23 Apr 2018 12:25:25 +0200 Cyril Hrubis <[email protected]> wrote:

Hi!
And the rest of the patches I haven't commented on looks good to me.

Okay, thank you for your reviews!

Best regards

Signature · 3 lines
Mylène Josserand, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com
#7 lore raw

RFC PATCH 2/9 testcases: ar: Add TST_NEEDS_CMDS on "ar"

In reply to Mylène Josserand

Hi Mylène,

Quoted 18 lines

In case "ar" binary is not available, the test will fail. It should return a TCONF as we just do not have the binary.

This commit adds TST_NEEDS_CMDS macro on "ar". Thanks to that, it will return "TCONF" and not "FAIL" when "ar" is not available.

---
 testcases/commands/ar/ar01 | 3 +++
 1 file changed, 3 insertions(+)
testcases/commands/ar/ar01 +0 -0
index ddab2e0f0..edaa24657 100644
@@ -22,9 +22,12 @@
 
 # This is a basic ar command test.

testcases/commands/ar/ar01 line 33

Quoted 10 lines
testcases/commands/ar/ar01 +3 -0
 
+AR=${AR:=ar}
 TST_CNT=17
 TST_TESTFUNC=test
 TST_NEEDS_TMPDIR=1
+TST_NEEDS_CMDS="$AR"
+
 . tst_test.sh
 
 test1()

Merged with minor change:
-AR=${AR:=ar}
+AR="${AR:=ar}"

Thanks for your contributions.

Kind regards,
Petr

#8 lore raw

RFC PATCH 3/9 testcases: file: Add TST_NEEDS_CMDS on readelf

In reply to Mylène Josserand

This test is using "readelf" binary that can be
unavailable on the system.
Instead of failing, it should return a TCONF.

This is what this commit is doing by adding "readelf" in TST_NEEDS_CMDS macro.

---
 testcases/commands/file/file01.sh | 2 ++
 1 file changed, 2 insertions(+)
testcases/commands/file/file01.sh +2 -0
index e04b32e86..b72760e9f 100755
@@ -28,6 +28,8 @@ TST_CNT=20
 TST_SETUP=setup
 TST_TESTFUNC=do_test
 TST_NEEDS_TMPDIR=1
+TST_NEEDS_CMDS="readelf"
+
 . tst_test.sh
 
 setup()
Signature · 1 line
2.11.0
#9 lore raw

RFC PATCH 3/9 testcases: file: Add TST_NEEDS_CMDS on readelf

Hi Mylène,

Quoted 17 lines

This test is using "readelf" binary that can be
unavailable on the system.
Instead of failing, it should return a TCONF.

This is what this commit is doing by adding "readelf" in TST_NEEDS_CMDS macro.

---
 testcases/commands/file/file01.sh | 2 ++
 1 file changed, 2 insertions(+)
testcases/commands/file/file01.sh +0 -0
index e04b32e86..b72760e9f 100755

testcases/commands/file/file01.sh TST_CNT=20 · line 35

Quoted 8 lines
testcases/commands/file/file01.sh +2 -0
@@ -28,6 +28,8 @@ TST_CNT=20
 TST_SETUP=setup
 TST_TESTFUNC=do_test
 TST_NEEDS_TMPDIR=1
+TST_NEEDS_CMDS="readelf"
+
 . tst_test.sh
 
 setup()

Pushed, thanks!

Kind regards,
Petr

#10 lore raw

RFC PATCH 4/9 testcases: tar: Add TST_NEEDS_CMDS on gzip and bzip

In reply to Mylène Josserand

Add TST_NEEDS_CMDS to return a TCONF in case "gzip" and "bzip2" binaries are not available on the system.

---
 testcases/commands/tar/tar_tests.sh | 2 ++
 1 file changed, 2 insertions(+)
testcases/commands/tar/tar_tests.sh +2 -0
index 7ac18a4e5..946e9c7b1 100755
@@ -27,6 +27,8 @@
 TST_CNT=6
 TST_TESTFUNC=do_test
 TST_NEEDS_TMPDIR=1
+TST_NEEDS_CMDS="gzip bzip2"
+
 . tst_test.sh
 
 TAR_FILES="file1 file2 file3"
Signature · 1 line
2.11.0
#11 lore raw

RFC PATCH 4/9 testcases: tar: Add TST_NEEDS_CMDS on gzip and bzip

Hi Mylène,

Quoted 13 lines

Add TST_NEEDS_CMDS to return a TCONF in case "gzip" and "bzip2" binaries are not available on the system.

---
 testcases/commands/tar/tar_tests.sh | 2 ++
 1 file changed, 2 insertions(+)
testcases/commands/tar/tar_tests.sh +0 -0
index 7ac18a4e5..946e9c7b1 100755

testcases/commands/tar/tar_tests.sh line 34

Quoted 8 lines
testcases/commands/tar/tar_tests.sh +2 -0
@@ -27,6 +27,8 @@
 TST_CNT=6
 TST_TESTFUNC=do_test
 TST_NEEDS_TMPDIR=1
+TST_NEEDS_CMDS="gzip bzip2"
+
 . tst_test.sh
 
 TAR_FILES="file1 file2 file3"

Pushed, thanks!

Kind regards,
Petr

#12 lore raw

RFC PATCH 5/9 testcases: logrotate: Check if "file" command exists

In reply to Mylène Josserand

Add "file" binary in the list of commands to check if they exist or not.

---
 testcases/commands/logrotate/logrotate_tests.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
testcases/commands/logrotate/logrotate_tests.sh +2 -1
index f5a22ddde..021972294 100755
@@ -97,10 +97,11 @@ init()
 		 return $RC
 	fi
 
-	# check if commands tst_*, logrotate, awk exists.
+	# check if commands tst_*, logrotate, awk and file exists.
 	chk_ifexists INIT tst_resm  || return $RC
 	chk_ifexists INIT logrotate || return $RC
 	chk_ifexists INIT awk       || return $RC
+	chk_ifexists INIT file      || return $RC
 
 	return $RC
 }
Signature · 1 line
2.11.0
#13 lore raw

RFC PATCH 5/9 testcases: logrotate: Check if "file" command exists

Hi Mylène,

Quoted 15 lines

Add "file" binary in the list of commands to check if they exist or not.

---
 testcases/commands/logrotate/logrotate_tests.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
testcases/commands/logrotate/logrotate_tests.sh +0 -0
index f5a22ddde..021972294 100755
@@ -97,10 +97,11 @@ init()
 		 return $RC
 	fi

testcases/commands/logrotate/logrotate_tests.sh init() · line 107

Quoted 10 lines
testcases/commands/logrotate/logrotate_tests.sh +2 -1
 
-	# check if commands tst_*, logrotate, awk exists.
+	# check if commands tst_*, logrotate, awk and file exists.
 	chk_ifexists INIT tst_resm  || return $RC
 	chk_ifexists INIT logrotate || return $RC
 	chk_ifexists INIT awk       || return $RC
+	chk_ifexists INIT file      || return $RC
 
 	return $RC
 }

Pushed, thanks.

Kind regards,
Petr

#14 lore raw

RFC PATCH 5/9 testcases: logrotate: Check if "file" command exists

In reply to Mylène Josserand

Hi Mylène,

Quoted 15 lines

Add "file" binary in the list of commands to check if they exist or not.

---
 testcases/commands/logrotate/logrotate_tests.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
testcases/commands/logrotate/logrotate_tests.sh +0 -0
index f5a22ddde..021972294 100755
@@ -97,10 +97,11 @@ init()
 		 return $RC
 	fi

testcases/commands/logrotate/logrotate_tests.sh init() · line 107

Quoted 10 lines
testcases/commands/logrotate/logrotate_tests.sh +2 -1
 
-	# check if commands tst_*, logrotate, awk exists.
+	# check if commands tst_*, logrotate, awk and file exists.
 	chk_ifexists INIT tst_resm  || return $RC
 	chk_ifexists INIT logrotate || return $RC
 	chk_ifexists INIT awk       || return $RC
+	chk_ifexists INIT file      || return $RC
 
 	return $RC
 }

Pushed, thanks.

Kind regards,
Petr

#15 lore raw

RFC PATCH 6/9 testcases: wc: Add "unrecognized option" as TCONF

In reply to Mylène Josserand

In case we are using Busybox, for example, some options may not available and leads to a test failure. This commit adds "unrecognized option" parsing to return the test as a TCONF and not FAIL anymore.

---
 testcases/commands/wc/wc01.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/commands/wc/wc01.sh +1 -1
index e72819c51..74d69e254 100755
@@ -40,7 +40,7 @@ wc_test()
 
 	eval $wc_cmd > temp 2>&1
 	if [ $? -ne 0 ]; then
-		grep -q -E "unknown option|invalid option" temp
+		grep -q -E "unknown option|invalid option|unrecognized option" temp
 		if [ $? -eq 0 ]; then
 			tst_res TCONF "$wc_cmd not supported."
 		else
Signature · 1 line
2.11.0
#16 lore raw

RFC PATCH 6/9 testcases: wc: Add "unrecognized option" as TCONF

Hi Mylène,

Quoted 15 lines

In case we are using Busybox, for example, some options may not available and leads to a test failure. This commit adds "unrecognized option" parsing to return the test as a TCONF and not FAIL anymore.

---
 testcases/commands/wc/wc01.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/commands/wc/wc01.sh +0 -0
index e72819c51..74d69e254 100755

testcases/commands/wc/wc01.sh wc_test() · line 43

Quoted 5 lines
testcases/commands/wc/wc01.sh +1 -1
@@ -40,7 +40,7 @@ wc_test()
 
 	eval $wc_cmd > temp 2>&1
 	if [ $? -ne 0 ]; then
-		grep -q -E "unknown option|invalid option" temp
+		grep -q -E "unknown option|invalid option|unrecognized option" temp

What exactly needs "unrecognized option".
I haven't found it in busybox sources neither in busybox git log.

testcases/commands/wc/wc01.sh wc_test() · line 46

Quoted 3 lines
testcases/commands/wc/wc01.sh +0 -0
 		if [ $? -eq 0 ]; then
 			tst_res TCONF "$wc_cmd not supported."
 		else

Kind regards,
Petr

#17 lore raw

RFC PATCH 6/9 testcases: wc: Add "unrecognized option" as TCONF

Hello Petr,

Quoted 17 lines · On Wed, 16 May 2018 12:00:55 +0200 Petr Vorel <[email protected]> wrote:

Hi Mylène,

Quoted 15 lines

In case we are using Busybox, for example, some options may not available and leads to a test failure. This commit adds "unrecognized option" parsing to return the test as a TCONF and not FAIL anymore.

---
 testcases/commands/wc/wc01.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)  
testcases/commands/wc/wc01.sh +0 -0
index e72819c51..74d69e254 100755
@@ -40,7 +40,7 @@ wc_test()  
Quoted 6 lines

testcases/commands/wc/wc01.sh wc_test() · line 43

Quoted 4 lines
testcases/commands/wc/wc01.sh +1 -1
 	eval $wc_cmd > temp 2>&1
 	if [ $? -ne 0 ]; then
-		grep -q -E "unknown option|invalid option" temp
+		grep -q -E "unknown option|invalid option|unrecognized option" temp  

What exactly needs "unrecognized option".
I haven't found it in busybox sources neither in busybox git log.

Just in case, this is what I get with my busybox (v1.24.1):

# wc --max-line-length
wc: unrecognized option '--max-line-length'
BusyBox v1.24.1 (2018-02-10 17:35:25 CET) multi-call binary.

Usage: wc [-clwL] [FILE]...

I looked very quickly and it seems to be glibc with "getopt" function that prints this error:
https://sourceware.org/git/?p=glibc.git;a=blob;f=posix/getopt.c#l309

Quoted 8 lines

testcases/commands/wc/wc01.sh wc_test() · line 46

Quoted 4 lines
testcases/commands/wc/wc01.sh +0 -0
 		if [ $? -eq 0 ]; then
 			tst_res TCONF "$wc_cmd not supported."
 		else  

Kind regards,
Petr

Best regards,

Signature · 3 lines
Mylène Josserand, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com
#18 lore raw

RFC PATCH 6/9 testcases: wc: Add "unrecognized option" as TCONF

Hi Mylène,

Quoted 8 lines
Quoted 1 line

I haven't found it in busybox sources neither in busybox git log.

Just in case, this is what I get with my busybox (v1.24.1):

# wc --max-line-length
wc: unrecognized option '--max-line-length'
BusyBox v1.24.1 (2018-02-10 17:35:25 CET) multi-call binary.
Quoted 5 lines

Usage: wc [-clwL] [FILE]...

I looked very quickly and it seems to be glibc with "getopt" function that prints this error:
https://sourceware.org/git/?p=glibc.git;a=blob;f=posix/getopt.c#l309

Thanks for debugging. Indeed, it really uses getopts() from libc, thus libc dependent - busybox with musl has it with comma:
wc: unrecognized option: max-line-length

But all libraries common libc libraries (glibc, musl, uclibc-ng) has string "unrecognized option" => make sense to add the patch.

Kind regards,
Petr

#19 lore raw

RFC PATCH 6/9 testcases: wc: Add "unrecognized option" as TCONF

Hi Petr,

Quoted 16 lines · On Mon, 4 Jun 2018 17:22:21 +0200 Petr Vorel <[email protected]> wrote:

Hi Mylène,

Quoted 8 lines
Quoted 1 line

I haven't found it in busybox sources neither in busybox git log.

Just in case, this is what I get with my busybox (v1.24.1):

# wc --max-line-length
wc: unrecognized option '--max-line-length'
BusyBox v1.24.1 (2018-02-10 17:35:25 CET) multi-call binary.  
Quoted 5 lines

Usage: wc [-clwL] [FILE]...

I looked very quickly and it seems to be glibc with "getopt" function that prints this error:
https://sourceware.org/git/?p=glibc.git;a=blob;f=posix/getopt.c#l309

Quoted 6 lines

Thanks for debugging. Indeed, it really uses getopts() from libc, thus libc dependent - busybox with musl has it with comma:
wc: unrecognized option: max-line-length

But all libraries common libc libraries (glibc, musl, uclibc-ng) has string "unrecognized option" => make sense to add the patch.

Oh yes, I did not check other C library, great to know that "unrecognized option" is common.

Thanks for the review and for the pushed!

Best regards,

Signature · 3 lines
Mylène Josserand, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com
#20 lore raw

RFC PATCH 6/9 testcases: wc: Add "unrecognized option" as TCONF

In reply to Mylène Josserand

Hi Mylène,

Quoted 4 lines

In case we are using Busybox, for example, some options may not available and leads to a test failure. This commit adds "unrecognized option" parsing to return the test as a TCONF and not FAIL anymore.

...

Quoted 1 line
 testcases/commands/wc/wc01.sh | 2 +-

...

testcases/commands/wc/wc01.sh wc_test() · line 43

Quoted 2 lines
testcases/commands/wc/wc01.sh +1 -1
-		grep -q -E "unknown option|invalid option" temp
+		grep -q -E "unknown option|invalid option|unrecognized option" temp

Pushed, thanks!

Kind regards,
Petr

#21 lore raw

RFC PATCH 7/9 testcases: df: Add "--printf" option as needed commands

In reply to Mylène Josserand

In case Busybox is used with minimal configuration, the option "--printf" is not available so the test is failing.

Add this option in the needed commands to return a TCONF if it is not available.

---
 testcases/commands/df/df01.sh | 2 ++
 1 file changed, 2 insertions(+)
testcases/commands/df/df01.sh +2 -0
index fbf1e2f2a..147620020 100755
@@ -26,6 +26,8 @@ TST_PARSE_ARGS=parse_args
 TST_NEEDS_ROOT=1
 TST_NEEDS_TMPDIR=1
 TST_NEEDS_DEVICE=1
+TST_NEEDS_CMDS="stat --printf=%f"
+
 . tst_test.sh
 
 usage()
Signature · 1 line
2.11.0
#22 lore raw

RFC PATCH 7/9 testcases: df: Add "--printf" option as needed commands

Hi!

testcases/commands/df/df01.sh TST_PARSE_ARGS=parse_args · line 29

Quoted 9 lines
testcases/commands/df/df01.sh +1 -0
index fbf1e2f2a..147620020 100755
@@ -26,6 +26,8 @@ TST_PARSE_ARGS=parse_args
 TST_NEEDS_ROOT=1
 TST_NEEDS_TMPDIR=1
 TST_NEEDS_DEVICE=1
+TST_NEEDS_CMDS="stat --printf=%f"

Does this work? Because when I do something as:

$ command -v stat --nonexistent-option
/usr/bin/stat
$ echo $?
0
Signature · 2 lines
Cyril Hrubis
[email protected]
#23 lore raw

RFC PATCH 7/9 testcases: df: Add "--printf" option as needed commands

Hi,

Quoted 12 lines

testcases/commands/df/df01.sh TST_PARSE_ARGS=parse_args · line 29

Quoted 9 lines
testcases/commands/df/df01.sh +1 -0
index fbf1e2f2a..147620020 100755
@@ -26,6 +26,8 @@ TST_PARSE_ARGS=parse_args
 TST_NEEDS_ROOT=1
 TST_NEEDS_TMPDIR=1
 TST_NEEDS_DEVICE=1
+TST_NEEDS_CMDS="stat --printf=%f"

Does this work? Because when I do something as:

Quoted 4 lines
$ command -v stat --nonexistent-option
/usr/bin/stat
$ echo $?
0

Checking whole output (not just binary file / script) presence in $PATH is what tst_verify_cmd in my patch [1] does.

[1] https://patchwork.ozlabs.org/patch/892779/

Kind regards,
Petr

#24 lore raw

RFC PATCH 7/9 testcases: df: Add "--printf" option as needed commands

Hi,

Quoted 19 lines · On Mon, 23 Apr 2018 15:27:27 +0200 Petr Vorel <[email protected]> wrote:

Hi,

Quoted 12 lines

testcases/commands/df/df01.sh TST_PARSE_ARGS=parse_args · line 29

Quoted 9 lines
testcases/commands/df/df01.sh +1 -0
index fbf1e2f2a..147620020 100755
@@ -26,6 +26,8 @@ TST_PARSE_ARGS=parse_args
 TST_NEEDS_ROOT=1
 TST_NEEDS_TMPDIR=1
 TST_NEEDS_DEVICE=1
+TST_NEEDS_CMDS="stat --printf=%f"  

Does this work? Because when I do something as:

Quoted 4 lines
$ command -v stat --nonexistent-option
/usr/bin/stat
$ echo $?
0  
Quoted 8 lines

Checking whole output (not just binary file / script) presence in $PATH is what tst_verify_cmd in my patch [1] does.

[1] https://patchwork.ozlabs.org/patch/892779/

Kind regards,
Petr

Indeed, I saw your patch just after I sent my series :)

I will test your "tst_verify_cmd" but it seems to fit my needs. I will keep you updated.

Best regards,

Signature · 3 lines
Mylène Josserand, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com
#25 lore raw

RFC PATCH 8/9 testcases: test.sh: Check if "getconf" is available

In reply to Mylène Josserand

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.

---
 testcases/lib/test.sh | 2 ++
 1 file changed, 2 insertions(+)
testcases/lib/test.sh +2 -0
index bce9893a9..b27dbf4ab 100644
@@ -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"
Signature · 1 line
2.11.0
#26 lore raw

RFC PATCH 8/9 testcases: test.sh: Check if "getconf" is available

Hi!

Quoted 15 lines

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.

---
 testcases/lib/test.sh | 2 ++
 1 file changed, 2 insertions(+)
testcases/lib/test.sh +0 -0
index bce9893a9..b27dbf4ab 100644

testcases/lib/test.sh fi · line 428

Quoted 8 lines
testcases/lib/test.sh +2 -0
@@ -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().

Signature · 2 lines
Cyril Hrubis
[email protected]
#27 lore raw

RFC PATCH 8/9 testcases: test.sh: Check if "getconf" is available

Hello,

Quoted 19 lines · On Mon, 23 Apr 2018 12:17:53 +0200 Cyril Hrubis <[email protected]> wrote:

Hi!

Quoted 18 lines

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.

---
 testcases/lib/test.sh | 2 ++
 1 file changed, 2 insertions(+)
testcases/lib/test.sh +0 -0
index bce9893a9..b27dbf4ab 100644
@@ -421,6 +421,8 @@ fi
 if [ "$TST_NEEDS_CHECKPOINTS" = "1" ]; then
 	LTP_IPC_PATH="/dev/shm/ltp_${TCID}_$$"
 
Quoted 10 lines

testcases/lib/test.sh fi · line 428

Quoted 5 lines
testcases/lib/test.sh +2 -0
+	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,

Signature · 3 lines
Mylène Josserand, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com
#28 lore raw

RFC PATCH 9/9 testcases: cpuset: Check if "getconf" is available

In reply to Mylène Josserand

The "getconf" binary is used by cpuset_regression_test.sh and may not be installed in the system. The test will fail but it is a misconfiguration so let's use "tst_check_cmds" to check if this binary is available and return a TCONF error if not.

---
 testcases/kernel/controllers/cpuset/cpuset_regression_test.sh | 2 ++
 1 file changed, 2 insertions(+)
testcases/kernel/controllers/cpuset/cpuset_regression_test.sh +2 -0
index 4a104a3ad..96a57955c 100755
@@ -34,6 +34,8 @@ setup()
 		tst_brkm TCONF "Test must be run with kernel 3.18.0 or newer"
 	fi
 
+	tst_check_cmds "getconf"
+
 	local cpu_num=$(getconf _NPROCESSORS_ONLN)
 	if [ $cpu_num -lt 2 ]; then
 		tst_brkm TCONF "We need 2 cpus at least to have test"
Signature · 1 line
2.11.0
#29 lore raw

RFC PATCH 9/9 testcases: cpuset: Check if "getconf" is available

Hi!

Quoted 16 lines

The "getconf" binary is used by cpuset_regression_test.sh and may not be installed in the system. The test will fail but it is a misconfiguration so let's use "tst_check_cmds" to check if this binary is available and return a TCONF error if not.

---
 testcases/kernel/controllers/cpuset/cpuset_regression_test.sh | 2 ++
 1 file changed, 2 insertions(+)
testcases/kernel/controllers/cpuset/cpuset_regression_test.sh +0 -0
index 4a104a3ad..96a57955c 100755

testcases/kernel/controllers/cpuset/cpuset_regression_test.sh setup() · line 41

Quoted 8 lines
testcases/kernel/controllers/cpuset/cpuset_regression_test.sh +2 -0
@@ -34,6 +34,8 @@ setup()
 		tst_brkm TCONF "Test must be run with kernel 3.18.0 or newer"
 	fi
 
+	tst_check_cmds "getconf"
+
 	local cpu_num=$(getconf _NPROCESSORS_ONLN)
 	if [ $cpu_num -lt 2 ]; then
 		tst_brkm TCONF "We need 2 cpus at least to have test"

Hmm, or we may put something as tst_getconf.c into the testcases/lib/ directory and implement subset of variables needed for the tests there.

Signature · 2 lines
Cyril Hrubis
[email protected]