The tests: The gate action now caps the base time and the cycle time at KTIME_MAX. Cover the accepted upper bound and both refusals. The accepted values: A base time and a cycle time of exactly KTIME_MAX install, and the read-back must show the value that was installed rather than only the index. The refusals: -1 reaches the kernel as the largest u64, above KTIME_MAX, so it is refused as out of range. The negative cycle time is tested against a base time that is itself accepted, so the case pins the cycle bound instead of whichever bound is checked first. Context note: tc does not print the same error line on every build: without libmnl it prints the strerror text, with libmnl the kernel's own message. The cases accept either. The values are signed decimals on purpose: iproute2 falls back to strtod() above S64_MAX and the conversion is undefined, so such an input is refused on x86 and installs on the architectures that saturate it. Signed-off-by: Jamal Hadi Salim --- .../tc-testing/tc-tests/actions/gate.json | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/gate.json b/tools/testing/selftests/tc-testing/tc-tests/actions/gate.json index db645c22ad7b..e5450557751d 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/actions/gate.json +++ b/tools/testing/selftests/tc-testing/tc-tests/actions/gate.json @@ -347,5 +347,113 @@ "teardown": [ "$TC action flush action gate" ] + }, + { + "id": "7d1f", + "name": "Add gate action with the maximum base time", + "category": [ + "actions", + "gate" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + [ + "$TC actions flush action gate", + 0, + 1, + 255 + ] + ], + "cmdUnderTest": "$TC action add action gate base-time 9223372036854775807 sched-entry close 1000000ns index 201", + "expExitCode": "0", + "verifyCmd": "$TC -j action get action gate index 201", + "matchPattern": "\"base_time\":9223372036854775807", + "matchCount": "1", + "teardown": [ + "$TC actions flush action gate" + ] + }, + { + "id": "9f10", + "name": "Add gate action with the maximum cycle time", + "category": [ + "actions", + "gate" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + [ + "$TC actions flush action gate", + 0, + 1, + 255 + ] + ], + "cmdUnderTest": "$TC action add action gate cycle-time 9223372036854775807 sched-entry close 1000000ns index 301", + "expExitCode": "0", + "verifyCmd": "$TC -j action get action gate index 301", + "matchPattern": "\"cycle_time\":9223372036854775807", + "matchCount": "1", + "teardown": [ + "$TC actions flush action gate" + ] + }, + { + "id": "5c47", + "name": "Reject gate action with a negative base time", + "category": [ + "actions", + "gate" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + [ + "$TC actions flush action gate", + 0, + 1, + 255 + ] + ], + "cmdUnderTest": "$TC action add action gate base-time -1 sched-entry close 1000000ns index 401", + "expExitCode": "255", + "verifyCmd": "$TC action add action gate base-time -1 sched-entry close 1000000ns index 401 2>&1", + "matchPattern": "integer out of range|RTNETLINK answers: Numerical result out of range", + "matchCount": "1", + "teardown": [ + "$TC actions flush action gate" + ] + }, + { + "id": "b3c3", + "name": "Reject gate action with a negative cycle time", + "category": [ + "actions", + "gate" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + [ + "$TC actions flush action gate", + 0, + 1, + 255 + ] + ], + "cmdUnderTest": "$TC action add action gate base-time 9223372036854775807 cycle-time -1 sched-entry close 1000000ns index 402", + "expExitCode": "255", + "verifyCmd": "$TC action add action gate base-time 9223372036854775807 cycle-time -1 sched-entry close 1000000ns index 402 2>&1", + "matchPattern": "integer out of range|RTNETLINK answers: Numerical result out of range", + "matchCount": "1", + "teardown": [ + "$TC actions flush action gate" + ] } ] -- 2.34.1