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