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.tearingDown = true;
allSessions.delete(this);
await new Promise((resolve) => setTimeout(resolve, 5000));
await this.run(this.privilegedTeardown());
await this.returnUID();
if (this.uidInfo) {
await this.run(this.privilegedTeardown());
await this.returnUID();
}
this.ws.terminate();
} catch (err) {
this.log(`Error during teardown`);

View File

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

View File

@ -26,7 +26,7 @@ void die_with_usage()
" riju-system-privileged useradd UID\n"
" riju-system-privileged setup UID UUID\n"
" riju-system-privileged spawn UID UUID CMDLINE...\n"
" riju-system-privileged teardown UUID");
" riju-system-privileged teardown UID UUID");
}
int parseUID(char *str)
@ -125,7 +125,7 @@ void teardown(int uid, char *uuid)
users = buf;
}
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");
status = system(cmdline);
if (status != 0 && status != 256)