]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.rocm/fork-exec-gpu-to-non-gpu.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.rocm / fork-exec-gpu-to-non-gpu.exp
1 # Copyright 2021-2024 Free Software Foundation, Inc.
2
3 # This file is part of GDB.
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
18 # Verify handling of a GPU program that does a (v)fork + exec to execute
19 # a non-GPU program.
20
21 load_lib rocm.exp
22
23 require allow_hipcc_tests
24
25 standard_testfile -execer.cpp -execee.cpp
26
27 set srcfile_execer "$srcfile"
28 set srcfile_execee "$srcfile2"
29 set binfile_execee "$binfile-execee"
30
31 # Compile two versions of execer, one that uses fork and one that uses vfork.
32 foreach_with_prefix fork_func { fork vfork } {
33 set opts [list debug hip additional_flags=-DFORK=$fork_func \
34 additional_flags=-DEXECEE="${::binfile_execee}"]
35 if {[build_executable "failed to prepare" ${::binfile}-execer-${fork_func} \
36 $srcfile_execer $opts]} {
37 return
38 }
39 }
40
41 if {[build_executable "failed to prepare" $binfile_execee $srcfile_execee \
42 {debug}]} {
43 return
44 }
45
46 proc do_test { detach-on-fork follow-fork-mode fork_func } {
47 # In this case, the parent can't execute, as it's blocked in
48 # vfork. Skip it.
49 if { ${detach-on-fork} == "off"
50 && ${follow-fork-mode} == "parent"
51 && ${fork_func} == "vfork" } {
52 return
53 }
54
55 with_rocm_gpu_lock {
56 clean_restart ${::binfile}-execer-${fork_func}
57
58 gdb_test_no_output "set detach-on-fork ${detach-on-fork}"
59 gdb_test_no_output "set follow-fork-mode ${follow-fork-mode}"
60
61 if { ${follow-fork-mode} == "parent" } {
62 runto break_here_execer allow-pending message
63 gdb_continue_to_end "continue parent to end" "continue" 1
64
65 if { ${detach-on-fork} == "off" } {
66 gdb_test "inferior 2" "Switching to inferior 2 .*"
67 gdb_continue_to_end "continue child to end" "continue" 1
68 }
69 } elseif { ${follow-fork-mode} == "child" } {
70 runto break_here_execee allow-pending message
71 gdb_continue_to_end "continue child to end" "continue" 1
72
73 if { ${detach-on-fork} == "off" } {
74 gdb_test "inferior 1" "Switching to inferior 1 .*"
75 gdb_continue_to_end "continue parent to end" "continue" 1
76 }
77 } else {
78 error "unexpected follow-fork-mode value: ${follow-fork-mode}"
79 }
80 }
81 }
82
83 foreach_with_prefix detach-on-fork { on off } {
84 foreach_with_prefix follow-fork-mode { parent child } {
85 foreach_with_prefix fork_func { fork vfork } {
86 do_test ${detach-on-fork} ${follow-fork-mode} $fork_func
87 }
88 }
89 }