diff options
author | Joshua MacDonald <josh.macdonald@gmail.com> | 2015-11-23 20:28:05 -0800 |
---|---|---|
committer | Joshua MacDonald <josh.macdonald@gmail.com> | 2015-11-23 20:28:05 -0800 |
commit | b24969720ac9c92f3d7327250b3ee8e86acc6def (patch) | |
tree | 1e2401ee0b0cfa0f9d382fbc33f3445a3947fb49 /xdelta3/go/src/regtest.go | |
parent | ede482d8f3398262adcfb23095b6caad5872d8ba (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/regtest.go')
-rw-r--r-- | xdelta3/go/src/regtest.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/xdelta3/go/src/regtest.go b/xdelta3/go/src/regtest.go index 793c9fc..385c936 100644 --- a/xdelta3/go/src/regtest.go +++ b/xdelta3/go/src/regtest.go | |||
@@ -20,7 +20,7 @@ func smokeTest(r *xdelta.Runner, p *xdelta.Program) { | |||
20 | target := "Hello world!" | 20 | target := "Hello world!" |
21 | source := "Hello world, nice to meet you!" | 21 | source := "Hello world, nice to meet you!" |
22 | 22 | ||
23 | enc, err := t.Exec(p, true, []string{"-evv"}) | 23 | enc, err := t.Exec("encode", p, true, []string{"-evv"}) |
24 | if err != nil { | 24 | if err != nil { |
25 | g.Panic(err) | 25 | g.Panic(err) |
26 | } | 26 | } |
@@ -34,7 +34,7 @@ func smokeTest(r *xdelta.Runner, p *xdelta.Program) { | |||
34 | g.Panic(err) | 34 | g.Panic(err) |
35 | } | 35 | } |
36 | 36 | ||
37 | dec, err := t.Exec(p, true, []string{"-dvv"}) | 37 | dec, err := t.Exec("decode", p, true, []string{"-dvv"}) |
38 | if err != nil { | 38 | if err != nil { |
39 | g.Panic(err) | 39 | g.Panic(err) |
40 | } | 40 | } |
@@ -59,13 +59,13 @@ func smokeTest(r *xdelta.Runner, p *xdelta.Program) { | |||
59 | func offsetTest(r *xdelta.Runner, p *xdelta.Program, bufsize, offset, length int64) { | 59 | func offsetTest(r *xdelta.Runner, p *xdelta.Program, bufsize, offset, length int64) { |
60 | t, g := xdelta.NewTestGroup(r) | 60 | t, g := xdelta.NewTestGroup(r) |
61 | eargs := []string{"-e", "-0", fmt.Sprint("-B", bufsize), "-vv", fmt.Sprint("-W", winsize)} | 61 | eargs := []string{"-e", "-0", fmt.Sprint("-B", bufsize), "-vv", fmt.Sprint("-W", winsize)} |
62 | enc, err := t.Exec(p, true, eargs) | 62 | enc, err := t.Exec("encode", p, true, eargs) |
63 | if err != nil { | 63 | if err != nil { |
64 | g.Panic(err) | 64 | g.Panic(err) |
65 | } | 65 | } |
66 | 66 | ||
67 | dargs := []string{"-d", fmt.Sprint("-B", bufsize), "-vv", fmt.Sprint("-W", winsize)} | 67 | dargs := []string{"-d", fmt.Sprint("-B", bufsize), "-vv", fmt.Sprint("-W", winsize)} |
68 | dec, err := t.Exec(p, true, dargs) | 68 | dec, err := t.Exec("decode", p, true, dargs) |
69 | if err != nil { | 69 | if err != nil { |
70 | g.Panic(err) | 70 | g.Panic(err) |
71 | } | 71 | } |
@@ -78,10 +78,8 @@ func offsetTest(r *xdelta.Runner, p *xdelta.Program, bufsize, offset, length int | |||
78 | t.CopyStreams(enc.Stdout, dec.Stdin) | 78 | t.CopyStreams(enc.Stdout, dec.Stdin) |
79 | t.CompareStreams(dec.Stdout, read, length) | 79 | t.CompareStreams(dec.Stdout, read, length) |
80 | 80 | ||
81 | // TODO: seems possible to use one WriteRstreams call to generate | 81 | xdelta.WriteRstreams(t, "encode", seed, offset, length, enc.Srcin, enc.Stdin) |
82 | // the source and target for both encoder and decoder. Why not? | 82 | xdelta.WriteRstreams(t, "decode", seed, offset, length, dec.Srcin, write) |
83 | xdelta.WriteRstreams(t, seed, offset, length, enc.Srcin, enc.Stdin) | ||
84 | xdelta.WriteRstreams(t, seed, offset, length, dec.Srcin, write) | ||
85 | 83 | ||
86 | t.Wait(g) | 84 | t.Wait(g) |
87 | } | 85 | } |
@@ -96,7 +94,9 @@ func main() { | |||
96 | prog := &xdelta.Program{xdelta3} | 94 | prog := &xdelta.Program{xdelta3} |
97 | 95 | ||
98 | smokeTest(r, prog) | 96 | smokeTest(r, prog) |
99 | offsetTest(r, prog, 4 << 20, 3 << 20, 5 << 20) | 97 | for { |
98 | offsetTest(r, prog, 4 << 20, 3 << 20, 5 << 20) | ||
99 | } | ||
100 | 100 | ||
101 | //offsetTest(r, xdelta.NewTestGroup(), prog, 1 << 31, 1 << 32, 1 << 33) | 101 | //offsetTest(r, xdelta.NewTestGroup(), prog, 1 << 31, 1 << 32, 1 << 33) |
102 | } | 102 | } |