repair some tests
A recent test for `_bytes` had a memory bug. An old test for weak hash tables had a race between GC and hash-table lookup.
This commit is contained in:
parent
62b8ca3ca7
commit
e2e469240f
|
@ -2270,15 +2270,18 @@
|
||||||
(for/list ([j 4])
|
(for/list ([j 4])
|
||||||
(thread
|
(thread
|
||||||
(lambda ()
|
(lambda ()
|
||||||
|
(define save-keys '())
|
||||||
(for ([i 1000])
|
(for ([i 1000])
|
||||||
(define v (random 100000))
|
(define v (random 100000))
|
||||||
(define k (a v))
|
(define k (a v))
|
||||||
|
(set! save-keys (cons k save-keys))
|
||||||
(hash-set! cht k v)
|
(hash-set! cht k v)
|
||||||
;; Make sure the addition didn't get lost, which
|
;; Make sure the addition didn't get lost, which
|
||||||
;; can happen when a lock is missing:
|
;; can happen when a lock is missing:
|
||||||
(unless (equal? (hash-ref cht k #f) v)
|
(unless (equal? (hash-ref cht k #f) v)
|
||||||
(error "oops")))
|
(error "oops")))
|
||||||
(semaphore-post done)))))
|
(semaphore-post done)
|
||||||
|
save-keys))))
|
||||||
|
|
||||||
(for-each sync ths)
|
(for-each sync ths)
|
||||||
|
|
||||||
|
|
|
@ -533,10 +533,14 @@
|
||||||
(test 107 ptr-ref v _intptr))
|
(test 107 ptr-ref v _intptr))
|
||||||
|
|
||||||
;; Test _bytes and _bytes/nul-terminated
|
;; Test _bytes and _bytes/nul-terminated
|
||||||
|
(let ([p (malloc 8)])
|
||||||
|
(memcpy p #"hi, all\0" 8)
|
||||||
|
(test #"hi, all" cast p _pointer _bytes)
|
||||||
|
(test #"hi, all" cast p _pointer _bytes/nul-terminated))
|
||||||
(let ([p (malloc 8)])
|
(let ([p (malloc 8)])
|
||||||
(memcpy p #"hi, all!" 8)
|
(memcpy p #"hi, all!" 8)
|
||||||
(test #"hi, all!" cast p _pointer _bytes)
|
(test #"hi, all!" cast p _pointer (_bytes o 8))
|
||||||
(test #"hi, all!" cast p _pointer _bytes/nul-terminated))
|
(test #"hi, all!" cast p _pointer (_bytes/nul-terminated o 8)))
|
||||||
(let* ([strdup (get-ffi-obj 'strdup #f (_fun _bytes/nul-terminated -> _pointer))]
|
(let* ([strdup (get-ffi-obj 'strdup #f (_fun _bytes/nul-terminated -> _pointer))]
|
||||||
[p (strdup #"howdy...")])
|
[p (strdup #"howdy...")])
|
||||||
(test #"howdy..." cast p _pointer _bytes)
|
(test #"howdy..." cast p _pointer _bytes)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user