]> Cypherpunks repositories - gostls13.git/commitdiff
compress/flate: improve short writer error test
authorKlaus Post <klauspost@gmail.com>
Sun, 10 Apr 2016 15:16:07 +0000 (17:16 +0200)
committerBrad Fitzpatrick <bradfitz@golang.org>
Sun, 10 Apr 2016 15:59:00 +0000 (15:59 +0000)
This improves the short version of the writer test.

First of all, it has a much quicker setup. Previously that
could take up towards 0.5 second.

Secondly, it will test all compression levels in short mode as well.

Execution time is 1.7s/0.03s for normal/short mode.

Change-Id: I275a21f712daff6f7125cc6a493415e86439cb19
Reviewed-on: https://go-review.googlesource.com/21800
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/compress/flate/writer_test.go

index 633cadf2b7cfa87c97a1b189552506f84b5ad0fa..e4c5c8cc72ba0ae84fd702b67157e04c1be00a7e 100644 (file)
@@ -86,14 +86,18 @@ func (e *errorWriter) Write(b []byte) (int, error) {
 // Test if errors from the underlying writer is passed upwards.
 func TestWriteError(t *testing.T) {
        buf := new(bytes.Buffer)
-       for i := 0; i < 1024*1024; i++ {
+       n := 65536
+       if !testing.Short() {
+               n *= 4
+       }
+       for i := 0; i < n; i++ {
                buf.WriteString(fmt.Sprintf("asdasfasf%d%dfghfgujyut%dyutyu\n", i, i, i))
        }
        in := buf.Bytes()
        // We create our own buffer to control number of writes.
-       copyBuffer := make([]byte, 1024)
+       copyBuffer := make([]byte, 128)
        for l := 0; l < 10; l++ {
-               for fail := 1; fail <= 512; fail *= 2 {
+               for fail := 1; fail <= 256; fail *= 2 {
                        // Fail after 'fail' writes
                        ew := &errorWriter{N: fail}
                        w, err := NewWriter(ew, l)