aboutsummaryrefslogtreecommitdiff
path: root/testsuite/runtest.libs/mockutil.tcl
diff options
context:
space:
mode:
authorJacob Bachmeyer <jcb@gnu.org>2022-09-30 21:14:37 -0500
committerJacob Bachmeyer <jcb@gnu.org>2022-09-30 21:14:37 -0500
commitaf1760154d4607fa59b1c4e06df59f8ae474b440 (patch)
tree555c2ab5d30617adc529af3090c7867040f5905a /testsuite/runtest.libs/mockutil.tcl
parent355456674cce4400c85770b50b0f1dda6cbebb9a (diff)
downloaddejagnu-af1760154d4607fa59b1c4e06df59f8ae474b440.zip
dejagnu-af1760154d4607fa59b1c4e06df59f8ae474b440.tar.gz
dejagnu-af1760154d4607fa59b1c4e06df59f8ae474b440.tar.bz2
Add initial unit tests for lib/dg.exp
Diffstat (limited to 'testsuite/runtest.libs/mockutil.tcl')
-rw-r--r--testsuite/runtest.libs/mockutil.tcl18
1 files changed, 17 insertions, 1 deletions
diff --git a/testsuite/runtest.libs/mockutil.tcl b/testsuite/runtest.libs/mockutil.tcl
index a8fa2fd..20b6b9b 100644
--- a/testsuite/runtest.libs/mockutil.tcl
+++ b/testsuite/runtest.libs/mockutil.tcl
@@ -28,7 +28,7 @@ proc strip_comment_lines { text } {
proc create_test_interpreter { name opts } {
array set opt {
- copy_arrays {} copy_procs {} copy_vars {}
+ copy_arrays {} copy_procs {} copy_vars {} attach_vfs {}
link_channels {} link_procs {} shim_procs {} mocks {} vars {}
}
array set opt [strip_comment_lines $opts]
@@ -75,6 +75,9 @@ proc create_test_interpreter { name opts } {
foreach chan $opt(link_channels) { interp share {} $chan $name }
foreach link $opt(link_procs) { establish_link $name $link }
foreach shim $opt(shim_procs) { establish_shim $name $shim }
+ if { $opt(attach_vfs) ne "" } {
+ attach_mockvfs $name [lindex $opt(attach_vfs) 0]
+ }
return $name
}
proc copy_array_to_test_interpreter { sicmd dest {src {}} } {
@@ -176,6 +179,13 @@ proc match_argpat { argpat call } {
return $result
}
+# test_proc_with_mocks testName sicmd testCode {
+# check_calls {
+# prefix mode:[*U[:digit:]] { [argument pattern]... }
+# prefix mode:[!] { }
+# prefix mode:[C] [ { count } | count ]
+# }
+# }
proc test_proc_with_mocks { name sicmd code args } {
array set opt {
check_calls {}
@@ -217,6 +227,12 @@ proc test_proc_with_mocks { name sicmd code args } {
verbose " failed!"
set result fail
}
+ } elseif { $callpos eq "C" } {
+ # succeed if exactly N calls match prefix
+ if { [llength $calls] != [lindex $argpat 0] } {
+ verbose " failed!"
+ set result fail
+ }
} elseif { $callpos eq "U" } {
# prefix selects one unique call
if { [llength $calls] != 1 } {