| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 1 个月前 | ||
| 8 个月前 | ||
| 7 个月前 | ||
| 8 个月前 | ||
| 1 个月前 |
C2Rust testsuite
Prerequisites
- the following binaries in path
uv: https://docs.astral.sh/uv/getting-started/installation/c2rust: https://github.com/immunant/c2rust?tab=readme-ov-file#installationintercept-build:pip3 install -r requirements.txt
- any other packages and binaries required by the tests themselves
- captured in
**/requirements.yml
- captured in
Command line interface
$ ./test.py # test everything
$ ./test.py --verbose # show test output
$ ./test.py lua # run specific project
$ ./test.py lua --stage transpile # run specific stage of project
Adding new tests as git submodules
cd path/to/tests/$PROJ
git submodule add --depth 10 $PROJ_URL repo
To track a specific branch ($SUBMOD_NAME can be found in .gitmodules):
git config -f .gitmodules submodule.$SUBMOD_NAME.branch $BRANCH_NAME
git submodule update --remote repo
Make sure to set update = none in .gitmodules, too,
or else cargo git dependencies on c2rust will clone them, too.
git config -f .gitmodules submodule.$SUBMOD_NAME.update none
Adding test steps
Each test stage can be controlled with a script (in tests/$PROJ) named as follows:
- autogen stage ->
autogen.sh - configure stage ->
configure.sh - make stage ->
make.sh|cmake.sh - transpile stage ->
transpile.sh|transpile.gen.sh|cmake.sh - cargo build stage ->
cargo.sh|cargo.gen.sh - test stage ->
check.sh|test.sh
note the .gen.sh suffix are used to mark scripts generated automatically. Generation is requested via conf.yml like this:
transpile:
autogen: true
cargo:
autogen: true
Unlike hand-written scripts, autogenerated ones are not version controlled.
Each script is expected to tee its output to a file named $SCRIPT.log. For example, make.sh produces make.sh.log.
Controlling test steps via environment variables
Use the following optional variables to control test steps:
EXTRA_CFLAGSpasses extra flags to the compiler when transpilingEXTRA_TFLAGSpasses extra flags to the transpiler itselfTOOLCHAINcontrols which toolchaincargo builds the transpiled code (must start with a + character)C2RUST_DIRis the path to a local checkout of the c2rust sources. Runtime support crates from this checkout will be used instead of pulling them from crates.io.
TODOs
-
- allow cargo build and transpile steps w/o scripts