jjb: binutils-gdb: remove unneeded commands at the end
[lttng-ci.git] / scripts / binutils-gdb / build.sh
CommitLineData
91ba8aa1
MJ
1#!/bin/bash
2#
3# Copyright (C) 2021 Michael Jeanson <mjeanson@efficios.com>
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18set -exu
19
20failed_configure() {
21 # Assume we are in the configured build directory
22 echo "#################### BEGIN config.log ####################"
23 cat config.log
24 echo "#################### END config.log ####################"
25 exit 1
26}
27
28sum2junit() {
29 local infile="$1"
30 local outfile="$2"
31
bcd0bdf1
SM
32cat <<EOF > sum2junit.py
33import sys
34from datetime import datetime
35import re
36from xml.etree.ElementTree import ElementTree, Element, SubElement
37
38line_re = re.compile(
39 r"^(PASS|XPASS|FAIL|XFAIL|KFAIL|DUPLICATE|UNTESTED|UNSUPPORTED|UNRESOLVED): (.*?\.exp): (.*)"
40)
41
42pass_count = 0
43fail_count = 0
44skip_count = 0
45error_count = 0
46now = datetime.now().isoformat(timespec="seconds")
47
48testsuites = Element(
49 "testsuites",
50 {
51 "xmlns": "https://raw.githubusercontent.com/windyroad/JUnit-Schema/master/JUnit.xsd"
52 },
53)
54testsuite = SubElement(
55 testsuites,
56 "testsuite",
57 {
58 "name": "GDB",
59 "package": "package",
60 "id": "0",
61 "time": "1",
62 "timestamp": now,
63 "hostname": "hostname",
64 },
65)
66SubElement(testsuite, "properties")
67
68for line in sys.stdin:
69 m = line_re.match(line)
70 if not m:
71 continue
72
73 state, exp_filename, test_name = m.groups()
74
75 testcase_name = "{} - {}".format(exp_filename, test_name)
76
77 testcase = SubElement(
78 testsuite,
79 "testcase",
80 {"name": testcase_name, "classname": "classname", "time": "0"},
81 )
82
83 if state in ("PASS", "XFAIL", "KFAIL"):
84 pass_count += 1
85 elif state in ("FAIL", "XPASS"):
6e30c08a 86 print("{}: {}".format(state, testcase_name), file=sys.stderr)
bcd0bdf1
SM
87 fail_count += 1
88 SubElement(testcase, "failure", {"type": state})
89 elif state in ("UNRESOLVED", "DUPLICATE"):
6e30c08a 90 print("{}: {}".format(state, testcase_name), file=sys.stderr)
bcd0bdf1
SM
91 error_count += 1
92 SubElement(testcase, "error", {"type": state})
93 elif state in ("UNTESTED", "UNSUPPORTED"):
94 skip_count += 1
95 SubElement(testcase, "skipped")
96 else:
97 assert False
98
99testsuite.attrib["tests"] = str(pass_count + fail_count + skip_count)
100testsuite.attrib["failures"] = str(fail_count)
101testsuite.attrib["skipped"] = str(skip_count)
102testsuite.attrib["errors"] = str(error_count)
103
104SubElement(testsuite, "system-out")
105SubElement(testsuite, "system-err")
106
107et = ElementTree(testsuites)
108et.write(sys.stdout, encoding="unicode")
109
110sys.exit(1 if fail_count > 0 or error_count > 0 else 0)
91ba8aa1
MJ
111EOF
112
bcd0bdf1 113 python3 sum2junit.py < "$infile" > "$outfile"
91ba8aa1
MJ
114}
115
116# Required variables
117WORKSPACE=${WORKSPACE:-}
118
119arch=${arch:-}
120conf=${conf:-}
121build=${build:-}
91ba8aa1
MJ
122
123
124SRCDIR="$WORKSPACE/src/binutils-gdb"
125TMPDIR="$WORKSPACE/tmp"
126PREFIX="/build"
127
128# Create tmp directory
129rm -rf "$TMPDIR"
130mkdir -p "$TMPDIR"
131
132export TMPDIR
133export CFLAGS="-O2 -fsanitize=address"
134export CXXFLAGS="-O2 -fsanitize=address -D_GLIBCXX_DEBUG=1"
135export LDFLAGS="-fsanitize=address"
136
137# Set platform variables
138case "$arch" in
139*)
140 export MAKE=make
141 export TAR=tar
142 export NPROC=nproc
143 ;;
144esac
145
146# Print build env details
147print_os || true
148print_tooling || true
149
150# Enter the source directory
151cd "$SRCDIR"
152
153# Run bootstrap in the source directory prior to configure
154#./bootstrap
155
156# Get source version from configure script
157#eval "$(grep '^PACKAGE_VERSION=' ./configure)"
158#PACKAGE_VERSION=${PACKAGE_VERSION//\-pre*/}
159
160# Set configure options and environment variables for each build
161# configuration.
162CONF_OPTS=("--prefix=$PREFIX")
163
164case "$conf" in
165*)
166 echo "Standard configuration"
167
168 # Use system tools
169 CONF_OPTS+=("--disable-binutils" "--disable-ld" "--disable-gold" "--disable-gas" "--disable-sim" "--disable-gprof")
170
171 # Use system libs
172 CONF_OPTS+=("--with-system-readline" "--with-system-zlib")
173
174 # Enable optional features
175 CONF_OPTS+=("--enable-targets=all" "--with-expat=yes" "--with-python=python3" "--with-guile=guile-2.2" "--enable-libctf")
176
177 CONF_OPTS+=("--enable-build-warnings" "--enable-gdb-build-warnings" "--enable-unit-tests")
178
179 ;;
180esac
181
182# Build type
183# oot : out-of-tree build
184# dist : build via make dist
185# oot-dist: build via make dist out-of-tree
186# * : normal tree build
187#
188# Make sure to move to the build directory and run configure
189# before continuing.
190case "$build" in
191*)
192 echo "Out of tree build"
193
194 # Create and enter a temporary build directory
195 builddir=$(mktemp -d)
196 cd "$builddir"
197
198 "$SRCDIR/configure" "${CONF_OPTS[@]}" || failed_configure
199 ;;
200esac
201
202# We are now inside a configured build directory
203
204# BUILD!
205$MAKE -j "$($NPROC)" V=1 MAKEINFO=/bin/true
206
207# Install in the workspace
208$MAKE install DESTDIR="$WORKSPACE"
209
bcd0bdf1
SM
210# Run tests, don't fail now, we know that "make check" is going to fail,
211# since some tests don't pass.
f381084f 212$MAKE -C gdb --keep-going check -j "$($NPROC)" || true
91ba8aa1
MJ
213
214# Copy the dejagnu test results for archiving before cleaning the build dir
215mkdir "${WORKSPACE}/results"
f5dbc8e5 216cp gdb/testsuite/gdb.log "${WORKSPACE}/results/"
91ba8aa1 217cp gdb/testsuite/gdb.sum "${WORKSPACE}/results/"
bcd0bdf1 218
795db243
SM
219# Filter out some known failures.
220cat <<'EOF' > known-failures
221DUPLICATE: gdb.base/attach-pie-misread.exp: copy ld-2.27.so to ld-linux-x86-64.so.2
222DUPLICATE: gdb.base/attach-pie-misread.exp: copy libc-2.27.so to libc.so.6
223DUPLICATE: gdb.base/attach-pie-misread.exp: ldd attach-pie-misread
224DUPLICATE: gdb.base/attach-pie-misread.exp: ldd attach-pie-misread output contains libs
225DUPLICATE: gdb.base/call-signal-resume.exp: dummy stack frame number
226DUPLICATE: gdb.base/call-signal-resume.exp: return
227DUPLICATE: gdb.base/call-signal-resume.exp: set confirm off
228DUPLICATE: gdb.base/catch-signal.exp: 1: continue
229DUPLICATE: gdb.base/catch-signal.exp: SIGHUP: continue
230DUPLICATE: gdb.base/catch-signal.exp: SIGHUP SIGUSR2: continue
231DUPLICATE: gdb.base/checkpoint.exp: restart 0 one
232DUPLICATE: gdb.base/checkpoint.exp: verify lines 5 two
233DUPLICATE: gdb.base/checkpoint-ns.exp: restart 0 one
234DUPLICATE: gdb.base/checkpoint-ns.exp: verify lines 5 two
235DUPLICATE: gdb.base/complete-empty.exp: empty-input-line: cmd complete ""
236DUPLICATE: gdb.base/corefile-buildid.exp: could not generate core file
237DUPLICATE: gdb.base/decl-before-def.exp: p a
238DUPLICATE: gdb.base/define-prefix.exp: define user command: ghi-prefix-cmd
239DUPLICATE: gdb.base/del.exp: info break after removing break on main
240DUPLICATE: gdb.base/dfp-exprs.exp: p 1.2dl < 1.3df
241DUPLICATE: gdb.base/dfp-test.exp: 1.23E45A is an invalid number
242DUPLICATE: gdb.base/dfp-test.exp: 1.23E is an invalid number
243DUPLICATE: gdb.base/exprs.exp: \$[0-9]* = red (setup)
244DUPLICATE: gdb.base/funcargs.exp: run to call2a
245DUPLICATE: gdb.base/interp.exp: interpreter-exec mi "-var-update *"
246DUPLICATE: gdb.base/miscexprs.exp: print value of !ibig.i[100]
247DUPLICATE: gdb.base/nested-subp2.exp: continue to the STOP marker
248DUPLICATE: gdb.base/nested-subp2.exp: print c
249DUPLICATE: gdb.base/nested-subp2.exp: print count
250DUPLICATE: gdb.base/pending.exp: disable other breakpoints
251DUPLICATE: gdb.base/pie-fork.exp: test_no_detach_on_fork: continue
252DUPLICATE: gdb.base/pointers.exp: pointer assignment
253DUPLICATE: gdb.base/pretty-array.exp: print nums
254DUPLICATE: gdb.base/ptype.exp: list charfoo
255DUPLICATE: gdb.base/ptype.exp: list intfoo
256DUPLICATE: gdb.base/ptype.exp: ptype the_highest
257DUPLICATE: gdb.base/readline.exp: Simple operate-and-get-next - final prompt
258DUPLICATE: gdb.base/realname-expand.exp: set basenames-may-differ on
259DUPLICATE: gdb.base/set-cwd.exp: test_cwd_reset: continue to breakpoint: break-here
260DUPLICATE: gdb.base/shlib-call.exp: continue until exit
261DUPLICATE: gdb.base/shlib-call.exp: print g
262DUPLICATE: gdb.base/shlib-call.exp: set print address off
263DUPLICATE: gdb.base/shlib-call.exp: set print sevenbit-strings
264DUPLICATE: gdb.base/shlib-call.exp: set width 0
265DUPLICATE: gdb.base/solib-display.exp: IN: break 25
266DUPLICATE: gdb.base/solib-display.exp: IN: continue
267DUPLICATE: gdb.base/solib-display.exp: NO: break 25
268DUPLICATE: gdb.base/solib-display.exp: NO: continue
269DUPLICATE: gdb.base/solib-display.exp: SEP: break 25
270DUPLICATE: gdb.base/solib-display.exp: SEP: continue
271DUPLICATE: gdb.base/stack-checking.exp: bt
272DUPLICATE: gdb.base/subst.exp: unset substitute-path from, no rule entered yet
273DUPLICATE: gdb.base/ui-redirect.exp: redirect while already logging: set logging redirect off
274DUPLICATE: gdb.base/unload.exp: continuing to unloaded libfile
275DUPLICATE: gdb.base/watchpoints.exp: watchpoint hit, first time
276DUPLICATE: gdb.mi/mi2-amd64-entry-value.exp: breakpoint at main
277DUPLICATE: gdb.mi/mi2-amd64-entry-value.exp: mi runto main
278DUPLICATE: gdb.mi/mi2-var-child.exp: get children of psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr
279DUPLICATE: gdb.mi/mi2-var-child.exp: get children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr
280DUPLICATE: gdb.mi/mi2-var-child.exp: get children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr
281DUPLICATE: gdb.mi/mi2-var-child.exp: get number of children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr
282DUPLICATE: gdb.mi/mi-catch-cpp-exceptions.exp: breakpoint at main
283DUPLICATE: gdb.mi/mi-catch-cpp-exceptions.exp: mi runto main
284DUPLICATE: gdb.mi/mi-catch-load.exp: breakpoint at main
285DUPLICATE: gdb.mi/mi-catch-load.exp: mi runto main
286DUPLICATE: gdb.mi/mi-language.exp: set lang ada
287DUPLICATE: gdb.mi/mi-nonstop-exit.exp: breakpoint at main
288DUPLICATE: gdb.mi/mi-nonstop-exit.exp: mi runto main
289DUPLICATE: gdb.mi/mi-nonstop.exp: check varobj, w1, 1
290DUPLICATE: gdb.mi/mi-nonstop.exp: stacktrace of stopped thread
291DUPLICATE: gdb.mi/mi-nsthrexec.exp: breakpoint at main
292DUPLICATE: gdb.mi/mi-syn-frame.exp: finished exec continue
293DUPLICATE: gdb.mi/mi-syn-frame.exp: list stack frames
294DUPLICATE: gdb.mi/mi-var-child.exp: get children of psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr
295DUPLICATE: gdb.mi/mi-var-child.exp: get children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr
296DUPLICATE: gdb.mi/mi-var-child.exp: get children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr
297DUPLICATE: gdb.mi/mi-var-child.exp: get number of children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr
298DUPLICATE: gdb.mi/mi-var-cp.exp: create varobj for s
299DUPLICATE: gdb.mi/mi-var-rtti.exp: list children of ptr.Base.public (with RTTI) in use_rtti_with_multiple_inheritence
300DUPLICATE: gdb.mi/mi-var-rtti.exp: list children of ptr.public (without RTTI) in skip_type_update_when_not_use_rtti
301DUPLICATE: gdb.mi/mi-var-rtti.exp: list children of ptr (without RTTI) in skip_type_update_when_not_use_rtti
302DUPLICATE: gdb.mi/mi-var-rtti.exp: list children of s.ptr.public (without RTTI) in skip_type_update_when_not_use_rtti
303DUPLICATE: gdb.mi/mi-var-rtti.exp: list children of s.ptr (without RTTI) in skip_type_update_when_not_use_rtti
304DUPLICATE: gdb.mi/mi-watch.exp: mi-mode=main: wp-type=hw: watchpoint trigger
305DUPLICATE: gdb.mi/mi-watch.exp: mi-mode=main: wp-type=sw: watchpoint trigger
306DUPLICATE: gdb.mi/mi-watch.exp: mi-mode=separate: wp-type=hw: watchpoint trigger
307DUPLICATE: gdb.mi/mi-watch.exp: mi-mode=separate: wp-type=sw: watchpoint trigger
308FAIL: gdb.ada/interface.exp: print s
309FAIL: gdb.ada/iwide.exp: print d_access.all
310FAIL: gdb.ada/iwide.exp: print dp_access.all
311FAIL: gdb.ada/iwide.exp: print My_Drawable
312FAIL: gdb.ada/iwide.exp: print s_access.all
313FAIL: gdb.ada/iwide.exp: print sp_access.all
314FAIL: gdb.ada/mi_interface.exp: create ggg1 varobj (unexpected output)
315FAIL: gdb.ada/mi_interface.exp: list ggg1's children (unexpected output)
316FAIL: gdb.ada/tagged_access.exp: ptype c.all
317FAIL: gdb.ada/tagged_access.exp: ptype c.menu_name
318FAIL: gdb.ada/tagged.exp: print obj
319FAIL: gdb.ada/tagged.exp: ptype obj
320FAIL: gdb.base/bt-on-fatal-signal.exp: BUS: $saw_bt_end
321FAIL: gdb.base/bt-on-fatal-signal.exp: BUS: $saw_bt_start
322FAIL: gdb.base/bt-on-fatal-signal.exp: BUS: $saw_fatal_msg
323FAIL: gdb.base/bt-on-fatal-signal.exp: BUS: [expr $internal_error_msg_count == 2]
324FAIL: gdb.base/bt-on-fatal-signal.exp: FPE: $saw_bt_end
325FAIL: gdb.base/bt-on-fatal-signal.exp: FPE: $saw_bt_start
326FAIL: gdb.base/bt-on-fatal-signal.exp: FPE: $saw_fatal_msg
327FAIL: gdb.base/bt-on-fatal-signal.exp: FPE: [expr $internal_error_msg_count == 2]
328FAIL: gdb.base/bt-on-fatal-signal.exp: SEGV: $saw_bt_end
329FAIL: gdb.base/bt-on-fatal-signal.exp: SEGV: $saw_bt_start
330FAIL: gdb.base/bt-on-fatal-signal.exp: SEGV: $saw_fatal_msg
331FAIL: gdb.base/bt-on-fatal-signal.exp: SEGV: [expr $internal_error_msg_count == 2]
332FAIL: gdb.base/share-env-with-gdbserver.exp: strange named var: print result of getenv for 'asd ='
eb8ae82a 333FAIL: gdb.base/step-over-syscall.exp: clone: displaced=off: single step over clone
795db243 334FAIL: gdb.cp/no-dmgl-verbose.exp: setting breakpoint at 'f(std::string)'
eb8ae82a 335FAIL: gdb.dwarf2/dw2-inline-param.exp: running to *0x608 in runto
795db243
SM
336FAIL: gdb.gdb/python-interrupts.exp: run until breakpoint at captured_command_loop
337FAIL: gdb.mi/mi-break.exp: mi-mode=main: test_explicit_breakpoints: -break-insert -c "foo == 3" --source basics.c --function main --label label (unexpected output)
338FAIL: gdb.mi/mi-break.exp: mi-mode=main: test_explicit_breakpoints: -break-insert --source basics.c --function foobar (unexpected output)
339FAIL: gdb.mi/mi-break.exp: mi-mode=main: test_explicit_breakpoints: -break-insert --source basics.c --function main --label foobar (unexpected output)
340FAIL: gdb.mi/mi-break.exp: mi-mode=main: test_explicit_breakpoints: -break-insert --source basics.c (unexpected output)
341FAIL: gdb.mi/mi-break.exp: mi-mode=separate: test_explicit_breakpoints: -break-insert -c "foo == 3" --source basics.c --function main --label label (unexpected output)
342FAIL: gdb.mi/mi-break.exp: mi-mode=separate: test_explicit_breakpoints: -break-insert --source basics.c --function foobar (unexpected output)
343FAIL: gdb.mi/mi-break.exp: mi-mode=separate: test_explicit_breakpoints: -break-insert --source basics.c --function main --label foobar (unexpected output)
344FAIL: gdb.mi/mi-break.exp: mi-mode=separate: test_explicit_breakpoints: -break-insert --source basics.c (unexpected output)
345FAIL: gdb.mi/mi-breakpoint-changed.exp: test_auto_disable: -break-enable count 1 2 (unexpected output)
346FAIL: gdb.mi/mi-breakpoint-changed.exp: test_auto_disable: -break-insert -f pendfunc1 (unexpected output)
eb8ae82a 347FAIL: gdb.threads/detach-step-over.exp: breakpoint-condition-evaluation=host: target-non-stop=on: non-stop=on: displaced=off: iter 3: attach (GDB internal error)
795db243
SM
348UNRESOLVED: gdb.base/libsegfault.exp: gdb emits custom handler warning
349UNRESOLVED: gdb.base/readline-ask.exp: bell for more message
350UNRESOLVED: gdb.base/symbol-without-target_section.exp: list -q main
351UNRESOLVED: gdb.dwarf2/dw2-icc-opaque.exp: ptype p_struct
eb8ae82a
SM
352UNRESOLVED: gdb.opencl/vec_comps.exp: OpenCL support not detected
353UNRESOLVED: gdb.threads/attach-many-short-lived-threads.exp: iter 8: detach
795db243
SM
354EOF
355
356grep --invert-match --fixed-strings --file=known-failures "${WORKSPACE}/results/gdb.sum" > "${WORKSPACE}/results/gdb.filtered.sum"
357
bcd0bdf1
SM
358# Convert results to JUnit format.
359failed_tests=0
795db243 360sum2junit "${WORKSPACE}/results/gdb.filtered.sum" "${WORKSPACE}/results/gdb.xml" || failed_tests=1
91ba8aa1
MJ
361
362# Clean the build directory
363$MAKE clean
364
91ba8aa1
MJ
365# Exit with failure if any of the tests failed
366exit $failed_tests
367
368# EOF
This page took 0.038933 seconds and 4 git commands to generate.