OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [binutils-2.20.1/] [gas/] [testsuite/] [gas/] [template] - Blame information for rev 205

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 205 julius
#
2
# This is sort of a prototype test case, which parses the listing output
3
# from the assembler.  Later, more prototypes should be added for cases
4
# where objdump gets run over the .o file, and anything else like that...
5
#
6
# When you write a test case that uses the listing output, just copy this
7
# file (trimming down the overly-verbose comments a little), and
8
# adjust it to do what you need.
9
#
10
# Remember that any ".exp" file found in the tree will be processed by
11
# dejagnu.
12
 
13
#
14
# FIRST SAMPLE TEST CASE
15
#
16
 
17
proc do_foo {} {
18
# This string is used below when printing out a success or failure message.
19
# If more than one test is run by a given .exp file, it'd be nice to include
20
# the name of the input file.
21
    set testname "foo.s: multi-register tweaking and frobnication"
22
 
23
# I use this as a flag to record whether the test case passed.  If this
24
# flag is still clear when EOF is reached, this test fails.  If there are
25
# two or more patterns, and I need to see all of them, I'll create N variables
26
# and check if the sum is N.
27
    set x 0
28
 
29
# Call gas_start with two arguments: The input file name (which it'll search
30
# for in $srcdir/$subdir, that is, the source directory where the .exp file
31
# is), and a (possibly empty) string of options to pass to the assembler.
32
    gas_start "foo.s" "-al"
33
 
34
# Now I just iterate over all the output lines, looking for what I want
35
# to see.  Since each pattern explicitly will not span line breaks, there's
36
# also a pattern for lines that don't match anything else.   (Is it safe to
37
# use ".*" for patterns not crossing line breaks? I don't think "$" does the
38
# right thing for that, in any case.  I should check into whether the extra
39
# pattern is even needed.
40
 
41
# Apparently CRLF is received when using ptys for subprocesses; hence the
42
# \r\n for matching line number 3.
43
 
44
# Note that if you use "{ ... }" for the expect clause, you can't have
45
# comments inside it.
46
 
47
# This test case is kinda bogus in that seeing either a word of all zeros
48
# at address zero or a C-style comment on line three that says "Looking for
49
# C comments" (with very specific punctuation and whitespace) will cause
50
# it to pass this test.  Usually
51
    while 1 {
52
        expect {
53
            -re "^ +\[0-9\]+ 0000 00000000\[^\n\]*\n"           { set x 1 }
54
            -re "^ +3\[ \t\]+/. Looking for C comments. ./\r\n" { set x 1 }
55
            -re "\[^\n\]*\n"                            { }
56
            timeout                             { perror "timeout\n"; break }
57
            eof                                 { break }
58
        }
59
    }
60
# This was intended to do any cleanup necessary.  It kinda looks like it isn't
61
# needed, but just in case, please keep it in for now.
62
    gas_finish
63
 
64
# Did we find what we were looking for?  If not, flunk it.
65
    if $x then { pass $testname } else { fail $testname }
66
}
67
 
68
# Now actually run the test.  It can be conditionalized if the test is
69
# not appropriate for all targets.  The proc "istarget" checks a generalized
70
# form of the target name, so that (e.g.) "m68332-unknown-aout" would match
71
# here.  So far, I think only the CPU name is actually ever altered.
72
if [istarget m68k-*] then {
73
    do_foo
74
}
75
 
76
 
77
 
78
 
79
#
80
# SECOND SAMPLE TEST CASE
81
#
82
 
83
# This is a tiny bit like the C compiler torture tests, in that it'll run
84
# the assembler with the power set of the list of options supplied.
85
#
86
# The first argument is the test file name; the second is arguments that
87
# are always to be provided; the third is a space-separated list of options
88
# which are optional (ending in ">" if output should be ignored, like "-a>");
89
# the fourth is the name of the test.  So far, only binary options are handled
90
# this way; N-way options (like CPU type for m68k) aren't handled yet.
91
#
92
# The variable $stdoptlist usually has a reasonable set of optional options
93
# for this target.
94
 
95
# No, PIC isn't supported yet.  This is only an example.
96
gas_test "quux.s" "-K" $stdoptlist "use of quuxes in PIC mode"

powered by: WebSVN 2.1.0

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