rtla: Add tests for option parsing with attached arguments
Subsystems (2)
cover rtla: Add tests for option parsing with attached arguments
This patch series adds comprehensive tests to verify that short options with attached numeric arguments (e.g., -p100) work correctly across all rtla commands.
These tests complement Tomas Glozar's fix "rtla: Fix parsing of multi-character short options" which resolves the issue where options like -p100 were incorrectly parsed as multiple separate options due to getopt_long() being called twice.
The tests verify four option formats for each command:
-p 100 (short with space) -p100 (short attached - previously broken) --period=100 (long with equals) --period 100 (long with space)
Commands tested:
- timerlat hist and top
- osnoise hist and top
- hwnoise
All 20 tests pass with Tomas's fix applied, confirming the issue is resolved and preventing future regressions. These tests will continue to work when rtla transitions to libsubcmd in the future, ensuring this functionality remains correct across parsing implementations.
Note: Patch 1/2 is a resend of the timerlat hist tests sent previously. Patch 2/2 adds tests for the remaining rtla commands.
John Kacur (2):
rtla/timerlat: Add tests for option parsing with attached arguments
rtla: Add tests for option parsing with attached arguments
tools/tracing/rtla/tests/hwnoise.t | 10 ++++++++++ tools/tracing/rtla/tests/osnoise.t | 18 ++++++++++++++++++ tools/tracing/rtla/tests/timerlat.t | 18 ++++++++++++++++++ 3 files changed, 46 insertions(+)
Signature · 1 line
2.54.0
PATCH 1/2 rtla/timerlat: Add tests for option parsing with attached arguments
Add tests to verify that numeric arguments work correctly with both attached and detached formats:
-p 100 (short with space) -p100 (short without space) --period=100 (long with =) --period 100 (long with space)
These tests prevent regression of the bug fixed in commit eefa8af46ff7 ("rtla/timerlat: Fix parsing of short options with attached arguments") where -p100 was incorrectly parsed as multiple separate options.
The tests verify that:
1. All four argument formats succeed (exit code 0)
2. None trigger the "no-irq and no-thread" error that occurred when the bug was present
--- tools/tracing/rtla/tests/timerlat.t | 10 ++++++++++ 1 file changed, 10 insertions(+)
tools/tracing/rtla/tests/timerlat.t +10 -0
@@ -42,6 +42,16 @@ check "verify -c/--cpus" \ check "hist test in nanoseconds" \ "timerlat hist -i 2 -c 0 -n -d 10s" 2 "ns" +# Option parsing tests - verify attached numeric arguments work correctly +check "verify -p with space" \ + "timerlat hist -p 100 -c 0 -d 1s" 0 "" "no-irq and no-thread" +check "verify -p without space (attached argument)" \ + "timerlat hist -p100 -c 0 -d 1s" 0 "" "no-irq and no-thread" +check "verify --period with equals" \ + "timerlat hist --period=100 -c 0 -d 1s" 0 "" "no-irq and no-thread" +check "verify --period with space" \ + "timerlat hist --period 100 -c 0 -d 1s" 0 "" "no-irq and no-thread" + # Actions tests check "trace output through -t" \ "timerlat hist -T 2 -t" 2 "^ Saving trace to timerlat_trace.txt$"
Signature · 1 line
2.54.0
PATCH 2/2 rtla: Add tests for option parsing with attached arguments
In reply to John KacurAdd tests to verify that short options with attached numeric arguments work correctly for all rtla commands after the parsing fixes.
Tests verify four formats for each command:
- Short option with space: -p 100
- Short option attached: -p100
- Long option with equals: --period=100
- Long option with space: --period 100
For osnoise and hwnoise commands, the tests also include -r 100 (runtime) to satisfy the osnoise constraint that runtime <= period.
These tests complement the existing timerlat hist tests added in commit d489b602c669 ("rtla/timerlat: Add tests for option parsing with attached arguments").
--- tools/tracing/rtla/tests/hwnoise.t | 10 ++++++++++ tools/tracing/rtla/tests/osnoise.t | 18 ++++++++++++++++++ tools/tracing/rtla/tests/timerlat.t | 8 ++++++++ 3 files changed, 36 insertions(+)
tools/tracing/rtla/tests/hwnoise.t +10 -0
@@ -19,4 +19,14 @@ check "enable a trace event trigger" \ "hwnoise -t -e osnoise:irq_noise --trigger=\"hist:key=desc,duration:sort=desc,duration:vals=hitcount\" -d 10s" \ 0 "Saving event osnoise:irq_noise hist to osnoise_irq_noise_hist.txt" +# Option parsing tests - verify attached numeric arguments work correctly +check "verify -p with space" \ + "hwnoise -p 100 -r 100 -c 0 -d 1s" 0 "" "no-irq and no-thread" +check "verify -p without space (attached argument)" \ + "hwnoise -p100 -r 100 -c 0 -d 1s" 0 "" "no-irq and no-thread" +check "verify --period with equals" \ + "hwnoise --period=100 -r 100 -c 0 -d 1s" 0 "" "no-irq and no-thread" +check "verify --period with space" \ + "hwnoise --period 100 -r 100 -c 0 -d 1s" 0 "" "no-irq and no-thread" + test_end
tools/tracing/rtla/tests/osnoise.t +18 -0
@@ -17,6 +17,24 @@ check "verify the --trace param" \ check "verify the --entries/-E param" \ "osnoise hist -P F:1 -c 0 -r 900000 -d 10s -b 10 -E 25" +# Option parsing tests - verify attached numeric arguments work correctly +check "verify -p with space" \ + "osnoise hist -p 100 -r 100 -c 0 -d 1s" 0 "" "no-irq and no-thread" +check "verify -p without space (attached argument)" \ + "osnoise hist -p100 -r 100 -c 0 -d 1s" 0 "" "no-irq and no-thread" +check "verify --period with equals" \ + "osnoise hist --period=100 -r 100 -c 0 -d 1s" 0 "" "no-irq and no-thread" +check "verify --period with space" \ + "osnoise hist --period 100 -r 100 -c 0 -d 1s" 0 "" "no-irq and no-thread" +check "verify osnoise top -p with space" \ + "osnoise top -p 100 -r 100 -c 0 -d 1s -q" 0 "" "no-irq and no-thread" +check "verify osnoise top -p without space (attached argument)" \ + "osnoise top -p100 -r 100 -c 0 -d 1s -q" 0 "" "no-irq and no-thread" +check "verify osnoise top --period with equals" \ + "osnoise top --period=100 -r 100 -c 0 -d 1s -q" 0 "" "no-irq and no-thread" +check "verify osnoise top --period with space" \ + "osnoise top --period 100 -r 100 -c 0 -d 1s -q" 0 "" "no-irq and no-thread" + # Test setting default period by putting an absurdly high period # and stopping on threshold. # If default period is not set, this will time out.
tools/tracing/rtla/tests/timerlat.t +8 -0
@@ -51,6 +51,14 @@ check "verify --period with equals" \ "timerlat hist --period=100 -c 0 -d 1s" 0 "" "no-irq and no-thread" check "verify --period with space" \ "timerlat hist --period 100 -c 0 -d 1s" 0 "" "no-irq and no-thread" +check "verify timerlat top -p with space" \ + "timerlat top -p 100 -c 0 -d 1s -q" 0 "" "no-irq and no-thread" +check "verify timerlat top -p without space (attached argument)" \ + "timerlat top -p100 -c 0 -d 1s -q" 0 "" "no-irq and no-thread" +check "verify timerlat top --period with equals" \ + "timerlat top --period=100 -c 0 -d 1s -q" 0 "" "no-irq and no-thread" +check "verify timerlat top --period with space" \ + "timerlat top --period 100 -c 0 -d 1s -q" 0 "" "no-irq and no-thread" # Actions tests check "trace output through -t" \
Signature · 1 line
2.54.0
Tomas Glozar
maintainerút 2. 6. 2026 v 17:52 odesílatel John Kacur <[email protected]> napsal:
Quoted 4 lines
Note: Patch 1/2 is a resend of the timerlat hist tests sent previously. Patch 2/2 adds tests for the remaining rtla commands.
Ah, this confused me. I saw cover letters, 1/2, and 2/2 with almost the same title and content, and wondered what was going on.
Quoted 9 lines
Signed-off-by John Kacur <[email protected]>John Kacur (2):
rtla/timerlat: Add tests for option parsing with attached arguments
rtla: Add tests for option parsing with attached argumentstools/tracing/rtla/tests/hwnoise.t | 10 ++++++++++ tools/tracing/rtla/tests/osnoise.t | 18 ++++++++++++++++++ tools/tracing/rtla/tests/timerlat.t | 18 ++++++++++++++++++
This should be either one patch, or three patches (hwnoise, osnoise, timerlat); especially timerlat top and timerlat hist should not be split between two commits, as the tests are in the same file. Also, identical tests for both top and hist should use check_top_hist or check_top_q_hist, see commit c15c55c01e48 ("rtla/tests: Cover both top and hist tools where possible").
Anyway, I don't think this needs runtime tests. CLI unit tests (well, actually more like integration tests, as RTLA design doesn't have proper isolated unit tests) in tools/tracing/rtla/tests/unit/*_cli.c should be able to fully cover this, with the benefit of being much faster and not requiring root or any kernel features. Do you have any concerns that cannot be covered by unit testing?
Quoted 5 lines
3 files changed, 46 insertions(+)--
2.54.0
Tomas