OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [net/] [autotest/] [current/] [host/] [tftpput.sh] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#!/bin/sh
2
 
3
if [ $# -lt 1 ]; then
4
    echo "Usage: $0 target [tempfile [timeout [filesize]]]" > /dev/stderr
5
    exit 1
6
fi
7
 
8
[ "xXFAIL" == "x$1" ] && { XFAIL="XFAIL"; shift; }
9
TARGET=$1
10
if [ "x" == "x$2" ]; then TMP=tftpdata; else TMP=$2; fi
11
if [ "x" == "x$3" ]; then TIMEOUT=10;   else TIMEOUT=$3; fi
12
if [ "x" == "x$4" ]; then SIZE=unknown; else SIZE=$4; fi
13
 
14
if [ -f $TMP ]; then
15
    SRC=${TMP}
16
    TMP=${TMP}.tmp
17
else
18
    SRC=${TMP}.src
19
    TMP=${TMP}.tmp
20
fi
21
 
22
if [ -f $SRC ]; then
23
    [ $SIZE == unknown ] ||  \
24
    { echo "FAIL: '$SRC' exists but size given" > /dev/stderr; exit 1; }
25
else
26
    [ $SIZE == unknown ] && SIZE=876543
27
    tmpfile $SRC $SIZE $$ || \
28
    { echo "FAIL: Sourcefile '$SRC' create" > /dev/stderr; exit 1; }
29
fi
30
 
31
if [ ! -f $SRC ]; then
32
    echo "FAIL: Sourcefile '$SRC' not found" > /dev/stderr; exit 1
33
fi
34
 
35
if [ "x$XFAIL" != "xXFAIL" ]; then
36
    if ping -n -c5 $TARGET > /dev/null ; then
37
        echo "INFO:<$$: $TARGET is up>" > /dev/stderr
38
    else
39
        echo "FAIL:<$$: $TARGET is down>" > /dev/stderr; exit 1
40
    fi
41
fi
42
 
43
declare -i COUNT=0
44
 
45
# Just put the file without checking the data; the get test tests that.
46
while [ $SECONDS -le $TIMEOUT ]; do
47
tftp $TARGET  <<-EOF
48
        rexmt 1
49
        binary
50
        put $SRC $TMP
51
EOF
52
((COUNT++));
53
done
54
 
55
if [ "x$XFAIL" == "xXFAIL" ]; then
56
    echo "PASS:<$$: tftp put XFAIL, $TIMEOUT seconds $SIZE bytes $COUNT tries>" > /dev/stderr
57
    exit 0
58
fi
59
 
60
# Verify it once at the end.
61
rm -f $TMP
62
tftp $TARGET  <<-EOF
63
        rexmt 1
64
        binary
65
        get $TMP $TMP
66
EOF
67
 
68
if [ ! -f $TMP ]; then
69
    echo "FAIL:<$$: temp file $TMP nonexistent $COUNT xfers>" > /dev/stderr
70
    exit 1
71
fi
72
 
73
if ! cmp -s $SRC $TMP; then
74
    echo "FAIL:<$$: temp file $TMP corrupt $COUNT xfers>" > /dev/stderr
75
    exit 1
76
fi
77
 
78
echo "PASS:<$$: tftp put OK, $TIMEOUT seconds $SIZE bytes $COUNT xfers>" > /dev/stderr
79
 
80
# EOF

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.