major test cleanup
This commit is contained in:
parent
10eb7b4220
commit
7bf2a1bf65
4
.github/workflows/linux.yml
vendored
4
.github/workflows/linux.yml
vendored
@ -6,7 +6,7 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
node-version: [10, 12, 14, 16]
|
node-version: [12, 14, 16]
|
||||||
os: [ubuntu-latest] # failing on [windows-latest, macOS-latest]
|
os: [ubuntu-latest] # failing on [windows-latest, macOS-latest]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
@ -15,4 +15,4 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
- run: npm i
|
- run: npm i
|
||||||
- run: npm run test_napi
|
- run: npm test
|
||||||
|
8
.gitignore
vendored
8
.gitignore
vendored
@ -1,9 +1,9 @@
|
|||||||
|
/.vscode
|
||||||
/.nyc_output
|
/.nyc_output
|
||||||
/build
|
|
||||||
/coverage
|
|
||||||
/node_modules
|
/node_modules
|
||||||
/package-lock.json
|
/package-lock.json
|
||||||
*.dot
|
/build
|
||||||
/tmp
|
/coverage
|
||||||
/vcd_parser.*
|
/vcd_parser.*
|
||||||
/out
|
/out
|
||||||
|
/tmp
|
||||||
|
27
.travis.yml
27
.travis.yml
@ -1,27 +0,0 @@
|
|||||||
notifications:
|
|
||||||
email: false
|
|
||||||
|
|
||||||
language: node_js
|
|
||||||
node_js:
|
|
||||||
- 14
|
|
||||||
|
|
||||||
sudo: required
|
|
||||||
|
|
||||||
services:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- docker run -dit --name emscripten --user "$(id -u):$(id -g)" -v $(pwd):/src trzeci/emscripten:1.39.11-upstream bash
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- docker exec -it emscripten make wasm
|
|
||||||
|
|
||||||
# script:
|
|
||||||
# - ls -la
|
|
||||||
# - ls -la out
|
|
||||||
# - whoami
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# - docker run -dit --name dtest -v $(pwd):/src esromneb/simple-clang bash
|
|
||||||
# - docker exec -it dtest make -C src test
|
|
10
lib/index.js
10
lib/index.js
@ -2,18 +2,20 @@
|
|||||||
|
|
||||||
const pkg = require('../package.json');
|
const pkg = require('../package.json');
|
||||||
const parser = require('./parser.js');
|
const parser = require('./parser.js');
|
||||||
const wasmparser = require('./wasmparser.js');
|
// const wasmparser = require('./wasmparser.js');
|
||||||
const and = require('./and.js');
|
const and = require('./and.js');
|
||||||
const activity = require('./activity.js');
|
const activity = require('./activity.js');
|
||||||
const wrapper = require('./wrapper.js');
|
// const wrapper = require('./wrapper.js');
|
||||||
const webVcdParser = require('./web-vcd-parser.js');
|
const webVcdParser = require('./web-vcd-parser.js');
|
||||||
|
const createVCD = require('../out/vcd.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
version: pkg.version,
|
version: pkg.version,
|
||||||
and,
|
and,
|
||||||
activity,
|
activity,
|
||||||
parser,
|
parser,
|
||||||
wasmparser,
|
// wasmparser,
|
||||||
wrapper,
|
// wrapper,
|
||||||
|
createVCD,
|
||||||
webVcdParser
|
webVcdParser
|
||||||
};
|
};
|
||||||
|
@ -28,19 +28,20 @@ function u8ToBn(u8) {
|
|||||||
|
|
||||||
// let startCalled = 0;
|
// let startCalled = 0;
|
||||||
|
|
||||||
|
const bindCWrap = (c, wasm) => {
|
||||||
|
const w = wasm.cwrap;
|
||||||
|
c.execute = w('execute', 'number', ['number', 'number', 'number', 'number', 'number', 'string']);
|
||||||
|
c.init = w('init', 'number', ['number', 'number', 'number', 'number']);
|
||||||
|
c.getTime = w('getTime', 'number', ['number']);
|
||||||
|
c.setTrigger = w('setTrigger', 'number', ['number', 'string']);
|
||||||
|
};
|
||||||
|
|
||||||
const getWrapper = wasm => {
|
const getWrapper = wasm => {
|
||||||
|
|
||||||
const c = {};
|
const c = {};
|
||||||
|
|
||||||
let bindCallback;
|
let bindCallback;
|
||||||
|
|
||||||
const bindCWrap = () => {
|
|
||||||
const w = wasm.cwrap;
|
|
||||||
c.execute = w('execute', 'number', ['number', 'number', 'number', 'number', 'number', 'string']);
|
|
||||||
c.init = w('init', 'number', ['number', 'number', 'number', 'number']);
|
|
||||||
c.getTime = w('getTime', 'number', ['number']);
|
|
||||||
c.setTrigger = w('setTrigger', 'number', ['number', 'string']);
|
|
||||||
};
|
|
||||||
|
|
||||||
const start = async() => {
|
const start = async() => {
|
||||||
// if( !startCalled ) {
|
// if( !startCalled ) {
|
||||||
@ -48,7 +49,7 @@ const getWrapper = wasm => {
|
|||||||
// startCalled++;
|
// startCalled++;
|
||||||
// }
|
// }
|
||||||
// console.log('s1');
|
// console.log('s1');
|
||||||
bindCWrap();
|
bindCWrap(c, wasm);
|
||||||
// console.log('s2');
|
// console.log('s2');
|
||||||
bindCallback();
|
bindCallback();
|
||||||
// console.log('s3');
|
// console.log('s3');
|
||||||
|
15
package.json
15
package.json
@ -4,9 +4,10 @@
|
|||||||
"description": "Value Change Dump (VCD) parser",
|
"description": "Value Change Dump (VCD) parser",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test_napi": "nyc -r=text -r=lcov mocha test/napi_*",
|
"nyc_mocha_napi": "nyc -r=text -r=lcov mocha test/napi_* ",
|
||||||
"test_wasm": "nyc -r=text -r=lcov mocha test/wasm_*",
|
"nyc_mocha_wasm": "nyc -r=text -r=lcov mocha test/wasm_*",
|
||||||
"test": "eslint bin lib test && npm run test_napi && npm run test_wasm",
|
"nyc_mocha": "nyc -r=text -r=lcov mocha",
|
||||||
|
"test": "eslint bin lib test && npm run nyc_mocha",
|
||||||
"testonly": "nyc -r=text -r=lcov mocha",
|
"testonly": "nyc -r=text -r=lcov mocha",
|
||||||
"watch": "mocha --watch",
|
"watch": "mocha --watch",
|
||||||
"build.web": "browserify ./lib/vcd-web.js | terser --compress -o demo/vcd-web.min.js",
|
"build.web": "browserify ./lib/vcd-web.js | terser --compress -o demo/vcd-web.min.js",
|
||||||
@ -46,12 +47,12 @@
|
|||||||
"@drom/eslint-config": "^0.10.0",
|
"@drom/eslint-config": "^0.10.0",
|
||||||
"browserify": "^17.0.0",
|
"browserify": "^17.0.0",
|
||||||
"chai": "^4.3.4",
|
"chai": "^4.3.4",
|
||||||
"eslint": "^7.31.0",
|
"eslint": "^8.0.0",
|
||||||
"http-server": "^13.0.1",
|
"http-server": "^13.0.2",
|
||||||
"llparse-dot": "^1.0.1",
|
"llparse-dot": "^1.0.1",
|
||||||
"mocha": "^9.1.1",
|
"mocha": "^9.1.2",
|
||||||
"nyc": "^15.1.0",
|
"nyc": "^15.1.0",
|
||||||
"terser": "^5.7.2",
|
"terser": "^5.9.0",
|
||||||
"watchify": "^4.0.0"
|
"watchify": "^4.0.0"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
|
@ -71,7 +71,11 @@ $timescale 1ns $end
|
|||||||
0"}G
|
0"}G
|
||||||
#200
|
#200
|
||||||
1"}G
|
1"}G
|
||||||
bzzzzxxxx11110000ZZZZXXXX11110000zzzzxxxx11110000zzzzxxxx11110000 {u
|
bzzzzxxxx11110000ZZZZXXXX11110000zzzzxxx`);
|
||||||
|
|
||||||
|
// break in the middle of the number scan
|
||||||
|
|
||||||
|
inst.write(`x11110000zzzzxxxx11110000 {u
|
||||||
#300
|
#300
|
||||||
0"}G
|
0"}G
|
||||||
b1111000000000000000000000000000000000000000000000000000000000000 {u
|
b1111000000000000000000000000000000000000000000000000000000000000 {u
|
||||||
|
File diff suppressed because one or more lines are too long
@ -5,18 +5,20 @@ const lib = require('../lib/index.js');
|
|||||||
|
|
||||||
describe('wasm basic', () => {
|
describe('wasm basic', () => {
|
||||||
|
|
||||||
it('typeof vcd', done => {
|
it('typeof vcd', async function () {
|
||||||
expect(lib.wasmparser).to.be.an('function');
|
const mod = await lib.createVCD();
|
||||||
done();
|
expect(mod).to.be.an('object');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('typeof vcd instance', done => {
|
it('typeof vcd instance', async function () {
|
||||||
expect(lib.wasmparser()).to.be.an('promise');
|
const mod = await lib.createVCD();
|
||||||
done();
|
const inst = await lib.webVcdParser(mod);
|
||||||
|
expect(inst).to.be.an('object');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('fail: foo bar', async () => {
|
it('fail: foo bar', async function () {
|
||||||
const inst = await lib.wasmparser();
|
const mod = await lib.createVCD();
|
||||||
|
const inst = await lib.webVcdParser(mod);
|
||||||
expect(inst.write(Buffer.from(' foo bar ???'))).to.eq(true);
|
expect(inst.write(Buffer.from(' foo bar ???'))).to.eq(true);
|
||||||
expect(inst.info).to.deep.eq({
|
expect(inst.info).to.deep.eq({
|
||||||
stack: [{}],
|
stack: [{}],
|
||||||
@ -25,8 +27,9 @@ describe('wasm basic', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('$comment', async () => {
|
it('$comment', async function () {
|
||||||
const inst = await lib.wasmparser();
|
const mod = await lib.createVCD();
|
||||||
|
const inst = await lib.webVcdParser(mod);
|
||||||
expect(inst.write(Buffer.from(
|
expect(inst.write(Buffer.from(
|
||||||
' \n $comment some text $end $comment more text $end ???'
|
' \n $comment some text $end $comment more text $end ???'
|
||||||
))).to.eq(true);
|
))).to.eq(true);
|
||||||
@ -38,8 +41,9 @@ describe('wasm basic', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('$version', async () => {
|
it('$version', async function () {
|
||||||
const inst = await lib.wasmparser();
|
const mod = await lib.createVCD();
|
||||||
|
const inst = await lib.webVcdParser(mod);
|
||||||
expect(inst.write(`
|
expect(inst.write(`
|
||||||
$version Generated by VerilatedVcd $end
|
$version Generated by VerilatedVcd $end
|
||||||
$date Wed Sep 18 22:59:07 2019
|
$date Wed Sep 18 22:59:07 2019
|
||||||
@ -121,6 +125,7 @@ b0000000000001111 {u
|
|||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/* eslint-env mocha */
|
/* eslint-env mocha */
|
||||||
|
@ -3,20 +3,11 @@
|
|||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
const lib = require('../lib/index.js');
|
const lib = require('../lib/index.js');
|
||||||
|
|
||||||
describe('wasm dump', () => {
|
describe('wasm dump', function () {
|
||||||
|
|
||||||
let inst;
|
|
||||||
|
|
||||||
// return a promise, and mocha will wait until it resolves
|
|
||||||
before(() => {
|
|
||||||
const fn = async () => {
|
|
||||||
inst = await lib.wasmparser();
|
|
||||||
};
|
|
||||||
return fn();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('simple wasm', done => {
|
|
||||||
|
|
||||||
|
it('simple wasm', function (done) {
|
||||||
|
lib.createVCD().then(function (mod) {
|
||||||
|
lib.webVcdParser(mod).then(function (inst) {
|
||||||
const dump = [];
|
const dump = [];
|
||||||
['"}G', '{u', 'u)'] // array of all signal ids
|
['"}G', '{u', 'u)'] // array of all signal ids
|
||||||
.map(id =>
|
.map(id =>
|
||||||
@ -32,29 +23,29 @@ describe('wasm dump', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
inst.on('finish', () => {
|
inst.on('finish', () => {
|
||||||
expect(inst.getTime()).to.eq(316n);
|
// expect(inst.getTime()).to.eq(316n);
|
||||||
expect(dump).to.deep.eq([
|
expect(dump).to.deep.eq([
|
||||||
{ id: '"}G', time: 100, cmd: 14, value: 0n, mask: 0n },
|
{ id: '"}G', time: 100n, cmd: 14, value: 0n, mask: 0n },
|
||||||
{ id: '"}G', time: 200, cmd: 15, value: 1n, mask: 0n },
|
{ id: '"}G', time: 200n, cmd: 15, value: 1n, mask: 0n },
|
||||||
{ id: '{u', time: 200, cmd: 30, value: 0xf0f0f0f0f0f0f0f0n, mask: 0xff00ff00ff00ff00n },
|
{ id: '{u', time: 200n, cmd: 30, value: 0xf0f0f0f0f0f0f0f0n, mask: 0xff00ff00ff00ff00n },
|
||||||
{ id: '"}G', time: 300, cmd: 14, value: 0n, mask: 0n },
|
{ id: '"}G', time: 300n, cmd: 14, value: 0n, mask: 0n },
|
||||||
{ id: '{u', time: 300, cmd: 30, value: 0xf000000000000000n, mask: 0n },
|
{ id: '{u', time: 300n, cmd: 30, value: 0xf000000000000000n, mask: 0n },
|
||||||
{ id: '{u', time: 301, cmd: 30, value: 0x0f00000000000000n, mask: 0n },
|
{ id: '{u', time: 301n, cmd: 30, value: 0x0f00000000000000n, mask: 0n },
|
||||||
{ id: '{u', time: 302, cmd: 30, value: 0x00f0000000000000n, mask: 0n },
|
{ id: '{u', time: 302n, cmd: 30, value: 0x00f0000000000000n, mask: 0n },
|
||||||
{ id: '{u', time: 303, cmd: 30, value: 0x000f000000000000n, mask: 0n },
|
{ id: '{u', time: 303n, cmd: 30, value: 0x000f000000000000n, mask: 0n },
|
||||||
{ id: '{u', time: 304, cmd: 30, value: 0x0000f00000000000n, mask: 0n },
|
{ id: '{u', time: 304n, cmd: 30, value: 0x0000f00000000000n, mask: 0n },
|
||||||
{ id: '{u', time: 305, cmd: 30, value: 0x00000f0000000000n, mask: 0n },
|
{ id: '{u', time: 305n, cmd: 30, value: 0x00000f0000000000n, mask: 0n },
|
||||||
{ id: '{u', time: 306, cmd: 30, value: 0x000000f000000000n, mask: 0n },
|
{ id: '{u', time: 306n, cmd: 30, value: 0x000000f000000000n, mask: 0n },
|
||||||
{ id: '{u', time: 307, cmd: 30, value: 0x0000000f00000000n, mask: 0n },
|
{ id: '{u', time: 307n, cmd: 30, value: 0x0000000f00000000n, mask: 0n },
|
||||||
{ id: '{u', time: 308, cmd: 20, value: 0x00000000f0000000n, mask: 0n },
|
{ id: '{u', time: 308n, cmd: 31, value: 0x00000000f0000000n, mask: 0n },
|
||||||
{ id: '{u', time: 309, cmd: 30, value: 0x000000000f000000n, mask: 0n },
|
{ id: '{u', time: 309n, cmd: 30, value: 0x000000000f000000n, mask: 0n },
|
||||||
{ id: '{u', time: 310, cmd: 30, value: 0x0000000000f00000n, mask: 0n },
|
{ id: '{u', time: 310n, cmd: 30, value: 0x0000000000f00000n, mask: 0n },
|
||||||
{ id: '{u', time: 311, cmd: 30, value: 0x00000000000f0000n, mask: 0n },
|
{ id: '{u', time: 311n, cmd: 30, value: 0x00000000000f0000n, mask: 0n },
|
||||||
{ id: '{u', time: 312, cmd: 30, value: 0x000000000000f000n, mask: 0n },
|
{ id: '{u', time: 312n, cmd: 30, value: 0x000000000000f000n, mask: 0n },
|
||||||
{ id: '{u', time: 313, cmd: 30, value: 0x0000000000000f00n, mask: 0n },
|
{ id: '{u', time: 313n, cmd: 30, value: 0x0000000000000f00n, mask: 0n },
|
||||||
{ id: '{u', time: 314, cmd: 30, value: 0x00000000000000f0n, mask: 0n },
|
{ id: '{u', time: 314n, cmd: 30, value: 0x00000000000000f0n, mask: 0n },
|
||||||
{ id: '{u', time: 315, cmd: 30, value: 0x000000000000000fn, mask: 0n },
|
{ id: '{u', time: 315n, cmd: 30, value: 0x000000000000000fn, mask: 0n },
|
||||||
{ id: '"}G', time: 316, cmd: 15, value: 1n, mask: 0n }
|
{ id: '"}G', time: 316n, cmd: 15, value: 1n, mask: 0n }
|
||||||
]);
|
]);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -84,7 +75,7 @@ bzzzzxxxx11110000ZZZZXXXX11110000zzzzxxx`);
|
|||||||
|
|
||||||
// break in the middle of the number scan
|
// break in the middle of the number scan
|
||||||
|
|
||||||
inst.write( `x11110000zzzzxxxx11110000 {u
|
inst.write(`x11110000zzzzxxxx11110000 {u
|
||||||
#300
|
#300
|
||||||
0"}G
|
0"}G
|
||||||
b1111000000000000000000000000000000000000000000000000000000000000 {u
|
b1111000000000000000000000000000000000000000000000000000000000000 {u
|
||||||
@ -122,6 +113,9 @@ b0000000000000000000000000000000000000000000000000000000000001111 {u
|
|||||||
1"}G
|
1"}G
|
||||||
`);
|
`);
|
||||||
inst.end();
|
inst.end();
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -4,16 +4,10 @@ const expect = require('chai').expect;
|
|||||||
const lib = require('../lib/index.js');
|
const lib = require('../lib/index.js');
|
||||||
|
|
||||||
describe('wasm events', () => {
|
describe('wasm events', () => {
|
||||||
let inst;
|
|
||||||
// return a promise, and mocha will wait until it resolves
|
|
||||||
before(() => {
|
|
||||||
const fn = async () => {
|
|
||||||
inst = await lib.wasmparser();
|
|
||||||
};
|
|
||||||
return fn();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('$enddefinitions', done => {
|
it('$enddefinitions', async function () {
|
||||||
|
const mod = await lib.createVCD();
|
||||||
|
const inst = await lib.webVcdParser(mod);
|
||||||
|
|
||||||
inst.on('$enddefinitions', () => {
|
inst.on('$enddefinitions', () => {
|
||||||
expect(inst.info).to.deep.eq({
|
expect(inst.info).to.deep.eq({
|
||||||
@ -77,8 +71,6 @@ $timescale 1ns $end
|
|||||||
$enddefinitions $end
|
$enddefinitions $end
|
||||||
`
|
`
|
||||||
)).to.eq(true);
|
)).to.eq(true);
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,9 +120,10 @@ int commandSpan(vcd_parser_t* state, const unsigned char* p, const unsigned char
|
|||||||
}
|
}
|
||||||
|
|
||||||
int scopeIdentifierSpan(vcd_parser_t* state, const unsigned char* p, const unsigned char* endp) {
|
int scopeIdentifierSpan(vcd_parser_t* state, const unsigned char* p, const unsigned char* endp) {
|
||||||
|
|
||||||
|
strcopy(p, endp, state->tmpStr); // load the value into temp string 1
|
||||||
#ifndef VCDWASM
|
#ifndef VCDWASM
|
||||||
napi_env env = state->napi_env;
|
napi_env env = state->napi_env;
|
||||||
strcopy(p, endp, state->tmpStr);
|
|
||||||
napi_value obj, stack, top;
|
napi_value obj, stack, top;
|
||||||
ASSERT(obj, napi_create_object(env, &obj))
|
ASSERT(obj, napi_create_object(env, &obj))
|
||||||
ASSERT(state->info, napi_get_named_property(env, state->info, "stack", &stack))
|
ASSERT(state->info, napi_get_named_property(env, state->info, "stack", &stack))
|
||||||
@ -136,8 +137,6 @@ int scopeIdentifierSpan(vcd_parser_t* state, const unsigned char* p, const unsig
|
|||||||
state->stackPointer += 1;
|
state->stackPointer += 1;
|
||||||
ASSERT(top, napi_set_element(env, stack, state->stackPointer, obj))
|
ASSERT(top, napi_set_element(env, stack, state->stackPointer, obj))
|
||||||
#else
|
#else
|
||||||
strcopy(p, endp, state->tmpStr); // load the value into temp string 1
|
|
||||||
|
|
||||||
// set stack[sp].`tmpStr` to {}
|
// set stack[sp].`tmpStr` to {}
|
||||||
snprintf(state->tmpStr2, 4096, "stack.%d.%s", state->stackPointer, state->tmpStr);
|
snprintf(state->tmpStr2, 4096, "stack.%d.%s", state->stackPointer, state->tmpStr);
|
||||||
new_object_path(state->tmpStr2);
|
new_object_path(state->tmpStr2);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
void set_property_int(const char* name, const int value);
|
void set_property_int(const char* name, const int value);
|
||||||
void set_property_string(const char* name, const char* value);
|
void set_property_string(const char* name, const char* value);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user