-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update test and fix unspecified error in keystone
- Loading branch information
1 parent
baa4937
commit 0dc560d
Showing
5 changed files
with
6,984 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,69 @@ | ||
|
||
const opcodes = [ | ||
{ asm: 'orr x1, x2, x3', big: '0xaa030041', little: '41 00 03 AA' }, | ||
{ asm: 'orr x1, x2, x5', big: '0xaa050041', little: '41 00 05 AA' }, | ||
{ asm: 'orr x1, x2, x10', big: '0xaa0a0041', little: '41 00 0A AA' }, | ||
]; | ||
|
||
describe('aslp-web tests', () => { | ||
it('synchronises with big-endian input', () => { | ||
// cy.intercept('GET', 'aslp.heap').as('heap'); | ||
cy.aslpweb().then(() => { | ||
cy.getByLabel('big-endian').type('{selectall}0xaa030041').then(x => { | ||
cy.getByLabel('assembly').should('have.value', 'orr x1, x2, x3'); | ||
cy.getByLabel('little-endian').should('have.value', '41 00 03 AA'); | ||
}); | ||
}); | ||
}); | ||
it('synchronises valid inputs', () => { | ||
cy.aslpweb(); | ||
|
||
cy.getByLabel('big-endian').type('{selectall}' + opcodes[0].big); | ||
cy.getByLabel('assembly').should('have.value', opcodes[0].asm); | ||
cy.getByLabel('little-endian').should('have.value', opcodes[0].little); | ||
|
||
cy.getByLabel('little-endian').type('{selectall}' + opcodes[1].little); | ||
cy.getByLabel('big-endian').should('have.value', opcodes[1].big); | ||
cy.getByLabel('assembly').should('have.value', opcodes[1].asm); | ||
|
||
it('synchronises with little-endian input', () => { | ||
cy.aslpweb().then(() => { | ||
cy.getByLabel('little-endian').type('{selectall}41 00 03 AA').then(x => { | ||
cy.getByLabel('big-endian').should('have.value', '0xaa030041'); | ||
cy.getByLabel('assembly').should('have.value', 'orr x1, x2, x3'); | ||
}); | ||
}); | ||
cy.getByLabel('assembly').type('{selectall}' + opcodes[2].asm); | ||
cy.getByLabel('big-endian').should('have.value', opcodes[2].big); | ||
cy.getByLabel('little-endian').should('have.value', opcodes[2].little); | ||
}); | ||
|
||
it('synchronises with asm input', () => { | ||
cy.aslpweb().then(() => { | ||
cy.getByLabel('assembly').type('{selectall}orr x1, x2, x3').then(x => { | ||
cy.getByLabel('big-endian').should('have.value', '0xaa030041'); | ||
cy.getByLabel('little-endian').should('have.value', '41 00 03 AA'); | ||
}); | ||
}); | ||
it('synchronises and rejects invalid inputs', () => { | ||
cy.aslpweb(); | ||
|
||
cy.getByLabel('little-endian').type('{selectall}' + '41 00 0A AA 1'); | ||
cy.getByLabel('big-endian').should('have.value', '0x01aa0a0041'); | ||
cy.getByLabel('assembly').should('have.value', ''); | ||
cy.contains('bytes input:').should('be.visible').and('have.class', 'stderr'); | ||
|
||
cy.getByLabel('assembly').type('{selectall}' + 'an invalid assembly'); | ||
cy.getByLabel('big-endian').should('have.value', ''); | ||
cy.getByLabel('little-endian').should('have.value', ''); | ||
cy.contains('asm input:').should('be.visible').and('have.class', 'stderr'); | ||
}); | ||
|
||
it('disassembles', () => { | ||
cy.aslpweb().then(() => { | ||
cy.getByLabel('big-endian').type('{selectall}0xaa030041').then(x => { | ||
cy.get('button[type=submit]').click().then(x => { | ||
cy.get('#output').should('contain', 'aarch64_integer_logical_shiftedreg').and('contain', 'or_bits'); | ||
}); | ||
}); | ||
}); | ||
cy.aslpweb(); | ||
cy.getByLabel('big-endian').type('{selectall}0xaa030041'); | ||
cy.get('button[type=submit]').click(); | ||
cy.get('#output') | ||
.should('contain', 'aarch64_integer_logical_shiftedreg') | ||
.and('contain', 'or_bits'); | ||
|
||
cy.getByLabel('assembly').type('{selectall}' + 'add v0.4h, v0.4h, v0.4h'); | ||
cy.get('button[type=submit]').click(); | ||
cy.get('#output') | ||
.should('contain', 'aarch64_vector_arithmetic_binary_uniform_add_wrapping_single_simd') | ||
.and('not.contain', 'add_vec') | ||
.and('contain', 'add_bits'); | ||
|
||
cy.getByLabel('vector').check({ force: true }); | ||
cy.get('button[type=submit]').click(); | ||
cy.get('#output') | ||
.should('contain', 'aarch64_vector_arithmetic_binary_uniform_add_wrapping_single_simd') | ||
.and('contain', 'add_vec'); | ||
}); | ||
|
||
it('parses options from url', () => { | ||
cy.aslpweb('?opcode=0xaa030041&bytes=41+00+03+AA&asm=orr+x1%2C+x2%2C+x3&debug=1').then(() => { | ||
cy.get('#output').should('contain', 'aarch64_integer_logical_shiftedreg').and('contain', 'or_bits').and('contain', 'dis_decode_case'); | ||
}); | ||
cy.aslpweb('?opcode=0xaa030041&bytes=41+00+03+AA&asm=orr+x1%2C+x2%2C+x3&debug=1'); | ||
cy.get('#output') | ||
.should('contain', 'aarch64_integer_logical_shiftedreg') | ||
.and('contain', 'or_bits') | ||
.and('contain', 'dis_decode_case'); | ||
}); | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import './builder.bc.js'; | ||
import * as pako from './lib/pako.esm.mjs'; | ||
|
||
const IS_NODE = typeof self !== 'object'; | ||
const fs = IS_NODE ? await import('fs') : null; | ||
const path = IS_NODE ? await import('path') : null; | ||
|
||
export const marshal = () => { | ||
if (!IS_NODE) throw Error("marshalling only supported on node"); | ||
|
||
console.log('marshalling aslp environment...'); | ||
const arr = pako.gzip(libASL_builder.marshal(libASL_builder.force())); | ||
|
||
let marshalUrl; | ||
if (IS_NODE) { | ||
fs.writeFileSync('aslp.heap', Buffer.from(arr)); | ||
marshalUrl = path.resolve('.', 'aslp.heap'); | ||
|
||
} else { | ||
marshalUrl = URL.createObjectURL( | ||
new File( | ||
[arr], | ||
'aslp.heap', | ||
{ lastModified: Date.now(), type: 'application/octet-stream' })); | ||
|
||
} | ||
console.log(marshalUrl); | ||
}; | ||
|
||
|
||
export const unmarshal = async (/* ArrayBuffer */ buf) => { | ||
try { | ||
const arr = pako.ungzip(new Uint8Array(buf)); | ||
|
||
libASL_web.unmarshal(arr); | ||
console.log(`heap loaded: ${arr.length} bytes, ${buf.byteLength} compressed`); | ||
|
||
} catch (e) { | ||
console.warn('failed to fetch heap'); | ||
console.warn(e); | ||
} | ||
}; | ||
|
||
if (IS_NODE) { | ||
marshal(); | ||
} |
Oops, something went wrong.