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
80#
81# Unix Bourne shell script for running perf client tests
82# The parameter passed in is a string binding.
83
84# Usage:
85#           run_client.sh `string binding returned by server`
86#
87# An example run of this test involves starting the server:
88#        ./server 1 ncadg_ip_udp
89#              ==> returns binding, such as ncadg_ip_udp:129.35.130.133[2001]
90#         run_client.sh ncadg_ip_udp:129.35.130.133[2001]
91#
92
93CLIENT=client
94DEBUG=
95PC=false
96
97for ARG
98do
99    case $ARG in
100    -d)
101        DEBUG="-d"
102        shift
103        ;;
104    -pc)
105        PC=true
106        shift
107        ;;
108    *)
109        break
110        ;;
111    esac
112done
113
114echo "Testing against $1..."
115
116protocol=`expr "$1" : "\(.*\):"`
117
118${CLIENT} ${DEBUG} 0 $1 3 400 y n                # Null call
119${CLIENT} ${DEBUG} 0 $1 3 400 y y                # Null idempotent call
120${CLIENT} ${DEBUG} 1 $1 3 50 y n 3000            # Ins
121${CLIENT} ${DEBUG} 1 $1 3 50 y y 3000            # Ins, idempotent
122${CLIENT} ${DEBUG} 2 $1 3 50 y n 3000            # Outs
123${CLIENT} ${DEBUG} 2 $1 3 50 y y 3000            # Outs idempotent
124if [ $PC != "true" ]
125then
126    ${CLIENT} ${DEBUG} 1 $1 3 3 y n 100000       # Ins (100K)
127    ${CLIENT} ${DEBUG} 1 $1 3 3 y y 100000       # Ins, idempotent (100K)
128    ${CLIENT} ${DEBUG} 2 $1 3 3 y n 100000       # Outs (100K)
129    ${CLIENT} ${DEBUG} 2 $1 3 3 y y 100000       # Outs idempotent (100K)
130fi
131
132# Note: test 3 only works with UDP
133if [ "$protocol" = "ncadg_ip_udp" ]
134then
135    ${CLIENT} ${DEBUG} 3 ncadg_ip_udp                # Broadcast
136fi
137
138${CLIENT} ${DEBUG} 4 $1 3 2                         # Maybe
139
140# Note: test 5 only works with UDP
141if [ "$protocol" = "ncadg_ip_udp" ]
142then
143    ${CLIENT} ${DEBUG} 5 ncadg_ip_udp                # Broadcast/maybe
144fi
145${CLIENT} ${DEBUG} 6 $1 3 100 y y                # Floating point
146${CLIENT} ${DEBUG} 6 $1 3 100 y n                # Floating point
147${CLIENT} ${DEBUG} 7 $1                          # Unregistered interface
148${CLIENT} ${DEBUG} 8 $1 n                        # Forwarding
149${CLIENT} ${DEBUG} 9 $1                          # Exception
150${CLIENT} ${DEBUG} 10 $1 2 2 y n 60              # Slow call
151${CLIENT} ${DEBUG} 10 $1 2 2 y y 60              # Slow idempotent call
152