linux/tools/tracing/rtla/src
John Kacur 842fc5b87a rtla: Fix -t\--trace[=file]
The -t option has an optional argument.
The usual case is for a short option to be specified without an '='
and for the long version to be specified with an '='

Various forms of this do not work as expected.
For example:
rtla timerlat hist -T50 -tfile.txt
will result in a truncated file name of "ile.txt"

Another example is that the long form without the '=' will result in the
default file name instead of the requested file name.

This patch properly parses the optional argument with and without '='
and with and without spaces for the short form.

This patch was also tested using -t and --trace without providing a file
name both as the last requested option and with a following long and
short option.

For example:

  rtla timerlat hist -T50 -t -u
  rtla timerlat hist -T50 --trace -u

This fix is applied to both timerlat top and hist
and to osnoise top and hist.

Here is the full testing for rtla timerlat hist.
Before applying the patch

  rtla timerlat hist -T50 -t=file.txt
    Works as expected, "file.txt"

  rtla timerlat hist -T50 -tfile.txt
    Truncated file name "ile.txt"

  rtla timerlat hist -T50 -t file.txt
    Default file name instead of file.txt

  rtla timerlat hist -T50 --trace=file.txt
    Truncated file name "ile.txt"

  rtla timerlat hist -T50 --trace file.txt
    Default file name "timerlat_trace.txt" instead of "file.txt"

After applying the patch:

  rtla timerlat hist -T50 -t=file.txt
    Works as expected, "file.txt"

  rtla timerlat hist -T50 -tfile.txt
    Works as expected, "file.txt"

  rtla timerlat hist -T50 -t file.txt
    Works as expected, "file.txt"

  rtla timerlat hist -T50 --trace=file.txt
    Works as expected, "file.txt"

  rtla timerlat hist -T50 --trace file.txt
    Works as expected, "file.txt"

In addition the following tests were performed to make sure that
the default file name worked as expected including with trailing
options.

  rtla timerlat hist -T50 -t
    Works as expected "timerlat_trace.txt"

  rtla timerlat hist -T50 --trace
    Works as expected "timerlat_trace.txt"

  rtla timerlat hist -T50 -t -u
    Works as expected "timerlat_trace.txt"

  rtla timerlat hist -T50 --trace -u
    Works as expected "timerlat_trace.txt"

Link: https://lkml.kernel.org/r/20240515183024.59985-1-jkacur@redhat.com

Cc: Daniel Bristot de Oliveria <bristot@kernel.org>
Signed-off-by: John Kacur <jkacur@redhat.com>
Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
2024-05-16 16:49:10 +02:00
..
Build tools/rtla: Use tools/build makefiles to build rtla 2024-03-20 05:39:06 +01:00
osnoise.c rtla/timerlat_top: Add timerlat user-space support 2023-06-13 16:38:51 -04:00
osnoise.h rtla/timerlat_top: Add timerlat user-space support 2023-06-13 16:38:51 -04:00
osnoise_hist.c rtla: Fix -t\--trace[=file] 2024-05-16 16:49:10 +02:00
osnoise_top.c rtla: Fix -t\--trace[=file] 2024-05-16 16:49:10 +02:00
rtla.c rtla: Add hwnoise tool 2023-02-13 23:56:46 -05:00
timerlat.c rtla: Fix exit status when returning from calls to usage() 2022-12-09 18:06:24 -05:00
timerlat.h rtla/timerlat: Add timerlat hist mode 2022-01-13 17:02:43 -05:00
timerlat_aa.c rtla/auto-analysis: Replace \t with spaces 2024-05-15 15:13:56 +02:00
timerlat_aa.h rtla/timerlat: Give timerlat auto analysis its own instance 2023-06-13 16:31:35 -04:00
timerlat_hist.c rtla: Fix -t\--trace[=file] 2024-05-16 16:49:10 +02:00
timerlat_top.c rtla: Fix -t\--trace[=file] 2024-05-16 16:49:10 +02:00
timerlat_u.c rtla/timerlat: Do not stop user-space if a cpu is offline 2023-09-22 14:43:46 +02:00
timerlat_u.h rtla/timerlat_top: Add timerlat user-space support 2023-06-13 16:38:51 -04:00
trace.c rtla: Add --trace-buffer-size option 2024-05-16 16:44:34 +02:00
trace.h rtla: Add --trace-buffer-size option 2024-05-16 16:44:34 +02:00
utils.c tools/rtla: Replace setting prio with nice for SCHED_OTHER 2024-02-12 10:56:36 +01:00
utils.h tools/rtla: Replace setting prio with nice for SCHED_OTHER 2024-02-12 10:56:36 +01:00