Skip to content

Commit 1da47a1

Browse files
authored
Merge pull request #129 from rust-osdev/integration-test
Add Integration Test
2 parents c3a4e03 + c994e7b commit 1da47a1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1621
-1
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ indent_size = 4
1111
trim_trailing_whitespace = true
1212
max_line_length = 80
1313

14-
[*.yml]
14+
[{*.nix, *.yml}]
1515
indent_size = 2

.github/workflows/rust.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,37 @@ jobs:
127127
do-style-check: true
128128
do-test: false
129129
features: builder,unstable
130+
131+
integrationtest:
132+
name: integrationtest
133+
needs:
134+
- build_nightly
135+
- build_nostd_nightly
136+
runs-on: ubuntu-latest
137+
steps:
138+
- name: Check out
139+
uses: actions/checkout@v3
140+
- uses: cachix/install-nix-action@v20
141+
with:
142+
# This channel is only required to invoke "nix-shell".
143+
# Everything inside that nix-shell will use a pinned version of
144+
# nixpkgs.
145+
nix_path: nixpkgs=channel:nixos-23.05
146+
- name: Set up cargo cache
147+
uses: actions/cache@v3
148+
continue-on-error: false
149+
with:
150+
path: |
151+
~/.cargo/bin/
152+
~/.cargo/registry/index/
153+
~/.cargo/registry/cache/
154+
~/.cargo/git/db/
155+
integration-test/bins/target/
156+
# Hash over Cargo.toml and Cargo.lock, as this might be copied to
157+
# projects that do not have a Cargo.lock in their repository tree!
158+
key: ${{ runner.os }}-${{ github.job }}-${{ hashFiles('integration-test/**/Cargo.toml', 'integration-test/**/Cargo.lock', 'integration-test/bins/rust-toolchain.toml') }}
159+
# Have all the "copying into Nix store" messages in a dedicated step for
160+
# better log visibility.
161+
- run: cd integration-test && nix-shell --run "echo OK" && cd ..
162+
# Now, run the actual test.
163+
- run: cd integration-test && nix-shell --run ./run.sh && cd ..

.typos.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ extend-exclude = [
77

88
[default.extend-words]
99
Rela = "Rela"
10+
grup = "grup"
1011

1112
[default.extend-identifiers]
1213
# FOOBAR = "FOOBAR"

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ members = [
44
"multiboot2",
55
"multiboot2-header",
66
]
7+
exclude = [
8+
"integration-test"
9+
]
710

811
[workspace.dependencies]
912
bitflags = "2"

integration-test/.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use nix

integration-test/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Integrationtests
2+
3+
This directory contains integration tests for the `multiboot2` and the
4+
`multiboot2-header` crate. The integration tests start a QEMU VM and do certain
5+
checks at runtime. If something fails, they instruct QEMU to exit with an error
6+
code. All output of the VM is printed to the screen. If
7+
8+
The `bins` directory contains binaries that **are** the tests. The `tests`
9+
directory contains test definitions, run scripts, and other relevant files. The
10+
main entry to run all tests is `./run.sh` in this directory.
11+
12+
## TL;DR:
13+
- `$ nix-shell --run ./run.sh` to execute the integration tests with Nix (recommended)
14+
- `$ ./run.sh` to execute the integration tests (you have to install dependencies manually)
15+
16+
## Prerequisites
17+
The tests are executed best when using [`nix`](https://nixos.org/)/`nix-shell`
18+
to get the relevant tools. Otherwise, please make sure the following packages
19+
are available:
20+
- grub helper tools
21+
- rustup
22+
- QEMU
23+
- xorriso
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[unstable]
2+
build-std = ["core", "compiler_builtins", "alloc"]
3+
build-std-features = ["compiler-builtins-mem"]
4+
5+
[build]
6+
target = "x86-unknown-none.json"
7+
rustflags = [
8+
"-C", "code-model=kernel",
9+
# "-C", "link-arg=-Tlink.ld",
10+
"-C", "relocation-model=static",
11+
]

integration-test/bins/Cargo.lock

Lines changed: 285 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)