Skip to content

Commit

Permalink
Make tests a bit more robus
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Marr <git@stefan-marr.de>
  • Loading branch information
smarr committed May 3, 2017
1 parent ffcfd9b commit 010a053
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
8 changes: 4 additions & 4 deletions tools/kompos/tests/csp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe("Setting CSP Breakpoints", () => {
const breakpoint = createSectionBreakpointData(CSP_URI, 13, 12, 4,
BreakpointType.CHANNEL_BEFORE_RCV, true);
conn = new TestConnection(["halt"], null, CSP_FILE);
ctrl = new HandleStoppedAndGetStackTrace([breakpoint], conn);
ctrl = new HandleStoppedAndGetStackTrace([breakpoint], conn, conn.fullyConnected);
});

after(closeConnectionAfterSuite);
Expand All @@ -39,7 +39,7 @@ describe("Setting CSP Breakpoints", () => {
const breakpoint = createSectionBreakpointData(CSP_URI, 13, 12, 4,
BreakpointType.CHANNEL_AFTER_SEND, true);
conn = new TestConnection(["halt"], null, CSP_FILE);
ctrl = new HandleStoppedAndGetStackTrace([breakpoint], conn);
ctrl = new HandleStoppedAndGetStackTrace([breakpoint], conn, conn.fullyConnected);
});

after(closeConnectionAfterSuite);
Expand All @@ -56,7 +56,7 @@ describe("Setting CSP Breakpoints", () => {
const breakpoint = createSectionBreakpointData(CSP_URI, 12, 13, 12,
BreakpointType.CHANNEL_BEFORE_SEND, true);
conn = new TestConnection(["halt"], null, CSP_FILE);
ctrl = new HandleStoppedAndGetStackTrace([breakpoint], conn);
ctrl = new HandleStoppedAndGetStackTrace([breakpoint], conn, conn.fullyConnected);
});

after(closeConnectionAfterSuite);
Expand All @@ -74,7 +74,7 @@ describe("Setting CSP Breakpoints", () => {
const breakpoint = createSectionBreakpointData(CSP_URI, 12, 13, 12,
BreakpointType.CHANNEL_AFTER_RCV, true);
conn = new TestConnection(["halt"], null, CSP_FILE);
ctrl = new HandleStoppedAndGetStackTrace([breakpoint], conn);
ctrl = new HandleStoppedAndGetStackTrace([breakpoint], conn, conn.fullyConnected);
});

after(closeConnectionAfterSuite);
Expand Down
14 changes: 11 additions & 3 deletions tools/kompos/tests/test-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ export class TestConnection extends VmConnection {
this.connectionResolver = resolve;
let connecting = false;

this.somProc.on("exit", (code, signal) => {
if (code !== 0) {
reject(new Error("Process exited with code: " + code + " Signal: " + signal));
}
});

if (PRINT_SOM_OUTPUT) {
this.somProc.stderr.on("data", (data) => { console.error(data.toString()); });
}
Expand Down Expand Up @@ -146,23 +152,25 @@ export class HandleStoppedAndGetStackTrace extends ControllerWithInitialBreakpoi
public readonly stoppedActivities: Activity[];

constructor(initialBreakpoints: BreakpointData[], vmConnection: VmConnection,
numOps: number = 1) {
connectionP: Promise<boolean>, numOps: number = 1) {
super(initialBreakpoints, vmConnection);

this.numOps = numOps;
this.numStopped = 0;
this.stoppedActivities = [];

this.stackP = new Promise<StackTraceResponse>((resolve, _reject) => {
this.stackP = new Promise<StackTraceResponse>((resolve, reject) => {
this.resolveStackP = resolve;
connectionP.catch(reject);
});

if (numOps > 1) {
this.resolveStackPs = [];
this.stackPs = [];
for (let i = 1; i < numOps; i += 1) {
this.stackPs.push(new Promise<StackTraceResponse>((resolve, _reject) => {
this.stackPs.push(new Promise<StackTraceResponse>((resolve, reject) => {
this.resolveStackPs.push(resolve);
connectionP.catch(reject);
}));
}
}
Expand Down

0 comments on commit 010a053

Please sign in to comment.