Testing
Unit tests
Unit tests do not need a running NGINX, only a configured source tree:
NGINX_BUILD_DIR=/path/to/nginx/objs cargo test
Integration tests
The integration tests in t/ use the
nginx-tests framework and need the
brotli command-line tool and an nginx binary built with make:
git clone https://github.com/nginx/nginx-tests
TEST_NGINX_BINARY=/path/to/nginx/objs/nginx \
TEST_NGINX_GLOBALS="load_module $PWD/target/release/libngx_mbrotli.so;" \
prove -I nginx-tests/lib t/
For Angie, point TEST_NGINX_BINARY at objs/angie.
Miri
The body filter (src/body.rs) reaches NGINX only through a small Host
trait, so Miri runs it against a model of NGINX’s buffer and chain API
(src/body/tests.rs):
rustup +nightly component add miri rust-src
cargo +nightly miri test
The model frees drained input buffers and chain links, and leaves output buffers uninitialized, so stale pointers and reads of unwritten output show up as undefined behaviour. Its thread pool is either a queue that the tests run and report on their own schedule, or real threads, so that Miri also looks for data races between the filter and the segments being encoded.
What CI runs
CI (.github/workflows/ci.yml) runs on pull requests and pushes to main:
- rustfmt and clippy;
- unit and integration tests against NGINX 1.28, 1.30 and 1.31, freenginx 1.31
and Angie 1.12, built with
--with-threads; clippy also checks a build without it; - the integration tests under AddressSanitizer and LeakSanitizer, with NGINX
and the module (including the Rust standard library) instrumented, and
NGX_DEBUG_PALLOCso that each pool allocation is checked on its own; - the unit tests under Miri.
The documentation website is built and its links checked by a separate workflow.