blob: ea05f9f15ba9b12fa4fb15bbac91962a2718a18d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
// run a generated image directly, avoiding compiler time in vm execution tests.
const fs = require('fs');
const { TinyVM } = require('../../build/js/tinyvm.js');
const { mapValues } = require('../../src/js/mapvalues.js');
// usage: node tests/drivers/image_run.js genome.bin memmap.h [--stdin]
const image = fs.readFileSync(process.argv[2]);
const layout = mapValues(process.argv[3], ['GORG', 'DS0', 'DSLIM', 'RS0', 'RSLIM', 'SYSGATE', 'ZFP', 'HEAP_LO', 'HEAP_HI']);
const machine = new TinyVM({ layout, onMessage: message => process.stderr.write(message) });
machine.loadImage(image, layout.GORG);
if (process.argv[4] === '--stdin') machine.setInput(fs.readFileSync(0));
const status = machine.run();
process.stdout.write(machine.getOutput());
process.exit(status);
|