On 9/10/25 4:47 AM, Ihar Hrachyshka wrote:
> When nsec == 0, ofp_print_duration will not add a fractional part. This
> may happen either when you are very lucky, or when you use a libc
> without nanosecond precision.
>
> Signed-off-by: Ihar Hrachyshka <[email protected]>
> ---
> tests/ofproto-dpif.at | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
Hi, Ihar. Thanks for the fixes!
The main issue of most of the tests below is that they are not using
the common ofctl_strip function and open-coding parts of it instead.
The ofctl_strip already handles the zero case properly, so since we're
touching these lines, we should just convert them to ofctl_strip, if
possible.
Note: oss-fuzz build failures are unrelated and should be fixed now.
One more comment below.
>
> diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at
> index a0cd4a5ce..17f309e76 100644
> --- a/tests/ofproto-dpif.at
> +++ b/tests/ofproto-dpif.at
> @@ -1270,7 +1270,7 @@ n_flows=ok n_buckets=ok
> # bucket4: 0 0
>
> ovs-appctl time/warp 1000
> -AT_CHECK([ovs-ofctl -O OpenFlow13 dump-group-stats br0 | sed
> 's/duration=[[0-9]]\.[[0-9]]*s,//' | check_group_stats 40 80 200 500],
> +AT_CHECK([ovs-ofctl -O OpenFlow13 dump-group-stats br0 | sed
> 's/duration=[[0-9\.]]*s,//' | check_group_stats 40 80 200 500],
> [0], [dnl
> bucket0 >= 40
> bucket1 >= 80
> @@ -6885,7 +6885,7 @@ AT_CHECK([ovs-appctl netdev-dummy/receive p1 "$flow"],
> [0], [stdout])
>
> # Check flow stats
> AT_CHECK([ovs-ofctl dump-flows br0], [0], [stdout])
> -AT_CHECK([strip_xids < stdout | sed -n
> 's/duration=[[0-9]]*\.[[0-9]]*s/duration=0.0s/p' | sed -n
> 's/idle_age=[[0-9]]*/idle_age=0/p' | grep 'table=2'], [0], [dnl
> +AT_CHECK([strip_xids < stdout | sed -n
> 's/duration=[[0-9\.]]*s/duration=0.0s/p' | sed -n
> 's/idle_age=[[0-9]]*/idle_age=0/p' | grep 'table=2'], [0], [dnl
> cookie=0x0, duration=0.0s, table=2, n_packets=1, n_bytes=106, idle_age=0,
> reg1=0x1 actions=output:2
> ])
>
> @@ -6920,7 +6920,7 @@ AT_CHECK([ovs-appctl netdev-dummy/receive p1 "$flow"],
> [0], [stdout])
>
> # Check flow stats
> AT_CHECK([ovs-ofctl dump-flows br0], [0], [stdout])
> -AT_CHECK([strip_xids < stdout | sed -n
> 's/duration=[[0-9]]*\.[[0-9]]*s/duration=0.0s/p' | sed -n
> 's/idle_age=[[0-9]]*/idle_age=0/p' | grep 'table=2'], [0], [dnl
> +AT_CHECK([strip_xids < stdout | sed -n
> 's/duration=[[0-9\.]]*s/duration=0.0s/p' | sed -n
> 's/idle_age=[[0-9]]*/idle_age=0/p' | grep 'table=2'], [0], [dnl
> cookie=0x0, duration=0.0s, table=2, n_packets=1, n_bytes=106, idle_age=0,
> ct_state=+new+trk,icmp,in_port=1 actions=output:2
> ])
>
> @@ -7012,7 +7012,7 @@ AT_CHECK([ovs-appctl netdev-dummy/receive p0 "$flow"],
> [0], [stdout])
>
> # Check flow stats
> AT_CHECK([ovs-ofctl dump-flows br1], [0], [stdout])
> -AT_CHECK([strip_xids < stdout | sed -n
> 's/duration=[[0-9]]*\.[[0-9]]*s/duration=0.0s/p' | sed -n
> 's/idle_age=[[0-9]]*/idle_age=0/p' | grep 'table=3' | grep -v 'commit'], [0],
> [dnl
> +AT_CHECK([strip_xids < stdout | sed -n
> 's/duration=[[0-9\.]]*s/duration=0.0s/p' | sed -n
> 's/idle_age=[[0-9]]*/idle_age=0/p' | grep 'table=3' | grep -v 'commit'], [0],
> [dnl
> cookie=0x0, duration=0.0s, table=3, n_packets=1, n_bytes=106, idle_age=0,
> icmp,in_port=1 actions=output:2
> ])
>
> @@ -9248,7 +9248,7 @@ done
> AT_CHECK([ovs-appctl time/warp 1000], [0], [ignore])
> AT_CHECK([ovs-appctl revalidator/purge], [0])
> AT_CHECK([ovs-ofctl dump-flows br0], [0], [stdout])
> -AT_CHECK([strip_xids < stdout | sed -n
> 's/duration=[[0-9]]*\.[[0-9]]*s/duration=0.0s/p' | sort], [0], [dnl
> +AT_CHECK([strip_xids < stdout | sed -n
> 's/duration=[[0-9\.]]*s/duration=0.0s/p' | sort], [0], [dnl
> cookie=0x0, duration=0.0s, table=0, n_packets=0, n_bytes=0, idle_age=1,
> icmp actions=NORMAL
> cookie=0x0, duration=0.0s, table=0, n_packets=10, n_bytes=1180, idle_age=1,
> ip actions=NORMAL
> ])
> @@ -9273,7 +9273,7 @@ warp_and_dump_NXM () {
> else
> expected=" cookie=0x0, duration=$1s, table=0, n_packets=$2,
> n_bytes=$3, idle_age=$4, ip actions=NORMAL"
> fi
> - AT_CHECK_UNQUOTED([strip_xids < stdout | sed -n
> 's/duration=\([[0-9]]*\)\.*[[0-9]]*s/duration=\1s/p' | sort], [0], [dnl
> + AT_CHECK_UNQUOTED([strip_xids < stdout | sed -n
> 's/duration=\([[0-9\.]]*\)s/duration=\1s/p' | sort], [0], [dnl
These functions are different though, they are extracting explicit duration
values stripping out the fractions. But with this change, the fractions will
not be stripped out anymore and that may cause some test failures, depending
on the time stop and warping. The missing fractional part is also already
handled there with a zero-or-more match, so I'm not sure if we need to change
these functions.
Best regards, Ilya Maximets.
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev