aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Rstuff/.RDatabin0 -> 327 bytes
-rw-r--r--test/Rstuff/.Rhistory2
-rw-r--r--test/core_script.sh101
-rw-r--r--test/purge.sh9
-rw-r--r--test/test.sh9
5 files changed, 121 insertions, 0 deletions
diff --git a/test/Rstuff/.RData b/test/Rstuff/.RData
new file mode 100644
index 0000000..19644e0
--- /dev/null
+++ b/test/Rstuff/.RData
Binary files differ
diff --git a/test/Rstuff/.Rhistory b/test/Rstuff/.Rhistory
new file mode 100644
index 0000000..17b1a79
--- /dev/null
+++ b/test/Rstuff/.Rhistory
@@ -0,0 +1,2 @@
+source("[10_1_32].R")
+q()
diff --git a/test/core_script.sh b/test/core_script.sh
new file mode 100644
index 0000000..886b4aa
--- /dev/null
+++ b/test/core_script.sh
@@ -0,0 +1,101 @@
+#!/bin/sh
+
+MATRIX_SIZE=100
+TO_THREADS=4
+SOURCE_DIR=..
+TEST_DIR=.
+FROM_THREADS=1
+ANSW="g"
+
+#1-st argument is the size of the matrix. If ommited then it's 100
+[ $1 ] && [ $1 -ge 0 ] && MATRIX_SIZE=$1
+[ $2 ] && [ $2 -ge 1 ] && FROM_THREADS=$2
+[ $3 ] && [ $3 -ge $FROM_THREADS ] && TO_THREADS=$3
+
+nxn="$MATRIX_SIZE\\$MATRIX_SIZE"
+
+#make the executable
+make -C $SOURCE_DIR || (echo "ERROR: COULD NOT MAKE THE EXECUTABLE" ; exit -1) || exit
+
+#move it to testing grounds
+mv $SOURCE_DIR/main.exe $TEST_DIR/executables/main.exe
+
+#along the heavy line generator
+mv $SOURCE_DIR/make_heavy.exe $TEST_DIR/executables/make_heavy.exe
+
+#make matrix, dump it in a file and then execute over one thread
+if [ -e $TEST_DIR/inputs/matrix$nxn ]
+then
+ while [ $ANSW != "y" ] && [ $ANSW != "n" ]
+ do
+ echo "Testing on a matrix size that has been tested already. Run tests again[y/n]?"
+ read ANSW
+ done
+ [ $ANSW = "n" ] && exit
+ ANSW="g"
+ while [ $ANSW != "y" ] && [ $ANSW != "n" ]
+ do
+ echo "Generate new matrix?[y/n]?"
+ read ANSW
+ done
+
+ echo "Testing on $FROM_THREADS thread(s)"
+ [ $ANSW = "n" ] && $TEST_DIR/executables/main.exe -t $FROM_THREADS -i $TEST_DIR/inputs/matrix$nxn -o $TEST_DIR/outputs/output$nxn > $TEST_DIR/times/normal/[$nxn]$FROM_THREADS.time
+ [ $ANSW = "y" ] && $TEST_DIR/executables/main.exe -t $FROM_THREADS -dm $TEST_DIR/inputs/matrix$nxn -o $TEST_DIR/outputs/output$nxn -n $MATRIX_SIZE > $TEST_DIR/times/normal/[$nxn]$FROM_THREADS.time
+else
+ echo "Testing on $FROM_THREADS thread(s)"
+ $TEST_DIR/executables/main.exe -t $FROM_THREADS -dm $TEST_DIR/inputs/matrix$nxn -o $TEST_DIR/outputs/output$nxn -n $MATRIX_SIZE > $TEST_DIR/times/normal/[$nxn]$FROM_THREADS.time
+fi
+
+cat $TEST_DIR/times/normal/[$nxn]$FROM_THREADS.time | tail -n 1
+
+#execute over 2 or more threads using the dumped matrix (reusing it so we don't have misleading results)
+i=$((FROM_THREADS+1))
+while [ $i -le $TO_THREADS ]
+do
+ echo "Testing on $i threads"
+ $TEST_DIR/executables/main.exe -t $i -i $TEST_DIR/inputs/matrix$nxn -o $TEST_DIR/outputs/temp_output$nxn > $TEST_DIR/times/normal/[$nxn]$i.time
+
+ #check for consistency between outputs
+ [ $(cat $TEST_DIR/outputs/output$nxn) != $(cat $TEST_DIR/outputs/temp_output$nxn) ] && echo "ERROR OUTPUTS DO NOT MATCH" && exit
+
+ rm $TEST_DIR/outputs/temp_output$nxn
+
+ #print time it took for $i threads to do the task
+ cat $TEST_DIR/times/normal/[$nxn]$i.time | tail -n 1
+
+ i=$((i+1))
+done
+
+#test over a matrix with a heavy row (This should be the worst case for the algorithm)
+#make a matrix with a really heavy (MAXTHREADS - 1 to last ) row
+echo "$MATRIX_SIZE $((MATRIX_SIZE - MAX_THREADS+1))" | $TEST_DIR/executables/make_heavy.exe > $TEST_DIR/inputs/matrix$nxn.heavy
+
+#do not dump the matrix this time
+#heavy matrices are very alike - do not prompt to keep matrice
+
+echo "[HEAVY]Testing on $FROM_THREADS thread(s)"
+$TEST_DIR/executables/main.exe -t $FROM_THREADS -i $TEST_DIR/inputs/matrix$nxn.heavy -o $TEST_DIR/outputs/output$nxn.heavy > $TEST_DIR/times/heavy/[$nxn]$FROM_THREADS.time
+
+cat $TEST_DIR/times/heavy/[$nxn]$FROM_THREADS.time | tail -n 1
+
+#execute over 2 or more threads using the dumped matrix (reusing it so we don't have misleading results)
+i=$((FROM_THREADS+1))
+while [ $i -le $TO_THREADS ]
+do
+ echo "[HEAVY]Testing on $i threads"
+ $TEST_DIR/executables/main.exe -t $i -i $TEST_DIR/inputs/matrix$nxn.heavy -o $TEST_DIR/outputs/temp_output$nxn.heavy > $TEST_DIR/times/heavy/[$nxn]$i.time
+
+ #check for consistency between outputs
+ [ $(cat $TEST_DIR/outputs/output$nxn.heavy) != $(cat $TEST_DIR/outputs/temp_output$nxn.heavy) ] && echo "ERROR OUTPUTS DO NOT MATCH" && exit
+
+ rm $TEST_DIR/outputs/temp_output$nxn.heavy
+
+ #print time it took for $i threads to do the task
+ cat $TEST_DIR/times/heavy/[$nxn]$i.time | tail -n 1
+
+ i=$((i+1))
+done
+
+exit
+
diff --git a/test/purge.sh b/test/purge.sh
new file mode 100644
index 0000000..ce670c9
--- /dev/null
+++ b/test/purge.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+TEST_DIR=.
+rm $TEST_DIR/executables/*
+rm $TEST_DIR/logs/*
+rm $TEST_DIR/times/heavy/*
+rm $TEST_DIR/times/normal/*
+rm $TEST_DIR/inputs/*
+rm $TEST_DIR/outputs/*
+rm $TEST_DIR/Rstuff/*
diff --git a/test/test.sh b/test/test.sh
new file mode 100644
index 0000000..62d6edf
--- /dev/null
+++ b/test/test.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+TEST_DIR=.
+JID=$(echo $@ | sed 's/ /_/g')
+
+touch "$TEST_DIR/logs/log[$JID]"
+sh ./core_script.sh $@ | tee "$TEST_DIR/logs/log[$JID]"
+tail ./times/normal/* -q -n 1 | cut -f 2 -d " " | awk 'BEGIN{printf "a=c(";cnt=1}{if(cnt!=1){printf ","}printf "%s",$1; ++cnt}END{print ")"}' > $TEST_DIR/Rstuff/[$JID].R
+echo "plot(1:length(a),col='red',type='l');points(1:length(a),col='red');points(a/a[1],col='green');lines(a/a[1],col='green');" >> $TEST_DIR/Rstuff/[$JID].R
+