Repository navigation
sipp-rs: take a time unit on -rp, -d and -recv_timeout - #1296
Conversation
|
Thanks, this looks good: One suggestion: the shell tests in let bad = || format!("{opt}, \"{v}\" is not a valid time!");
let n: f64 = v[..split].parse().map_err(|_| bad())?;
// ...
_ => return Err(bad()),Then #!/bin/sh
# This regression test is a part of SIPp.
# -rp, -d and -recv_timeout take a time unit, milliseconds by default,
# and refuse an unknown one.
. "`dirname "$0"`/../functions"; init
for opt in -rp -d -recv_timeout; do
for v in 2000 5s 250ms 1m; do
out=`sippfg -sn uac -i 127.0.0.1 -p 24500 -m 1 -timeout 1s \
$opt $v 127.0.0.1:24501 2>&1`
test $? = 255 && fail "$opt $v refused: $out"
done
out=`sippfg -sn uac -i 127.0.0.1 -p 24500 $opt 5x 127.0.0.1:24501 2>&1`
case $out in
*"$opt, \"5x\" is not a valid time!"*) ;;
*) fail "$opt 5x: $out" ;;
esac
done
okIt passes with C SIPp and fails with sipp-rs on master ( Minor: the second commit only extends the test, so it could be squashed into the first. |
SIPp parses these as times whose default unit is milliseconds, so "-rp 5s" means five seconds; sipp-rs's own help gives "-r 10 -rp 5s" as an example. sipp-rs parsed them as plain integers and exited with '-rp, "5s" is not a valid integer!', so a command line that works with SIPp fails before sending anything. They now go through duration_ms(), as -T2, -deadcall_wait and the other millisecond options already do. A bare number still means milliseconds. A bad time now fails with get_time()'s message, '<opt>, "<v>" is not a valid time!', for every time option, so regress/github-#1296 can check the error against both SIPp and sipp-rs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6bf4b0c to
ab0ed4c
Compare
|
Thanks for the review, all three done and squashed into one commit:
|
|
Thank you! |
SIPp parses
-rp,-dand-recv_timeoutas times with a default unit of milliseconds, so-rp 5smeans five seconds. sipp-rs's own-htext gives-r 10 -rp 5sas an example. sipp-rs parsed these three as plain integers, so a SIPp command line that uses a unit fails before sending anything:This PR parses the three options with
duration_ms(), which-T2,-deadcall_wait,-reconnect_sleepand the other millisecond options already use. A bare number still means milliseconds, so existing command lines are unaffected. I compared every optionsrc/sipp.cppdeclares asSIPP_OPTION_TIME_*with its sipp-rs parser, and these were the only three still taking an integer.-send_timeoutand the-watchdog_*thresholds are accepted and ignored, so they never reject a unit.Tests:
regress/github-#1296runs each option with2000,5s,250msand1m, and checks that5xfails with SIPp's-rp, "5x" is not a valid time!. It runs against both binaries and fails on sipp-rs master with the error above.millisecond_options_take_a_unitchecks the parsed values.cargo test --workspace --lockedpasses.A bad value for any time option now fails with
get_time()'s message instead of sipp-rs's own wording, so the shell test can share the check with C.No help text or docs change: the help already describes this behaviour.
🤖 Generated with Claude Code