summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichael Buesch <m@bues.ch>2012-04-06 22:19:56 +0200
committerMichael Buesch <m@bues.ch>2012-04-06 22:19:56 +0200
commit06de5a43527c12b41eebf2f96f85febaf64668b0 (patch)
treeb7ae8c9abda09fbd06c1512bdcf5a66a189996cd /tests
parent889ae3e0f47de1bf4ba9e3ef13e139e4f18b5143 (diff)
downloadtoprammer-06de5a43527c12b41eebf2f96f85febaf64668b0.tar.xz
toprammer-06de5a43527c12b41eebf2f96f85febaf64668b0.zip
Port testsuite to dash
Signed-off-by: Michael Buesch <m@bues.ch>
Diffstat (limited to 'tests')
-rw-r--r--tests/defaults.test8
-rw-r--r--tests/generic/001-basic.test4
-rw-r--r--tests/generic/002-toprammer-layout.test4
-rwxr-xr-xtests/run-tests.sh93
-rw-r--r--tests/top2049/74hc4094dip16.test6
-rw-r--r--tests/top2049/at89c2051dip20.test6
-rw-r--r--tests/top2049/atmega32dip40.test6
-rw-r--r--tests/top2049/atmega88dip28.test6
-rw-r--r--tests/top2049/atmega8dip28.test6
-rw-r--r--tests/top2049/attiny13dip8.test6
-rw-r--r--tests/top2049/hm62256dip28.test6
-rw-r--r--tests/top2049/m24c08.test6
-rw-r--r--tests/top2049/w29ee011dip32.test6
13 files changed, 79 insertions, 84 deletions
diff --git a/tests/defaults.test b/tests/defaults.test
index 33765d6..e26cb0c 100644
--- a/tests/defaults.test
+++ b/tests/defaults.test
@@ -1,16 +1,16 @@
-#!/bin/bash
+#!/bin/sh
-function test_init
+test_init()
{
true
}
-function test_exit
+test_exit()
{
true
}
-function test_run
+test_run()
{
die "test_run unimplemented"
}
diff --git a/tests/generic/001-basic.test b/tests/generic/001-basic.test
index fff9965..3654853 100644
--- a/tests/generic/001-basic.test
+++ b/tests/generic/001-basic.test
@@ -1,6 +1,6 @@
-#!/bin/bash
+#!/bin/sh
-function test_run
+test_run()
{
# Run some very basic tests
toprammer -h
diff --git a/tests/generic/002-toprammer-layout.test b/tests/generic/002-toprammer-layout.test
index 188ad89..9edaaa1 100644
--- a/tests/generic/002-toprammer-layout.test
+++ b/tests/generic/002-toprammer-layout.test
@@ -1,6 +1,6 @@
-#!/bin/bash
+#!/bin/sh
-function test_run
+test_run()
{
# Some basic toprammer-layout tests
toprammer_layout_silent -h
diff --git a/tests/run-tests.sh b/tests/run-tests.sh
index d186162..bf4debc 100755
--- a/tests/run-tests.sh
+++ b/tests/run-tests.sh
@@ -1,16 +1,16 @@
-#!/bin/bash
+#!/bin/sh
# Toprammer regression tests
-# Copyright (c) 2010 Michael Buesch <m@bues.ch>
+# Copyright (c) 2010-2012 Michael Buesch <m@bues.ch>
basedir="$(dirname "$0")"
-[ "${basedir:0:1}" = "/" ] || basedir="$PWD/$basedir"
+[ "$(echo -n "$basedir" | cut -c1)" = "/" ] || basedir="$PWD/$basedir"
tmpdir="/tmp/toprammer-test-$$"
cleanup_enabled=1
-function cleanup
+cleanup()
{
[ $cleanup_enabled -ne 0 ] || return
echo "Cleanup..."
@@ -19,96 +19,94 @@ function cleanup
trap cleanup INT TERM
-function info
+info()
{
- echo "$current_test: $@"
+ echo "$current_test: $*"
}
-function warning
+warning()
{
- echo "WARNING $current_test: $@"
+ echo "WARNING $current_test: $*"
}
-function error
+error()
{
- echo "ERROR $current_test: $@"
+ echo "ERROR $current_test: $*"
}
-function abort
+abort()
{
cleanup
exit 1
}
-function die
+die()
{
- error $@
+ error "$@"
cleanup
exit 1
}
-function toprammer
+toprammer()
{
- local args="$@"
local logfile="$tmpdir/toprammer.log"
+ local args=
[ -n "$current_chipid" ] && args="--chip-id $current_chipid $args"
args="-B -I bin -O bin $args"
- echo " toprammer $args"
+ echo " toprammer $args $*"
cd "$basedir/.." || die "Failed to chdir"
if [ $verbose -eq 0 ]; then
- ./toprammer $args >$logfile 2>&1
+ ./toprammer $args "$@" >$logfile 2>&1
if [ $? -ne 0 ]; then
[ -r "$logfile" ] && cat "$logfile"
- die "toprammer $args <<<FAILED>>>"
+ die "toprammer $args $* <<<FAILED>>>"
fi
else
- ./toprammer $args -V2
- [ $? -eq 0 ] || die "toprammer $args <<<FAILED>>>"
+ ./toprammer $args "$@" -V2
+ [ $? -eq 0 ] || die "toprammer $args $* <<<FAILED>>>"
fi
}
-function toprammer_layout_silent
+toprammer_layout_silent()
{
- local args="$@"
local logfile="$tmpdir/toprammer-layout.log"
- echo " toprammer-layout $args"
+ echo " toprammer-layout $*"
cd "$basedir/.." || die "Failed to chdir"
- ./toprammer-layout $args >$logfile 2>&1
+ ./toprammer-layout "$@" >$logfile 2>&1
if [ $? -ne 0 ]; then
[ -r "$logfile" ] && cat "$logfile"
- die "toprammer-layout $args <<<FAILED>>>"
+ die "toprammer-layout $* <<<FAILED>>>"
fi
}
-function toprammer_layout
+toprammer_layout()
{
- local args="$@"
cd "$basedir/.." || die "Failed to chdir"
- ./toprammer-layout $args
- [ $? -eq 0 ] || die "toprammer-layout $args <<<FAILED>>>"
+ ./toprammer-layout "$@"
+ [ $? -eq 0 ] || die "toprammer-layout $* <<<FAILED>>>"
}
-function ask
+ask()
{
- read -n1 -p "$@ " ok
+ read -p "$* " ok
echo
[ "$ok" = "y" -o "$ok" = "Y" -o \
"$ok" = "1" -o "$ok" = "" ] && return 0
return 1
}
-function request
+request()
{
- read -s -n1 -p "$@" res
+ read -p "$*" res
echo
[ "$res" = "a" ] && abort
[ "$res" = "x" ] && return 1
return 0
}
-function request_DUT # $1=DUT-name
+request_DUT() # $1=DUT-name
{
local dut="$1"
@@ -120,12 +118,12 @@ function request_DUT # $1=DUT-name
request "Please insert a $dut into the ZIF socket (x to skip; a to abort)..."
}
-function request_TOP # $1=TOPxxxx
+request_TOP() # $1=TOPxxxx
{
- request "Please connect the $@ programmer (x to skip; a to abort)..."
+ request "Please connect the $* programmer (x to skip; a to abort)..."
}
-function create_random_file # $1=file $2=bs $3=count
+create_random_file() # $1=file $2=bs $3=count
{
dd if=/dev/urandom of="$1" bs="$2" count="$3" >/dev/null 2>&1
[ $? -eq 0 ] || die "Failed to create $1"
@@ -133,7 +131,7 @@ function create_random_file # $1=file $2=bs $3=count
[ $? -eq 0 ] || die "Failed to set $1 read-only"
}
-function compare_files # $1=file1 $2=file2
+compare_files() # $1=file1 $2=file2
{
[ -r "$1" -a -r "$2" ] || return 1
sum1="$(sha1sum "$1" | cut -d' ' -f1)"
@@ -141,13 +139,13 @@ function compare_files # $1=file1 $2=file2
[ "$sum1" = "$sum2" ]
}
-function compare_file_to_hex # $1=file $2=hex_string
+compare_file_to_hex() # $1=file $2=hex_string
{
local filehex="$(hexdump -v -e '/1 "%02X"' $1)"
[ "$filehex" = "$2" ]
}
-function usage
+usage()
{
echo "Usage: run-tests.sh <OPTIONS> <SCRIPTPATH>"
echo
@@ -163,7 +161,7 @@ function usage
}
# Parse commandline
-nr_scriptpaths=0
+scriptpaths=
verbose=0
while [ $# -gt 0 ]; do
if [ "$1" = "-h" -o "$1" = "--help" ]; then
@@ -175,8 +173,7 @@ while [ $# -gt 0 ]; do
shift
continue
fi
- scriptpaths[nr_scriptpaths]="$1"
- let nr_scriptpaths=nr_scriptpaths+1
+ scriptpaths="$scriptpaths $1"
shift
done
@@ -224,7 +221,7 @@ testfile_128k="$tmpdir/testfile_128k"
create_random_file "$testfile_128k" 4096 32
-function do_run_test # $1=device, $2=testscript
+do_run_test() # $1=device, $2=testscript
{
current_device="$1"
current_test="$1/$2"
@@ -261,11 +258,11 @@ function do_run_test # $1=device, $2=testscript
current_chipid=
}
-if [ $nr_scriptpaths -eq 0 ]; then
+if [ -z "$scriptpaths" ]; then
# Run all scripts
for device in $(ls "$basedir"); do
[ -d "$basedir/$device" ] || continue
- [ "$device" == "generic" ] || request_TOP "$device" || continue
+ [ "$device" = "generic" ] || request_TOP "$device" || continue
for testscript in $(ls "$basedir/$device"); do
do_run_test "$device" "$testscript"
@@ -273,9 +270,7 @@ if [ $nr_scriptpaths -eq 0 ]; then
done
else
# Only run the specified tests
- let end=nr_scriptpaths-1
- for i in $(seq 0 $end); do
- scriptpath="${scriptpaths[i]}"
+ for scriptpath in $scriptpaths; do
device="$(echo "$scriptpath" | cut -d'/' -f1)"
testscript="$(echo "$scriptpath" | cut -d'/' -f2)"
[ -d "$basedir/$device" -a -f "$basedir/$device/$testscript" ] || \
diff --git a/tests/top2049/74hc4094dip16.test b/tests/top2049/74hc4094dip16.test
index 0f45c74..6d5a5e8 100644
--- a/tests/top2049/74hc4094dip16.test
+++ b/tests/top2049/74hc4094dip16.test
@@ -1,12 +1,12 @@
-#!/bin/bash
+#!/bin/sh
-function test_init
+test_init()
{
request_DUT "74hc4094dip16" || return 1
return 0
}
-function test_run
+test_run()
{
toprammer --test
}
diff --git a/tests/top2049/at89c2051dip20.test b/tests/top2049/at89c2051dip20.test
index 40fe8fd..1730869 100644
--- a/tests/top2049/at89c2051dip20.test
+++ b/tests/top2049/at89c2051dip20.test
@@ -1,12 +1,12 @@
-#!/bin/bash
+#!/bin/sh
-function test_init
+test_init()
{
request_DUT "at89c2051dip20" || return 1
return 0
}
-function test_run
+test_run()
{
# Check signature
toprammer --read-sig "$tmpfile"
diff --git a/tests/top2049/atmega32dip40.test b/tests/top2049/atmega32dip40.test
index e7c7255..a346729 100644
--- a/tests/top2049/atmega32dip40.test
+++ b/tests/top2049/atmega32dip40.test
@@ -1,12 +1,12 @@
-#!/bin/bash
+#!/bin/sh
-function test_init
+test_init()
{
request_DUT "atmega32dip40" || return 1
return 0
}
-function test_run
+test_run()
{
# Check signature
toprammer --read-sig "$tmpfile"
diff --git a/tests/top2049/atmega88dip28.test b/tests/top2049/atmega88dip28.test
index 2e0ca8f..6d904c1 100644
--- a/tests/top2049/atmega88dip28.test
+++ b/tests/top2049/atmega88dip28.test
@@ -1,12 +1,12 @@
-#!/bin/bash
+#!/bin/sh
-function test_init
+test_init()
{
request_DUT "atmega88dip28" || return 1
return 0
}
-function test_run
+test_run()
{
# Check signature
toprammer --read-sig "$tmpfile"
diff --git a/tests/top2049/atmega8dip28.test b/tests/top2049/atmega8dip28.test
index 32133b7..5d5ec19 100644
--- a/tests/top2049/atmega8dip28.test
+++ b/tests/top2049/atmega8dip28.test
@@ -1,12 +1,12 @@
-#!/bin/bash
+#!/bin/sh
-function test_init
+test_init()
{
request_DUT "atmega8dip28" || return 1
return 0
}
-function test_run
+test_run()
{
# Check signature
toprammer --read-sig "$tmpfile"
diff --git a/tests/top2049/attiny13dip8.test b/tests/top2049/attiny13dip8.test
index 4411bb9..15060cc 100644
--- a/tests/top2049/attiny13dip8.test
+++ b/tests/top2049/attiny13dip8.test
@@ -1,12 +1,12 @@
-#!/bin/bash
+#!/bin/sh
-function test_init
+test_init()
{
request_DUT "attiny13dip8" || return 1
return 0
}
-function test_run
+test_run()
{
# Check signature
toprammer --read-sig "$tmpfile"
diff --git a/tests/top2049/hm62256dip28.test b/tests/top2049/hm62256dip28.test
index 06c1354..0904711 100644
--- a/tests/top2049/hm62256dip28.test
+++ b/tests/top2049/hm62256dip28.test
@@ -1,12 +1,12 @@
-#!/bin/bash
+#!/bin/sh
-function test_init
+test_init()
{
request_DUT "hm62256dip28" || return 1
return 0
}
-function test_run
+test_run()
{
toprammer --test
}
diff --git a/tests/top2049/m24c08.test b/tests/top2049/m24c08.test
index 89c1b7f..098c922 100644
--- a/tests/top2049/m24c08.test
+++ b/tests/top2049/m24c08.test
@@ -1,12 +1,12 @@
-#!/bin/bash
+#!/bin/sh
-function test_init
+test_init()
{
request_DUT "m24c08dip8" || return 1
return 0
}
-function test_run
+test_run()
{
toprammer --write-eeprom "$testfile_1k"
toprammer --read-eeprom "$tmpfile"
diff --git a/tests/top2049/w29ee011dip32.test b/tests/top2049/w29ee011dip32.test
index ad8a619..a0d627c 100644
--- a/tests/top2049/w29ee011dip32.test
+++ b/tests/top2049/w29ee011dip32.test
@@ -1,12 +1,12 @@
-#!/bin/bash
+#!/bin/sh
-function test_init
+test_init()
{
request_DUT "w29ee011dip32" || return 1
return 0
}
-function test_run
+test_run()
{
toprammer --erase
bues.ch cgit interface