Root/prod/Common

Source at commit 0db361d49da04eef1f4dd77996450d54e900e083 created 8 years 4 months ago.
By Werner Almesberger, atusb/fw/Makefile (dfu): pass transfer size to hide DFU non-compliance
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
21if [ ${DUT#net:} = $DUT ]; then
22    LOCAL_EXEC=
23    LOCAL_DUT=$DUT
24else
25    LOCAL_EXEC="ssh `echo $DUT | sed 's/^net://;s/,.*$//'`"
26    LOCAL_DUT=`atrf-id -d $DUT -s -s`
27fi
28
29
30##### Test setup ############################################################
31
32
33step()
34{
35    echo -n " .... $1"
36    step=$1
37    cmd=
38    >_out
39    echo $DIV2 >>$LOG
40}
41
42
43##### Test result ###########################################################
44
45
46finish()
47{
48    echo "$cmd" >>$LOG
49    echo | sed "c$DIV1" >>$LOG
50    cat _out >>$LOG
51    sed "1i$DIV1" >>$LOG
52}
53
54
55pass()
56{
57    echo '\r\033[42;30m PASS \033[0m '
58    echo "$step: PASS" >>$LOG
59    finish </dev/null
60}
61
62
63fail()
64{
65    echo '\r\033[41;37m FAIL \033[0m '
66    echo "$step: FAIL" >>$LOG
67    finish
68#
69# to do: allow looping back
70#
71    exit 1
72}
73
74
75todo()
76{
77    echo '\r\033[43;30m TODO \033[0m '
78    echo "$step: TODO" >>$LOG
79    finish </dev/null
80}
81
82
83##### Test execution ##########################################################
84
85
86cmd()
87{
88    cmd=$1
89}
90
91
92##### Evaluation ############################################################
93
94
95expect()
96{
97    eval "$cmd" >_out 2>&1 || { echo "exit code $?" | fail; exit 1; }
98    fgrep -q "$1" _out || { echo "expected $1" | fail; exit 1; }
99    pass
100}
101
102
103expect_re()
104{
105    eval "$cmd" >_out 2>&1 || { echo "exit code $?" | fail; exit 1; }
106    grep -q "$1" _out || { echo "expected $1" | fail; exit 1; }
107    pass
108}
109
110
111##### Tests #################################################################
112
113
114begin()
115{
116    if [ -z "$1" ]; then
117        echo "usage: begin profile" 1>&2
118        exit 1
119    fi
120    PROFILE=$1
121    if [ ! -r $PROFILE ]; then
122        echo "$PROFILE not found" 1>&2
123        exit 1
124    fi
125}
126
127
128identify()
129{
130    step "Identification"
131    cmd "atrf-id -d $DUT"
132    expect "AT86RF231, part 0x03 version 2 manufacturer xxxx001f (Atmel)"
133}
134
135
136spectrum()
137{
138    step "Spectrum"
139# todo:
140# - trim values (maybe)
141# - decide on power
142# - decide on offset
143    cmd "atrf-path -g -T +0.5 -P $PROFILE $REF $DUT 10"
144    expect PASS
145}
146
147
148transmit()
149{
150    step "Receive"
151# todo:
152# - trim values (maybe)
153# - channel
154# - tolerate imperfection (e.g., 99/100|100/100)
155    cmd "atrf-xmit -p 0 $REF $DUT 100"
156    expect 100/100
157
158    step "Send"
159    cmd "atrf-xmit -p 15 $DUT $REF 100"
160    expect 100/100
161}
162

Archive Download this file



interactive