[PATCH] selftests/powerpc: Use date instead of EPOCHSECONDS in mitigation-patching.sh

Subsystems: kernel selftest framework, the rest

STALE1744d LANDED

Landed in mainline as cb662608e546 on 2021-10-27.

2 messages, 2 authors, 2021-11-02 · open the first message on its own page

[PATCH] selftests/powerpc: Use date instead of EPOCHSECONDS in mitigation-patching.sh

From: Russell Currey <hidden>
Date: 2021-10-25 10:33:14

The EPOCHSECONDS environment variable was added in bash 5.0 (released
2019).  Some distributions of the "stable" and "long-term" variety ship
older versions of bash than this, so swap to using the date command
instead.

"%s" was added to coreutils `date` in 1993 so we should be good, but who
knows, it is a GNU extension and not part of the POSIX spec for `date`.

Signed-off-by: Russell Currey <redacted>
---
 .../testing/selftests/powerpc/security/mitigation-patching.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/powerpc/security/mitigation-patching.sh b/tools/testing/selftests/powerpc/security/mitigation-patching.sh
index 00197acb7ff1..b0b20e0b4e30 100755
--- a/tools/testing/selftests/powerpc/security/mitigation-patching.sh
+++ b/tools/testing/selftests/powerpc/security/mitigation-patching.sh
@@ -13,7 +13,7 @@ function do_one
 
     orig=$(cat "$mitigation")
 
-    start=$EPOCHSECONDS
+    start=$(date +%s)
     now=$start
 
     while [[ $((now-start)) -lt "$TIMEOUT" ]]
@@ -21,7 +21,7 @@ function do_one
         echo 0 > "$mitigation"
         echo 1 > "$mitigation"
 
-        now=$EPOCHSECONDS
+        now=$(date +%s)
     done
 
     echo "$orig" > "$mitigation"
-- 
2.33.1

Re: [PATCH] selftests/powerpc: Use date instead of EPOCHSECONDS in mitigation-patching.sh

From: Michael Ellerman <hidden>
Date: 2021-11-02 11:51:41

On Mon, 25 Oct 2021 20:24:36 +1000, Russell Currey wrote:
The EPOCHSECONDS environment variable was added in bash 5.0 (released
2019).  Some distributions of the "stable" and "long-term" variety ship
older versions of bash than this, so swap to using the date command
instead.

"%s" was added to coreutils `date` in 1993 so we should be good, but who
knows, it is a GNU extension and not part of the POSIX spec for `date`.

[...]
Applied to powerpc/next.

[1/1] selftests/powerpc: Use date instead of EPOCHSECONDS in mitigation-patching.sh
      https://git.kernel.org/powerpc/c/cb662608e546d755e3e1b51b30a269459323bf24

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help