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