diff options
Diffstat (limited to 'xdelta3/go')
-rw-r--r-- | xdelta3/go/src/regtest.go | 37 | ||||
-rw-r--r-- | xdelta3/go/src/xdelta/test.go | 14 |
2 files changed, 30 insertions, 21 deletions
diff --git a/xdelta3/go/src/regtest.go b/xdelta3/go/src/regtest.go index 6497166..b028ed5 100644 --- a/xdelta3/go/src/regtest.go +++ b/xdelta3/go/src/regtest.go | |||
@@ -10,8 +10,8 @@ import ( | |||
10 | 10 | ||
11 | const ( | 11 | const ( |
12 | blocksize = 1<<16 | 12 | blocksize = 1<<16 |
13 | winsize = 1<<26 | 13 | winsize = 1<<22 |
14 | xdelta3 = "/volume/home/jmacd/src/xdelta-64bithash/xdelta3/build/x86_64-pc-linux-gnu-m64/usize64/xoff64/xdelta3" | 14 | xdelta3 = "/volume/home/jmacd/src/xdelta-devel/xdelta3/xdelta3" |
15 | seed = 1422253499919909358 | 15 | seed = 1422253499919909358 |
16 | ) | 16 | ) |
17 | 17 | ||
@@ -20,32 +20,32 @@ func smokeTest(r *xdelta.Runner, t *xdelta.TestGroup, 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 | run, err := r.Exec(p, true, []string{"-evv"}) | 23 | enc, err := r.Exec(p, true, []string{"-evv"}) |
24 | if err != nil { | 24 | if err != nil { |
25 | t.Panic(err) | 25 | t.Panic(err) |
26 | } | 26 | } |
27 | encodeout := t.Drain(run.Stdout, "encode.stdout") | 27 | encodeout := t.Drain(enc.Stdout, "encode.stdout") |
28 | t.Empty(run.Stderr, "encode") | 28 | t.Empty(enc.Stderr, "encode") |
29 | 29 | ||
30 | t.Write("encode.stdin", run.Stdin, []byte(target)) | 30 | t.Write("encode.stdin", enc.Stdin, []byte(target)) |
31 | t.Write("encode.srcin", run.Srcin, []byte(source)) | 31 | t.Write("encode.srcin", enc.Srcin, []byte(source)) |
32 | 32 | ||
33 | if err := run.Cmd.Wait(); err != nil { | 33 | if err := enc.Cmd.Wait(); err != nil { |
34 | t.Panic(err) | 34 | t.Panic(err) |
35 | } | 35 | } |
36 | 36 | ||
37 | run, err = r.Exec(p, true, []string{"-dvv"}) | 37 | dec, err := r.Exec(p, true, []string{"-dvv"}) |
38 | if err != nil { | 38 | if err != nil { |
39 | t.Panic(err) | 39 | t.Panic(err) |
40 | } | 40 | } |
41 | 41 | ||
42 | decodeout := t.Drain(run.Stdout, "decode.stdout") | 42 | decodeout := t.Drain(dec.Stdout, "decode.stdout") |
43 | t.Empty(run.Stderr, "decode") | 43 | t.Empty(dec.Stderr, "decode") |
44 | 44 | ||
45 | t.Write("decode.stdin", run.Stdin, <-encodeout) | 45 | t.Write("decode.stdin", dec.Stdin, <-encodeout) |
46 | t.Write("decode.srcin", run.Srcin, []byte(source)) | 46 | t.Write("decode.srcin", dec.Srcin, []byte(source)) |
47 | decoded := string(<-decodeout) | 47 | decoded := string(<-decodeout) |
48 | if err := run.Cmd.Wait(); err != nil { | 48 | if err := dec.Cmd.Wait(); err != nil { |
49 | t.Panic(err) | 49 | t.Panic(err) |
50 | } | 50 | } |
51 | if decoded != target { | 51 | if decoded != target { |
@@ -55,9 +55,9 @@ func smokeTest(r *xdelta.Runner, t *xdelta.TestGroup, p *xdelta.Program) { | |||
55 | fmt.Println("Smoketest pass") | 55 | fmt.Println("Smoketest pass") |
56 | } | 56 | } |
57 | 57 | ||
58 | func offsetTest(r *xdelta.Runner, t *xdelta.TestGroup, p *xdelta.Program, offset, bufsize, length int64) { | 58 | func offsetTest(r *xdelta.Runner, t *xdelta.TestGroup, p *xdelta.Program, bufsize, offset, length int64) { |
59 | t.Add(1) | 59 | t.Add(1) |
60 | eargs := []string{"-e", "-1", "-N", fmt.Sprint("-B", bufsize), "-vv", fmt.Sprint("-W", winsize)} | 60 | eargs := []string{"-e", "-0", fmt.Sprint("-B", bufsize), "-vv", fmt.Sprint("-W", winsize)} |
61 | enc, err := r.Exec(p, true, eargs) | 61 | enc, err := r.Exec(p, true, eargs) |
62 | if err != nil { | 62 | if err != nil { |
63 | t.Panic(err) | 63 | t.Panic(err) |
@@ -78,7 +78,7 @@ func offsetTest(r *xdelta.Runner, t *xdelta.TestGroup, p *xdelta.Program, offset | |||
78 | 78 | ||
79 | // TODO: seems possible to use one WriteRstreams call to generate | 79 | // TODO: seems possible to use one WriteRstreams call to generate |
80 | // the source and target for both encoder and decoder. Why not? | 80 | // the source and target for both encoder and decoder. Why not? |
81 | xdelta.WriteRstreams(t, seed, offset, length, enc.Srcin, enc. Stdin) | 81 | xdelta.WriteRstreams(t, seed, offset, length, enc.Srcin, enc.Stdin) |
82 | xdelta.WriteRstreams(t, seed, offset, length, dec.Srcin, write) | 82 | xdelta.WriteRstreams(t, seed, offset, length, dec.Srcin, write) |
83 | 83 | ||
84 | if err := enc.Cmd.Wait(); err != nil { | 84 | if err := enc.Cmd.Wait(); err != nil { |
@@ -100,6 +100,7 @@ func main() { | |||
100 | prog := &xdelta.Program{xdelta3} | 100 | prog := &xdelta.Program{xdelta3} |
101 | 101 | ||
102 | smokeTest(r, xdelta.NewTestGroup(), prog) | 102 | smokeTest(r, xdelta.NewTestGroup(), prog) |
103 | offsetTest(r, xdelta.NewTestGroup(), prog, 4 << 20, 3 << 20, 5 << 20) | ||
103 | 104 | ||
104 | offsetTest(r, xdelta.NewTestGroup(), prog, 1 << 31, 1 << 32, 1 << 33) | 105 | //offsetTest(r, xdelta.NewTestGroup(), prog, 1 << 31, 1 << 32, 1 << 33) |
105 | } | 106 | } |
diff --git a/xdelta3/go/src/xdelta/test.go b/xdelta3/go/src/xdelta/test.go index 9eb47f6..e853554 100644 --- a/xdelta3/go/src/xdelta/test.go +++ b/xdelta3/go/src/xdelta/test.go | |||
@@ -31,6 +31,8 @@ type Runner struct { | |||
31 | 31 | ||
32 | type TestGroup struct { | 32 | type TestGroup struct { |
33 | sync.WaitGroup | 33 | sync.WaitGroup |
34 | sync.Mutex | ||
35 | errs []error | ||
34 | } | 36 | } |
35 | 37 | ||
36 | type Run struct { | 38 | type Run struct { |
@@ -42,10 +44,17 @@ type Run struct { | |||
42 | Stderr io.ReadCloser | 44 | Stderr io.ReadCloser |
43 | } | 45 | } |
44 | 46 | ||
47 | |||
45 | func (t *TestGroup) Panic(err error) { | 48 | func (t *TestGroup) Panic(err error) { |
49 | t.Lock() | ||
50 | t.errs = append(t.errs, err) | ||
51 | t.Unlock() | ||
46 | t.Done() // For the caller | 52 | t.Done() // For the caller |
47 | t.Wait() | 53 | t.Wait() |
48 | panic(err) | 54 | for _, e := range t.errs { |
55 | fmt.Println(e) | ||
56 | } | ||
57 | panic(fmt.Sprintf("%d errors", len(t.errs))) | ||
49 | } | 58 | } |
50 | 59 | ||
51 | func NewTestGroup() *TestGroup { | 60 | func NewTestGroup() *TestGroup { |
@@ -185,9 +194,8 @@ func (r *Runner) Exec(p *Program, srcfifo bool, flags []string) (*Run, error) { | |||
185 | run.Cmd.Path = p.Path | 194 | run.Cmd.Path = p.Path |
186 | run.Cmd.Args = append(args, flags...) | 195 | run.Cmd.Args = append(args, flags...) |
187 | run.Cmd.Dir = r.Testdir | 196 | run.Cmd.Dir = r.Testdir |
188 | run.Cmd.Start() | ||
189 | 197 | ||
190 | return run, nil | 198 | return run, run.Cmd.Start() |
191 | } | 199 | } |
192 | 200 | ||
193 | func writeFifo(srcfile string, read io.Reader) error { | 201 | func writeFifo(srcfile string, read io.Reader) error { |