Name Date Size #Lines LOC

..15-May-2026-

filetests/H15-May-2026-339,259313,791

src/H15-May-2026-3,8322,851

Cargo.tomlH A D15-May-20261.5 KiB4340

LICENSEH A D15-May-202612 KiB221182

README.mdH A D15-May-20261.2 KiB3726

README.md

1# filetests
2
3Filetests is a crate that contains multiple test suites for testing
4various parts of cranelift. Each folder under `cranelift/filetests/filetests` is a different
5test suite that tests different parts.
6
7## Adding a runtest
8
9One of the available testsuites is the "runtest" testsuite. Its goal is to compile some piece
10of clif code, run it and ensure that what comes out is what we expect.
11
12To build a run test you can add the following to a file:
13
14```
15test interpret
16test run
17target x86_64
18target aarch64
19target s390x
20
21function %band_f32(f32, f32) -> f32 {
22block0(v0: f32, v1: f32):
23    v2 = band v0, v1
24    return v2
25}
26; run: %band_f32(0x0.5, 0x1.0) == 0x1.0p-2
27```
28
29Since this is a run test for `band` we can put it in: `runtests/band.clif`.
30Once we have the file in the test suite we can run it by invoking: `cargo run -- test filetests/filetests/runtests/band.clif` from the cranelift directory.
31
32
33The first lines tell `clif-util` what kind of tests we want to run on this file.
34`test interpret` invokes the interpreter and checks if the conditions in the `; run` comments pass. `test run` does the same, but compiles the file and runs it as a native binary.
35
36For more information about testing see [testing.md](../docs/testing.md).
37