From cacb1cc2d4fdb7c7bc844a4653d4947be4fee646 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Mon, 1 Feb 2016 13:17:13 +0100 Subject: [PATCH] sharness: add lib/iptb-lib.sh License: MIT Signed-off-by: Christian Couder --- test/sharness/lib/iptb-lib.sh | 18 ++++++++++++++++++ test/sharness/lib/test-lib.sh | 3 +++ test/sharness/t0101-iptb-name.sh | 13 ------------- 3 files changed, 21 insertions(+), 13 deletions(-) create mode 100644 test/sharness/lib/iptb-lib.sh diff --git a/test/sharness/lib/iptb-lib.sh b/test/sharness/lib/iptb-lib.sh new file mode 100644 index 000000000..5f49fdef4 --- /dev/null +++ b/test/sharness/lib/iptb-lib.sh @@ -0,0 +1,18 @@ +# iptb test framework +# +# Copyright (c) 2014, 2016 Jeromy Johnson, Christian Couder +# MIT Licensed; see the LICENSE file in this repository. + +export IPTB_ROOT="`pwd`/.iptb" + +ipfsi() { + dir="$1" + shift + IPFS_PATH="$IPTB_ROOT/$dir" ipfs $@ +} + +check_has_connection() { + node=$1 + ipfsi $node swarm peers | grep ipfs > /dev/null +} + diff --git a/test/sharness/lib/test-lib.sh b/test/sharness/lib/test-lib.sh index ec28d6d77..9d2f40544 100644 --- a/test/sharness/lib/test-lib.sh +++ b/test/sharness/lib/test-lib.sh @@ -53,6 +53,9 @@ fi # source our generic test lib . ../../ipfs-test-lib.sh +# source iptb lib +. ../lib/iptb-lib.sh + test_cmp_repeat_10_sec() { for i in $(test_seq 1 100) do diff --git a/test/sharness/t0101-iptb-name.sh b/test/sharness/t0101-iptb-name.sh index f5534aa29..21c8987d4 100755 --- a/test/sharness/t0101-iptb-name.sh +++ b/test/sharness/t0101-iptb-name.sh @@ -8,25 +8,12 @@ test_description="Test ipfs repo operations" . lib/test-lib.sh -export IPTB_ROOT="`pwd`/.iptb" - num_nodes=4 -ipfsi() { - dir="$1" - shift - IPFS_PATH="$IPTB_ROOT/$dir" ipfs $@ -} - test_expect_success "set up an iptb cluster" ' iptb init -n $num_nodes -p 0 -f --bootstrap=none ' -check_has_connection() { - node=$1 - ipfsi $node swarm peers | grep ipfs > /dev/null -} - startup_cluster() { bound=`expr $num_nodes - 1` test_expect_success "start up nodes" '