summaryrefslogtreecommitdiff
path: root/agen5/test/debug.test
blob: d83216fd83ddca0bdc10b855cf1a304a9f47dbcc (plain)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#! /bin/sh
#  -*- Mode: Shell-script -*-
# debug.test --- definition reference testing
#
# Time-stamp:        "2012-04-07 09:45:03 bkorb"
# Author:            Bruce Korb <bkorb@gnu.org>
#
## This file is part of AutoGen.
## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
##
## AutoGen is free software: you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## AutoGen is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
## See the GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License along
## with this program.  If not, see <http://www.gnu.org/licenses/>.

. ./defs

# # # # # # # # # # TEMPLATE FILE # # # # # # # # #

cat > ${testname}.tpl <<_EOF_
<= AutoGen5 template test =>
The last of each list:<=
FOR list =><= DEBUG slot 64 =>
  LAST -> <= val[$] =>

  list -> <=
  FOR val ", " =><= DEBUG bucket 128 => val[<=(for-index)=>]=<=val=><=
  ENDFOR =><=
ENDFOR =>
_EOF_

# # # # # # # # # # DEFINITIONS FILE # # # # # # # # #

# Create the files we need in the test environment
cat > ${testname}.def <<_EOF_
AutoGen definitions "${testname}." "tpl";
list =    { val = L0.first, L0.last; };
List[3] = { val = L3.third.all; };
_EOF_

# # # # # # # # # # ANTICIPATED RESULTS # # # # # # # # #

cat > ${testname}.base1 <<\_EOF_

eval from file agInit.c line XXX:
(debug-enable 'backtrace)
Definition Load:
list[0] (block) from debug.def/2
  val[0] (text) from debug.def/2
  val[1] (text) from debug.def/2
list[3] (block) from debug.def/3
  val[0] (text) from debug.def/3
marker ``<='' loaded
marker ``=>'' loaded
Starting test template
open_output_file 'debug.test' mode wb+
Text       (15) in debug.tpl at line 2
  The last of each list:
FOR        ( F) in debug.tpl at line 3
FOR list loop in debug.tpl on line 3 begins:
DEBUG      ( 5) in debug.tpl at line 3
  slot 64
  --  DEBUG slot 64 -- FOR index 0
Text       (15) in debug.tpl at line 3
  
Unknown    (16) in debug.tpl at line 4
remapped to 'Expr' (16) in debug.tpl at line 4
	based on val[$]
Text       (15) in debug.tpl at line 4
  
FOR        ( F) in debug.tpl at line 7
  , 
FOR val loop in debug.tpl on line 7 begins:
DEBUG      ( 5) in debug.tpl at line 7
  bucket 128
  --  DEBUG bucket 128 -- FOR index 0
Text       (15) in debug.tpl at line 7
   val[
EXPR       ( E) in debug.tpl at line 7
  (for-index)
eval from file debug.tpl line 7:
(for-index)
Text       (15) in debug.tpl at line 7
  ]=
Unknown    (16) in debug.tpl at line 7
remapped to 'Expr' (16) in debug.tpl at line 7
	based on val
DEBUG      ( 5) in debug.tpl at line 7
  bucket 128
  --  DEBUG bucket 128 -- FOR index 1
Text       (15) in debug.tpl at line 7
   val[
EXPR       ( E) in debug.tpl at line 7
  (for-index)
eval from file debug.tpl line 7:
(for-index)
Text       (15) in debug.tpl at line 7
  ]=
EXPR       ( E) in debug.tpl at line 7
FOR val repeated 2 times
	from debug.tpl line 7
DEBUG      ( 5) in debug.tpl at line 3
  slot 64
  --  DEBUG slot 64 -- FOR index 3
Text       (15) in debug.tpl at line 3
  
EXPR       ( E) in debug.tpl at line 4
Text       (15) in debug.tpl at line 4
  
FOR        ( F) in debug.tpl at line 7
  , 
FOR val loop in debug.tpl on line 7 begins:
DEBUG      ( 5) in debug.tpl at line 7
  bucket 128
  --  DEBUG bucket 128 -- FOR index 0
Text       (15) in debug.tpl at line 7
   val[
EXPR       ( E) in debug.tpl at line 7
  (for-index)
eval from file debug.tpl line 7:
(for-index)
Text       (15) in debug.tpl at line 7
  ]=
EXPR       ( E) in debug.tpl at line 7
FOR val repeated 1 times
	from debug.tpl line 7
FOR list repeated 2 times
	from debug.tpl line 3
Text       (15) in debug.tpl at line 9
  
out_close 'debug.test'
_EOF_

traceout=${testname}-aglog-x1-$$.log

if ${VERBOSE}
then trace_args=''
else trace_args=--trace=everything\ --trace-out=${traceout}
fi

run_ag x1 ${trace_args} ${testname}.def || failure AutoGen failed
${SED} -e 's@from file .*agInit.*@from file agInit.c line XXX:@' \
    -e '/Called ag_scm_for_index/d' \
    -e '/^AutoGen [0-9]* starts:/d' \
    ${traceout} > ${testname}.trace1
cmp -s ${testname}.base1 ${testname}.trace1 || \
  failure "`diff -c ${testname}.base1 ${testname}.trace1`"

${VERBOSE} || {
    traceout=${testname}-aglog-x2-$$.log
    trace_args=--trace-out=${traceout}
    run_ag x2 ${trace_args} ${testname}.def || failure AutoGen failed
    test -f ${traceout} -a -s ${traceout} && \
        failure "autogen produced trace output"
}

cleanup

## 
## Local Variables:
## mode: shell-script
## indent-tabs-mode: nil
## sh-indentation: 2
## sh-basic-offset: 2
## End:

# end of debug.test