cli 教程

本教程介绍如何构建 floating-conformance 可执行文件,并通过它运行四个符合性运行器:既可以直接调用,也可以借助 just conformance 工具链,由它下载整套语料并规划执行。

快速入门

该可执行文件仅支持 native 目标。在仓库根目录下构建它并打印用法行:

sh tools/run_moon_clean_exec.sh run --release --target native src/cli -- --help
usage: floating-conformance --backend <gda|testfloat|mpfr|itl> [backend options]

运行仓库中提交的 GDA 冒烟测试文件(即 gda 运行器的默认路径):

sh tools/run_moon_clean_exec.sh run --release --target native src/cli -- --backend gda

运行器打印一份摘要;当所有可执行行都通过时,进程以 0 退出。

日常任务

选择后端

分发器自身选项之后的所有参数都会传给运行器:

floating-conformance --backend gda --json testdata/decimal/smoke.decTest
floating-conformance --backend itl testdata/interval/smoke.itl
floating-conformance --backend mpfr --json testdata/bin_float/mpfr-4.2.2-elementary.txt
floating-conformance --backend testfloat --function f64_mul --rounding rnear_even vectors.tv

(floating-conformance 代指构建出的可执行文件,例如 _build/conformance/gda/native/release/build/gda-conformance.exe。)

用工具链代替直接调用

对于完整语料,让 tools/conformance.py 来构建可执行文件、获取固定版本的数据、规划各阶段并行运行各分片:

just conformance build decimal_gda
just conformance smoke binary
just conformance run interval
just gate decimal_gda 8

解读退出码

0 表示成功,1 表示有失败的用例(或在严格模式下存在不支持的用例),2 表示用法、文件或解析错误。脚本应检查退出码;使用 --json 时,再解析标准输出上的那一个 JSON 对象。

深入了解

常见陷阱

  • --help 属于分发器。 --backend gda --help 打印分发器的用法并以 0 退出;它不会显示运行器的选项。
  • 默认路径是相对路径。 运行器默认读取 testdata/ 下的文件;请在仓库根目录下运行。
  • 每次调用只能使用一个后端。 --backend 只能给出一次。

后续步骤