2011-04-20 07:29:11 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
DIV1=------------------------------------------------------------------------
|
|
|
|
DIV2=========================================================================
|
|
|
|
|
|
|
|
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
echo "usage: $0 ref_dev test_dev" 1>&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[ "$2" -a -z "$3" ] || usage
|
|
|
|
REF=$1
|
|
|
|
# DUT = Device Under Test
|
|
|
|
DUT=$2
|
|
|
|
LOG=_log
|
|
|
|
>$LOG
|
|
|
|
|
2011-05-31 09:30:57 +03:00
|
|
|
LIVE=
|
|
|
|
|
2011-05-21 17:08:46 +03:00
|
|
|
if [ ${REF#net:} = $REF ]; then
|
|
|
|
REF_EXEC=
|
|
|
|
else
|
|
|
|
REF_EXEC="ssh `echo $REF | sed 's/^net://;s/,.*$//'`"
|
|
|
|
fi
|
|
|
|
|
2011-04-20 07:29:11 +03:00
|
|
|
if [ ${DUT#net:} = $DUT ]; then
|
|
|
|
LOCAL_EXEC=
|
|
|
|
LOCAL_DUT=$DUT
|
|
|
|
else
|
|
|
|
LOCAL_EXEC="ssh `echo $DUT | sed 's/^net://;s/,.*$//'`"
|
2011-04-20 15:00:28 +03:00
|
|
|
LOCAL_DUT=`atrf-id -d $DUT -s -s`
|
2011-04-20 07:29:11 +03:00
|
|
|
fi
|
|
|
|
|
2011-04-20 14:13:27 +03:00
|
|
|
|
|
|
|
##### Test setup ############################################################
|
|
|
|
|
|
|
|
|
2011-04-20 07:29:11 +03:00
|
|
|
step()
|
|
|
|
{
|
|
|
|
echo -n " .... $1"
|
|
|
|
step=$1
|
|
|
|
cmd=
|
|
|
|
>_out
|
|
|
|
echo $DIV2 >>$LOG
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-20 14:13:27 +03:00
|
|
|
##### Test result ###########################################################
|
|
|
|
|
|
|
|
|
2011-04-20 07:29:11 +03:00
|
|
|
finish()
|
|
|
|
{
|
|
|
|
echo "$cmd" >>$LOG
|
|
|
|
echo | sed "c$DIV1" >>$LOG
|
|
|
|
cat _out >>$LOG
|
|
|
|
sed "1i$DIV1" >>$LOG
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pass()
|
|
|
|
{
|
|
|
|
echo '\r\033[42;30m PASS \033[0m '
|
|
|
|
echo "$step: PASS" >>$LOG
|
|
|
|
finish </dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fail()
|
|
|
|
{
|
|
|
|
echo '\r\033[41;37m FAIL \033[0m '
|
|
|
|
echo "$step: FAIL" >>$LOG
|
|
|
|
finish
|
|
|
|
#
|
|
|
|
# to do: allow looping back
|
|
|
|
#
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
todo()
|
|
|
|
{
|
|
|
|
echo '\r\033[43;30m TODO \033[0m '
|
|
|
|
echo "$step: TODO" >>$LOG
|
|
|
|
finish </dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-20 14:13:27 +03:00
|
|
|
##### Test execution ##########################################################
|
|
|
|
|
|
|
|
|
2011-04-20 07:29:11 +03:00
|
|
|
cmd()
|
|
|
|
{
|
|
|
|
cmd=$1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-20 14:13:27 +03:00
|
|
|
##### Evaluation ############################################################
|
|
|
|
|
|
|
|
|
2011-05-21 17:08:46 +03:00
|
|
|
_doit()
|
2011-04-20 07:29:11 +03:00
|
|
|
{
|
2011-05-31 09:30:57 +03:00
|
|
|
if ${LIVE:-false}; then
|
|
|
|
echo
|
|
|
|
script -c "$cmd" -q _out ||
|
|
|
|
{ echo "exit code $?" | fail; exit 1; }
|
|
|
|
else
|
|
|
|
eval "$cmd" >_out 2>&1 ||
|
|
|
|
{ echo "exit code $?" | fail; exit 1; }
|
|
|
|
fi
|
2011-05-21 17:08:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
doit()
|
|
|
|
{
|
|
|
|
_doit
|
|
|
|
pass
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
expect()
|
|
|
|
{
|
|
|
|
_doit
|
2011-05-18 04:07:24 +03:00
|
|
|
fgrep -q "$@" _out || { echo "expected $*" | fail; exit 1; }
|
2011-04-20 07:29:11 +03:00
|
|
|
pass
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
expect_re()
|
|
|
|
{
|
2011-05-21 17:08:46 +03:00
|
|
|
_doit
|
2011-05-18 04:07:24 +03:00
|
|
|
grep -q "$@" _out || { echo "expected $*" | fail; exit 1; }
|
2011-04-20 07:29:11 +03:00
|
|
|
pass
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-20 14:13:27 +03:00
|
|
|
##### Tests #################################################################
|
|
|
|
|
|
|
|
|
|
|
|
begin()
|
|
|
|
{
|
2011-05-21 17:08:46 +03:00
|
|
|
if [ "$1" ]; then
|
|
|
|
PROFILE=$1
|
|
|
|
if [ ! -r $PROFILE ]; then
|
|
|
|
echo "$PROFILE not found" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2011-04-20 14:13:27 +03:00
|
|
|
fi
|
2011-05-19 22:45:22 +03:00
|
|
|
if [ "$2" ]; then
|
|
|
|
CLKREF=$2
|
|
|
|
if ! $LOCAL_EXEC "[ -r $CLKREF ]"; then
|
|
|
|
echo "$CLKREF not found" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2011-04-20 14:13:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-20 07:29:11 +03:00
|
|
|
identify()
|
|
|
|
{
|
|
|
|
step "Identification"
|
|
|
|
cmd "atrf-id -d $DUT"
|
|
|
|
expect "AT86RF231, part 0x03 version 2 manufacturer xxxx001f (Atmel)"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
spectrum()
|
|
|
|
{
|
|
|
|
step "Spectrum"
|
|
|
|
# todo:
|
|
|
|
# - trim values (maybe)
|
|
|
|
# - decide on power
|
|
|
|
# - decide on offset
|
2011-04-20 14:13:27 +03:00
|
|
|
cmd "atrf-path -g -T +0.5 -P $PROFILE $REF $DUT 10"
|
2011-04-20 07:29:11 +03:00
|
|
|
expect PASS
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
transmit()
|
|
|
|
{
|
|
|
|
step "Receive"
|
|
|
|
# todo:
|
|
|
|
# - trim values (maybe)
|
|
|
|
# - channel
|
|
|
|
# - tolerate imperfection (e.g., 99/100|100/100)
|
|
|
|
cmd "atrf-xmit -p 0 $REF $DUT 100"
|
|
|
|
expect 100/100
|
|
|
|
|
|
|
|
step "Send"
|
|
|
|
cmd "atrf-xmit -p 15 $DUT $REF 100"
|
|
|
|
expect 100/100
|
|
|
|
}
|