linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests/run_kselftest.sh: Use readlink if realpath is not available
@ 2025-03-18 16:05 Yosry Ahmed
  2025-03-28 20:05 ` Shuah Khan
  0 siblings, 1 reply; 4+ messages in thread
From: Yosry Ahmed @ 2025-03-18 16:05 UTC (permalink / raw)
  To: Shuah Khan; +Cc: linux-kselftest, linux-kernel, Yosry Ahmed

'realpath' is not always available,  fallback to 'readlink -f' if is not
available. They seem to work equally well in this context.

Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev>
---
 tools/testing/selftests/run_kselftest.sh | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/run_kselftest.sh b/tools/testing/selftests/run_kselftest.sh
index 50e03eefe7ac7..0443beacf3621 100755
--- a/tools/testing/selftests/run_kselftest.sh
+++ b/tools/testing/selftests/run_kselftest.sh
@@ -3,7 +3,14 @@
 #
 # Run installed kselftest tests.
 #
-BASE_DIR=$(realpath $(dirname $0))
+
+# Fallback to readlink if realpath is not available
+if which realpath > /dev/null; then
+        BASE_DIR=$(realpath $(dirname $0))
+else
+        BASE_DIR=$(readlink -f $(dirname $0))
+fi
+
 cd $BASE_DIR
 TESTS="$BASE_DIR"/kselftest-list.txt
 if [ ! -r "$TESTS" ] ; then
-- 
2.49.0.rc1.451.g8f38331e32-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] selftests/run_kselftest.sh: Use readlink if realpath is not available
  2025-03-18 16:05 [PATCH] selftests/run_kselftest.sh: Use readlink if realpath is not available Yosry Ahmed
@ 2025-03-28 20:05 ` Shuah Khan
  2025-03-29 19:48   ` Yosry Ahmed
  2025-05-06  9:19   ` Yosry Ahmed
  0 siblings, 2 replies; 4+ messages in thread
From: Shuah Khan @ 2025-03-28 20:05 UTC (permalink / raw)
  To: Yosry Ahmed, Shuah Khan; +Cc: linux-kselftest, linux-kernel, Shuah Khan

On 3/18/25 10:05, Yosry Ahmed wrote:
> 'realpath' is not always available,  fallback to 'readlink -f' if is not
> available. They seem to work equally well in this context.

Can you add more specifics on "realpath" is not always available,"

No issues with the patch itself. I would like to know the cases
where "realpath" command is missing.


> 
> Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev>
> ---
>   tools/testing/selftests/run_kselftest.sh | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/run_kselftest.sh b/tools/testing/selftests/run_kselftest.sh
> index 50e03eefe7ac7..0443beacf3621 100755
> --- a/tools/testing/selftests/run_kselftest.sh
> +++ b/tools/testing/selftests/run_kselftest.sh
> @@ -3,7 +3,14 @@
>   #
>   # Run installed kselftest tests.
>   #
> -BASE_DIR=$(realpath $(dirname $0))
> +
> +# Fallback to readlink if realpath is not available
> +if which realpath > /dev/null; then
> +        BASE_DIR=$(realpath $(dirname $0))
> +else
> +        BASE_DIR=$(readlink -f $(dirname $0))
> +fi
> +
>   cd $BASE_DIR
>   TESTS="$BASE_DIR"/kselftest-list.txt
>   if [ ! -r "$TESTS" ] ; then

thanks,
-- Shuah


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] selftests/run_kselftest.sh: Use readlink if realpath is not available
  2025-03-28 20:05 ` Shuah Khan
@ 2025-03-29 19:48   ` Yosry Ahmed
  2025-05-06  9:19   ` Yosry Ahmed
  1 sibling, 0 replies; 4+ messages in thread
From: Yosry Ahmed @ 2025-03-29 19:48 UTC (permalink / raw)
  To: Shuah Khan, Shuah Khan; +Cc: linux-kselftest, linux-kernel, Shuah Khan

March 28, 2025 at 10:05 PM, "Shuah Khan" <skhan@linuxfoundation.org> wrote:
> 
> On 3/18/25 10:05, Yosry Ahmed wrote:
> 
> > 'realpath' is not always available, fallback to 'readlink -f' if is not
> >  available. They seem to work equally well in this context.
> 
> Can you add more specifics on "realpath" is not always available,"
> No issues with the patch itself. I would like to know the cases
> where "realpath" command is missing.

Not all distros have realpath. In my case, it was an internal distro we use on some test machines, so I can't really share much details about it.

Thanks.

> > 
> > Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev>
> >  ---
> >  tools/testing/selftests/run_kselftest.sh | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> >  diff --git a/tools/testing/selftests/run_kselftest.sh b/tools/testing/selftests/run_kselftest.sh
> >  index 50e03eefe7ac7..0443beacf3621 100755
> >  --- a/tools/testing/selftests/run_kselftest.sh
> >  +++ b/tools/testing/selftests/run_kselftest.sh
> >  @@ -3,7 +3,14 @@
> >  #
> >  # Run installed kselftest tests.
> >  #
> >  -BASE_DIR=$(realpath $(dirname $0))
> >  +
> >  +# Fallback to readlink if realpath is not available
> >  +if which realpath > /dev/null; then
> >  + BASE_DIR=$(realpath $(dirname $0))
> >  +else
> >  + BASE_DIR=$(readlink -f $(dirname $0))
> >  +fi
> >  +
> >  cd $BASE_DIR
> >  TESTS="$BASE_DIR"/kselftest-list.txt
> >  if [ ! -r "$TESTS" ] ; then
> 
> thanks,
> 
> -- Shuah
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] selftests/run_kselftest.sh: Use readlink if realpath is not available
  2025-03-28 20:05 ` Shuah Khan
  2025-03-29 19:48   ` Yosry Ahmed
@ 2025-05-06  9:19   ` Yosry Ahmed
  1 sibling, 0 replies; 4+ messages in thread
From: Yosry Ahmed @ 2025-05-06  9:19 UTC (permalink / raw)
  To: Shuah Khan; +Cc: Shuah Khan, linux-kselftest, linux-kernel

On Fri, Mar 28, 2025 at 02:05:43PM -0600, Shuah Khan wrote:
> On 3/18/25 10:05, Yosry Ahmed wrote:
> > 'realpath' is not always available,  fallback to 'readlink -f' if is not
> > available. They seem to work equally well in this context.
> 
> Can you add more specifics on "realpath" is not always available,"
> 
> No issues with the patch itself. I would like to know the cases
> where "realpath" command is missing.

I think I already responded but I can't find my response, anyway:

Not all distros have realpath. In my case, it was an internal distro we
use on some test machines, so I can't really share much details about
it.

Are there any other questions that I can help answer about this patch?

> 
> 
> > 
> > Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev>
> > ---
> >   tools/testing/selftests/run_kselftest.sh | 9 ++++++++-
> >   1 file changed, 8 insertions(+), 1 deletion(-)
> > 
> > diff --git a/tools/testing/selftests/run_kselftest.sh b/tools/testing/selftests/run_kselftest.sh
> > index 50e03eefe7ac7..0443beacf3621 100755
> > --- a/tools/testing/selftests/run_kselftest.sh
> > +++ b/tools/testing/selftests/run_kselftest.sh
> > @@ -3,7 +3,14 @@
> >   #
> >   # Run installed kselftest tests.
> >   #
> > -BASE_DIR=$(realpath $(dirname $0))
> > +
> > +# Fallback to readlink if realpath is not available
> > +if which realpath > /dev/null; then
> > +        BASE_DIR=$(realpath $(dirname $0))
> > +else
> > +        BASE_DIR=$(readlink -f $(dirname $0))
> > +fi
> > +
> >   cd $BASE_DIR
> >   TESTS="$BASE_DIR"/kselftest-list.txt
> >   if [ ! -r "$TESTS" ] ; then
> 
> thanks,
> -- Shuah
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-05-06  9:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-18 16:05 [PATCH] selftests/run_kselftest.sh: Use readlink if realpath is not available Yosry Ahmed
2025-03-28 20:05 ` Shuah Khan
2025-03-29 19:48   ` Yosry Ahmed
2025-05-06  9:19   ` Yosry Ahmed

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).