diff options
author | Joshua MacDonald <josh.macdonald@gmail.com> | 2015-02-01 21:20:03 -0800 |
---|---|---|
committer | Joshua MacDonald <josh.macdonald@gmail.com> | 2015-02-01 21:20:03 -0800 |
commit | 1e7f716f0854ad67df9a77341a829c84e4e6b1e5 (patch) | |
tree | 3f64e096859c7b2fa47f5bbaf56f7adbee9a57cc /xdelta3/go/src/regtest.go | |
parent | b55fcf3dc4c775ef35dce116ab23d35a5f9ff326 (diff) |
regtest.go exhibits bad compression >2GB boundary
Diffstat (limited to 'xdelta3/go/src/regtest.go')
-rw-r--r-- | xdelta3/go/src/regtest.go | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/xdelta3/go/src/regtest.go b/xdelta3/go/src/regtest.go index d31e905..52547e1 100644 --- a/xdelta3/go/src/regtest.go +++ b/xdelta3/go/src/regtest.go | |||
@@ -1,16 +1,20 @@ | |||
1 | package main | 1 | package main |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "bufio" | ||
4 | "bytes" | 5 | "bytes" |
5 | "fmt" | 6 | "fmt" |
6 | "io" | 7 | "io" |
7 | "io/ioutil" | 8 | "io/ioutil" |
9 | "os" | ||
10 | |||
8 | "xdelta" | 11 | "xdelta" |
9 | ) | 12 | ) |
10 | 13 | ||
11 | const ( | 14 | const ( |
12 | blocksize = 1<<20 | 15 | blocksize = 1<<16 |
13 | prog = "/Users/jmacd/src/xdelta/xdelta3/xdelta3" | 16 | winsize = 1<<26 |
17 | prog = "/Users/jmacd/src/xdelta/xdelta3/build/m64/64size-64off/xdelta3" | ||
14 | seed = 1422253499919909358 | 18 | seed = 1422253499919909358 |
15 | ) | 19 | ) |
16 | 20 | ||
@@ -26,10 +30,14 @@ func drain(f io.ReadCloser) <-chan []byte { | |||
26 | return c | 30 | return c |
27 | } | 31 | } |
28 | 32 | ||
29 | func empty(f io.ReadCloser) { | 33 | func empty(f io.ReadCloser, desc string) { |
30 | go func() { | 34 | go func() { |
31 | if _, err := ioutil.ReadAll(f); err != nil { | 35 | s := bufio.NewScanner(f) |
32 | panic(err) | 36 | for s.Scan() { |
37 | os.Stderr.Write([]byte(fmt.Sprint(desc, ": ", s.Text(), "\n"))) | ||
38 | } | ||
39 | if err := s.Err(); err != nil { | ||
40 | fmt.Println("error reading input:", err) | ||
33 | } | 41 | } |
34 | }() | 42 | }() |
35 | } | 43 | } |
@@ -52,7 +60,7 @@ func smokeTest(r *xdelta.Runner, p *xdelta.Program) { | |||
52 | panic(err) | 60 | panic(err) |
53 | } | 61 | } |
54 | encodeout := drain(run.Stdout) | 62 | encodeout := drain(run.Stdout) |
55 | empty(run.Stderr) | 63 | empty(run.Stderr, "encode") |
56 | 64 | ||
57 | write(run.Stdin, []byte(target)) | 65 | write(run.Stdin, []byte(target)) |
58 | write(run.Srcin, []byte(source)) | 66 | write(run.Srcin, []byte(source)) |
@@ -67,7 +75,7 @@ func smokeTest(r *xdelta.Runner, p *xdelta.Program) { | |||
67 | } | 75 | } |
68 | 76 | ||
69 | decodeout := drain(run.Stdout) | 77 | decodeout := drain(run.Stdout) |
70 | empty(run.Stderr) | 78 | empty(run.Stderr, "decode") |
71 | 79 | ||
72 | write(run.Stdin, <-encodeout) | 80 | write(run.Stdin, <-encodeout) |
73 | write(run.Srcin, []byte(source)) | 81 | write(run.Srcin, []byte(source)) |
@@ -121,12 +129,12 @@ func compareStreams(r1 io.ReadCloser, r2 io.ReadCloser, length int64) { | |||
121 | } | 129 | } |
122 | } | 130 | } |
123 | 131 | ||
124 | func offsetTest(r *xdelta.Runner, p *xdelta.Program, offset, length int64) { | 132 | func offsetTest(r *xdelta.Runner, p *xdelta.Program, offset, bufsize, length int64) { |
125 | enc, err := r.Exec(p, true, []string{"-e"}) | 133 | enc, err := r.Exec(p, true, []string{"-e", "-1", "-n", fmt.Sprint("-B", bufsize), "-vv", fmt.Sprint("-W", winsize)}) |
126 | if err != nil { | 134 | if err != nil { |
127 | panic(err) | 135 | panic(err) |
128 | } | 136 | } |
129 | dec, err := r.Exec(p, true, []string{"-d"}) | 137 | dec, err := r.Exec(p, true, []string{"-d", fmt.Sprint("-B", bufsize), "-vv", fmt.Sprint("-W", winsize)}) |
130 | if err != nil { | 138 | if err != nil { |
131 | panic(err) | 139 | panic(err) |
132 | } | 140 | } |
@@ -136,8 +144,8 @@ func offsetTest(r *xdelta.Runner, p *xdelta.Program, offset, length int64) { | |||
136 | go copyStreams(enc.Stdout, dec.Stdin) | 144 | go copyStreams(enc.Stdout, dec.Stdin) |
137 | go compareStreams(dec.Stdout, read, length) | 145 | go compareStreams(dec.Stdout, read, length) |
138 | 146 | ||
139 | empty(enc.Stderr) // Use these? | 147 | empty(enc.Stderr, "encode") |
140 | empty(dec.Stderr) | 148 | empty(dec.Stderr, "decode") |
141 | 149 | ||
142 | // TODO: seems possible to use one WriteRstreams call to generate | 150 | // TODO: seems possible to use one WriteRstreams call to generate |
143 | // the source and target for both encoder and decoder. Why not? | 151 | // the source and target for both encoder and decoder. Why not? |
@@ -163,5 +171,5 @@ func main() { | |||
163 | 171 | ||
164 | smokeTest(r, prog) | 172 | smokeTest(r, prog) |
165 | 173 | ||
166 | offsetTest(r, prog, 0, 1024 << 20) | 174 | offsetTest(r, prog, 1 << 31, 1 << 32, 1 << 33) |
167 | } | 175 | } |