From 9e300052bd830d48f6016d5f90441030fd556f1c Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Wed, 1 Aug 2012 22:32:16 -0400 Subject: [PATCH] Add test to check that a machine with a minimal kernel but all of the requiredKernelConfig options set boots and shuts down --- modules/system/boot/kernel.nix | 5 +++++ release.nix | 1 + tests/default.nix | 1 + tests/minimal-kernel.nix | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 tests/minimal-kernel.nix diff --git a/modules/system/boot/kernel.nix b/modules/system/boot/kernel.nix index 5bb47969835..326cf64d6b8 100644 --- a/modules/system/boot/kernel.nix +++ b/modules/system/boot/kernel.nix @@ -195,16 +195,19 @@ let kernel = config.boot.kernelPackages.kernel; in isYes = option: { assertion = config: config.isYes option; message = "CONFIG_${option} is not yes!"; + configLine = "CONFIG_${option}=y"; }; isNo = option: { assertion = config: config.isNo option; message = "CONFIG_${option} is not no!"; + configLine = "CONFIG_${option}=n"; }; isModule = option: { assertion = config: config.isModule option; message = "CONFIG_${option} is not built as a module!"; + configLine = "CONFIG_${option}=m"; }; ### Usually you will just want to use these two @@ -212,12 +215,14 @@ let kernel = config.boot.kernelPackages.kernel; in isEnabled = option: { assertion = config: config.isEnabled option; message = "CONFIG_${option} is not enabled!"; + configLine = "CONFIG_${option}=y"; }; # True if no or omitted isDisabled = option: { assertion = config: config.isDisabled option; message = "CONFIG_${option} is not disabled!"; + configLine = "CONFIG_${option}=n"; }; }; diff --git a/release.nix b/release.nix index 4ccbd2ef754..9f76ee4a254 100644 --- a/release.nix +++ b/release.nix @@ -212,6 +212,7 @@ 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 4edcbd2f325..2433826a9d1 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -11,6 +11,7 @@ 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 new file mode 100644 index 00000000000..04fe17c261b --- /dev/null +++ b/tests/minimal-kernel.nix @@ -0,0 +1,34 @@ +{ pkgs, ... }: + + +{ + machine = { config, pkgs, ... }: + let + configfile = builtins.storePath (builtins.toFile "config" (pkgs.lib.concatStringsSep "\n" + (map (builtins.getAttr "configLine") config.system.requiredKernelConfig))); + + kernel = pkgs.lib.overrideDerivation (pkgs.linuxManualConfig { + inherit (pkgs.linux) src version; + inherit configfile; + allowImportFromDerivation = true; + }) (attrs: { + 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; + ''; +}