forked from geoffmeyers/interceptty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test
executable file
·148 lines (123 loc) · 2.41 KB
/
test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/bash
# You can run this script after building to test out interceptty in a
# safe way.
# These two settings are adjustable, although the defaults will
# probably work fine.
INET_PORT=9999
DELAY=2
trap 'exec 2>/dev/null; [ -n "$kids" ] && kill $kids' EXIT
printf "%40s" "Starting up echo server..."
./interceptty -q '!cat' ./test1.tty &
kids="$kids $!"
sleep $DELAY
if [ -c ./test1.tty ]
then
echo "OK"
else
echo "NO"
exit 1
fi
printf "%40s" "Testing echo server..."
if ./testport ./test1.tty "Test 1 OK"
then
echo "OK"
else
echo "NO"
exit 1
fi
printf "%40s" "Starting up tty server..."
./interceptty -q ./test1.tty ./test2.tty &
kids="$kids $!"
sleep $DELAY
if [ -c ./test2.tty ]
then
echo "OK"
else
echo "NO"
exit 1
fi
printf "%40s" "Testing tty server..."
if ./testport ./test2.tty "Test 2 OK"
then
echo "OK"
else
echo "NO"
exit 1
fi
printf "%40s" "Starting Unix socket server..."
./interceptty -q ./test2.tty @./test3.sock &
kids="$kids $!"
sleep $DELAY
if [ -r ./test3.sock ]
then
echo "OK"
else
echo "NO"
exit 1
fi
printf "%40s" "Starting Unix socket client..."
./interceptty -q @./test3.sock ./test4.tty &
kids="$kids $!"
sleep $DELAY
if [ -c ./test4.tty ]
then
echo "OK"
else
echo "NO"
exit 1
fi
printf "%40s" "Testing Unix sockets..."
if ./testport ./test4.tty "Test 4 OK"
then
echo "OK"
else
echo "NO"
exit 1
fi
printf "%40s" "Starting file descriptor server..."
./interceptty -q =0,1 ./test5.tty <test4.tty >>test4.tty &
kids="$kids $!"
sleep $DELAY
if [ -c ./test5.tty ]
then
echo "OK"
else
echo "NO"
exit 1
fi
printf "%40s" "Testing file descriptors..."
if ./testport ./test5.tty "Test 5 OK"
then
echo "OK"
else
echo "NO"
exit 1
fi
printf "%40s" "Starting Inet server on port $INET_PORT..."
./interceptty -q ./test5.tty @localhost:$INET_PORT &
kids="$kids $!"
sleep $DELAY
# The netstat test we used to do doesn't work in some configurations.
echo "OK"
printf "%40s" "Starting Inet client on port $INET_PORT..."
./interceptty -q @localhost:$INET_PORT ./test6.tty &
kids="$kids $!"
sleep $DELAY
if [ -c ./test6.tty ]
then
echo "OK"
else
echo "NO"
echo "You may want to try changing the port used for testing, at the top of $0."
exit 1
fi
printf "%40s" "Testing Internet socket server..."
if ./testport ./test6.tty "Test 6 OK"
then
echo "OK"
else
echo "You may want to try changing the port used for testing, at the top of $0."
echo "NO"
exit 1
fi
exit 0