1#!/bin/sh
2#
3#
4# Copyright (c) 2010 Apple Inc. All rights reserved.
5#
6# @APPLE_LICENSE_HEADER_START@
7#
8# Redistribution and use in source and binary forms, with or without
9# modification, are permitted provided that the following conditions
10# are met:
11#
12# 1.  Redistributions of source code must retain the above copyright
13#     notice, this list of conditions and the following disclaimer.
14# 2.  Redistributions in binary form must reproduce the above copyright
15#     notice, this list of conditions and the following disclaimer in the
16#     documentation and/or other materials provided with the distribution.
17# 3.  Neither the name of Apple Inc. ("Apple") nor the names of its
18#     contributors may be used to endorse or promote products derived from
19#     this software without specific prior written permission.
20#
21# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
22# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
25# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31#
32# Portions of this software have been released under the following terms:
33#
34# (c) Copyright 1989-1993 OPEN SOFTWARE FOUNDATION, INC.
35# (c) Copyright 1989-1993 HEWLETT-PACKARD COMPANY
36# (c) Copyright 1989-1993 DIGITAL EQUIPMENT CORPORATION
37#
38# To anyone who acknowledges that this file is provided "AS IS"
39# without any express or implied warranty:
40# permission to use, copy, modify, and distribute this file for any
41# purpose is hereby granted without fee, provided that the above
42# copyright notices and this notice appears in all source code copies,
43# and that none of the names of Open Software Foundation, Inc., Hewlett-
44# Packard Company or Digital Equipment Corporation be used
45# in advertising or publicity pertaining to distribution of the software
46# without specific, written prior permission.  Neither Open Software
47# Foundation, Inc., Hewlett-Packard Company nor Digital
48# Equipment Corporation makes any representations about the suitability
49# of this software for any purpose.
50#
51# Copyright (c) 2007, Novell, Inc. All rights reserved.
52# Redistribution and use in source and binary forms, with or without
53# modification, are permitted provided that the following conditions
54# are met:
55#
56# 1.  Redistributions of source code must retain the above copyright
57#     notice, this list of conditions and the following disclaimer.
58# 2.  Redistributions in binary form must reproduce the above copyright
59#     notice, this list of conditions and the following disclaimer in the
60#     documentation and/or other materials provided with the distribution.
61# 3.  Neither the name of Novell Inc. nor the names of its contributors
62#     may be used to endorse or promote products derived from this
63#     this software without specific prior written permission.
64#
65# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
66# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
67# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
68# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY
69# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
70# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
71# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
72# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
73# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
74# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
75#
76# @APPLE_LICENSE_HEADER_END@
77#
78#
79
80case $# in
812) ;;
82*) echo 'Usage: perf_tcp.sh server_host_name client_program_directory' 1>&2 ; exit 1;;
83esac
84
85cd $2
86##IP=`host $1 | awk '{print $3}'`
87# Use the dce getip program, and if that doesn't work, try the
88# basic approach of greping /etc/hosts.  This combination
89# should cover most any platform.
90if [ -x /opt/dcelocal/bin/getip ]; then
91        IP=`getip $1`
92else
93        IP=`grep $1 /etc/hosts | awk '{print $1}'`
94fi
95
96FAILED=""
97
98echo "client 0a"
99client 0 "ncacn_ip_tcp:${IP}[2001]" 3 40 y y || FAILED="$FAILED 0a"
100echo "client 0b"
101client 0 "ncacn_ip_tcp:${IP}[2001]" 3 40 y n || FAILED="$FAILED 0b"
102echo "client 0c"
103client 0 "ncacn_ip_tcp:${IP}[2001]" 3 40 n y || FAILED="$FAILED 0c"
104echo "client 0d"
105client 0 "ncacn_ip_tcp:${IP}[2001]" 3 40 n n || FAILED="$FAILED 0d"
106echo "client 1a"
107client 1 "ncacn_ip_tcp:${IP}[2001]" 3 40 y y 400 || FAILED="$FAILED 1a"
108echo "client 1b"
109client 1 "ncacn_ip_tcp:${IP}[2001]" 3 40 y n 400 || FAILED="$FAILED 1b"
110echo "client 1c"
111client 1 "ncacn_ip_tcp:${IP}[2001]" 3 10 y y 4000 || FAILED="$FAILED 1c"
112echo "client 1d"
113client 1 "ncacn_ip_tcp:${IP}[2001]" 3 10 y n 4000 || FAILED="$FAILED 1d"
114#echo "client 1e"
115#client 1 "ncacn_ip_tcp:${IP}[2001]" 3 2 y y 100000 || FAILED="$FAILED 1e"
116#echo "client 1f"
117#client 1 "ncacn_ip_tcp:${IP}[2001]" 3 2 y n 100000 || FAILED="$FAILED 1f"
118echo "client 2a"
119client 2 "ncacn_ip_tcp:${IP}[2001]" 3 100 y y 400 || FAILED="$FAILED 2a"
120echo "client 2b"
121client 2 "ncacn_ip_tcp:${IP}[2001]" 3 100 y n 400 || FAILED="$FAILED 2b"
122echo "client 2c"
123client 2 "ncacn_ip_tcp:${IP}[2001]" 3 10 y y 4000 || FAILED="$FAILED 2c"
124echo "client 2d"
125client 2 "ncacn_ip_tcp:${IP}[2001]" 3 10 y n 4000 || FAILED="$FAILED 2d"
126#echo "client 2e"
127#client 2 "ncacn_ip_tcp:${IP}[2001]" 3 2 y y 100000 || FAILED="$FAILED 2e"
128#echo "client 2f"
129#client 2 "ncacn_ip_tcp:${IP}[2001]" 3 2 y n 100000 || FAILED="$FAILED 2f"
130#echo "client 3"
131#client 3 "ncacn_ip_tcp" || FAILED="$FAILED 3"
132echo "client 4"
133client 4 "ncacn_ip_tcp:${IP}[2001]" 3 2 || FAILED="$FAILED 4"
134#echo "client 5"
135#client 5 "ncacn_ip_tcp" || FAILED="$FAILED 5"
136echo "client 6a"
137client 6 "ncacn_ip_tcp:${IP}[2001]" 3 100 y y || FAILED="$FAILED 6a"
138echo "client 6b"
139client 6 "ncacn_ip_tcp:${IP}[2001]" 3 100 y n || FAILED="$FAILED 6b"
140echo "client 8"
141client 8 "ncacn_ip_tcp:${IP}[2001]" y || FAILED="$FAILED 8"
142echo "client 7"
143client 7 "ncacn_ip_tcp:${IP}[2001]" || FAILED="$FAILED 7"
144echo "client 9"
145client 9 "ncacn_ip_tcp:${IP}[2001]" || FAILED="$FAILED 9"
146echo "client 10a"
147client 10 "ncacn_ip_tcp:${IP}[2001]" 4 3 y y 2 || FAILED="$FAILED 10a"
148echo "client 10b"
149client 10 "ncacn_ip_tcp:${IP}[2001]" 2 3 y n 2 || FAILED="$FAILED 10b"
150echo "client 10c"
151client 10 "ncacn_ip_tcp:${IP}[2001]" 4 3 y y 2 1 || FAILED="$FAILED 10c"
152echo "client 10d"
153client 10 "ncacn_ip_tcp:${IP}[2001]" 2 3 y n 2 1 || FAILED="$FAILED 10d"
154echo "client 10e"
155client 10 "ncacn_ip_tcp:${IP}[2001]" 4 3 y y 2 2 || FAILED="$FAILED 10e"
156echo "client 10f"
157client 10 "ncacn_ip_tcp:${IP}[2001]" 2 3 y n 2 2 || FAILED="$FAILED 10f"
158# These test are unsupported and will fail
159#echo "client 12a"
160#client 12 "ncacn_ip_tcp:${IP}[2001]" 2 10 y
161#echo "client 12b"
162#client 12 "ncacn_ip_tcp:${IP}[2001]" 2 10 n
163echo "client 13"
164client 13 "ncacn_ip_tcp:${IP}[2001]" || FAILED="$FAILED 13"
165echo "client 14a"
166client 14 "ncacn_ip_tcp:${IP}[2001]" 4 n 1 || FAILED="$FAILED 14a"
167echo "client 14b"
168client 14 "ncacn_ip_tcp:${IP}[2001]" 4 y 1 || FAILED="$FAILED 14b"
169echo "client 15a"
170client 15 "ncacn_ip_tcp:${IP}[2001]" 2 y 1 || FAILED="$FAILED 15a"
171echo "client 15b"
172client 15 "ncacn_ip_tcp:${IP}[2001]" 2 n 1 || FAILED="$FAILED 15b"
173echo "client 15c"
174client 15 "ncacn_ip_tcp:${IP}[2001]" 2 y 1 5 || FAILED="$FAILED 15c"
175echo "client 15d"
176client 15 "ncacn_ip_tcp:${IP}[2001]" 2 n 1 5 || FAILED="$FAILED 15d"
177
178if [ -n "$FAILED" ] ; then
179	echo "The failed tests were"
180	echo "$FAILED"
181	exit 1
182else
183	echo "All tests OK"
184	exit 0
185fi
186