mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] selftests/cpu-hotplug: Use $(id -u) instead of $UID for root check
@ 2026-10-22  5:22 Darren Chang
  2026-10-22  5:22 ` [PATCH 2/2] selftests/memory-hotplug: " Darren Chang
  0 siblings, 1 reply; 2+ messages in thread
From: Darren Chang @ 2026-10-22  5:22 UTC (permalink / raw)
  To: shuah, david, osalvador
  Cc: linux-kselftest, linux-mm, linux-kernel, Darren Chang

$UID is a bash-specific variable and is not defined in other shells such
as Android's /system/bin/sh (mksh) or POSIX sh. When running this test
on environments without bash (e.g. Android), $UID is unset and
'[ $UID != 0 ]' expands to '[ != 0 ]', causing a syntax error.

Replace $UID with "$(id -u)" so the root privilege check works across
different shells.

Signed-off-by: Darren Chang <chihsheng@google.com>
---
 tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh b/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
index 287cfd5809f6..6653507b9348 100755
--- a/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
+++ b/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
@@ -10,7 +10,7 @@ prerequisite()
 {
 	msg="skip all tests:"
 
-	if [ $UID != 0 ]; then
+	if [ "$(id -u)" -ne 0 ]; then
 		echo $msg must be run as root >&2
 		exit $ksft_skip
 	fi
-- 
2.56.0.257.gf7497c7d27-goog


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

* [PATCH 2/2] selftests/memory-hotplug: Use $(id -u) instead of $UID for root check
  2026-10-22  5:22 [PATCH 1/2] selftests/cpu-hotplug: Use $(id -u) instead of $UID for root check Darren Chang
@ 2026-10-22  5:22 ` Darren Chang
  0 siblings, 0 replies; 2+ messages in thread
From: Darren Chang @ 2026-10-22  5:22 UTC (permalink / raw)
  To: shuah, david, osalvador
  Cc: linux-kselftest, linux-mm, linux-kernel, Darren Chang

$UID is a bash-specific variable and is not defined in other shells such
as Android's /system/bin/sh (mksh) or POSIX sh. When running this test
on environments without bash (e.g. Android), $UID is unset and
'[ $UID != 0 ]' expands to '[ != 0 ]', causing a syntax error.

Replace $UID with "$(id -u)" so the root privilege check works across
different shells.

Signed-off-by: Darren Chang <chihsheng@google.com>
---
 tools/testing/selftests/memory-hotplug/mem-on-off-test.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh b/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh
index 611be86eaf3d..11fb70bf1833 100755
--- a/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh
+++ b/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh
@@ -10,7 +10,7 @@ prerequisite()
 {
 	msg="skip all tests:"
 
-	if [ $UID != 0 ]; then
+	if [ "$(id -u)" -ne 0 ]; then
 		echo $msg must be run as root >&2
 		exit $ksft_skip
 	fi
-- 
2.56.0.257.gf7497c7d27-goog


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

end of thread, other threads:[~2026-10-22  5:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-22  5:22 [PATCH 1/2] selftests/cpu-hotplug: Use $(id -u) instead of $UID for root check Darren Chang
2026-10-22  5:22 ` [PATCH 2/2] selftests/memory-hotplug: " Darren Chang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®