xref: /netbsd-src/tests/net/fdpass/t_fdpass.sh (revision 324d0ec8507df2d5e24be03fa899f1f3c561c1f0)
1*324d0ec8Smartin# $NetBSD: t_fdpass.sh,v 1.2 2012/08/16 08:39:43 martin Exp $
2e3b23739Schristos#
3e3b23739Schristos# Copyright (c) 2012 The NetBSD Foundation, Inc.
4e3b23739Schristos# All rights reserved.
5e3b23739Schristos#
6e3b23739Schristos# This code is derived from software contributed to The NetBSD Foundation
7e3b23739Schristos# by Christos Zoulas
8e3b23739Schristos#
9e3b23739Schristos# Redistribution and use in source and binary forms, with or without
10e3b23739Schristos# modification, are permitted provided that the following conditions
11e3b23739Schristos# are met:
12e3b23739Schristos# 1. Redistributions of source code must retain the above copyright
13e3b23739Schristos#    notice, this list of conditions and the following disclaimer.
14e3b23739Schristos# 2. Redistributions in binary form must reproduce the above copyright
15e3b23739Schristos#    notice, this list of conditions and the following disclaimer in the
16e3b23739Schristos#    documentation and/or other materials provided with the distribution.
17e3b23739Schristos#
18e3b23739Schristos# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19e3b23739Schristos# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20e3b23739Schristos# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21e3b23739Schristos# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22e3b23739Schristos# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23e3b23739Schristos# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24e3b23739Schristos# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25e3b23739Schristos# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26e3b23739Schristos# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27e3b23739Schristos# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28e3b23739Schristos# POSSIBILITY OF SUCH DAMAGE.
29e3b23739Schristos#
30e3b23739Schristos
31e3b23739Schristoshave32() {
32e3b23739Schristos	local src="$(atf_get_srcdir)"
33e3b23739Schristos	if cmp "${src}/fdpass64" "${src}/fdpass32" > /dev/null
34e3b23739Schristos	then
35*324d0ec8Smartin		# echo "no -m32 support"
36e3b23739Schristos		return 1
37e3b23739Schristos	else
38e3b23739Schristos		return 0
39e3b23739Schristos	fi
40e3b23739Schristos}
41e3b23739Schristos
42e3b23739Schristosatf_test_case fdpass_normal
43e3b23739Schristos
44e3b23739Schristosfdpass_normal_head() {
45e3b23739Schristos	atf_set "descr" "Test file descriptor passing (default)"
46e3b23739Schristos}
47e3b23739Schristos
48e3b23739Schristosfdpass_normal_body() {
49e3b23739Schristos	local src="$(atf_get_srcdir)"
50e3b23739Schristos	atf_check "${src}/fdpass64"
51e3b23739Schristos}
52e3b23739Schristos
53e3b23739Schristos
54e3b23739Schristosatf_test_case fdpass_compat
55e3b23739Schristos
56e3b23739Schristosfdpass_compat_head() {
57e3b23739Schristos	atf_set "descr" "Test file descriptor passing (compat)"
58e3b23739Schristos}
59e3b23739Schristos
60e3b23739Schristosfdpass_compat_body() {
61e3b23739Schristos	local src="$(atf_get_srcdir)"
62e3b23739Schristos	have32 && atf_check "${src}/fdpass32"
63e3b23739Schristos}
64e3b23739Schristos
65e3b23739Schristos
66e3b23739Schristosatf_test_case fdpass_normal_compat
67e3b23739Schristos
68e3b23739Schristosfdpass_normal_compat_head() {
69e3b23739Schristos	atf_set "descr" "Test file descriptor passing (normal->compat)"
70e3b23739Schristos}
71e3b23739Schristos
72e3b23739Schristosfdpass_normal_compat_body() {
73e3b23739Schristos	local src="$(atf_get_srcdir)"
74e3b23739Schristos	have32 && atf_check "${src}/fdpass64" -p "${src}/fdpass32"
75e3b23739Schristos}
76e3b23739Schristos
77e3b23739Schristos
78e3b23739Schristosatf_test_case fdpass_compat_normal
79e3b23739Schristos
80e3b23739Schristosfdpass_compat_normal_head() {
81e3b23739Schristos	atf_set "descr" "Test file descriptor passing (normal->compat)"
82e3b23739Schristos}
83e3b23739Schristos
84e3b23739Schristosfdpass_compat_normal_body() {
85e3b23739Schristos	local src="$(atf_get_srcdir)"
86e3b23739Schristos	have32 && atf_check "${src}/fdpass32" -p "${src}/fdpass64"
87e3b23739Schristos}
88e3b23739Schristos
89e3b23739Schristos
90e3b23739Schristosatf_init_test_cases()
91e3b23739Schristos{
92e3b23739Schristos	atf_add_test_case fdpass_normal
93e3b23739Schristos	if have32
94e3b23739Schristos	then
95e3b23739Schristos		atf_add_test_case fdpass_compat
96e3b23739Schristos		atf_add_test_case fdpass_compat_normal
97e3b23739Schristos		atf_add_test_case fdpass_normal_compat
98e3b23739Schristos	fi
99e3b23739Schristos}
100