Add tests.
This commit is contained in:
parent
96d17772f9
commit
b9bb1dcdbe
|
@ -6,4 +6,8 @@
|
||||||
# this notice are preserved. This file is offered as-is, without any warranty.
|
# this notice are preserved. This file is offered as-is, without any warranty.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
*.log
|
||||||
|
*.sum
|
||||||
|
site.bak
|
||||||
|
site.exp
|
||||||
tcsgrep
|
tcsgrep
|
||||||
|
|
|
@ -6,7 +6,12 @@
|
||||||
# this notice are preserved. This file is offered as-is, without any warranty.
|
# this notice are preserved. This file is offered as-is, without any warranty.
|
||||||
#
|
#
|
||||||
|
|
||||||
AM_CPPFLAGS = -I$(top_srcdir)/src
|
AUTOMAKE_OPTIONS = dejagnu
|
||||||
|
AM_CPPFLAGS = -I$(top_srcdir)/src
|
||||||
|
|
||||||
noinst_PROGRAMS = tcsgrep
|
noinst_PROGRAMS = tcsgrep
|
||||||
tcsgrep_SOURCES = tcsgrep.c
|
tcsgrep_SOURCES = tcsgrep.c
|
||||||
tcsgrep_LDADD = $(top_srcdir)/src/libctlseqs.la
|
tcsgrep_LDADD = $(top_srcdir)/src/libctlseqs.la
|
||||||
|
|
||||||
|
RUNTESTDEFAULTFLAGS = TCSGREP_BIN=$(srcdir)/tcsgrep
|
||||||
|
EXTRA_DEJAGNU_SITE_CONFIG = $(srcdir)/init.exp
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
#
|
||||||
|
# Copyright (C) 2021 CismonX <admin@cismon.net>
|
||||||
|
#
|
||||||
|
# Copying and distribution of this file, with or without modification, are
|
||||||
|
# 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 [ expr int(rand()*5000) ]
|
||||||
|
set n2 [ expr int(rand()*5000) ]
|
||||||
|
set n3 [ expr int(rand()*5000) ]
|
||||||
|
|
||||||
|
set input { }
|
||||||
|
lappend input "$CSI$n1;${n2}H"
|
||||||
|
lappend input "$DCS$n1;$n2|$n3$ST"
|
||||||
|
lappend input "$CSI<?${n1}Z"
|
||||||
|
|
||||||
|
set output { }
|
||||||
|
lappend output "OK CUP $n1 $n2"
|
||||||
|
lappend output "OK DECUDK $n1 $n2 $n3"
|
||||||
|
lappend output "NOMATCH [ expr [ string length $n1 ] + 5 ] ESC \[ < ? [ split $n1 {} ] Z"
|
||||||
|
|
||||||
|
tcsgrep_start
|
||||||
|
|
||||||
|
for { set i 0 } { $i < [ llength $input ] } { incr i } {
|
||||||
|
set seq [ lindex $input $i ]
|
||||||
|
set expected [ lindex $output $i ]
|
||||||
|
send -- $seq
|
||||||
|
expect {
|
||||||
|
-ex "$expected\n" {
|
||||||
|
pass "OK"
|
||||||
|
}
|
||||||
|
default {
|
||||||
|
puts $expect_out(buffer)
|
||||||
|
fail "fail"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tcsgrep_stop
|
|
@ -0,0 +1,7 @@
|
||||||
|
#
|
||||||
|
# Copyright (C) 2021 CismonX <admin@cismon.net>
|
||||||
|
#
|
||||||
|
# Copying and distribution of this file, with or without modification, are
|
||||||
|
# permitted in any medium without royalty, provided the copyright notice and
|
||||||
|
# this notice are preserved. This file is offered as-is, without any warranty.
|
||||||
|
#
|
|
@ -0,0 +1,7 @@
|
||||||
|
#
|
||||||
|
# Copyright (C) 2021 CismonX <admin@cismon.net>
|
||||||
|
#
|
||||||
|
# Copying and distribution of this file, with or without modification, are
|
||||||
|
# permitted in any medium without royalty, provided the copyright notice and
|
||||||
|
# this notice are preserved. This file is offered as-is, without any warranty.
|
||||||
|
#
|
|
@ -0,0 +1,7 @@
|
||||||
|
#
|
||||||
|
# Copyright (C) 2021 CismonX <admin@cismon.net>
|
||||||
|
#
|
||||||
|
# Copying and distribution of this file, with or without modification, are
|
||||||
|
# permitted in any medium without royalty, provided the copyright notice and
|
||||||
|
# this notice are preserved. This file is offered as-is, without any warranty.
|
||||||
|
#
|
|
@ -0,0 +1,44 @@
|
||||||
|
#
|
||||||
|
# Copyright (C) 2021 CismonX <admin@cismon.net>
|
||||||
|
#
|
||||||
|
# Copying and distribution of this file, with or without modification, are
|
||||||
|
# permitted in any medium without royalty, provided the copyright notice and
|
||||||
|
# this notice are preserved. This file is offered as-is, without any warranty.
|
||||||
|
#
|
||||||
|
|
||||||
|
proc tcsgrep_start args {
|
||||||
|
global TCSGREP_BIN
|
||||||
|
set run_cmd [ list $TCSGREP_BIN "-t500" ]
|
||||||
|
foreach arg $args {
|
||||||
|
lappend run_cmd [
|
||||||
|
switch -regexp -matchvar value -- $arg {
|
||||||
|
verbose { lindex "-v" }
|
||||||
|
purge { lindex "-p" }
|
||||||
|
limit=(\\d+) { lindex "-l[lindex $value 1]" }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
set stty_init { raw -echo }
|
||||||
|
global spawn_id
|
||||||
|
spawn {*}$run_cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
proc tcsgrep_stop { } {
|
||||||
|
global spawn_id
|
||||||
|
send \x04
|
||||||
|
expect {
|
||||||
|
-ex "NOSEQ 1 EOT\n" { }
|
||||||
|
default {
|
||||||
|
fail "program exited unexpectedly"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch wait result
|
||||||
|
if { [ set exit_code [ lindex $result 3 ] ] } {
|
||||||
|
fail "program exited with code $exit_code"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
set ESC "\x1b"
|
||||||
|
set CSI "$ESC\["
|
||||||
|
set DCS "${ESC}P"
|
||||||
|
set ST "$ESC\\"
|
|
@ -439,7 +439,7 @@ main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
case CTLSEQS_NOSEQ:
|
case CTLSEQS_NOSEQ:
|
||||||
print_generic_seq("NOSEQ", result, true);
|
print_generic_seq("NOSEQ", result, true);
|
||||||
if (result[1].str[0] == 0x04) {
|
if (!ctx.not_tty && result[1].str[0] == 0x04) {
|
||||||
goto terminate;
|
goto terminate;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue