[PATCH v2] selftest: net: Fix error message if empty variable

Alessandro Zanni posted 1 patch 6 days, 10 hours ago
tools/testing/selftests/net/tfo_passive.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v2] selftest: net: Fix error message if empty variable
Posted by Alessandro Zanni 6 days, 10 hours ago
Fix to avoid cases where the `res` shell variable is
empty in script comparisons.
The comparison has been modified into string comparison to
handle other possible values the variable could assume.

The issue can be reproduced with the command:
make kselftest TARGETS=net

It solves the error:
./tfo_passive.sh: line 98: [: -eq: unary operator expected

Signed-off-by: Alessandro Zanni <alessandro.zanni87@gmail.com>
---

Notes:
    v2: edit condition to handle strings

 tools/testing/selftests/net/tfo_passive.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/tfo_passive.sh b/tools/testing/selftests/net/tfo_passive.sh
index 80bf11fdc046..a4550511830a 100755
--- a/tools/testing/selftests/net/tfo_passive.sh
+++ b/tools/testing/selftests/net/tfo_passive.sh
@@ -95,7 +95,7 @@ wait
 res=$(cat $out_file)
 rm $out_file
 
-if [ $res -eq 0 ]; then
+if [ "$res" = "0" ]; then
 	echo "got invalid NAPI ID from passive TFO socket"
 	cleanup_ns
 	exit 1
-- 
2.43.0
Re: [PATCH v2] selftest: net: Fix error message if empty variable
Posted by Simon Horman 5 days, 10 hours ago
On Thu, Sep 25, 2025 at 03:28:23PM +0200, Alessandro Zanni wrote:
> Fix to avoid cases where the `res` shell variable is
> empty in script comparisons.
> The comparison has been modified into string comparison to
> handle other possible values the variable could assume.
> 
> The issue can be reproduced with the command:
> make kselftest TARGETS=net
> 
> It solves the error:
> ./tfo_passive.sh: line 98: [: -eq: unary operator expected
> 
> Signed-off-by: Alessandro Zanni <alessandro.zanni87@gmail.com>
> ---
> 
> Notes:
>     v2: edit condition to handle strings

Thanks. This seems more robust to me.

Reviewed-by: Simon Horman <horms@kernel.org>