[go: nahoru, domu]

Skip to content

Running Tests, Fuzzers

Nabil S. Alramli edited this page May 4, 2021 · 5 revisions

H2O uses two main facilities for tests: unit tests in C and integration tests written mostly in perl.

Unit tests are found under t/00unit directory, and use picotest as a testing framework.

Integration tests are found under the t/ directory, and are any file ending with .t extension. The test suite uses Test::More as a testing framework. t/Util.pm offers facilities like running curl for all supported protocols, spawning H2O or instantiating a backend server using Plackup.

Running the tests using Docker

The easiest way of running the tests is to use the pre-built Docker image. The following command pulls the image from Docker Hub, and runs the tests using the h2o source repository in the current directory.

make -f misc/docker-ci/check.mk pull ALL

Running the tests manually

Both tests can be run with make check. Some tests require to be run with root privilege through sudo. You might need dependencies such as curl or nghttp2, or some perl modules. You can refer to the misc/docker-ci/Dockerfile file for an example of how to install the dependencies.

Single tests can be run manually by running PERL5LIB=. perl t/<test>.t, in which case, you might have to set the environment variable H2O_ROOT to the root of the H2O repository since some tests rely on it, and also BINARY_DIR to the binary directory if you are building them off-the-source.

Fuzzers

H2O is part of Google's OSS-Fuzz project, and as such H2O is continuously fuzzed. Fuzzers are build when cmake is passed the -DBUILD_FUZZER=ON flag, they use libFuzzer. Anything that parses input from the network is a good candidate for fuzzing.