1272343Sngie#	$NetBSD: t_sp.sh,v 1.12 2014/08/30 12:14:17 gson 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 \
76272343Sngie	    -lrumpvfs -lrumpnet -lrumpnet_net -lrumpnet_netinet ${RUMP_SERVER}
77272343Sngie	atf_check -s exit:0 -e ignore $(atf_get_srcdir)/h_client/h_stresscli $@
78272343Sngie}
79272343Sngie
80272343Sngiefork()
81272343Sngie{
82272343Sngie
83272343Sngie	export RUMP_SERVER=unix://commsock
84272343Sngie	atf_check -s exit:0 rump_server -lrumpvfs ${RUMP_SERVER}
85272343Sngie	atf_check -s exit:0 $(atf_get_srcdir)/h_client/h_forkcli ${1}
86272343Sngie}
87272343Sngie
88272343Sngiesigsafe()
89272343Sngie{
90272343Sngie
91272343Sngie	export RUMP_SERVER=unix://commsock
92272343Sngie	atf_check -s exit:0 rump_server ${RUMP_SERVER}
93272343Sngie	atf_check -s exit:0 $(atf_get_srcdir)/h_client/h_sigcli
94272343Sngie
95272343Sngie}
96272343Sngie
97272343Sngiesignal()
98272343Sngie{
99272343Sngie
100272343Sngie	export RUMP_SERVER=unix://commsock
101272343Sngie	atf_check -s exit:0 $(atf_get_srcdir)/h_server/h_simpleserver \
102272343Sngie	    ${RUMP_SERVER} sendsig 27
103272343Sngie	atf_check -s signal:27 $(atf_get_srcdir)/h_client/h_simplecli block
104272343Sngie}
105272343Sngie
106272343Sngiereconnect()
107272343Sngie{
108272343Sngie
109272343Sngie
110272343Sngie	export RUMP_SERVER=unix://commsock
111272343Sngie	atf_check -s exit:0 rump_server ${RUMP_SERVER}
112272343Sngie	atf_check -s exit:0 -e ignore $(atf_get_srcdir)/h_client/h_reconcli 2
113272343Sngie}
114272343Sngie
115272343Sngieatf_init_test_cases()
116272343Sngie{
117272343Sngie
118272343Sngie	atf_add_test_case basic
119272343Sngie	atf_add_test_case stress_short
120272343Sngie	atf_add_test_case stress_long
121272343Sngie	atf_add_test_case stress_killer
122272343Sngie	atf_add_test_case fork_simple
123272343Sngie	atf_add_test_case fork_pipecomm
124272343Sngie	atf_add_test_case fork_fakeauth
125272343Sngie	atf_add_test_case sigsafe
126272343Sngie	atf_add_test_case signal
127272343Sngie	atf_add_test_case reconnect
128272343Sngie}
129