Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/debug/WARDuino.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ export namespace WARDuino {
tableIndexes: number[]
}

export enum Inspect {
counter = '01',
breakpoints = '02',
callstack = '03',
globals = '04',
table = '05',
memory = '06',
branching = '07',
stack = '08',
callbacks = '09',
events = '0a',
io = '0b'
}

export enum Interrupt {
run = '01',
halt = '02',
Expand Down Expand Up @@ -72,5 +86,6 @@ export namespace WARDuino {
br_table?: BRTable;
callbacks?: CallbackMapping[];
events?: InterruptEvent[];
io?: string[];
}
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ export * from './framework/scenario/Invoker';
export * from './testbeds/TestbedSpecification';
export * from './debug/Breakpoint';
export * from './reporter/index';
export * from './debug/WARDuino';

export const latch = Framework.getImplementation();
6 changes: 4 additions & 2 deletions src/messaging/Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface Request<R> {

export namespace Message {
import Float = WASM.Float;
import Inspect = WARDuino.Inspect;
export const run: Request<Ack> = {
type: Interrupt.run,
parser: (line: string) => {
Expand Down Expand Up @@ -85,10 +86,11 @@ export namespace Message {
};
}

export function inspect(payload: string): Request<State> {
export function inspect(fields: Inspect[]): Request<State> {
return {
type: Interrupt.inspect,
payload: () => payload,
payload: () => fields.length.toString(16).padStart(4, '0') + fields.join('')
,
parser: stateParser
}
}
Expand Down
47 changes: 35 additions & 12 deletions tests/examples/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ import {
Message,
Step,
Verbosity,
WASM
WASM,
WARDuino
} from '../../src/index';
import dump = Message.dump;
import stepOver = Message.stepOver;
import Inspect = WARDuino.Inspect;
import State = WARDuino.State;

const framework = Framework.getImplementation();

Expand Down Expand Up @@ -74,16 +77,16 @@ const DUMP: Step = {
title: 'Send DUMP command',
instruction: {kind: Kind.Request, value: Message.dump},
expected: [
{'pc': {kind: 'description', value: Description.defined} as Expected<string>},
{
'breakpoints': {
kind: 'comparison', value: (state: Object, value: Array<any>) => {
return value.length === 0;
}, message: 'list of breakpoints should be empty'
} as Expected<Array<any>>
},
{'callstack[0].sp': {kind: 'primitive', value: -1} as Expected<number>},
{'callstack[0].fp': {kind: 'primitive', value: -1} as Expected<number>}]
{'pc': {kind: 'description', value: Description.defined} as Expected<string>},
{
'breakpoints': {
kind: 'comparison', value: (state: Object, value: Array<any>) => {
return value.length === 0;
}, message: 'list of breakpoints should be empty'
} as Expected<Array<any>>
},
{'callstack[0].sp': {kind: 'primitive', value: -1} as Expected<number>},
{'callstack[0].fp': {kind: 'primitive', value: -1} as Expected<number>}]
};

debug.test({
Expand All @@ -92,5 +95,25 @@ debug.test({
steps: [DUMP]
});

const reverse = framework.suite('Test Reverse interface');
reverse.testee('emulator[:8530]', new EmulatorSpecification(8530));

reverse.test({
title: 'Test snapshot',
program: 'tests/examples/blink.wast',
steps: [{
title: 'Test IO snapshot',
instruction: {kind: Kind.Request, value: Message.inspect([Inspect.io])},
expected: [{
'io': {
kind: 'comparison', value: (state: State) => state.io?.length === 0
}
}],
},
new Invoker('read', [WASM.i32(BigInt(15))], WASM.i32(BigInt(0))),
new Invoker('write', [WASM.i32(BigInt(15)), WASM.i32(BigInt(1))], undefined),
new Invoker('read', [WASM.i32(BigInt(15))], WASM.i32(BigInt(1)))]
})

framework.reporter.verbosity(Verbosity.debug);
framework.analyse([spec, debug]);
framework.analyse([spec, debug, reverse]);
Loading