]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.opencl/convs_casts.exp
Update copyright year range in all GDB files
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.opencl / convs_casts.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# Tests GDBs support for OpenCL type conversions and casts.
19
f4b8a18d
KW
20load_lib opencl.exp
21
22if { [skip_opencl_tests] } {
163df4df 23 unsupported "OpenCL support not detected"
f4b8a18d
KW
24 return 0
25}
26
27set testfile "convs_casts"
28set clprogram [remote_download target ${srcdir}/${subdir}/${testfile}.cl]
29
30# Compile the generic OpenCL host app
31if { [gdb_compile_opencl_hostapp "${clprogram}" "${testfile}" "" ] != "" } {
5b362f04 32 untested "failed to compile"
f4b8a18d
KW
33 return -1
34}
35
36# Load the OpenCL app
37clean_restart ${testfile}
38
39# Set breakpoint at the OpenCL kernel
b2030fb5 40gdb_test "tbreak testkernel" \
d468832a
KW
41 "" \
42 "Set pending breakpoint" \
43 ".*Function \"testkernel\" not defined.*Make breakpoint pending.*y or \\\[n\\\]. $" \
44 "y"
f4b8a18d
KW
45
46gdb_run_cmd
b2030fb5 47gdb_test "" ".*reakpoint.*1.*testkernel.*" "run"
f4b8a18d 48
d468832a
KW
49# Continue to the marker
50gdb_breakpoint [gdb_get_line_number "marker" "${clprogram}"]
51gdb_continue_to_breakpoint "marker"
52
f4b8a18d
KW
53# Retrieve some information about availability of OpenCL extensions
54set have_cl_khr_fp64 [get_integer_valueof "have_cl_khr_fp64" 0]
55set have_cl_khr_fp16 [get_integer_valueof "have_cl_khr_fp16" 0]
56
57proc vec_casts { name } {
58 global have_cl_khr_fp16 have_cl_khr_fp64
59 set types {"char" "uchar" "short" "ushort" "int" "uint" "long" "ulong" "half" "float" "double"}
60 set len [llength ${types}]
61
62 for {set i 0} {$i < ${len}} {incr i} {
63 set type [lindex ${types} $i]
64
65 gdb_test "print/d (${type}2)${name}" " = \\{123, 123\\}"
66 gdb_test "print/d (${type}3)${name}" " = \\{123, 123, 123\\}"
67 gdb_test "print/d (${type}4)${name}" " = \\{123, 123, 123, 123\\}"
68 gdb_test "print/d (${type}8)${name}" " = \\{123, 123, 123, 123, 123, 123, 123, 123\\}"
69 gdb_test "print/d (${type}16)${name}" " = \\{123 <repeats 16 times>\\}"
70
ea5e6b0e
UW
71 gdb_test "ptype (${type}2)${name}" "${type}2"
72 gdb_test "ptype (${type}3)${name}" "${type}3"
73 gdb_test "ptype (${type}4)${name}" "${type}4"
74 gdb_test "ptype (${type}8)${name}" "${type}8"
75 gdb_test "ptype (${type}16)${name}" "${type}16"
f4b8a18d
KW
76 }
77}
78
79vec_casts "c"
80vec_casts "uc"
81vec_casts "s"
82vec_casts "us"
83vec_casts "i"
84vec_casts "ui"
85vec_casts "l"
86vec_casts "ul"
87if { ${have_cl_khr_fp16} } {
88 vec_casts "h"
89}
90vec_casts "f"
91if { ${have_cl_khr_fp64} } {
92 vec_casts "d"
93}
94
95# Delete the OpenCL program source
96remote_file target delete ${clprogram}