mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-23 06:26:15 +02:00
Begin to split up overlay-local-store tests
The bad-uris tests are now in their own file. "Outer" is a bad name, but it will be split up next.
This commit is contained in:
parent
b7e5aaf90d
commit
0979a374c5
7 changed files with 90 additions and 64 deletions
|
@ -4,7 +4,7 @@ if [[ -z "${COMMON_SH_SOURCED-}" ]]; then
|
||||||
|
|
||||||
COMMON_SH_SOURCED=1
|
COMMON_SH_SOURCED=1
|
||||||
|
|
||||||
source "$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")/common/vars-and-functions.sh"
|
source "$(readlink -f "$(dirname "${BASH_SOURCE[0]-$0}")")/common/vars-and-functions.sh"
|
||||||
if [[ -n "${NIX_DAEMON_PACKAGE:-}" ]]; then
|
if [[ -n "${NIX_DAEMON_PACKAGE:-}" ]]; then
|
||||||
startDaemon
|
startDaemon
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -133,7 +133,8 @@ nix_tests = \
|
||||||
impure-derivations.sh \
|
impure-derivations.sh \
|
||||||
path-from-hash-part.sh \
|
path-from-hash-part.sh \
|
||||||
toString-path.sh \
|
toString-path.sh \
|
||||||
overlay-local-store.sh
|
overlay-local-store/outer.sh \
|
||||||
|
overlay-local-store/bad-uris.sh
|
||||||
|
|
||||||
ifeq ($(HAVE_LIBCPUID), 1)
|
ifeq ($(HAVE_LIBCPUID), 1)
|
||||||
nix_tests += compute-levels.sh
|
nix_tests += compute-levels.sh
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
source common.sh
|
|
||||||
|
|
||||||
requireSandboxSupport
|
|
||||||
[[ $busybox =~ busybox ]] || skipTest "no busybox"
|
|
||||||
if [[ $(uname) != Linux ]]; then skipTest "Need Linux for overlayfs"; fi
|
|
||||||
needLocalStore "The test uses --store always so we would just be bypassing the daemon"
|
|
||||||
|
|
||||||
echo "drop-supplementary-groups = false" >> "$NIX_CONF_DIR"/nix.conf
|
|
||||||
|
|
||||||
exec unshare --mount --map-root-user overlay-local-store/inner.sh
|
|
25
tests/overlay-local-store/bad-uris.sh
Normal file
25
tests/overlay-local-store/bad-uris.sh
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
source common.sh
|
||||||
|
|
||||||
|
requireEnvironment
|
||||||
|
setupConfig
|
||||||
|
storeDirs
|
||||||
|
|
||||||
|
mkdir -p $TEST_ROOT/bad_test
|
||||||
|
badTestRoot=$TEST_ROOT/bad_test
|
||||||
|
storeBadRoot="local-overlay?root=$badTestRoot&lower-store=$storeA&upper-layer=$storeBTop"
|
||||||
|
storeBadLower="local-overlay?root=$TEST_ROOT/merged-store&lower-store=$badTestRoot&upper-layer=$storeBTop"
|
||||||
|
storeBadUpper="local-overlay?root=$TEST_ROOT/merged-store&lower-store=$storeA&upper-layer=$badTestRoot"
|
||||||
|
|
||||||
|
declare -a storesBad=(
|
||||||
|
"$storeBadRoot" "$storeBadLower" "$storeBadUpper"
|
||||||
|
)
|
||||||
|
|
||||||
|
for i in "${storesBad[@]}"; do
|
||||||
|
echo $i
|
||||||
|
unshare --mount --map-root-user bash <<EOF
|
||||||
|
source common.sh
|
||||||
|
storeDirs
|
||||||
|
mountOverlayfs
|
||||||
|
expectStderr 1 nix doctor --store "$i" | grepQuiet "overlay filesystem .* mounted incorrectly"
|
||||||
|
EOF
|
||||||
|
done
|
52
tests/overlay-local-store/common.sh
Normal file
52
tests/overlay-local-store/common.sh
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
source ../common.sh
|
||||||
|
|
||||||
|
requireEnvironment () {
|
||||||
|
requireSandboxSupport
|
||||||
|
[[ $busybox =~ busybox ]] || skipTest "no busybox"
|
||||||
|
if [[ $(uname) != Linux ]]; then skipTest "Need Linux for overlayfs"; fi
|
||||||
|
needLocalStore "The test uses --store always so we would just be bypassing the daemon"
|
||||||
|
}
|
||||||
|
|
||||||
|
setupConfig () {
|
||||||
|
echo "drop-supplementary-groups = false" >> "$NIX_CONF_DIR"/nix.conf
|
||||||
|
echo "build-users-group = " >> "$NIX_CONF_DIR"/nix.conf
|
||||||
|
}
|
||||||
|
|
||||||
|
storeDirs () {
|
||||||
|
storeA="$TEST_ROOT/store-a"
|
||||||
|
storeBTop="$TEST_ROOT/store-b"
|
||||||
|
storeB="local-overlay?root=$TEST_ROOT/merged-store&lower-store=$storeA&upper-layer=$storeBTop"
|
||||||
|
# Creating testing directories
|
||||||
|
mkdir -p "$TEST_ROOT"/{store-a/nix/store,store-b,merged-store/nix/store,workdir}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Mounting Overlay Store
|
||||||
|
mountOverlayfs () {
|
||||||
|
mount -t overlay overlay \
|
||||||
|
-o lowerdir="$storeA/nix/store" \
|
||||||
|
-o upperdir="$storeBTop" \
|
||||||
|
-o workdir="$TEST_ROOT/workdir" \
|
||||||
|
"$TEST_ROOT/merged-store/nix/store" \
|
||||||
|
|| skipTest "overlayfs is not supported"
|
||||||
|
|
||||||
|
cleanupOverlay () {
|
||||||
|
umount "$TEST_ROOT/merged-store/nix/store"
|
||||||
|
rm -r $TEST_ROOT/workdir
|
||||||
|
}
|
||||||
|
trap cleanupOverlay EXIT
|
||||||
|
}
|
||||||
|
|
||||||
|
toRealPath () {
|
||||||
|
storeDir=$1; shift
|
||||||
|
storePath=$1; shift
|
||||||
|
echo $storeDir$(echo $storePath | sed "s^$NIX_STORE_DIR^^")
|
||||||
|
}
|
||||||
|
|
||||||
|
initLowerStore () {
|
||||||
|
# Init lower store with some stuff
|
||||||
|
nix-store --store "$storeA" --add ../dummy
|
||||||
|
|
||||||
|
# Build something in lower store
|
||||||
|
drvPath=$(nix-instantiate --store $storeA ../hermetic.nix --arg busybox "$busybox" --arg seed 1)
|
||||||
|
path=$(nix-store --store "$storeA" --realise $drvPath)
|
||||||
|
}
|
|
@ -6,53 +6,11 @@ set -x
|
||||||
|
|
||||||
source common.sh
|
source common.sh
|
||||||
|
|
||||||
export NIX_CONFIG='build-users-group = '
|
storeDirs
|
||||||
|
|
||||||
# Creating testing directories
|
initLowerStore
|
||||||
|
|
||||||
storeA="$TEST_ROOT/store-a"
|
mountOverlayfs
|
||||||
storeBTop="$TEST_ROOT/store-b"
|
|
||||||
storeB="local-overlay?root=$TEST_ROOT/merged-store&lower-store=$storeA&upper-layer=$storeBTop"
|
|
||||||
|
|
||||||
mkdir -p $TEST_ROOT/bad_test
|
|
||||||
badTestRoot=$TEST_ROOT/bad_test
|
|
||||||
storeBadRoot="local-overlay?root=$badTestRoot&lower-store=$storeA&upper-layer=$storeBTop"
|
|
||||||
storeBadLower="local-overlay?root=$TEST_ROOT/merged-store&lower-store=$badTestRoot&upper-layer=$storeBTop"
|
|
||||||
storeBadUpper="local-overlay?root=$TEST_ROOT/merged-store&lower-store=$storeA&upper-layer=$badTestRoot"
|
|
||||||
|
|
||||||
declare -a storesBad=(
|
|
||||||
"$storeBadRoot" "$storeBadLower" "$storeBadUpper"
|
|
||||||
)
|
|
||||||
|
|
||||||
mkdir -p "$TEST_ROOT"/{store-a,store-b,merged-store/nix/store,workdir}
|
|
||||||
|
|
||||||
# Mounting Overlay Store
|
|
||||||
|
|
||||||
# Init lower store with some stuff
|
|
||||||
nix-store --store "$storeA" --add dummy
|
|
||||||
|
|
||||||
# Build something in lower store
|
|
||||||
drvPath=$(nix-instantiate --store $storeA ./hermetic.nix --arg busybox "$busybox" --arg seed 1)
|
|
||||||
path=$(nix-store --store "$storeA" --realise $drvPath)
|
|
||||||
|
|
||||||
mount -t overlay overlay \
|
|
||||||
-o lowerdir="$storeA/nix/store" \
|
|
||||||
-o upperdir="$storeBTop" \
|
|
||||||
-o workdir="$TEST_ROOT/workdir" \
|
|
||||||
"$TEST_ROOT/merged-store/nix/store" \
|
|
||||||
|| skipTest "overlayfs is not supported"
|
|
||||||
|
|
||||||
cleanupOverlay () {
|
|
||||||
umount "$TEST_ROOT/merged-store/nix/store"
|
|
||||||
rm -r $TEST_ROOT/workdir
|
|
||||||
}
|
|
||||||
trap cleanupOverlay EXIT
|
|
||||||
|
|
||||||
toRealPath () {
|
|
||||||
storeDir=$1; shift
|
|
||||||
storePath=$1; shift
|
|
||||||
echo $storeDir$(echo $storePath | sed "s^$NIX_STORE_DIR^^")
|
|
||||||
}
|
|
||||||
|
|
||||||
### Check status
|
### Check status
|
||||||
|
|
||||||
|
@ -113,12 +71,7 @@ hashPart=$(echo $path | sed "s^$NIX_STORE_DIR/^^" | sed 's/-.*//')
|
||||||
# upper layer should not have it
|
# upper layer should not have it
|
||||||
expect 1 stat $(toRealPath "$storeBTop/nix/store" "$path")
|
expect 1 stat $(toRealPath "$storeBTop/nix/store" "$path")
|
||||||
|
|
||||||
path=$(nix-store --store "$storeB" --add dummy)
|
path=$(nix-store --store "$storeB" --add ../dummy)
|
||||||
|
|
||||||
for i in "${storesBad[@]}"; do
|
|
||||||
echo $i
|
|
||||||
expectStderr 1 nix-store --store "$i" --add dummy | grepQuiet "overlay filesystem .* mounted incorrectly"
|
|
||||||
done
|
|
||||||
|
|
||||||
# lower store should have it from before
|
# lower store should have it from before
|
||||||
stat $(toRealPath "$storeA/nix/store" "$path")
|
stat $(toRealPath "$storeA/nix/store" "$path")
|
||||||
|
@ -128,7 +81,7 @@ expect 1 stat $(toRealPath "$storeB/nix/store" "$path")
|
||||||
|
|
||||||
### Do a build in overlay store
|
### Do a build in overlay store
|
||||||
|
|
||||||
path=$(nix-build ./hermetic.nix --arg busybox $busybox --arg seed 2 --store "$storeB" --no-out-link)
|
path=$(nix-build ../hermetic.nix --arg busybox $busybox --arg seed 2 --store "$storeB" --no-out-link)
|
||||||
|
|
||||||
# Checking for path in lower layer (should fail)
|
# Checking for path in lower layer (should fail)
|
||||||
expect 1 stat $(toRealPath "$storeA/nix/store" "$path")
|
expect 1 stat $(toRealPath "$storeA/nix/store" "$path")
|
||||||
|
|
5
tests/overlay-local-store/outer.sh
Executable file
5
tests/overlay-local-store/outer.sh
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
source common.sh
|
||||||
|
|
||||||
|
requireEnvironment
|
||||||
|
setupConfig
|
||||||
|
exec unshare --mount --map-root-user ./inner.sh
|
Loading…
Reference in a new issue