Root/prod/Common

1#!/bin/sh
2
3DIV1=------------------------------------------------------------------------
4DIV2=========================================================================
5
6
7usage()
8{
9    echo "usage: $0 ref_dev test_dev" 1>&2
10    exit 1
11}
12
13
14[ "$2" -a -z "$3" ] || usage
15REF=$1
16# DUT = Device Under Test
17DUT=$2
18LOG=_log
19>$LOG
20
21LIVE=
22
23if [ ${REF#net:} = $REF ]; then
24    REF_EXEC=
25else
26    REF_EXEC="ssh `echo $REF | sed 's/^net://;s/,.*$//'`"
27fi
28
29if [ ${DUT#net:} = $DUT ]; then
30    LOCAL_EXEC=
31    LOCAL_DUT=$DUT
32else
33    LOCAL_EXEC="ssh `echo $DUT | sed 's/^net://;s/,.*$//'`"
34    LOCAL_DUT=`atrf-id -d $DUT -s -s`
35fi
36
37
38##### Test setup ############################################################
39
40
41step()
42{
43    echo -n " .... $1"
44    step=$1
45    cmd=
46    >_out
47    echo $DIV2 >>$LOG
48}
49
50
51##### Test result ###########################################################
52
53
54g_echo()
55{
56    /bin/echo -e "$@"
57}
58
59
60finish()
61{
62    echo "$cmd" >>$LOG
63    echo | sed "c$DIV1" >>$LOG
64    cat _out >>$LOG
65    sed "1i$DIV1" >>$LOG
66}
67
68
69pass()
70{
71    g_echo '\r\033[42;30m PASS \033[0m '
72    echo "$step: PASS" >>$LOG
73    finish </dev/null
74}
75
76
77fail()
78{
79    g_echo '\r\033[41;37m FAIL \033[0m '
80    echo "$step: FAIL" >>$LOG
81    finish
82#
83# to do: allow looping back
84#
85    exit 1
86}
87
88
89todo()
90{
91    g_echo '\r\033[43;30m TODO \033[0m '
92    echo "$step: TODO" >>$LOG
93    finish </dev/null
94}
95
96
97##### Test execution ##########################################################
98
99
100cmd()
101{
102    cmd=$1
103}
104
105
106##### Evaluation ############################################################
107
108
109_doit()
110{
111    if ${LIVE:-false}; then
112        echo
113        script -c "$cmd" -q _out ||
114            { echo "exit code $?" | fail; exit 1; }
115    else
116        eval "$cmd" >_out 2>&1 ||
117            { echo "exit code $?" | fail; exit 1; }
118    fi
119}
120
121
122doit()
123{
124    _doit
125    pass
126}
127
128
129expect()
130{
131    _doit
132    fgrep -q "$@" _out || { echo "expected $*" | fail; exit 1; }
133    pass
134}
135
136
137expect_re()
138{
139    _doit
140    grep -q "$@" _out || { echo "expected $*" | fail; exit 1; }
141    pass
142}
143
144
145##### Tests #################################################################
146
147
148begin()
149{
150    if [ "$1" ]; then
151        PROFILE=$1
152        if [ ! -r $PROFILE ]; then
153            echo "$PROFILE not found" 1>&2
154            exit 1
155        fi
156    fi
157    if [ "$2" ]; then
158        CLKREF=$2
159        if ! $LOCAL_EXEC "[ -r $CLKREF ]"; then
160            echo "$CLKREF not found" 1>&2
161            exit 1
162        fi
163    fi
164}
165
166
167identify()
168{
169    step "Identification"
170    cmd "atrf-id -d $DUT"
171    expect "AT86RF231, part 0x03 version 2 manufacturer xxxx001f (Atmel)"
172}
173
174
175spectrum()
176{
177    step "Spectrum"
178# todo:
179# - trim values (maybe)
180# - decide on power
181    cmd "atrf-path -g -P $PROFILE $REF $DUT 10"
182    expect PASS
183}
184
185
186transmit()
187{
188    step "Receive"
189# todo:
190# - trim values (maybe)
191# - channel
192# - tolerate imperfection (e.g., 99/100|100/100)
193    cmd "atrf-xmit -p 0 $REF $DUT 100"
194    expect 100/100
195
196    step "Send"
197    cmd "atrf-xmit -p 15 $DUT $REF 100"
198    expect 100/100
199}
200

Archive Download this file



interactive