diff --git a/test/sharness/lib/test-lib.sh b/test/sharness/lib/test-lib.sh index b5c03ba48..659e8b98d 100644 --- a/test/sharness/lib/test-lib.sh +++ b/test/sharness/lib/test-lib.sh @@ -52,9 +52,13 @@ TEST_OS="$(uname -s | tr '[a-z]' '[A-Z]')" # grab + output options test "$TEST_NO_FUSE" != 1 && test_set_prereq FUSE test "$TEST_EXPENSIVE" = 1 && test_set_prereq EXPENSIVE -test "$TEST_NO_DOCKER" != 1 && type docker >/dev/null 2>&1 && test_set_prereq DOCKER +test "$TEST_NO_DOCKER" != 1 && type docker >/dev/null 2>&1 && groups | egrep "\bdocker\b" && test_set_prereq DOCKER test "$TEST_NO_PLUGIN" != 1 && test "$TEST_OS" = "LINUX" && test_set_prereq PLUGIN +# this may not be available, skip a few dependent tests +type socat >/dev/null 2>&1 && test_set_prereq SOCAT + + # Set a prereq as error messages are often different on Windows/Cygwin expr "$TEST_OS" : "CYGWIN_NT" >/dev/null || test_set_prereq STD_ERR_MSG diff --git a/test/sharness/t0010-basic-commands.sh b/test/sharness/t0010-basic-commands.sh index d483adfd7..b59f011f5 100755 --- a/test/sharness/t0010-basic-commands.sh +++ b/test/sharness/t0010-basic-commands.sh @@ -45,8 +45,9 @@ test_expect_success "ipfs version deps succeeds" ' ipfs version deps >deps.txt ' -test_expect_success "ipfs version deps output looks good" ' +test_expect_success "ipfs version deps output looks good ( set \$GOIPFSTEST_SKIP_LOCAL_DEVTREE_DEPS_CHECK to skip this test )" ' head -1 deps.txt | grep "go-ipfs@(devel)" && + [[ "$GOIPFSTEST_SKIP_LOCAL_DEVTREE_DEPS_CHECK" == "1" ]] || [[ $(tail -n +2 deps.txt | egrep -v -c "^[^ @]+@v[^ @]+( => [^ @]+@v[^ @]+)?$") -eq 0 ]] || test_fsh cat deps.txt ' diff --git a/test/sharness/t0060-daemon.sh b/test/sharness/t0060-daemon.sh index 67108f7cd..7e7c658fb 100755 --- a/test/sharness/t0060-daemon.sh +++ b/test/sharness/t0060-daemon.sh @@ -108,8 +108,9 @@ test_expect_success "ipfs version deps succeeds" ' ipfs version deps >deps.txt ' -test_expect_success "ipfs version deps output looks good" ' +test_expect_success "ipfs version deps output looks good ( set \$GOIPFSTEST_SKIP_LOCAL_DEVTREE_DEPS_CHECK to skip this test )" ' head -1 deps.txt | grep "go-ipfs@(devel)" && + [[ "$GOIPFSTEST_SKIP_LOCAL_DEVTREE_DEPS_CHECK" == "1" ]] || [[ $(tail -n +2 deps.txt | egrep -v -c "^[^ @]+@v[^ @]+( => [^ @]+@v[^ @]+)?$") -eq 0 ]] || test_fsh cat deps.txt ' @@ -124,13 +125,8 @@ test_expect_success "ipfs help output looks good" ' test_fsh cat help.txt ' -# netcat (nc) is needed for the following test -test_expect_success "socat is available" ' - type socat >/dev/null -' - # check transport is encrypted -test_expect_success "transport should be encrypted" ' +test_expect_success SOCAT "transport should be encrypted ( needs socat )" ' socat - tcp:localhost:$SWARM_PORT,connect-timeout=1 > swarmnc < ../t0060-data/mss-ls && grep -q "/secio" swarmnc && test_must_fail grep -q "/plaintext/1.0.0" swarmnc || diff --git a/test/sharness/t0061-daemon-opts.sh b/test/sharness/t0061-daemon-opts.sh index 227d4fa30..7d5cf7fe7 100755 --- a/test/sharness/t0061-daemon-opts.sh +++ b/test/sharness/t0061-daemon-opts.sh @@ -17,7 +17,7 @@ gwyaddr=$GWAY_ADDR apiaddr=$API_ADDR # Odd. this fails here, but the inverse works on t0060-daemon. -test_expect_success 'transport should be unencrypted' ' +test_expect_success SOCAT 'transport should be unencrypted ( needs socat )' ' socat - tcp:localhost:$SWARM_PORT,connect-timeout=1 > swarmnc < ../t0060-data/mss-ls && grep -q -v "/secio" swarmnc && grep -q "/plaintext" swarmnc || diff --git a/test/sharness/t0080-repo.sh b/test/sharness/t0080-repo.sh index 46254288e..3d228ea33 100755 --- a/test/sharness/t0080-repo.sh +++ b/test/sharness/t0080-repo.sh @@ -247,10 +247,10 @@ test_expect_success "'ipfs repo stat --human' succeeds" ' test_expect_success "repo stats --human came out correct" ' grep "RepoPath" repo-stats-human && - grep -P "RepoSize:\s*([0-9]*[.])?[0-9]+\s+?(B|kB|MB|GB|TB|PB|EB)" repo-stats-human && + grep -E "RepoSize:\s*([0-9]*[.])?[0-9]+\s+?(B|kB|MB|GB|TB|PB|EB)" repo-stats-human && grep "NumObjects" repo-stats-human && grep "Version" repo-stats-human && - grep -P "StorageMax:\s*([0-9]*[.])?[0-9]+\s+?(B|kB|MB|GB|TB|PB|EB)" repo-stats-human || + grep -E "StorageMax:\s*([0-9]*[.])?[0-9]+\s+?(B|kB|MB|GB|TB|PB|EB)" repo-stats-human || test_fsh cat repo-stats-human ' diff --git a/test/sharness/t0095-refs.sh b/test/sharness/t0095-refs.sh index d363d043f..99dc361c7 100755 --- a/test/sharness/t0095-refs.sh +++ b/test/sharness/t0095-refs.sh @@ -182,4 +182,6 @@ test_refs_output '' 'cat' test_refs_output '--cid-base=base32' 'ipfs cid base32' +test_kill_ipfs_daemon + test_done diff --git a/test/sharness/t0121-bootstrap-iptb.sh b/test/sharness/t0121-bootstrap-iptb.sh index 8de23a216..16dcbdb2f 100755 --- a/test/sharness/t0121-bootstrap-iptb.sh +++ b/test/sharness/t0121-bootstrap-iptb.sh @@ -38,11 +38,11 @@ betterwait() { } test_expect_success "bring down iptb nodes" ' - PID0=$(cat "$IPTB_ROOT/benches/default/0/daemon.pid") && - PID1=$(cat "$IPTB_ROOT/benches/default/1/daemon.pid") && - PID2=$(cat "$IPTB_ROOT/benches/default/2/daemon.pid") && - PID3=$(cat "$IPTB_ROOT/benches/default/3/daemon.pid") && - PID4=$(cat "$IPTB_ROOT/benches/default/4/daemon.pid") && + PID0=$(cat "$IPTB_ROOT/testbeds/default/0/daemon.pid") && + PID1=$(cat "$IPTB_ROOT/testbeds/default/1/daemon.pid") && + PID2=$(cat "$IPTB_ROOT/testbeds/default/2/daemon.pid") && + PID3=$(cat "$IPTB_ROOT/testbeds/default/3/daemon.pid") && + PID4=$(cat "$IPTB_ROOT/testbeds/default/4/daemon.pid") && iptb stop && # TODO: add --wait flag to iptb stop betterwait $PID0 betterwait $PID1 diff --git a/test/sharness/t0130-multinode.sh b/test/sharness/t0130-multinode.sh index 1c732db7a..e0a27b666 100755 --- a/test/sharness/t0130-multinode.sh +++ b/test/sharness/t0130-multinode.sh @@ -80,7 +80,7 @@ run_advanced_test() { test_expect_success "shut down nodes" ' iptb stop && iptb_wait_stop || - test_fsh tail -n +1 .iptb/benches/default/*/daemon.std* + test_fsh tail -n +1 .iptb/testbeds/default/*/daemon.std* ' } diff --git a/test/sharness/t0180-p2p.sh b/test/sharness/t0180-p2p.sh index 0aa9d8c42..236f2ac9f 100755 --- a/test/sharness/t0180-p2p.sh +++ b/test/sharness/t0180-p2p.sh @@ -22,10 +22,10 @@ test_expect_success 'peer ids' ' ' check_test_ports() { test_expect_success "test ports are closed" ' - (! (netstat -lnp | grep "LISTEN" | grep ":10101 ")) && - (! (netstat -lnp | grep "LISTEN" | grep ":10102 "))&& - (! (netstat -lnp | grep "LISTEN" | grep ":10103 ")) && - (! (netstat -lnp | grep "LISTEN" | grep ":10104 ")) + (! (netstat -aln | grep "LISTEN" | grep -E "[.:]10101 ")) && + (! (netstat -aln | grep "LISTEN" | grep -E "[.:]10102 ")) && + (! (netstat -aln | grep "LISTEN" | grep -E "[.:]10103 ")) && + (! (netstat -aln | grep "LISTEN" | grep -E "[.:]10104 ")) ' } check_test_ports diff --git a/test/sharness/t0181-private-network.sh b/test/sharness/t0181-private-network.sh index d2230aa1b..dfb4be203 100755 --- a/test/sharness/t0181-private-network.sh +++ b/test/sharness/t0181-private-network.sh @@ -132,4 +132,6 @@ test_expect_success "stop testbed" ' iptb stop ' +test_kill_ipfs_daemon + test_done diff --git a/test/sharness/t0184-http-proxy-over-p2p.sh b/test/sharness/t0184-http-proxy-over-p2p.sh index d647273f0..9beda4fbc 100755 --- a/test/sharness/t0184-http-proxy-over-p2p.sh +++ b/test/sharness/t0184-http-proxy-over-p2p.sh @@ -3,6 +3,12 @@ test_description="Test http proxy over p2p" . lib/test-lib.sh + +if ! test_have_prereq SOCAT; then + skip_all="skipping '$test_description': socat is not available" + test_done +fi + WEB_SERVE_PORT=5099 IPFS_GATEWAY_PORT=5199 SENDER_GATEWAY="http://127.0.0.1:$IPFS_GATEWAY_PORT" diff --git a/test/sharness/t0235-cli-request.sh b/test/sharness/t0235-cli-request.sh index 24bccd4d5..3d50a2e62 100755 --- a/test/sharness/t0235-cli-request.sh +++ b/test/sharness/t0235-cli-request.sh @@ -8,6 +8,12 @@ test_description="test http requests made by cli" . lib/test-lib.sh +if ! test_have_prereq SOCAT; then + skip_all="skipping '$test_description': socat is not available" + test_done +fi + + test_init_ipfs test_expect_success "start nc" ' diff --git a/test/sharness/t0236-cli-api-dns-resolve.sh b/test/sharness/t0236-cli-api-dns-resolve.sh index 1beefed09..eddbc93da 100755 --- a/test/sharness/t0236-cli-api-dns-resolve.sh +++ b/test/sharness/t0236-cli-api-dns-resolve.sh @@ -8,6 +8,11 @@ test_description="test dns resolution of api endpoint by cli" . lib/test-lib.sh +if ! test_have_prereq SOCAT; then + skip_all="skipping '$test_description': socat is not available" + test_done +fi + test_init_ipfs test_expect_success "start nc" ' diff --git a/test/sharness/t0280-plugin-git.sh b/test/sharness/t0280-plugin-git.sh index f5948fbb6..e7bc06427 100755 --- a/test/sharness/t0280-plugin-git.sh +++ b/test/sharness/t0280-plugin-git.sh @@ -21,7 +21,7 @@ test_dag_git() { ' test_expect_success "successfully get added objects" ' - cat hashes | xargs -i ipfs dag get -- {} > /dev/null + cat hashes | xargs -I {} ipfs dag get -- {} > /dev/null ' test_expect_success "path traversals work" ' diff --git a/test/sharness/t0300-docker-image.sh b/test/sharness/t0300-docker-image.sh index 741f8885a..3d8f573f2 100755 --- a/test/sharness/t0300-docker-image.sh +++ b/test/sharness/t0300-docker-image.sh @@ -23,10 +23,6 @@ test_expect_success "'docker --version' output looks good" ' egrep "^Docker version" actual ' -test_expect_success "current user is in the 'docker' group" ' - groups | egrep "\bdocker\b" -' - TEST_TRASH_DIR=$(pwd) TEST_SCRIPTS_DIR=$(dirname "$TEST_TRASH_DIR") TEST_TESTS_DIR=$(dirname "$TEST_SCRIPTS_DIR") diff --git a/test/sharness/t0301-docker-migrate.sh b/test/sharness/t0301-docker-migrate.sh index 767769202..2ccc8bae2 100755 --- a/test/sharness/t0301-docker-migrate.sh +++ b/test/sharness/t0301-docker-migrate.sh @@ -10,11 +10,16 @@ test_description="Test docker image migration" # if in travis CI on OSX, docker is not available if ! test_have_prereq DOCKER; then - skip_all='skipping docker tests, docker not available' + skip_all='skipping '$test_description', docker not available' test_done fi +if ! test_have_prereq SOCAT; then + skip_all="skipping '$test_description': socat is not available" + test_done +fi + TEST_TRASH_DIR=$(pwd) TEST_SCRIPTS_DIR=$(dirname "$TEST_TRASH_DIR") TEST_TESTS_DIR=$(dirname "$TEST_SCRIPTS_DIR") diff --git a/test/sharness/t0600-issues-and-regressions-online.sh b/test/sharness/t0600-issues-and-regressions-online.sh index 1abf87170..8496a0f03 100755 --- a/test/sharness/t0600-issues-and-regressions-online.sh +++ b/test/sharness/t0600-issues-and-regressions-online.sh @@ -46,7 +46,7 @@ test_expect_success "pin add api looks right - #3753" ' test_cmp pinrm_out pinrm_exp ' -test_expect_success "no daemon crash on improper file argument - #4003" ' +test_expect_success SOCAT "no daemon crash on improper file argument - #4003 ( test needs socat )" ' FNC=$(echo $API_ADDR | awk -F: '\''{ printf "%s:%s", $1, $2 }'\'') && printf "POST /api/v0/add?pin=true HTTP/1.1\r\nHost: $API_ADDR\r\nContent-Type: multipart/form-data; boundary=Pyw9xQLtiLPE6XcI\r\nContent-Length: 22\r\n\r\n\r\n--Pyw9xQLtiLPE6XcI\r\n" | socat STDIO tcp-connect:$FNC | grep -m1 "500 Internal Server Error" '