Skip to contentSkip to conversation

ftrace/selftests: Add softlink to latest log directory

PATCH In review Steven Rostedt 3 participants 4 messages Sep 8, 2023 – Sep 11, 2023

Subsystems (2)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

PATCH 1/1 ftrace/selftests: Add softlink to latest log directory

From: Steven Rostedt (Google) <[email protected]>

When I'm debugging something with the ftrace selftests and need to look at the logs, it becomes tedious that I need to do the following:

ls -ltr logs
[ copy the last directory ]
ls logs/<paste-last-dir>

to see where the logs are.

Instead, do the common practice of having a "latest" softlink to the last run selftest. This way after running the selftest I only need to do:

ls logs/latest/

and it will always give me the directory of the last run selftest logs!

---

tools/testing/selftests/ftrace/ftracetest +9 -1
index cb5f18c06593..7df8baa0f98f 100755
@@ -124,6 +124,7 @@ parse_opts() { # opts
     ;;
     --logdir|-l)
       LOG_DIR=$2
+      LINK_PTR=
       shift 2
     ;;
     *.tc)
@@ -181,7 +182,10 @@ fi
 TOP_DIR=`absdir $0`
 TEST_DIR=$TOP_DIR/test.d
 TEST_CASES=`find_testcases $TEST_DIR`
-LOG_DIR=$TOP_DIR/logs/`date +%Y%m%d-%H%M%S`/
+LOG_TOP_DIR=$TOP_DIR/logs
+LOG_DATE=`date +%Y%m%d-%H%M%S`
+LOG_DIR=$LOG_TOP_DIR/$LOG_DATE/
+LINK_PTR=$LOG_TOP_DIR/latest
 KEEP_LOG=0
 KTAP=0
 DEBUG=0
@@ -207,6 +211,10 @@ else
   LOG_FILE=$LOG_DIR/ftracetest.log
   mkdir -p $LOG_DIR || errexit "Failed to make a log directory: $LOG_DIR"
   date > $LOG_FILE
+  if [ "x-$LINK_PTR" != "x-" ]; then
+    unlink $LINK_PTR
+    ln -fs $LOG_DATE $LINK_PTR
+  fi
 fi
 
 # Define text colors
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · On Fri, 8 Sep 2023 18:17:21 -0400 Steven Rostedt <[email protected]> wrote:

From: Steven Rostedt (Google) <[email protected]>

When I'm debugging something with the ftrace selftests and need to look at the logs, it becomes tedious that I need to do the following:

ls -ltr logs
[ copy the last directory ]
ls logs/<paste-last-dir>

Quoted 9 lines

to see where the logs are.

Instead, do the common practice of having a "latest" softlink to the last run selftest. This way after running the selftest I only need to do:

ls logs/latest/

and it will always give me the directory of the last run selftest logs!

Nice! I like this and this looks good to me.

Thank you!

Quoted 38 lines

---

tools/testing/selftests/ftrace/ftracetest +9 -1
index cb5f18c06593..7df8baa0f98f 100755
@@ -124,6 +124,7 @@ parse_opts() { # opts
     ;;
     --logdir|-l)
       LOG_DIR=$2
+      LINK_PTR=
       shift 2
     ;;
     *.tc)
@@ -181,7 +182,10 @@ fi
 TOP_DIR=`absdir $0`
 TEST_DIR=$TOP_DIR/test.d
 TEST_CASES=`find_testcases $TEST_DIR`
-LOG_DIR=$TOP_DIR/logs/`date +%Y%m%d-%H%M%S`/
+LOG_TOP_DIR=$TOP_DIR/logs
+LOG_DATE=`date +%Y%m%d-%H%M%S`
+LOG_DIR=$LOG_TOP_DIR/$LOG_DATE/
+LINK_PTR=$LOG_TOP_DIR/latest
 KEEP_LOG=0
 KTAP=0
 DEBUG=0
@@ -207,6 +211,10 @@ else
   LOG_FILE=$LOG_DIR/ftracetest.log
   mkdir -p $LOG_DIR || errexit "Failed to make a log directory: $LOG_DIR"
   date > $LOG_FILE
+  if [ "x-$LINK_PTR" != "x-" ]; then
+    unlink $LINK_PTR
+    ln -fs $LOG_DATE $LINK_PTR
+  fi
 fi
 
 # Define text colors
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
author maintainer
#2 lore raw
Quoted 19 lines · On Mon, 11 Sep 2023 09:21:05 +0900 Masami Hiramatsu (Google)…
Quoted 16 lines · On Fri, 8 Sep 2023 18:17:21 -0400 Steven Rostedt <[email protected]> wrote:

From: Steven Rostedt (Google) <[email protected]>

When I'm debugging something with the ftrace selftests and need to look at the logs, it becomes tedious that I need to do the following:

ls -ltr logs
[ copy the last directory ]
ls logs/<paste-last-dir>

to see where the logs are.

Instead, do the common practice of having a "latest" softlink to the last run selftest. This way after running the selftest I only need to do:

ls logs/latest/

Quoted 9 lines
Quoted 2 lines

and it will always give me the directory of the last run selftest logs!

Nice! I like this and this looks good to me.

Thank you!

Should this go via Shuah's tree?

-- Steve

maintainer
#3 lore raw
Quoted 25 lines · Steven Rostedt
Quoted 22 lines · On Mon, 11 Sep 2023 09:21:05 +0900 Masami Hiramatsu (Google)…
Quoted 18 lines · On Fri, 8 Sep 2023 18:17:21 -0400 Steven Rostedt <[email protected]> wrote:

From: Steven Rostedt (Google) <[email protected]>

When I'm debugging something with the ftrace selftests and need to look at the logs, it becomes tedious that I need to do the following:

ls -ltr logs
[ copy the last directory ]
ls logs/<paste-last-dir>

to see where the logs are.

Instead, do the common practice of having a "latest" softlink to the last run selftest. This way after running the selftest I only need to do:

ls logs/latest/

and it will always give me the directory of the last run selftest logs!

Quoted 9 lines
Quoted 6 lines

Nice! I like this and this looks good to me.

Thank you!

Should this go via Shuah's tree?

Looks like it is a self contained patch. I will take it.

thanks,
-- Shuah