diff options
Diffstat (limited to 'nixpkgs/pkgs/test')
-rw-r--r-- | nixpkgs/pkgs/test/cc-wrapper/default.nix | 8 | ||||
-rw-r--r-- | nixpkgs/pkgs/test/cc-wrapper/nostdinc-main.c | 8 | ||||
-rw-r--r-- | nixpkgs/pkgs/test/cc-wrapper/stdio.h | 1 | ||||
-rw-r--r-- | nixpkgs/pkgs/test/cross/default.nix | 16 | ||||
-rw-r--r-- | nixpkgs/pkgs/test/kernel.nix | 90 |
5 files changed, 90 insertions, 33 deletions
diff --git a/nixpkgs/pkgs/test/cc-wrapper/default.nix b/nixpkgs/pkgs/test/cc-wrapper/default.nix index 7bd82b4ab2a..c0c89d63fff 100644 --- a/nixpkgs/pkgs/test/cc-wrapper/default.nix +++ b/nixpkgs/pkgs/test/cc-wrapper/default.nix @@ -45,6 +45,14 @@ in stdenv.mkDerivation { NIX_LDFLAGS="-L$NIX_BUILD_TOP/foo/lib -rpath $NIX_BUILD_TOP/foo/lib" $CC -lfoo -o ldflags-check ${./ldflags-main.c} ./ldflags-check + printf "Check whether -nostdinc and -nostdinc++ is handled correctly" >&2 + mkdir -p std-include + cp ${./stdio.h} std-include/stdio.h + NIX_DEBUG=1 $CC -I std-include -nostdinc -o nostdinc-main ${./nostdinc-main.c} + ./nostdinc-main + $CXX -I std-include -nostdinc++ -o nostdinc-main++ ${./nostdinc-main.c} + ./nostdinc-main++ + ${optionalString sanitizersWorking '' printf "checking whether sanitizers are fully functional... ">&2 $CC -o sanitizers -fsanitize=address,undefined ${./sanitizers.c} diff --git a/nixpkgs/pkgs/test/cc-wrapper/nostdinc-main.c b/nixpkgs/pkgs/test/cc-wrapper/nostdinc-main.c new file mode 100644 index 00000000000..f71d155b1b2 --- /dev/null +++ b/nixpkgs/pkgs/test/cc-wrapper/nostdinc-main.c @@ -0,0 +1,8 @@ +// This one should not come from libc because of -nostdinc +#include <stdio.h> + +int main(int argc, char *argv[]) { + // provided by our own stdio.h + foo(); + return 0; +} diff --git a/nixpkgs/pkgs/test/cc-wrapper/stdio.h b/nixpkgs/pkgs/test/cc-wrapper/stdio.h new file mode 100644 index 00000000000..4bddf1d9d48 --- /dev/null +++ b/nixpkgs/pkgs/test/cc-wrapper/stdio.h @@ -0,0 +1 @@ +static void foo(void) {} diff --git a/nixpkgs/pkgs/test/cross/default.nix b/nixpkgs/pkgs/test/cross/default.nix index 6c31a16f2fd..c5a24143773 100644 --- a/nixpkgs/pkgs/test/cross/default.nix +++ b/nixpkgs/pkgs/test/cross/default.nix @@ -13,7 +13,7 @@ let compareTest = { emulator, pkgFun, hostPkgs, crossPkgs, exec, args ? [] }: let pkgName = (pkgFun hostPkgs).name; args' = lib.concatStringsSep " " args; - in pkgs.runCommand "test-${pkgName}-${crossPkgs.hostPlatform.config}" { + in crossPkgs.runCommand "test-${pkgName}-${crossPkgs.hostPlatform.config}" { nativeBuildInputs = [ pkgs.dos2unix ]; } '' # Just in case we are using wine, get rid of that annoying extra @@ -91,6 +91,20 @@ let pkgFun = pkgs: pkgs.hello; }; + pkg-config = {platformFun, crossPkgs, emulator}: crossPkgs.runCommand + "test-pkg-config-${crossPkgs.hostPlatform.config}" + { + depsBuildBuild = [ crossPkgs.pkgsBuildBuild.pkg-config ]; + nativeBuildInputs = [ crossPkgs.pkgsBuildHost.pkg-config crossPkgs.buildPackages.zlib ]; + depsBuildTarget = [ crossPkgs.pkgsBuildTarget.pkg-config ]; + buildInputs = [ crossPkgs.zlib ]; + NIX_DEBUG = 7; + } '' + mkdir $out + ${crossPkgs.pkgsBuildBuild.pkg-config.targetPrefix}pkg-config --cflags zlib > "$out/for-build" + ${crossPkgs.pkgsBuildHost.pkg-config.targetPrefix}pkg-config --cflags zlib > "$out/for-host" + ! diff "$out/for-build" "$out/for-host" + ''; }; in { diff --git a/nixpkgs/pkgs/test/kernel.nix b/nixpkgs/pkgs/test/kernel.nix index 86f1b8d8e9a..a4da1003033 100644 --- a/nixpkgs/pkgs/test/kernel.nix +++ b/nixpkgs/pkgs/test/kernel.nix @@ -1,53 +1,79 @@ +# to run these tests: +# nix-instantiate --eval --strict . -A tests.kernel-config +# +# make sure to use NON EXISTING kernel settings else they may conflict with +# common-config.nix { lib, pkgs }: -with lib.kernel; -with lib.asserts; -with lib.modules; +with lib; +with kernel; -# 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; + # to see the result once the module transformed the lose structured config + getConfig = structuredConfig: + (lts_kernel.override { + structuredExtraConfig = structuredConfig; + }).configfile.structuredConfig; mandatoryVsOptionalConfig = mkMerge [ - { USB_DEBUG = option yes;} - { USB_DEBUG = yes;} + { NIXOS_FAKE_USB_DEBUG = yes;} + { NIXOS_FAKE_USB_DEBUG = option 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: + { NIXOS_FAKE_MMC_BLOCK_MINORS = freeform "32"; } # same as default, won't trigger any error + { NIXOS_FAKE_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; } + # default for "NIXOS_TEST_BOOLEAN" is no + { "NIXOS_TEST_BOOLEAN" = yes; } # yes wins over no by default + { "NIXOS_TEST_BOOLEAN" = no; } + ]; + + optionalNoWins = mkMerge [ + { NIXOS_FAKE_USB_DEBUG = option yes;} + { NIXOS_FAKE_USB_DEBUG = yes;} + ]; + + allOptionalRemainOptional = mkMerge [ + { NIXOS_FAKE_USB_DEBUG = option yes;} + { NIXOS_FAKE_USB_DEBUG = option yes;} ]; + in -{ +runTests { + testEasy = { + expr = (getConfig { NIXOS_FAKE_USB_DEBUG = yes;}).NIXOS_FAKE_USB_DEBUG; + expected = { tristate = "y"; optional = false; freeform = null; }; + }; + # mandatory flag should win over optional - mandatoryCheck = (kernelTestConfig mandatoryVsOptionalConfig); + testMandatoryCheck = { + expr = (getConfig mandatoryVsOptionalConfig).NIXOS_FAKE_USB_DEBUG.optional; + expected = false; + }; + + testYesWinsOverNo = { + expr = (getConfig yesWinsOverNoConfig)."NIXOS_TEST_BOOLEAN".tristate; + expected = "y"; + }; + + testAllOptionalRemainOptional = { + expr = (getConfig allOptionalRemainOptional)."NIXOS_FAKE_USB_DEBUG".optional; + expected = true; + }; # 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"); + # > The option `settings.NIXOS_FAKE_MMC_BLOCK_MINORS.freeform' has conflicting definitions, in `<unknown-file>' and `<unknown-file>' + testTreeform = let + res = builtins.tryEval ( (getConfig freeformConfig).NIXOS_FAKE_MMC_BLOCK_MINORS.freeform); + in { + expr = res.success; + expected = false; + }; + } |