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
|
||||
|
||||
TEST_FILE=$1
|
||||
TEST_FILE=test_$1.sh
|
||||
|
||||
test_success=0
|
||||
|
||||
source ./$TEST_FILE
|
||||
|
||||
pre
|
||||
body
|
||||
post
|
||||
function do_it() {
|
||||
pre
|
||||
body
|
||||
post
|
||||
return $?
|
||||
}
|
||||
|
||||
do_it
|
||||
exit $test_success
|
||||
|
|
|
@ -1,9 +1,29 @@
|
|||
#!/bin/bash
|
||||
|
||||
./run_test.sh test_1.sh
|
||||
./run_test.sh test_2.sh
|
||||
./run_test.sh test_3.sh
|
||||
./run_test.sh test_4.sh
|
||||
./run_test.sh test_5.sh
|
||||
./run_test.sh test_6.sh
|
||||
./run_test.sh test_7.sh
|
||||
#source ./test_helpers.sh
|
||||
|
||||
rm testlog.txt
|
||||
|
||||
num_tests=9
|
||||
tests_passed=0
|
||||
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
|
||||
|
||||
####
|
||||
# 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 {
|
||||
rm -Rf /tmp/ipfs_1
|
||||
eval "$IPFS" init;
|
||||
check_failure "pre" $?
|
||||
check_failure_with_exit "pre" $?
|
||||
cp ../config.test1.wo_journal /tmp/ipfs_1/config
|
||||
}
|
||||
|
||||
|
@ -23,22 +23,23 @@ function post {
|
|||
}
|
||||
|
||||
function body {
|
||||
create_binary_file;
|
||||
create_binary_file 512;
|
||||
eval "$IPFS" add hello.bin
|
||||
check_failure "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 "cat" $?
|
||||
eval "$IPFS" cat QmVGA3bXDJ41xoT621xQNzQgtBMQHj2AYxaunLBJtSoNgg > hello2.bin
|
||||
check_failure_with_exit "cat" $?
|
||||
|
||||
# file size should be 256
|
||||
# file size should be 512
|
||||
actualsize=$(wc -c < hello2.bin)
|
||||
if [ $actualsize -ne 256 ]; then
|
||||
if [ $actualsize -ne 512 ]; then
|
||||
echo '*** Failure *** file size incorrect'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
kill -9 $daemon_id
|
||||
|
|
|
@ -7,7 +7,7 @@ IPFS="../../main/ipfs --config /tmp/ipfs_1"
|
|||
function pre {
|
||||
post
|
||||
eval "$IPFS" init;
|
||||
check_failure "pre" $?
|
||||
check_failure_with_exit "pre" $?
|
||||
}
|
||||
|
||||
function post {
|
||||
|
@ -18,10 +18,10 @@ function post {
|
|||
function body {
|
||||
create_hello_world;
|
||||
eval "$IPFS" add hello.txt
|
||||
check_failure "add hello.txt" $?
|
||||
check_failure_with_exit "add hello.txt" $?
|
||||
|
||||
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 {
|
||||
post
|
||||
eval "$IPFS" init;
|
||||
check_failure "pre" $?
|
||||
check_failure_with_exit "pre" $?
|
||||
}
|
||||
|
||||
function post {
|
||||
|
@ -23,7 +23,7 @@ function post {
|
|||
function body {
|
||||
create_hello_world;
|
||||
eval "$IPFS" add hello.txt
|
||||
check_failure "add hello.txt" $?
|
||||
check_failure_with_exit "add hello.txt" $?
|
||||
|
||||
#start the daemon
|
||||
eval "../../main/ipfs --config /tmp/ipfs_1 daemon &"
|
||||
|
@ -31,7 +31,7 @@ function body {
|
|||
sleep 5
|
||||
|
||||
eval "$IPFS" cat QmYAXgX8ARiriupMQsbGXtKdDyGzWry1YV3sycKw1qqmgH
|
||||
check_failure "cat hello.txt" $?
|
||||
check_failure_with_exit "cat hello.txt" $?
|
||||
|
||||
kill -9 $daemon_id
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ IPFS="../../main/ipfs --config /tmp/ipfs_1"
|
|||
function pre {
|
||||
post
|
||||
eval "$IPFS" init;
|
||||
check_failure "pre" $?
|
||||
check_failure_with_exit "pre" $?
|
||||
cp ../config.test1.wo_journal /tmp/ipfs_1/config
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ function post {
|
|||
function body {
|
||||
create_hello_world;
|
||||
eval "$IPFS" add hello.txt
|
||||
check_failure "add hello.txt" $?
|
||||
check_failure_with_exit "add hello.txt" $?
|
||||
|
||||
#start the daemon
|
||||
eval "../../main/ipfs --config /tmp/ipfs_1 daemon &"
|
||||
|
@ -32,10 +32,10 @@ function body {
|
|||
sleep 5
|
||||
|
||||
eval "$IPFS" name publish QmYAXgX8ARiriupMQsbGXtKdDyGzWry1YV3sycKw1qqmgH
|
||||
check_failure "name publish" $?
|
||||
check_failure_with_exit "name publish" $?
|
||||
|
||||
eval "$IPFS" name resolve /ipns/QmZVoAZGFfinB7MQQiDzB84kWaDPQ95GLuXdemJFM2r9b4
|
||||
check_failure "name resolve" $?
|
||||
check_failure_with_exit "name resolve" $?
|
||||
|
||||
kill -9 $daemon_id
|
||||
}
|
||||
|
|
|
@ -12,11 +12,11 @@ IPFS2="../../main/ipfs --config /tmp/ipfs_2"
|
|||
function pre {
|
||||
post
|
||||
eval "$IPFS1" init;
|
||||
check_failure "pre" $?
|
||||
check_failure_with_exit "pre" $?
|
||||
cp ../config.test1.wo_journal /tmp/ipfs_1/config
|
||||
|
||||
eval "$IPFS2" init;
|
||||
check_failure "pre ipfs2" $?
|
||||
check_failure_with_exit "pre ipfs2" $?
|
||||
cp ../config.test2.wo_journal /tmp/ipfs_2/config
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ function post {
|
|||
function body {
|
||||
create_hello_world;
|
||||
eval "$IPFS1" add hello.txt
|
||||
check_failure "add hello.txt" $?
|
||||
check_failure_with_exit "add hello.txt" $?
|
||||
|
||||
#start the daemons
|
||||
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
|
||||
eval "$IPFS2" cat QmYAXgX8ARiriupMQsbGXtKdDyGzWry1YV3sycKw1qqmgH
|
||||
check_failure "cat" $?
|
||||
check_failure_with_exit "cat" $?
|
||||
|
||||
kill -9 $daemon_id_1
|
||||
kill -9 $daemon_id_2
|
||||
|
|
|
@ -12,7 +12,7 @@ IPFS="../../main/ipfs --config /tmp/ipfs_1"
|
|||
function pre {
|
||||
post
|
||||
eval "$IPFS" init;
|
||||
check_failure "pre" $?
|
||||
check_failure_with_exit "pre" $?
|
||||
cp ../config.test1.wo_journal /tmp/ipfs_1/config
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ function post {
|
|||
function body {
|
||||
create_hello_world;
|
||||
eval "$IPFS" add hello.txt
|
||||
check_failure "add hello.txt" $?
|
||||
check_failure_with_exit "add hello.txt" $?
|
||||
|
||||
#start the daemon
|
||||
eval "../../main/ipfs --config /tmp/ipfs_1 daemon &"
|
||||
|
@ -32,7 +32,7 @@ function body {
|
|||
sleep 5
|
||||
|
||||
eval "$IPFS" name publish QmYAXgX8ARiriupMQsbGXtKdDyGzWry1YV3sycKw1qqmgH
|
||||
check_failure "name publish" $?
|
||||
check_failure_with_exit "name publish" $?
|
||||
|
||||
kill -9 $daemon_id
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ IPFS="../../main/ipfs --config /tmp/ipfs_1"
|
|||
function pre {
|
||||
rm -Rf /tmp/ipfs_1
|
||||
eval "$IPFS" init;
|
||||
check_failure "pre" $?
|
||||
check_failure_with_exit "pre" $?
|
||||
cp ../config.test1.wo_journal /tmp/ipfs_1/config
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ function post {
|
|||
}
|
||||
|
||||
function body {
|
||||
create_binary_file;
|
||||
create_binary_file 256;
|
||||
|
||||
#start the daemon
|
||||
eval "../../main/ipfs --config /tmp/ipfs_1 daemon &"
|
||||
|
@ -32,12 +32,12 @@ function body {
|
|||
|
||||
# add file
|
||||
eval "$IPFS" add hello.bin
|
||||
check_failure "add hello.bin" $?
|
||||
check_failure_with_exit "add hello.bin" $?
|
||||
sleep 5
|
||||
|
||||
# retrieve file
|
||||
eval "$IPFS" cat QmX4zpwaE7CSgZZsULgoB3gXYC6hh7RN19bEfWxw7sL8Xx > hello2.bin
|
||||
check_failure "cat" $?
|
||||
check_failure_with_exit "cat" $?
|
||||
|
||||
# file size should be 256
|
||||
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
|
||||
|
||||
#####
|
||||
# global to keep track of failures
|
||||
#####
|
||||
failure_count=0
|
||||
|
||||
#####
|
||||
# Functions to help with test scripts
|
||||
#####
|
||||
|
@ -16,9 +21,15 @@ function create_hello_world {
|
|||
###
|
||||
function create_binary_file {
|
||||
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
|
||||
printf "\\$(printf "%o" $byte)" >> hello.bin
|
||||
remainder=($byte % 255)
|
||||
printf "\\$(printf "%o" $remainder)" >> hello.bin
|
||||
done
|
||||
}
|
||||
|
||||
|
@ -33,4 +44,20 @@ function check_failure() {
|
|||
if [ $RESULT -ne 0 ]; then
|
||||
echo "***Failure*** in $FUNC. The return value was $RESULT";
|
||||
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