]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/lib/opencl.exp
Update copyright year range in all GDB files
[thirdparty/binutils-gdb.git] / gdb / testsuite / lib / opencl.exp
CommitLineData
3666a048 1# Copyright 2010-2021 Free Software Foundation, Inc.
f4b8a18d
KW
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15#
16# Contributed by Ken Werner <ken.werner@de.ibm.com>.
17#
18# Support library for testing OpenCL GDB features
19
20# Compile OpenCL programs using a generic host app.
21proc gdb_compile_opencl_hostapp {clsource executable options} {
22 global srcdir objdir subdir
23 set src "${srcdir}/lib/cl_util.c ${srcdir}/lib/opencl_hostapp.c"
aa480355 24 set binfile [standard_output_file ${executable}]
f4b8a18d
KW
25 set compile_flags [concat additional_flags=-I${srcdir}/lib/ additional_flags=-DCL_SOURCE=$clsource]
26 set options_opencl [concat {debug} $compile_flags $options [list libs=-lOpenCL]]
27 return [gdb_compile ${src} ${binfile} "executable" ${options_opencl}]
28}
29
30# Run a test on the target to check if it supports OpenCL. Return 0 if so, 1 if
31# it does not.
17e1c970
TT
32gdb_caching_proc skip_opencl_tests {
33 global srcdir objdir subdir gdb_prompt
fda326dd 34 global inferior_exited_re
f4b8a18d 35
f4b8a18d 36 set me "skip_opencl_tests"
f4b8a18d
KW
37
38 # Set up, compile, and execute an OpenCL program. Include the current
39 # process ID in the file name of the executable to prevent conflicts with
40 # invocations for multiple testsuites.
41 set clprogram [remote_download target ${srcdir}/lib/opencl_kernel.cl]
42 set executable opencltest[pid].x
43
44 verbose "$me: compiling OpenCL test app" 2
45 set compile_flags {debug nowarnings quiet}
46
6da78614 47 if { [gdb_compile_opencl_hostapp "${clprogram}" "${executable}" "${compile_flags}" ] != "" } {
17e1c970 48 remote_file target delete ${clprogram}
f4b8a18d 49 verbose "$me: compiling OpenCL binary failed, returning 1" 2
17e1c970 50 return 1
f4b8a18d
KW
51 }
52
53 # Compilation succeeded so now run it via gdb.
54 clean_restart "$executable"
55 gdb_run_cmd
56 gdb_expect 30 {
fda326dd 57 -re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
f4b8a18d 58 verbose -log "\n$me: OpenCL support detected"
17e1c970 59 set result 0
f4b8a18d 60 }
d2b584a5 61 -re ".*$inferior_exited_re with code.*${gdb_prompt} $" {
f4b8a18d 62 verbose -log "\n$me: OpenCL support not detected"
17e1c970 63 set result 1
f4b8a18d
KW
64 }
65 default {
66 verbose -log "\n$me OpenCL support not detected (default case)"
17e1c970 67 set result 1
f4b8a18d
KW
68 }
69 }
70 gdb_exit
71 remote_file build delete $executable
72
73 # Delete the OpenCL program source file.
74 remote_file target delete ${clprogram}
75
17e1c970
TT
76 verbose "$me: returning $result" 2
77 return $result
f4b8a18d 78}