]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/lib/opencl.exp
56af9d3affed3fada631b62d9adb92ff01c52e3b
[thirdparty/binutils-gdb.git] / gdb / testsuite / lib / opencl.exp
1 # Copyright 2010-2015 Free Software Foundation, Inc.
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.
21 proc 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"
24 set binfile ${objdir}/${subdir}/${executable}
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.
32 gdb_caching_proc skip_opencl_tests {
33 global srcdir objdir subdir gdb_prompt
34 global inferior_exited_re
35
36 set me "skip_opencl_tests"
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
47 if { [gdb_compile_opencl_hostapp "${clprogram}" "${executable}" "${compile_flags}" ] != "" } {
48 remote_file target delete ${clprogram}
49 verbose "$me: compiling OpenCL binary failed, returning 1" 2
50 return 1
51 }
52
53 # Compilation succeeded so now run it via gdb.
54 clean_restart "$executable"
55 gdb_run_cmd
56 gdb_expect 30 {
57 -re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
58 verbose -log "\n$me: OpenCL support detected"
59 set result 0
60 }
61 -re ".*$inferior_exited_re code.*${gdb_prompt} $" {
62 verbose -log "\n$me: OpenCL support not detected"
63 set result 1
64 }
65 default {
66 verbose -log "\n$me OpenCL support not detected (default case)"
67 set result 1
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
76 verbose "$me: returning $result" 2
77 return $result
78 }