xref: /aosp_15_r20/external/ltp/testcases/network/sockets/ltpSockets.sh (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1*49cdfc7eSAndroid Build Coastguard Worker#!/bin/sh
2*49cdfc7eSAndroid Build Coastguard Worker# This script will start the socket server and then run the
3*49cdfc7eSAndroid Build Coastguard Worker# sockets clients to execute the tests. If the kernel isn't
4*49cdfc7eSAndroid Build Coastguard Worker# setup for multiCast server, then the other tests will continue without multiCast.
5*49cdfc7eSAndroid Build Coastguard Worker# 03/28/03 [email protected] new tests
6*49cdfc7eSAndroid Build Coastguard Worker
7*49cdfc7eSAndroid Build Coastguard Workercd `dirname $0`
8*49cdfc7eSAndroid Build Coastguard Workerexport LTPROOT=${PWD}
9*49cdfc7eSAndroid Build Coastguard Workerexport TMPBASE="/tmp"
10*49cdfc7eSAndroid Build Coastguard Worker
11*49cdfc7eSAndroid Build Coastguard Worker
12*49cdfc7eSAndroid Build Coastguard Workerusage()
13*49cdfc7eSAndroid Build Coastguard Worker{
14*49cdfc7eSAndroid Build Coastguard Worker	cat <<-END >&2
15*49cdfc7eSAndroid Build Coastguard Worker	usage: ${0##*/} [ -h hostname2 ] [ -d testdata ]
16*49cdfc7eSAndroid Build Coastguard Worker
17*49cdfc7eSAndroid Build Coastguard Worker	defaults:
18*49cdfc7eSAndroid Build Coastguard Worker	hostname1=$hostname1
19*49cdfc7eSAndroid Build Coastguard Worker	testdata=$testdata
20*49cdfc7eSAndroid Build Coastguard Worker	ltproot=$LTPROOT
21*49cdfc7eSAndroid Build Coastguard Worker	tmpdir=$TMPBASE
22*49cdfc7eSAndroid Build Coastguard Worker
23*49cdfc7eSAndroid Build Coastguard Worker	example: ${0##*/} -h myhostname  -d "my test data to be sent"
24*49cdfc7eSAndroid Build Coastguard Worker
25*49cdfc7eSAndroid Build Coastguard Worker
26*49cdfc7eSAndroid Build Coastguard Worker	END
27*49cdfc7eSAndroid Build Coastguard Workerexit
28*49cdfc7eSAndroid Build Coastguard Worker}
29*49cdfc7eSAndroid Build Coastguard Worker
30*49cdfc7eSAndroid Build Coastguard Workerwhile getopts :h:d: arg
31*49cdfc7eSAndroid Build Coastguard Workerdo      case $arg in
32*49cdfc7eSAndroid Build Coastguard Worker		h)	hostname1=$OPTARG;;
33*49cdfc7eSAndroid Build Coastguard Worker                d)      testdata=$OPTARG;;
34*49cdfc7eSAndroid Build Coastguard Worker
35*49cdfc7eSAndroid Build Coastguard Worker                \?)     echo "************** Help Info: ********************"
36*49cdfc7eSAndroid Build Coastguard Worker                        usage;;
37*49cdfc7eSAndroid Build Coastguard Worker        esac
38*49cdfc7eSAndroid Build Coastguard Workerdone
39*49cdfc7eSAndroid Build Coastguard Worker
40*49cdfc7eSAndroid Build Coastguard Workerif [ ! -n "$hostname1"  ]; then
41*49cdfc7eSAndroid Build Coastguard Worker  echo "Missing the hostname! A hostname must be passed for the test."
42*49cdfc7eSAndroid Build Coastguard Worker  usage;
43*49cdfc7eSAndroid Build Coastguard Worker  exit
44*49cdfc7eSAndroid Build Coastguard Workerfi
45*49cdfc7eSAndroid Build Coastguard Worker
46*49cdfc7eSAndroid Build Coastguard Workerif [ ! -n "$testdata" ]; then
47*49cdfc7eSAndroid Build Coastguard Worker  echo "Missing test data! You must pass data for the test."
48*49cdfc7eSAndroid Build Coastguard Worker  usage;
49*49cdfc7eSAndroid Build Coastguard Worker  exit
50*49cdfc7eSAndroid Build Coastguard Workerfi
51*49cdfc7eSAndroid Build Coastguard Worker
52*49cdfc7eSAndroid Build Coastguard Workerecho "Starting UDP, TCP and Multicast tests..."
53*49cdfc7eSAndroid Build Coastguard Worker
54*49cdfc7eSAndroid Build Coastguard Workerecho "Starting ltpServer..."
55*49cdfc7eSAndroid Build Coastguard Worker
56*49cdfc7eSAndroid Build Coastguard Worker./ltpServer $hostname1 &
57*49cdfc7eSAndroid Build Coastguard Workersleep 5
58*49cdfc7eSAndroid Build Coastguard Workerecho "Starting ltpClient..."
59*49cdfc7eSAndroid Build Coastguard Worker./ltpClient $hostname1 $hostname1 $testdata
60*49cdfc7eSAndroid Build Coastguard Workersleep 1
61*49cdfc7eSAndroid Build Coastguard Workerkillall -9 ltpServer
62*49cdfc7eSAndroid Build Coastguard Workerkillall -9 ltpClient
63*49cdfc7eSAndroid Build Coastguard Worker
64*49cdfc7eSAndroid Build Coastguard Worker
65