Lines Matching +full:self +full:- +full:test
7 # June 1991 as shown in the file COPYING in the top-level directory of this
53 log_level -= sub
116 stdout = stdout.decode("utf-8")
117 stderr = stderr.decode("utf-8")
122 if stderr[-1] == "\n":
123 stderr = stderr[:-1]
132 if len(stderr) > 0 and stderr[-1] == "\n":
133 stderr = stderr[:-1]
142 cmd("rm -f %s" % (f))
174 return tool("bpftool", args, {"json":"-p"}, JSON=JSON, ns=ns,
234 args = "-force " + args
235 return tool("ip", args, {"json":"-j"}, JSON=JSON, ns=ns,
239 return tool("tc", args, {"json":"-p"}, JSON=JSON, ns=ns,
288 def __init__(self, path): argument
289 self.path = path
290 self._dict = self._debugfs_dir_read(path)
292 def __len__(self): argument
293 return len(self._dict.keys())
295 def __getitem__(self, key): argument
297 key = list(self._dict.keys())[key]
298 return self._dict[key]
300 def __setitem__(self, key, value): argument
304 cmd("echo '%s' > %s/%s" % (value, self.path, key))
307 _, out = cmd('cat %s/%s' % (self.path, key))
308 self._dict[key] = out.strip()
310 def _debugfs_dir_read(self, path): argument
346 def __init__(self, port_count=1, ns=None): argument
348 devs.append(self)
350 def _make_port(self, port_index, ifname): argument
351 return BpfNetdevSim(self, port_index, ifname, self.ns)
353 def dfs_num_bound_progs(self): argument
354 path = os.path.join(self.dfs_dir, "bpf_bound_progs")
358 def dfs_get_bound_progs(self, expected): argument
359 progs = DebugfsDir(os.path.join(self.dfs_dir, "bpf_bound_progs"))
366 def remove(self): argument
368 devs.remove(self)
376 def __init__(self, nsimdev, port_index, ifname, ns=None): argument
379 self.dfs_dir = "%s/ports/%u/" % (nsimdev.dfs_dir, port_index)
380 self.dfs_refresh()
382 def __getitem__(self, key): argument
383 return self.dev[key]
385 def remove(self): argument
386 self.nsimdev.remove_nsim(self)
388 def dfs_refresh(self): argument
389 self.dfs = DebugfsDir(self.dfs_dir)
390 return self.dfs
392 def dfs_read(self, f): argument
393 path = os.path.join(self.dfs_dir, f)
397 def wait_for_flush(self, bound=0, total=0, n_retry=20): argument
399 nbound = self.nsimdev.dfs_num_bound_progs()
406 def set_ns(self, ns): argument
408 ip("link set dev %s netns %s" % (self.dev["ifname"], name), ns=self.ns)
409 self.ns = ns
411 def set_mtu(self, mtu, fail=True): argument
412 return ip("link set dev %s mtu %d" % (self.dev["ifname"], mtu),
415 def set_xdp(self, bpf, mode, force=False, JSON=True, verbose=False, argument
419 return ip("link set dev %s xdp%s %s" % (self.dev["ifname"], mode, bpf),
423 def unset_xdp(self, mode, force=False, JSON=True, argument
425 return ip("link set dev %s xdp%s off" % (self.dev["ifname"], mode),
429 def ip_link_show(self, xdp): argument
430 _, link = ip("link show dev %s" % (self['ifname']))
440 def tc_add_ingress(self): argument
441 tc("qdisc add dev %s ingress" % (self['ifname']))
443 def tc_del_ingress(self): argument
444 tc("qdisc del dev %s ingress" % (self['ifname']))
446 def tc_flush_filters(self, bound=0, total=0): argument
447 self.tc_del_ingress()
448 self.tc_add_ingress()
449 self.wait_for_flush(bound=bound, total=total)
451 def tc_show_ingress(self, expected=None): argument
456 args = "-s filter show dev %s ingress" % (self['ifname'])
482 def cls_filter_op(self, op, qdisc="ingress", prio=None, handle=None, argument
494 .format(op=op, dev=self['ifname'], qdisc=qdisc, spec=spec,
498 def cls_bpf_add_filter(self, bpf, op="add", prio=None, handle=None, argument
514 return self.cls_filter_op(op=op, prio=prio, handle=handle, cls=cls,
518 def set_ethtool_tc_offloads(self, enable, fail=True): argument
519 args = "hw-tc-offload %s" % ("on" if enable else "off")
520 return ethtool(self, "-K", args, fail=fail)
529 cmd("rm -f %s" % (f))
560 fail(err["error"].find("No such device") == -1,
628 start_test("Test multi-attachment XDP - %s + offload..." %
648 start_test("Test multi-attachment XDP - replace...")
650 fail(ret == 0, "Replaced one of programs without -force")
653 start_test("Test multi-attachment XDP - remove without mode...")
672 start_test("Test multi-attachment XDP - reattach...")
680 start_test("Test multi-attachment XDP - device remove...")
690 parser.add_argument("--log", help="output verbose log to given file")
694 logfile.write("# -*-Org-*-")
700 skip(os.getuid() != 0, "test must be run as root")
719 if out.find("/sys/kernel/debug type debugfs") == -1:
720 cmd("mount -t debugfs none /sys/kernel/debug")
732 if err.find("Error: Failed to find qdisc with specified handle.") == -1:
747 start_test("Test destruction of generic XDP...")
758 start_test("Test TC non-offloaded...")
762 start_test("Test TC non-offloaded isn't getting bound...")
769 start_test("Test TC offloads are off by default...")
779 start_test("Test TC offload by default...")
789 start_test("Test TC cBPF bytcode tries offload by default...")
800 start_test("Test TC cBPF unbound bytecode doesn't offload...")
808 start_test("Test non-0 chain offload...")
816 start_test("Test TC replace...")
829 start_test("Test TC replace bad flags...")
836 "Software TC incorrect load in replace test, iteration %d" %
840 start_test("Test spurious extack from the driver...")
853 start_test("Test TC offloads failure...")
861 start_test("Test TC offloads work...")
866 start_test("Test TC offload basics...")
878 start_test("Test TC offload is device-bound...")
885 start_test("Test disabling TC offloads is rejected while filters installed...")
890 start_test("Test qdisc removal frees things...")
894 start_test("Test disabling TC offloads is OK without filters...")
901 start_test("Test destroying device gets rid of TC filters...")
910 start_test("Test destroying device gets rid of XDP...")
919 start_test("Test XDP prog reporting...")
926 start_test("Test XDP prog replace without force...")
928 fail(ret == 0, "Replaced XDP program without -force")
931 start_test("Test XDP prog replace with force...")
933 fail(ret != 0, "Could not replace XDP program with -force")
940 "Device parameters reported for non-offloaded program")
942 start_test("Test XDP prog replace with bad flags...")
950 start_test("Test MTU restrictions...")
963 start_test("Test non-offload XDP attaching to HW...")
968 fail(ret == 0, "attached non-offloaded XDP program to HW")
969 check_extack_nsim(err, "xdpoffload of non-bound program.", args)
972 start_test("Test offload XDP attaching to drv...")
982 start_test("Test XDP load failure...")
991 start_test("Test XDP offload...")
999 start_test("Test XDP offload is device bound...")
1009 start_test("Test removing XDP program many times...")
1018 start_test("Test attempt to use a program for a wrong device...")
1040 start_test("Test mixing of TC and XDP...")
1055 start_test("Test binding TC from pinned...")
1061 start_test("Test binding XDP from pinned...")
1070 start_test("Test offload of wrong type fails...")
1074 start_test("Test asking for TC offload of two filters...")
1083 start_test("Test if netdev removal waits for translation...")
1096 time_diff = end - start
1111 start_test("Test loading program with maps...")
1114 start_test("Test bpftool bound info reporting (own ns)...")
1117 start_test("Test bpftool bound info reporting (other ns)...")
1122 start_test("Test bpftool bound info reporting (remote ns)...")
1125 start_test("Test bpftool bound info reporting (back to own ns)...")
1133 start_test("Test bpftool bound info reporting (removed dev)...")
1143 start_test("Test map update (no flags)...")
1159 start_test("Test map update (exists)...")
1169 fail(ret == 0, "updated non-existing key")
1170 fail(err["error"].find("No such file or directory") == -1,
1173 start_test("Test map update (noexist)...")
1180 fail(err["error"].find("File exists") == -1,
1183 start_test("Test map dump...")
1192 start_test("Test map getnext...")
1204 fail(err["error"].find("No such file or directory") == -1,
1207 start_test("Test map delete (htab)...")
1211 start_test("Test map delete (array)...")
1216 fail(err["error"].find("No such file or directory") == -1,
1219 start_test("Test map remove...")
1230 start_test("Test map creation fail path...")
1240 start_test("Test multi-dev ASIC program reuse...")
1259 start_test("Test multi-dev ASIC cross-dev replace...")
1261 fail(ret == 0, "cross-ASIC program allowed")
1264 fail(ret == 0, "cross-ASIC program allowed")
1266 start_test("Test multi-dev ASIC cross-dev install...")
1272 fail(ret == 0, "cross-ASIC program allowed")
1277 fail(ret == 0, "cross-ASIC program allowed")
1280 start_test("Test multi-dev ASIC cross-dev map reuse...")
1298 "error message missing for cross-ASIC map")
1306 "error message missing for cross-ASIC map")
1308 start_test("Test multi-dev ASIC cross-dev destruction...")
1319 start_test("Test multi-dev ASIC cross-dev destruction - move...")
1332 start_test("Test multi-dev ASIC cross-dev destruction - orphaned...")