Skip to content

Commit 2df6bde

Browse files
committed
Merge branch 'selftests-tc-testing-updates-and-cleanups-for-tdc'
Pedro Tammela says: ==================== selftests: tc-testing: updates and cleanups for tdc Address the recommendations from the previous series and cleanup some leftovers. ==================== Link: https://lore.kernel.org/r/20231124154248.315470-1-pctammela@mojatatu.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents cae0de4 + ed346fc commit 2df6bde

File tree

9 files changed

+25
-130
lines changed

9 files changed

+25
-130
lines changed
Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,6 @@
11
# SPDX-License-Identifier: GPL-2.0
2-
include ../../../scripts/Makefile.include
32

4-
top_srcdir = $(abspath ../../../..)
5-
APIDIR := $(top_scrdir)/include/uapi
6-
TEST_GEN_FILES = action.o
3+
TEST_PROGS += ./tdc.sh
4+
TEST_FILES := action-ebpf tdc*.py Tdc*.py plugins plugin-lib tc-tests scripts
75

86
include ../lib.mk
9-
10-
PROBE := $(shell $(LLC) -march=bpf -mcpu=probe -filetype=null /dev/null 2>&1)
11-
12-
ifeq ($(PROBE),)
13-
CPU ?= probe
14-
else
15-
CPU ?= generic
16-
endif
17-
18-
CLANG_SYS_INCLUDES := $(shell $(CLANG) -v -E - </dev/null 2>&1 \
19-
| sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }')
20-
21-
CLANG_FLAGS = -I. -I$(APIDIR) \
22-
$(CLANG_SYS_INCLUDES) \
23-
-Wno-compare-distinct-pointer-types
24-
25-
$(OUTPUT)/%.o: %.c
26-
$(CLANG) $(CLANG_FLAGS) \
27-
-O2 --target=bpf -emit-llvm -c $< -o - | \
28-
$(LLC) -march=bpf -mcpu=$(CPU) $(LLC_FLAGS) -filetype=obj -o $@
29-
30-
TEST_PROGS += ./tdc.sh
31-
TEST_FILES := tdc*.py Tdc*.py plugins plugin-lib tc-tests scripts

tools/testing/selftests/tc-testing/README

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,6 @@ directory:
195195
and the other is a test whether the command leaked memory or not.
196196
(This one is a preliminary version, it may not work quite right yet,
197197
but the overall template is there and it should only need tweaks.)
198-
- buildebpfPlugin.py:
199-
builds all programs in $EBPFDIR.
200198

201199

202200
ACKNOWLEDGEMENTS
856 Bytes
Binary file not shown.

tools/testing/selftests/tc-testing/plugin-lib/buildebpfPlugin.py

Lines changed: 0 additions & 67 deletions
This file was deleted.

tools/testing/selftests/tc-testing/plugin-lib/nsPlugin.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ def __init__(self):
2323
super().__init__()
2424

2525
def pre_suite(self, testcount, testlist):
26-
from itertools import cycle
27-
2826
super().pre_suite(testcount, testlist)
2927

3028
def prepare_test(self, test):
@@ -37,7 +35,7 @@ def prepare_test(self, test):
3735
if netlink == True:
3836
self._nl_ns_create()
3937
else:
40-
self._ns_create()
38+
self._ipr2_ns_create()
4139

4240
# Make sure the netns is visible in the fs
4341
ticks = 20
@@ -71,14 +69,14 @@ def post_case(self):
7169
if netlink == True:
7270
self._nl_ns_destroy()
7371
else:
74-
self._ns_destroy()
72+
self._ipr2_ns_destroy()
7573

7674
def post_suite(self, index):
7775
if self.args.verbose:
7876
print('{}.post_suite'.format(self.sub_class))
7977

8078
# Make sure we don't leak resources
81-
cmd = "$IP -a netns del"
79+
cmd = self._replace_keywords("$IP -a netns del")
8280

8381
if self.args.verbose > 3:
8482
print('_exec_cmd: command "{}"'.format(cmd))
@@ -161,7 +159,7 @@ def _nl_ns_create(self):
161159
ticks -= 1
162160
continue
163161

164-
def _ns_create_cmds(self):
162+
def _ipr2_ns_create_cmds(self):
165163
cmds = []
166164

167165
ns = self.args.NAMES['NS']
@@ -181,26 +179,26 @@ def _ns_create_cmds(self):
181179

182180
return cmds
183181

184-
def _ns_create(self):
182+
def _ipr2_ns_create(self):
185183
'''
186184
Create the network namespace in which the tests will be run and set up
187185
the required network devices for it.
188186
'''
189-
self._exec_cmd_batched('pre', self._ns_create_cmds())
187+
self._exec_cmd_batched('pre', self._ipr2_ns_create_cmds())
190188

191189
def _nl_ns_destroy(self):
192190
ns = self.args.NAMES['NS']
193191
netns.remove(ns)
194192

195-
def _ns_destroy_cmd(self):
193+
def _ipr2_ns_destroy_cmd(self):
196194
return self._replace_keywords('netns delete {}'.format(self.args.NAMES['NS']))
197195

198-
def _ns_destroy(self):
196+
def _ipr2_ns_destroy(self):
199197
'''
200198
Destroy the network namespace for testing (and any associated network
201199
devices as well)
202200
'''
203-
self._exec_cmd('post', self._ns_destroy_cmd())
201+
self._exec_cmd('post', self._ipr2_ns_destroy_cmd())
204202

205203
@cached_property
206204
def _proc(self):

tools/testing/selftests/tc-testing/tc-tests/actions/bpf.json

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@
5454
"actions",
5555
"bpf"
5656
],
57-
"plugins": {
58-
"requires": "buildebpfPlugin"
59-
},
6057
"setup": [
6158
[
6259
"$TC action flush action bpf",
@@ -65,10 +62,10 @@
6562
255
6663
]
6764
],
68-
"cmdUnderTest": "$TC action add action bpf object-file $EBPFDIR/action.o section action-ok index 667",
65+
"cmdUnderTest": "$TC action add action bpf object-file $EBPFDIR/action-ebpf section action-ok index 667",
6966
"expExitCode": "0",
7067
"verifyCmd": "$TC action get action bpf index 667",
71-
"matchPattern": "action order [0-9]*: bpf action.o:\\[action-ok\\] id [0-9].* tag [0-9a-f]{16}( jited)? default-action pipe.*index 667 ref",
68+
"matchPattern": "action order [0-9]*: bpf action-ebpf:\\[action-ok\\] id [0-9].* tag [0-9a-f]{16}( jited)? default-action pipe.*index 667 ref",
7269
"matchCount": "1",
7370
"teardown": [
7471
"$TC action flush action bpf"
@@ -81,9 +78,6 @@
8178
"actions",
8279
"bpf"
8380
],
84-
"plugins": {
85-
"requires": "buildebpfPlugin"
86-
},
8781
"setup": [
8882
[
8983
"$TC action flush action bpf",
@@ -92,10 +86,10 @@
9286
255
9387
]
9488
],
95-
"cmdUnderTest": "$TC action add action bpf object-file $EBPFDIR/action.o section action-ko index 667",
89+
"cmdUnderTest": "$TC action add action bpf object-file $EBPFDIR/action-ebpf section action-ko index 667",
9690
"expExitCode": "255",
9791
"verifyCmd": "$TC action get action bpf index 667",
98-
"matchPattern": "action order [0-9]*: bpf action.o:\\[action-ko\\] id [0-9].*index 667 ref",
92+
"matchPattern": "action order [0-9]*: bpf action-ebpf:\\[action-ko\\] id [0-9].*index 667 ref",
9993
"matchCount": "0",
10094
"teardown": [
10195
[

tools/testing/selftests/tc-testing/tc-tests/filters/bpf.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,16 @@
5252
],
5353
"plugins": {
5454
"requires": [
55-
"buildebpfPlugin",
5655
"nsPlugin"
5756
]
5857
},
5958
"setup": [
6059
"$TC qdisc add dev $DEV1 ingress"
6160
],
62-
"cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf object-file $EBPFDIR/action.o section action-ok",
61+
"cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf object-file $EBPFDIR/action-ebpf section action-ok",
6362
"expExitCode": "0",
6463
"verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf",
65-
"matchPattern": "filter parent ffff: protocol ip pref 100 bpf chain [0-9]+ handle 0x1 action.o:\\[action-ok\\].*tag [0-9a-f]{16}( jited)?",
64+
"matchPattern": "filter parent ffff: protocol ip pref 100 bpf chain [0-9]+ handle 0x1 action-ebpf:\\[action-ok\\].*tag [0-9a-f]{16}( jited)?",
6665
"matchCount": "1",
6766
"teardown": [
6867
"$TC qdisc del dev $DEV1 ingress"
@@ -77,17 +76,16 @@
7776
],
7877
"plugins": {
7978
"requires": [
80-
"buildebpfPlugin",
8179
"nsPlugin"
8280
]
8381
},
8482
"setup": [
8583
"$TC qdisc add dev $DEV1 ingress"
8684
],
87-
"cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf object-file $EBPFDIR/action.o section action-ko",
85+
"cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf object-file $EBPFDIR/action-ebpf section action-ko",
8886
"expExitCode": "1",
8987
"verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf",
90-
"matchPattern": "filter parent ffff: protocol ip pref 100 bpf chain [0-9]+ handle 0x1 action.o:\\[action-ko\\].*tag [0-9a-f]{16}( jited)?",
88+
"matchPattern": "filter parent ffff: protocol ip pref 100 bpf chain [0-9]+ handle 0x1 action-ebpf:\\[action-ko\\].*tag [0-9a-f]{16}( jited)?",
9189
"matchCount": "0",
9290
"teardown": [
9391
"$TC qdisc del dev $DEV1 ingress"

tools/testing/selftests/tc-testing/tdc.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -497,11 +497,6 @@ def prepare_run(pm, args, testlist):
497497
pm.call_post_suite(1)
498498
return emergency_exit_message
499499

500-
if args.verbose:
501-
print('give test rig 2 seconds to stabilize')
502-
503-
time.sleep(2)
504-
505500
def purge_run(pm, index):
506501
pm.call_post_suite(index)
507502

@@ -1023,7 +1018,11 @@ def main():
10231018
if args.verbose > 2:
10241019
print('args is {}'.format(args))
10251020

1026-
set_operation_mode(pm, parser, args, remaining)
1021+
try:
1022+
set_operation_mode(pm, parser, args, remaining)
1023+
except KeyboardInterrupt:
1024+
# Cleanup on Ctrl-C
1025+
pm.call_post_suite(None)
10271026

10281027
if __name__ == "__main__":
10291028
main()

tools/testing/selftests/tc-testing/tdc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@ try_modprobe sch_hfsc
6464
try_modprobe sch_hhf
6565
try_modprobe sch_htb
6666
try_modprobe sch_teql
67-
./tdc.py -J`nproc` -c actions --nobuildebpf
67+
./tdc.py -J`nproc` -c actions
6868
./tdc.py -J`nproc` -c qdisc

0 commit comments

Comments
 (0)