Add tests.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
CismonX 2021-02-01 20:49:18 +08:00
parent 9f60546d0b
commit 5b9d919a17
Signed by: cismonx
GPG Key ID: 3094873E29A482FB
3 changed files with 64 additions and 3 deletions

View File

@ -5,3 +5,24 @@
# permitted in any medium without royalty, provided the copyright notice and
# this notice are preserved. This file is offered as-is, without any warranty.
#
set tool ctlseqs
set timeout 2
set seq "${CSI}123;4567S"
set expected "NOMEM 10 ESC \[ 1 2 3 ; 4 5 6 7\nNOSEQ 1 S"
tcsgrep_start limit=10 purge
send -- $seq
expect {
-ex "$expected\n" {
pass "OK"
}
default {
puts $expect_out(buffer)
fail "fail"
}
}
tcsgrep_stop

View File

@ -5,3 +5,42 @@
# permitted in any medium without royalty, provided the copyright notice and
# this notice are preserved. This file is offered as-is, without any warranty.
#
set tool ctlseqs
set timeout 2
set n1 [ random_int ]
set nlen [ string length $n1 ]
tcsgrep_start verbose
send -- "$CSI"
expect {
-ex "PARTIAL 2 ESC \[\n" { }
default {
puts $expect_out(buffer)
fail "fail"
}
}
for { set i 0 } { $i < $nlen } { incr i } {
send -- [ string index $n1 $i ]
expect {
-ex "PARTIAL [ expr $i + 3 ] ESC \[ [ split [ string range $n1 0 $i ] {} ]\n" { }
default {
puts $expect_out(buffer)
fail "fail"
}
}
}
send -- "p"
expect {
-ex "NOMATCH [ expr $nlen + 3 ] ESC \[ [ split $n1 {} ] p\n" { }
default {
puts $expect_out(buffer)
fail "fail"
}
}
tcsgrep_stop

View File

@ -17,9 +17,10 @@ proc tcsgrep_start args {
foreach arg $args {
lappend run_cmd [
switch -regexp -matchvar value -- $arg {
verbose { lindex "-v" }
purge { lindex "-p" }
limit=(\\d+) { lindex "-l[lindex $value 1]" }
verbose { lindex "-v" }
purge { lindex "-p" }
limit=(\\d+) { lindex "-l [ lindex $value 1 ]" }
timeout=(\\d+) { lindex "-t [ lindex $value 1 ]" }
}
]
}