5583d77f1c 2019-09-14 rkeene: set dir "//xvfs:/example"
5583d77f1c 2019-09-14 rkeene: set dirNative [file join [pwd] example]
5583d77f1c 2019-09-14 rkeene: set file "${dir}/foo"
7d74392642 2019-09-13 rkeene:
7d74392642 2019-09-13 rkeene: set fd [open $file]
38bed7cee0 2019-09-13 rkeene: seek $fd 0 end
38bed7cee0 2019-09-13 rkeene: seek $fd -1 current
38bed7cee0 2019-09-13 rkeene: set check [read $fd 1]
38bed7cee0 2019-09-13 rkeene: if {$check != "\n"} {
38bed7cee0 2019-09-13 rkeene: error "EXPECTED: (new line); GOT: [binary encode hex $check]"
38bed7cee0 2019-09-13 rkeene: }
7d74392642 2019-09-13 rkeene: close $fd
7d74392642 2019-09-13 rkeene:
7d74392642 2019-09-13 rkeene: set fd1 [open $file]
7d74392642 2019-09-13 rkeene: set fd2 [open $file]
7d74392642 2019-09-13 rkeene: set data1 [read $fd1]
7d74392642 2019-09-13 rkeene: close $fd1
7d74392642 2019-09-13 rkeene: set data2 [read $fd2]
7d74392642 2019-09-13 rkeene: close $fd2
7d74392642 2019-09-13 rkeene: if {$data1 != $data2} {
7d74392642 2019-09-13 rkeene: error "EXPECTED match, differs"
7d74392642 2019-09-13 rkeene: }
7d74392642 2019-09-13 rkeene:
7d74392642 2019-09-13 rkeene: set fd [open $file]
7d74392642 2019-09-13 rkeene: seek $fd 0 end
7d74392642 2019-09-13 rkeene: set size [tell $fd]
7d74392642 2019-09-13 rkeene: close $fd
7d74392642 2019-09-13 rkeene: set fd [open $file]
7d74392642 2019-09-13 rkeene: set done false
7d74392642 2019-09-13 rkeene: set calls 0
7d74392642 2019-09-13 rkeene: set output ""
7d74392642 2019-09-13 rkeene: fileevent $fd readable [list apply {{fd} {
7d74392642 2019-09-13 rkeene: set pos [tell $fd]
7d74392642 2019-09-13 rkeene: set x [read $fd 1]
7d74392642 2019-09-13 rkeene: if {[string length $x] == 0} {
7d74392642 2019-09-13 rkeene: set ::done true
7d74392642 2019-09-13 rkeene: fileevent $fd readable ""
7d74392642 2019-09-13 rkeene: }
7d74392642 2019-09-13 rkeene:
7d74392642 2019-09-13 rkeene: lappend ::output $pos
7d74392642 2019-09-13 rkeene: incr ::calls
7d74392642 2019-09-13 rkeene: }} $fd]
7d74392642 2019-09-13 rkeene: vwait done
7d74392642 2019-09-13 rkeene: if {$calls != ($size + 1)} {
7d74392642 2019-09-13 rkeene: error "EXPECTED [expr {$size + 1}], got $calls"
7d74392642 2019-09-13 rkeene: }
7d74392642 2019-09-13 rkeene: if {[lsort -integer $output] != $output} {
7d74392642 2019-09-13 rkeene: error "EXPECTED [lsort -integer $output], GOT $output"
7d74392642 2019-09-13 rkeene: }
aa08a4a749 2019-09-14 rkeene: close $fd
aa08a4a749 2019-09-14 rkeene: update idle
5583d77f1c 2019-09-14 rkeene:
5583d77f1c 2019-09-14 rkeene:
5583d77f1c 2019-09-14 rkeene: proc glob_verify {args} {
5583d77f1c 2019-09-14 rkeene: set rv [glob -nocomplain -directory $::dir {*}$args]
5583d77f1c 2019-09-14 rkeene: set verify [glob -nocomplain -directory $::dirNative {*}$args]
5583d77f1c 2019-09-14 rkeene:
5583d77f1c 2019-09-14 rkeene: if {[llength $rv] != [llength $verify]} {
5583d77f1c 2019-09-14 rkeene: error "VERIFY FAILED: glob ... $args ($rv versus $verify)"
5583d77f1c 2019-09-14 rkeene: }
5583d77f1c 2019-09-14 rkeene:
5583d77f1c 2019-09-14 rkeene: return $rv
5583d77f1c 2019-09-14 rkeene: }
5583d77f1c 2019-09-14 rkeene:
5583d77f1c 2019-09-14 rkeene: set check [glob_verify *]
5583d77f1c 2019-09-14 rkeene: if {[llength $check] < 2} {
5583d77f1c 2019-09-14 rkeene: error "EXPECTED >=2, GOT [llength $check] ($check)"
5583d77f1c 2019-09-14 rkeene: }
5583d77f1c 2019-09-14 rkeene:
5583d77f1c 2019-09-14 rkeene: set check [glob_verify f*]
5583d77f1c 2019-09-14 rkeene: if {[llength $check] != 1} {
5583d77f1c 2019-09-14 rkeene: error "EXPECTED 1, GOT [llength $check] ($check)"
5583d77f1c 2019-09-14 rkeene: }
5583d77f1c 2019-09-14 rkeene:
5583d77f1c 2019-09-14 rkeene: set check [glob_verify ./f*]
5583d77f1c 2019-09-14 rkeene: if {[llength $check] != 1} {
5583d77f1c 2019-09-14 rkeene: error "EXPECTED 1, GOT [llength $check] ($check)"
5583d77f1c 2019-09-14 rkeene: }
5583d77f1c 2019-09-14 rkeene:
5583d77f1c 2019-09-14 rkeene: set check [glob_verify -type f ./f*]
5583d77f1c 2019-09-14 rkeene: if {[llength $check] != 1} {
5583d77f1c 2019-09-14 rkeene: error "EXPECTED 1, GOT [llength $check] ($check)"
5583d77f1c 2019-09-14 rkeene: }
5583d77f1c 2019-09-14 rkeene:
5583d77f1c 2019-09-14 rkeene: set check [glob_verify -type d ./f*]
5583d77f1c 2019-09-14 rkeene: if {[llength $check] != 0} {
5583d77f1c 2019-09-14 rkeene: error "EXPECTED 0, GOT [llength $check] ($check)"
5583d77f1c 2019-09-14 rkeene: }
5583d77f1c 2019-09-14 rkeene:
5583d77f1c 2019-09-14 rkeene: set check [glob_verify x*]
5583d77f1c 2019-09-14 rkeene: if {[llength $check] != 0} {
5583d77f1c 2019-09-14 rkeene: error "EXPECTED 0, GOT [llength $check] ($check)"
5583d77f1c 2019-09-14 rkeene: }
5583d77f1c 2019-09-14 rkeene:
5583d77f1c 2019-09-14 rkeene: set check [glob_verify lib/*]
5583d77f1c 2019-09-14 rkeene: if {[llength $check] != 1} {
5583d77f1c 2019-09-14 rkeene: error "EXPECTED 1, GOT [llength $check] ($check)"
5583d77f1c 2019-09-14 rkeene: }
5583d77f1c 2019-09-14 rkeene:
5583d77f1c 2019-09-14 rkeene: set check [lindex $check 0]
5583d77f1c 2019-09-14 rkeene: if {![string match $dir/* $check]} {
5583d77f1c 2019-09-14 rkeene: error "EXPECTED \"$dir/*\", GOT $check"
5583d77f1c 2019-09-14 rkeene: }
5583d77f1c 2019-09-14 rkeene:
5583d77f1c 2019-09-14 rkeene: set check [glob_verify -type d *]
5583d77f1c 2019-09-14 rkeene: if {[llength $check] != 1} {
5583d77f1c 2019-09-14 rkeene: error "EXPECTED 1, GOT [llength $check] ($check)"
5583d77f1c 2019-09-14 rkeene: }
12ff77016f 2019-09-14 rkeene:
12ff77016f 2019-09-14 rkeene: set check [glob_verify -type d lib/*]
12ff77016f 2019-09-14 rkeene: if {[llength $check] != 1} {
12ff77016f 2019-09-14 rkeene: error "EXPECTED 1, GOT [llength $check] ($check)"
12ff77016f 2019-09-14 rkeene: }
12ff77016f 2019-09-14 rkeene:
12ff77016f 2019-09-14 rkeene: cd $dir
12ff77016f 2019-09-14 rkeene: cd lib
12ff77016f 2019-09-14 rkeene: glob *
12ff77016f 2019-09-14 rkeene:
12ff77016f 2019-09-14 rkeene:
12ff77016f 2019-09-14 rkeene: lappend auto_path ${dir}/lib
12ff77016f 2019-09-14 rkeene: package require hello
38bed7cee0 2019-09-13 rkeene:
38bed7cee0 2019-09-13 rkeene: puts "ALL TESTS PASSED"