Print this page
10816 ctf_dwarf_convert_type() relies on un-initialized id
10817 ctfconvert -i option is mis-handled
10818 Improve ctfconvert error messages
10819 ctfconvert should handle empty dies
10820 ctfconvert -i never converts
10821 bad free in ctf_dwarf_init_die
10815 shouldn't build gcore.c as part of kmdb
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/test/util-tests/tests/ctf/ctftest.ksh
+++ new/usr/src/test/util-tests/tests/ctf/ctftest.ksh
1 1 #!/usr/bin/ksh
2 2 #
3 3 #
4 4 # This file and its contents are supplied under the terms of the
5 5 # Common Development and Distribution License ("CDDL"), version 1.0.
6 6 # You may only use this file in accordance with the terms of version
7 7 # 1.0 of the CDDL.
8 8 #
9 9 # A full copy of the text of the CDDL should have accompanied this
10 10 # source. A copy of the CDDL is also available via the Internet at
11 11 # http://www.illumos.org/license/CDDL.
12 12 #
13 13
14 14 #
15 15 # Copyright (c) 2019, Joyent, Inc.
16 16 #
17 17
18 18 #
↓ open down ↓ |
18 lines elided |
↑ open up ↑ |
19 19 # Run all of the various CTF tests
20 20 #
21 21
22 22 unalias -a
23 23 #set -o xtrace
24 24
25 25 if [[ -z "$TMPDIR" ]]; then
26 26 TMPDIR="/tmp"
27 27 fi
28 28
29 +
29 30 ctf_arg0=$(basename $0)
30 31 ctf_root=$(cd $(dirname $0) && echo $PWD)
31 32 ctf_tests=
32 -ctf_compiler="gcc"
33 +ctf_cc="gcc"
34 +ctf_cxx="g++"
35 +ctf_as="as"
33 36 ctf_convert="ctfconvert"
34 37 ctf_merge="ctfmerge"
35 38 ctf_debugflags="-gdwarf-2 "
36 39 ctf_mach32="-m32"
37 40 ctf_mach64="-m64"
38 -ctf_32cflags="$ctf_mach32 $ctf_debugflags"
39 -ctf_64cflags="$ctf_mach64 $ctf_debugflags"
40 41 ctf_temp="$TMPDIR/ctftest.$$.o"
41 42 ctf_makefile="Makefile.ctftest"
42 43 ctf_nerrs=0
43 44
44 45 usage()
45 46 {
46 47 typeset msg="$*"
47 48 [[ -z "$msg" ]] || echo "$msg" >&2
48 49 cat <<USAGE >&2
49 -Usage: $ctf_arg0 [-c compiler] [-g flags] [-m ctfmerge] [-t ctfconvert]
50 +Usage: $ctf_arg0 [-a as] [-c cc] [-C CC] [-g flags] [-m ctfmerge] [-t ctfconvert]
50 51
51 52 Runs the CTF test suite
52 53
53 - -c compiler Use the specified compiler, defaults to 'gcc'
54 - on path.
54 + -a assembler Use the specified assembler, defaults to 'as'
55 + -c compiler Use the specified C compiler, defaults to 'gcc'
56 + -C compiler Use the specified C++ compiler, defaults to 'g++'
55 57 -g flags Use flags to generate debug info. Defaults to
56 58 "-gdwarf-2".
57 59 -m ctfmerge Use the specified ctfmerge, defaults to
58 - 'ctfmerge' on path.
60 + 'ctfmerge'
59 61 -t ctfconvert Use the specified ctfconvert, defaults to
60 - 'ctfconvert' on path.
62 + 'ctfconvert'
61 63 USAGE
62 64 exit 2
63 65 }
64 66
65 67
66 68 test_fail()
67 69 {
68 70 typeset msg="$*"
69 71 [[ -z "$msg" ]] && msg="failed"
70 72 echo "TEST FAILED: $msg" >&2
71 73 ((ctf_nerrs++))
72 74 }
↓ open down ↓ |
2 lines elided |
↑ open up ↑ |
73 75
74 76 fatal()
75 77 {
76 78 typeset msg="$*"
77 79 [[ -z "$msg" ]] && msg="failed"
78 80 echo "$ctf_arg0: $msg" >&2
79 81 rm -f "$ctf_tmp32" "$ctf_temp64"
80 82 exit 1
81 83 }
82 84
83 -check_env()
84 -{
85 - if which "$1" 2>/dev/null >/dev/null; then
86 - return
87 - fi
88 -
89 - [[ -f "$1" ]] || fatal "failed to find tool $1"
90 -}
91 -
92 85 announce()
93 86 {
94 87 cat << EOF
95 88 Beginning CTF tests with the following settings:
96 -COMPILER: $(which $ctf_compiler)
97 -CTFCONVERT: $(which $ctf_convert)
98 -CTFMERGE: $(which $ctf_merge)
89 +cc: $(which $ctf_cc)
90 +CC: $(which $ctf_cxx)
91 +as: $(which $ctf_as)
92 +ctfconvert: $(which $ctf_convert)
93 +ctfmerge: $(which $ctf_merge)
99 94 32-bit CFLAGS: $ctf_32cflags
100 95 64-bit CFLAGS: $ctf_64cflags
101 96
102 97 EOF
103 98 }
104 99
105 100 run_one()
106 101 {
107 102 typeset source=$1 checker=$2 flags=$3
108 103
109 - if ! "$ctf_compiler" $flags -o "$ctf_temp" -c "$source"; then
104 + if ! "$ctf_cc" $flags -o "$ctf_temp" -c "$source"; then
110 105 test_fail "failed to compile $source with flags: $flags"
111 106 return
112 107 fi
113 108
114 109 if ! "$ctf_convert" "$ctf_temp"; then
115 110 test_fail "failed to convert CTF in $source"
116 111 return
117 112 fi
118 113
119 114 if ! "$checker" "$ctf_temp"; then
120 115 test_fail "check for $source, $checker, failed"
121 116 return
122 117 fi
123 118
124 119 echo "TEST PASSED: $source $flags"
125 120 }
126 121
127 122 #
128 123 # Perform a more complex build. The Makefile present will drive the
129 124 # building of the artifacts and the running of the tests based on the
130 125 # variables that we pass to it.
131 126 #
132 127 run_dir()
133 128 {
134 129 typeset dir outdir check32 check64 flags32 flags64
135 130
136 131 dir=$1
137 132 outdir="$TMPDIR/ctftest.$$-$(basename $d)"
138 133 check32=$2
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
139 134 flags32=$3
140 135 check64=$4
141 136 flags64=$5
142 137
143 138 if ! mkdir $outdir; then
144 139 fatal "failed to make temporary directory '$outdir'"
145 140 fi
146 141
147 142 if ! make -C $dir -f Makefile.ctftest \
148 143 BUILDDIR="$outdir" \
149 - CC="$ctf_compiler" \
144 + CC="$ctf_cc" \
150 145 CFLAGS32="$ctf_mach32" \
151 146 CFLAGS64="$ctf_mach64" \
152 147 DEBUGFLAGS="$ctf_debugflags" \
153 148 CTFCONVERT="$ctf_convert" \
154 149 CTFMERGE="$ctf_merge" \
155 150 build 1>/dev/null; then
156 151 rm -rf $outdir
157 152 test_fail "failed to build $dir"
158 153 return
159 154 fi
160 155
161 156 if ! make -C $dir -f Makefile.ctftest \
162 157 BUILDDIR="$outdir" \
163 158 CHECK32="$check32" \
164 159 CHECK64="$check64" \
165 160 run-test 1>/dev/null; then
166 161 rm -rf $outdir
167 162 test_fail "failed to run tests for $dir"
168 163 return
169 164 fi
170 165
171 166 rm -rf $outdir
172 167 echo "TEST PASSED: $dir (dir)"
173 168 }
174 169
175 170 #
176 171 # Find all of the tests that exist and then try to run them all. Tests
177 172 # may either be a single file or a directory.
178 173 #
179 174 run_tests()
180 175 {
181 176 typeset t base check
182 177 ctf_tests=$(ls "$ctf_root"/*.c)
183 178 for t in $ctf_tests; do
184 179 base=$(basename "$t" .c)
185 180 check=$(echo "$base" | sed s/test-/check-/)
186 181 if [[ -f "$ctf_root/$check" ]]; then
187 182 run_one $t "$ctf_root/$check" "$ctf_32cflags"
188 183 run_one $t "$ctf_root/$check" "$ctf_64cflags"
189 184 elif [[ -f "$ctf_root/$check-32" && \
190 185 -f "$ctf_root/$check-64" ]]; then
191 186 run_one $t "$ctf_root/$check-32" "$ctf_32cflags"
192 187 run_one $t "$ctf_root/$check-64" "$ctf_64cflags"
193 188 else
194 189 test_fail "missing checker for $t"
195 190 fi
196 191 done
197 192
198 193 for d in $(find "$ctf_root" -maxdepth 1 -type d -name 'test-*'); do
199 194 [[ ! -f "$d/$ctf_makefile" ]] && continue
200 195 base=$(basename "$d")
201 196 check=$(echo "$base" | sed s/test-/check-/)
202 197 if [[ -f "$ctf_root/$check" ]]; then
↓ open down ↓ |
43 lines elided |
↑ open up ↑ |
203 198 run_dir $d "$ctf_root/$check" "$ctf_32cflags" \
204 199 "$ctf_root/$check" "$ctf_64cflags"
205 200 elif [[ -f "$ctf_root/$check-32" && \
206 201 -f "$ctf_root/$check-64" ]]; then
207 202 run_dir $d "$ctf_root/$check-32" "$ctf_32cflags" \
208 203 "$ctf_root/$check-64" "$ctf_64cflags"
209 204 else
210 205 test_fail "missing checker for $t"
211 206 fi
212 207 done
208 +
209 + outdir="$TMPDIR/ctftest.$$"
210 +
211 + for f in $(find "$ctf_root" -maxdepth 1 -type f -name 'ctftest-*'); do
212 + if ! mkdir $outdir; then
213 + fatal "failed to make temporary directory '$outdir'"
214 + fi
215 +
216 + echo "Running $f in $outdir"
217 +
218 + (cd $outdir && $f)
219 +
220 + if [[ $? -ne 0 ]]; then
221 + test_fail "$f failed"
222 + else
223 + echo "TEST PASSED: $f"
224 + fi
225 +
226 + rm -rf $outdir
227 + done
213 228 }
214 229
215 -while getopts ":c:g:m:t:" c $@; do
230 +while getopts ":a:C:c:g:m:t:" c $@; do
216 231 case "$c" in
232 + a)
233 + ctf_as=$OPTARG
234 + ;;
235 + C)
236 + ctf_cxx=$OPTARG
237 + ;;
217 238 c)
218 - ctf_compiler=$OPTARG
239 + ctf_cc=$OPTARG
219 240 ;;
220 241 g)
221 242 ctf_debugflags=$OPTARG
222 243 ;;
223 244 m)
224 245 ctf_merge=$OPTARG
225 246 ;;
226 247 t)
227 248 ctf_convert=$OPTARG
228 249 ;;
229 250 :)
230 251 usage "option requires an argument -- $OPTARG"
↓ open down ↓ |
2 lines elided |
↑ open up ↑ |
231 252 ;;
232 253 *)
233 254 usage "invalid option -- $OPTARG"
234 255 ;;
235 256 esac
236 257 done
237 258
238 259 ctf_32cflags="$ctf_mach32 $ctf_debugflags"
239 260 ctf_64cflags="$ctf_mach64 $ctf_debugflags"
240 261
241 -check_env "$ctf_compiler"
242 -check_env "$ctf_convert"
243 -check_env "$ctf_merge"
262 +export ctf_as ctf_cc ctf_cxx ctf_debugflags ctf_merge ctf_convert
263 +
244 264 announce
245 265
246 266 run_tests
247 267
248 268 if [[ $ctf_nerrs -ne 0 ]]; then
249 269 if [[ $ctf_nerrs -eq 1 ]]; then
250 270 printf "\n%s: %u test failed\n" "$ctf_arg0" "$ctf_nerrs"
251 271 else
252 272 printf "\n%s: %u tests failed\n" "$ctf_arg0" "$ctf_nerrs"
253 273 fi
274 + exit 1
254 275 else
255 276 printf "\n%s: All tests passed successfully\n" "$ctf_arg0"
256 277 exit 0
257 278 fi
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX