xref: /freebsd/tools/regression/sockets/unix_cmsg/unix_cmsg.t (revision 8ddb146abcdf061be9f2c0db7e391697dafad85c)
1#!/bin/sh
2# $FreeBSD$
3
4cd `dirname $0`
5cmd="./`basename $0 .t`"
6
7make ${cmd} >/dev/null 2>&1
8
9IFS=
10n=0
11
12run()
13{
14	result=`${cmd} -t $2 $3 ${5%% *} 2>&1`
15	if [ $? -ne 0 ]; then
16		echo -n "not "
17	fi
18	echo "ok $1 - $4 ${5#* }"
19	echo ${result} | grep -E "SERVER|CLIENT" | while read line; do
20		echo "# ${line}"
21	done
22}
23
24echo "1..47"
25
26for t1 in \
27	"1 Sending, receiving cmsgcred" \
28	"4 Sending cmsgcred, receiving sockcred" \
29	"5 Sending, receiving timeval" \
30	"6 Sending, receiving bintime" \
31	"7 Check cmsghdr.cmsg_len"
32do
33	for t2 in \
34		"0 " \
35		"1 (no data)" \
36		"2 (no array)" \
37		"3 (no data, array)"
38	do
39		n=$((n + 1))
40		run ${n} stream "-z ${t2%% *}" STREAM "${t1} ${t2#* }"
41	done
42done
43
44for t1 in \
45	"2 Receiving sockcred (listening socket)" \
46	"3 Receiving sockcred (accepted socket)"
47do
48	for t2 in \
49		"0 " \
50		"1 (no data)"
51	do
52		n=$((n + 1))
53		run ${n} stream "-z ${t2%% *}" STREAM "${t1} ${t2#* }"
54	done
55done
56
57n=$((n + 1))
58run ${n} stream "-z 0" STREAM "8 Check LOCAL_PEERCRED socket option"
59
60for t1 in \
61	"1 Sending, receiving cmsgcred" \
62	"3 Sending cmsgcred, receiving sockcred" \
63	"4 Sending, receiving timeval" \
64	"5 Sending, receiving bintime" \
65	"6 Check cmsghdr.cmsg_len"
66do
67	for t2 in \
68		"0 " \
69		"1 (no data)" \
70		"2 (no array)" \
71		"3 (no data, array)"
72	do
73		n=$((n + 1))
74		run ${n} dgram "-z ${t2%% *}" DGRAM "${t1} ${t2#* }"
75	done
76done
77
78for t1 in \
79	"2 Receiving sockcred"
80do
81	for t2 in \
82		"0 " \
83		"1 (no data)"
84	do
85		n=$((n + 1))
86		run ${n} dgram "-z ${t2%% *}" DGRAM "${t1} ${t2#* }"
87	done
88done
89