nix: add (failing) selfreference test for multiple realizations

The test illustrates failure in issue #5320. Here derivation and
it's built input have identical CA sotre path. As a result we generate
extraneout reference to build input:

    $ make installcheck
    ...
    ran test tests/selfref-gc.sh... [PASS]
    ran test tests/ca/selfref-gc.sh... [FAIL]
    ...
        deleting '/tmp/.../tests/ca/selfref-gc/store/iqciq1mpg5hc7p6a52fp2bjxbyc9av0v-selfref-gc'
        deleting '/tmp/...tests/ca/selfref-gc/store/zh0kwpnirw3qbv6dl1ckr1y0kd5aw6ax-selfref-gc.drv'
        error: executing SQLite statement
          'delete from ValidPaths where path = '/tmp/.../tests/ca/selfref-gc/store/fsjq0k146r85lsh01l0icl30rnhv7z72-selfref-gc';':
            constraint failed (in '/tmp/.../tests/ca/selfref-gc/var/nix/db/db.sqlite')
This commit is contained in:
Sergei Trofimovich 2021-10-04 09:00:01 +01:00 committed by Théophane Hufschmitt
parent 9345b4e9ca
commit 6ada496311
3 changed files with 40 additions and 0 deletions

11
tests/ca/selfref-gc.sh Executable file
View file

@ -0,0 +1,11 @@
#!/usr/bin/env bash
source common.sh
requireDaemonNewerThan "2.4pre20210626"
sed -i 's/experimental-features .*/& ca-derivations ca-references nix-command flakes/' "$NIX_CONF_DIR"/nix.conf
export NIX_TESTS_CA_BY_DEFAULT=1
cd ..
source ./selfref-gc.sh

View file

@ -92,6 +92,7 @@ nix_tests = \
plugins.sh \ plugins.sh \
build.sh \ build.sh \
ca/nix-run.sh \ ca/nix-run.sh \
selfref-gc.sh ca/selfref-gc.sh \
db-migration.sh \ db-migration.sh \
bash-profile.sh \ bash-profile.sh \
pass-as-file.sh \ pass-as-file.sh \

28
tests/selfref-gc.sh Normal file
View file

@ -0,0 +1,28 @@
source common.sh
clearStore
nix-build --no-out-link -E '
with import ./config.nix;
let d1 = mkDerivation {
name = "selfref-gc";
outputs = [ "out" ];
buildCommand = "
echo SELF_REF: $out > $out
";
}; in
# the only change from d1 is d1 as an (unused) build input
# to get identical store path in CA.
mkDerivation {
name = "selfref-gc";
outputs = [ "out" ];
buildCommand = "
echo UNUSED: ${d1}
echo SELF_REF: $out > $out
";
}
'
nix-collect-garbage