[racket-dev] [plt] Push #26219: master branch updated
Danny, have you considered using random testing to compare the C
implementation to the Racket one?
You have a great example of a bug to evaluate a random testing strategy!
Robby
On Tue, Feb 5, 2013 at 6:03 PM, <dyoo at racket-lang.org> wrote:
> dyoo has updated `master' from bf2768f2c5 to c6775cc060.
> http://git.racket-lang.org/plt/bf2768f2c5..c6775cc060
>
> =====[ 2 Commits ]======================================================
> Directory summary:
> 7.9% collects/file/
> 92.0% collects/tests/file/
>
> ~~~~~~~~~~
>
> 31b6648 Danny Yoo <dyoo at racket-lang.org> 2013-02-04 23:53
> :
> | Add test case to show bug with inflate.
> |
> | related to PR 13489.
> :
> M collects/tests/file/gzip.rkt | 52
> +++++++++++++++++++++++++++++++++++++++++
>
> ~~~~~~~~~~
>
> c6775cc Danny Yoo <dyoo at racket-lang.org> 2013-02-04 23:45
> :
> | Fix to inflate: treat EOF as a character, as in the C code.
> |
> | closes PR 13489.
> |
> | In the C code, inflate is allowed to peek at least one character
> | beyond the extent of a deflated byte sequence. The thread related to
> | the bug report of PR 13489 documents that deflate can peek beyond EOF.
> :
> M collects/file/gunzip.rkt | 3 ++-
>
> =====[ Overall Diff ]===================================================
>
> collects/file/gunzip.rkt
> ~~~~~~~~~~~~~~~~~~~~~~~~
> --- OLD/collects/file/gunzip.rkt
> +++ NEW/collects/file/gunzip.rkt
> @@ -278,7 +278,8 @@
> (set! buf-pos MAX-LOOKAHEAD))
> (let ([got (peek-bytes-avail! buffer buf-pos #f input-port
> buf-pos BUFFER-SIZE)])
> (if (eof-object? got)
> - (error 'inflate "unexpected end of file")
> + (begin (bytes-set! buffer buf-pos 255)
> + (set! buf-max (add1 buf-pos)))
> (set! buf-max (+ buf-pos got))))
> (READBITS n))
> (let ([v (bytes-ref buffer buf-pos)])
>
> collects/tests/file/gzip.rkt
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> --- OLD/collects/tests/file/gzip.rkt
> +++ NEW/collects/tests/file/gzip.rkt
> @@ -21,6 +21,56 @@
> (test (< (/ o i) ratio))))))
> => buf))
>
> +
> +
> +(define (test-degenerate-input-1)
> + ;; The content here causes fails in Racket <= 5.3.2. This test case
> + ;; makes sure it doesn't break now.
> + (define sample-file
> + (bytes-append #"(\"5.3.2\"
> (\"ab7f6f4533252566bc62383ca395f8272851592b\""
> + #" . \"9364523f1c28f962fb967025aa140670c9b5b9a5\") "
> +
> #"#\"/Users/dyoo/work/minipascal/minipascal/lang/../semantics.rkt\""
> + #" (collects #\"syntax\" #\"parse\" #\"private\"
> #\"runtime-report.rkt\")"
> + #"
> #\"/Users/dyoo/work/minipascal/minipascal/lang/reader.rkt\")\n"))
> +
> + (define compressed (open-output-bytes))
> +
> + (deflate (open-input-bytes sample-file) compressed)
> +
> + (define inflated (open-output-bytes))
> + (define ip (open-input-bytes (get-output-bytes compressed)))
> + (inflate ip inflated)
> +
> + (test (get-output-bytes inflated) => sample-file)
> + (test (read-byte ip) => eof))
> +
> +
> +(define (test-degenerate-input-2)
> + ;; Like the first test, but we add a zero byte at the end. We make
> sure the inflater
> + ;; doesn't consume the extra byte.
> + (define sample-file
> + (bytes-append #"(\"5.3.2\"
> (\"ab7f6f4533252566bc62383ca395f8272851592b\""
> + #" . \"9364523f1c28f962fb967025aa140670c9b5b9a5\") "
> +
> #"#\"/Users/dyoo/work/minipascal/minipascal/lang/../semantics.rkt\""
> + #" (collects #\"syntax\" #\"parse\" #\"private\"
> #\"runtime-report.rkt\")"
> + #"
> #\"/Users/dyoo/work/minipascal/minipascal/lang/reader.rkt\")\n"))
> +
> + (define compressed (open-output-bytes))
> +
> + (deflate (open-input-bytes sample-file) compressed)
> +
> + (define inflated (open-output-bytes))
> + (define ip (open-input-bytes (bytes-append (get-output-bytes
> compressed) (bytes 0))))
> + (inflate ip inflated)
> +
> + (test (get-output-bytes inflated) => sample-file)
> + (test (read-byte ip) => 0)
> + (test (read-byte ip) => eof))
> +
> +
> +
> +
> +
> (define (test-big-file)
> (define big-file
> (build-path (collection-path "drracket/private") "unit.rkt"))
> @@ -31,6 +81,8 @@
> (define (rand-bytes)
> (list->bytes (for/list ([j (in-range (random 1000))]) (random 256))))
> (test-big-file)
> + (test-degenerate-input-1)
> + (test-degenerate-input-2)
> (for ([i (in-range 100)]) (id* (rand-bytes)))
> (regression-test))
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/dev/archive/attachments/20130205/dbb56ebe/attachment.html>