文件最后提交记录最后更新时间
1 个月前
8 个月前
7 个月前
8 个月前
1 个月前
README

C2Rust testsuite

Prerequisites

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_CFLAGS passes extra flags to the compiler when transpiling
  • EXTRA_TFLAGS passes extra flags to the transpiler itself
  • TOOLCHAIN controls which toolchain cargo builds the transpiled code (must start with a + character)
  • C2RUST_DIR is 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