summaryrefslogtreecommitdiff
path: root/rts.tests
diff options
context:
space:
mode:
Diffstat (limited to 'rts.tests')
-rw-r--r--rts.tests255
1 files changed, 255 insertions, 0 deletions
diff --git a/rts.tests b/rts.tests
new file mode 100644
index 0000000..ba8477b
--- /dev/null
+++ b/rts.tests
@@ -0,0 +1,255 @@
+# Assumes that there is no port named nonexistentport.
+# Assumes that there is no listener for TCP port 16 at 127.0.0.1.
+# Assumes that there is no listener for TCP port 50016 at 127.0.0.1.
+# Assumes that there is no use of TCP port 50017 at 127.0.0.1.
+# Assumes that DNS lookup on nonexistent.local. will give hard error.
+
+# Not tested:
+# who@
+# date@
+# finger@
+# http@
+# tcpclient handles temporary DNS errors
+# tcpserver handles temporary DNS errors
+# tcpclient -i
+# tcpclient -r
+# tcpclient -h
+# tcpclient -d
+# tcpclient -D
+# tcpclient -T
+# tcpclient -t
+# tcpserver -1
+# tcpserver -p
+# tcpserver -r
+# tcpserver -h
+# tcpserver -o
+# tcpserver -O
+# tcpserver -d
+# tcpserver -D
+# tcpserver -v
+# tcpserver -c
+# tcpserver -g
+# tcpserver -u
+# tcpserver -b
+# tcpserver -t
+# tcpserver -x
+
+
+echo '--- tcpclient prints usage message without enough arguments'
+tcpclient 0 0; echo $?
+
+echo '--- tcpclient prints error message with unknown port name'
+tcpclient 0 nonexistentport echo wrong; echo $?
+
+echo '--- tcpclient prints error message when connection fails'
+tcpclient 0 016 echo wrong; echo $?
+
+echo '--- tcpclient -q does not print error message when connection fails'
+tcpclient -q 0 016 echo wrong; echo $?
+
+echo '--- tcpclient understands empty host name as synonym for 0'
+tcpclient '' 016 echo wrong; echo $?
+
+echo '--- tcpclient understands unbracketed IP address'
+tcpclient '127.000.000.001' 016 echo wrong; echo $?
+
+echo '--- tcpclient understands bracketed IP address'
+tcpclient '[127.000.000.001]' 016 echo wrong; echo $?
+
+echo '--- tcpclient prints error message with unknown host name'
+tcpclient nonexistent.local. 016 echo wrong; echo $?
+
+echo '--- tcpserver prints usage message without enough arguments'
+tcpserver 0 0; echo $?
+
+echo '--- tcpserver prints error message with unknown port name'
+tcpserver 0 nonexistentport echo wrong; echo $?
+
+echo '--- tcpserver prints error message with unknown host name'
+tcpserver nonexistent.local. 016 echo wrong; echo $?
+
+echo '--- tcpserver prints error message with non-local host name'
+tcpserver 1.2.3.4 016 echo wrong; echo $?
+
+tcpserver -q -R -H -l Local 127.0.0.1 50016 sh -c '
+ echo PROTO="$PROTO"
+ echo TCPLOCALHOST="$TCPLOCALHOST"
+ echo TCPLOCALIP="$TCPLOCALIP"
+ echo TCPLOCALPORT="$TCPLOCALPORT"
+ echo TCPREMOTEHOST="$TCPREMOTEHOST"
+ echo TCPREMOTEIP="$TCPREMOTEIP"
+ echo TCPREMOTEPORT="$TCPREMOTEPORT"
+ echo TCPREMOTEINFO="$TCPREMOTEINFO"
+' &
+pid=$!
+sleep 1 #XXX
+
+echo '--- tcpserver sets basic environment variables'
+tcpclient -p 50017 -R -H -l Local 0 50016 sh -c 'cat <&6'
+echo $?
+
+echo '--- tcpclient sets basic environment variables'
+tcpclient -p 50017 -R -H -l Local 0 50016 sh -c '
+ echo PROTO="$PROTO"
+ echo TCPLOCALHOST="$TCPLOCALHOST"
+ echo TCPLOCALIP="$TCPLOCALIP"
+ echo TCPLOCALPORT="$TCPLOCALPORT"
+ echo TCPREMOTEHOST="$TCPREMOTEHOST"
+ echo TCPREMOTEIP="$TCPREMOTEIP"
+ echo TCPREMOTEPORT="$TCPREMOTEPORT"
+ echo TCPREMOTEINFO="$TCPREMOTEINFO"
+'
+echo $?
+
+echo '--- tcpclient -v works'
+tcpclient -v -R -H -l Local 0 50016 echo ok
+echo $?
+
+echo '--- tcpserver prints error message with used port'
+tcpserver -R -H -l Local 127.0.0.1 50016 echo wrong
+echo $?
+
+kill $pid
+wait
+
+tcpserver -B banner -q -R -H -l Local 127.0.0.1 50016 echo ok &
+pid=$!
+sleep 1 #XXX
+
+echo '--- tcpcat works; tcpserver -B works'
+tcpcat 0 50016
+echo $?
+
+echo '--- mconnect works'
+mconnect 0 50016 </dev/null
+echo $?
+
+kill $pid
+wait
+
+echo '--- tcprules prints usage message without enough arguments'
+tcprules test.cdb; echo $?
+
+echo '--- tcprules prints error message if it cannot create tmp'
+echo 1.2.3.4:deny | tcprules test.cdb /dev/nonexistent/tmp; echo $?
+
+echo '--- tcprules prints error message if it cannot move tmp to cdb'
+echo 1.2.3.4:deny | tcprules /dev/nonexistent/cdb test.tmp; echo $?
+
+echo '--- tcprules creates a cdb file'
+echo 1.2.3.4:deny | tcprules test.cdb test.tmp; echo $?
+
+echo '--- tcprulescheck sees deny'
+tcprulescheck test.cdb 1.2.3.4; echo $?
+
+echo '--- tcprulescheck does not apply deny to another host'
+tcprulescheck test.cdb 1.2.3.5; echo $?
+
+echo '--- tcprules replaces a cdb file'
+echo 'joe@127.0.0.1:allow,which=/first/
+18.23.0.32:allow,which="second"
+127.:allow,which=+third+
+:allow,which==fourth=' | tcprules test.cdb test.tmp; echo $?
+
+echo '--- tcprulescheck finds rule with address and info'
+tcprulescheck test.cdb 127.0.0.1 joe; echo $?
+
+echo '--- tcprulescheck finds rule with address'
+tcprulescheck test.cdb 18.23.0.32 joe ; echo $?
+
+echo '--- tcprulescheck finds one-dot wildcard'
+tcprulescheck test.cdb 127.0.0.1 bill; echo $?
+
+echo '--- tcprulescheck finds zero-dot wildcard'
+tcprulescheck test.cdb 10.119.75.38 bill; echo $?
+
+echo '--- tcprules handles comments, address ranges, multiple variables'
+echo '127.0-5.:allow,which=/first/,where=/whatever/
+# comment' | tcprules test.cdb test.tmp; echo $?
+tcprulescheck test.cdb 127.0.0.1
+tcprulescheck test.cdb 127.1.0.1
+tcprulescheck test.cdb 127.2.0.1
+tcprulescheck test.cdb 127.3.0.1
+tcprulescheck test.cdb 127.4.0.1
+tcprulescheck test.cdb 127.5.0.1
+tcprulescheck test.cdb 127.6.0.1
+tcprulescheck test.cdb 127.7.0.1
+tcprulescheck test.cdb 127.8.0.1
+tcprulescheck test.cdb 127.9.0.1
+tcprulescheck test.cdb 127.10.0.1
+
+
+echo '--- addcr leaves an empty file alone'
+echo -n '' | addcr; echo $?
+
+echo '--- addcr leaves a partial final line alone'
+echo -n test | addcr; echo $?
+
+echo '--- addcr adds CR after the first line'
+echo test | addcr; echo $?
+
+echo '--- addcr adds CR after the second line'
+( echo test; echo test2 ) | addcr; echo $?
+
+echo '--- addcr handles nulls'
+echo test | tr e '\0' | addcr; echo $?
+
+echo '--- delcr leaves an empty file alone'
+echo -n '' | delcr; echo $?
+
+echo '--- delcr leaves a non-CR line alone'
+echo test | delcr; echo $?
+
+echo '--- delcr removes CR if a line has it'
+echo testx | tr x '\015' | delcr; echo $?
+
+echo '--- delcr converts CR CR LF to CR LF'
+echo testxx | tr x '\015' | delcr; echo $?
+
+echo '--- delcr removes CR from a partial final line'
+echo -n testx | tr x '\015' | delcr; echo $?
+
+echo '--- delcr handles a non-CR partial final line'
+echo -n test | delcr; echo $?
+
+echo '--- delcr handles nulls'
+echo test | tr e '\0' | delcr; echo $?
+
+echo '--- fixcr leaves an empty file alone'
+echo -n '' | fixcr; echo $?
+
+echo '--- fixcr leaves a partial final line alone'
+echo -n test | fixcr; echo $?
+
+echo '--- fixcr adds CR after the first line'
+echo test | fixcr; echo $?
+
+echo '--- fixcr adds CR after the second line'
+( echo test; echo test2 ) | fixcr; echo $?
+
+echo '--- fixcr does not add CR if a line has it'
+echo testx | tr x '\015' | fixcr; echo $?
+
+echo '--- fixcr handles nulls'
+echo test | tr e '\0' | fixcr; echo $?
+
+echo '--- recordio works'
+( echo test; sleep 1 ) | recordio cat 2>&1 >/dev/null \
+| sed 's/^[0-9]*/.../' | sed 's/$/$/'
+
+echo '--- recordio handles multiple-line packets'
+( echo 'test
+test2'; sleep 1 ) | recordio cat 2>&1 >/dev/null \
+| sed 's/^[0-9]*/.../' | sed 's/$/$/'
+
+echo '--- recordio handles partial final lines'
+( echo -n test; sleep 1 ) | recordio cat 2>&1 >/dev/null \
+| sed 's/^[0-9]*/.../' | sed 's/$/$/'
+
+echo '--- argv0 works'
+argv0 sh zero -c 'echo $0'; echo $?
+
+echo '--- argv0 requires arguments'
+argv0 sh; echo $?
+
+exit 0