summaryrefslogtreecommitdiff
path: root/xdelta3/go/src/xdelta/rstream.go
diff options
context:
space:
mode:
authorJoshua MacDonald <josh.macdonald@gmail.com>2015-11-23 20:28:05 -0800
committerJoshua MacDonald <josh.macdonald@gmail.com>2015-11-23 20:28:05 -0800
commitb24969720ac9c92f3d7327250b3ee8e86acc6def (patch)
tree1e2401ee0b0cfa0f9d382fbc33f3445a3947fb49 /xdelta3/go/src/xdelta/rstream.go
parentede482d8f3398262adcfb23095b6caad5872d8ba (diff)
Improve error handling; allow two routines to have errors in a successful test (Empty, which can get bad file descriptor after the process exits, and the Decode-Source writer, since the decoder is not required to read the full source)
Diffstat (limited to 'xdelta3/go/src/xdelta/rstream.go')
-rw-r--r--xdelta3/go/src/xdelta/rstream.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/xdelta3/go/src/xdelta/rstream.go b/xdelta3/go/src/xdelta/rstream.go
index 3f520d7..e31b0b0 100644
--- a/xdelta3/go/src/xdelta/rstream.go
+++ b/xdelta3/go/src/xdelta/rstream.go
@@ -10,17 +10,20 @@ const (
10 blocksize = 16380 10 blocksize = 16380
11) 11)
12 12
13func WriteRstreams(t *TestGroup, seed, offset, len int64, 13func WriteRstreams(t *TestGroup, desc string, seed, offset, len int64,
14 src, tgt io.WriteCloser) { 14 src, tgt io.WriteCloser) {
15 t.Go("src", func (g Goroutine) { 15 t.Go("src-write:"+desc, func (g Goroutine) {
16 go writeOne(g, seed, 0, len, src) 16 writeOne(g, seed, 0, len, src, false)
17 }) 17 })
18 t.Go("tgt", func (g Goroutine) { 18 t.Go("tgt-write:"+desc, func (g Goroutine) {
19 go writeOne(g, seed, offset, len, tgt) 19 writeOne(g, seed, offset, len, tgt, true)
20 }) 20 })
21} 21}
22 22
23func writeOne(g Goroutine, seed, offset, len int64, stream io.WriteCloser) { 23func writeOne(g Goroutine, seed, offset, len int64, stream io.WriteCloser, readall bool) {
24 if !readall {
25 g.OK()
26 }
24 if offset != 0 { 27 if offset != 0 {
25 // Fill with other random data until the offset 28 // Fill with other random data until the offset
26 if err := writeRand(rand.New(rand.NewSource(^seed)), offset, stream); err != nil { 29 if err := writeRand(rand.New(rand.NewSource(^seed)), offset, stream); err != nil {