~ubuntu-branches/ubuntu/saucy/dejagnu/saucy

« back to all changes in this revision

Viewing changes to doc/html/x319.html

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Jacobowitz
  • Date: 2004-02-09 15:07:58 UTC
  • Revision ID: james.westby@ubuntu.com-20040209150758-oaj7r5zrop60v8sb
Tags: upstream-1.4.4
ImportĀ upstreamĀ versionĀ 1.4.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
 
2
<HTML
 
3
><HEAD
 
4
><TITLE
 
5
>A first remote test</TITLE
 
6
><META
 
7
NAME="GENERATOR"
 
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
 
9
"><LINK
 
10
REL="HOME"
 
11
TITLE="DejaGnu"
 
12
HREF="book1.html"><LINK
 
13
REL="UP"
 
14
TITLE="Getting DejaGnu up and running"
 
15
HREF="c203.html"><LINK
 
16
REL="PREVIOUS"
 
17
TITLE="Our first automated tests"
 
18
HREF="x276.html"><LINK
 
19
REL="NEXT"
 
20
TITLE="Running Tests"
 
21
HREF="c401.html"></HEAD
 
22
><BODY
 
23
CLASS="SECT1"
 
24
BGCOLOR="#FFFFFF"
 
25
TEXT="#000000"
 
26
LINK="#0000FF"
 
27
VLINK="#840084"
 
28
ALINK="#0000FF"
 
29
><DIV
 
30
CLASS="NAVHEADER"
 
31
><TABLE
 
32
SUMMARY="Header navigation table"
 
33
WIDTH="100%"
 
34
BORDER="0"
 
35
CELLPADDING="0"
 
36
CELLSPACING="0"
 
37
><TR
 
38
><TH
 
39
COLSPAN="3"
 
40
ALIGN="center"
 
41
>DejaGnu: The GNU Testing Framework</TH
 
42
></TR
 
43
><TR
 
44
><TD
 
45
WIDTH="10%"
 
46
ALIGN="left"
 
47
VALIGN="bottom"
 
48
><A
 
49
HREF="x276.html"
 
50
ACCESSKEY="P"
 
51
>&#60;&#60;&#60; Previous</A
 
52
></TD
 
53
><TD
 
54
WIDTH="80%"
 
55
ALIGN="center"
 
56
VALIGN="bottom"
 
57
>Getting DejaGnu up and running</TD
 
58
><TD
 
59
WIDTH="10%"
 
60
ALIGN="right"
 
61
VALIGN="bottom"
 
62
><A
 
63
HREF="c401.html"
 
64
ACCESSKEY="N"
 
65
>Next &#62;&#62;&#62;</A
 
66
></TD
 
67
></TR
 
68
></TABLE
 
69
><HR
 
70
ALIGN="LEFT"
 
71
WIDTH="100%"></DIV
 
72
><DIV
 
73
CLASS="SECT1"
 
74
><H1
 
75
CLASS="SECT1"
 
76
><A
 
77
NAME="AEN319"
 
78
></A
 
79
>A first remote test</H1
 
80
><P
 
81
>Testing remote targets is a lot trickier especially if you are using an
 
82
 embedded target
 
83
which has no built in support for things like a compiler, ftp server or a Bash-shell.
 
84
Before you can test calc on a remote target you have to acquire a few basics skills.</P
 
85
><DIV
 
86
CLASS="SECT2"
 
87
><H2
 
88
CLASS="SECT2"
 
89
><A
 
90
NAME="AEN322"
 
91
></A
 
92
>Setup telnet to your own host</H2
 
93
><P
 
94
>The easiest remote host is usually the host you are working on.
 
95
In this example we will use telnet to login in your own workstation.
 
96
For security reason you should never have a telnet deamon running on
 
97
machine connected on the internet, as password and usernames are transmitted
 
98
 in clear text.
 
99
We assume you know how to setup your machine for a telnet daemon.</P
 
100
><P
 
101
>Next try whether you may login in your own host by issuing the
 
102
command &#8220;telnet localhost.1&#8221;. In order to be able to
 
103
distinguish between a normal session an a telnet login add the following lines to /home/dgt/.bashrc.</P
 
104
><TABLE
 
105
BORDER="0"
 
106
BGCOLOR="#E0E0E0"
 
107
WIDTH="100%"
 
108
><TR
 
109
><TD
 
110
><PRE
 
111
CLASS="PROGRAMLISTING"
 
112
>if [ "$REMOTEHOST" ]
 
113
then
 
114
   PS1='remote:\w\$ '
 
115
fi</PRE
 
116
></TD
 
117
></TR
 
118
></TABLE
 
119
><P
 
120
>Now on the machine a &#8220;remote&#8221; login looks like this:</P
 
121
><DIV
 
122
CLASS="EXAMPLE"
 
123
><A
 
124
NAME="AEN328"
 
125
></A
 
126
><P
 
127
><B
 
128
>Example 11. Sample log of a telnet login to localhost</B
 
129
></P
 
130
><TABLE
 
131
BORDER="0"
 
132
BGCOLOR="#E0E0E0"
 
133
WIDTH="100%"
 
134
><TR
 
135
><TD
 
136
><PRE
 
137
CLASS="PROGRAMLISTING"
 
138
>dgt:~/dejagnu.test$ telnet localhost
 
139
Trying 127.0.0.1...
 
140
Connected to 127.0.0.1.
 
141
Escape character is '^]'.
 
142
Debian GNU/Linux testing/unstable Linux
 
143
K6Linux login: dgt
 
144
Password:
 
145
Last login: Sun Nov 25 22:46:34 2001 from localhost on pts/4
 
146
Linux K6Linux 2.4.14 #1 Fre Nov 16 19:28:25 CET 2001 i586 unknown
 
147
No mail.
 
148
remote:~$ exit
 
149
logout
 
150
Connection closed by foreign host.</PRE
 
151
></TD
 
152
></TR
 
153
></TABLE
 
154
></DIV
 
155
></DIV
 
156
><DIV
 
157
CLASS="SECT2"
 
158
><H2
 
159
CLASS="SECT2"
 
160
><A
 
161
NAME="AEN331"
 
162
></A
 
163
>A test case for login via telnet</H2
 
164
><P
 
165
>In order to define a correct setup we have add a line containing
 
166
&#8220;set target unix&#8221; either to ~/.dejagnurc or to ~/my_dejagnu.exp.
 
167
In ~/boards/standard.exp add the following four lines to define a few patterns for the DejaGnu telnet login procedure.</P
 
168
><DIV
 
169
CLASS="EXAMPLE"
 
170
><A
 
171
NAME="AEN334"
 
172
></A
 
173
><P
 
174
><B
 
175
>Example 12. Defining a remote target board</B
 
176
></P
 
177
><TABLE
 
178
BORDER="0"
 
179
BGCOLOR="#E0E0E0"
 
180
WIDTH="100%"
 
181
><TR
 
182
><TD
 
183
><PRE
 
184
CLASS="PROGRAMLISTING"
 
185
>set_board_info shell_prompt    "remote:"
 
186
set_board_info telnet_username "dgt"
 
187
set_board_info telnet_password "top_secret"
 
188
set_board_info hostname        "localhost"&#13;</PRE
 
189
></TD
 
190
></TR
 
191
></TABLE
 
192
></DIV
 
193
><P
 
194
>As DejaGnu will be parsing the telnet session output for some well
 
195
known pattern the output there are a lot of things that can go wrong.
 
196
If you have any problems verify your setup:</P
 
197
><P
 
198
></P
 
199
><UL
 
200
><LI
 
201
><P
 
202
>Is <TT
 
203
CLASS="FILENAME"
 
204
>/etc/motd</TT
 
205
> empty?</P
 
206
></LI
 
207
><LI
 
208
><P
 
209
>Is <TT
 
210
CLASS="FILENAME"
 
211
>/etc/issue.net</TT
 
212
> empty?</P
 
213
></LI
 
214
><LI
 
215
><P
 
216
>Exists a empty <TT
 
217
CLASS="FILENAME"
 
218
>~/.hushlogin</TT
 
219
>?</P
 
220
></LI
 
221
><LI
 
222
><P
 
223
>The LANG environment variable must be either empty or set to &#8220;C&#8221;. </P
 
224
></LI
 
225
></UL
 
226
><P
 
227
>To test the login via telnet write a sample test case.
 
228
Create the file ~/dejagnu.test/testsuite/calc.test/remote_echo.exp and
 
229
add the following few lines:</P
 
230
><DIV
 
231
CLASS="EXAMPLE"
 
232
><A
 
233
NAME="AEN351"
 
234
></A
 
235
><P
 
236
><B
 
237
>Example 13. DejaGnu script for logging in into a remote target</B
 
238
></P
 
239
><TABLE
 
240
BORDER="0"
 
241
BGCOLOR="#E0E0E0"
 
242
WIDTH="100%"
 
243
><TR
 
244
><TD
 
245
><PRE
 
246
CLASS="PROGRAMLISTING"
 
247
>puts "this is remote_echo.exp target for $target "
 
248
target_info $target
 
249
#set verbose 9
 
250
set shell_id [remote_open $target]
 
251
set test "Remote login to $target"
 
252
#set verbose 0
 
253
puts "Spawn id for remote shell is $shell_id"
 
254
if { $shell_id &#62; 0 } {
 
255
   pass "$test"
 
256
} else {
 
257
   fail "Remote open to $target"
 
258
}</PRE
 
259
></TD
 
260
></TR
 
261
></TABLE
 
262
></DIV
 
263
><P
 
264
>In the runtest output you should find something like:</P
 
265
><TABLE
 
266
BORDER="0"
 
267
BGCOLOR="#E0E0E0"
 
268
WIDTH="100%"
 
269
><TR
 
270
><TD
 
271
><PRE
 
272
CLASS="PROGRAMLISTING"
 
273
>Running ./testsuite/calc.test/local_echo.exp ...
 
274
Running ./testsuite/calc.test/remote_echoo.exp ...
 
275
this is remote_echo.exp target is unix
 
276
Spawn id for remote shell is exp7</PRE
 
277
></TD
 
278
></TR
 
279
></TABLE
 
280
><P
 
281
>Have again a look at calc.log to get a feeling how DejaGnu and expect
 
282
parse the input. </P
 
283
></DIV
 
284
><DIV
 
285
CLASS="SECT2"
 
286
><H2
 
287
CLASS="SECT2"
 
288
><A
 
289
NAME="AEN357"
 
290
></A
 
291
>Remote testing &#8220;Hello world&#8221;</H2
 
292
><P
 
293
>Next you will transform the above &#8220;hello world&#8221; example to
 
294
its remote equivalent.
 
295
This can be done by adding the following lines to our file remote_echo.exp.</P
 
296
><DIV
 
297
CLASS="EXAMPLE"
 
298
><A
 
299
NAME="AEN360"
 
300
></A
 
301
><P
 
302
><B
 
303
>Example 14. A first (local) remote "Hello world" test</B
 
304
></P
 
305
><TABLE
 
306
BORDER="0"
 
307
BGCOLOR="#E0E0E0"
 
308
WIDTH="100%"
 
309
><TR
 
310
><TD
 
311
><PRE
 
312
CLASS="PROGRAMLISTING"
 
313
>set test "Remote_send Hello World"
 
314
set status [remote_send $target "echo \"Hello\" \"World\"\n" ]
 
315
pass "$test"
 
316
set test "Remote_expect Hello World"
 
317
remote_expect $target 5 {
 
318
   -re "Hello World"  { pass "$test" }
 
319
}</PRE
 
320
></TD
 
321
></TR
 
322
></TABLE
 
323
></DIV
 
324
><P
 
325
>Call make check. The output should contain
 
326
&#8220;# of expected passes 9&#8221; and &#8220;# of unexcpected failures 1&#8221;.</P
 
327
><P
 
328
>Have a look at the procedures in /usr/share/dejagnu/remote.exp to have an overview of the offered procedures and their features. </P
 
329
><P
 
330
>Now setup a real target.
 
331
In the following example we assume as target a PowerBook running Debian.
 
332
As above add a test user "dgt", install telnet and FTP servers.
 
333
In order to distinguish it from the host add the line
 
334
<TABLE
 
335
BORDER="0"
 
336
BGCOLOR="#E0E0E0"
 
337
WIDTH="100%"
 
338
><TR
 
339
><TD
 
340
><PRE
 
341
CLASS="PROGRAMLISTING"
 
342
>PS1='test:&#62;'</PRE
 
343
></TD
 
344
></TR
 
345
></TABLE
 
346
> to /home/dgt/.bash_profile.
 
347
Also add a corresponding entry "powerbook" to /etc/hosts and verify that you
 
348
are able to ping, telnet and ftp to the target "powerbook".</P
 
349
><P
 
350
>In order to let runtest run its test on the "powerbook" target change the following lines in ~/boards/standard.exp:</P
 
351
><DIV
 
352
CLASS="EXAMPLE"
 
353
><A
 
354
NAME="AEN368"
 
355
></A
 
356
><P
 
357
><B
 
358
>Example 15. Board definition for a remote target</B
 
359
></P
 
360
><TABLE
 
361
BORDER="0"
 
362
BGCOLOR="#E0E0E0"
 
363
WIDTH="100%"
 
364
><TR
 
365
><TD
 
366
><PRE
 
367
CLASS="PROGRAMLISTING"
 
368
>set_board_info protocol        "telnet"
 
369
set_board_info telnet_username "dgt"
 
370
set_board_info telnet_password "top_secret"
 
371
set_board_info shell_prompt    "test:&#62; "
 
372
set_board_info hostname        "powerbook"</PRE
 
373
></TD
 
374
></TR
 
375
></TABLE
 
376
></DIV
 
377
><P
 
378
>Now call runtest again with the same arguments and verify whether all went okay by taking a close look at calc.log.</P
 
379
></DIV
 
380
><DIV
 
381
CLASS="SECT2"
 
382
><H2
 
383
CLASS="SECT2"
 
384
><A
 
385
NAME="AEN372"
 
386
></A
 
387
>Transferring files from/to the target</H2
 
388
><P
 
389
>A simple procedure like this will do the job for you:</P
 
390
><DIV
 
391
CLASS="EXAMPLE"
 
392
><A
 
393
NAME="AEN375"
 
394
></A
 
395
><P
 
396
><B
 
397
>Example 16. Test script to transfer a file to a remote target</B
 
398
></P
 
399
><TABLE
 
400
BORDER="0"
 
401
BGCOLOR="#E0E0E0"
 
402
WIDTH="100%"
 
403
><TR
 
404
><TD
 
405
><PRE
 
406
CLASS="PROGRAMLISTING"
 
407
>set test "Remote_download"
 
408
puts "Running Remote_download"
 
409
# set verbose 9
 
410
set remfile /home/dgt/dejagnu2
 
411
 
 
412
set status [remote_download $target /home/dgt/.dejagnurc $remfile]
 
413
if { "$status" == "" } {
 
414
     fail "Remote download to $remfile on $target"
 
415
} else {
 
416
   pass "$test"
 
417
}
 
418
 
 
419
puts "status of remote_download ist $status"
 
420
# set verbose 0</PRE
 
421
></TD
 
422
></TR
 
423
></TABLE
 
424
></DIV
 
425
><P
 
426
>After running runtest again, check whether the file dejagnu2 exists on the target.
 
427
 
 
428
This example will only work if the rcp command works with your target.
 
429
 
 
430
If you have a working FTP-server on the target you can use it by adding the
 
431
following lines to ~/boards/standard.exp:</P
 
432
><DIV
 
433
CLASS="EXAMPLE"
 
434
><A
 
435
NAME="AEN379"
 
436
></A
 
437
><P
 
438
><B
 
439
>Example 17. Defining a board to use FTP as file transport</B
 
440
></P
 
441
><TABLE
 
442
BORDER="0"
 
443
BGCOLOR="#E0E0E0"
 
444
WIDTH="100%"
 
445
><TR
 
446
><TD
 
447
><PRE
 
448
CLASS="PROGRAMLISTING"
 
449
>set_board_info file_transfer   "ftp"
 
450
set_board_info ftp_username    "dgt"
 
451
set_board_info ftp_password    "1234"</PRE
 
452
></TD
 
453
></TR
 
454
></TABLE
 
455
></DIV
 
456
></DIV
 
457
><DIV
 
458
CLASS="SECT2"
 
459
><H2
 
460
CLASS="SECT2"
 
461
><A
 
462
NAME="AEN382"
 
463
></A
 
464
>Preparing for crosscompilation</H2
 
465
><P
 
466
>For crosscompiling you need working binutils, gcc and a base library like
 
467
libc or glib for your target.
 
468
It is beyond the scope of this document to describe how to get it working.
 
469
The following examples assume a cross compiler for PowerPC which is called linux-powerpc-gcc.</P
 
470
><P
 
471
>Add AC_CANONICAL_TARGET in dejagnu.test/configure.in at the following location. Copy config.guess from /usr/share/automake to dejagnu.test.</P
 
472
><TABLE
 
473
BORDER="0"
 
474
BGCOLOR="#E0E0E0"
 
475
WIDTH="100%"
 
476
><TR
 
477
><TD
 
478
><PRE
 
479
CLASS="PROGRAMLISTING"
 
480
>AM_CONFIG_HEADER(calc.h)
 
481
AC_CANONICAL_TARGET([])
 
482
AM_INIT_AUTOMAKE(calc, 1.1)</PRE
 
483
></TD
 
484
></TR
 
485
></TABLE
 
486
><P
 
487
>You need to run automake 2.5 or later.
 
488
Depending on your installation calling autoconf2.5 instead of autoconf is not needed.
 
489
The sequence to regenerate all files is:</P
 
490
><DIV
 
491
CLASS="EXAMPLE"
 
492
><A
 
493
NAME="AEN388"
 
494
></A
 
495
><P
 
496
><B
 
497
>Example 18. Using autotools for cross development</B
 
498
></P
 
499
><TABLE
 
500
BORDER="0"
 
501
BGCOLOR="#E0E0E0"
 
502
WIDTH="100%"
 
503
><TR
 
504
><TD
 
505
><PRE
 
506
CLASS="PROGRAMLISTING"
 
507
>$ autoconf2.5
 
508
$ autoheader
 
509
$ automake
 
510
$ ./configure --host=powerpc-linux --target=powerpc-linux
 
511
configure: WARNING: If you wanted to set the --build type, don't use --host.
 
512
    If a cross compiler is detected then cross compile mode will be used.
 
513
checking build system type... ./config.guess: ./config.guess: No such file or directory
 
514
configure: error: cannot guess build type; you must specify one
 
515
$ cp /usr/share/automake/config.guess .
 
516
$ ./configure --host=powerpc-linux --target=powerpc-linux
 
517
configure: WARNING: If you wanted to set the --build type, don't use --host.
 
518
If a cross compiler is detected then cross compile mode will be used. \
 
519
checking build system type... i586-pc-linux-gnu
 
520
checking host system type... powerpc-unknown-linux-gnu
 
521
&#60;...&#62;
 
522
checking whether we are cross compiling... yes
 
523
&#60;...&#62;
 
524
Configuration:
 
525
Source code location: .
 
526
C Compiler: powerpc-linux-gcc
 
527
C Compiler flags: -g -O2&#13;</PRE
 
528
></TD
 
529
></TR
 
530
></TABLE
 
531
></DIV
 
532
><P
 
533
>Everything should be ready to recompile for the target:</P
 
534
><TABLE
 
535
BORDER="0"
 
536
BGCOLOR="#E0E0E0"
 
537
WIDTH="100%"
 
538
><TR
 
539
><TD
 
540
><PRE
 
541
CLASS="PROGRAMLISTING"
 
542
>$ make
 
543
powerpc-linux-gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c calc.c
 
544
powerpc-linux-gcc -g -O2 -o calc calc.o&#13;</PRE
 
545
></TD
 
546
></TR
 
547
></TABLE
 
548
></DIV
 
549
><DIV
 
550
CLASS="SECT2"
 
551
><H2
 
552
CLASS="SECT2"
 
553
><A
 
554
NAME="AEN393"
 
555
></A
 
556
>Remote testing of calc</H2
 
557
><P
 
558
>Not yet written, as I have problem getting libc6-dev-powerpc to work. Probably I first have to build my cross compiler. </P
 
559
></DIV
 
560
><DIV
 
561
CLASS="SECT2"
 
562
><H2
 
563
CLASS="SECT2"
 
564
><A
 
565
NAME="AEN396"
 
566
></A
 
567
>Using Windows as host and vxWorks as target</H2
 
568
><P
 
569
>A more thorough walk-through will be written in a few weeks.</P
 
570
><P
 
571
>In order to test the vxWorks as a target I changed boards/standards.exp to reflect my settings (IP, username, password). Then I reconfigured vxWorks to include a FTP and telnet server (using the same username/password combination ad in boards/standard.exp).</P
 
572
><P
 
573
>With this setup and some minor modification (e.g. replacing echo by printf) in my test cases I could test my vxWorks system. It sure does not seem to be a correct setup by DejaGnu standard. For instance, it still loading /usr/share/dejagnu/baseboards/unix.exp instead of vxWorks. In any case I found that (at least under Windows) I did not find out how the command line would let me override settings in my personal config files.</P
 
574
></DIV
 
575
></DIV
 
576
><DIV
 
577
CLASS="NAVFOOTER"
 
578
><HR
 
579
ALIGN="LEFT"
 
580
WIDTH="100%"><TABLE
 
581
SUMMARY="Footer navigation table"
 
582
WIDTH="100%"
 
583
BORDER="0"
 
584
CELLPADDING="0"
 
585
CELLSPACING="0"
 
586
><TR
 
587
><TD
 
588
WIDTH="33%"
 
589
ALIGN="left"
 
590
VALIGN="top"
 
591
><A
 
592
HREF="x276.html"
 
593
ACCESSKEY="P"
 
594
>&#60;&#60;&#60; Previous</A
 
595
></TD
 
596
><TD
 
597
WIDTH="34%"
 
598
ALIGN="center"
 
599
VALIGN="top"
 
600
><A
 
601
HREF="book1.html"
 
602
ACCESSKEY="H"
 
603
>Home</A
 
604
></TD
 
605
><TD
 
606
WIDTH="33%"
 
607
ALIGN="right"
 
608
VALIGN="top"
 
609
><A
 
610
HREF="c401.html"
 
611
ACCESSKEY="N"
 
612
>Next &#62;&#62;&#62;</A
 
613
></TD
 
614
></TR
 
615
><TR
 
616
><TD
 
617
WIDTH="33%"
 
618
ALIGN="left"
 
619
VALIGN="top"
 
620
>Our first automated tests</TD
 
621
><TD
 
622
WIDTH="34%"
 
623
ALIGN="center"
 
624
VALIGN="top"
 
625
><A
 
626
HREF="c203.html"
 
627
ACCESSKEY="U"
 
628
>Up</A
 
629
></TD
 
630
><TD
 
631
WIDTH="33%"
 
632
ALIGN="right"
 
633
VALIGN="top"
 
634
>Running Tests</TD
 
635
></TR
 
636
></TABLE
 
637
></DIV
 
638
></BODY
 
639
></HTML
 
640
>
 
 
b'\\ No newline at end of file'