From ba680b10dac61d15f45bb024fd2262e102a5247a Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 29 Nov 2017 23:01:34 -0800 Subject: [PATCH] make sure the repo size is greater than the size of the symlink Before, we'd check to make sure the repo, when checked through a symlink, is at least as large as the repo *before* we checked it through the symlink. However, this assumes that the repo can't shrink. Really, this test exists to ensure we measure the repo size itself instead of the size of the symlink; this commit changes the test to reflect this. This test fails when 54d7e03303f70d88bfaa8a8aee636dd33b2dd491 is reverted. fixes #4408 License: MIT Signed-off-by: Steven Allen --- test/sharness/lib/test-lib.sh | 21 +++++++++++++++++++++ test/sharness/t0088-repo-stat-symlink.sh | 9 +++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/test/sharness/lib/test-lib.sh b/test/sharness/lib/test-lib.sh index 660f94e1b..3830fa49d 100644 --- a/test/sharness/lib/test-lib.sh +++ b/test/sharness/lib/test-lib.sh @@ -363,10 +363,31 @@ generic_stat() { FreeBSD | Darwin | DragonFly) _STAT="stat -f %Sp" ;; + *) + echo "unsupported OS" >&2 + exit 1 + ;; esac $_STAT "$1" || echo "failed" # Avoid returning nothing. } +# output a file's permission in human readable format +file_size() { + case $(uname -s) in + Linux) + _STAT="stat --format=%s" + ;; + FreeBSD | Darwin | DragonFly) + _STAT="stat -f%z" + ;; + *) + echo "unsupported OS" >&2 + exit 1 + ;; + esac + $_STAT "$1" +} + test_check_peerid() { peeridlen=$(echo "$1" | tr -dC "[:alnum:]" | wc -c | tr -d " ") && test "$peeridlen" = "46" || { diff --git a/test/sharness/t0088-repo-stat-symlink.sh b/test/sharness/t0088-repo-stat-symlink.sh index 405d8ac5b..e38f7c7c2 100755 --- a/test/sharness/t0088-repo-stat-symlink.sh +++ b/test/sharness/t0088-repo-stat-symlink.sh @@ -15,14 +15,11 @@ test_expect_success "create symbolic link for IPFS_PATH" ' test_init_ipfs -# compare RepoSize when getting it directly vs via symbolic link +# ensure that the RepoSize is reasonable when checked via a symlink. test_expect_success "'ipfs repo stat' RepoSize is correct with sym link" ' - export IPFS_PATH="sym_link_target" && - reposize_direct=$(ipfs repo stat | grep RepoSize | awk '\''{ print $2 }'\'') && - export IPFS_PATH=".ipfs" && reposize_symlink=$(ipfs repo stat | grep RepoSize | awk '\''{ print $2 }'\'') && - echo "reposize_symlink: $reposize_symlink; reposize_direct: $reposize_direct" && - test $reposize_symlink -ge $reposize_direct + symlink_size=$(file_size .ipfs) && + test "${reposize_symlink}" -gt "${symlink_size}" ' test_done