mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2025-02-16 23:27:17 +02:00
Split tests some more
Good for parallelism and easier reading.
This commit is contained in:
parent
97deb00cbc
commit
5d18120ba8
8 changed files with 81 additions and 39 deletions
|
@ -138,7 +138,9 @@ nix_tests = \
|
||||||
toString-path.sh
|
toString-path.sh
|
||||||
|
|
||||||
overlay-local-store-tests := \
|
overlay-local-store-tests := \
|
||||||
$(d)/overlay-local-store/outer.sh \
|
$(d)/overlay-local-store/check-post-init.sh \
|
||||||
|
$(d)/overlay-local-store/redundant-add.sh \
|
||||||
|
$(d)/overlay-local-store/build.sh \
|
||||||
$(d)/overlay-local-store/bad-uris.sh
|
$(d)/overlay-local-store/bad-uris.sh
|
||||||
|
|
||||||
install-tests-groups += overlay-local-store
|
install-tests-groups += overlay-local-store
|
||||||
|
|
26
tests/overlay-local-store/build-inner.sh
Executable file
26
tests/overlay-local-store/build-inner.sh
Executable file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eu -o pipefail
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
source common.sh
|
||||||
|
|
||||||
|
storeDirs
|
||||||
|
|
||||||
|
initLowerStore
|
||||||
|
|
||||||
|
mountOverlayfs
|
||||||
|
|
||||||
|
### Do a build in overlay store
|
||||||
|
|
||||||
|
path=$(nix-build ../hermetic.nix --arg busybox $busybox --arg seed 2 --store "$storeB" --no-out-link)
|
||||||
|
|
||||||
|
# Checking for path in lower layer (should fail)
|
||||||
|
expect 1 stat $(toRealPath "$storeA/nix/store" "$path")
|
||||||
|
|
||||||
|
# Checking for path in upper layer
|
||||||
|
stat $(toRealPath "$storeBTop" "$path")
|
||||||
|
|
||||||
|
# Verifying path in overlay store
|
||||||
|
nix-store --verify-path --store "$storeB" "$path"
|
|
@ -2,4 +2,4 @@ source common.sh
|
||||||
|
|
||||||
requireEnvironment
|
requireEnvironment
|
||||||
setupConfig
|
setupConfig
|
||||||
exec unshare --mount --map-root-user ./inner.sh
|
execUnshare ./build-inner.sh
|
|
@ -65,29 +65,3 @@ hashPart=$(echo $path | sed "s^$NIX_STORE_DIR/^^" | sed 's/-.*//')
|
||||||
|
|
||||||
# merged store can find from hash part
|
# merged store can find from hash part
|
||||||
[[ $(nix store --store $storeB path-from-hash-part $hashPart) == $path ]]
|
[[ $(nix store --store $storeB path-from-hash-part $hashPart) == $path ]]
|
||||||
|
|
||||||
### Do a redundant add
|
|
||||||
|
|
||||||
# upper layer should not have it
|
|
||||||
expect 1 stat $(toRealPath "$storeBTop/nix/store" "$path")
|
|
||||||
|
|
||||||
path=$(nix-store --store "$storeB" --add ../dummy)
|
|
||||||
|
|
||||||
# lower store should have it from before
|
|
||||||
stat $(toRealPath "$storeA/nix/store" "$path")
|
|
||||||
|
|
||||||
# upper layer should still not have it (no redundant copy)
|
|
||||||
expect 1 stat $(toRealPath "$storeB/nix/store" "$path")
|
|
||||||
|
|
||||||
### Do a build in overlay store
|
|
||||||
|
|
||||||
path=$(nix-build ../hermetic.nix --arg busybox $busybox --arg seed 2 --store "$storeB" --no-out-link)
|
|
||||||
|
|
||||||
# Checking for path in lower layer (should fail)
|
|
||||||
expect 1 stat $(toRealPath "$storeA/nix/store" "$path")
|
|
||||||
|
|
||||||
# Checking for path in upper layer
|
|
||||||
stat $(toRealPath "$storeBTop" "$path")
|
|
||||||
|
|
||||||
# Verifying path in overlay store
|
|
||||||
nix-store --verify-path --store "$storeB" "$path"
|
|
5
tests/overlay-local-store/check-post-init.sh
Executable file
5
tests/overlay-local-store/check-post-init.sh
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
source common.sh
|
||||||
|
|
||||||
|
requireEnvironment
|
||||||
|
setupConfig
|
||||||
|
execUnshare ./check-post-init-inner.sh
|
|
@ -1,23 +1,23 @@
|
||||||
source ../common.sh
|
source ../common.sh
|
||||||
|
|
||||||
requireEnvironment () {
|
requireEnvironment () {
|
||||||
requireSandboxSupport
|
requireSandboxSupport
|
||||||
[[ $busybox =~ busybox ]] || skipTest "no busybox"
|
[[ $busybox =~ busybox ]] || skipTest "no busybox"
|
||||||
if [[ $(uname) != Linux ]]; then skipTest "Need Linux for overlayfs"; fi
|
if [[ $(uname) != Linux ]]; then skipTest "Need Linux for overlayfs"; fi
|
||||||
needLocalStore "The test uses --store always so we would just be bypassing the daemon"
|
needLocalStore "The test uses --store always so we would just be bypassing the daemon"
|
||||||
}
|
}
|
||||||
|
|
||||||
setupConfig () {
|
setupConfig () {
|
||||||
echo "drop-supplementary-groups = false" >> "$NIX_CONF_DIR"/nix.conf
|
echo "drop-supplementary-groups = false" >> "$NIX_CONF_DIR"/nix.conf
|
||||||
echo "build-users-group = " >> "$NIX_CONF_DIR"/nix.conf
|
echo "build-users-group = " >> "$NIX_CONF_DIR"/nix.conf
|
||||||
}
|
}
|
||||||
|
|
||||||
storeDirs () {
|
storeDirs () {
|
||||||
storeA="$TEST_ROOT/store-a"
|
storeA="$TEST_ROOT/store-a"
|
||||||
storeBTop="$TEST_ROOT/store-b"
|
storeBTop="$TEST_ROOT/store-b"
|
||||||
storeB="local-overlay?root=$TEST_ROOT/merged-store&lower-store=$storeA&upper-layer=$storeBTop"
|
storeB="local-overlay?root=$TEST_ROOT/merged-store&lower-store=$storeA&upper-layer=$storeBTop"
|
||||||
# Creating testing directories
|
# Creating testing directories
|
||||||
mkdir -p "$TEST_ROOT"/{store-a/nix/store,store-b,merged-store/nix/store,workdir}
|
mkdir -p "$TEST_ROOT"/{store-a/nix/store,store-b,merged-store/nix/store,workdir}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Mounting Overlay Store
|
# Mounting Overlay Store
|
||||||
|
@ -50,3 +50,7 @@ initLowerStore () {
|
||||||
drvPath=$(nix-instantiate --store $storeA ../hermetic.nix --arg busybox "$busybox" --arg seed 1)
|
drvPath=$(nix-instantiate --store $storeA ../hermetic.nix --arg busybox "$busybox" --arg seed 1)
|
||||||
path=$(nix-store --store "$storeA" --realise $drvPath)
|
path=$(nix-store --store "$storeA" --realise $drvPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
execUnshare () {
|
||||||
|
exec unshare --mount --map-root-user "$@"
|
||||||
|
}
|
||||||
|
|
26
tests/overlay-local-store/redundant-add-inner.sh
Executable file
26
tests/overlay-local-store/redundant-add-inner.sh
Executable file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eu -o pipefail
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
source common.sh
|
||||||
|
|
||||||
|
storeDirs
|
||||||
|
|
||||||
|
initLowerStore
|
||||||
|
|
||||||
|
mountOverlayfs
|
||||||
|
|
||||||
|
### Do a redundant add
|
||||||
|
|
||||||
|
# upper layer should not have it
|
||||||
|
expect 1 stat $(toRealPath "$storeBTop/nix/store" "$path")
|
||||||
|
|
||||||
|
path=$(nix-store --store "$storeB" --add ../dummy)
|
||||||
|
|
||||||
|
# lower store should have it from before
|
||||||
|
stat $(toRealPath "$storeA/nix/store" "$path")
|
||||||
|
|
||||||
|
# upper layer should still not have it (no redundant copy)
|
||||||
|
expect 1 stat $(toRealPath "$storeB/nix/store" "$path")
|
5
tests/overlay-local-store/redundant-add.sh
Executable file
5
tests/overlay-local-store/redundant-add.sh
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
source common.sh
|
||||||
|
|
||||||
|
requireEnvironment
|
||||||
|
setupConfig
|
||||||
|
execUnshare ./redundant-add-inner.sh
|
Loading…
Add table
Reference in a new issue