row 251 step 1: T27's lists print the timing and the agent state when they fail (#453)
A failed list now names when addKey started and resolved and when each list ran, on hrtime and /proc/uptime, with how far into its second each fell, and whether the agent and its socket were still there. The test's checks are unchanged.
This commit is contained in:
@@ -458,17 +458,32 @@ test('T27: ssh-add -t drops the key from an agent the test keeps alive', async (
|
||||
const agent = spawn('ssh-agent', ['-D', '-a', sock], { stdio: 'ignore' });
|
||||
t.after(() => agent.kill('SIGKILL'));
|
||||
assert.ok(await until(() => existsSync(sock)));
|
||||
// A failed list names its cause: when each step ran on the monotonic clock (hrtime) and on
|
||||
// /proc/uptime (CLOCK_BOOTTIME, which ssh-agent's lifetime counts in whole seconds), and
|
||||
// whether the agent and its socket were still there.
|
||||
const marks = [];
|
||||
const mark = (name) => marks.push({ name, ns: process.hrtime.bigint(), uptime: readFileSync('/proc/uptime', 'utf8').split(' ')[0] });
|
||||
const timing = () => {
|
||||
const at = (m) => `${m.name} +${(Number(m.ns - marks[0].ns) / 1e6).toFixed(1)} ms (hrtime ${(Number(m.ns % 1_000_000_000n) / 1e9).toFixed(4)} s into its second, uptime ${m.uptime})`;
|
||||
const alive = agent.exitCode === null && agent.signalCode === null;
|
||||
return `${marks.map(at).join('; ')}; agent ${alive ? 'alive' : `gone (${agent.exitCode ?? agent.signalCode})`}, socket ${existsSync(sock) ? 'present' : 'missing'}`;
|
||||
};
|
||||
mark('addKey start');
|
||||
await addKey(sock, readFileSync(join(dir, 'k'), 'utf8'), 1);
|
||||
const list = () => {
|
||||
mark('addKey resolved');
|
||||
const list = (name) => {
|
||||
mark(name);
|
||||
try {
|
||||
return execFileSync('ssh-add', ['-l'], { env: { PATH: '/usr/bin:/bin', SSH_AUTH_SOCK: sock }, encoding: 'utf8' });
|
||||
} catch (e) {
|
||||
return e.stdout;
|
||||
}
|
||||
};
|
||||
assert.match(list(), /SHA256:/);
|
||||
const first = list('first list');
|
||||
assert.match(first, /SHA256:/, `first list got ${JSON.stringify(first)}: ${timing()}`);
|
||||
await sleep(2500);
|
||||
assert.match(list(), /no identities/);
|
||||
const second = list('second list');
|
||||
assert.match(second, /no identities/, `second list got ${JSON.stringify(second)}: ${timing()}`);
|
||||
});
|
||||
|
||||
// The test's own limit makes a hung addKey (M37a, M37b) fail in seconds, not at the batch timeout.
|
||||
|
||||
Reference in New Issue
Block a user