-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds kernel tests running on x86_64 for 5.15, 6.0, 6.2, and 6.6 using vmtest[0]. The main goal is to ensure that the BPF programs load fine for various kernels. The original plan was to have a nix derivation that would do everything: 1) download the kernels 2) build vmtest 3) build lightswitch 4) generate the vmtest configuration, and finally 5) run vmtest with said configuration. I attempted to do this in this branch [1] but I was taking too long and decided for this approach that gets us 80% of the value for 20% of the work. The downsides for this approach are: 1) As the vmtest config file is not generated on the fly, the kernel paths have to be hardcoded. This is not as bad as it might seem because nix guarantees these paths to be the same accross machines, but it's still a bit kludgy; 2) There is an expectation that lightswitch in dev mode has been built before runnign the vmtests; How to run the kernel tests =========================== ``` nix develop cargo build vmtest ``` Notes ===== We still require qemu-guest-agen to be running in the base OS (nix or not) which is not ideal, but a proper fix might be quite involved. Test Plan ========= Forced a panic to make sure the kernel tests would fail. - [0]: https://github.com/danobi/vmtest - [1]: https://github.com/javierhonduco/lightswitch/commits/wip-vmtests
- Loading branch information
1 parent
c5b8525
commit ae589c3
Showing
6 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: vmtests | ||
on: | ||
pull_request: | ||
push: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
vmtests: | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
steps: | ||
- uses: actions/checkout@main | ||
- uses: DeterminateSystems/nix-installer-action@main | ||
- uses: DeterminateSystems/magic-nix-cache-action@main | ||
|
||
- name: Install system dependencies | ||
run: | | ||
export DEBIAN_FRONTEND=noninteractive | ||
sudo apt update && sudo apt -y install --no-install-recommends qemu-system-x86 qemu-guest-agent | ||
- name: Set up nix dev env | ||
run: nix develop --command echo 0 | ||
|
||
- name: Build `lightswitch` | ||
run: nix develop --ignore-environment --command bash -c 'cargo build' | ||
|
||
- name: Run kernel tests | ||
run: nix develop --command 'vmtest' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/target | ||
flame.svg | ||
src/bpf/*_skel.rs | ||
.vmtest.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
{ pkgs }: | ||
{ | ||
kernel_5_15 = pkgs.stdenv.mkDerivation { | ||
name = "download-kernel-5.15"; | ||
src = pkgs.fetchurl { | ||
url = "https://github.com/danobi/vmtest/releases/download/test_assets/bzImage-v5.15-fedora38"; | ||
hash = "sha256-nq8W72vuNKCgO1OS6aJtAfg7AjHavRZ7WAkP7X6V610="; | ||
}; | ||
dontUnpack = true; | ||
installPhase = '' | ||
mkdir -p $out | ||
cp -r $src $out/bzImage | ||
''; | ||
}; | ||
|
||
kernel_6_0 = pkgs.stdenv.mkDerivation { | ||
name = "download-kernel-6.0"; | ||
src = pkgs.fetchurl { | ||
url = "https://github.com/danobi/vmtest/releases/download/test_assets/bzImage-v6.0-fedora38"; | ||
hash = "sha256-ZBBQ0yVUn+Isd2b+a32oMEbNo8T1v46P3rEtZ+1j9Ic="; | ||
}; | ||
dontUnpack = true; | ||
installPhase = '' | ||
mkdir -p $out | ||
cp -r $src $out/bzImage | ||
''; | ||
}; | ||
|
||
kernel_6_2 = pkgs.stdenv.mkDerivation { | ||
name = "download-kernel-6.2"; | ||
src = pkgs.fetchurl { | ||
url = "https://github.com/danobi/vmtest/releases/download/test_assets/bzImage-v6.2-fedora38"; | ||
hash = "sha256-YO2HEIWTuEEJts9JrW3V7UVR7t4J3+8On+tjdELa2m8="; | ||
}; | ||
dontUnpack = true; | ||
installPhase = '' | ||
mkdir -p $out | ||
cp -r $src $out/bzImage | ||
''; | ||
}; | ||
|
||
kernel_6_6 = pkgs.stdenv.mkDerivation { | ||
name = "download-kernel-6.6"; | ||
src = pkgs.fetchurl { | ||
url = "https://github.com/danobi/vmtest/releases/download/test_assets/bzImage-v6.6-fedora38"; | ||
hash = "sha256-6Fu16SPBITP0sI3lapkckZna6GKBn2hID038itt82jA="; | ||
}; | ||
dontUnpack = true; | ||
installPhase = '' | ||
mkdir -p $out | ||
cp -r $src $out/bzImage | ||
''; | ||
}; | ||
|
||
vmtest = pkgs.rustPlatform.buildRustPackage { | ||
name = "vmtest"; | ||
src = pkgs.fetchFromGitHub { | ||
owner = "danobi"; | ||
repo = "vmtest"; | ||
rev = "51f11bf301fea054342996802a16ed21fb5054f4"; | ||
sha256 = "sha256-qtTq0dnDHi1ITfQzKrXz+1dRMymAFBivWpjXntD09+A="; | ||
}; | ||
cargoHash = "sha256-SHjjCWz4FVVk1cczkMltRVEB3GK8jz2tVABNSlSZiUc="; | ||
# nativeCheckInputs = [ pkgs.qemu ]; | ||
|
||
# There are some errors trying to access `/build/source/tests/*`. | ||
doCheck = false; | ||
|
||
meta = with pkgs.lib; { | ||
description = "Helps run tests in virtual machines"; | ||
homepage = "https://github.com/danobi/vmtest/"; | ||
license = licenses.asl20; | ||
mainProgram = ""; | ||
maintainers = with maintainers; [ ]; | ||
platforms = platforms.linux; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[[target]] | ||
name = "Fedora 5.15" | ||
kernel = "/nix/store/cg9wq48zz2dbvayh7sigr5smaf4dwcxp-download-kernel-5.15/bzImage" | ||
command = "/mnt/vmtest/target/debug/lightswitch --duration 0" | ||
|
||
[[target]] | ||
name = "Fedora 6.0" | ||
kernel = "/nix/store/p8xc9gqdkpfjpmcb9ja2gx6g6bd9cby7-download-kernel-6.0/bzImage" | ||
command = "/mnt/vmtest/target/debug/lightswitch --duration 0" | ||
|
||
[[target]] | ||
name = "Fedora 6.2" | ||
kernel = "/nix/store/79wzcqy12fncdf6pk1fj627ggh7v0nc7-download-kernel-6.2/bzImage" | ||
command = "/mnt/vmtest/target/debug/lightswitch --duration 0" | ||
|
||
[[target]] | ||
name = "Fedora 6.6" | ||
kernel = "/nix/store/77ixckavs2qidx1pglmlxsj6bfvjqijb-download-kernel-6.6/bzImage" | ||
command = "/mnt/vmtest/target/debug/lightswitch --duration 0" |