diff --git a/.github/workflows/vmtests.yml b/.github/workflows/vmtests.yml index a3f4d32..0580fdf 100644 --- a/.github/workflows/vmtests.yml +++ b/.github/workflows/vmtests.yml @@ -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' \ No newline at end of file + run: nix run .#vmtest \ No newline at end of file diff --git a/flake.lock b/flake.lock index a7465a3..21eac4f 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1714864355, - "narHash": "sha256-uXNW6bapWFfkYIkK1EagydSrFMqycOYEDSq75GmUpjk=", + "lastModified": 1716745752, + "narHash": "sha256-8K1R9Yg4r08rYk86Yq+lu3E9L3uRUb4xMqYHgl0VGS0=", "owner": "ipetkov", "repo": "crane", - "rev": "442a7a6152f49b907e73206dc8e1f46a61e8e873", + "rev": "19ca94ec2d288de334ae932107816b4a97736cd8", "type": "github" }, "original": { @@ -40,11 +40,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1714906307, - "narHash": "sha256-UlRZtrCnhPFSJlDQE7M0eyhgvuuHBTe1eJ9N9AQlJQ0=", + "lastModified": 1716509168, + "narHash": "sha256-4zSIhSRRIoEBwjbPm3YiGtbd8HDWzFxJjw5DYSDy1n8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "25865a40d14b3f9cf19f19b924e2ab4069b09588", + "rev": "bfb7a882678e518398ce9a31a881538679f6f092", "type": "github" }, "original": { @@ -72,11 +72,11 @@ ] }, "locked": { - "lastModified": 1715048276, - "narHash": "sha256-SqWSTvCjNBBnV/WIQdaxVi5V9H3VJ7cOJAxPQdR1TBY=", + "lastModified": 1716862669, + "narHash": "sha256-7oTPM9lcdwiI1cpRC313B+lHawocgpY5F07N+Rbm5Uk=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "b037d65c988421b54024e62691eace4f2fe623bc", + "rev": "47b2d15658b37716393b2463a019000dbd6ce4bc", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 151c859..87a168b 100644 --- a/flake.nix +++ b/flake.nix @@ -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; @@ -65,6 +65,7 @@ ]; }; }; + vmtest = (import ./vm.nix { inherit pkgs; }).run-vmtest lightswitch; }; devShells.default = mkShell { nativeBuildInputs = nativeBuildInputs; @@ -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 ]; diff --git a/src/main.rs b/src/main.rs index 4aec28c..b57a683 100644 --- a/src/main.rs +++ b/src/main.rs @@ -233,7 +233,7 @@ fn main() -> Result<(), Box> { 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"); @@ -241,7 +241,7 @@ fn main() -> Result<(), Box> { Err(e) => { error!("Failed generate profile: {:?}", e); } - } + } */ Ok(()) } diff --git a/vm.nix b/vm.nix index d847ed7..b536c05 100644 --- a/vm.nix +++ b/vm.nix @@ -1,5 +1,6 @@ { pkgs }: -{ +let + kernel_5_15 = pkgs.stdenv.mkDerivation { name = "download-kernel-5.15"; src = pkgs.fetchurl { @@ -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 { @@ -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 + ''; + }; + } diff --git a/vmtest.toml b/vmtest.toml deleted file mode 100644 index 3e9501b..0000000 --- a/vmtest.toml +++ /dev/null @@ -1,29 +0,0 @@ -[[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" - -[[target]] -name = "Upstream 6.8.7" -kernel = "/nix/store/3ip5l5bmrxpjdf11xbrqpbrh7pqjn9wa-download-kernel-6.8.7/bzImage" -command = "/mnt/vmtest/target/debug/lightswitch --duration 0" - -[[target]] -name = "Upstream v6.9-rc5" -kernel = "/nix/store/zjwmw9s2gr772mjf0y3pfqvknbs0mcdc-download-kernel-6.9-rc5/bzImage" -command = "/mnt/vmtest/target/debug/lightswitch --duration 0" \ No newline at end of file