File: template

package info (click to toggle)
binutils 2.32.51.20190821-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 309,676 kB
  • sloc: ansic: 1,201,497; asm: 658,869; cpp: 130,432; exp: 69,370; makefile: 56,804; sh: 23,583; lisp: 14,519; yacc: 14,467; perl: 2,111; ada: 1,681; lex: 1,649; pascal: 1,446; python: 991; cs: 879; sed: 195; xml: 95; awk: 25
file content (96 lines) | stat: -rw-r--r-- 3,804 bytes parent folder | download | duplicates (50)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#
# This is sort of a prototype test case, which parses the listing output
# from the assembler.  Later, more prototypes should be added for cases
# where objdump gets run over the .o file, and anything else like that...
#
# When you write a test case that uses the listing output, just copy this
# file (trimming down the overly-verbose comments a little), and
# adjust it to do what you need.
#
# Remember that any ".exp" file found in the tree will be processed by
# dejagnu.

#
# FIRST SAMPLE TEST CASE
#

proc do_foo {} {
# This string is used below when printing out a success or failure message.
# If more than one test is run by a given .exp file, it'd be nice to include
# the name of the input file.
    set testname "foo.s: multi-register tweaking and frobnication"

# I use this as a flag to record whether the test case passed.  If this
# flag is still clear when EOF is reached, this test fails.  If there are
# two or more patterns, and I need to see all of them, I'll create N variables
# and check if the sum is N.
    set x 0

# Call gas_start with two arguments: The input file name (which it'll search
# for in $srcdir/$subdir, that is, the source directory where the .exp file
# is), and a (possibly empty) string of options to pass to the assembler.
    gas_start "foo.s" "-al"

# Now I just iterate over all the output lines, looking for what I want
# to see.  Since each pattern explicitly will not span line breaks, there's
# also a pattern for lines that don't match anything else.   (Is it safe to
# use ".*" for patterns not crossing line breaks? I don't think "$" does the
# right thing for that, in any case.  I should check into whether the extra
# pattern is even needed.

# Apparently CRLF is received when using ptys for subprocesses; hence the
# \r\n for matching line number 3.

# Note that if you use "{ ... }" for the expect clause, you can't have
# comments inside it.

# This test case is kinda bogus in that seeing either a word of all zeros
# at address zero or a C-style comment on line three that says "Looking for
# C comments" (with very specific punctuation and whitespace) will cause
# it to pass this test.  Usually 
    while 1 {
	expect {
	    -re "^ +\[0-9\]+ 0000 00000000\[^\n\]*\n"		{ set x 1 }
	    -re "^ +3\[ \t\]+/. Looking for C comments. ./\r\n"	{ set x 1 }
	    -re "\[^\n\]*\n"				{ }
	    timeout				{ perror "timeout\n"; break }
	    eof					{ break }
	}
    }
# This was intended to do any cleanup necessary.  It kinda looks like it isn't
# needed, but just in case, please keep it in for now.
    gas_finish

# Did we find what we were looking for?  If not, flunk it.
    if $x then { pass $testname } else { fail $testname }
}

# Now actually run the test.  It can be conditionalized if the test is
# not appropriate for all targets.  The proc "istarget" checks a generalized
# form of the target name, so that (e.g.) "m68332-unknown-aout" would match
# here.  So far, I think only the CPU name is actually ever altered.
if [istarget m68k-*] then {
    do_foo
}




#
# SECOND SAMPLE TEST CASE
#

# This is a tiny bit like the C compiler torture tests, in that it'll run
# the assembler with the power set of the list of options supplied.
#
# The first argument is the test file name; the second is arguments that
# are always to be provided; the third is a space-separated list of options
# which are optional (ending in ">" if output should be ignored, like "-a>");
# the fourth is the name of the test.  So far, only binary options are handled
# this way; N-way options (like CPU type for m68k) aren't handled yet.
#
# The variable $stdoptlist usually has a reasonable set of optional options
# for this target.

# No, PIC isn't supported yet.  This is only an example.
gas_test "quux.s" "-K" $stdoptlist "use of quuxes in PIC mode"