Various fixes

This commit is contained in:
Radon Rosborough 2020-07-29 21:06:57 -06:00
parent 76f176a267
commit 0945ad6550
3 changed files with 12 additions and 8 deletions

View File

@ -436,9 +436,10 @@ export class Session {
this.log(`Tearing down session`); this.log(`Tearing down session`);
this.tearingDown = true; this.tearingDown = true;
allSessions.delete(this); allSessions.delete(this);
await new Promise((resolve) => setTimeout(resolve, 5000)); if (this.uidInfo) {
await this.run(this.privilegedTeardown()); await this.run(this.privilegedTeardown());
await this.returnUID(); await this.returnUID();
}
this.ws.terminate(); this.ws.terminate();
} catch (err) { } catch (err) {
this.log(`Error during teardown`); this.log(`Error during teardown`);

View File

@ -37,6 +37,7 @@ class Test {
run = async () => { run = async () => {
let session = null; let session = null;
let timeout = null;
try { try {
const that = this; const that = this;
this.ws = { this.ws = {
@ -70,7 +71,7 @@ class Test {
session = new api.Session(this.ws, this.lang, (msg: string) => { session = new api.Session(this.ws, this.lang, (msg: string) => {
this.messages.push({ event: "serverLog", message: msg }); this.messages.push({ event: "serverLog", message: msg });
}); });
setTimeout(() => { timeout = setTimeout(() => {
this.timedOut = true; this.timedOut = true;
this.handleUpdate(); this.handleUpdate();
}, TIMEOUT_MS); }, TIMEOUT_MS);
@ -98,6 +99,9 @@ class Test {
} }
} finally { } finally {
this.ws = null; this.ws = null;
if (timeout) {
clearTimeout(timeout);
}
if (session) { if (session) {
await session.teardown(); await session.teardown();
} }
@ -228,7 +232,7 @@ const testTypes: {
repl: { repl: {
pred: ({ repl }) => (repl ? true : false), pred: ({ repl }) => (repl ? true : false),
}, },
runRepl: { runrepl: {
pred: ({ repl }) => (repl ? true : false), pred: ({ repl }) => (repl ? true : false),
}, },
scope: { scope: {
@ -266,7 +270,6 @@ async function main() {
try { try {
await test.run(); await test.run();
console.error("succeeded"); console.error("succeeded");
console.error(test.getLog());
} catch (err) { } catch (err) {
console.error("failed:"); console.error("failed:");
console.error(test.getLog()); console.error(test.getLog());

View File

@ -26,7 +26,7 @@ void die_with_usage()
" riju-system-privileged useradd UID\n" " riju-system-privileged useradd UID\n"
" riju-system-privileged setup UID UUID\n" " riju-system-privileged setup UID UUID\n"
" riju-system-privileged spawn UID UUID CMDLINE...\n" " riju-system-privileged spawn UID UUID CMDLINE...\n"
" riju-system-privileged teardown UUID"); " riju-system-privileged teardown UID UUID");
} }
int parseUID(char *str) int parseUID(char *str)
@ -125,7 +125,7 @@ void teardown(int uid, char *uuid)
users = buf; users = buf;
} }
if (users != NULL) { if (users != NULL) {
if (asprintf(&cmdline, "pkill -SIGKILL --uid %s", users) < 0) if (asprintf(&cmdline, "while pkill -9 --uid %1$s; do sleep 0.01; done", users) < 0)
die("asprintf failed"); die("asprintf failed");
status = system(cmdline); status = system(cmdline);
if (status != 0 && status != 256) if (status != 0 && status != 256)