* [LTP] [PATCH] run-posix-option-group-test.sh: Log and exit if one attempts to run tests without compiling
@ 2022-06-07 22:08 shatur.linux
0 siblings, 0 replies; 4+ messages in thread
From: shatur.linux @ 2022-06-07 22:08 UTC (permalink / raw)
To: ltp; +Cc: shatur.linux, sturlapati
From: Sharan Turlapati <sturlapati@vmware.com>
Currently, run-posix-option-group-test.sh erroneously
logs "***Tests Completed***" when no test has actually run if the script is invoked
to run without actually compiling the tests.
Check if the .run-test files actually exist before attempting to run them.
If not found, log a message indicating the problem and suggest to check if
the tests were compiled. Exit the script without attempting to run other
tests.
Signed-off-by: Sharan Turlapati <sturlapati@vmware.com>
---
.../bin/run-posix-option-group-test.sh | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/testcases/open_posix_testsuite/bin/run-posix-option-group-test.sh b/testcases/open_posix_testsuite/bin/run-posix-option-group-test.sh
index 0d4c9bd80..56773f0f0 100755
--- a/testcases/open_posix_testsuite/bin/run-posix-option-group-test.sh
+++ b/testcases/open_posix_testsuite/bin/run-posix-option-group-test.sh
@@ -22,9 +22,16 @@ EOF
run_option_group_tests()
{
- for test_script in $(find $1 -name '*.run-test' | sort); do
- (cd "$(dirname "$test_script")" && ./$(basename "$test_script"))
- done
+ list_of_tests=`find $1 -name '*.run-test' | sort`
+ if [[ -n $list_of_tests ]]
+ then
+ for test_script in $list_of_tests; do
+ (cd "$(dirname "$test_script")" && ./$(basename "$test_script"))
+ done
+ else
+ echo ".run-test files not found under $1. Were the tests compiled?"
+ exit 1
+ fi
}
case $1 in
--
2.19.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [LTP] [PATCH] run-posix-option-group-test.sh: Log and exit if one attempts to run tests without compiling
@ 2022-06-07 22:18 shatur.linux
2022-06-10 5:41 ` Petr Vorel
0 siblings, 1 reply; 4+ messages in thread
From: shatur.linux @ 2022-06-07 22:18 UTC (permalink / raw)
To: ltp; +Cc: shatur.linux, sturlapati
From: Sharan Turlapati <sturlapati@vmware.com>
Currently, run-posix-option-group-test.sh erroneously
logs "***Tests Completed***" when no test has actually run if the script is invoked
to run without actually compiling the tests.
Check if the .run-test files actually exist before attempting to run them.
If not found, log a message indicating the problem and suggest to check if
the tests were compiled. Exit the script without attempting to run other
tests.
Signed-off-by: Sharan Turlapati <sturlapati@vmware.com>
---
.../bin/run-posix-option-group-test.sh | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/testcases/open_posix_testsuite/bin/run-posix-option-group-test.sh b/testcases/open_posix_testsuite/bin/run-posix-option-group-test.sh
index 0d4c9bd80..56773f0f0 100755
--- a/testcases/open_posix_testsuite/bin/run-posix-option-group-test.sh
+++ b/testcases/open_posix_testsuite/bin/run-posix-option-group-test.sh
@@ -22,9 +22,16 @@ EOF
run_option_group_tests()
{
- for test_script in $(find $1 -name '*.run-test' | sort); do
- (cd "$(dirname "$test_script")" && ./$(basename "$test_script"))
- done
+ list_of_tests=`find $1 -name '*.run-test' | sort`
+ if [[ -n $list_of_tests ]]
+ then
+ for test_script in $list_of_tests; do
+ (cd "$(dirname "$test_script")" && ./$(basename "$test_script"))
+ done
+ else
+ echo ".run-test files not found under $1. Were the tests compiled?"
+ exit 1
+ fi
}
case $1 in
--
2.19.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCH] run-posix-option-group-test.sh: Log and exit if one attempts to run tests without compiling
2022-06-07 22:18 [LTP] [PATCH] run-posix-option-group-test.sh: Log and exit if one attempts to run tests without compiling shatur.linux
@ 2022-06-10 5:41 ` Petr Vorel
2022-06-13 13:46 ` Petr Vorel
0 siblings, 1 reply; 4+ messages in thread
From: Petr Vorel @ 2022-06-10 5:41 UTC (permalink / raw)
To: shatur.linux; +Cc: ltp, sturlapati
Hi Sharan,
> From: Sharan Turlapati <sturlapati@vmware.com>
> Currently, run-posix-option-group-test.sh erroneously
> logs "***Tests Completed***" when no test has actually run if the script is invoked
> to run without actually compiling the tests.
> Check if the .run-test files actually exist before attempting to run them.
> If not found, log a message indicating the problem and suggest to check if
> the tests were compiled. Exit the script without attempting to run other
> tests.
Can you please describe how this happen? open POSIX failed to compile?
...
> +++ b/testcases/open_posix_testsuite/bin/run-posix-option-group-test.sh
> @@ -22,9 +22,16 @@ EOF
> run_option_group_tests()
> {
> - for test_script in $(find $1 -name '*.run-test' | sort); do
> - (cd "$(dirname "$test_script")" && ./$(basename "$test_script"))
> - done
> + list_of_tests=`find $1 -name '*.run-test' | sort`
> + if [[ -n $list_of_tests ]]
[[ ]] are bashisms, we require support for POSIX shell (i.e. dash, busybox sh)
TL;DR: simply use:
if [ -n "$list_of_tests" ]; then
NOTE [ ] require using quotes (unlike [[ ]]).
You can check similar error yourself:
$ checkbashisms run-posix-option-group-test.sh
possible bashism in run-posix-option-group-test.sh line 26 (alternative test command ([[ foo ]] should be [ foo ])):
if [[ -n $list_of_tests ]]
All is described in:
https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines#22-shell-coding-style
> + then
> + for test_script in $list_of_tests; do
> + (cd "$(dirname "$test_script")" && ./$(basename "$test_script"))
> + done
> + else
> + echo ".run-test files not found under $1. Were the tests compiled?"
> + exit 1
> + fi
> }
I'd prefer slightly different version:
* check for error first, then for can be out of else (readability)
* add local
run_option_group_tests()
{
local list_of_tests
list_of_tests=`find $1 -name '*.run-test' | sort`
if [ -z "$list_of_tests" ]; then
echo ".run-test files not found under $1. Were the tests compiled?"
exit 1
fi
for test_script in $list_of_tests; do
(cd "$(dirname "$test_script")" && ./$(basename "$test_script"))
done
}
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCH] run-posix-option-group-test.sh: Log and exit if one attempts to run tests without compiling
2022-06-10 5:41 ` Petr Vorel
@ 2022-06-13 13:46 ` Petr Vorel
0 siblings, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2022-06-13 13:46 UTC (permalink / raw)
To: shatur.linux, ltp, sturlapati
Hi Sharan,
> > Currently, run-posix-option-group-test.sh erroneously
> > logs "***Tests Completed***" when no test has actually run if the script is invoked
> > to run without actually compiling the tests.
> > Check if the .run-test files actually exist before attempting to run them.
> > If not found, log a message indicating the problem and suggest to check if
> > the tests were compiled. Exit the script without attempting to run other
> > tests.
> Can you please describe how this happen? open POSIX failed to compile?
OK, you noted this in the commit message.
Merged with fixed bashism, improved style and commit message.
Thanks!
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-06-13 13:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-07 22:18 [LTP] [PATCH] run-posix-option-group-test.sh: Log and exit if one attempts to run tests without compiling shatur.linux
2022-06-10 5:41 ` Petr Vorel
2022-06-13 13:46 ` Petr Vorel
-- strict thread matches above, loose matches on Subject: below --
2022-06-07 22:08 shatur.linux
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox