mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 03:56:01 +01:00
Merge pull request #14108 from fzakaria/fzakaria/shellcheck-multiple-3
shellcheck fixes for tests/functional/local-overlay-store
This commit is contained in:
commit
738d141dd9
20 changed files with 69 additions and 72 deletions
|
|
@ -122,29 +122,6 @@
|
|||
''^tests/functional/install-darwin\.sh$''
|
||||
''^tests/functional/legacy-ssh-store\.sh$''
|
||||
''^tests/functional/linux-sandbox\.sh$''
|
||||
''^tests/functional/local-overlay-store/add-lower-inner\.sh$''
|
||||
''^tests/functional/local-overlay-store/add-lower\.sh$''
|
||||
''^tests/functional/local-overlay-store/bad-uris\.sh$''
|
||||
''^tests/functional/local-overlay-store/build-inner\.sh$''
|
||||
''^tests/functional/local-overlay-store/build\.sh$''
|
||||
''^tests/functional/local-overlay-store/check-post-init-inner\.sh$''
|
||||
''^tests/functional/local-overlay-store/check-post-init\.sh$''
|
||||
''^tests/functional/local-overlay-store/common\.sh$''
|
||||
''^tests/functional/local-overlay-store/delete-duplicate-inner\.sh$''
|
||||
''^tests/functional/local-overlay-store/delete-duplicate\.sh$''
|
||||
''^tests/functional/local-overlay-store/delete-refs-inner\.sh$''
|
||||
''^tests/functional/local-overlay-store/delete-refs\.sh$''
|
||||
''^tests/functional/local-overlay-store/gc-inner\.sh$''
|
||||
''^tests/functional/local-overlay-store/gc\.sh$''
|
||||
''^tests/functional/local-overlay-store/optimise-inner\.sh$''
|
||||
''^tests/functional/local-overlay-store/optimise\.sh$''
|
||||
''^tests/functional/local-overlay-store/redundant-add-inner\.sh$''
|
||||
''^tests/functional/local-overlay-store/redundant-add\.sh$''
|
||||
''^tests/functional/local-overlay-store/remount\.sh$''
|
||||
''^tests/functional/local-overlay-store/stale-file-handle-inner\.sh$''
|
||||
''^tests/functional/local-overlay-store/stale-file-handle\.sh$''
|
||||
''^tests/functional/local-overlay-store/verify-inner\.sh$''
|
||||
''^tests/functional/local-overlay-store/verify\.sh$''
|
||||
''^tests/functional/logging\.sh$''
|
||||
''^tests/functional/misc\.sh$''
|
||||
''^tests/functional/multiple-outputs\.sh$''
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# shellcheck shell=bash
|
||||
source common.sh
|
||||
source ../common/init.sh
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# shellcheck shell=bash
|
||||
source common.sh
|
||||
source ../common/init.sh
|
||||
|
||||
|
|
@ -5,7 +6,7 @@ requireEnvironment
|
|||
setupConfig
|
||||
setupStoreDirs
|
||||
|
||||
mkdir -p $TEST_ROOT/bad_test
|
||||
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=$storeBRoot&lower-store=$badTestRoot&upper-layer=$storeBTop"
|
||||
|
|
@ -18,7 +19,8 @@ declare -a storesBad=(
|
|||
TODO_NixOS
|
||||
|
||||
for i in "${storesBad[@]}"; do
|
||||
echo $i
|
||||
echo "$i"
|
||||
# shellcheck disable=SC2119
|
||||
execUnshare <<EOF
|
||||
source common.sh
|
||||
setupStoreDirs
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@ mountOverlayfs
|
|||
|
||||
### 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)
|
||||
expect 1 stat $(toRealPath "$storeA/nix/store" "$path")
|
||||
expect 1 stat "$(toRealPath "$storeA/nix/store" "$path")"
|
||||
|
||||
# Checking for path in upper layer
|
||||
stat $(toRealPath "$storeBTop" "$path")
|
||||
stat "$(toRealPath "$storeBTop" "$path")"
|
||||
|
||||
# Verifying path in overlay store
|
||||
nix-store --verify-path --store "$storeB" "$path"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# shellcheck shell=bash
|
||||
source common.sh
|
||||
source ../common/init.sh
|
||||
|
||||
|
|
|
|||
|
|
@ -19,41 +19,41 @@ mountOverlayfs
|
|||
### Check status
|
||||
|
||||
# Checking for path in lower layer
|
||||
stat $(toRealPath "$storeA/nix/store" "$pathInLowerStore")
|
||||
stat "$(toRealPath "$storeA/nix/store" "$pathInLowerStore")"
|
||||
|
||||
# Checking for path in upper layer (should fail)
|
||||
expect 1 stat $(toRealPath "$storeBTop" "$pathInLowerStore")
|
||||
expect 1 stat "$(toRealPath "$storeBTop" "$pathInLowerStore")"
|
||||
|
||||
# Checking for path in overlay store matching lower layer
|
||||
diff $(toRealPath "$storeA/nix/store" "$pathInLowerStore") $(toRealPath "$storeBRoot/nix/store" "$pathInLowerStore")
|
||||
diff "$(toRealPath "$storeA/nix/store" "$pathInLowerStore")" "$(toRealPath "$storeBRoot/nix/store" "$pathInLowerStore")"
|
||||
|
||||
# Checking requisites query agreement
|
||||
[[ \
|
||||
$(nix-store --store $storeA --query --requisites $drvPath) \
|
||||
$(nix-store --store "$storeA" --query --requisites "$drvPath") \
|
||||
== \
|
||||
$(nix-store --store $storeB --query --requisites $drvPath) \
|
||||
$(nix-store --store "$storeB" --query --requisites "$drvPath") \
|
||||
]]
|
||||
|
||||
# Checking referrers query agreement
|
||||
busyboxStore=$(nix store --store $storeA add-path $busybox)
|
||||
busyboxStore=$(nix store --store "$storeA" add-path "$busybox")
|
||||
[[ \
|
||||
$(nix-store --store $storeA --query --referrers $busyboxStore) \
|
||||
$(nix-store --store "$storeA" --query --referrers "$busyboxStore") \
|
||||
== \
|
||||
$(nix-store --store $storeB --query --referrers $busyboxStore) \
|
||||
$(nix-store --store "$storeB" --query --referrers "$busyboxStore") \
|
||||
]]
|
||||
|
||||
# Checking derivers query agreement
|
||||
[[ \
|
||||
$(nix-store --store $storeA --query --deriver $pathInLowerStore) \
|
||||
$(nix-store --store "$storeA" --query --deriver "$pathInLowerStore") \
|
||||
== \
|
||||
$(nix-store --store $storeB --query --deriver $pathInLowerStore) \
|
||||
$(nix-store --store "$storeB" --query --deriver "$pathInLowerStore") \
|
||||
]]
|
||||
|
||||
# Checking outputs query agreement
|
||||
[[ \
|
||||
$(nix-store --store $storeA --query --outputs $drvPath) \
|
||||
$(nix-store --store "$storeA" --query --outputs "$drvPath") \
|
||||
== \
|
||||
$(nix-store --store $storeB --query --outputs $drvPath) \
|
||||
$(nix-store --store "$storeB" --query --outputs "$drvPath") \
|
||||
]]
|
||||
|
||||
# Verifying path in lower layer
|
||||
|
|
@ -62,10 +62,10 @@ nix-store --verify-path --store "$storeA" "$pathInLowerStore"
|
|||
# Verifying path in merged-store
|
||||
nix-store --verify-path --store "$storeB" "$pathInLowerStore"
|
||||
|
||||
hashPart=$(echo $pathInLowerStore | sed "s^${NIX_STORE_DIR:-/nix/store}/^^" | sed 's/-.*//')
|
||||
hashPart=$(echo "$pathInLowerStore" | sed "s^${NIX_STORE_DIR:-/nix/store}/^^" | sed 's/-.*//')
|
||||
|
||||
# Lower store can find from hash part
|
||||
[[ $(nix store --store $storeA path-from-hash-part $hashPart) == $pathInLowerStore ]]
|
||||
[[ $(nix store --store "$storeA" path-from-hash-part "$hashPart") == "$pathInLowerStore" ]]
|
||||
|
||||
# merged store can find from hash part
|
||||
[[ $(nix store --store $storeB path-from-hash-part $hashPart) == $pathInLowerStore ]]
|
||||
[[ $(nix store --store "$storeB" path-from-hash-part "$hashPart") == "$pathInLowerStore" ]]
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# shellcheck shell=bash
|
||||
source common.sh
|
||||
source ../common/init.sh
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# shellcheck shell=bash
|
||||
source ../common/vars.sh
|
||||
source ../common/functions.sh
|
||||
|
||||
|
|
@ -54,6 +55,7 @@ setupStoreDirs () {
|
|||
storeA="$storeVolume/store-a"
|
||||
storeBTop="$storeVolume/store-b"
|
||||
storeBRoot="$storeVolume/merged-store"
|
||||
# shellcheck disable=SC2034
|
||||
storeB="local-overlay://?root=$storeBRoot&lower-store=$storeA&upper-layer=$storeBTop"
|
||||
# Creating testing directories
|
||||
mkdir -p "$storeVolume"/{store-a/nix/store,store-b,merged-store/nix/store,workdir}
|
||||
|
|
@ -69,8 +71,10 @@ mountOverlayfs () {
|
|||
|| skipTest "overlayfs is not supported"
|
||||
|
||||
cleanupOverlay () {
|
||||
# shellcheck disable=2317
|
||||
umount -n "$storeBRoot/nix/store"
|
||||
rm -r $storeVolume/workdir
|
||||
# shellcheck disable=2317
|
||||
rm -r "$storeVolume"/workdir
|
||||
}
|
||||
trap cleanupOverlay EXIT
|
||||
}
|
||||
|
|
@ -82,7 +86,8 @@ remountOverlayfs () {
|
|||
toRealPath () {
|
||||
storeDir=$1; shift
|
||||
storePath=$1; shift
|
||||
echo $storeDir$(echo $storePath | sed "s^${NIX_STORE_DIR:-/nix/store}^^")
|
||||
# shellcheck disable=SC2001
|
||||
echo "$storeDir""$(echo "$storePath" | sed "s^${NIX_STORE_DIR:-/nix/store}^^")"
|
||||
}
|
||||
|
||||
initLowerStore () {
|
||||
|
|
@ -90,8 +95,9 @@ initLowerStore () {
|
|||
nix-store --store "$storeA" --add ../dummy
|
||||
|
||||
# Build something in lower store
|
||||
drvPath=$(nix-instantiate --store $storeA ../hermetic.nix --arg withFinalRefs true --arg busybox "$busybox" --arg seed 1)
|
||||
pathInLowerStore=$(nix-store --store "$storeA" --realise $drvPath)
|
||||
drvPath=$(nix-instantiate --store "$storeA" ../hermetic.nix --arg withFinalRefs true --arg busybox "$busybox" --arg seed 1)
|
||||
# shellcheck disable=SC2034
|
||||
pathInLowerStore=$(nix-store --store "$storeA" --realise "$drvPath")
|
||||
}
|
||||
|
||||
addTextToStore() {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# shellcheck shell=bash
|
||||
source common.sh
|
||||
source ../common/init.sh
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ initLowerStore
|
|||
mountOverlayfs
|
||||
|
||||
export NIX_REMOTE="$storeB"
|
||||
# shellcheck disable=SC2034
|
||||
stateB="$storeBRoot/nix/var/nix"
|
||||
hermetic=$(nix-build ../hermetic.nix --no-out-link --arg busybox "$busybox" --arg withFinalRefs true --arg seed 2)
|
||||
input1=$(nix-build ../hermetic.nix --no-out-link --arg busybox "$busybox" --arg withFinalRefs true --arg seed 2 -A passthru.input1 -j0)
|
||||
|
|
@ -22,18 +23,18 @@ input2=$(nix-build ../hermetic.nix --no-out-link --arg busybox "$busybox" --arg
|
|||
input3=$(nix-build ../hermetic.nix --no-out-link --arg busybox "$busybox" --arg withFinalRefs true --arg seed 2 -A passthru.input3 -j0)
|
||||
|
||||
# Can't delete because referenced
|
||||
expectStderr 1 nix-store --delete $input1 | grepQuiet "Cannot delete path"
|
||||
expectStderr 1 nix-store --delete $input2 | grepQuiet "Cannot delete path"
|
||||
expectStderr 1 nix-store --delete $input3 | grepQuiet "Cannot delete path"
|
||||
expectStderr 1 nix-store --delete "$input1" | grepQuiet "Cannot delete path"
|
||||
expectStderr 1 nix-store --delete "$input2" | grepQuiet "Cannot delete path"
|
||||
expectStderr 1 nix-store --delete "$input3" | grepQuiet "Cannot delete path"
|
||||
|
||||
# These same paths are referenced in the lower layer (by the seed 1
|
||||
# build done in `initLowerStore`).
|
||||
expectStderr 1 nix-store --store "$storeA" --delete $input2 | grepQuiet "Cannot delete path"
|
||||
expectStderr 1 nix-store --store "$storeA" --delete $input3 | grepQuiet "Cannot delete path"
|
||||
expectStderr 1 nix-store --store "$storeA" --delete "$input2" | grepQuiet "Cannot delete path"
|
||||
expectStderr 1 nix-store --store "$storeA" --delete "$input3" | grepQuiet "Cannot delete path"
|
||||
|
||||
# Can delete
|
||||
nix-store --delete $hermetic
|
||||
nix-store --delete "$hermetic"
|
||||
|
||||
# Now unreferenced in upper layer, can delete
|
||||
nix-store --delete $input3
|
||||
nix-store --delete $input2
|
||||
nix-store --delete "$input3"
|
||||
nix-store --delete "$input2"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# shellcheck shell=bash
|
||||
source common.sh
|
||||
source ../common/init.sh
|
||||
|
||||
|
|
|
|||
|
|
@ -21,24 +21,24 @@ outPath=$(nix-build ../hermetic.nix --no-out-link --arg busybox "$busybox" --arg
|
|||
# Set a GC root.
|
||||
mkdir -p "$stateB"
|
||||
rm -f "$stateB/gcroots/foo"
|
||||
ln -sf $outPath "$stateB/gcroots/foo"
|
||||
ln -sf "$outPath" "$stateB/gcroots/foo"
|
||||
|
||||
[ "$(nix-store -q --roots $outPath)" = "$stateB/gcroots/foo -> $outPath" ]
|
||||
[ "$(nix-store -q --roots "$outPath")" = "$stateB/gcroots/foo -> $outPath" ]
|
||||
|
||||
nix-store --gc --print-roots | grep $outPath
|
||||
nix-store --gc --print-live | grep $outPath
|
||||
if nix-store --gc --print-dead | grep -E $outPath$; then false; fi
|
||||
nix-store --gc --print-roots | grep "$outPath"
|
||||
nix-store --gc --print-live | grep "$outPath"
|
||||
if nix-store --gc --print-dead | grep -E "$outPath"$; then false; fi
|
||||
|
||||
nix-store --gc --print-dead
|
||||
|
||||
expect 1 nix-store --delete $outPath
|
||||
expect 1 nix-store --delete "$outPath"
|
||||
test -e "$storeBRoot/$outPath"
|
||||
|
||||
shopt -s nullglob
|
||||
for i in $storeBRoot/*; do
|
||||
for i in "$storeBRoot"/*; do
|
||||
if [[ $i =~ /trash ]]; then continue; fi # compat with old daemon
|
||||
touch $i.lock
|
||||
touch $i.chroot
|
||||
touch "$i".lock
|
||||
touch "$i".chroot
|
||||
done
|
||||
|
||||
nix-collect-garbage
|
||||
|
|
@ -51,7 +51,8 @@ rm "$stateB/gcroots/foo"
|
|||
nix-collect-garbage
|
||||
|
||||
# Check that the output has been GC'd.
|
||||
test ! -e $outPath
|
||||
test ! -e "$outPath"
|
||||
|
||||
# Check that the store is empty.
|
||||
# shellcheck disable=SC2012
|
||||
[ "$(ls -1 "$storeBTop" | wc -l)" = "0" ]
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# shellcheck shell=bash
|
||||
source common.sh
|
||||
source ../common/init.sh
|
||||
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@ overlayPath="$storeBRoot/nix/store/$dupFilename"
|
|||
lowerInode=$(stat -c %i "$lowerPath")
|
||||
upperInode=$(stat -c %i "$upperPath")
|
||||
overlayInode=$(stat -c %i "$overlayPath")
|
||||
[[ $upperInode == $overlayInode ]]
|
||||
[[ $upperInode != $lowerInode ]]
|
||||
[[ $upperInode == "$overlayInode" ]]
|
||||
[[ $upperInode != "$lowerInode" ]]
|
||||
|
||||
# Run optimise to deduplicate store paths
|
||||
nix-store --store "$storeB" --optimise
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# shellcheck shell=bash
|
||||
source common.sh
|
||||
source ../common/init.sh
|
||||
|
||||
|
|
|
|||
|
|
@ -22,14 +22,14 @@ mountOverlayfs
|
|||
pathInLowerStore=$(nix-store --store "$storeA" --add ../dummy)
|
||||
|
||||
# upper layer should not have it
|
||||
expect 1 stat $(toRealPath "$storeBTop/nix/store" "$pathInLowerStore")
|
||||
expect 1 stat "$(toRealPath "$storeBTop/nix/store" "$pathInLowerStore")"
|
||||
|
||||
pathFromB=$(nix-store --store "$storeB" --add ../dummy)
|
||||
|
||||
[[ $pathInLowerStore == $pathFromB ]]
|
||||
[[ $pathInLowerStore == "$pathFromB" ]]
|
||||
|
||||
# lower store should have it from before
|
||||
stat $(toRealPath "$storeA/nix/store" "$pathInLowerStore")
|
||||
stat "$(toRealPath "$storeA/nix/store" "$pathInLowerStore")"
|
||||
|
||||
# upper layer should still not have it (no redundant copy)
|
||||
expect 1 stat $(toRealPath "$storeBTop" "$pathInLowerStore")
|
||||
expect 1 stat "$(toRealPath "$storeBTop" "$pathInLowerStore")"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# shellcheck shell=bash
|
||||
source common.sh
|
||||
source ../common/init.sh
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# shellcheck shell=bash
|
||||
source common.sh
|
||||
source ../common/init.sh
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ mountOverlayfs
|
|||
## Initialise stores for test
|
||||
|
||||
# Realise a derivation from the lower store to propagate paths to overlay DB
|
||||
nix-store --store "$storeB" --realise $drvPath
|
||||
nix-store --store "$storeB" --realise "$drvPath"
|
||||
|
||||
# Also ensure dummy file exists in overlay DB
|
||||
dummyPath=$(nix-store --store "$storeB" --add ../dummy)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# shellcheck shell=bash
|
||||
source common.sh
|
||||
source ../common/init.sh
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue