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 <steven@stebalien.com>
Steven Allen committed
Nov 29, 2017 at 23:01 UTC
ba680b10dac61d15f45bb024fd2262e102a5247a
2 files changed
+24
-6
test/sharness/lib/test-lib.sh
+21
@@ -363,10 +363,31 @@ generic_stat() {
363
FreeBSD | Darwin | DragonFly)
364
_STAT="stat -f %Sp"
365
;;
366
+ *)
367
+ echo "unsupported OS" >&2
368
+ exit 1
369
+ ;;
370
esac
371
$_STAT "$1" || echo "failed" # Avoid returning nothing.
372
}
373
374
+# output a file's permission in human readable format
375
+file_size() {
376
+ case $(uname -s) in
377
+ Linux)
378
+ _STAT="stat --format=%s"
379
+ ;;
380
+ FreeBSD | Darwin | DragonFly)
381
+ _STAT="stat -f%z"
382
+ ;;
383
+ *)
384
+ echo "unsupported OS" >&2
385
+ exit 1
386
+ ;;
387
+ esac
388
+ $_STAT "$1"
389
+}
390
+
391
test_check_peerid() {
392
peeridlen=$(echo "$1" | tr -dC "[:alnum:]" | wc -c | tr -d " ") &&
393
test "$peeridlen" = "46" || {
test/sharness/t0088-repo-stat-symlink.sh
+3
-6
@@ -15,14 +15,11 @@ test_expect_success "create symbolic link for IPFS_PATH" '
15
16
test_init_ipfs
17
18
-# compare RepoSize when getting it directly vs via symbolic link
18
+# ensure that the RepoSize is reasonable when checked via a symlink.
19
test_expect_success "'ipfs repo stat' RepoSize is correct with sym link" '
20
- export IPFS_PATH="sym_link_target" &&
21
- reposize_direct=$(ipfs repo stat | grep RepoSize | awk '\''{ print $2 }'\'') &&
22
- export IPFS_PATH=".ipfs" &&
20
reposize_symlink=$(ipfs repo stat | grep RepoSize | awk '\''{ print $2 }'\'') &&
24
- echo "reposize_symlink: $reposize_symlink; reposize_direct: $reposize_direct" &&
25
- test $reposize_symlink -ge $reposize_direct
21
+ symlink_size=$(file_size .ipfs) &&
22
+ test "${reposize_symlink}" -gt "${symlink_size}"
23
'
24
25
test_done