From eb4508210331d796d415a187b1cf8596e768acfe Mon Sep 17 00:00:00 2001 From: rht Date: Tue, 28 Jul 2015 09:42:15 +0700 Subject: [PATCH] Add reversible gc test License: MIT Signed-off-by: rht --- test/sharness/lib/test-lib.sh | 16 ++++++++++++++++ test/sharness/t0080-repo.sh | 10 ++++++++++ 2 files changed, 26 insertions(+) diff --git a/test/sharness/lib/test-lib.sh b/test/sharness/lib/test-lib.sh index e257ba1e5c8..4741d2c7f27 100644 --- a/test/sharness/lib/test-lib.sh +++ b/test/sharness/lib/test-lib.sh @@ -314,3 +314,19 @@ test_str_contains() { shift echo "$@" | grep "$find" >/dev/null } + +disk_usage() { + # normalize du across systems + case $(uname -s) in + Linux) + DU="du -sb" + ;; + FreeBSD) + DU="du -s -A -B 1" + ;; + Darwin | DragonFly) + DU="du" + ;; + esac + $DU "$1" | awk "{print \$1}" +} diff --git a/test/sharness/t0080-repo.sh b/test/sharness/t0080-repo.sh index f3dfc98a91a..d9e85702084 100755 --- a/test/sharness/t0080-repo.sh +++ b/test/sharness/t0080-repo.sh @@ -44,6 +44,16 @@ test_expect_success "'ipfs pin rm' output looks good" ' test_cmp expected1 actual1 ' +test_expect_failure "ipfs repo gc fully reverse ipfs add" ' + random 100000 41 >gcfile && + disk_usage "$IPFS_PATH/blocks" >expected && + hash=`ipfs add -q gcfile` && + ipfs pin rm -r $hash && + ipfs repo gc && + disk_usage "$IPFS_PATH/blocks" >actual && + test_cmp expected actual +' + test_expect_success "file no longer pinned" ' # we expect the welcome files and gw assets to show up here echo "$HASH_WELCOME_DOCS" >expected2 &&