t_pipes.sh revision 276478
1183170Simp# $NetBSD: t_pipes.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $
2183170Simp#
3183170Simp# Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
4183170Simp# All rights reserved.
5183170Simp#
6183170Simp# Redistribution and use in source and binary forms, with or without
7183170Simp# modification, are permitted provided that the following conditions
8183170Simp# are met:
9183170Simp# 1. Redistributions of source code must retain the above copyright
10183170Simp#    notice, this list of conditions and the following disclaimer.
11183170Simp# 2. Redistributions in binary form must reproduce the above copyright
12183170Simp#    notice, this list of conditions and the following disclaimer in the
13183170Simp#    documentation and/or other materials provided with the distribution.
14183170Simp#
15183170Simp# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16183170Simp# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17183170Simp# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18183170Simp# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19183170Simp# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20183170Simp# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21183170Simp# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22183170Simp# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23183170Simp# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24183170Simp# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25183170Simp# POSSIBILITY OF SUCH DAMAGE.
26183170Simp#
27183170Simp
28183170Simpatf_test_case basic
29178170Simpbasic_head() {
30178170Simp	atf_set "descr" "Verifies that pipes work"
31178170Simp	atf_set "require.user" "root"
32178170Simp}
33178170Simpbasic_body() {
34178170Simp	test_mount
35201986Simp
36201986Simp	umask 022
37204305Simp
38178170Simp	atf_check -s eq:0 -o empty -e empty mknod pipe p
39178170Simp
40178170Simp	echo "Writing to pipe and waiting for response"
41178170Simp	echo -n foo >pipe &
42178170Simp	[ "$(cat pipe)" = foo ] || atf_fail "Received data is incorrect"
43178170Simp
44178170Simp	test_unmount
45178170Simp}
46178170Simp
47178170Simpatf_init_test_cases() {
48178170Simp	. $(atf_get_srcdir)/../h_funcs.subr
49201986Simp	. $(atf_get_srcdir)/h_funcs.subr
50201986Simp
51178170Simp	atf_add_test_case basic
52201986Simp}
53178170Simp