summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/fs.py19
-rw-r--r--test/perf.zig9
2 files changed, 23 insertions, 5 deletions
diff --git a/test/fs.py b/test/fs.py
index b20dc8ee..c8dea2d9 100644
--- a/test/fs.py
+++ b/test/fs.py
@@ -470,7 +470,13 @@ def test(binary, quic=False):
spaced = child_dir / 'space name.txt'
spaced.write_bytes(b'first line\nsecond line\n')
env = os.environ.copy()
- env.update(PARDES_9P=str(address), PARDES_PANE='1', PARDES_FORWARD_LOOK='1')
+ # PARDES_PID is what says "you are inside a pardes"; the socket
+ # and the pane only say how to reach it. Without the pid the child
+ # starts its own session, so this test used to pass only when the
+ # runner itself happened to be running inside one.
+ status = dict(line.split(maxsplit=1) for line in client.read('/status').decode().splitlines())
+ env.update(PARDES_9P=str(address), PARDES_PANE='1', PARDES_PID=status['pid'])
+ env.pop('PARDES_FORWARD_LOOK', None)
for word, expected, selected, reuse in [('space name.txt:2:4', spaced.read_bytes(), [14, 14], False),
('/n/self/pane/1/body', b'initial\n', None, False),
('/virtual/pane/1/body:1:2-4', b'initial\n', [1, 4], True)]:
@@ -518,7 +524,7 @@ def test(binary, quic=False):
assert time.monotonic() < deadline, 'forwarding fixture Dump did not finish'
time.sleep(.005)
before = client.read('/index')
- inherited = {key: env[key] for key in ['PARDES_9P', 'PARDES_PANE', 'PARDES_FORWARD_LOOK']}
+ inherited = {key: env[key] for key in ['PARDES_9P', 'PARDES_PANE', 'PARDES_PID']}
cases = [
('mount', ['--mount=peer=' + str(address), '/n/peer/pane/1/body'], None),
('name', ['--9p=forwarded-name'], 'forwarded-name'),
@@ -543,7 +549,10 @@ def test(binary, quic=False):
assert local.read('/index') == before
assert local.read('/pane/1/body') == b'initial\n'
else:
- assert len(index) == (3 if name == 'shells' else 1), index
+ # A bare tty launch is a shell plus the empty text pane
+ # the boot puts under it; --shells=3 is the classic
+ # three-shell layout and has no scratch.
+ assert len(index) == (3 if name == 'shells' else 2), index
if name in ['tcp', 'quic']:
assert (name + '!127.0.0.1!').encode() in local.read('/listeners')
assert client.read('/index') == before
@@ -554,7 +563,9 @@ def test(binary, quic=False):
('stale-missing', dict(inherited, PARDES_9P=str(root / 'absent.sock')), 'missing-child-file.txt'),
('stale-noarg', dict(inherited, PARDES_9P=str(root / 'absent.sock')), None),
('stale-pane', dict(inherited, PARDES_PANE='4294967295'), str(spaced)),
- ('disabled', dict(inherited, PARDES_FORWARD_LOOK='0'), str(spaced)),
+ # No pid means "not inside a pardes at all", which is what
+ # --nested withholds and what a plain shell has.
+ ('not-nested', {k: v for k, v in inherited.items() if k != 'PARDES_PID'}, str(spaced)),
]:
with session(binary, root, name, tty=True, inherited=identity,
launch=['--tty', *([word] if word else [])]) as (local, local_address):
diff --git a/test/perf.zig b/test/perf.zig
index 8f463204..5ac38ccf 100644
--- a/test/perf.zig
+++ b/test/perf.zig
@@ -200,6 +200,10 @@ fn measureStartup(io: std.Io, reps: usize, json: bool) !void {
bytes += counter.bytes;
peak = @max(peak, counter.peak);
}
+ // Every other measurement in this file checks the session gave
+ // everything back; a boot that leaks is exactly what a startup
+ // benchmark should be the first to notice.
+ if (counter.live != 0) return error.LeakedStartupMemory;
}
std.mem.sort(u64, init_samples, {}, std.sort.asc(u64));
std.mem.sort(u64, frame_samples, {}, std.sort.asc(u64));
@@ -212,7 +216,10 @@ fn measureStartup(io: std.Io, reps: usize, json: bool) !void {
.reps = reps,
.cold_ns = cold_ns,
.init_median_ns = init_samples[reps / 2],
- .init_p95_ns = init_samples[@min(reps - 1, reps * 95 / 100)],
+ // A p95 needs at least twenty samples to be one; below that this
+ // is the maximum and says so rather than dressing it up.
+ .init_p95_ns = if (reps >= 20) init_samples[reps * 95 / 100] else init_samples[reps - 1],
+ .init_max_ns = init_samples[reps - 1],
.frame_median_ns = frame_samples[reps / 2],
.allocations = calls / reps,
.allocated_bytes = bytes / reps,