t_exec.sh revision 1.13 1 1.13 riastrad # $NetBSD: t_exec.sh,v 1.13 2025/04/06 14:07:07 riastradh Exp $
2 1.1 pooka #
3 1.1 pooka # Copyright (c) 2011 The NetBSD Foundation, Inc.
4 1.1 pooka # All rights reserved.
5 1.1 pooka #
6 1.1 pooka # Redistribution and use in source and binary forms, with or without
7 1.1 pooka # modification, are permitted provided that the following conditions
8 1.1 pooka # are met:
9 1.1 pooka # 1. Redistributions of source code must retain the above copyright
10 1.1 pooka # notice, this list of conditions and the following disclaimer.
11 1.1 pooka # 2. Redistributions in binary form must reproduce the above copyright
12 1.1 pooka # notice, this list of conditions and the following disclaimer in the
13 1.1 pooka # documentation and/or other materials provided with the distribution.
14 1.1 pooka #
15 1.1 pooka # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 1.1 pooka # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 1.1 pooka # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 1.1 pooka # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 1.1 pooka # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 1.1 pooka # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 1.1 pooka # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 1.1 pooka # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 1.1 pooka # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 1.1 pooka # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 1.1 pooka # POSSIBILITY OF SUCH DAMAGE.
26 1.1 pooka #
27 1.1 pooka
28 1.10 bad rumpsrv='rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet'
29 1.1 pooka export RUMP_SERVER=unix://csock
30 1.6 pooka export RUMPHIJACK_RETRYCONNECT='die'
31 1.1 pooka
32 1.1 pooka atf_test_case noexec cleanup
33 1.1 pooka noexec_head()
34 1.1 pooka {
35 1.1 pooka atf_set "descr" "check that we see what we expect without exec"
36 1.1 pooka }
37 1.1 pooka
38 1.1 pooka noexec_body()
39 1.1 pooka {
40 1.1 pooka
41 1.1 pooka atf_check -s exit:0 ${rumpsrv} ${RUMP_SERVER}
42 1.3 pooka atf_check -s exit:0 env $(atf_get_srcdir)/h_exec
43 1.7 pooka atf_check -s exit:0 -o save:sstat.out rump.sockstat -n
44 1.13 riastrad echo '# begin sstat.out'
45 1.13 riastrad cat sstat.out
46 1.13 riastrad echo '# end sstat.out'
47 1.1 pooka atf_check -s exit:0 -o match:'^root.*h_exec.*tcp.*\*\.1234' \
48 1.1 pooka sed -n 2p sstat.out
49 1.1 pooka atf_check -s exit:0 -o match:'^root.*h_exec.*tcp.*\*\.2345' \
50 1.1 pooka sed -n 3p sstat.out
51 1.1 pooka }
52 1.1 pooka
53 1.1 pooka noexec_cleanup()
54 1.1 pooka {
55 1.1 pooka rump.halt
56 1.1 pooka }
57 1.1 pooka
58 1.1 pooka atf_test_case exec cleanup
59 1.1 pooka exec_head()
60 1.1 pooka {
61 1.1 pooka atf_set "descr" "check that client names changes after exec"
62 1.1 pooka }
63 1.1 pooka
64 1.1 pooka exec_body()
65 1.1 pooka {
66 1.1 pooka
67 1.1 pooka atf_check -s exit:0 ${rumpsrv} ${RUMP_SERVER}
68 1.4 pooka atf_check -s exit:0 $(atf_get_srcdir)/h_exec $(atf_get_srcdir)/h_exec
69 1.7 pooka atf_check -s exit:0 -o save:sstat.out rump.sockstat -n
70 1.13 riastrad echo '# begin sstat.out'
71 1.13 riastrad cat sstat.out
72 1.13 riastrad echo '# end sstat.out'
73 1.1 pooka atf_check -s exit:0 -o match:'^root.*h_ution.*tcp.*\*\.1234' \
74 1.1 pooka sed -n 2p sstat.out
75 1.1 pooka atf_check -s exit:0 -o match:'^root.*h_ution.*tcp.*\*\.2345' \
76 1.1 pooka sed -n 3p sstat.out
77 1.1 pooka }
78 1.1 pooka
79 1.1 pooka exec_cleanup()
80 1.1 pooka {
81 1.1 pooka rump.halt
82 1.1 pooka }
83 1.1 pooka
84 1.2 pooka atf_test_case cloexec cleanup
85 1.2 pooka cloexec_head()
86 1.2 pooka {
87 1.2 pooka atf_set "descr" "check that FD_CLOEXEC works"
88 1.2 pooka }
89 1.2 pooka
90 1.2 pooka cloexec_body()
91 1.2 pooka {
92 1.2 pooka
93 1.2 pooka atf_check -s exit:0 ${rumpsrv} ${RUMP_SERVER}
94 1.3 pooka atf_check -s exit:0 \
95 1.4 pooka $(atf_get_srcdir)/h_exec $(atf_get_srcdir)/h_exec cloexec1
96 1.7 pooka atf_check -s exit:0 -o save:sstat.out rump.sockstat -n
97 1.13 riastrad echo '# begin sstat.out'
98 1.13 riastrad cat sstat.out
99 1.13 riastrad echo '# end sstat.out'
100 1.2 pooka atf_check -s exit:0 -o inline:'2\n' sed -n '$=' sstat.out
101 1.2 pooka atf_check -s exit:0 -o match:'^root.*h_ution.*tcp.*\*\.2345' \
102 1.2 pooka sed -n 2p sstat.out
103 1.2 pooka }
104 1.2 pooka
105 1.2 pooka cloexec_cleanup()
106 1.2 pooka {
107 1.2 pooka rump.halt
108 1.2 pooka }
109 1.2 pooka
110 1.5 pooka atf_test_case vfork cleanup
111 1.5 pooka vfork_head()
112 1.5 pooka {
113 1.5 pooka atf_set "descr" "test rumpclient_vfork()"
114 1.5 pooka }
115 1.5 pooka
116 1.5 pooka vfork_body()
117 1.5 pooka {
118 1.5 pooka
119 1.5 pooka atf_check -s exit:0 ${rumpsrv} ${RUMP_SERVER}
120 1.5 pooka atf_check -s exit:0 \
121 1.5 pooka $(atf_get_srcdir)/h_exec $(atf_get_srcdir)/h_exec vfork_please
122 1.7 pooka atf_check -s exit:0 -o save:sstat.out rump.sockstat -n
123 1.13 riastrad echo '# begin sstat.out'
124 1.13 riastrad cat sstat.out
125 1.13 riastrad echo '# end sstat.out'
126 1.5 pooka atf_check -s exit:0 -o inline:'5\n' sed -n '$=' sstat.out
127 1.5 pooka atf_check -s exit:0 -o match:'^root.*h_ution.*tcp.*\*\.1234' \
128 1.5 pooka cat sstat.out
129 1.5 pooka atf_check -s exit:0 -o match:'^root.*h_ution.*tcp.*\*\.2345' \
130 1.5 pooka cat sstat.out
131 1.5 pooka atf_check -s exit:0 -o match:'^root.*fourchette.*tcp.*\*\.1234' \
132 1.5 pooka cat sstat.out
133 1.5 pooka atf_check -s exit:0 -o match:'^root.*fourchette.*tcp.*\*\.2345' \
134 1.5 pooka cat sstat.out
135 1.5 pooka }
136 1.5 pooka
137 1.5 pooka vfork_cleanup()
138 1.5 pooka {
139 1.5 pooka rump.halt
140 1.5 pooka }
141 1.5 pooka
142 1.8 pooka atf_test_case threxec cleanup
143 1.8 pooka threxec_head()
144 1.8 pooka {
145 1.8 pooka atf_set "descr" "check that threads are killed before exec continues"
146 1.8 pooka }
147 1.8 pooka
148 1.8 pooka threxec_body()
149 1.8 pooka {
150 1.12 martin # atf_skip "PR 55338: triggers a scheduler bug"
151 1.8 pooka atf_check -s exit:0 rump_server ${RUMP_SERVER}
152 1.8 pooka atf_check -s exit:0 $(atf_get_srcdir)/h_execthr
153 1.8 pooka }
154 1.8 pooka
155 1.8 pooka threxec_cleanup()
156 1.8 pooka {
157 1.8 pooka rump.halt
158 1.8 pooka }
159 1.1 pooka
160 1.1 pooka atf_init_test_cases()
161 1.1 pooka {
162 1.1 pooka atf_add_test_case noexec
163 1.1 pooka atf_add_test_case exec
164 1.2 pooka atf_add_test_case cloexec
165 1.5 pooka atf_add_test_case vfork
166 1.8 pooka atf_add_test_case threxec
167 1.1 pooka }
168