aboutsummaryrefslogtreecommitdiff
path: root/tests/repair.sh
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2022-03-10 16:20:01 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2022-03-10 16:20:01 +0000
commit938650700fafe76e3755982d670855fed3db35c6 (patch)
tree7a6ac217f87cad07bb963ec658bd60625b868466 /tests/repair.sh
parent195daa82995b43b3cbd552735a678afb85f4ae28 (diff)
parent8ba089597fa19bfd49ba5f22a5e821740ca4eb5d (diff)
Merge branch 'path-info' into ca-drv-exotic
Diffstat (limited to 'tests/repair.sh')
-rw-r--r--tests/repair.sh49
1 files changed, 48 insertions, 1 deletions
diff --git a/tests/repair.sh b/tests/repair.sh
index 12dcde8ea..c8f07b1c6 100644
--- a/tests/repair.sh
+++ b/tests/repair.sh
@@ -30,7 +30,7 @@ nix-store --verify-path $path2
chmod u+w $path2
touch $path2/bad
-nix-store --delete $(nix-store -qd $path2)
+nix-store --delete $(nix-store -q --referrers-closure $(nix-store -qd $path2))
(! nix-store --verify --check-contents --repair)
@@ -74,3 +74,50 @@ if [ "$(nix-hash $path2)" != "$hash" -o -e $path2/bad ]; then
echo "path not repaired properly" >&2
exit 1
fi
+
+# Check that --repair-path also checks content of optimised symlinks (1/2)
+nix-store --verify-path $path2
+
+if (! nix-store --optimize); then
+ echo "nix-store --optimize failed to optimize the store" >&2
+ exit 1
+fi
+chmod u+w $path2/bar
+echo 'rabrab' > $path2/bar # different length
+
+if nix-store --verify-path $path2; then
+ echo "nix-store --verify-path did not detect .links file corruption" >&2
+ exit 1
+fi
+
+nix-store --repair-path $path2 --option auto-optimise-store true
+
+if [ "$(nix-hash $path2)" != "$hash" -o "BAR" != "$(< $path2/bar)" ]; then
+ echo "path not repaired properly" >&2
+ exit 1
+fi
+
+# Check that --repair-path also checks content of optimised symlinks (2/2)
+nix-store --verify-path $path2
+
+if (! nix-store --optimize); then
+ echo "nix-store --optimize failed to optimize the store" >&2
+ exit 1
+fi
+chmod u+w $path2
+chmod u+w $path2/bar
+sed -e 's/./X/g' < $path2/bar > $path2/tmp # same length, different content.
+cp $path2/tmp $path2/bar
+rm $path2/tmp
+
+if nix-store --verify-path $path2; then
+ echo "nix-store --verify-path did not detect .links file corruption" >&2
+ exit 1
+fi
+
+nix-store --repair-path $path2 --substituters "file://$cacheDir" --no-require-sigs --option auto-optimise-store true
+
+if [ "$(nix-hash $path2)" != "$hash" -o "BAR" != "$(< $path2/bar)" ]; then
+ echo "path not repaired properly" >&2
+ exit 1
+fi