Files
StreamDevice/streamApp/tests/testSeverityAndStatus

77 lines
1.5 KiB
Tcl
Executable File

#!/usr/bin/env tclsh
source streamtestlib.tcl
# Define records, protocol and startup (text goes to files)
# The asynPort "device" is connected to a network TCP socket
# Talk to the socket with send/receive/assure
# Send commands to the ioc shell with ioccmd
set records {
record (stringin, "DZ:readTimeout")
{
field (DTYP, "stream")
field (INP, "@test.proto read device")
}
record (bo, "DZ:echo")
{
field (DTYP, "stream")
field (OUT, "@test.proto print(DZ:readTimeout) device")
}
}
set protocol {
Terminator = LF;
read {out "Give me input"; in "%s";}
print {out "Text:'%(\$1.VAL)s' SEVR=%(\$1.SEVR)d STAT=%(\$1.STAT)d";}
}
set startup {
}
set debug 0
startioc
# reply timeout
process DZ:readTimeout
assure "Give me input\n"
after 1100
process DZ:echo
ioccmd {dbpr DZ:echo 1}
assure "Text:'' SEVR=3 STAT=10\n"
# read timeout
process DZ:readTimeout
assure "Give me input\n"
send "Trulala"
after 200
process DZ:echo
assure "Text:'Trulala' SEVR=3 STAT=1\n"
# reply timeout again, old input stays
process DZ:readTimeout
assure "Give me input\n"
after 1100
process DZ:echo
assure "Text:'Trulala' SEVR=3 STAT=10\n"
# mismatch, partially parsed
process DZ:readTimeout
assure "Give me input\n"
send "bla extra\n"
after 200
process DZ:echo
assure "Text:'bla' SEVR=3 STAT=12\n"
# success
process DZ:readTimeout
assure "Give me input\n"
send "Input\n"
after 200
process DZ:echo
assure "Text:'Input' SEVR=0 STAT=0\n"
finish