Skip to content

Add Integration Test #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ indent_size = 4
trim_trailing_whitespace = true
max_line_length = 80

[*.yml]
[{*.nix, *.yml}]
indent_size = 2
34 changes: 34 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,37 @@ jobs:
do-style-check: true
do-test: false
features: builder,unstable

integrationtest:
name: integrationtest
needs:
- build_nightly
- build_nostd_nightly
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
with:
# This channel is only required to invoke "nix-shell".
# Everything inside that nix-shell will use a pinned version of
# nixpkgs.
nix_path: nixpkgs=channel:nixos-23.05
- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
integration-test/bins/target/
# Hash over Cargo.toml and Cargo.lock, as this might be copied to
# projects that do not have a Cargo.lock in their repository tree!
key: ${{ runner.os }}-${{ github.job }}-${{ hashFiles('integration-test/**/Cargo.toml', 'integration-test/**/Cargo.lock', 'integration-test/bins/rust-toolchain.toml') }}
# Have all the "copying into Nix store" messages in a dedicated step for
# better log visibility.
- run: cd integration-test && nix-shell --run "echo OK" && cd ..
# Now, run the actual test.
- run: cd integration-test && nix-shell --run ./run.sh && cd ..
1 change: 1 addition & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ extend-exclude = [

[default.extend-words]
Rela = "Rela"
grup = "grup"

[default.extend-identifiers]
# FOOBAR = "FOOBAR"
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ members = [
"multiboot2",
"multiboot2-header",
]
exclude = [
"integration-test"
]

[workspace.dependencies]
bitflags = "2"
Expand Down
1 change: 1 addition & 0 deletions integration-test/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use nix
23 changes: 23 additions & 0 deletions integration-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Integrationtests

This directory contains integration tests for the `multiboot2` and the
`multiboot2-header` crate. The integration tests start a QEMU VM and do certain
checks at runtime. If something fails, they instruct QEMU to exit with an error
code. All output of the VM is printed to the screen. If

The `bins` directory contains binaries that **are** the tests. The `tests`
directory contains test definitions, run scripts, and other relevant files. The
main entry to run all tests is `./run.sh` in this directory.

## TL;DR:
- `$ nix-shell --run ./run.sh` to execute the integration tests with Nix (recommended)
- `$ ./run.sh` to execute the integration tests (you have to install dependencies manually)

## Prerequisites
The tests are executed best when using [`nix`](https://nixos.org/)/`nix-shell`
to get the relevant tools. Otherwise, please make sure the following packages
are available:
- grub helper tools
- rustup
- QEMU
- xorriso
11 changes: 11 additions & 0 deletions integration-test/bins/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[unstable]
build-std = ["core", "compiler_builtins", "alloc"]
build-std-features = ["compiler-builtins-mem"]

[build]
target = "x86-unknown-none.json"
rustflags = [
"-C", "code-model=kernel",
# "-C", "link-arg=-Tlink.ld",
"-C", "relocation-model=static",
]
285 changes: 285 additions & 0 deletions integration-test/bins/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading