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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [net/] [autotest/] [current/] [doc/] [host.txt] - Blame information for rev 856

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
 
2
Host Software for Automated Network Testing for eCos
3
====================================================
4
 
5
Hugo Tyson, Red Hat, Cambridge UK, 2000-10-20
6
 
7
 
8
What Host Software?
9
-------------------
10
 
11
This note refers to the package CYGPKG_NET_AUTOTEST which lives in
12
packages/net/autotest in the eCos repository.
13
 
14
It contains, amongst other things, some software to run a "network testing
15
server" which eCos network test cases (from the same package) use to test
16
the network stack.
17
 
18
The reason such a server is needed is simple: testing the eCos network
19
stack involves an external, standard, computer _doing_things_to_ the target
20
board as well as having the target board's test program do things itself.
21
 
22
For example, one test case (in the main network package, net/tcpip) to test
23
TFTP will get a file from a server using TFTP and put the data to another
24
file on the server using TFTP.  This tests the ability of the eCos TCPIP
25
stack to act as a TFTP client.  But it does not test the eCos TCPIP stack's
26
TFTP server at all.  To do that an external agent must act as client -
27
using the standard tftp(1) app on linux, for example - to put and get data
28
to and from an eCos testcase running on the target, offering a TFTP server.
29
 
30
 
31
Quick Start Guide
32
-----------------
33
 
34
Set up your LINUX machine to serve DHCP to the target you want to test;
35
ensure that any 10.0.0.x addresses used are given a class C (/24) netmask.
36
Provide a genuine gateway to the internet via some route; the routing tests
37
expect to ping www.cygnus.com!  Also let it have the normal networking apps
38
(tftp, ftp, ping) and servers (tftpd, ftpd) available, plus the SNMP
39
package from UCD: snmpwalk and snmpstatus and standard MIBs.
40
 
41
Make sure it is on on the same network(s) as the target you want to test.
42
 
43
Set up aliases for loopback interface on the servers: on server for eth0 on
44
the target, add an alias for 10.0.3.1/24.  For eth1, 10.0.4.1/24.
45
 
46
With a checked-out eCos source tree, change directory into either
47
packages/net/autotest/current/host or a copy of it, and type make.
48
 
49
Follow the printed instruction to change the simple executable "./_suping"
50
to su root execution.  You will need to become root temporarily to do this.
51
 
52
Make sure . is on your path and type "awaitorder | obey.sh" to run the
53
server; it prints info about messages it receives and sends.
54
 
55
The test server is now running.  You can now run test built from the
56
CYGPKG_NET_AUTOTEST package (packages/net/autotest) on your target and they
57
will talk to this host test server.
58
 
59
 
60
Categories of Tests
61
-------------------
62
 
63
 o Host passive
64
 
65
        The host is server, the eCos test case is the proactive client.
66
 
67
        Such tests use the host to talk to, where the eCos testcase is the
68
        client, and the host is the server.  The network testing server is
69
        not involved in these tests, but other servers which must be set up
70
        there are used.
71
 
72
 o Host proactive
73
 
74
        The host is client to the eCos server.
75
 
76
        The target board running eCos is the server, the host must run
77
        scripts to do thing to it and report success or otherwise over the
78
        net.  The eCos test case typically starts a server, issues order
79
        about how to test it, then sleeps for a time until the test is
80
        deemed complete.
81
 
82
 
83
Building the Network Testing Server
84
-----------------------------------
85
 
86
Cd into either packages/net/autotest/current/host or a copy of it, and type
87
make.  The standard makefile just compiles ./awaitorder.c into ./awaitorder
88
the executable that waits for a request from a testcase and prints it to
89
its stdout.  It also builds some other utilities that are used by the test
90
scripts, for example ./tmpfile from ./tmpfile.c - this just creates a file
91
of random data for passing back and forth.  It also builds _suping: make
92
sure this is suid-root to be able to flood-ping the target.
93
 
94
 
95
Running the Network Testing Server
96
----------------------------------
97
 
98
Make sure "." is on your path, early enough, then
99
 
100
        awaitorder | obey.sh
101
 
102
This is all you need to do to run the testing server.
103
 
104
 
105
"./awaitorder" just waits for a connection on TCP port 9980 and prints what
106
it receives.  For example, to test it:
107
 
108
                % telnet masala 9980
109
 you type --->  Eggs, bacon, beans, mushrooms, toast and coffee
110
                Acknowledged
111
                Connection closed by foreign host.
112
                %
113
 
114
and awaitorder will print as follows:
115
 
116
                 % awaitorder
117
                awaitorder: connection from 172.16.19.13:3739
118
                ORDERS: Eggs, bacon, beans, mushrooms, toast and coffee
119
 
120
and continue waiting for the next order.
121
 
122
 
123
"./obey.sh" does rather more.  It assumes that its stdin is connected to a
124
source of orders, and it expects that lines of input will look like this:
125
 
126
        ORDERS: TFTP_SERV_GET 10.16.19.171 300
127
 
128
or more generally
129
 
130
        "ORDERS:" [XFAIL]   
131
 
132
The set of valid orders (TFTP_SERV_GET, TFTP_SERV_PUT ...) will expand with
133
time as we add more tests.
134
 
135
Having checked that an order looks generally valid, and set up some
136
environment, it then switches on the order to execute a test script to do
137
what the testcase that sent the order wants.  The extra params are given to
138
the test script.  The test script is invoked in background, so that several
139
sessions can be running at once to hit the target board hard, or of course
140
one network testing server can be servicing several target boards running
141
different testcases all at once.  After the test script is launched,
142
obey.sh just loops back to reading an input line, to get the next order.
143
 
144
"XFAIL" in parameter 1 means the target is configured to simulate network
145
unreliability, or otherwise be uncooperative.  It is passed both to the
146
individual testing scripts and to the system for returning status messages
147
to the test target.
148
 
149
This structure is designed to allow separate development and testing of the
150
individual parts of the network testing server and also of new testcases;
151
the eCos testcase and its test script can be developed on your desk without
152
running the network test server - you only need to knit them all together
153
at the end by adding a simple clause to obey.sh to invoke the test script
154
automatically.
155
 
156
 
157
Test Script Environment
158
-----------------------
159
 
160
There is some IO redirection nastiness in obey.sh to separate errors from
161
good status from status to return to the eCos testcase and so on.
162
 
163
awaitorder takes care to issue complaints to stderr, whilst obviously its
164
stdout is piped in to obey.sh
165
 
166
obey.sh takes care to issue problem reports to stderr, and mere commentary
167
to stdout; neither is paricularly verbose right now, so there's no need to
168
so anything special.
169
 
170
Individual test scripts are invoked as follows.  Stdout is directed to a
171
logfile named uniquely and for the test in question, according the the
172
variable $LG.  Stderr is piped to an acknowledgement agent, by default
173
"./sendack.sh", which is invoked with the target address as its argument.
174
This returns status messages from the host testing script to the eCos
175
testcase via TCP port 9990.
176
 
177
Let's look at the two example switch cases for the TFTP tests.  There are
178
two to mostly put versus mostly get files with the eCos TFTP server.
179
 
180
    # Now the main swicth that runs the test script: this is where
181
    # new testcases are added:
182
    case $TEST in
183
 
184
    TFTP_SERV_GET)
185
    tftpget.sh $TARGET $WF/tftpget.$unique ${PARAMS[@]} \
186
            2>&1 >$LG/tftpget.$unique | $SENDACK $TARGET & ;;
187
 
188
    TFTP_SERV_PUT)
189
    tftpput.sh $TARGET $WF/tftpput.$unique ${PARAMS[@]} \
190
            2>&1 >$LG/tftpput.$unique | $SENDACK $TARGET & ;;
191
 
192
OK, this is horrid.  But breaking up one example:
193
 
194
this first part is the invokation of the script:
195
 
196
    tftpput.sh $TARGET $WF/tftpput.$unique ${PARAMS[@]}
197
 
198
its arguments are
199
 
200
    tftpput.sh    
201
 
202
 o  is $TARGET, from the original order.
203
 
204
 o obey.sh has invented  with a unique id, in the workfiles
205
   directory, $WF.  It will typically be "/tmp/auto/wf/tftpput.1138".  In
206
   this example, the test script will make files called
207
   "/tmp/auto/wf/tftpput.1138.src" and "/tmp/auto/wf/tftpput.1138.tmp" to
208
   play with; one is created by the tmpfile program, the other read back
209
   from the TFTP server.
210
 
211
 o  is part of the extra params supplied by the eCos testcase,
212
   which in this case will serve TFTP for about 5 minutes, so it tells the
213
   test script to diddle it for about 5 minutes too.
214
 
215
 o  is another param supplied by the eCos testcase, which tells
216
   the script to create a testfile of a particular size to exercise edge
217
   conditions wrt the blocksize.
218
 
219
The second part of the example is the IO redirection and backgrounding:
220
 
221
            2>&1 >$LG/tftpput.$unique | $SENDACK $XFAIL $TARGET & ;;
222
 
223
This sets the script's fd2 to a copy of its stdout, then sets its stdout to
224
go to the logfile, typically "/tmp/auto/log/tftpput.1138", then pipes the
225
original stdout which now occupies fd2 into $SENDACK, the acknowledgement
226
agent, which is itself invoked with the target's IP address and optionally
227
XFAIL to tell it not to be so upset if it fails to return the result.  The
228
whole thing is run in background by the "&" and the ";;" is the end of this
229
case within the switch statement.  Phew!
230
 
231
More briefly, the test script's stdout goes into the logfile and the test
232
script's stderr goes into $SENDACK (./sendack.sh) and thence to the
233
testcase.
234
 
235
 
236
Typical Output
237
--------------
238
 
239
This is the output from awaitorder | obey.sh from running just one eCos
240
testcase, which requests 3 simultaneous TFTP sessions for 5 minutes:
241
 
242
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
243
awaitorder: connection from 10.16.19.171:34554
244
test TFTP_SERV_PUT; target 10.16.19.171; params 300 512
245
awaitorder: connection from 10.16.19.171:46052
246
test TFTP_SERV_PUT; target 10.16.19.171; params 300 513
247
awaitorder: connection from 172.16.19.171:25388
248
test TFTP_SERV_PUT; target 172.16.19.171; params 300 512
249
10.16.19.171: result INFO:<10.16.19.171 is up>
250
172.16.19.171: result INFO:<172.16.19.171 is up>
251
10.16.19.171: result INFO:<10.16.19.171 is up>
252
10.16.19.171: result PASS:
253
10.16.19.171: result PASS:
254
172.16.19.171: result PASS:
255
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
256
 
257
and the eCos test case prints, amongst other things, on receipt of the
258
results via sendack.sh
259
 
260
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
261
INFO:<10.16.19.171 is up> (10.16.19.171) (from 10.16.19.13:4764)
262
INFO:<172.16.19.171 is up> (172.16.19.171) (from 172.16.19.13:4765)
263
INFO:<10.16.19.171 is up> (10.16.19.171) (from 10.16.19.13:4766)
264
....
265
PASS: (10.16.19.171) (from 10.16.19.13:4775)
266
PASS: (10.16.19.171) (from 10.16.19.13:4776)
267
PASS: (172.16.19.171) (from 172.16.19.13:4777)
268
....
269
PASS:
270
EXIT:
271
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
272
 
273
This output format will change over time as more features may be added, but
274
this example should convey the general idea.
275
 
276
 
277
Individual Host Testing Scripts
278
-------------------------------
279
 
280
The params and invocation of these is entirely a matter of agreement
281
between the eCos testcase and the test script.  A new case arm in the
282
obey.sh switch statement must be written for any new testcase, so the
283
script's invocation is not prescribed in any way.
284
 
285
For the sake of easier separate development of testcases, it would be
286
better to follow the pattern of the other testcases, also for consistency
287
and comprehensibility.  Here are some guidelines and requirements, but
288
first some assumptions:
289
 
290
 o One test script "does things to" one target board, and more specifically
291
   one target IP address.  If you want several things done to your target
292
   board at once, invoke several scripts at once - all on the same IP
293
   address if you want, that's fine.
294
 
295
 o The test script may need to be told that the target network stack is
296
   configured to simulate network unreliability, so the test script should
297
   not expect perfect communications.  Eg. weaker protocols will in fact
298
   fail - the point of the test is verify that the target does not hang or
299
   crash or assert-fail and so on; host side network failures within the
300
   script are unimportant.  Otherwise, the test script should expect
301
   correct operation in the operations it performs.
302
 
303
 o The network test server can serve testing to many eCos target boards at
304
   once.  Therefore any particular test script can be invoked several times
305
   at once to deal with different target boards, if they happen at random
306
   to run the same testcase at the same time as each other.  Therefore a
307
   test script should only use temporary files which are uniquely named per
308
   invocation.
309
 
310
These lead to requirements and guidelines:
311
 
312
 o Take the flag XFAIL optionally as the first argument, if it is XFAIL
313
   shift to get the other arguments.
314
 
315
 o Take the target IP address as the next argument; it's an obvious place
316
   for it and you'll certainly need it anyhow.
317
 
318
 o For workfiles, have obey.sh supply a parameter to name such files
319
   uniquely.  Use a full pathname.  Include the test type also, for example
320
   "/tmp/auto/wf/tftpput.1138" identifies the file as belonging to the
321
   tftpput testcase.  Make required workfiles be second and subsequent
322
   arguments.
323
 
324
 o Further arguments which are arbitrary and passed from the testcase
325
   should be last, and passed all together.  It's not convenient in the
326
   shell to split out words 2 through the end from an array if you already
327
   quoted word one elsewhere, so instead put all the extras together as in
328
   ${PARAMS[@]} in the tftpput.sh invocation discussed above.
329
 
330
 
331
Other Environment
332
-----------------
333
 
334
 o DHCP
335
 
336
Set up DHCP to support the target board - it's the easiest way.
337
 
338
The tests know which server to talk to by looking in the server ID field of
339
the bootp information record; if DHCP or BOOTP is used, this will be the
340
server that served it.  It is also possible to set up the stack with static
341
initialization of that field - if you do this, make sure it points to a
342
machine that is running the network test server.
343
 
344
Setting up the server to serve DHCP to the target boards only is easy;
345
keeping other DHCP servers, who offer dynamic addresses to any new net
346
presence, from offering service to them requires a little trick.  A dynamic
347
server should be set up to supply a static address to the target board's
348
MAC address, with the additional key: "deny booting;".  This does nothing
349
malicious, but it lets the server recognize the target board and ignore it.
350
 
351
This ensures that the network test server machine "wins" the race to set up
352
the target, and so ensures that the test talks to the network test server
353
rather than trying to talk to a global DHCP server.
354
 
355
 
356
 o /tmp clearance
357
 
358
The ongoing testing fills /tmp with log files and work files.  The logs
359
will likely not be very large, but the work files could be a few Mb per
360
test run.
361
 
362
A cron job to remove everything older than an hour, or some such might be
363
useful; or if the machine can stand it, just wipe /tmp/auto every night.
364
 
365
 
366
 o Ping!
367
 
368
The tests will expect to ping (and flood ping) the server; it should be
369
allowed to do this back.  An suid executable (CARE!) is needed to enable
370
this.  "./_suping" is built by the host makefile: make it be suid root.
371
It is a trivial app that execs ping after setting the effective UID to
372
root.  This is necessary because ping is an suid-root executable anyway, to
373
be able to get at raw sockets; it checks the effective UID to decide
374
whether to permit flood pinging; we need this for the flood tests floodping
375
and floodpingmux.
376
 
377
 
378
 o Network aliases in the loopback interface
379
 
380
The routing tests require a network setup like this:
381
 
382
  10.0.3.1      A.B.C.D   A.B.C.E        N.M.O.P   N.M.O.Q      10.0.4.1
383
  -------- Box1 ----------------- target ----------------- Box2 --------
384
 
385
 
386
Optionally with 10.0.3 and 10.0.4 being real networks, with other stations
387
on them; addresses 10.0.x.99 are also pinged.  Alternatively, 10.0.3 and
388
10.0.4 can be aliases for the loopback device in Box1 and Box2 (which may
389
be the same box really).  A typical setup might really look like:
390
 
391
  HOST: eth0 172.16.19.13 ------ 172.16.19.171 eth0 on TARGET
392
  HOST: eth1 10.16.19.13 -------- 10.16.19.171 eth1 on TARGET
393
  HOST: lo:0 10.0.3.1
394
  HOST: lo:1 10.0.4.1
395
 
396
with all netmasks being /24 (255.255.255.0).
397
 
398
This means that the target can only ping addresses 10.0.3.x and 10.0.4.x if
399
a route has been set up via 172.16.19.13 or 10.16.19.13 (respectively, for
400
the case of having two distinct hosts).  The routing tests verify that
401
behaviour.
402
 
403
 
404
 o TFTP server and its files
405
 
406
No test of the eCos TFTP client yet, so no details here.
407
 
408
 o FTP server and its files
409
 
410
No test for the eCos FTP client yet, so no details here.
411
 
412
 
413
 
414
.fin

powered by: WebSVN 2.1.0

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