Testing NASM
============
We use [Travis CI](https://travis-ci.org/) service to execute NASM tests,
which basically prepares the environment and runs our `nasm-t.py` script.
The script scans a testing directory for `*.json` test descriptor files
and runs test by descriptor content.
Test engine
-----------
`nasm-t.py` script is a simple test engine written by Python3 language
which allows either execute a single test or run them all in a sequence.
A typical test case processed by the following steps:
- a test descriptor get parsed to figure out which arguments
are to be provided into the NASM command line;
- invoke the NASM with arguments;
- compare generated files with precompiled templates.
`nasm-t.py` supports the following commands:
- `list`: to list all test cases
- `run`: to run test cases
- `update`: to update precompiled templates
Use `nasm-t.py -h` command to get the detailed description of every option.
### Test unit structure
Each test consists at least of three files:
- a test descriptor in with `*.json` extension;
- a source file to compile;
- a target file to compare result with, it is assumed to have
the same name as output generated during the pass file but with `*.t`
extension; thus if a test generates `*.bin` file the appropriate target
should have `*.bin.t` name.
Running tests
-------------
To run all currently available tests simply type the following
```console
python3 travis/nasm-t.py run
```
By default the `nasm-t.py` scans `test` subdirectory for `*.json` files and
consider each as a test descriptor. Then every test is executed sequentially.
If the descriptor can not be parsed it silently ignored.
To run a particular test provide the test name, for example
```console
python3 travis/nasm-t.py list
...
./travis/test/utf Test __utf__ helpers
./travis/test/utf Test errors in __utf__ helpers
...
python3 travis/nasm-t.py run -t ./travis/test/utf
```
Test name duplicates in the listing above means that the descriptor
carries several tests with same name but different options.
Test descriptor file
--------------------
A descriptor file should provide enough information how to run the NASM
itself and which output files or streams to compare with predefined ones.
We use *JSON* format with the following fields:
- `description`: a short description of a test which is shown to
a user when tests are being listed;
- `id`: descriptor internal name to use with `ref` field;
- `ref`: a reference to `id` from where settings should be
copied, it is convenient when say only `option` is different
while the rest of the fields are the same;
- `format`: NASM output format to use (`bin`,`elf` and etc);
- `source`: is a source file name to compile, this file must
be shipped together with descriptor file itself;
- `option`: an additional option passed to the command line;
- `update`: a trigger to skip updating targets when running
an update procedure;
- `target`: an array of targets which the test engine should
check once compilation finished:
- `stderr`: a file containing *stderr* stream output to check;
- `stdout`: a file containing *stdout* stream output to check;
- `output`: a file containing compiled result to check, in other
words it is a name passed as `-o` option to the compiler;
- `error`: an error handler, can be either *over* to ignore any
error happened, or *expected* to make sure the test is failing.
### Examples
A simple test where no additional options are used, simply compile
`absolute.asm` file with `bin` format for output, then compare
produced `absolute.bin` file with precompiled `absolute.bin.t`.
```json
{
"description": "Check absolute addressing",
"format": "bin",
"source": "absolute.asm",
"target": [
{ "output": "absolute.bin" }
]
}
```
Note the `output` target is named as *absolute.bin* where *absolute.bin.t*
should be already precompiled (we will talk about it in `update` action)
and present on disk.
A slightly complex example: compile one source file with different optimization
options and all results must be the same. To not write three descriptors
we assign `id` to the first one and use `ref` term to copy settings.
Also, it is expected that `stderr` stream will not be empty but carry some
warnings to compare.
```json
[
{
"description": "Check 64-bit addressing (-Ox)",
"id": "addr64x",
"format": "bin",
"source": "addr64x.asm",
"option": "-Ox",
"target": [
{ "output": "addr64x.bin" },
{ "stderr": "addr64x.stderr" }
]
},
{
"description": "Check 64-bit addressing (-O1)",
"ref": "addr64x",
"option": "-O1",
"update": "false"
},
{
"description": "Check 64-bit addressing (-O0)",
"ref": "addr64x",
"option": "-O0",
"update": "false"
}
]
```
Updating tests
--------------
If during development some of the targets are expected to change
the tests will start to fail so the should be updated. Thus new
precompiled results will be treated as templates to compare with.
To update all tests in one pass run
```console
python3 travis/nasm-t.py update
...
=== Updating ./travis/test/xcrypt ===
Processing ./travis/test/xcrypt
Executing ./nasm -f bin -o ./travis/test/xcrypt.bin ./travis/test/xcrypt.asm
Moving ./travis/test/xcrypt.bin to ./travis/test/xcrypt.bin.t
=== Test ./travis/test/xcrypt UPDATED ===
...
```
and commit the results. To update a particular test provide its name
with `-t` option.
没有合适的资源?快使用搜索试试~ 我知道了~
nasm-2.15.tar.gz
需积分: 1 0 下载量 178 浏览量
2023-11-03
16:15:14
上传
评论
收藏 1.51MB GZ 举报
温馨提示
共974个文件
asm:332个
t:135个
json:116个
nasm开源软件源码
资源推荐
资源详情
资源评论
收起资源包目录
nasm-2.15.tar.gz (974个子文件)
nasm.1 14KB
ndisasm.1 4KB
rdf2bin.1 1KB
ldrdf.1 1KB
rdflib.1 879B
rdfdump.1 758B
rdx.1 444B
rdf2ith.1 19B
rdf2srec.1 19B
rdf2ihx.1 19B
rdf2com.1 19B
configure.ac 11KB
proc32.ash 12KB
avx512f.asm 1023KB
avx512f.asm 1023KB
riprel.asm 178KB
riprel.asm 178KB
br3392668-3.asm 128KB
avx2.asm 127KB
tmap.asm 42KB
br3392667.asm 29KB
avx005.asm 22KB
avx005.asm 22KB
lwp.asm 21KB
avx512er.asm 18KB
avx512er.asm 18KB
testnos3.asm 15KB
testnos3.asm 15KB
floatexp.asm 13KB
avx512cd.asm 13KB
avx512cd.asm 13KB
floatexp.asm 13KB
floatx.asm 12KB
changed.asm 10KB
avx512pf.asm 10KB
avx512pf.asm 10KB
ifmacro.asm 5KB
ifmacro.asm 5KB
ilog2.asm 5KB
br2148476.asm 5KB
br2148476.asm 5KB
alonesym-obj.asm 4KB
alonesym-obj.asm 4KB
iftoken.asm 4KB
iftoken.asm 4KB
elf64so.asm 3KB
float.asm 3KB
fpu.asm 3KB
fpu.asm 3KB
float.asm 3KB
aoutso.asm 3KB
elfso.asm 3KB
elfso.asm 3KB
br3392669-57.asm 3KB
expimp.asm 3KB
expimp.asm 3KB
mpx-64.asm 3KB
mpx-64.asm 3KB
aoutso.asm 3KB
float8.asm 2KB
k_test.asm 2KB
float8.asm 2KB
aouttest.asm 2KB
fwdoptpp.asm 2KB
cofftest.asm 2KB
elftest.asm 2KB
objtest.asm 2KB
obj.asm 2KB
aouttest.asm 2KB
vgather.asm 2KB
imm64.asm 2KB
fwdoptpp.asm 2KB
multisection.asm 2KB
multisection.asm 2KB
imul.asm 2KB
mpx.asm 2KB
mpx.asm 2KB
fwdopt.asm 2KB
optimization.asm 2KB
fwdopt.asm 2KB
imm64.asm 2KB
imul.asm 2KB
dtbcd.asm 2KB
utf.asm 2KB
macro-defaults.asm 2KB
macro-defaults.asm 2KB
bintest.asm 2KB
lar_lsl.asm 2KB
optimization.asm 1KB
lar_lsl.asm 1KB
utf.asm 1KB
immwarn.asm 1KB
immwarn.asm 1KB
br3066383.asm 1KB
bintest.asm 1KB
pinsr64.asm 1KB
rdftest1.asm 1KB
br3066383.asm 1KB
pinsr64.asm 1KB
floatb.asm 1KB
共 974 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
资源评论
21岁被迫秃头
- 粉丝: 2w+
- 资源: 26
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功