Adjusting test scripts to make it easier to spot failures.
This commit is contained in:
parent
42aa1646ab
commit
2ee0a87439
12 changed files with 191 additions and 42 deletions
|
@ -1,10 +1,17 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
TEST_FILE=$1
|
TEST_FILE=test_$1.sh
|
||||||
|
|
||||||
|
test_success=0
|
||||||
|
|
||||||
source ./$TEST_FILE
|
source ./$TEST_FILE
|
||||||
|
|
||||||
pre
|
function do_it() {
|
||||||
body
|
pre
|
||||||
post
|
body
|
||||||
|
post
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
|
do_it
|
||||||
|
exit $test_success
|
||||||
|
|
|
@ -1,9 +1,29 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
./run_test.sh test_1.sh
|
#source ./test_helpers.sh
|
||||||
./run_test.sh test_2.sh
|
|
||||||
./run_test.sh test_3.sh
|
rm testlog.txt
|
||||||
./run_test.sh test_4.sh
|
|
||||||
./run_test.sh test_5.sh
|
num_tests=9
|
||||||
./run_test.sh test_6.sh
|
tests_passed=0
|
||||||
./run_test.sh test_7.sh
|
tests_failed=0
|
||||||
|
i=1
|
||||||
|
while [ $i -le $num_tests ]; do
|
||||||
|
echo *Running test number $i
|
||||||
|
echo *Running test number $i >> testlog.txt
|
||||||
|
./run_test.sh $i >>testlog.txt 2>&1
|
||||||
|
retVal=$?
|
||||||
|
if [ $retVal -ne 0 ]; then
|
||||||
|
echo *Test number $i failed
|
||||||
|
echo *Test number $i failed >> testlog.txt
|
||||||
|
let tests_failed++
|
||||||
|
else
|
||||||
|
echo *Test number $i passed
|
||||||
|
echo *Test number $i passed >> testlog.txt
|
||||||
|
let tests_passed++
|
||||||
|
fi
|
||||||
|
let i++
|
||||||
|
done
|
||||||
|
echo Of $num_tests tests, $tests_passed passed and $tests_failed failed.
|
||||||
|
echo Of $num_tests tests, $tests_passed passed and $tests_failed failed. >> testlog.txt
|
||||||
|
echo Results are in testlog.txt
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
####
|
####
|
||||||
# Attempt to retrieve binary file from running daemon
|
# Attempt to retrieve large binary file from running daemon
|
||||||
#
|
#
|
||||||
####
|
####
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ IPFS="../../main/ipfs --config /tmp/ipfs_1"
|
||||||
function pre {
|
function pre {
|
||||||
rm -Rf /tmp/ipfs_1
|
rm -Rf /tmp/ipfs_1
|
||||||
eval "$IPFS" init;
|
eval "$IPFS" init;
|
||||||
check_failure "pre" $?
|
check_failure_with_exit "pre" $?
|
||||||
cp ../config.test1.wo_journal /tmp/ipfs_1/config
|
cp ../config.test1.wo_journal /tmp/ipfs_1/config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,22 +23,23 @@ function post {
|
||||||
}
|
}
|
||||||
|
|
||||||
function body {
|
function body {
|
||||||
create_binary_file;
|
create_binary_file 512;
|
||||||
eval "$IPFS" add hello.bin
|
eval "$IPFS" add hello.bin
|
||||||
check_failure "add hello.bin" $?
|
check_failure_with_exit "add hello.bin" $?
|
||||||
|
|
||||||
#start the daemon
|
#start the daemon
|
||||||
eval "../../main/ipfs --config /tmp/ipfs_1 daemon &"
|
eval "../../main/ipfs --config /tmp/ipfs_1 daemon &"
|
||||||
daemon_id=$!
|
daemon_id=$!
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
eval "$IPFS" cat QmX4zpwaE7CSgZZsULgoB3gXYC6hh7RN19bEfWxw7sL8Xx > hello2.bin
|
eval "$IPFS" cat QmVGA3bXDJ41xoT621xQNzQgtBMQHj2AYxaunLBJtSoNgg > hello2.bin
|
||||||
check_failure "cat" $?
|
check_failure_with_exit "cat" $?
|
||||||
|
|
||||||
# file size should be 256
|
# file size should be 512
|
||||||
actualsize=$(wc -c < hello2.bin)
|
actualsize=$(wc -c < hello2.bin)
|
||||||
if [ $actualsize -ne 256 ]; then
|
if [ $actualsize -ne 512 ]; then
|
||||||
echo '*** Failure *** file size incorrect'
|
echo '*** Failure *** file size incorrect'
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
kill -9 $daemon_id
|
kill -9 $daemon_id
|
||||||
|
|
|
@ -7,7 +7,7 @@ IPFS="../../main/ipfs --config /tmp/ipfs_1"
|
||||||
function pre {
|
function pre {
|
||||||
post
|
post
|
||||||
eval "$IPFS" init;
|
eval "$IPFS" init;
|
||||||
check_failure "pre" $?
|
check_failure_with_exit "pre" $?
|
||||||
}
|
}
|
||||||
|
|
||||||
function post {
|
function post {
|
||||||
|
@ -18,10 +18,10 @@ function post {
|
||||||
function body {
|
function body {
|
||||||
create_hello_world;
|
create_hello_world;
|
||||||
eval "$IPFS" add hello.txt
|
eval "$IPFS" add hello.txt
|
||||||
check_failure "add hello.txt" $?
|
check_failure_with_exit "add hello.txt" $?
|
||||||
|
|
||||||
eval "$IPFS" cat QmYAXgX8ARiriupMQsbGXtKdDyGzWry1YV3sycKw1qqmgH
|
eval "$IPFS" cat QmYAXgX8ARiriupMQsbGXtKdDyGzWry1YV3sycKw1qqmgH
|
||||||
check_failure "cat hello.txt" $?
|
check_failure_with_exit "cat hello.txt" $?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ IPFS="../../main/ipfs --config /tmp/ipfs_1"
|
||||||
function pre {
|
function pre {
|
||||||
post
|
post
|
||||||
eval "$IPFS" init;
|
eval "$IPFS" init;
|
||||||
check_failure "pre" $?
|
check_failure_with_exit "pre" $?
|
||||||
}
|
}
|
||||||
|
|
||||||
function post {
|
function post {
|
||||||
|
@ -23,7 +23,7 @@ function post {
|
||||||
function body {
|
function body {
|
||||||
create_hello_world;
|
create_hello_world;
|
||||||
eval "$IPFS" add hello.txt
|
eval "$IPFS" add hello.txt
|
||||||
check_failure "add hello.txt" $?
|
check_failure_with_exit "add hello.txt" $?
|
||||||
|
|
||||||
#start the daemon
|
#start the daemon
|
||||||
eval "../../main/ipfs --config /tmp/ipfs_1 daemon &"
|
eval "../../main/ipfs --config /tmp/ipfs_1 daemon &"
|
||||||
|
@ -31,7 +31,7 @@ function body {
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
eval "$IPFS" cat QmYAXgX8ARiriupMQsbGXtKdDyGzWry1YV3sycKw1qqmgH
|
eval "$IPFS" cat QmYAXgX8ARiriupMQsbGXtKdDyGzWry1YV3sycKw1qqmgH
|
||||||
check_failure "cat hello.txt" $?
|
check_failure_with_exit "cat hello.txt" $?
|
||||||
|
|
||||||
kill -9 $daemon_id
|
kill -9 $daemon_id
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ IPFS="../../main/ipfs --config /tmp/ipfs_1"
|
||||||
function pre {
|
function pre {
|
||||||
post
|
post
|
||||||
eval "$IPFS" init;
|
eval "$IPFS" init;
|
||||||
check_failure "pre" $?
|
check_failure_with_exit "pre" $?
|
||||||
cp ../config.test1.wo_journal /tmp/ipfs_1/config
|
cp ../config.test1.wo_journal /tmp/ipfs_1/config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ function post {
|
||||||
function body {
|
function body {
|
||||||
create_hello_world;
|
create_hello_world;
|
||||||
eval "$IPFS" add hello.txt
|
eval "$IPFS" add hello.txt
|
||||||
check_failure "add hello.txt" $?
|
check_failure_with_exit "add hello.txt" $?
|
||||||
|
|
||||||
#start the daemon
|
#start the daemon
|
||||||
eval "../../main/ipfs --config /tmp/ipfs_1 daemon &"
|
eval "../../main/ipfs --config /tmp/ipfs_1 daemon &"
|
||||||
|
@ -32,10 +32,10 @@ function body {
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
eval "$IPFS" name publish QmYAXgX8ARiriupMQsbGXtKdDyGzWry1YV3sycKw1qqmgH
|
eval "$IPFS" name publish QmYAXgX8ARiriupMQsbGXtKdDyGzWry1YV3sycKw1qqmgH
|
||||||
check_failure "name publish" $?
|
check_failure_with_exit "name publish" $?
|
||||||
|
|
||||||
eval "$IPFS" name resolve /ipns/QmZVoAZGFfinB7MQQiDzB84kWaDPQ95GLuXdemJFM2r9b4
|
eval "$IPFS" name resolve /ipns/QmZVoAZGFfinB7MQQiDzB84kWaDPQ95GLuXdemJFM2r9b4
|
||||||
check_failure "name resolve" $?
|
check_failure_with_exit "name resolve" $?
|
||||||
|
|
||||||
kill -9 $daemon_id
|
kill -9 $daemon_id
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,11 +12,11 @@ IPFS2="../../main/ipfs --config /tmp/ipfs_2"
|
||||||
function pre {
|
function pre {
|
||||||
post
|
post
|
||||||
eval "$IPFS1" init;
|
eval "$IPFS1" init;
|
||||||
check_failure "pre" $?
|
check_failure_with_exit "pre" $?
|
||||||
cp ../config.test1.wo_journal /tmp/ipfs_1/config
|
cp ../config.test1.wo_journal /tmp/ipfs_1/config
|
||||||
|
|
||||||
eval "$IPFS2" init;
|
eval "$IPFS2" init;
|
||||||
check_failure "pre ipfs2" $?
|
check_failure_with_exit "pre ipfs2" $?
|
||||||
cp ../config.test2.wo_journal /tmp/ipfs_2/config
|
cp ../config.test2.wo_journal /tmp/ipfs_2/config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ function post {
|
||||||
function body {
|
function body {
|
||||||
create_hello_world;
|
create_hello_world;
|
||||||
eval "$IPFS1" add hello.txt
|
eval "$IPFS1" add hello.txt
|
||||||
check_failure "add hello.txt" $?
|
check_failure_with_exit "add hello.txt" $?
|
||||||
|
|
||||||
#start the daemons
|
#start the daemons
|
||||||
eval "../../main/ipfs --config /tmp/ipfs_1 daemon &"
|
eval "../../main/ipfs --config /tmp/ipfs_1 daemon &"
|
||||||
|
@ -40,7 +40,7 @@ function body {
|
||||||
|
|
||||||
#A client of server 2 wants the file at server 1
|
#A client of server 2 wants the file at server 1
|
||||||
eval "$IPFS2" cat QmYAXgX8ARiriupMQsbGXtKdDyGzWry1YV3sycKw1qqmgH
|
eval "$IPFS2" cat QmYAXgX8ARiriupMQsbGXtKdDyGzWry1YV3sycKw1qqmgH
|
||||||
check_failure "cat" $?
|
check_failure_with_exit "cat" $?
|
||||||
|
|
||||||
kill -9 $daemon_id_1
|
kill -9 $daemon_id_1
|
||||||
kill -9 $daemon_id_2
|
kill -9 $daemon_id_2
|
||||||
|
|
|
@ -12,7 +12,7 @@ IPFS="../../main/ipfs --config /tmp/ipfs_1"
|
||||||
function pre {
|
function pre {
|
||||||
post
|
post
|
||||||
eval "$IPFS" init;
|
eval "$IPFS" init;
|
||||||
check_failure "pre" $?
|
check_failure_with_exit "pre" $?
|
||||||
cp ../config.test1.wo_journal /tmp/ipfs_1/config
|
cp ../config.test1.wo_journal /tmp/ipfs_1/config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ function post {
|
||||||
function body {
|
function body {
|
||||||
create_hello_world;
|
create_hello_world;
|
||||||
eval "$IPFS" add hello.txt
|
eval "$IPFS" add hello.txt
|
||||||
check_failure "add hello.txt" $?
|
check_failure_with_exit "add hello.txt" $?
|
||||||
|
|
||||||
#start the daemon
|
#start the daemon
|
||||||
eval "../../main/ipfs --config /tmp/ipfs_1 daemon &"
|
eval "../../main/ipfs --config /tmp/ipfs_1 daemon &"
|
||||||
|
@ -32,7 +32,7 @@ function body {
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
eval "$IPFS" name publish QmYAXgX8ARiriupMQsbGXtKdDyGzWry1YV3sycKw1qqmgH
|
eval "$IPFS" name publish QmYAXgX8ARiriupMQsbGXtKdDyGzWry1YV3sycKw1qqmgH
|
||||||
check_failure "name publish" $?
|
check_failure_with_exit "name publish" $?
|
||||||
|
|
||||||
kill -9 $daemon_id
|
kill -9 $daemon_id
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ IPFS="../../main/ipfs --config /tmp/ipfs_1"
|
||||||
function pre {
|
function pre {
|
||||||
rm -Rf /tmp/ipfs_1
|
rm -Rf /tmp/ipfs_1
|
||||||
eval "$IPFS" init;
|
eval "$IPFS" init;
|
||||||
check_failure "pre" $?
|
check_failure_with_exit "pre" $?
|
||||||
cp ../config.test1.wo_journal /tmp/ipfs_1/config
|
cp ../config.test1.wo_journal /tmp/ipfs_1/config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ function post {
|
||||||
}
|
}
|
||||||
|
|
||||||
function body {
|
function body {
|
||||||
create_binary_file;
|
create_binary_file 256;
|
||||||
|
|
||||||
#start the daemon
|
#start the daemon
|
||||||
eval "../../main/ipfs --config /tmp/ipfs_1 daemon &"
|
eval "../../main/ipfs --config /tmp/ipfs_1 daemon &"
|
||||||
|
@ -32,12 +32,12 @@ function body {
|
||||||
|
|
||||||
# add file
|
# add file
|
||||||
eval "$IPFS" add hello.bin
|
eval "$IPFS" add hello.bin
|
||||||
check_failure "add hello.bin" $?
|
check_failure_with_exit "add hello.bin" $?
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
# retrieve file
|
# retrieve file
|
||||||
eval "$IPFS" cat QmX4zpwaE7CSgZZsULgoB3gXYC6hh7RN19bEfWxw7sL8Xx > hello2.bin
|
eval "$IPFS" cat QmX4zpwaE7CSgZZsULgoB3gXYC6hh7RN19bEfWxw7sL8Xx > hello2.bin
|
||||||
check_failure "cat" $?
|
check_failure_with_exit "cat" $?
|
||||||
|
|
||||||
# file size should be 256
|
# file size should be 256
|
||||||
actualsize=$(wc -c < hello2.bin)
|
actualsize=$(wc -c < hello2.bin)
|
||||||
|
|
49
test/scripts/test_8.sh
Executable file
49
test/scripts/test_8.sh
Executable file
|
@ -0,0 +1,49 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
####
|
||||||
|
# Attempt to add and retrieve binary file from running daemon
|
||||||
|
#
|
||||||
|
####
|
||||||
|
|
||||||
|
source ./test_helpers.sh
|
||||||
|
|
||||||
|
IPFS="../../main/ipfs --config /tmp/ipfs_1"
|
||||||
|
|
||||||
|
function pre {
|
||||||
|
rm -Rf /tmp/ipfs_1
|
||||||
|
eval "$IPFS" init;
|
||||||
|
check_failure_with_exit "pre" $?
|
||||||
|
cp ../config.test1.wo_journal /tmp/ipfs_1/config
|
||||||
|
}
|
||||||
|
|
||||||
|
function post {
|
||||||
|
rm -Rf /tmp/ipfs_1;
|
||||||
|
rm hello.bin;
|
||||||
|
rm hello2.bin;
|
||||||
|
}
|
||||||
|
|
||||||
|
function body {
|
||||||
|
create_binary_file 256;
|
||||||
|
|
||||||
|
#start the daemon
|
||||||
|
eval "../../main/ipfs --config /tmp/ipfs_1 daemon &"
|
||||||
|
daemon_id=$!
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
# add file
|
||||||
|
eval "$IPFS" add hello.bin
|
||||||
|
check_failure_with_exit "add hello.bin" $?
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
# retrieve file
|
||||||
|
eval "$IPFS" cat QmX4zpwaE7CSgZZsULgoB3gXYC6hh7RN19bEfWxw7sL8Xx > hello2.bin
|
||||||
|
check_failure_with_exit "cat" $?
|
||||||
|
|
||||||
|
# file size should be 256
|
||||||
|
actualsize=$(wc -c < hello2.bin)
|
||||||
|
if [ $actualsize -ne 256 ]; then
|
||||||
|
echo '*** Failure *** file size incorrect'
|
||||||
|
fi
|
||||||
|
|
||||||
|
kill -9 $daemon_id
|
||||||
|
}
|
45
test/scripts/test_9.sh
Executable file
45
test/scripts/test_9.sh
Executable file
|
@ -0,0 +1,45 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
####
|
||||||
|
# Attempt to retrieve binary file from running daemon
|
||||||
|
#
|
||||||
|
####
|
||||||
|
|
||||||
|
source ./test_helpers.sh
|
||||||
|
|
||||||
|
IPFS="../../main/ipfs --config /tmp/ipfs_1"
|
||||||
|
|
||||||
|
function pre {
|
||||||
|
rm -Rf /tmp/ipfs_1
|
||||||
|
eval "$IPFS" init;
|
||||||
|
check_failure_with_exit "pre" $?
|
||||||
|
cp ../config.test1.wo_journal /tmp/ipfs_1/config
|
||||||
|
}
|
||||||
|
|
||||||
|
function post {
|
||||||
|
rm -Rf /tmp/ipfs_1;
|
||||||
|
rm hello.bin;
|
||||||
|
rm hello2.bin;
|
||||||
|
}
|
||||||
|
|
||||||
|
function body {
|
||||||
|
create_binary_file 256;
|
||||||
|
eval "$IPFS" add hello.bin
|
||||||
|
check_failure_with_exit "add hello.bin" $?
|
||||||
|
|
||||||
|
#start the daemon
|
||||||
|
eval "../../main/ipfs --config /tmp/ipfs_1 daemon &"
|
||||||
|
daemon_id=$!
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
eval "$IPFS" cat QmX4zpwaE7CSgZZsULgoB3gXYC6hh7RN19bEfWxw7sL8Xx > hello2.bin
|
||||||
|
check_failure_with_exit "cat" $?
|
||||||
|
|
||||||
|
# file size should be 256
|
||||||
|
actualsize=$(wc -c < hello2.bin)
|
||||||
|
if [ $actualsize -ne 256 ]; then
|
||||||
|
echo '*** Failure *** file size incorrect'
|
||||||
|
fi
|
||||||
|
|
||||||
|
kill -9 $daemon_id
|
||||||
|
}
|
|
@ -1,5 +1,10 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#####
|
||||||
|
# global to keep track of failures
|
||||||
|
#####
|
||||||
|
failure_count=0
|
||||||
|
|
||||||
#####
|
#####
|
||||||
# Functions to help with test scripts
|
# Functions to help with test scripts
|
||||||
#####
|
#####
|
||||||
|
@ -16,9 +21,15 @@ function create_hello_world {
|
||||||
###
|
###
|
||||||
function create_binary_file {
|
function create_binary_file {
|
||||||
rm hello.bin
|
rm hello.bin
|
||||||
for byte in `seq 0 255`;
|
num_bytes=$1
|
||||||
|
if [ $num_bytes -eq 0 ]; then
|
||||||
|
num_bytes=255;
|
||||||
|
fi
|
||||||
|
let num_bytes--
|
||||||
|
for byte in `seq 0 $num_bytes`;
|
||||||
do
|
do
|
||||||
printf "\\$(printf "%o" $byte)" >> hello.bin
|
remainder=($byte % 255)
|
||||||
|
printf "\\$(printf "%o" $remainder)" >> hello.bin
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,4 +44,20 @@ function check_failure() {
|
||||||
if [ $RESULT -ne 0 ]; then
|
if [ $RESULT -ne 0 ]; then
|
||||||
echo "***Failure*** in $FUNC. The return value was $RESULT";
|
echo "***Failure*** in $FUNC. The return value was $RESULT";
|
||||||
fi
|
fi
|
||||||
|
return $RESULT
|
||||||
|
}
|
||||||
|
|
||||||
|
####
|
||||||
|
# Checks the return code and displays message if return code is not 0
|
||||||
|
# Param $1 name of function
|
||||||
|
# Param $2 return code
|
||||||
|
####
|
||||||
|
function check_failure_with_exit() {
|
||||||
|
FUNC=$1;
|
||||||
|
RESULT=$2;
|
||||||
|
if [ $RESULT -ne 0 ]; then
|
||||||
|
echo "***Failure*** in $FUNC. The return value was $RESULT";
|
||||||
|
exit $RESULT
|
||||||
|
fi
|
||||||
|
return $RESULT
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue