1313498Sngie#	$NetBSD: t_sp.sh,v 1.13 2016/08/10 23:47:14 kre Exp $
2272343Sngie#
3272343Sngie# Copyright (c) 2010 The NetBSD Foundation, Inc.
4272343Sngie# All rights reserved.
5272343Sngie#
6272343Sngie# Redistribution and use in source and binary forms, with or without
7272343Sngie# modification, are permitted provided that the following conditions
8272343Sngie# are met:
9272343Sngie# 1. Redistributions of source code must retain the above copyright
10272343Sngie#    notice, this list of conditions and the following disclaimer.
11272343Sngie# 2. Redistributions in binary form must reproduce the above copyright
12272343Sngie#    notice, this list of conditions and the following disclaimer in the
13272343Sngie#    documentation and/or other materials provided with the distribution.
14272343Sngie#
15272343Sngie# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16272343Sngie# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17272343Sngie# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18272343Sngie# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19272343Sngie# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20272343Sngie# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21272343Sngie# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22272343Sngie# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23272343Sngie# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24272343Sngie# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25272343Sngie# POSSIBILITY OF SUCH DAMAGE.
26272343Sngie#
27272343Sngie
28272343Sngietest_case()
29272343Sngie{
30272343Sngie	local name="${1}"; shift
31272343Sngie	local check_function="${1}"; shift
32272343Sngie
33272343Sngie	atf_test_case "${name}" cleanup
34272343Sngie	eval "${name}_head() {  }"
35272343Sngie	eval "${name}_body() { \
36272343Sngie		${check_function} " "${@}" "; \
37272343Sngie	}"
38272343Sngie        eval "${name}_cleanup() { \
39272343Sngie		RUMP_SERVER=unix://commsock rump.halt
40272343Sngie        }"
41272343Sngie}
42272343Sngie
43272343Sngietest_case basic basic
44272343Sngietest_case stress_short stress 1
45272343Sngietest_case stress_long stress 2
46272343Sngietest_case stress_killer stress 5 kill
47272343Sngietest_case fork_simple fork simple
48272343Sngietest_case fork_pipecomm fork pipecomm
49272343Sngietest_case fork_fakeauth fork fakeauth
50272343Sngietest_case sigsafe sigsafe sigsafe
51272343Sngietest_case signal signal
52272343Sngietest_case reconnect reconnect
53272343Sngie
54272343Sngiebasic()
55272343Sngie{
56272343Sngie	export RUMP_SERVER=unix://commsock
57272343Sngie	atf_check -s exit:0 rump_server ${RUMP_SERVER}
58272343Sngie	atf_check -s exit:0 $(atf_get_srcdir)/h_client/h_simplecli
59272343Sngie}
60272343Sngie
61272343Sngiestress_short_head()
62272343Sngie{
63272343Sngie	atf_set "require.memory" "64M"
64272343Sngie}
65272343Sngie
66272343Sngiestress_long_head()
67272343Sngie{
68272343Sngie	atf_set "require.memory" "64M"
69272343Sngie}
70272343Sngie
71272343Sngiestress()
72272343Sngie{
73272343Sngie
74272343Sngie	export RUMP_SERVER=unix://commsock
75272343Sngie	atf_check -s exit:0 rump_server \
76313498Sngie	    -lrumpvfs -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpdev \
77313498Sngie	    ${RUMP_SERVER}
78272343Sngie	atf_check -s exit:0 -e ignore $(atf_get_srcdir)/h_client/h_stresscli $@
79272343Sngie}
80272343Sngie
81272343Sngiefork()
82272343Sngie{
83272343Sngie
84272343Sngie	export RUMP_SERVER=unix://commsock
85313498Sngie	atf_check -s exit:0 rump_server -lrumpvfs -lrumpdev ${RUMP_SERVER}
86272343Sngie	atf_check -s exit:0 $(atf_get_srcdir)/h_client/h_forkcli ${1}
87272343Sngie}
88272343Sngie
89272343Sngiesigsafe()
90272343Sngie{
91272343Sngie
92272343Sngie	export RUMP_SERVER=unix://commsock
93272343Sngie	atf_check -s exit:0 rump_server ${RUMP_SERVER}
94272343Sngie	atf_check -s exit:0 $(atf_get_srcdir)/h_client/h_sigcli
95272343Sngie
96272343Sngie}
97272343Sngie
98272343Sngiesignal()
99272343Sngie{
100272343Sngie
101272343Sngie	export RUMP_SERVER=unix://commsock
102272343Sngie	atf_check -s exit:0 $(atf_get_srcdir)/h_server/h_simpleserver \
103272343Sngie	    ${RUMP_SERVER} sendsig 27
104272343Sngie	atf_check -s signal:27 $(atf_get_srcdir)/h_client/h_simplecli block
105272343Sngie}
106272343Sngie
107272343Sngiereconnect()
108272343Sngie{
109272343Sngie
110272343Sngie
111272343Sngie	export RUMP_SERVER=unix://commsock
112272343Sngie	atf_check -s exit:0 rump_server ${RUMP_SERVER}
113272343Sngie	atf_check -s exit:0 -e ignore $(atf_get_srcdir)/h_client/h_reconcli 2
114272343Sngie}
115272343Sngie
116272343Sngieatf_init_test_cases()
117272343Sngie{
118272343Sngie
119272343Sngie	atf_add_test_case basic
120272343Sngie	atf_add_test_case stress_short
121272343Sngie	atf_add_test_case stress_long
122272343Sngie	atf_add_test_case stress_killer
123272343Sngie	atf_add_test_case fork_simple
124272343Sngie	atf_add_test_case fork_pipecomm
125272343Sngie	atf_add_test_case fork_fakeauth
126272343Sngie	atf_add_test_case sigsafe
127272343Sngie	atf_add_test_case signal
128272343Sngie	atf_add_test_case reconnect
129272343Sngie}
130