From 1b615f460bc40cf2697d7e972bad3091cf87ceaf Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sat, 4 Aug 2012 09:45:26 -0400 Subject: [PATCH] Allow overriding all NixOS tests to run with the minimal kernel possible for that test's config(s) (based on requiredKernelConfig) --- lib/build-vms.nix | 4 ++-- lib/testing.nix | 4 ++-- modules/testing/minimal-kernel.nix | 28 ++++++++++++++++++++++ release.nix | 6 ++--- tests/default.nix | 5 ++-- tests/minimal-kernel.nix | 37 ------------------------------ 6 files changed, 37 insertions(+), 47 deletions(-) create mode 100644 modules/testing/minimal-kernel.nix delete mode 100644 tests/minimal-kernel.nix diff --git a/lib/build-vms.nix b/lib/build-vms.nix index e8e5885137d6..aacd0e99cb18 100644 --- a/lib/build-vms.nix +++ b/lib/build-vms.nix @@ -1,4 +1,4 @@ -{ system }: +{ system, minimal ? false }: let pkgs = import { config = {}; inherit system; }; in @@ -27,7 +27,7 @@ rec { [ ../modules/virtualisation/qemu-vm.nix ../modules/testing/test-instrumentation.nix # !!! should only get added for automated test runs { key = "no-manual"; services.nixosManual.enable = false; } - ]; + ] ++ lib.optional minimal ../modules/testing/minimal-kernel.nix; extraArgs = { inherit nodes; }; }; diff --git a/lib/testing.nix b/lib/testing.nix index 6a39df8c865d..a27f4344c6ae 100644 --- a/lib/testing.nix +++ b/lib/testing.nix @@ -1,6 +1,6 @@ -{ system }: +{ system, minimal ? false }: -with import ./build-vms.nix { inherit system; }; +with import ./build-vms.nix { inherit system minimal; }; with pkgs; rec { diff --git a/modules/testing/minimal-kernel.nix b/modules/testing/minimal-kernel.nix new file mode 100644 index 000000000000..0ad20bbf75a2 --- /dev/null +++ b/modules/testing/minimal-kernel.nix @@ -0,0 +1,28 @@ +{ config, pkgs, ... }: + +let + configfile = builtins.storePath (builtins.toFile "config" (pkgs.lib.concatStringsSep "\n" + (map (builtins.getAttr "configLine") config.system.requiredKernelConfig)) + ); + + origKernel = pkgs.linuxManualConfig { + inherit (pkgs.linux) src version; + inherit configfile; + allowImportFromDerivation = true; + kernelPatches = [ pkgs.kernelPatches.cifs_timeout_2_6_38 ]; + }; + + kernel = origKernel // (derivation (origKernel.drvAttrs // { + configurePhase = '' + runHook preConfigure + mkdir ../build + make $makeFlags "''${makeFlagsArray[@]}" mrproper + make $makeFlags "''${makeFlagsArray[@]}" KCONFIG_ALLCONFIG=${configfile} allnoconfig + runHook postConfigure + ''; + })); + + kernelPackages = pkgs.linuxPackagesFor kernel kernelPackages; +in { + boot.kernelPackages = kernelPackages; +} diff --git a/release.nix b/release.nix index 9f76ee4a254c..10cea94881f2 100644 --- a/release.nix +++ b/release.nix @@ -1,5 +1,6 @@ { nixosSrc ? {outPath = ./.; revCount = 1234; shortRev = "abcdef"; } , nixpkgs ? {outPath = ; revCount = 5678; shortRev = "fedcba"; } +, minimal ? false }: let @@ -194,8 +195,8 @@ let tests = let - t = import ./tests { system = "i686-linux"; }; - t_64 = import ./tests { system = "x86_64-linux"; }; + t = import ./tests { system = "i686-linux"; inherit minimal; }; + t_64 = import ./tests { system = "x86_64-linux"; inherit minimal; }; in { avahi = t.avahi.test; bittorrent = t.bittorrent.test; @@ -212,7 +213,6 @@ let kde4 = t.kde4.test; login = t.login.test; misc = t.misc.test; - minimal_kernel = t.minimal_kernel.test; mpich = t.mpich.test; mysql = t.mysql.test; mysql_replication = t.mysql_replication.test; diff --git a/tests/default.nix b/tests/default.nix index 2433826a9d17..0d2c3102a646 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -1,6 +1,6 @@ -{ system ? builtins.currentSystem }: +{ system ? builtins.currentSystem, minimal ? false }: -with import ../lib/testing.nix { inherit system; }; +with import ../lib/testing.nix { inherit system minimal; }; { avahi = makeTest (import ./avahi.nix); @@ -11,7 +11,6 @@ with import ../lib/testing.nix { inherit system; }; ipv6 = makeTest (import ./ipv6.nix); kde4 = makeTest (import ./kde4.nix); login = makeTest (import ./login.nix); - minimal_kernel = makeTest (import ./minimal-kernel.nix); misc = makeTest (import ./misc.nix); mpich = makeTest (import ./mpich.nix); mysql = makeTest (import ./mysql.nix); diff --git a/tests/minimal-kernel.nix b/tests/minimal-kernel.nix deleted file mode 100644 index e27b39d17643..000000000000 --- a/tests/minimal-kernel.nix +++ /dev/null @@ -1,37 +0,0 @@ -{ pkgs, ... }: - - -{ - machine = { config, pkgs, ... }: - let - configfile = builtins.storePath (builtins.toFile "config" (pkgs.lib.concatStringsSep "\n" - (map (builtins.getAttr "configLine") config.system.requiredKernelConfig))); - - origKernel = pkgs.linuxManualConfig { - inherit (pkgs.linux) src version; - inherit configfile; - allowImportFromDerivation = true; - kernelPatches = [ pkgs.kernelPatches.cifs_timeout_2_6_38 ]; - }; - - kernel = origKernel //(derivation (origKernel.drvAttrs // { - configurePhase = '' - runHook preConfigure - mkdir ../build - make $makeFlags "''${makeFlagsArray[@]}" mrproper - make $makeFlags "''${makeFlagsArray[@]}" KCONFIG_ALLCONFIG=${configfile} allnoconfig - runHook postConfigure - ''; - })); - - kernelPackages = pkgs.linuxPackagesFor kernel kernelPackages; - in { - boot.kernelPackages = kernelPackages; - }; - - testScript = - '' - startAll; - $machine->shutdown; - ''; -}