ci: the host oracle compares the netlink sockets and the public destinations of each kind on Linux
The whole-run trace of the host oracle now also records, per process kind, every netlink socket the tree opens (by protocol: NETLINK_ROUTE, NETLINK_KOBJECT_UEVENT, ...), the requests it sends on it (RTM_GETLINK, RTM_GETADDR, ..., read from strace's decoding or from the message bytes) and the multicast groups it binds to, and every connect or send towards a public address, with transport, family, address and port. A socket is known by the inode -y prints for it, so a send names the protocol of the socket() that made it, whichever thread sends. The set per kind enters the comparison like the host paths: identical, no exception. Loopback, the lab's documentation ranges (192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24), private, link-local and multicast destinations are not compared and are counted by class as evidence. The warm-up report lists the network entries only the warm-up had. The strace stand-in traces socket, connect, bind, sendto, sendmsg and sendmmsg only when the host oracle asks (network=True); the font tests' default is unchanged. Windows is not covered and the report says why: the connect and send events are in the Microsoft-Windows-Kernel-Network provider, which needs a second provider in the session, logs every packet of the machine and has no field names verified on a hosted runner yet; interface enumeration there is NSI by IOCTL, not a socket.
This commit is contained in:
1 parent
9bd7622e83
commit
d4f4f86d88
3 files changed
+371
-24
No files matched your search
+207
-18
@@ -6,29 +6,35 @@ change (a helper that is no longer spawned, a path of the machine it did not tou
|
||||
TRACE of the run, from the launch to the exit of the browser (the quiet point is the exit of the process, not a wait), after the same short
|
||||
journey (the first steps of the fake web's P4 walk, tests/fakeweb/profile_p4.py, no internet, driven by the stock Playwright client).
|
||||
|
||||
Two things are compared, over the whole trace:
|
||||
Three things are compared, over the whole trace:
|
||||
|
||||
* the processes, by KIND, from the command lines of the launch: the parent, `-contentproc` with its type, `-sandboxingKind N` and
|
||||
`-isForBrowser` / `-notForBrowser`, and the helpers (glxtest, pingsender, ...) by what they ran. Every kind and its COUNT must be identical,
|
||||
with one exception: for the content processes of type `tab` only the presence of the kind counts, because how many are alive follows the idle
|
||||
time (a spare process is prelaunched after a delay and closed after a grace period);
|
||||
* the files: every path the tree touched (opened, stat'ed, accessed, read as a link, executed), classified `ours` or `host`. The SET of host
|
||||
paths must be identical, no exception. `ours` leaves the comparison as a class (OURS below: reading its own package is not touching the host).
|
||||
paths must be identical, no exception. `ours` leaves the comparison as a class (OURS below: reading its own package is not touching the host);
|
||||
* the network, per kind (Linux): every NETLINK socket the tree opens, by protocol (NETLINK_ROUTE, NETLINK_KOBJECT_UEVENT, ...), with the requests
|
||||
it sends on it (RTM_GETLINK, RTM_GETADDR, ...) and the multicast groups it binds to, and every connect or send towards a PUBLIC address, with
|
||||
the transport, the family, the address and the port. The SET per kind must be identical, no exception, like the host paths. A destination that
|
||||
is loopback, the lab's (the documentation ranges of LAB_NETWORKS), private or link-local, or a multicast group is not compared: it is counted
|
||||
by class (NET_NOT_COMPARED). On Windows it is not covered (NET_WINDOWS says why).
|
||||
|
||||
The trace is of the TREE of the launch only: what a process outside it does (on Windows a service, the antivirus) is not the engine's, so it is left out of
|
||||
the comparison and the report says how many paths each outside process name touched (`OUTSIDE THE TREE`). A path or a kind that differs names the processes
|
||||
to blame (`by A: ... | B: ...`: who touched the path, who spawned the kind).
|
||||
|
||||
Each engine run starts with a discarded WARM-UP launch (the first seed), an experiment control and not an excuse: its trace is kept in the footprint and the
|
||||
report lists what only the warm-up did (`WARMUP-ONLY`, per kind and per path, with the process that did it), so that a first-launch-only behaviour (a
|
||||
report lists what only the warm-up did (`WARMUP-ONLY`, per kind, per path and per net entry, with the process that did it), so that a first-launch-only behaviour (a
|
||||
helper spawned at the first shutdown of a cold machine) stays visible from run to run. The measured launches are compared as they are: a kind or a count that differs
|
||||
after the warm-up is red.
|
||||
|
||||
How the trace is taken:
|
||||
|
||||
* Linux: `strace -f -y` of the whole tree (the stand-in of tests/_strace_stand_in.py), calls execve, clone, fork, prctl and the file calls
|
||||
(open, openat, stat, access, readlink, ...). The tree is named by what each process ran, or called itself when it forked without exec
|
||||
(the forkserver's children), and the log is read after the tree has exited.
|
||||
* Linux: `strace -f -y` of the whole tree (the stand-in of tests/_strace_stand_in.py), calls execve, clone, fork, prctl, the file calls
|
||||
(open, openat, stat, access, readlink, ...) and the network calls (socket, connect, bind, sendto, sendmsg, sendmmsg). The tree is named by
|
||||
what each process ran, or called itself when it forked without exec (the forkserver's children), and the log is read after the tree has exited.
|
||||
A socket is known by the inode `-y` prints for it (`5<socket:[1234]>`), so a send names the protocol of the socket() that made it.
|
||||
* Windows: the process starts WITH their command lines come from the Security log, event 4688 (the process-creation audit with the command
|
||||
line, switched on for the run and put back after it): the kernel writes one per process, so a short-lived child cannot be missed, which a
|
||||
poll of the job's pids can. The files come from an ETW session on Microsoft-Windows-Kernel-File (the Create events: every path a process
|
||||
@@ -51,6 +57,7 @@ from __future__ import annotations
|
||||
import argparse
|
||||
import codecs
|
||||
import collections
|
||||
import ipaddress
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
@@ -80,9 +87,10 @@ JOURNEY = (("open home", "s1_open_home"),
|
||||
("nav Category", "s7_nav_category"))
|
||||
#: What a seed's footprint must hold at least, per category of leaf: a footprint that holds less did not see the run.
|
||||
#: Provisional: the first A/A on both systems gives the real numbers (they are in diff.json, "leaves").
|
||||
#: There is no floor for `net`: a run that opens no netlink socket and sends nothing to a public address is a run that can exist.
|
||||
FLOORS = {"proc": 3, "file": 100}
|
||||
#: The categories of leaf a footprint has.
|
||||
CATEGORIES = ("proc", "file")
|
||||
CATEGORIES = ("proc", "file", "net")
|
||||
MISSING = "<missing>"
|
||||
#: Seconds a closed run is given to exit (an acquisition limit, never read by a verdict: `trace.exited` says whether the tree had gone).
|
||||
EXIT_LIMIT_S, EXIT_PERIOD_S = 120.0, 0.25
|
||||
@@ -466,6 +474,162 @@ def spawned_counts(procs: dict) -> dict:
|
||||
return dict(sorted(collections.Counter(p["label"] for p in procs.values()).items()))
|
||||
|
||||
|
||||
# -
|
||||
# Linux: the network of the tree. A page cannot read it, a release can change it: a netlink socket it did not open before (the machine's interfaces and
|
||||
# addresses asked of the kernel), a request it did not send, a public address it did not reach.
|
||||
|
||||
#: The calls of the network the trace adds (tests/_strace_stand_in.py traces them when it is asked `network=True`).
|
||||
NET_CALLS = ("socket", "connect", "bind", "sendto", "sendmsg", "sendmmsg")
|
||||
#: The documentation ranges (RFC 5737) the lab gives its fake servers and exits: 192.0.2.0/24 (the DoH bootstrap of tests/_doh_servers.py),
|
||||
#: 198.51.100.0/24 (the page work of tests/_page_work.py, STUN, TURN and the exits of tests/_socks_servers.py and scripts/ci_ab_network.py, the
|
||||
#: lab exit on `lo`) and 203.0.113.0/24 (the exits and the web address of tests/_socks_servers.py).
|
||||
LAB_NETWORKS = tuple(ipaddress.ip_network(n) for n in ("192.0.2.0/24", "198.51.100.0/24", "203.0.113.0/24"))
|
||||
#: The destinations that are not compared, by class, and why. They are counted per seed (`net_not_compared`), never excused one by one.
|
||||
NET_NOT_COMPARED = {
|
||||
"loopback": "the engine's own processes, the oracle and the fake web talk to each other on loopback: it is the run's, not the host's network",
|
||||
"lab": "the documentation ranges the lab gives its fake servers and exits (LAB_NETWORKS) are the lab's, not a destination on the internet",
|
||||
"private": "RFC 1918, link-local, shared (100.64/10), unique local and the other ranges that are not global are the machine's own network",
|
||||
"multicast": "a multicast group (mDNS, SSDP) is the local link's, not a public destination",
|
||||
}
|
||||
NET_WINDOWS = (
|
||||
"not covered on Windows. The equivalent of a connect or a send is the Microsoft-Windows-Kernel-Network provider (TCP connect, events 12 and 28; "
|
||||
"UDP send, 42 and 58; the process in the event's PID field, not in its header): it is not in the session, because logman takes a second "
|
||||
"provider only through a providers file, the provider logs every packet the whole machine sends and receives (the runner's own traffic and "
|
||||
"the fake web's loopback included), and no trace of a hosted runner has shown yet how tracerpt names its fields, so a reader written now "
|
||||
"would need a canary of its own (a loopback datagram of the oracle's) not to be blind. The equivalent of netlink is not a socket: "
|
||||
"GetAdaptersAddresses and NotifyIpInterfaceChange go through nsi.dll to the NSI driver by IOCTL, which no Kernel-File Create event carries "
|
||||
"(the open of the device is a Create, in the file set).")
|
||||
_SOCK_INODE = re.compile(r"<socket:\[(\d+)\]>")
|
||||
_FD_ARG = re.compile(r"^-?\d+(?:<socket:\[(\d+)\]>)?")
|
||||
_INET4 = re.compile(r'sa_family=AF_INET, sin_port=htons\((\d+)\), sin_addr=inet_addr\("([^"]+)"\)')
|
||||
_INET6 = re.compile(r'sa_family=AF_INET6, sin6_port=htons\((\d+)\),[^}]*?inet_pton\(AF_INET6, "([^"]+)"')
|
||||
_NL_ADDR = re.compile(r"sa_family=AF_NETLINK, nl_pid=-?\d+, nl_groups=([0-9a-fA-Fx]+)")
|
||||
#: The header of a netlink message as strace decodes it: `{nlmsg_len=20, nlmsg_type=RTM_GETADDR, ...` (and `{len=20, type=RTM_GETADDR, ...` of the
|
||||
#: older builds); an unknown type is a number (`nlmsg_type=0x1d /* RTM_??? */`).
|
||||
_NL_HEADER = re.compile(r"\{(?:nlmsg_len|len)=\d+, (?:nlmsg_type|type)=([A-Za-z0-9_]+)")
|
||||
#: The requests of NETLINK_ROUTE (linux/rtnetlink.h), for a message strace printed as bytes (a socket it could not name).
|
||||
ROUTE_TYPES = {16: "RTM_NEWLINK", 18: "RTM_GETLINK", 20: "RTM_NEWADDR", 22: "RTM_GETADDR", 24: "RTM_NEWROUTE", 26: "RTM_GETROUTE",
|
||||
28: "RTM_NEWNEIGH", 30: "RTM_GETNEIGH", 34: "RTM_GETRULE", 38: "RTM_GETQDISC", 74: "RTM_GETNETCONF"}
|
||||
_TRANSPORT = {"SOCK_STREAM": "tcp", "SOCK_DGRAM": "udp", "SOCK_RAW": "raw", "SOCK_SEQPACKET": "seqpacket"}
|
||||
|
||||
|
||||
def destination_class(address: str) -> str:
|
||||
"""`public`, or the class of NET_NOT_COMPARED of an address (an IPv4 address mapped in IPv6 is its IPv4). An address that cannot be read is
|
||||
`public`: it is compared, not dropped."""
|
||||
try:
|
||||
ip = ipaddress.ip_address(address.split("%", 1)[0])
|
||||
except ValueError:
|
||||
return "public"
|
||||
if ip.version == 6 and ip.ipv4_mapped:
|
||||
ip = ip.ipv4_mapped
|
||||
if ip.is_loopback:
|
||||
return "loopback"
|
||||
if any(ip in net for net in LAB_NETWORKS):
|
||||
return "lab"
|
||||
if ip.is_multicast:
|
||||
return "multicast"
|
||||
if not ip.is_global:
|
||||
return "private"
|
||||
return "public"
|
||||
|
||||
|
||||
def _socket_args(rest: str) -> list:
|
||||
"""The three arguments of a socket() line: `AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC, NETLINK_ROUTE) = 5<socket:[1]>`."""
|
||||
text = rest.split(" <unfinished ...>", 1)[0]
|
||||
text = text.rsplit(") =", 1)[0] if ") =" in text else text.rstrip(")")
|
||||
args = [a.strip() for a in text.split(",", 2)]
|
||||
return args + ["?"] * (3 - len(args))
|
||||
|
||||
|
||||
def _socket_of(args: list) -> dict:
|
||||
"""{"family", "proto"} of the arguments of a socket(): the protocol of a netlink socket (`NETLINK_ROUTE`, or its number), the transport of an
|
||||
internet socket (`tcp`, `udp`, `icmp`, ...)."""
|
||||
family, kind, proto = args[0], args[1].split("|", 1)[0], args[2].split(" ", 1)[0]
|
||||
if family == "AF_NETLINK":
|
||||
return {"family": family, "proto": proto}
|
||||
if proto.startswith("IPPROTO_") and proto != "IPPROTO_IP":
|
||||
return {"family": family, "proto": proto[len("IPPROTO_"):].lower()}
|
||||
return {"family": family, "proto": _TRANSPORT.get(kind, kind.lower())}
|
||||
|
||||
|
||||
def _raw_netlink_types(rest: str, proto: str) -> list:
|
||||
"""The type of a netlink message strace printed as bytes (the first string of the call): the u16 after the length, named for NETLINK_ROUTE."""
|
||||
s = _STR.search(rest)
|
||||
if not s:
|
||||
return []
|
||||
data = codecs.escape_decode(s.group(1).encode("latin-1", errors="replace"))[0]
|
||||
if len(data) < 6:
|
||||
return []
|
||||
n = int.from_bytes(data[4:6], "little")
|
||||
return [(ROUTE_TYPES.get(n) if proto == "NETLINK_ROUTE" else None) or "type=%d" % n]
|
||||
|
||||
|
||||
def network_events(lines) -> tuple:
|
||||
"""`([(pid, what)], {class: n})` of a strace log read as lines: `what` is `netlink NETLINK_ROUTE` (a socket opened, failed attempts included),
|
||||
`netlink NETLINK_ROUTE RTM_GETADDR` (a request sent on it), `netlink NETLINK_ROUTE bind nl_groups=00000111` (a subscription to its groups),
|
||||
`connect tcp AF_INET 93.184.216.34:443` or `send udp AF_INET6 [2001:4860::8888]:53` (a destination that is public); the destinations that are
|
||||
not public are counted by class. A socket is known by the inode `-y` printed for it, so a send names the protocol of the socket() that made it,
|
||||
whichever thread or process sends."""
|
||||
socks: dict = {}
|
||||
pending: dict = {}
|
||||
out, skipped = [], collections.Counter()
|
||||
|
||||
def opened(pid, args, result):
|
||||
sock = _socket_of(args)
|
||||
if sock["family"] == "AF_NETLINK":
|
||||
out.append((pid, "netlink %s" % sock["proto"]))
|
||||
inode = _SOCK_INODE.search(result)
|
||||
if inode:
|
||||
socks[inode.group(1)] = sock
|
||||
|
||||
for line in lines:
|
||||
m = _LINE.match(line)
|
||||
if not m:
|
||||
r = _RESUMED.match(line)
|
||||
if r and r.group(2) == "socket" and int(r.group(1)) in pending:
|
||||
opened(int(r.group(1)), pending.pop(int(r.group(1))), r.group(3))
|
||||
continue
|
||||
pid, call, rest = int(m.group(1)), m.group(2), m.group(3)
|
||||
if call == "socket":
|
||||
if "<unfinished ...>" in rest:
|
||||
pending[pid] = _socket_args(rest)
|
||||
else:
|
||||
opened(pid, _socket_args(rest), rest.rsplit(") =", 1)[-1])
|
||||
continue
|
||||
if call not in NET_CALLS:
|
||||
continue
|
||||
fd = _FD_ARG.match(rest)
|
||||
sock = socks.get(fd.group(1)) if fd and fd.group(1) else None
|
||||
headers = _NL_HEADER.findall(rest)
|
||||
if (sock and sock["family"] == "AF_NETLINK") or "sa_family=AF_NETLINK" in rest or headers:
|
||||
proto = sock["proto"] if sock and sock["family"] == "AF_NETLINK" else "NETLINK_?"
|
||||
if call == "bind":
|
||||
groups = _NL_ADDR.search(rest)
|
||||
if groups and int(groups.group(1), 16):
|
||||
out.append((pid, "netlink %s bind nl_groups=%s" % (proto, groups.group(1))))
|
||||
elif call.startswith("send"):
|
||||
for t in headers or _raw_netlink_types(rest, proto):
|
||||
out.append((pid, "netlink %s %s" % (proto, t)))
|
||||
continue
|
||||
if call == "bind":
|
||||
continue # a local address, not a destination
|
||||
verb, transport = ("connect" if call == "connect" else "send"), (sock["proto"] if sock else "?")
|
||||
found = [("AF_INET", port, addr, addr) for port, addr in _INET4.findall(rest)]
|
||||
found += [("AF_INET6", port, addr, "[%s]" % addr) for port, addr in _INET6.findall(rest)]
|
||||
for family, port, addr, shown in found:
|
||||
cls = destination_class(addr)
|
||||
if cls == "public":
|
||||
out.append((pid, "%s %s %s %s:%s" % (verb, transport, family, shown, port)))
|
||||
else:
|
||||
skipped[cls] += 1
|
||||
return out, dict(sorted(skipped.items()))
|
||||
|
||||
|
||||
def net_by_kind(events, label_of) -> list:
|
||||
"""The sorted set `<kind>: <what>` of `network_events`, `label_of(pid)` naming the process (a thread is its process's)."""
|
||||
return sorted({"%s: %s" % (label_of(pid), what) for pid, what in events})
|
||||
|
||||
|
||||
def _read_lines(log: Path):
|
||||
with open(log, encoding="utf-8", errors="replace") as f:
|
||||
for line in f:
|
||||
@@ -782,13 +946,16 @@ def wait_exited(read_tree, alive, period=EXIT_PERIOD_S, limit_s=EXIT_LIMIT_S, sl
|
||||
# The comparison.
|
||||
|
||||
def leaves_of(seed_footprint: dict) -> dict:
|
||||
"""{leaf: value} of one seed: proc.<kind> = how many processes of that kind the run made (1 for a kind of type tab: its presence) and
|
||||
file.<path> = 1 for every HOST path the tree touched."""
|
||||
"""{leaf: value} of one seed: proc.<kind> = how many processes of that kind the run made (1 for a kind of type tab: its presence),
|
||||
file.<path> = 1 for every HOST path the tree touched and net.<kind>: <what> = 1 for every netlink socket, netlink request and public
|
||||
destination of a process of that kind (`network_events`)."""
|
||||
out = {}
|
||||
for kind, n in seed_footprint.get("kinds", {}).items():
|
||||
out["proc." + kind] = 1 if is_tab(kind) and n else n
|
||||
for path in seed_footprint.get("files", []):
|
||||
out["file." + path] = 1
|
||||
for entry in seed_footprint.get("net") or []:
|
||||
out["net." + entry] = 1
|
||||
return out
|
||||
|
||||
|
||||
@@ -826,7 +993,7 @@ def warmup_only(fp: dict) -> dict | None:
|
||||
return None
|
||||
m = next((s for s in fp.get("seeds", []) if s["seed"] == w["seed"]), None)
|
||||
if m is None:
|
||||
return {"seed": w["seed"], "kinds": [], "files": [], "measured": False}
|
||||
return {"seed": w["seed"], "kinds": [], "files": [], "net": [], "measured": False}
|
||||
kinds = []
|
||||
for kind, n in sorted(w.get("kinds", {}).items()):
|
||||
measured = m.get("kinds", {}).get(kind, 0)
|
||||
@@ -834,7 +1001,9 @@ def warmup_only(fp: dict) -> dict | None:
|
||||
kinds.append({"kind": kind, "warmup": n, "measured": measured, "spawned_by": w.get("spawned_by", {}).get(kind, [])})
|
||||
measured_files = set(m.get("files", []))
|
||||
files = [{"path": path, "touched_by": w.get("touched_by", {}).get(path, [])} for path in w.get("files", []) if path not in measured_files]
|
||||
return {"seed": w["seed"], "kinds": kinds, "files": files, "measured": True}
|
||||
measured_net = set(m.get("net") or [])
|
||||
net = [entry for entry in (w.get("net") or []) if entry not in measured_net]
|
||||
return {"seed": w["seed"], "kinds": kinds, "files": files, "net": net, "measured": True}
|
||||
|
||||
|
||||
def _by_text(d: dict) -> str:
|
||||
@@ -843,8 +1012,10 @@ def _by_text(d: dict) -> str:
|
||||
|
||||
|
||||
def _by(seed_footprint: dict, leaf: str) -> list:
|
||||
"""The processes to blame for a leaf in a seed's footprint: who touched a path, who spawned a kind."""
|
||||
"""The processes to blame for a leaf in a seed's footprint: who touched a path, who spawned a kind (a net leaf names its kind itself)."""
|
||||
category, _dot, name = leaf.partition(".")
|
||||
if category == "net":
|
||||
return []
|
||||
return list(seed_footprint.get("touched_by" if category == "file" else "spawned_by", {}).get(name, []))
|
||||
|
||||
|
||||
@@ -904,14 +1075,19 @@ def judge(a: dict, b: dict, expected: list | None = None, a_a: bool = False, pla
|
||||
for seed in sorted(set(seeds_a) & set(seeds_b))}
|
||||
outside = {side: {str(seed): seeds[seed]["outside_tree"] for seed in sorted(seeds) if seeds[seed].get("outside_tree")}
|
||||
for side, seeds in (("A", seeds_a), ("B", seeds_b))}
|
||||
net_skipped = {side: {str(seed): seeds[seed]["net_not_compared"] for seed in sorted(seeds) if seeds[seed].get("net_not_compared")}
|
||||
for side, seeds in (("A", seeds_a), ("B", seeds_b))}
|
||||
net = ({"covered": False, "reason": NET_WINDOWS} if os_name == "windows"
|
||||
else {"covered": True, "not_compared": NET_NOT_COMPARED, "counts": net_skipped})
|
||||
warm = {"A": warmup_only(a), "B": warmup_only(b)}
|
||||
both = None
|
||||
if warm["A"] and warm["B"]:
|
||||
both = {"kinds": sorted({k["kind"] for k in warm["A"]["kinds"]} & {k["kind"] for k in warm["B"]["kinds"]}),
|
||||
"files": sorted({f["path"] for f in warm["A"]["files"]} & {f["path"] for f in warm["B"]["files"]})}
|
||||
"files": sorted({f["path"] for f in warm["A"]["files"]} & {f["path"] for f in warm["B"]["files"]}),
|
||||
"net": sorted(set(warm["A"].get("net", [])) & set(warm["B"].get("net", [])))}
|
||||
return {"format": FORMAT, "mode": "a-a" if a_a else "a-b", "verdict": "red" if problems else "green", "problems": problems,
|
||||
"differences": differences, "declared": declared, "ours": OURS, "tab": {"reason": TAB_REASON, "counts": tab},
|
||||
"outside_tree": outside, "warmup": dict(warm, both=both), "stale": [e.get("id") for e in stale], "leaves": counts}
|
||||
"outside_tree": outside, "warmup": dict(warm, both=both), "stale": [e.get("id") for e in stale], "leaves": counts, "net": net}
|
||||
|
||||
|
||||
def print_report(report: dict, a_name: str, b_name: str) -> None:
|
||||
@@ -928,12 +1104,21 @@ def print_report(report: dict, a_name: str, b_name: str) -> None:
|
||||
name, warm["seed"], k["kind"], k["warmup"], k["measured"], ", ".join(k["spawned_by"]) or "-"))
|
||||
for f in warm["files"][:100]:
|
||||
print("WARMUP-ONLY %s seed %s file.%s (touched by: %s)" % (name, warm["seed"], f["path"], ", ".join(f["touched_by"]) or "-"))
|
||||
for entry in warm.get("net", [])[:100]:
|
||||
print("WARMUP-ONLY %s seed %s net.%s" % (name, warm["seed"], entry))
|
||||
for side, name in (("A", a_name), ("B", b_name)):
|
||||
for seed, names in sorted(((report.get("outside_tree") or {}).get(side) or {}).items()):
|
||||
print("OUTSIDE THE TREE (not compared) %s seed %s: %s" % (name, seed, ", ".join("%s %d paths" % kv for kv in sorted(names.items()))))
|
||||
for d in report["declared"]:
|
||||
print("DECLARED seed %s %s (%s)" % (d["seed"], d["leaf"], d["id"]))
|
||||
print("OURS (not compared): " + "; ".join("%s: %s" % kv for kv in sorted(report.get("ours", OURS).items())))
|
||||
net = report.get("net") or {}
|
||||
if net and not net.get("covered"):
|
||||
print("NET NOT COVERED: " + net["reason"])
|
||||
elif net:
|
||||
for side, name in (("A", a_name), ("B", b_name)):
|
||||
for seed, classes in sorted((net.get("counts") or {}).get(side, {}).items()):
|
||||
print("NET (not compared) %s seed %s: %s" % (name, seed, ", ".join("%s %d" % kv for kv in sorted(classes.items()))))
|
||||
n = len(report["differences"])
|
||||
for p in report["problems"][:len(report["problems"]) - n]:
|
||||
print("FAIL " + p)
|
||||
@@ -992,7 +1177,7 @@ def run_seed(binary: str, seed: int, work: Path, name: str | None = None) -> dic
|
||||
else:
|
||||
from _strace_stand_in import _stand_in
|
||||
|
||||
exe = _stand_in(binary, seed_work / "engine", log, pidfile, syscalls=STRACE_CALLS, fd_paths=True)
|
||||
exe = _stand_in(binary, seed_work / "engine", log, pidfile, syscalls=STRACE_CALLS, fd_paths=True, network=True)
|
||||
origin_a, origin_o, stop_site = journey_site.start((0, 0))
|
||||
server, steps, root_pid = None, [], None
|
||||
try:
|
||||
@@ -1075,6 +1260,7 @@ def _seed_result(binary: str, seed: int, seed_work: Path, steps: list, log: Path
|
||||
problems.append("the tree did not exit within %d s of the close: the trace is cut short" % EXIT_LIMIT_S)
|
||||
detail = sorted(({"label": p["label"], "cmd": p["cmd"][:300]} for p in procs.values()), key=lambda d: (d["label"], d["cmd"]))
|
||||
outside = got["outside"]
|
||||
net, net_skipped = None, None # NET_WINDOWS
|
||||
else:
|
||||
lines = list(_read_lines(log))
|
||||
procs = spawned_processes(lines, real)
|
||||
@@ -1085,6 +1271,8 @@ def _seed_result(binary: str, seed: int, seed_work: Path, steps: list, log: Path
|
||||
parents = {pid: owner_of(p["parent"], owners) for pid, p in procs.items() if p["parent"] is not None}
|
||||
label_of = lambda pid: labels.get(owner_of(pid, owners), "?") # noqa: E731
|
||||
info, problems, outside = {"source": "strace", "exited": True}, [], {} # strace follows our tree and nothing else
|
||||
events, net_skipped = network_events(lines)
|
||||
net = net_by_kind(events, label_of)
|
||||
detail = sorted(({"label": p["label"], "exec": (" ".join([os.path.basename(p["exec"][0])] + p["exec"][1][1:6]) if p["exec"] else None),
|
||||
"name": p["name"]} for p in procs.values()), key=lambda d: (d["label"], d["exec"] or ""))
|
||||
raw = {path for _pid, path in pairs}
|
||||
@@ -1093,7 +1281,8 @@ def _seed_result(binary: str, seed: int, seed_work: Path, steps: list, log: Path
|
||||
info.update({"processes": len(procs), "paths": len(raw)})
|
||||
# touched_by and spawned_by are evidence, never compared: the process to blame for a path or a kind that differs
|
||||
return {"seed": seed, "steps": steps, "kinds": kinds, "files": host, "ours": ours, "trace": info, "problems": problems, "processes": detail,
|
||||
"touched_by": by_kind(pairs, label_of, ctx), "spawned_by": spawners(labels, parents), "outside_tree": outside}
|
||||
"touched_by": by_kind(pairs, label_of, ctx), "spawned_by": spawners(labels, parents), "outside_tree": outside,
|
||||
"net": net, "net_not_compared": net_skipped}
|
||||
|
||||
|
||||
def run_engine(binary: str, leg: str, seeds: list, label: str) -> dict:
|
||||
@@ -1117,8 +1306,8 @@ def run_engine(binary: str, leg: str, seeds: list, label: str) -> dict:
|
||||
for step in fp["steps"]:
|
||||
if not step["ok"]:
|
||||
problems.append("seed %d: step %d (%s) failed: %s" % (seed, step["n"], step["name"], step.get("error")))
|
||||
print("seed %d: %s; %d host paths, %s" % (seed, json.dumps(fp["kinds"], sort_keys=True), len(fp["files"]),
|
||||
json.dumps(fp.get("ours", {}), sort_keys=True)))
|
||||
print("seed %d: %s; %d host paths, %d net entries, %s" % (seed, json.dumps(fp["kinds"], sort_keys=True), len(fp["files"]),
|
||||
len(fp.get("net") or []), json.dumps(fp.get("ours", {}), sort_keys=True)))
|
||||
sys.stdout.flush()
|
||||
finally:
|
||||
shutil.rmtree(work, ignore_errors=True)
|
||||
|
||||
@@ -17,6 +17,8 @@ import pytest
|
||||
|
||||
_SYSCALLS = ("execve,clone,clone3,fork,vfork,open,openat,stat,lstat,"
|
||||
"newfstatat,statx,access,faccessat,faccessat2,readlink")
|
||||
#: The network calls, traced only when a caller asks (``network=True``: scripts/ci_ab_host.py, NET_CALLS): the font tests do not.
|
||||
_NET_SYSCALLS = "socket,connect,bind,sendto,sendmsg,sendmmsg"
|
||||
|
||||
|
||||
def _strace_options(fd_paths: bool = False) -> str:
|
||||
@@ -39,7 +41,7 @@ def _require_strace_can_trace(tmp: Path) -> None:
|
||||
|
||||
|
||||
def _stand_in(binary: str, tree: Path, log: Path, pidfile: Path, syscalls: str = _SYSCALLS,
|
||||
timestamps: bool = False, fd_paths: bool = False) -> str:
|
||||
timestamps: bool = False, fd_paths: bool = False, network: bool = False) -> str:
|
||||
"""A copy of the engine's directory made of links, whose executable runs
|
||||
the real one under strace, in the engine's place.
|
||||
|
||||
@@ -55,7 +57,10 @@ def _stand_in(binary: str, tree: Path, log: Path, pidfile: Path, syscalls: str =
|
||||
``syscalls`` is what strace traces; ``timestamps`` adds ``-ttt`` (the epoch
|
||||
seconds after each pid), which ``_LINE`` does not read: a caller that asks
|
||||
for them strips them first (``test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e``);
|
||||
``fd_paths`` adds ``-y`` (scripts/ci_ab_host.py reads the paths the tree touched)."""
|
||||
``fd_paths`` adds ``-y`` (scripts/ci_ab_host.py reads the paths the tree touched, and knows a socket by its inode);
|
||||
``network`` adds the network calls to ``syscalls`` (scripts/ci_ab_host.py reads the netlink sockets and the public destinations)."""
|
||||
if network:
|
||||
syscalls = syscalls + "," + _NET_SYSCALLS
|
||||
real = Path(os.path.realpath(binary))
|
||||
tree.mkdir()
|
||||
for entry in real.parent.iterdir():
|
||||
|
||||
+157
-4
@@ -4,8 +4,9 @@ The oracle compares the WHOLE TRACE of a closed run, from the launch to the exit
|
||||
`tab`, whose count follows the idle time and only whose presence counts) and the set of host paths the tree touched (what is `ours` -- its package, its profile and temp
|
||||
dirs, the run's cache, its own shared memory -- leaves the comparison as a class). Nothing is excused: there is no list of noise.
|
||||
Each property is shown on the input it exists for: a host path on one side only is red (naming it), a path of ours on one side only is green, a kind with another count
|
||||
is red, a tab count that differs is green and a tab kind that is absent on one side is red, the one declared difference passes in an A/B by kind, and the Windows
|
||||
processes are named by their command lines from the audit events.
|
||||
is red, a tab count that differs is green and a tab kind that is absent on one side is red, the one declared difference passes in an A/B by kind, the Windows
|
||||
processes are named by their command lines from the audit events, and on Linux a netlink socket, a netlink request or a public destination of a kind on one side
|
||||
only is red while a loopback or lab destination is not compared.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -65,7 +66,7 @@ def test_equal_footprints_are_green():
|
||||
report = judge(footprint(), footprint(), expected=[], a_a=True)
|
||||
assert report["verdict"] == "green" and report["problems"] == [] and report["differences"] == []
|
||||
assert set(report["leaves"]) == {"11", "12"}
|
||||
assert report["leaves"]["11"] == {"proc": 4, "file": 3}
|
||||
assert report["leaves"]["11"] == {"proc": 4, "file": 3, "net": 0}
|
||||
|
||||
|
||||
def test_a_host_path_touched_on_one_side_only_is_red_and_names_the_path_and_both_sides():
|
||||
@@ -781,7 +782,7 @@ def test_the_report_lists_what_is_only_in_the_warm_up_and_says_when_both_engines
|
||||
b = with_warmup(footprint("firefox-68 again"), kinds=kinds, spawned_by=spawned)
|
||||
report = judge(a, b, a_a=True)
|
||||
assert report["verdict"] == "green", "a first-launch-only behaviour that the measured launches do not have is written, not red"
|
||||
assert report["warmup"]["both"] == {"kinds": ["backgroundtask/pingsender"], "files": []}
|
||||
assert report["warmup"]["both"] == {"kinds": ["backgroundtask/pingsender"], "files": [], "net": []}
|
||||
host.print_report(report, "firefox-68", "firefox-68 again")
|
||||
out = capsys.readouterr().out
|
||||
assert "WARMUP-ONLY firefox-68 seed 11 proc.backgroundtask/pingsender: warm-up 3, measured 0 (spawned by: parent)" in out
|
||||
@@ -874,3 +875,155 @@ def test_a_closed_linux_run_keeps_the_kinds_that_touched_each_path_and_nothing_i
|
||||
fp = host._seed_result(REAL, 11, tmp_path, [], log, None, None, False)
|
||||
assert fp["touched_by"]["/etc/machine-id"] == ["glxtest", "lsb_release"]
|
||||
assert fp["spawned_by"]["glxtest"] == ["parent"] and fp["outside_tree"] == {}
|
||||
|
||||
|
||||
# -
|
||||
# The network of the tree (Linux): the netlink sockets, their requests, and the public destinations, per kind.
|
||||
|
||||
NET_LOG = r"""300 execve("/e/firefox/firefox", ["/e/firefox/firefox", "-profile", "/tmp/p"], 0x7ffd /* 40 vars */) = 0
|
||||
300 socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC, NETLINK_ROUTE) = 41<socket:[81234]>
|
||||
300 bind(41<socket:[81234]>, {sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000511}, 12) = 0
|
||||
300 clone3({flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM, exit_signal=0, stack=0x7f}, 88) = 301
|
||||
301 sendto(41<socket:[81234]>, [{nlmsg_len=20, nlmsg_type=RTM_GETLINK, nlmsg_flags=NLM_F_REQUEST|NLM_F_DUMP, nlmsg_seq=1700000001, nlmsg_pid=0}, {ifi_family=AF_UNSPEC, ifi_type=ARPHRD_NETROM, ifi_index=0, ifi_flags=0, ifi_change=0}], 20, 0, {sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, 12) = 20
|
||||
301 sendmsg(41<socket:[81234]>, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base=[{nlmsg_len=24, nlmsg_type=RTM_GETADDR, nlmsg_flags=NLM_F_REQUEST|NLM_F_DUMP, nlmsg_seq=1700000002, nlmsg_pid=0}, {ifa_family=AF_UNSPEC, ifa_prefixlen=0, ifa_flags=0, ifa_scope=RT_SCOPE_UNIVERSE, ifa_index=0}], iov_len=24}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 24
|
||||
300 socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC|SOCK_NONBLOCK, NETLINK_KOBJECT_UEVENT <unfinished ...>
|
||||
300 <... socket resumed>) = 42<socket:[81240]>
|
||||
300 socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 43<socket:[81250]>
|
||||
301 connect(43<socket:[81250]>, {sa_family=AF_INET, sin_port=htons(443), sin_addr=inet_addr("93.184.215.14")}, 16) = -1 EINPROGRESS (Operation now in progress)
|
||||
300 socket(AF_INET6, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_UDP) = 44<socket:[81260]>
|
||||
300 sendto(44<socket:[81260]>, "\x12\x34\x01\x00\x00\x01", 6, MSG_NOSIGNAL, {sa_family=AF_INET6, sin6_port=htons(53), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "2001:4860:4860::8888", &sin6_addr), sin6_scope_id=0}, 28) = 6
|
||||
300 connect(43<socket:[81250]>, {sa_family=AF_INET, sin_port=htons(41234), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
|
||||
300 connect(43<socket:[81250]>, {sa_family=AF_INET, sin_port=htons(443), sin_addr=inet_addr("198.51.100.9")}, 16) = 0
|
||||
300 connect(43<socket:[81250]>, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("10.1.0.4")}, 16) = 0
|
||||
300 sendto(44<socket:[81260]>, "\x00", 1, 0, {sa_family=AF_INET6, sin6_port=htons(5353), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "ff02::fb", &sin6_addr), sin6_scope_id=0}, 28) = 1
|
||||
300 connect(45<socket:[81270]>, {sa_family=AF_UNIX, sun_path="/run/dbus/system_bus_socket"}, 110) = 0
|
||||
300 sendto(43<socket:[81250]>, "GET / HTTP/1.1\r\n", 16, MSG_NOSIGNAL, NULL, 0) = 16
|
||||
300 fork() = 302
|
||||
302 execve("/proc/self/exe", ["/e/firefox/firefox", "-contentproc", "-prefsLen", "1", "socket"], 0x7ffd /* 40 vars */) = 0
|
||||
302 socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 5<socket:[81300]>
|
||||
302 sendmmsg(5<socket:[81300]>, [{msg_hdr={msg_name={sa_family=AF_INET, sin_port=htons(3478), sin_addr=inet_addr("74.125.250.129")}, msg_namelen=16, msg_iov=[{iov_base="\x00\x01\x00\x00", iov_len=4}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, msg_len=4}], 1, 0) = 1
|
||||
302 connect(5<socket:[81300]>, {sa_family=AF_INET6, sin6_port=htons(443), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "::ffff:203.0.113.7", &sin6_addr), sin6_scope_id=0}, 28) = 0
|
||||
"""
|
||||
|
||||
PARENT_NET = ["parent: connect tcp AF_INET 93.184.215.14:443", "parent: netlink NETLINK_KOBJECT_UEVENT", "parent: netlink NETLINK_ROUTE",
|
||||
"parent: netlink NETLINK_ROUTE RTM_GETADDR", "parent: netlink NETLINK_ROUTE RTM_GETLINK", "parent: netlink NETLINK_ROUTE bind nl_groups=00000511",
|
||||
"parent: send udp AF_INET6 [2001:4860:4860::8888]:53"]
|
||||
|
||||
|
||||
def test_the_network_of_a_linux_run_is_its_netlink_sockets_their_requests_and_its_public_destinations_per_kind(tmp_path, monkeypatch):
|
||||
log = tmp_path / "strace.log"
|
||||
log.write_text(NET_LOG, encoding="utf-8")
|
||||
monkeypatch.setattr(host.os.path, "realpath", lambda p: p)
|
||||
monkeypatch.setattr(host, "_context", lambda binary, windows, work: host.Context("linux", app=["/e/firefox"], temp=["/tmp/ab-host-tmp-x"]))
|
||||
fp = host._seed_result(REAL, 11, tmp_path, [], log, None, None, False)
|
||||
assert fp["net"] == PARENT_NET + ["socket: send udp AF_INET 74.125.250.129:3478"], "a thread's request is its process's, a socket is known by its inode"
|
||||
assert fp["net_not_compared"] == {"lab": 2, "loopback": 1, "multicast": 1, "private": 1}, "198.51.100.9 and ::ffff:203.0.113.7 are the lab's"
|
||||
leaves = host.leaves_of(fp)
|
||||
assert leaves["net.parent: netlink NETLINK_ROUTE RTM_GETADDR"] == 1 and not any("127.0.0.1" in k or "198.51.100" in k for k in leaves)
|
||||
|
||||
|
||||
def test_a_netlink_message_strace_printed_as_bytes_is_read_for_its_type():
|
||||
lines = ["7 socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC, NETLINK_ROUTE) = 3<socket:[9]>",
|
||||
r'7 sendto(3<socket:[9]>, "\x14\x00\x00\x00\x16\x00\x01\x03\x01\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00", 20, 0, '
|
||||
r"{sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, 12) = 20",
|
||||
"7 sendto(8, {{len=20, type=RTM_GETROUTE, flags=NLM_F_REQUEST|NLM_F_DUMP, seq=1, pid=0}, {rtm_family=AF_INET}}, 20, 0, NULL, 0) = 20"]
|
||||
events, skipped = host.network_events(lines)
|
||||
assert events == [(7, "netlink NETLINK_ROUTE"), (7, "netlink NETLINK_ROUTE RTM_GETADDR"), (7, "netlink NETLINK_? RTM_GETROUTE")] and skipped == {}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("address,cls", [
|
||||
("93.184.215.14", "public"), ("2001:4860:4860::8888", "public"), ("127.0.0.53", "loopback"), ("::1", "loopback"),
|
||||
("192.0.2.53", "lab"), ("198.51.100.9", "lab"), ("203.0.113.80", "lab"), ("::ffff:198.51.100.5", "lab"),
|
||||
("10.1.0.4", "private"), ("172.17.0.1", "private"), ("192.168.1.1", "private"), ("169.254.169.254", "private"), ("fe80::1%2", "private"),
|
||||
("100.64.0.1", "private"), ("fd00::1", "private"), ("0.0.0.0", "private"), ("224.0.0.251", "multicast"), ("ff02::fb", "multicast"),
|
||||
("not-an-address", "public"),
|
||||
])
|
||||
def test_only_a_public_destination_is_compared(address, cls):
|
||||
assert host.destination_class(address) == cls
|
||||
|
||||
|
||||
def with_net(fp, entries, skipped=None):
|
||||
fp = copy.deepcopy(fp)
|
||||
for seed in fp["seeds"]:
|
||||
seed["net"] = list(entries)
|
||||
seed["net_not_compared"] = dict(skipped or {})
|
||||
return fp
|
||||
|
||||
|
||||
def test_a_netlink_request_of_a_kind_on_one_side_only_is_red_and_names_the_kind_and_the_request(capsys):
|
||||
a = with_net(footprint(), PARENT_NET)
|
||||
b = with_net(footprint("candidate"), [e for e in PARENT_NET if "RTM_GETADDR" not in e])
|
||||
report = judge(a, b, expected=[], a_a=True)
|
||||
assert report["verdict"] == "red"
|
||||
assert [(d["seed"], d["category"], d["leaf"], d["a"], d["b"]) for d in report["differences"]] == [
|
||||
(11, "net", "net.parent: netlink NETLINK_ROUTE RTM_GETADDR", 1, host.MISSING), (12, "net", "net.parent: netlink NETLINK_ROUTE RTM_GETADDR", 1, host.MISSING)]
|
||||
assert 'seed 11 net.parent: netlink NETLINK_ROUTE RTM_GETADDR: A 1 | B "<missing>"' in report["problems"]
|
||||
host.print_report(report, "firefox-68", "candidate")
|
||||
assert 'DIFF seed 11 net.parent: netlink NETLINK_ROUTE RTM_GETADDR: firefox-68 1 | candidate "<missing>"' in capsys.readouterr().out
|
||||
|
||||
|
||||
def test_the_same_request_from_another_kind_is_a_difference_too():
|
||||
moved = [e.replace("parent: netlink NETLINK_ROUTE RTM_GETADDR", "socket: netlink NETLINK_ROUTE RTM_GETADDR") for e in PARENT_NET]
|
||||
report = judge(with_net(footprint(), PARENT_NET), with_net(footprint("again"), moved), a_a=True)
|
||||
assert {(d["leaf"], d["a"], d["b"]) for d in report["differences"]} == {
|
||||
("net.parent: netlink NETLINK_ROUTE RTM_GETADDR", 1, host.MISSING), ("net.socket: netlink NETLINK_ROUTE RTM_GETADDR", host.MISSING, 1)}
|
||||
|
||||
|
||||
def test_a_public_destination_only_the_candidate_reaches_is_red_and_the_declared_list_does_not_cover_it():
|
||||
c = with_net(a_candidate_without_glxtest(), PARENT_NET + ["socket: connect tcp AF_INET 34.107.221.82:80"])
|
||||
report = judge(with_net(footprint(), PARENT_NET), c, expected=expected())
|
||||
assert report["verdict"] == "red" and [d["id"] for d in report["declared"]] == ["glxtest-69", "glxtest-69"]
|
||||
assert [(d["seed"], d["leaf"], d["a"], d["b"]) for d in report["differences"]] == [
|
||||
(11, "net.socket: connect tcp AF_INET 34.107.221.82:80", host.MISSING, 1), (12, "net.socket: connect tcp AF_INET 34.107.221.82:80", host.MISSING, 1)]
|
||||
|
||||
|
||||
def test_loopback_and_lab_destinations_are_not_compared_and_are_counted_as_evidence(capsys):
|
||||
a = with_net(footprint(), PARENT_NET, skipped={"loopback": 40, "lab": 2})
|
||||
b = with_net(footprint("again"), PARENT_NET, skipped={"loopback": 57})
|
||||
report = judge(a, b, a_a=True)
|
||||
assert report["verdict"] == "green" and report["differences"] == []
|
||||
assert report["net"]["covered"] and report["net"]["counts"]["A"]["11"] == {"lab": 2, "loopback": 40}
|
||||
assert set(report["net"]["not_compared"]) == {"loopback", "lab", "private", "multicast"}
|
||||
host.print_report(report, "firefox-68", "firefox-68 again")
|
||||
assert "NET (not compared) firefox-68 seed 11: lab 2, loopback 40" in capsys.readouterr().out
|
||||
|
||||
|
||||
def test_identical_network_sets_are_green_and_are_counted_as_leaves():
|
||||
report = judge(with_net(footprint(), PARENT_NET), with_net(footprint("again"), PARENT_NET), a_a=True)
|
||||
assert report["verdict"] == "green" and report["leaves"]["11"] == {"proc": 4, "file": 3, "net": len(PARENT_NET)}
|
||||
|
||||
|
||||
def test_a_network_entry_only_the_warm_up_had_is_listed_not_red(capsys):
|
||||
a = with_warmup(with_net(footprint(), PARENT_NET), kinds=KINDS)
|
||||
a["warmup"]["net"] = PARENT_NET + ["parent: connect tcp AF_INET 34.107.221.82:80"]
|
||||
report = judge(a, with_net(footprint("again"), PARENT_NET), a_a=True)
|
||||
assert report["verdict"] == "green" and report["warmup"]["A"]["net"] == ["parent: connect tcp AF_INET 34.107.221.82:80"]
|
||||
host.print_report(report, "firefox-68", "firefox-68 again")
|
||||
assert "WARMUP-ONLY firefox-68 seed 11 net.parent: connect tcp AF_INET 34.107.221.82:80" in capsys.readouterr().out
|
||||
|
||||
|
||||
def test_on_windows_the_network_is_said_not_covered_with_the_reason(capsys):
|
||||
report = judge(footprint(platform="win32"), footprint("again", platform="win32"), a_a=True)
|
||||
assert report["verdict"] == "green" and report["net"] == {"covered": False, "reason": host.NET_WINDOWS}
|
||||
assert "Microsoft-Windows-Kernel-Network" in host.NET_WINDOWS and "GetAdaptersAddresses" in host.NET_WINDOWS
|
||||
host.print_report(report, "firefox-68", "firefox-68 again")
|
||||
assert "NET NOT COVERED: not covered on Windows." in capsys.readouterr().out
|
||||
|
||||
|
||||
def test_the_stand_in_traces_the_network_only_when_the_host_oracle_asks(tmp_path, monkeypatch):
|
||||
import _strace_stand_in as stand_in
|
||||
|
||||
class Help:
|
||||
stdout = "strace --kill-on-exit"
|
||||
|
||||
monkeypatch.setattr(stand_in.shutil, "which", lambda name: "/usr/bin/strace")
|
||||
monkeypatch.setattr(stand_in.subprocess, "run", lambda *a, **k: Help())
|
||||
(tmp_path / "ff").mkdir()
|
||||
binary = tmp_path / "ff" / "firefox"
|
||||
binary.write_text("", encoding="utf-8")
|
||||
font = Path(stand_in._stand_in(str(binary), tmp_path / "font", tmp_path / "f.log", tmp_path / "f.pid")).read_text(encoding="utf-8")
|
||||
oracle = Path(stand_in._stand_in(str(binary), tmp_path / "host", tmp_path / "h.log", tmp_path / "h.pid", syscalls=host.STRACE_CALLS,
|
||||
fd_paths=True, network=True)).read_text(encoding="utf-8")
|
||||
assert "-e trace=%s " % stand_in._SYSCALLS in font and "socket" not in font, "the font tests' default is unchanged"
|
||||
assert "-e trace=%s,%s " % (host.STRACE_CALLS, stand_in._NET_SYSCALLS) in oracle and " -y" in oracle
|
||||
assert set(stand_in._NET_SYSCALLS.split(",")) == set(host.NET_CALLS)
|
||||
Reference in new issue
Block a user