diff mbox series

[VSP-Tests,3/3] scripts/logger: Use new monotonic-ts tool

Message ID 20200916144302.1483470-4-kieran.bingham@ideasonboard.com (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show
Series Run as user, and python3 support | expand

Commit Message

Kieran Bingham Sept. 16, 2020, 2:43 p.m. UTC
Utilise the new monotonic timestamping tool to remove the manual parsing of
timestamps via /proc/timer_list which can only be read by root.

This also simplifies the processing required and contains all timestamping
actions within a single process space.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 scripts/logger.sh | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

Comments

Laurent Pinchart Sept. 17, 2020, 1:17 a.m. UTC | #1
Hi Kieran,

Thank you for the patch.

On Wed, Sep 16, 2020 at 03:43:02PM +0100, Kieran Bingham wrote:
> Utilise the new monotonic timestamping tool to remove the manual parsing of
> timestamps via /proc/timer_list which can only be read by root.
> 
> This also simplifies the processing required and contains all timestamping
> actions within a single process space.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>  scripts/logger.sh | 20 ++++----------------
>  1 file changed, 4 insertions(+), 16 deletions(-)
> 
> diff --git a/scripts/logger.sh b/scripts/logger.sh
> index 97e1f582da2b..452ebc8c82ba 100755
> --- a/scripts/logger.sh
> +++ b/scripts/logger.sh
> @@ -2,23 +2,11 @@
>  # SPDX-License-Identifier: GPL-2.0-or-later
>  # SPDX-FileCopyrightText: 2016 Renesas Electronics Corporation
>  
> -now() {
> -	awk '/^now/ {time=$3; printf("[%u.%06u]", time / 1000000000, (time % 1000000000) / 1000) ; exit}' /proc/timer_list
> -}
> -
>  label=${1:+ [$1]}
>  
>  TRACE_MARKER=/sys/kernel/debug/tracing/trace_marker
> -if [ -e $TRACE_MARKER ]; then
> -	extra_log_files=$TRACE_MARKER
> +if [ -e $TRACE_MARKER ] && [ $(id -u) == 0 ]; then
> +	./monotonic-ts $label | tee -a $TRACE_MARKER
> +else
> +	./monotonic-ts $label
>  fi
> -
> -while read line ; do
> -	newline="$(now)$label $line"
> -
> -	echo "$newline"
> -
> -	for f in $extra_log_files; do
> -		echo "$newline" >> $f;
> -	done;
> -done

In logger.sh line 8:
if [ -e $TRACE_MARKER ] && [ $(id -u) == 0 ]; then
                             ^------^ SC2046: Quote this to prevent word splitting.
                                      ^-- SC2039: In POSIX sh, == in place of = is undefined.


In logger.sh line 9:
        ./monotonic-ts $label | tee -a $TRACE_MARKER
                       ^----^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean:
        ./monotonic-ts "$label" | tee -a $TRACE_MARKER


In logger.sh line 11:
        ./monotonic-ts $label
                       ^----^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean:
        ./monotonic-ts "$label"

For more information:
  https://www.shellcheck.net/wiki/SC2039 -- In POSIX sh, == in place of = is ...
  https://www.shellcheck.net/wiki/SC2046 -- Quote this to prevent word splitt...
  https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ...

With this fixed,

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
diff mbox series

Patch

diff --git a/scripts/logger.sh b/scripts/logger.sh
index 97e1f582da2b..452ebc8c82ba 100755
--- a/scripts/logger.sh
+++ b/scripts/logger.sh
@@ -2,23 +2,11 @@ 
 # SPDX-License-Identifier: GPL-2.0-or-later
 # SPDX-FileCopyrightText: 2016 Renesas Electronics Corporation
 
-now() {
-	awk '/^now/ {time=$3; printf("[%u.%06u]", time / 1000000000, (time % 1000000000) / 1000) ; exit}' /proc/timer_list
-}
-
 label=${1:+ [$1]}
 
 TRACE_MARKER=/sys/kernel/debug/tracing/trace_marker
-if [ -e $TRACE_MARKER ]; then
-	extra_log_files=$TRACE_MARKER
+if [ -e $TRACE_MARKER ] && [ $(id -u) == 0 ]; then
+	./monotonic-ts $label | tee -a $TRACE_MARKER
+else
+	./monotonic-ts $label
 fi
-
-while read line ; do
-	newline="$(now)$label $line"
-
-	echo "$newline"
-
-	for f in $extra_log_files; do
-		echo "$newline" >> $f;
-	done;
-done