From 95b9c7281b9c067936ae096db191774410585ab1 Mon Sep 17 00:00:00 2001 From: yuzou Date: Thu, 4 Feb 2016 16:14:35 +0800 Subject: [PATCH] read the actual number of bytes according to the initial size. Signed-off-by: yuzou --- docs/storage/driver/testsuites/testsuites.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/storage/driver/testsuites/testsuites.go b/docs/storage/driver/testsuites/testsuites.go index 5c34cca63..b178cb3da 100644 --- a/docs/storage/driver/testsuites/testsuites.go +++ b/docs/storage/driver/testsuites/testsuites.go @@ -1184,7 +1184,11 @@ func (rr *randReader) Read(p []byte) (n int, err error) { rr.m.Lock() defer rr.m.Unlock() - n = copy(p, randomContents(int64(len(p)))) + toread := int64(len(p)) + if toread > rr.r { + toread = rr.r + } + n = copy(p, randomContents(toread)) rr.r -= int64(n) if rr.r <= 0 {