kselftests: Sort the collections list to avoid duplicate tests

Message ID 20230601211112.12724-1-risbhat@amazon.com
State New
Headers
Series kselftests: Sort the collections list to avoid duplicate tests |

Commit Message

Rishabh Bhatnagar June 1, 2023, 9:11 p.m. UTC
  If the collections list is not sorted uniq doesn't weed out duplicate
tests correctly. Make sure to sort it before running uniq.

Signed-off-by: Rishabh Bhatnagar <risbhat@amazon.com>
---
 tools/testing/selftests/run_kselftest.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Shuah Khan June 5, 2023, 7:40 p.m. UTC | #1
On 6/1/23 15:11, Rishabh Bhatnagar wrote:
> If the collections list is not sorted uniq doesn't weed out duplicate
> tests correctly. Make sure to sort it before running uniq.
> 
> Signed-off-by: Rishabh Bhatnagar <risbhat@amazon.com>
> ---
>   tools/testing/selftests/run_kselftest.sh | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/run_kselftest.sh b/tools/testing/selftests/run_kselftest.sh
> index 97165a83df63..e0cb10c85169 100755
> --- a/tools/testing/selftests/run_kselftest.sh
> +++ b/tools/testing/selftests/run_kselftest.sh
> @@ -85,7 +85,7 @@ if [ -n "$TESTS" ]; then
>   	available="$(echo "$valid" | sed -e 's/ /\n/g')"
>   fi
>   
> -collections=$(echo "$available" | cut -d: -f1 | uniq)
> +collections=$(echo "$available" | cut -d: -f1 | sort | uniq)
>   for collection in $collections ; do
>   	[ -w /dev/kmsg ] && echo "kselftest: Running tests in $collection" >> /dev/kmsg
>   	tests=$(echo "$available" | grep "^$collection:" | cut -d: -f2)

Applied to linux-kselftest next for Linux 6.5-rc1.

thanks,
-- Shuah
  

Patch

diff --git a/tools/testing/selftests/run_kselftest.sh b/tools/testing/selftests/run_kselftest.sh
index 97165a83df63..e0cb10c85169 100755
--- a/tools/testing/selftests/run_kselftest.sh
+++ b/tools/testing/selftests/run_kselftest.sh
@@ -85,7 +85,7 @@  if [ -n "$TESTS" ]; then
 	available="$(echo "$valid" | sed -e 's/ /\n/g')"
 fi
 
-collections=$(echo "$available" | cut -d: -f1 | uniq)
+collections=$(echo "$available" | cut -d: -f1 | sort | uniq)
 for collection in $collections ; do
 	[ -w /dev/kmsg ] && echo "kselftest: Running tests in $collection" >> /dev/kmsg
 	tests=$(echo "$available" | grep "^$collection:" | cut -d: -f2)