3 bp=`basename $0 | sed s/^test_//`
4 in="$BP_DIR/bp_test/in/$bp.in"
5 out="$BP_DIR/bp_test/out/$bp.out"
7 tmp_dir="$BP_TMP/test_tmp"
8 log_file="$BP_TMP/$USER.test.log"
10 # Function to run a given command (verbose).
15 msg="${command/$BP_DIR/\$BP_DIR}"
16 msg="${msg//$BP_TMP/\$BP_TMP}"
18 echo -n "Testing $msg ... "
19 eval $command > /dev/null 2>&1
22 # Function to run a given command (quiet).
27 eval $command > /dev/null 2>&1
30 # Function to assert no difference between
32 function assert_no_diff
37 if [ ! -f $src ]; then
43 if [ ! -f $dst ]; then
49 local diff=`diff -q $src $dst`
51 if [ "$diff" != "" ]; then
60 # Function to assert no difference between the content
61 # of two given direcories (recursive).
62 function assert_no_diff_dir
67 src_cksum=`find $src_dir -type f | xargs cat | cksum`
68 dst_cksum=`find $dst_dir -type f | xargs cat | cksum`
70 if [ "$src_cksum" == "$dst_cksum" ]; then
79 # Function to assert that all given files do exists.
80 function assert_files_exists
85 if [ ! -f $arg ]; then
90 if [ $error = 1 ]; then
99 # Function to output a given message to the log file.
104 echo "$msg" >> $log_file
107 # Function that renders a given message in ASCII green.
112 echo -e "\033[32;38m$msg\033[0m"
115 # Function that renders a given message in ASCII yellow.
120 echo -e "\033[33;38m$msg\033[0m"
123 # Function that renders a given message in ASCII red.
128 echo -e "\033[31;38m$msg\033[0m"
131 # Function to clean the temporary file.
134 if [ -f "$tmp" ]; then
139 # Function to test if the required version of Perl is installed.
142 echo -n "Testing Perl version ... "
144 if error=$( perl -e 'use 5.8.0;' 2>&1 ); then
148 echo $error | sed "s/, stopped.*//"
154 # Function to test if a given Perl module is installed.
155 function test_perl_module
159 echo -n "Testing required Perl module - \"$module\": "
161 if ! error=$( perl -M$module -e '' 2>&1 > /dev/null ); then
163 echo " Try: perl -MCPAN -e 'install $module'"
171 # Function to test if the required version of Ruby is installed.
174 echo -n "Testing Ruby version ... "
176 if error=$( ruby -e 'raise "Ruby version 1.9 required--this is only #{RUBY_VERSION}" if RUBY_VERSION < "1.9"' 2>&1 ); then
180 echo $error | sed "s/.*: //"
186 # Function to test if a given Ruby gem is installed.
187 function test_ruby_gem
191 echo -n "Testing required Ruby gem - \"$gem\": "
193 if error=$( gem list --local | grep $gem ); then
198 echo " Try: gem install $gem"
203 # Function to test is a given auxillary program is in $PATH.
204 function test_aux_program
208 echo -n "Testing auxiliary program - \"$program\": "
210 if command -v $program >/dev/null; then
214 echo_yellow "WARNING"