Add preliminary version of test library
authorMichal Sojka <sojkam1@fel.cvut.cz>
Sun, 28 Nov 2010 22:00:24 +0000 (23:00 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Sun, 28 Nov 2010 22:00:24 +0000 (23:00 +0100)
gw-tests/gw-nop.sh [new file with mode: 0755]
gw-tests/lib.sh [new file with mode: 0644]

diff --git a/gw-tests/gw-nop.sh b/gw-tests/gw-nop.sh
new file mode 100755 (executable)
index 0000000..acada91
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+. lib.sh
+
+
+
+test_end
diff --git a/gw-tests/lib.sh b/gw-tests/lib.sh
new file mode 100644 (file)
index 0000000..c27cd0d
--- /dev/null
@@ -0,0 +1,76 @@
+set -x
+set -e
+
+PATH=$PWD/../_compiled/bin/:$PATH
+
+error() {
+    echo $1 >&2
+    exit 1
+}
+
+sshgw() {
+    ssh root@192.168.2.3 "$@"
+}
+
+initgw() {
+    sshgw 'for i in 0 1; do ip link set can$i up type can bitrate 1000000; done'
+}
+
+plot() {
+#    for i in "${!PLOT_CMD[@]}"; do
+    local testname=`basename $0 .sh`
+    for i in 0; do
+       cmd=`p`                 # Get plot commands
+       cmd=$(echo "$cmd" | sed -e "/set title/ s/[\"']\(.*\)[\"']/\"\1\\\\n($(kvers), CPU\\\\\\\\@${clk}MHz)\"/")
+       if [ -z "$OPT_NO_X11" ]; then
+           echo "set terminal x11 enhanced; ${cmd}" | gnuplot -persist
+       fi
+       I=${i/0/}
+       echo 'set terminal postscript color eps enhanced size 6cm,4cm lw 1 "Times-Roman" 10;' \
+            'set lmargin 8;' \
+             "${cmd}" | gnuplot > ${testname}$I.eps
+       echo "set terminal postscript color eps enhanced;" \
+            "${cmd}" | gnuplot | epstopdf --filter > ${testname}$I.pdf
+       mkdir -p thumb
+       convert -density 30  -gamma 0.5 -quality 90 -type Palette -depth 8 ${testname}$I.pdf thumb/${testname}$I.png
+       convert -density 150 -gamma 0.7 -quality 90 -type Palette -depth 8 ${testname}$I.pdf ${testname}$I.png
+    done
+}
+
+create_dirs_and_links() {
+    local test=$1
+    local kver=$2
+    local clck=$3
+
+    local  d=results/by-kern/$kver/$clck/$test
+    mkdir -p $d
+    mkdir -p results/by-kern/$kver/$test # 1
+    mkdir -p results/by-test/$test/$kver # 2
+    mkdir -p results/by-test/$test/$clck # 3
+    mkdir -p results/by-clck/$clck/$kver # 4
+    mkdir -p results/by-clck/$clck/$test # 5
+    ln -sfT ../../../${d#results/} results/by-kern/$kver/$test/$clck # 1
+    ln -sfT ../../../${d#results/} results/by-test/$test/$kver/$clck # 2
+    ln -sfT ../../../${d#results/} results/by-test/$test/$clck/$kver # 3
+    ln -sfT ../../../${d#results/} results/by-clck/$clck/$kver/$test # 4
+    ln -sfT ../../../${d#results/} results/by-clck/$clck/$test/$kver # 5
+    echo $d
+}
+
+run() {
+    initgw
+}
+
+test_end() {
+    test_end_called=t
+    run
+}
+
+exit() {
+    if [[ ! "$test_end_called" ]]; then
+       test_end_called=t
+       error "bug in the test script: No test_end called"
+    fi
+}
+
+trap 'exit' EXIT