linux/tools
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
..
accounting
arch tools/include: Sync arm64 asm/cputype.h with the kernel sources 2024-04-11 10:38:29 -07:00
bootconfig
bpf libbpf, selftests/bpf: Adjust libbpf, bpftool, selftests to match LLVM 2024-03-15 14:24:00 -07:00
build
certs
cgroup
counter
crypto crypto: ccp - Update return values for some unit tests 2024-02-24 08:41:20 +08:00
debugging
firewire
firmware
gpio
hv hv/hv_kvp_daemon: Handle IPv4 and Ipv6 combination for keyfile format 2024-04-10 21:25:40 +00:00
iio
include perf tools fixes for v6.9 2024-04-19 16:34:10 -07:00
kvm/kvm_stat
laptop
leds
lib bpf-for-netdev 2024-03-26 12:55:18 +01:00
memory-model
mm tools/mm: add thpmaps script to dump THP usage info 2024-02-22 10:24:38 -08:00
net/ynl tools: ynl: don't ignore errors in NLMSG_DONE messages 2024-04-23 15:37:33 +02:00
objtool objtool: Fix compile failure when using the x32 compiler 2024-03-30 22:12:37 +01:00
pci
pcmcia
perf RISC-V Fixes for 6.9-rc6 2024-04-27 12:02:55 -07:00
power Turbostat version 2024.04.10 2024-04-10 13:13:27 -07:00
rcu
scripts treewide: remove meaningless assignments in Makefiles 2024-02-23 14:19:07 -08:00
spi
testing Fix Kselftest's vfork() side effects 2024-05-12 13:01:59 -07:00
thermal
time
tracing rtla: Fix -t\--trace[=file] 2024-05-16 16:49:10 +02:00
usb
verification tools/verification: Use tools/build makefiles on rv 2024-03-20 05:39:06 +01:00
virtio tools: virtio: introduce vhost_net_test 2024-03-05 11:38:14 +01:00
wmi
workqueue
Makefile tools/Makefile: remove cgroup target 2024-03-26 11:07:21 -07:00