diff options
author | Matthieu Coudron <mattator@gmail.com> | 2018-10-03 18:54:42 +0900 |
---|---|---|
committer | Matthieu Coudron <mattator@gmail.com> | 2019-01-28 09:07:24 +0900 |
commit | 461cb3f9ed4e536a612cd98c5c12d50d561c29e8 (patch) | |
tree | 4ab274a9c257bbdb8c290229391d5980b0d1a265 | |
parent | 7aacbdb8986f0d75c3770e70a39147c272e1eac8 (diff) |
linux: added tests for the config
-rw-r--r-- | pkgs/test/default.nix | 2 | ||||
-rw-r--r-- | pkgs/test/kernel.nix | 53 |
2 files changed, 55 insertions, 0 deletions
diff --git a/pkgs/test/default.nix b/pkgs/test/default.nix index 809b2d0b553c..9b434da7a84a 100644 --- a/pkgs/test/default.nix +++ b/pkgs/test/default.nix @@ -24,6 +24,8 @@ with pkgs; cc-multilib-gcc = callPackage ./cc-wrapper/multilib.nix { stdenv = gccMultiStdenv; }; cc-multilib-clang = callPackage ./cc-wrapper/multilib.nix { stdenv = clangMultiStdenv; }; + kernel-config = callPackage ./kernel.nix {}; + ld-library-path = callPackage ./ld-library-path {}; macOSSierraShared = callPackage ./macos-sierra-shared {}; diff --git a/pkgs/test/kernel.nix b/pkgs/test/kernel.nix new file mode 100644 index 000000000000..14a4d5ea1041 --- /dev/null +++ b/pkgs/test/kernel.nix @@ -0,0 +1,53 @@ +{ stdenv, lib, pkgs }: + +with lib.kernel; +with lib.asserts; +with lib.modules; + +# To test nixos/modules/system/boot/kernel_config.nix; +let + # copied from release-lib.nix + assertTrue = bool: + if bool + then pkgs.runCommand "evaluated-to-true" {} "touch $out" + else pkgs.runCommand "evaluated-to-false" {} "false"; + + lts_kernel = pkgs.linuxPackages.kernel; + + kernelTestConfig = structuredConfig: (lts_kernel.override { + structuredExtraConfig = structuredConfig; + }).configfile.structuredConfig; + + mandatoryVsOptionalConfig = mkMerge [ + { USB_DEBUG = option yes;} + { USB_DEBUG = yes;} + ]; + + freeformConfig = mkMerge [ + { MMC_BLOCK_MINORS = freeform "32"; } # same as default, won't trigger any error + { MMC_BLOCK_MINORS = freeform "64"; } # will trigger an error but the message is not great: + ]; + + yesWinsOverNoConfig = mkMerge [ + # default for "8139TOO_PIO" is no + { "8139TOO_PIO" = yes; } # yes wins over no by default + { "8139TOO_PIO" = no; } + ]; +in +{ + # mandatory flag should win over optional + mandatoryCheck = (kernelTestConfig mandatoryVsOptionalConfig); + + # check that freeform options are unique + # Should trigger + # > The option `settings.MMC_BLOCK_MINORS.freeform' has conflicting definitions, in `<unknown-file>' and `<unknown-file>' + freeformCheck = let + res = builtins.tryEval ( (kernelTestConfig freeformConfig).MMC_BLOCK_MINORS.freeform); + in + assertTrue (res.success == false); + + yesVsNoCheck = let + res = kernelTestConfig yesWinsOverNoConfig; + in + assertTrue (res."8139TOO_PIO".tristate == "y"); +} |