Our Continuous Integration (CI) pipeline is implemented on top of Buildkite. For the complete list of tests, check our CI pipeline.
Each individual test runs in a container. To reproduce a test locally, you can use the dev-container on both x86 and arm64.
container_version=11
docker run -it \
--security-opt seccomp=unconfined \
--volume $(pwd):/linux-loader \
rustvmm/dev:v${container_version}
cd linux-loader/
cargo test --all-features
The kernel images used in the unit tests fall into 3 categories:
- downloaded from known distro sources using the download script.
- fuzzing images; these images were generated by fuzzers such as
libfuzzer
orafl
starting from an existing image already used by the unit tests. These are named withfuzz_
so that they are easy to identify. - generated images (either by building the Linux kernel, or by using other tools such as ELFIO).
The PE image used by the linux-loader unit tests is built on an aarch64
machine using the following commands:
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git checkout v4.20
# To be able to run the following command, you'll need to install
# flex and bison.
make allnoconfig
make Image
head -c 4096 arch/arm64/boot/Image > test_image.bin
Generating ELF
images with ELFIO
All the ELF files used in linux-loader
are generated using the ELFIO
tool.
The .cpp
source files are created from the ELFIO writer
example, with minimal changes on top.
The next section includes an example of how to use the source files to generate the binaries used in the unit tests.
Source File | Generated Binary File |
---|---|
bad_align_writer.cpp | test_bad_align.bin |
invalid_pvh_note_writer.cpp | test_invalid_pvh_note.bin |
dummy_note.cpp | test_dummy_note.bin |
basic_elf.cpp | test_elf.bin |
ignored_phv.cpp | test_elfnote.bin |
ignored_phv_8byte_align.cpp | test_elfnote_8byte_align.bin |
git clone [email protected]:serge1/ELFIO.git
# Copy the bad_align_writer.cpp file from this repo to the ELFIO path.
cp "${LINUX_LOADER_PATH}/docs/elfio_files/bad_align_writer.cpp" "${ELFIO_PATH}"
cd "${ELFIO_PATH}"
# The images in this repo were built from the`57e614a` commit.
git checkout 57e614a
g++ bad_align_writer.cpp -o bad_align_writer -I. -std=c++11
./bad_align_writer
cp test_bad_align.bin "${LINUX_LOADER_PATH}/src/loader/elf/"