1272343Sngie#       $NetBSD: t_asyncio.sh,v 1.4 2014/08/27 13:32:16 gson Exp $
2272343Sngie#
3272343Sngie# Copyright (c) 2011 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
28272343Sngierumpsrv='rump_server'
29272343Sngieexport RUMP_SERVER=unix://csock
30272343Sngie
31272343Sngieatf_test_case select_timeout cleanup
32272343Sngieselect_timeout_head()
33272343Sngie{
34272343Sngie        atf_set "descr" "select() with timeout returns no fds set"
35272343Sngie}
36272343Sngie
37272343Sngieselect_timeout_body()
38272343Sngie{
39272343Sngie
40272343Sngie	atf_check -s exit:0 ${rumpsrv} ${RUMP_SERVER}
41272343Sngie	atf_check -s exit:0 env LD_PRELOAD=/usr/lib/librumphijack.so \
42272343Sngie	    $(atf_get_srcdir)/h_client select_timeout
43272343Sngie}
44272343Sngie
45272343Sngieselect_timeout_cleanup()
46272343Sngie{
47272343Sngie	rump.halt
48272343Sngie}
49272343Sngie
50272343Sngieatf_test_case select_allunset cleanup
51272343Sngieselect_allunset_head()
52272343Sngie{
53272343Sngie        atf_set "descr" "select() with no set fds in fd_set should not crash"
54272343Sngie}
55272343Sngie
56272343Sngieselect_allunset_body()
57272343Sngie{
58272343Sngie
59272343Sngie	atf_check -s exit:0 ${rumpsrv} ${RUMP_SERVER}
60272343Sngie	atf_check -s exit:0 env LD_PRELOAD=/usr/lib/librumphijack.so \
61272343Sngie	    $(atf_get_srcdir)/h_client select_allunset
62272343Sngie}
63272343Sngie
64272343Sngieselect_allunset_cleanup()
65272343Sngie{
66272343Sngie	rump.halt
67272343Sngie}
68272343Sngie
69272343Sngieatf_test_case invafd cleanup
70272343Sngieinvafd_head()
71272343Sngie{
72272343Sngie        atf_set "descr" "poll on invalid rump fd"
73272343Sngie	atf_set "timeout" "10"
74272343Sngie}
75272343Sngie
76272343Sngieinvafd_body()
77272343Sngie{
78272343Sngie
79272343Sngie	atf_check -s exit:0 rump_server -lrumpvfs ${RUMP_SERVER}
80272343Sngie	atf_check -s exit:0 env LD_PRELOAD=/usr/lib/librumphijack.so \
81272343Sngie	    $(atf_get_srcdir)/h_client invafd
82272343Sngie}
83272343Sngie
84272343Sngieinvafd_cleanup()
85272343Sngie{
86272343Sngie	rump.halt
87272343Sngie}
88272343Sngie
89272343Sngieatf_init_test_cases()
90272343Sngie{
91272343Sngie	atf_add_test_case select_timeout
92272343Sngie	atf_add_test_case select_allunset
93272343Sngie	atf_add_test_case invafd
94272343Sngie}
95