Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
javierhonduco committed May 28, 2024
1 parent d74b430 commit 32ad7af
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 56 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/vmtests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,5 @@ jobs:
export DEBIAN_FRONTEND=noninteractive
sudo apt-get -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'
run: nix run .#vmtest
18 changes: 9 additions & 9 deletions flake.lock

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

10 changes: 2 additions & 8 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
nativeBuildInputs = with pkgs; [
pkg-config
];
craneLib = crane.lib.${system};
craneLib = (crane.mkLib nixpkgs.legacyPackages.${system});
lightswitch = craneLib.buildPackage {
src = ./.;
doCheck = false;
Expand All @@ -65,6 +65,7 @@
];
};
};
vmtest = (import ./vm.nix { inherit pkgs; }).run-vmtest lightswitch;
};
devShells.default = mkShell {
nativeBuildInputs = nativeBuildInputs;
Expand All @@ -79,13 +80,6 @@
# snapshot testing plugin binary
cargo-insta
# ocamlPackages.magic-trace
(import ./vm.nix { inherit pkgs; }).vmtest
(import ./vm.nix { inherit pkgs; }).kernel_5_15
(import ./vm.nix { inherit pkgs; }).kernel_6_0
(import ./vm.nix { inherit pkgs; }).kernel_6_2
(import ./vm.nix { inherit pkgs; }).kernel_6_6
(import ./vm.nix { inherit pkgs; }).kernel_6_8_7
(import ./vm.nix { inherit pkgs; }).kernel_6_9_rc5
];

LIBCLANG_PATH = lib.makeLibraryPath [ llvmPackages_16.libclang ];
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,15 @@ fn main() -> Result<(), Box<dyn Error>> {
let mut options: flamegraph::Options<'_> = flamegraph::Options::default();
let data = folded.as_bytes();
let flame_path = args.flamegraph_file;
let f = File::create(flame_path).unwrap();
/* let f = File::create(flame_path).unwrap();
match flamegraph::from_reader(&mut options, data, f) {
Ok(_) => {
eprintln!("Profile successfully written to disk");
}
Err(e) => {
error!("Failed generate profile: {:?}", e);
}
}
} */

Ok(())
}
Expand Down
65 changes: 64 additions & 1 deletion vm.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{ pkgs }:
{
let

kernel_5_15 = pkgs.stdenv.mkDerivation {
name = "download-kernel-5.15";
src = pkgs.fetchurl {
Expand Down Expand Up @@ -78,6 +79,48 @@
'';
};

vmtest-create-config = lightswitch: pkgs.stdenv.mkDerivation {
name = "vmtest-dump-config";
dontUnpack = true;

src = pkgs.writeText "vmtest.toml" ''
[[target]]
name = "Fedora 5.15"
kernel = "${kernel_5_15}/bzImage"
command = "${lightswitch}/bin/lightswitch --duration 0"
[[target]]
name = "Fedora 6.0"
kernel = "${kernel_6_0}/bzImage"
command = "${lightswitch}/bin/lightswitch --duration 0"
[[target]]
name = "Fedora 6.2"
kernel = "${kernel_6_2}/bzImage"
command = "${lightswitch}/bin/lightswitch --duration 0"
[[target]]
name = "Fedora 6.6"
kernel = "${kernel_6_6}/bzImage"
command = "${lightswitch}/bin/lightswitch --duration 0"
[[target]]
name = "Upstream 6.8.7"
kernel = "${kernel_6_8_7}/bzImage"
command = "${lightswitch}/bin/lightswitch --duration 0"
[[target]]
name = "Upstream v6.9-rc5"
kernel = "${kernel_6_9_rc5}/bzImage"
command = "${lightswitch}/bin/lightswitch --duration 0"
'';
nativeBuildInputs = [ ];
installPhase = ''
mkdir -p $out
cp -r $src $out/vmtest.toml
'';
};

vmtest = pkgs.rustPlatform.buildRustPackage {
name = "vmtest";
src = pkgs.fetchFromGitHub {
Expand All @@ -101,4 +144,24 @@
platforms = platforms.linux;
};
};
in
{


run-vmtest = lightswitch:
pkgs.stdenv.mkDerivation {
name = "run-vmtests";
dontUnpack = true;

src = pkgs.writeText "run-vmtests" ''
${vmtest}/bin/vmtest --config ${vmtest-create-config lightswitch}/vmtest.toml
'';
nativeBuildInputs = [ ];
installPhase = ''
mkdir -p $out/bin
cp -r $src $out/bin/run-vmtests
chmod +x $out/bin/run-vmtests
'';
};

}
29 changes: 0 additions & 29 deletions vmtest.toml

This file was deleted.

0 comments on commit 32ad7af

Please sign in to comment.