c-ipfs/test/scripts/test_helpers.sh

38 lines
646 B
Bash
Raw Normal View History

2017-09-27 12:40:55 +00:00
#!/bin/bash
#####
# Functions to help with test scripts
#####
####
# Create a text file "hello.txt" that contains "Hello, World!"
####
2017-09-27 11:16:18 +00:00
function create_hello_world {
echo 'Hello, World!' > hello.txt
}
2017-09-27 12:40:55 +00:00
2017-10-04 11:34:37 +00:00
####
# Create a binary file
###
function create_binary_file {
rm hello.bin
for byte in `seq 0 256`;
do
printf "\\$(printf "%o" 0x$byte)" >> hello.bin
done
}
2017-09-27 12:40:55 +00:00
####
# 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() {
FUNC=$1;
RESULT=$2;
if [ $RESULT -ne 0 ]; then
echo "***Failure*** in $FUNC. The return value was $RESULT";
fi
}